Skip to content

Instantly share code, notes, and snippets.

View ubermajestix's full-sized avatar

Tyler Montgomery ubermajestix

View GitHub Profile
class A
def implicit_block_implicit_ensure
begin
"block"
ensure
"ensure"
end
end
def implicit_block_explicit_ensure
@zerowidth
zerowidth / paginated_collection.js
Created November 18, 2010 22:04
first whack at pagination with backbone.js
// 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");
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
# a little wrapper on yaml/store to give collection and record access to a
# transaction yaml store.
#
# sample usage
#
# require 'ydb'
#
# db = Db.new
#
# collection = db.collection(:posts)
# Automatically add mustaches to any images it can
#
#
module.exports = (robot) ->
robot.hear /^(https?:\/\/[^ #]+\.(?:png|jpg|jpeg))(?:[#]\.png)?$/i, (msg) ->
src = msg.match[1]
unless src.match(/^http:\/\/mustachify.me/)
msg.http("http://stacheable.herokuapp.com")
@ahoward
ahoward / routes.rb
Created December 5, 2011 15:55
scope gives cleaner routes compared to nested resources
class Acccount
def to_param
slug
end
end
@ahoward
ahoward / rego.rb
Created January 5, 2012 22:29
runs an arbitrary commands when files change
#! /usr/bin/env ruby
## rego command to run -- files to watch
#
# rego command_to_run on @ -- {lib/*,test/*}
#
require 'time'
require 'pathname'
require 'rubygems'
@paulca
paulca / .ey-example
Created February 20, 2012 22:46
Quick Deploy for Rails 3.1 on Engine Yard Cloud
# Place this file in the root of your project directory
# eg. APPNAME=tito
APPNAME=
# eg. APP_SERVERS=([email protected] [email protected])
APP_SERVERS=()
# eg. CACHE_DIRS=(public/cache)
CACHE_DIRS=()
require 'minitest/unit'
require 'celluloid'
module MiniTest
module Celluloid
class Runner < MiniTest::Unit
def _run_suites(suites, type)
futures = suites.map do |suite|
::Celluloid::Future.new { _run_suite suite, type }
##########################################################################
# something like this which can dump your db in a portable format. you could use mongodump... etc.
#
def App.db_snapshot
reinitialize_loggers if defined?(reinitialize_loggers)
$db_collections = Map.new