Skip to content

Instantly share code, notes, and snippets.

View bensie's full-sized avatar

James Miller bensie

View GitHub Profile
@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
// Examples:
//
// button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "form_to_link"
// button_to "New Alert", new_alert
//
jQuery(document).ready(function($) {
jQuery('.form_to_link').each(function(el){
var form = el.parents('form');
form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + form_to_link.attr('value') + '</a>');
form.hide();
@mislav
mislav / update-ree-passenger.sh
Created May 26, 2009 17:08
Update Ruby Enterprise Edition and Passenger
set -e
# for a setup script see http://gist.github.com/32917
PASSENGER=2.2.3
REE="ruby-enterprise-1.8.6-20090610"
PREFIX=/opt/$REE
# git checkout of git://github.com/FooBarWidget/passenger.git
cd ~/passenger
git fetch origin
@pat
pat / application_controller.rb
Created June 15, 2009 21:51
Returning HTML in AJAX calls, without layouts.
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)
# * adjust_for_inline
#
class ApplicationController < ActionController::Base
# ...
before_filter :adjust_for_inline
@schacon
schacon / gist:171255
Created August 20, 2009 18:39
my .gitconfig file
[user]
name = Scott Chacon
email = schacon@gmail.com
[alias]
serve = !git daemon --reuseaddr --verbose --base-path=. --export-all ./.git
unstage = reset HEAD
lol = log --pretty=oneline --abbrev-commit --graph --decorate
branches = !git-branches
st = status
[gui]

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

~vp(master)> cat ~/.gitconfig
...SNIP...
[alias]
datetag = !git tag `date \"+%Y%m%d%H%M\"`
update = pull --rebase
commdiff = log --pretty=oneline --left-right
...SNIP...
~vp(master)> git commdiff master...staging
>bb569b9a8c70a61ecffd4def3ac5e460848e0f36 Merge branch 'master' into staging
>f95b7db13fb48b3b5e1c2c484d00909a89f468d5 bulk edit on search page is no longer experimental
@jnunemaker
jnunemaker / database.yml
Created November 12, 2009 14:59
mongo initializer to load config from database.yml, authenticate if needed and ensure indexes are created
development: &global_settings
database: textual_development
host: 127.0.0.1
port: 27017
test:
database: textual_test
<<: *global_settings
production:
@kneath
kneath / ._what.md
Created December 4, 2009 18:23
Badass git pull alias (up) to show commit log that just got pulled in addition to changes

Badass git pull alternative

Add this little snippet to your ~/.gitconfig and it amps up your git pull by means of git up

  1. Adds in a list of the commits you're pulling down
  2. Auto-prunes remote branches
  3. Defaults to pull --rebase - gets rid of unnecessary merge commits. If you don't know what rebase does, this is probably safe for you. If you know what rebase does, you should know where this will not be safe for you.

Scott Chacon and Ryan Tomayko basically figured out how to do this and I am stealing all of the credit.

class JsonHax
def initialize(app)
@app = app
end
def call(env)
if env['CONTENT_TYPE'] == 'application/json'
env['CONTENT_TYPE'] = 'application/xml'
env['REQUEST_URI'].gsub!(/\.json/, '.xml')