Skip to content

Instantly share code, notes, and snippets.

View trotter's full-sized avatar

Trotter Cashion trotter

View GitHub Profile
#Routes
map.resources :posts
map.resources :posts, :member => {:unpublish => :post}
#Posts controller
def unpublish
@post = Post.find(params[:id])
@post.current_state = "unpublished"
@post.save
respond_to do |format|
// ./config/db.json
{ "mysql": { "server_root_password": "beefcakes" },
"recipes": [ "mysql" ] }
# ./roles/db.rb
name "database"
description "Be a DB"
run_list [ "mysql::server" ]
default_attributes :mysql => { :server_root_password => "beefcake" }
[Mon, 25 Oct 2010 16:23:23 -0400] INFO: Setting the run_list to ["role[app]"] from JSON
[Mon, 25 Oct 2010 16:23:23 -0400] INFO: Starting Chef Run (Version 0.9.12)
[Mon, 25 Oct 2010 16:23:23 -0400] WARN: Missing gem 'mysql'
[Mon, 25 Oct 2010 16:23:23 -0400] ERROR: Running exception handlers
[Mon, 25 Oct 2010 16:23:23 -0400] ERROR: Exception handlers complete
/tmp/chef-solo/cookbooks/mysql/attributes/server.rb:20:in `from_file': uninitialized constant Opscode::OpenSSL (NameError)
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/node.rb:578:in `load_attributes'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/node.rb:576:in `each'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/node.rb:576:in `load_attributes'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.12/bin/../lib/chef/node.rb:575:in `each'
@trotter
trotter / tmux.conf
Created December 13, 2010 15:25
it's mah tmux conf and bash functions
# Change prefix key to Ctrl+\
unbind C-b
set -g prefix C-\
# Last active window
unbind l
bind C-\ last-window
# Use Vi mode
setw -g mode-keys vi
@trotter
trotter / .vimrc
Created December 15, 2010 16:34
It's mah vimrc
set nocompatible
syntax on
set backspace=indent,eol,start
set number " Show line numbers
" Pathogen ********************************************************************
filetype off
call pathogen#helptags()
function Chart() {
}
Chart.prototype = {
l_gutter: 120,
l_margin: 20,
r_margin: 20,
r_gutter: 80,
x_bound: 900,
t_gutter: 20,
var r = Raphael("circle", 100, 100);
r.circle(50, 50, 40);
r = Raphael("jobs-graph", 640, 120);
rect = r.rect(481, 30, 7, 90);
rect.attr({stroke: "none",
fill: "#446093"});
r = Raphael("jobs-graph", 640, 140);
text = r.text(490, 130, "Clinton");
text.attr({"font-family": "8px Courier",
fill: "#9c9c9b"});
@trotter
trotter / chloe-example.js
Created April 2, 2011 17:57
The Chloe example
var chloe = new Chloe({host: "<%= server_name %>", port: 8901});
chloe.connect(function () {
console.log('Holy crap, connected!');
chloe.send('Ohai Chloe!');
chloe.subscribe('pumpkin', function (message) {
console.log('Someone was eating pumpkins: ' + message);
});