Skip to content

Instantly share code, notes, and snippets.

module Kernel
def min(*args)
[*args].sort.first
end
end
module Kernel
def min(*args)
[*args].inject {|a,b| a = a < b ? a : b}
end
end
function extract {
echo Extracting $1 ...
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
history 1000 | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
#!/bin/sh
# Send the file to our running Emacs and bring it to the foreground.
/Applications/Emacs.app/Contents/MacOS/bin/emacsclient "${1}" \
2> /dev/null \
&& open -a Emacs
# If that failed, then open a new emacs visiting the file.
if [ $? -ne 0 ]; then
EOPEN_DIR="${PWD}" EOPEN_FILE="${1}" open -a Emacs
#!/bin/sh
# Send the file to our running Emacs and bring it to the foreground.
~/tools/emacs/bin/emacsclient "${1}" \
2> /dev/null \
# If that failed, then open a new emacs visiting the file.
if [ $? -ne 0 ]; then
dir=sed "/s/\/cygdrive\//g/" ${PWD} 2> /dev/null
EOPEN_DIR="${dir}" EOPEN_FILE="${1}" ~/tools/emacs/bin/runemacs.exe
#import <Foundation/Foundation.h>
@interface NSString(Extensions)
-(NSString *) sha1Hash;
@end
@developernotes
developernotes / brew-update-all.rb
Created December 26, 2010 17:43
Updates homebrew, installed packages and cleans up old packages
require 'utils'
class UpdateAll
def run
display("Updating homebrew and all installed packages, also cleaning up old packages:")
safe_system("brew update && brew upgrade && brew cleanup")
end
def display(message, &block)
@developernotes
developernotes / emacs-daemon.plist
Created April 2, 2011 20:50
Launch the emacs daemon at login
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>emacs-daemon</string>
<key>RunAtLoad</key>
<true/>
@developernotes
developernotes / gist:1015445
Created June 8, 2011 21:25
Enumeration extensions
public static void WhenNotNullPerform<TType, TResult>(this IEnumerable<TType> items, Func<TType, TResult> conditionToCheck, Action<TResult> actionToApply) where TResult : class
{
items.Each(x =>
{
var result = conditionToCheck.Invoke(x);
if (result != null)
{
actionToApply.Invoke(result);
}
});