Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
subtleGradient / appify
Created November 11, 2010 16:03
appify. Create the simplest possible mac app from a shell script
#!/usr/bin/env bash
#
# url : https://gist.github.com/672684
# version : 2.0.2
# name : appify
# description : Create the simplest possible mac app from a shell script.
# usage : cat my-script.sh | appify MyApp
# platform : Mac OS X
# author : Thomas Aylott <[email protected]>
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@RobertAudi
RobertAudi / removexattr.c
Created November 27, 2010 15:28
Little script to make all the files under a certain directory safe on OS X.
/***********************************************************************
* Little script to make all the files under a certain directory safe. *
* Works only on Mac OS X. Tested on 10.5 and 10.6 *
* *
* Written by bojo (Bo Johansson) in a comment on Mac OS X Hint: *
* http://hints.macworld.com/article.php?story=20071029151619619 *
***********************************************************************/
/* Compile by
* gcc -O2 -Wall removexattr.c -o removexattr
@RobertAudi
RobertAudi / please.rb
Created December 2, 2010 12:50
`pmset schedule` wrapper to easily schedule OS X to sleep, shutdown, etc
#!/usr/bin/env ruby
# NOTES:
# - This script only works on OS X.
# - This script was only tested with ruby 1.9.2 using
# the aaronh-chronic gem. If the chronic gem is used
# instead, this script will not work (unless the chronic
# gem was updated to work with ruby 1.9.2).
require 'rubygems'
@mattwynne
mattwynne / be_same_file_as.rb
Last active May 21, 2022 13:27
RSpec matcher to compare two file, using their MD5 hashes
RSpec::Matchers.define(:be_same_file_as) do |exected_file_path|
match do |actual_file_path|
expect(md5_hash(actual_file_path)).to eq(md5_hash(expected_file_path))
end
def md5_hash(file_path)
Digest::MD5.hexdigest(File.read(file_path))
end
end
@joefiorini
joefiorini / .vmail.sh
Created December 16, 2010 16:44
Shell function to support multiple accounts for vmail (http://danielchoi.com/software/vmail.html) using one command.
mail() {
if [[ $1 = "p" ]]; then
rvm system exec vmail -c ~/.vmailrc-p
elif [[ $1 = "w" ]]; then
rvm system exec vmail -c ~/.vmailrc-w
else
echo "Please specify an account."
fi
}
@macournoyer
macournoyer / tm_reveal_in_github.rb
Created January 14, 2011 15:31
Reveal in GitHub TextMate command
#!/usr/bin/env ruby
# Reveal in GitHub TextMate command
require 'pathname'
path = Pathname.new(ENV["TM_FILEPATH"]).relative_path_from(Pathname.new(ENV["TM_PROJECT_DIRECTORY"]))
repo_path = `/usr/local/bin/git remote show origin`[/Fetch URL: git@(.*)\.git$/, 1].tr(":", "/")
branch = `/usr/local/bin/git symbolic-ref HEAD`[/refs\/heads\/(.*)$/, 1]
exec "open 'http://#{repo_path}/blob/#{branch}/#{path}'"
@janlelis
janlelis / blip
Created January 16, 2011 14:38
Easy access to your clipboard
#!/usr/bin/env ruby
require 'rubygems' unless defined? Gem
require 'clipboard'
if $stdin.tty? && $*.empty?
puts Clipboard.paste # the trailing new-line is intended ;)
else
Clipboard.copy ARGF.read
end
@lenary
lenary / gitconfig.ini
Created February 18, 2011 01:21
a special excerpt of my gitconfig
$ git clone github:lenary/guides.git
Cloning into guides...
remote: Counting objects: 255, done.
remote: Compressing objects: 100% (216/216), done.
remote: Total 255 (delta 111), reused 163 (delta 35)
Receiving objects: 100% (255/255), 1.49 MiB | 564 KiB/s, done.
Resolving deltas: 100% (111/111), done.
$ cd guides
$ git remote -v
gems = Hash.new(0)
gems_size = Hash.new(0)
total = 0
`du -ks ~/.rvm/gems/*/gems/*`.each_line do |line|
size = line[/\d+/].to_i
name = line[/\/([^\/\n]+)$/, 1]
gems[name] += 1
gems_size[name] = size