Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / marshal.js
Created December 31, 2012 06:20
NodeJS module to allow unmarshaling of Ruby serialized objects. Works fine for simple objects, but there's no clear way to implement classes, etc.
"use strict";
/**
* @author geoff
*/
var Marshal = (function() {
var debug = false;
var symbols;
var marshal_major = 4, marshal_minor = 8;
@ngryman
ngryman / service.conf.sh
Created October 2, 2012 21:10
Post: Using upstart with forever to manage your node.js application
#!upstart
description "your fancy description that no one will see ;)"
author "Your Name <youremail@fqdn>"
# start on every run level, 2 is the one on Ubuntu
start on runlevel [2345]
# stop on halt, maintenance or reboot
stop on runlevel [016]
@mikeal
mikeal / gist:2504336
Created April 27, 2012 00:11
Date parsing JSON
JSON._dateReviver = function (k,v) {
if (v.length !== 24 || typeof v !== 'string') return v
try {return new Date(v)}
catch(e) {return v}
}
JSON.parseWithDates = function (obj) {
return JSON.parse(obj, JSON._dateReviver);
}
@uhlenbrock
uhlenbrock / deploy.rb
Created December 14, 2011 17:36
Precompile assets locally for Capistrano deploy
load 'deploy/assets'
namespace :deploy do
namespace :assets do
desc 'Run the precompile task locally and rsync with shared'
task :precompile, :roles => :web, :except => { :no_release => true } do
%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}
end
@avakhov
avakhov / ability_rules.rb
Created August 27, 2011 19:18
six gem usage
class AbilityRules
class AccessDenied < Exception
end
def self.allowed(user, subject)
rules = []
railse [user, subject].inspect # <--- this exception was rescued by six rescue block (of course it need only in development for debug :)
return rules unless user
@jumski
jumski / backbone_sync_hack.coffee
Created August 5, 2011 17:10
BackboneJS sync hack to namespace params when saving/updating model
###
Usage:
* add model.name property that will be used as a namespace in the json request
* put this code before your Backbone app code
* use toJSON() as usual (so there is no namespacing in your templates)
* your model's data will be sent under model.name key when calling save()
###
# save reference to Backbone.sync
Backbone.oldSync = Backbone.sync
I decide to work on a new feature, so I create a branch, topic.
o---o master
\
o---o---o---o topic
I am not yet finished working on my feature when I have to make some bugfixes to master
o---o---o---o master
@weppos
weppos / capistrano_database_yml.rb
Created July 27, 2008 10:04
Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2010 The Authors