Skip to content

Instantly share code, notes, and snippets.

@schacon
schacon / gist:942899
Created April 26, 2011 19:19
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
@brianmario
brianmario / config.ru.rb
Created April 21, 2011 06:11
minimal rails3 app
# minimal rails3 app
require 'action_controller'
Router = ActionDispatch::Routing::RouteSet.new
Router.draw do
root :to => 'site#index'
end
class SiteController < ActionController::Metal
@Floby
Floby / editor.js
Created April 19, 2011 09:18
open the default editor from node
var fs = require('fs');
var child_process = require('child_process');
var spawn = child_process.spawn;
function openEditor(file) {
var cp = spawn(process.env.EDITOR, [file], {
customFds: [
process.stdin,
process.stdout,
process.stderr
@derekcollison
derekcollison / Cloud Foundry Production Updates
Created April 16, 2011 17:11
How to update your application in Cloud Foundry without dropping user requests..
# vmc update is great for test and development, however it stops your old app and stages and starts the new one,
# resulting in dropped requests.
# If you want to update an application without dropping user requests, see below.
# NOTE: This change assumes your application can share services, etc with the new version.
# Assume my app is named foo
vmc push foo-v2 --url foov2.cloudfoundry.com

Different services I can suggest when a non-tech friend or family member asks me how they can cheaply make a website and possibly use it to sell stuff online.

Website Hosting

@saimonmoore
saimonmoore / bash function: execute command n times
Created March 31, 2011 22:13
A bash function that executes a command n (default 5) times
# Usage:
# $loopc echo 'hello world'
# hello world
# hello world
# hello world
# hello world
# hello world
#
#(i.e. defaults to 5 iterations)
########################################################################
### Rakefile for encrypted passwords
########################################################################
#
# Here's a little Rakefile to manage your encrypted password file! It's
# really easy to use:
#
# 1) put the email addresses of the keys you want in AUTHORIZED_USERS
# 2) create a passwords.txt (and ignore it in your SCM)
# 3) run `rake passwords:encrypt`
@bryanveloso
bryanveloso / puppet.txt
Created January 4, 2011 08:37
Links I've found while studying the world of Puppet.
http://about.digg.com/blog/master-puppets-2-speaking-language
http://agiletesting.blogspot.com/2009/11/automated-deployments-with-puppet-and.html
http://articles.itecsoftware.com/linux/install-and-configure-puppet-client-on-ubuntu-10-10
http://articles.itecsoftware.com/linux/install-and-configure-puppet-server-puppetmaster-on-ubuntu-10-10
http://bitfieldconsulting.com/puppet-and-mysql-create-databases-and-users
http://blog.credativ.com/en/2010/03/howto-introduction-to-puppet.html
http://blog.kumina.nl/2010/11/puppet-tipstricks-running-apt-get-update-only-when-needed/
http://en.gentoo-wiki.com/wiki/Puppet (the "User" portion)
http://evolvingweb.ca/story/controlling-your-cloud-puppet
http://library.linode.com/application-stacks/puppet/automation
@creationix
creationix / inspect.js
Created December 23, 2010 06:51
a custom object inspector to help me understand JavaScript
function escapeString(string) {
string = string.replace(/\\/g, "\\\\").
replace(/\n/g, "\\n").
replace(/\r/g, "\\r").
replace(/\t/g, "\\t");
if (string.indexOf("'") < 0) {
return "'" + string + "'";
}
string = string.replace(/"/g, "\\\"");
return '"' + string + '"';
@dchelimsky
dchelimsky / shared_example_group_rspec_2_workaround.rb
Created December 3, 2010 15:46
shared_example_group_rspec_2_workaround
# shared example groups in rspec-1 are evaluated in the example group that
# has it_should_behave_like.
#
# This behavior changed in rspec-2, in which it_should_behave_like generates a
# nested group. This means that a structure like this won't work as you expect
# in rspec-2
#
# shared_examples_for "logged in as admin" do
# before { login_as :admin }
# end