- GitHub Staff
- http://zerowidth.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Golem | |
class ServerMapConverter | |
def self.convert(src_path, dest_path) | |
new(src_path, dest_path).convert | |
end | |
attr_reader :src, :dest | |
def initialize(src_path, dest_path) | |
@src = Pathname.new(src_path).expand_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// includes bindings for fetching/fetched | |
PaginatedCollection = Backbone.Collection.extend({ | |
initialize: function() { | |
_.bindAll(this, 'parse', 'url', 'pageInfo', 'nextPage', 'previousPage'); | |
this.page = 1; | |
}, | |
fetch: function(options) { | |
options || (options = {}); | |
this.trigger("fetching"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module App | |
class Model | |
def as_json(opts={}) | |
hash = super | |
if opts && inclusions = opts[:include] | |
case inclusions | |
when Array | |
inclusions.each do |key| | |
hash[key.to_s] = send(key.to_sym).as_json | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "fileutils" | |
require "pathname" | |
require "zlib" | |
world = Pathname.new File.expand_path("./world") | |
0.upto(3) do |x| | |
0.upto(3) do |z| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is why AR3 and arel is awesome. | |
# bus route data, loaded from google transit data | |
# the usage | |
class StopsController < ApplicationController | |
def nearest | |
@stops = Stop.nearest_to(lon, lat).serving_route("SKIP").limit(5).all | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'); | |
var foo = { | |
name: 'foo', | |
bar: function() { | |
sys.puts('in bar, this is ' + this.name); | |
setTimeout(this.bar, 1000); | |
}, | |
baz: function() { | |
var me = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A rough example of how I'm putting module method overrides to use. | |
# This allows me to add functionality to methods without having to | |
# do method aliasing, and it's easy to enable/disable things too. | |
module Search | |
def search(query, opts={}) | |
request("search", :query => query).results | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# git post-receive hook that posts the log messages to pivotal tracker | |
# for automatic updates of stories. | |
# See http://www.pivotaltracker.com/help/api?version=v3#scm_post_commit | |
# for more information | |
require "cgi" | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# try out cloning and pushing using a working copy in git | |
# | |
function log() { | |
echo | |
echo "***** $1" | |
echo | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Force ActiveRecord to insert the 'DEFAULT' literal for columns which | |
# are non-null but do not have a default that AR understands. | |
# | |
# MySQL is lenient in that if you insert a NULL in something with a default, | |
# the database will just insert the default anyway. Postgres is not so kind: | |
# it'll do exactly what you told it, causing an error. | |
# Usually AR can figure out the default for a column, but if it's a default | |
# value that the connection adapter can't figure out, it'll insert a NULL. | |
# So: allow explicit 'DEFAULT' literals (which is SQL standard) to be used instead | |
# where appropriate. |