Testing with underscorejs

Underscore is an awesome functional javascript library but I think it needs a flush feature so we can easily test our applications that use it. A underscore.flush method would allow you to test the different cases without having to make your unit tests slow. This could work similar to angular.js's $httpBackend.flush(). Heres an implementation of what I mean....

<span title='2013-07-01 02:09:00.002 -0700 -0700'>July 1, 2013</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

Server updates: Email notifications and 1-click Apply.

These days Im getting update notifications via email, and now applying those updates with one click. I've had email notifications for a while, But lately I got annoyed that'd have to login to my server and run the `apt-get dist-upgrade` command. I noticed that I wasn't even doing it. I was just ignoring the updates, which is not good practice! So I've turned the 5minute job of logging in and applying the update into a 1 second job....

<span title='2013-06-01 00:12:00 -0700 -0700'>June 1, 2013</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

How I Sync to my mac to my android

I used to use SyncMe Wireless but now I have a mac and SyncMe doesnt support the afp file sharing protocol. So I run a ssh server on the phone and use rsync over ssh to sync the folders. This is a different approach. Instead of the phone asking the computer when the files have changed. I run rsync from my computer which connects to the phone and does the update....

<span title='2013-01-27 03:06:00.003 -0800 -0800'>January 27, 2013</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

Adding version info to your javascript app

When deploying apps is helpful to know exactly what version your looking at. Where it might be the one on your server that you deployed months ago or the version you have checked out on your development machine. With java / maven applications you can configure the maven jar plugin to append this information to the  jar META-INF. I havent found anything like this yet for javascript / angular.js but its easy to craft a script to append it like this....

<span title='2013-01-20 23:16:00 -0800 -0800'>January 20, 2013</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

One click deploy and rollback From shell

Heres how I auto deploy my app, and how i roll back if something goes wrong. sh scripts/deploy.sh deploy sh scripts/deploy.sh deploy rollback It couldnt be easier. #!/bin/bash TARGET=example.com TARGET_BASE=/var/www/p TARGET_ARCHIVE=$TARGET_BASE/analyse.tgz TARGET_LOCATION=$TARGET_BASE/analyse case "$1" in deploy) echo "building" yeoman build if [ ! -d dist ]; then echo "yeoman didnt build" exit 1 fi cd dist tar -czf ../dist.tgz * cd .. echo "backing up" ssh $TARGET << EOF...

<span title='2013-01-20 22:58:00.001 -0800 -0800'>January 20, 2013</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

Dont make me think!

Part of my app requires extracting a date from the line of text. To do this I use a regular expression to pick the substring that has the date, then use a date format to parse it. Heres a screen shot my first version of getting that information. The user inputs both the regex and the date format. After a while it became clear to me that the regex could be derived from the date format....

<span title='2013-01-20 22:05:00 -0800 -0800'>January 20, 2013</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

e2e testing in angular.js with a mocked httpBackend

Angular.js is a great framework used to make web apps, by manipulating the DOM and integrating with a rest backend. Edit: You should use ngMockE2E rather than the technique described bellow. They are verry similar. ngMockE2E is the more supported. An Example of using can be found github.com/~~/angular_e2e_http/tree/ngMockE2E An Angular.js app has 3 main parts. *  html where additional markup is used to populate a template with data. * The controller's which control the templates and the services....

<span title='2012-09-12 00:07:00 -0700 -0700'>September 12, 2012</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

Earthquake Data

I was in my first big earthquake the other day. Being my first I didn't know if it felt like a big one or not. I jumped on geonet.org.nz looking for the answer. GeoNet have this awesome heat map of earthquakes around NZ I thought it'd be cool to make a video of it. To show how that changed over time. So I did. Unfortunately I've only got the aftermath. But I'm sussed to make cool videos next time....

<span title='2012-07-05 02:39:00 -0700 -0700'>July 5, 2012</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

How 2degrees messed up their website

