Skip to content

Instantly share code, notes, and snippets.

@granth
granth / thorcat.rb
Created January 21, 2009 17:16
show the code for a Thor task
# thor install http://gist.github.com/50043.txt
# thor cat:task some:task
# thor cat:task thor:runner:install # built-in tasks
require 'ruby2ruby'
class Cat < Thor
$requires = []
module ::Kernel
def require_with_record(file)
tell application "Twitterrific"
open location "http://search.twitter.com/search?q=%40" & screen name of selection
end tell
tell application "Twitterrific"
set peep to screen name of selection
set twid to id of selection
open location "http://twitter.com/" & peep & "/status/" & twid
end tell
# available domain names
# http://gilesbowkett.blogspot.com/2009/02/simple-bash-domain-availability.html
domainavailable() {
if whois $1 | grep "No match for" &>/dev/null; then
echo "$1 is available"
return 0
else
echo "$1 is not available"
return 1;
fi
-- save as "Add Pinboard Bookmark.scpt" in ~/Library/Scripts/Applications/Safari
-- assign it ⌘D in FastScripts to use instead of Safari's bookmarks
tell application "Safari"
set pinboardBookmarklet to "
document.location = 'http://pinboard.in/add?next=same' +
'&url=' + encodeURIComponent(location.href) +
'&title=' + encodeURIComponent(document.title);
"
do JavaScript pinboardBookmarklet in document 1
export PATH=$HOME/bin:/usr/local/bin:/usr/local/git/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/X11R6/bin:$PATH
source /usr/local/git/contrib/completion/git-completion.bash
prompt_status() {
local branch=$(__git_ps1 "%s")
if [ -n "$branch" ]; then
if git_dirty; then
echo "⚡"
return
// http://1kbgrid.com as a sass file.
@for !i from 1 through !number_of_columns
.grid_#{!i}
width = (!column_width + !gutter_width) * !i - !gutter_width
.column
margin = "0 #{!gutter_width / 2}"
overflow: hidden
float: left
# Rack file for local Rubygems server, using YARD
require "rubygems"
require "yard"
libraries = {}
Gem.source_index.find_name('').each do |spec|
libraries[spec.name] ||= []
libraries[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
end
@granth
granth / gist:940639
Created April 25, 2011 15:06
repair busted iTunes file locations with macirb
# repair busted iTunes file locations with macirb
framework 'ScriptingBridge'
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.itunes")
load_bridge_support_file 'iTunes.bridgesupport'
class SBElementArray
def [](value)
self.objectWithName(value)
@granth
granth / gist:1005312
Created June 2, 2011 20:57
git prompt
export PS1='\[\033]0;\w\007\[\033[0;32m\]\W\[\033[0;38m\] $(git_branch)$(prompt_status "%s") '
prompt_status() {
local branch=$(__git_ps1 "%s")
if [ -n "$branch" ]; then
if git_dirty; then
echo "⚡"
return
fi