Skip to content

Instantly share code, notes, and snippets.

View therabidbanana's full-sized avatar
🌴
On vacation

David Haslem therabidbanana

🌴
On vacation
  • Pathstream
  • San Francisco
View GitHub Profile
@tmm1
tmm1 / em-irb-console.rb
Created July 12, 2009 01:17
networked irb server/client in EM
require 'rubygems'
require 'eventmachine'
module Console
PROMPT = "\n>> ".freeze
def post_init
send_data PROMPT
send_data "\0"
end
@therabidbanana
therabidbanana / hello_world.rb
Created June 15, 2010 04:57
An extremely convoluted hello world
#!/usr/bin/env ruby
require 'yaml'
# Prints out the string "Hello World!" in
# an extremely convoluted way involving
# method_missing magic, dynamic method calls,
# some metaprogramming, completely useless comments,
# the DATA block, yaml, and Sesame Street.
#
# This hello world brought to you by the letter Q.
@therabidbanana
therabidbanana / config.ru
Created July 8, 2010 04:14
(Nearly) Smallest possible orange-sparkles site
#-s thin -p 5432
require "rubygems"
require 'orange-sparkles'
app = Orange::SparklesApp.app
app.orange.options["main_user"] = "therabidbanana@gmail.com"
run app
@therabidbanana
therabidbanana / Gemfile
Created August 20, 2010 04:22
A simple sparkles app with blog
# Gemfile
source "http://rubygems.org"
gem "openid_dm_store", :git => "git://github.com/therabidbanana/openid_dm_store.git"
gem "orange-more", :git => "git://github.com/therabidbanana/orange-more.git"
gem "orange-core", :git => "git://github.com/therabidbanana/orange-core.git"
gem "orange-sparkles", :git => "git://github.com/orange-project/orange-sparkles.git"
gem "dm-postgres-adapter"
@TwP
TwP / gist:981176
Created May 19, 2011 16:29
A simple rack middleware that allows you to post JSON body data. We are using the YAJL json library for ruby. Feel free to substitute your own.
require 'yajl'
module Rack
# A Rack middleware for parsing POST/PUT body data when Content-Type is
# <tt>application/json</tt>.
#
class JsonPostBody
@madrobby
madrobby / i18n.coffee
Created November 14, 2011 15:45
Backbone i18n with CoffeeScript
# before this file is loaded, a locale should be set:
#
# In a browser environment, you can use:
# ```<script>__locale='en';</script>```
#
# In a server environment (specifically node.js):
# ```global.__locale = 'en';```
# normalize in-app locale string to "en" or "de-AT"
parts = @__locale.split('-')
@addyosmani
addyosmani / jasmine.md
Created January 3, 2012 01:14
Rough-work for Jasmine section of Backbone Fundamentals

##Introduction

One definition of unit testing is the process of taking the smallest piece of testable code in an application, isolating it from the remainder of your codebase and determining if it behaves exactly as expected. In this section, we'll be taking a look at how to unit test Backbone applications using a popular JavaScript testing framework called Jasmine from Pivotal Labs.

For an application to be considered 'well'-tested, distinct functionality should ideally have its own separate unit tests where it's tested against the different conditions you expect it to work under. All tests must pass before functionality is considered 'complete'. This allows developers to both modify a unit of code and it's dependencies with a level of confidence about whether these changes have caused any breakage.

As a basic example of unit testing is where a developer may wish to assert whether passing specific values through to a sum function results in the correct output being re

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@jamiew
jamiew / Procfile
Last active October 4, 2015 12:28
Using unicorn on Heroku
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method: