Skip to content

Instantly share code, notes, and snippets.

@grassdog
grassdog / gist:783893
Created January 18, 2011 02:31
Add this to your bashrc or zsh profile so you can serve up the current directory with webrick
function rserve () {
ruby -rwebrick -e"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
}
@grassdog
grassdog / DefaultKeyBinding.dict
Created February 4, 2011 04:50
Change the home, end, page up, and page down key bindings in macosx
{
/* home */
"\UF729" = "moveToBeginningOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
/* end */
"\UF72B" = "moveToEndOfLine:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
/* page up/down */
@grassdog
grassdog / class_that_can_dynamically_ad_instance_methods_to_itself.rb
Created April 7, 2011 09:18
Dynamically add instance methods to a Ruby class
class ClassThatCanDynamicallyAddInstanceMethodsToItself
def define_method(method_name, &block)
method_carrying_module = Module.new do
define_method(method_name, &block)
end
self.extend method_carrying_module
end
end
@grassdog
grassdog / set-terminal-background-colour.sh
Created May 4, 2011 00:01
Set your terminal bg colour based upon host type (from: http://talkfast.org/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
# 3. alias ssh=/some/bin/ssh-host-color
# 4. Configure your host colors below.
@grassdog
grassdog / git-notpushed.sh
Created August 18, 2011 00:27
Script to show which commits aren't pushed to a remote
#!/bin/sh
#
# Shows commits you haven't pushed to the remote yet. Accepts same
# arguments as git-log. Assumes 'origin' is the default remote if no
# branch.Foo.remote configuration exists.
curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
origin=$(git config --get "branch.$curr_branch.remote")
origin=${origin:-origin}
@grassdog
grassdog / Stellar.tmTheme
Created January 16, 2012 08:37
My fork of the dark Solarized theme for textmate
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Stellar</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@grassdog
grassdog / band_names.md
Last active October 6, 2015 19:58
List of bands represented by Vanderhuge Industries A&R division.
  • Stingray Tetanus
  • This side towards enemy
  • Restrictive Clause is Parenthetical
  • Wolfman Strauss and the Pestilence
  • Above the Popcorn
  • Sherpa Support Cr3w
  • Suddenly Flatulent
  • Finger Smash Scream Time
@grassdog
grassdog / download-and-run.ps1
Created July 23, 2012 03:23
Script for downloading a Powerhell script via a proxy and executing it
param (
[Parameter(Mandatory=$true, HelpMessage='Provide a URL to download')]
$url
)
$proxy = new-object System.Net.WebProxy("http://myproxyaddress")
$username = 'myusername'
$password = ConvertTo-SecureString 'MyPass' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential $username, $password
$proxy.credentials = $cred
@grassdog
grassdog / goals.rb
Created December 12, 2012 13:37
An example of a JSON presenter. It uses the Representative gem for JSON rendering.
class Goal < ActiveRecord::Base
belongs_to :user
has_many :checkpoints
# Fields from schema.rb
#create_table "goals", :force => true do |t|
# t.string "description"
# t.string "period"
# t.integer "user_id"
# t.integer "position"
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z]+\.)*([A-Za-z]+)( extends [A-Za-z.]+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?([A-Za-z.]+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?([A-Za-z.]+)[ \t]+=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@([A-Za-z.]+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*([A-Za-z.]+):[^->\n]*$/\1/f,field/
--regex-coffee=/(constructor: \()@([A-Za-z.]+)/\2/f,field/