Leveraging browser caching with Caddy

To get the maximum performance from your site, you need to make the user's browser cache your site. Google Pagespeed and tools like it complain a lot when that doesn't happen. To activate browser caching, set appropriate headers. There are basically three methods to choose from: Cache-Control Expires Etag Expires… »

How to not get hacked

There's a lot of talk about people being hacked, especially on social media. In Sweden, SVT (Swedish PBS) even made a series about it called Dold (Hidden). They had some good advice about passwords - like don't use the same everywhere. They also had some questionable ones - like change… »

Shrink your virtual hard drive file in Docker for MacOS

I really like Docker for MacOS. Not having to explicitly run a virtual machine acting as your Docker host saves a lot of time and headaches. However, Docker for MacOS is still doing just that - running a virtual machine that is your Docker host. And as with all virtual… »

Zeit - a nice scheduler for Node.js

At one point or another you want to stuff in your code to happen at intervals. The requirements usually vary - it could be at fixed points in time, once every day, a fixed number of times, a regular interval between starts, a regular intervals between the last finish and… »

Make Array.forEach synchronous even with an asynchronous body

Array iterators in JavaScript are beautiful things, if you don't know about them read up on them here. Array.forEach is handy for doing something to each item in an array synchronously and in order. So when forEach returns you can be sure that "something" was done to… »

How to get Wordpress working with HTTPS behind a reverse proxy

"I am Anders, I am a PHP user." Support group: "Hi Anders!" In my last post I described how to get HTTP/2 working with Caddy. Now I'm going to tell you how to get a Wordpress blog working behind it. Caddy is called a reverse… »

How to use Caddy to get HTTP/2 support in Rancher

After having used Tutum and Docker Cloud for my hobby projects I've now switched to Rancher. It's basically the same thing as Docker Cloud, but it's self hosted and gives you better control (and a lower price tag). For those that don't know, Rancher is a Docker orchestration tool handling… »

json-server: npm package to mock a JSON REST API

What comes first - the front-end chicken or the API egg? Well, with the npm package json-server you can mock the egg to be able to develop your chicken independently. What json-server does is expose a static json file as a REST API, complete with routes for single items, POSTing… »

Two Nifty iPhone Apps for Google Analytics

As a developer you often want to keep track of your services statistics. Up until now there has been no official app for Google Analytics for iOS, but Google has finally released one: It's free on Itunes. Google Antalytics on Itunes, free As a bonus, there's also an app that… »

Closure: My new Superhero

His power: to always know what "this" is.… »

Managing Users in Self-Hosted Drone.IO 0.2.0

There is a bug in user handling the current release (0.2.0) of open-source Drone.IO. The only way of adding users to you Drone server (except yourself - that you add in the install process) is by inviting them via email. Problem is that the invitation emails lead… »

Host Your Own Continuous Integration Server with Drone

Drone.io is an excellent build and deployment server for modern web applications built (supports Nodejs, Go, PHP, C, Scala and many others). It's integrated with Github and Bitbucket, so with a simple push you can have your repository automatically built, tested and deployed. Drone has a hosted service that's… »

Three Ways of Dealing with CORS

What is CORS and why do we need it? AJAX has been popular for over 10 years now, and is a part of almost any web site that is anything more than a static display case for a digital brochure. Requests from in-page script languages such as JavaScript have to… »

How to Fix SoundCloud is Gold in WordPress 3.9

I don't often admit it, but I actually use WordPress for my other blog: http://www.osirisguitar.com Usually, upgrading to a new WordPress version is smooth sailing but this time the editor broke down completely - TinyMce didn't show up at all, just a white empty space. Turns out… »

Watch out for Erlang-style callbacks in RabbitMQ

When using RabbitMQ, you're probably going to use the amqp-node library. It's good even though it really only has the bare minumum of functions you need for Rabbit connectivity. The biggest gotcha of the all though is that this library, at least for some functions, uses a different callback pattern… »

Mocking AngularJS services in unit test

When unit testing controllers in AngularJS, there are good mechanisms in place for mocking injected services, as such: var controller; var myServiceMock = { myServiceMethod: sinon.stub() }; module('myApp'); inject(function($rootScope, $controller) { var scope = $rootScope.$new(); var controller = $controller('MyController', { $scope: scope, MyService: myServiceMock }); } } So now we've created a mock of… »