When on a small screen, the 2degrees site puts some of the content to the left of screen where you can’t see or click it. I noticed this on my smart phone when trying to top up. Here what It looks like on my desktop. Notice the important “Top Up” button in the navigation menu on the left. This cannot be clicked on my phone. The web page is made with a main div that is the first thing in the body of the html who’s job is to center the content....

<span title='2012-06-09 00:17:00 -0700 -0700'>June 9, 2012</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

Working Hours Graph - Life Logger

I’ve been using Life Logger to track how long I spend at work. It has a pretty rudimentary way to get summaries from it. I wanted to see a graph of how long I’ve spent at work in a graph so I exported the database and made my own. Here’s what I Came Up With. If my boss sees this, its all those public holidays that bring those hours down....

<span title='2012-05-23 03:38:00.002 -0700 -0700'>May 23, 2012</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

Ubuntu updates visualization

I was wondering if there would be lots of updates to Ubuntu leading up to the release of 11/4 and thought I could data mine this to find out. So I made a visualization to see if that was the case, turns out the opposite is true. There has been a distinct lack of updates in the last couple of months. At least in the main repository. Heres the visualization I made....

<span title='2012-05-06 07:55:00 -0700 -0700'>May 6, 2012</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

Problem with corrupt files and eCrypt

I've been noticing some strange behaviour on my Ubuntu laptop lately. In Google Chrome I get logged out whenever I close the browser, even though set it to remember me. I've also seen a lot of these log messages from eCryptfs which encrypts my home directory. Apr 14 10:29:41 stephen-ThinkPad-T520 kernel: [170037.012495] Valid eCryptfs headers not found in file header region or xattr region, inode 524280 Apr 14 10:29:41 stephen-ThinkPad-T520 kernel: [170037....

<span title='2012-04-14 20:56:00 -0700 -0700'>April 14, 2012</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

How to find an open source project to work on using github search.

You can search for popular projects that have TODO notes in the source code To search for popular projects execute this search query for repositories. followers:[1 TO *] followers:[1 TO *] If you judge popularity by the number of followers. To search for the TODO notes in that repo execute this search query for code. TODO repo:django/django Because the code is indexed differently to the repository there is no direct relationship from the code to the repositories followers....

<span title='2012-03-08 00:57:00.001 -0800 -0800'>March 8, 2012</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

Router bandwidth usage monitoring per user

My flat has a shared internet connection, and we have a bandwidth cap, If we go over our cap it costs us all extra money. There's this great little script wrtbwmon for DD-WRT that shows total bandwidth usage. There are other projects that do a nicer job but they require different router firmware, that doesn't support my router. The main imitation of Wrtbwmon is that it doesn't show how usage is changing over time. If someone suddenly uses lots of our bandwidth cap I need to be able to tell them when it was....

<span title='2012-01-21 12:34:00 -0800 -0800'>January 21, 2012</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

Concordion acceptance tests from Scala

Concordion is a great test automation framework written in Java. Scala is a great functional programming language which runs on the JVM. Scala can easily use Java code, which makes using Concordion from Scala very simple. However there was one feature of Concordion that gave us some trouble. Java Concordion fixtures can return objects with public variables that Concordion can use to make assertions. But in Scala you cant really create public class variables. Scala creates public getter and setter methods with the name of the variable and keeps the variable private....

<span title='2012-01-18 02:11:00 -0800 -0800'>January 18, 2012</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

What should a Distributed Operating System should look like and how close are we to making one

Overview - A Distributed Operating SystemA Distributed operating system is a system that operates a distributed collection of computers, a cluster. Some require a single controller, but that shouldn't be necessary and isn't an interesting part of the problem. The system runs programmes and manages resources. The system should completely abstract the view of the hardware away from the software. Fault tolerance, scalability and redundancyThe cluster may be heterogeneous, nodes may go offline, new nodes may come online....

<span title='2011-09-19 06:58:00 -0700 -0700'>September 19, 2011</span>&nbsp;·&nbsp;9 min&nbsp;·&nbsp;Stephen Nancekivell

Server updates: Automate it!

A Ubuntu automatic update script with email notifications. We all know that we should keep our systems up to date with security patches and whatnot. This is something that we don't thing about on desktop computers, our operating systems (windows/ubuntu) do it automatically for us, giving us popup notifications when these are ready. But on servers we never log in to get those notifications, as long as things keep running we don't care. You may get hacked one day and become extra vigilant for a while, but that's not going to last, were all lazy....

<span title='2011-07-28 23:52:00 -0700 -0700'>July 28, 2011</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

Document Browsing and Comparison

I've been looking at ways to organize a document set. Im particularly interested in comparing and clustering documents based on their content. In these experiments a test set of Wikipedia documents, most of the documents come from a keyword search about fish with some random ones to mix it up. For comparing these documents I’ve used the categories taken from wikipedia and mined the important words. Each document can belong to multiple categories....

<span title='2011-06-21 18:15:00 -0700 -0700'>June 21, 2011</span>&nbsp;·&nbsp;5 min&nbsp;·&nbsp;Stephen Nancekivell

Bike Pics Wallpaper Android app

Well i did it again, i made another android app. Check it out in the market "Bike Pics Wallpaper".I should probably come up with better names :( oh well, no surprises as to what it does. It gets a wallpaper from bikepics.com and automatically sets it as the phone wallpaper. Should be kinda fun. I'm hoping that because motorbikes are cool all over the world this will be more popular than my other apps :)I timed how long it took me to code, 10....

<span title='2010-11-28 05:44:00 -0800 -0800'>November 28, 2010</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

TM Watcher Android app

TM Watcher for Trademe.co.nzTM Watcher checks auctions in your Trademe watchlist to see when any of their attributes change, then notify the user. This includes attributes like bid price, end date.--I've put alot more polish into this than ODW, it feels good. I figured out how to have it run something at boot, which has the effect of greatly simplifying the user controls improving the user experience, compared to that of ODW....

<span title='2010-11-14 18:49:00 -0800 -0800'>November 14, 2010</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

One Day Watcher Android app

I finished/published version 1.0 of my first android app today. One Day Watcher.This app automatically checks 1-day.co.nz for you, so you dont have to. It checks for keywords that you set, and gives you notification with the results.Check it out at http://code.google.com/p/one-day-watcher/or search for it on the Android Market.It'll be interesting to see if many people find it useful.

<span title='2010-10-08 02:49:00 -0700 -0700'>October 8, 2010</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

mv with progress bar!

Well not quite use rsync with a quick alias. Countless times have i thought this would be nice, and now i have it :) alias rsynccopy="rsync --partial --progress --append -r"alias rsyncmove="rsync --partial --progress --append --remove-sent-files -r"

<span title='2010-09-28 02:26:00 -0700 -0700'>September 28, 2010</span>&nbsp;·&nbsp;1 min&nbsp;·&nbsp;Stephen Nancekivell

How to restore your nexus one with the original shipping roms then update to 2.2.1

This will remove everything off your device, except stuff on the sd-card. I take no responsibility if you somehow brick the it ;). You will end up running 2.2.1 unrooted. This was written for the at&t nexus one. Im not sure if there are any differences for the other one. You should be able to give this a go, and if the radio doesnt work with this stuff, you can always find the right stuff and re flash it....

<span title='2010-09-28 01:32:00 -0700 -0700'>September 28, 2010</span>&nbsp;·&nbsp;2 min&nbsp;·&nbsp;Stephen Nancekivell

Ext3 file fragmentation on my server

So I've got this file server/torrent box running raid 5 with 5 discs ATM, but i  can add more disks to it when it gets full and have been doing so for the last year. Lately we've been noticing terrible performance from it, like browsing a folder (over samba) could take about 30 seconds to load. Looking into this i found that the files being downloaded slowly by the torrents are getting terribly fragmented,  like, from filefrag...

<span title='2010-06-27 03:13:00 -0700 -0700'>June 27, 2010</span>&nbsp;·&nbsp;4 min&nbsp;·&nbsp;Stephen Nancekivell