Skip to content

Instantly share code, notes, and snippets.

View aliang's full-sized avatar

Alvin Liang aliang

View GitHub Profile
@vvalgis
vvalgis / Capistrano tasks for starting unicorn.rb
Created May 7, 2010 08:13
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
@mkdynamic
mkdynamic / bundles.sh
Created June 18, 2010 02:31
Install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#!/usr/bin/env bash
#
# install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#
echo "Installing bundles..."
# backup dir
if [ -d ~/desktop/_tm_bundle_backups ]; then rm -rf ~/desktop/_tm_bundle_backups; fi
@juggy
juggy / call_template.rb
Created May 17, 2011 19:25
Render a complete page in rails 3 without controller
# create the template
template = PageOfflineTemplate.new
template.quote = quote
template.pages = quote.build_pages
# Here I render a template with layout to a string then a PDF
pdf = PDFKit.new template.render_to_string(:template=>"quotes/review.html.haml")
@etrepat
etrepat / criteria.rb
Created June 12, 2011 18:56 — forked from outoftime/criteria.rb
Instantiate the results of map-reduce operations as Mongoid documents
module Mongoid
class Criteria
include Criterion::MapReduce
end
end
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@wilmoore
wilmoore / knife.rb
Created June 22, 2011 07:56
Base "knife" configuration for a standard chef-solo setup
# .chef/knife.rb
# SEE: http://wiki.opscode.com/display/chef/Troubleshooting+and+Technical+FAQ
# set some sensible defaults
current_dir = File.dirname(__FILE__)
user = ENV['OPSCODE_USER'] || ENV['USER']
log_level :debug
log_location STDOUT
node_name `hostname`
client_key ''
@harlanbarnes
harlanbarnes / Vagrantfile
Created January 17, 2012 23:34
Vagrantfile Multi VM
user = ENV['OPSCODE_USER'] || ENV['USER']
base_box = ENV['VAGRANT_BOX'] || 'centos-5.5-x86_64'
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.box = base_box
web_config.vm.forward_port("http", 80, 8080)
web_config.vm.provision :chef_client do |chef|
@jtimberman
jtimberman / knife.rb
Created February 1, 2012 19:33
Commented knife.rb for all the things
# Knife Configuration File.
#
# This is a Ruby DSL to set configuration parameters for Knife's
# general options. The default location for this file is
# ~/.chef/knife.rb. If multiple Chef repositories are used,
# per-repository configuration files can be created. A per repository
# configuration file must be .chef/knife.rb in the base directory of
# the Chef repository. For example,
#
# ~/Development/chef-repo/.chef/knife.rb
@mbostock
mbostock / .block
Last active March 10, 2024 07:21
Mitchell’s Best-Candidate
license: gpl-3.0
redirect: https://observablehq.com/@mbostock/best-candidate-circles
@unicodefreak
unicodefreak / gist:1901458
Created February 24, 2012 14:59
Include tag for underscore template
// based on http://emptysquare.net/blog/adding-an-include-tag-to-underscore-js-templates/
// include tag for underscore templates
// <% include template-id %>
var _underscore_template = _.template;
_.template = function(str, data) {
// match "<% include template-id %>"
return _underscore_template(
str.replace(
/<%\s*include\s*(.*?)\s*%>/g,