Skip to content

Instantly share code, notes, and snippets.

View dansimpson's full-sized avatar

Dan Simpson dansimpson

View GitHub Profile
UrlEncoder = {
/**
* Encode a [deeply] nested object for use in a url
* Assumes Array.each is defined
*/
encode: function(params, prefix) {
var items = [];
Array.prototype.each = function(fn, scope) {
var count = 0;
while(count < this.length) {
fn.call(scope || window, this[count], count)
count++;
}
};
Array.prototype.search = function(fn) {
var result = [];
require 'rubygems'
require 'pp'
require 'logger'
$LOAD_PATH << File.dirname(__FILE__)
require 'proxy/base'
require 'proxy/wibox_proxy'
require 'sensors/reading'
require 'sensors/sensor'
require "rubygems"
require "eventmachine"
module Echo
def receive_data data
send_data(data)
end
end
EM.epoll
<!doctype html>
<html>
<head>
<title>JS1k, 1k demo submission</title>
<meta charset="utf-8" />
</head>
<body>
<canvas id="c"></canvas>
<script>
require "rubygems"
require "eventmachine"
class HttpHandler < EM::Connection
def initialize *args
super
@header = ""
@status = 200
end
class ConversationsController < ApplicationController
before_filter :load_board
def index
@conversations = Conversation.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @conversations }
@dansimpson
dansimpson / twilight_pygments.css
Created January 30, 2011 16:57
Pygments stylesheet based on Textmates's Twilight theme
pre.code { background: #181818; padding: 16px; color: #F8F8F8; font-family: Consolas, Monaco,"Lucida Console"; }
pre.code * { font-family: Consolas, Monaco,"Lucida Console"; }
pre.code .hll { background-color: #ffffcc }
pre.code .c { color: #5F5A60; font-style: italic } /* Comment */
pre.code .err { border:#B22518; } /* Error */
pre.code .k { color: #CDA869 } /* Keyword */
pre.code .cm { color: #5F5A60; font-style: italic } /* Comment.Multiline */
pre.code .cp { color: #5F5A60 } /* Comment.Preproc */
pre.code .c1 { color: #5F5A60; font-style: italic } /* Comment.Single */
pre.code .cs { color: #5F5A60; font-style: italic } /* Comment.Special */
@dansimpson
dansimpson / gist:1339595
Created November 4, 2011 15:31
essential packages for rvm on ubuntu
sudo apt-get -y install aptitude git-core curl build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
@dansimpson
dansimpson / ifind
Last active December 19, 2015 12:19
Small command line utility for fetching GPS coordinates of you iPhone, iPad, or iPod.
#!/usr/bin/env ruby
require "optparse"
require "json"
require "findi"
def report device, mode=:text
name = device.name