This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
require 'yaml' | |
require 'rexml/document' | |
class PlistWriter | |
PLIST_STUB_DOC = %q[ | |
<?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"></plist>] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# URL regexp from http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
# URL regexp adapted to have captures removed | |
RX_URL = %r[ | |
\b | |
(?: | |
[a-z][\w-]+: # URL protocol and colon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby | |
# encoding: UTF-8 | |
require 'yaml' | |
require "base64" | |
require 'rexml/document' | |
class PList < BasicObject | |
ELEMENT_PROCESSORS = {} | |
def self.process_element_named(name, &block); ELEMENT_PROCESSORS[name.to_s] = block; end | |
def self.process_element(elt) ; ELEMENT_PROCESSORS[elt.name][elt]; end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
# encoding: UTF-8 | |
require 'rubygems' | |
require 'fsevent' | |
require 'shellwords' | |
class Time | |
def age_in_seconds(now = Time.now) | |
now - self |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
require 'rubygems' | |
require 'appscript' | |
include Appscript | |
# Copy Window's URLs: | |
# Copies the URLs from all tabs in Safari/WebKit's front window to the pasteboard. | |
# `process_for_either_browser` will be any process named Safari, this includes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9 -ryaml | |
# encoding: UTF-8 | |
class Class | |
def initialize_with_attributes(*attrs) | |
attr_reader *attrs | |
define_method(:initialize) do |*args| | |
attrs.zip(args).each { |attr, v| instance_variable_set("@#{attr}", v) } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find app/views -name '*.html.erb' | | |
perl -pe 's/\.erb$//' | | |
xargs -I @ html2haml --erb @.erb @.haml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lastdir_store="$HOME/.last_cd_path" | |
function cd () { | |
builtin cd "$@" | |
exitcode=$? | |
pwd > "$lastdir_store" | |
return $exitcode | |
} | |
[ -f "$lastdir_store" ] && target=`cat "$lastdir_store"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9 | |
# encoding: UTF-8 | |
require 'appscript' | |
include Appscript | |
itunes = app("iTunes") | |
pos = itunes.player_position.get | |
pos = pos > 30 ? pos - 30 : pos / 2 | |
itunes.player_position.set pos |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loading the Cocoa framework. If you need to load more frameworks, you can do that here too. | |
framework 'Cocoa' | |
# Loading all the Ruby project files. | |
[__FILE__].concat(Dir[File.join(NSBundle.mainBundle.resourcePath.fileSystemRepresentation, '*.{rb,rbo}')]) | |
.map { |path| File.basename(path, File.extname(path)) }.uniq[1..-1] | |
.each { |name| require(name) } | |
# Starting the Cocoa main loop. | |
NSApplicationMain(0, nil) |