Category: Mikael Lofjärd

It has been a bad year for my blog. Early on I started working on a new blogging platform that would also support a number of other content types to better reflect my life. I wanted to host my own data from my running and mountain biking activities and I wanted to review at least a part of all the tech and sporting equipment I've bought over the year. None of this came to pass... ...and I'm quite ashamed... ...and consider it a personal failure. The new platform is still under construction and I'm thinking of breaking it into parts and doing a partial release as soon as possible, though that might still be closer to the end of Q1 2015. New hardware for my office has been ordered a few days ago and I hope I will get some time to do some serious bare knuckle programming done as soon a...
And with summer, my almost year long blog hiatus ends. July 31st 2013 was the day my second daughter was born. Besides installing some long forgotten parts in the server machine, little has happened since then. Well, little has happened with regards to the blog, that is. September 25th marked my 31st birthday and the scale tipped at 90 kilograms. I strapped on my running shoes and started running. Once a week. Then twice a week. For a while I ran three times a week. I also cut all my intake of carbohydrates, except for one beer each weekend, and about two weeks after Christmas the blinking digits underneath my feet presented themselves as 75 kilograms. I've kept on running ever since. Then the year 2014 happened and boy did it happen fast. It's already May and I've yet to write a sing...
My server mostly keeps to itself, chugging along in my apartment storage space, but sometimes I order new parts for it. One such part was the picoPSU I bought several months ago to replace my totally overkill 650W PSU. Essentially, I wanted to replace this: !Really big PSU with this: !Really tiny PSU The Corsair TX-650 has worked without a hitch, but my server is an Atom D525 with a TDP of 12W and its only other hardware is an SSD. It seems like there would be some serious loss of power due to PSU inefficiencies on such small loads. The picoPSU on the other hand is a DC-DC PSU with an external brick rated for 120W loads, and it has proven much more efficient on smaller loads in test around the interwebs. When I finally took the time to switch to the picoPSU, I also got rid of one of...
Here's my latest project: !Sanded down keys It's taking me a lot longer to sand down all the keys with 180 grit sand paper than I originally planned, but a few more hours and I'll be ready for paint. Having kids though, I might not be able to complete it until next weekend. :) Oh and yes; that's a Logitech Wave I'm modifying......
The blog has been silent lately but i certainly have not been sitting still. About a month ago I started to remake the administration area of the blog into something a bit more fashionable (today it consists of a few input boxes and a "publish" button). Halfway through I decided to rewrite it using AngularJS. Needles to say, I'm not quite done with it yet but it's a work in progress and it's going to be awesome. My great friend and fellow coder Mattias spent a long weekend here and we put together a little P2P file sharing site using Node.js, AngularJS and Web RTC data channels. It's really cool but like most things, it needs a little more work. It's up on GitHub though if anyone wants to take a peek at it. The day before yesterday I beefed up security on my server and it's been quite in...
I've been using Google Web Fonts ever since I started building this blog. It's an awesome service with a great user interface and it makes it really easy to add fonts to your web site. Of course I had to find something wrong with it. Earlier this week our company released our new web site. On our Yammer page, one of my colleagues posted a link to a WebPageTest result for it and it fared reasonably well. It got an "F" on the "First Byte Time" test, but that test is really finicky and could just as well show an "A" if you retake the test (as I later became aware). This triggered my inner masochist and I just had to run the same test on this blog. The first result was this: Test | Score ----|:--: First Byte Time | A Keep-alive Enabled | A Compress Transfer | A Compress Images | C Cache st...
Uploading files asynchronously with XMLHttpRequest is a neat trick on its own, but what I really wanted was a nice way to upload images from my phone and/or tablet. The problem with this is that technology is evolving quite rapidly these days and my smartphone has an 8 megapixel camera. 8 megapixel pictures averages around 2.2 MB on my iPhone 5 and Chrome (and others) defaults file uploads with XMLHttpRequest to 1 MB. Now, one can easily find their way around such limitations but then you just run straight into the arms of the next thing limiting your upload sizes; the web server. And even if you would change all the settings, to allow larger file uploads, you'd have to ask yourself if that's what you really want. It wasn't what I wanted. Uploading photos from my phone is awesome since...
Uploading files using HTML forms has always felt a bit off for me. You had to set your encoding to `multipart/form-data` and the synchronous nature of form posts always made it a waiting game when uploading larger files. Then came AJAX and the dawn of "single page applications" and such buzzwords, but file uploads somehow got left behind. Javascript didn't have the access it needed to send files with the `XMLHttpRequest`. Years passed and along came the File API and XMLHttpRequest Level 2 (it seems to be called that again) with its `upload` attribute, support for byte streams and progress events. Today I'm going to show you how to build an asynchronous file uploader with it. We'll start with the HTML part: There's nothing weird going on here; just a regular file selector and a list o...
I've been hacking away at the blog again and made a little nifty photo uploader for the admin area. It resizes the image on the client (browser) before uploading it with Ajax which is great because now I can upload directly from my phone without worrying about file size. The uploader really needs its own blog post but I'm heading out so in the meanwhile, here is a sneak preview of things to come! !Robotics Oh, that's right; inline pictures are working as well. Remember to refresh your browser cache if stuff looks weird. ...
Every blog should have a search box. Not because it's necessary, but because it's fun to implement. A few weeks ago I ran across a small Javascript library called Lunr.js. It's basically a small text indexer that can rank search results and it's written entirely in Javascript, just the way I like it. Setting up an index is really easy: Then you just add some documents to the index: Then you can search for it by simply calling `searchIndex.search('crummy blog');` and that will return an array of objects with the properties `ref` and `score`. `ref` is the `id` property of the indexed document and `score` is, well, how well it scored. The array will be sorted with the highest scoring result first in the array. If you want you can supply a word list to the search index with words tha...