Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am ruudud on github.
  • I am ruudud (https://keybase.io/ruudud) on keybase.
  • I have a public key whose fingerprint is EF97 8A63 DF96 F778 C0C2 263B 1911 C986 E3C1 E737

To claim this, I am signing this object:

#!/bin/bash
# Source files so we can announce stuff
. /mnt/apps/scripts/setenv.sh
. /mnt/apps/scripts/hipchat_notify.sh
if [ $(pidof -x deploy_if_new.sh | wc -w) -gt 2 ]; then
echo "$(date +"%Y-%m-%d %H:%M:%S %Z") Cowardly exiting as deploy_if_new is already running"
exit -1
fi
@ruudud
ruudud / casper.cookies.spec.js
Created January 23, 2014 09:47
Setting cookies before page load in a CasperJS test.
casper.test.setUp(function () {
casper.echo('Cookies enabled?: ' + phantom.cookiesEnabled);
phantom.addCookie({
domain: '.localhost',
name: 'sessionId',
value: '12345abcd6789efg'
});
casper.start("http://localhost:8000/test_index.html#pageRequiringLogin", function () {
casper.echo('Start callback has cookie: ' + JSON.stringify(phantom.cookies));
});
@ruudud
ruudud / queuedmodel.js
Created December 4, 2013 13:30
Queued save in Backbone.Model using jQuery Deferred
var QueuedModel = Backbone.Model.extend({
url: function () {
var delay = Math.floor(Math.random() * 7);
return "/echo/json/?delay=" + delay;
},
initialize : function () {
this.saveQueue = jQuery.Deferred();
this.saveQueue.resolve();
@ruudud
ruudud / tomatousb-alsa-mpd.md
Last active July 22, 2016 05:43
Asus RT-AC66U TomatoUSB (kernel 2.6) with USB soundcard, Alsa, MPD, Spotify, Icecast and PulseAudio

This is some notes jotted down while trying to get an old USB sound card, connected to an Asus RT-AC66U router, to output music -- both from local MP3 files and Spotify.

Initially the idea was to run Mopidy on the router, but one of its core dependencies, libspotify, is not (yet) compiled for the MIPS architecture the Asus router runs under.

Maybe that will change some time: http://community.spotify.com/t5/Spotify-Ideas/libspotify-for-the-Mipsel-processor-Architecture/idi-p/36599

For now, Mopidy will have to run on another device on the network, and stream audio to the router.

@ruudud
ruudud / unicode-to-unihex.sh
Created October 28, 2013 09:42
Replace special unicode characters (e.g. ❤) with code points in ASCII (e.g. \2764). Written with CSS in mind.
#!/usr/bin/env bash
set -e
# Find unicode chars outside ASCII range recursively from this directory
chars=$(grep -r -P -n "[\x80-\xFF]" . | awk -F':' '{print $1 ";" $2}')
for fileandline in $chars; do
arrIN=(${fileandline//;/ })
filename=${arrIN[0]}
@ruudud
ruudud / change-java
Last active December 19, 2015 04:39
Script to change Java JDK in OSX. Only tested on Mountain Lion, other versions should use the Java Preferences app.
#!/bin/bash
TXTBLD=$(tput bold)
TXTRST=$(tput sgr0)
JVMS="/System/Library/Java/JavaVirtualMachines"
JAVA7="jdk1.7.0_17.jdk"
JDKS="~/.jdks"
usage () {
@ruudud
ruudud / ListBooksServlet.java
Created April 9, 2013 12:41
javax Servlet 3, Tomcat 7, JSP with JSTL
package editio;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ruudud
ruudud / test.js
Created March 12, 2013 14:41
Buster/Sinon test click handler
var assert = buster.assertions.assert;
var refute = buster.assertions.refute;
var testCase = buster.testCase('my views', {
'spy reg': function () {
var View = Backbone.View.extend({
events: { 'click': 'myclick' },
myclick: function () {
console.log('orig handler click');
}
@ruudud
ruudud / buster-phantom.sh
Created December 14, 2012 12:46
BusterJS and PhantomJS start/stop script, handy for Jenkins/CI
#!/bin/bash
#
# Depends on buster.js and phantom.js being installed
#
BUSTERPATH_OSX="/usr/local/lib/node_modules/buster"
BUSTERPATH_GNU="/usr/lib/node_modules/buster"
BUSTER_PHANTOMSCRIPT="script/phantom.js"
BUSTER_CMD="buster-server"