Skip to content

Instantly share code, notes, and snippets.

@ashwinr
ashwinr / test.html
Created January 31, 2013 18:51
qunit test file
<!DOCTYPE html>
<html>
<head>
<title>Test Title</title>
<script src = "libraries/qunit-1.11.0/qunit-1.11.0.js"></script>
<script>
throw(new Error("Error!"));
</script>
@ashwinr
ashwinr / run-test.js
Created January 31, 2013 18:51
phantomjs test file
if (phantom.args.length === 0 || phantom.args.length > 2) {
console.log('Usage: run-qunit.js URL');
phantom.exit();
}
var page = new WebPage();
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
console.log(msg);
@ashwinr
ashwinr / git_match.rb
Created June 28, 2012 19:22
Use camelCase syntax to detect files for a 'git diff'
#!/usr/bin/ruby
# usage: git_match.rb <camel-characters>
GIT = 'git'
DIFF_OPT = 'diff'
TRACK_OPT = 'status -s -uno' #tracked files
def diff(arr)
arr.each { |gf| fork{ puts "#{gf}"; `#{GIT} #{DIFF_OPT} #{gf}` }}
@ashwinr
ashwinr / Histogram.sh
Created December 23, 2011 07:02
A spark one-liner to display the histogram of word lengths from /usr/share/dict/words
#!/bin/sh
cat /usr/share/dict/words | awk '{ print length($0) }' | sort -n | uniq -c | awk '{ print $1 }' | spark
@ashwinr
ashwinr / deferrable.rb
Created December 10, 2010 03:21
A simple example to illustrate EventMachine's Deferrable.
require 'rubygems'
require 'sinatra/async'
require 'thin'
class App < Sinatra::Base
register Sinatra::Async
@@clients = []