Skip to content

Instantly share code, notes, and snippets.

View fullofcaffeine's full-sized avatar

Marcelo Serpa fullofcaffeine

View GitHub Profile
@yashh
yashh / SSH Terminal Colors
Created January 10, 2011 20:49
Automatically set your terminal color upon SSH to a host
# Full credit to: http://jeffmiller.github.com/2011/01/10/ssh-host-color
#!/bin/bash
#
# ssh into a machine and automatically set the background
# color of Mac OS X Terminal depending on the hostname.
#
# Installation:
# 1. Save this script to /some/bin/ssh-host-color
# 2. chmod 755 /some/bin/ssh-host-color
@joefiorini
joefiorini / reviews_controller_spec.rb
Created May 15, 2011 17:41
decent_exposure and Rails-less testing
require 'units/spec_helper'
require 'reviews_controller'
class Review; end
describe ReviewsController do
let(:controller) { ReviewsController.new }
it { should expose :reviews }
@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created September 9, 2011 10:49
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@spicycode
spicycode / tmux.conf
Created September 20, 2011 16:43
The best and greatest tmux.conf ever
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
#set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
@pauljamesrussell
pauljamesrussell / spec_helper.rb
Created November 9, 2011 23:15
RSpec matcher for ensuring a model is accepting nested attributes for an association, and accepting/rejecting the right values.
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
model.send("#{association}").clear
@jblanche
jblanche / typeParams.rb
Created November 22, 2011 23:45 — forked from devboy/typeParams.as
This is not a language flamewar, Haxe really do looks great and one should use the language he feels the more comfortable with. But I wanted to show how Ruby Duck Typing can handle this kind of situations.
# Ruby is using Duck Typing, rather than checking types, Ruby checks if an object can or cannot respond to a method.
# Here is a "port" of the Haxe example in Ruby.
# Ruby is not a compiled language, so that the "easiest" syntax comes with some shortcoming,
# those errors can only be detected at runtime, your favorite IDE won't warn you before :)
ints = [1, 2, 3]
strings = ["a", "bb", "ccc"]
def biggerThan1(x)
x > 1
@xolox
xolox / restore-zsh-history.lua
Created January 31, 2012 22:20
Lua script to restore ZSH history file from backups (useful for completion)
#!/usr/bin/env lua
-- Posted this online because of http://news.ycombinator.com/item?id=3535349
ordered = {}
index = {}
need_continuation = false
first_continued_line = 0
function add_or_replace(line)
@assaf
assaf / deploy.sh
Created February 16, 2012 00:02
Deploy using chef-solo
# Run command(s) over SSH
run() {
ssh deploy@${HOST} -t $* || exit 1
}
# Transfer all the specified files/directories to working directory
upload() {
tar czf - $* | ssh deploy@${HOST} tar xzf - -C /etc/chef || exit 1
}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ejhayes
ejhayes / README.md
Created June 6, 2012 01:12
Debugging Hubot Scripts using Node Inspector

About

Use node-inspector to debug hubot!

sudo npm install -g node-inspector

Run Hubot in Debug Mode

coffee --nodejs --debug $(which hubot)