Skip to content

Instantly share code, notes, and snippets.

@ruudud
ruudud / gitintrotopics.rst
Created January 2, 2012 15:15
Git introduction course topics
  1. Get to know the environment, and VCS lingo
  2. Basic functionality: add, commit, diff, log
  3. Basic cooperative actions: fetch, push, pull
  4. Getting out of trouble: reset, checkout
  5. Branching: branch, merge, checkout
  6. Best practices: Branching models, infrastructure/GitHub, tools
@ruudud
ruudud / gist:1922646
Created February 27, 2012 09:08
Underscore templates with Django syntax
// Ovveride Underscore.js' template format
_.templateSettings = {
evaluate: /\{%([\s\S]+?)%\}/g,
interpolate: /\{\{(.+?)\}\}/g
};
@ruudud
ruudud / demo.htm
Created May 30, 2012 09:27 — forked from bennadel/demo.htm
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
<!DOCTYPE html>
<html>
<head>
<title>Cross-Origin Resource Sharing (CORS) With jQuery And Node.js</title>
</head>
<body>
<h1>
Cross-Origin Resource Sharing (CORS) With jQuery And Node.js
</h1>
@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"
@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 / 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 / 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 / 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 / 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 / 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();