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
framework 'Cocoa' | |
# store any new classes created during the requires that follow | |
LOADED_RUBY_CLASSES = [] | |
class << Object | |
def inherited(m) | |
LOADED_RUBY_CLASSES << m | |
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
#!/usr/bin/env macruby | |
framework 'Cocoa' | |
cocoa_array = NSArray.new | |
ruby_array = [] | |
puts ruby_array.count # => 0 | |
puts ruby_array.count { true } # => 0 | |
puts ruby_array.count("whatever") # => 0 |
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 | |
ARGV.reject! { |path| !File.file?(path) } | |
(puts DATA.read.gsub("$0", File.basename($0)); exit 1) if ARGV.empty? | |
ARGV.each do |path| | |
ls = IO.readlines(path) | |
ix = ls[0] !~ /^#!/ ? 0 : 1 | |
next if ls[ix] =~ /#.*?coding\s*[:=]\s*\S/ |
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 'strscan' | |
(puts DATA.read.gsub(/\$0/, File.basename($0)); exit 1) unless ARGV.empty? # handled -h and anything else since we don't take args | |
# tokenize lines | |
lines = STDIN.read.strip.split(/\n+/) | |
gems = lines.inject({}) do |h, line| | |
next h if line =~ /^\s*(#.*)?$/ |
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
;; drops the first element from a list and returns it | |
(macro shift! (l) | |
`(let (e (car ,l)) | |
(set ,l (cdr ,l)) | |
e)) | |
;; drops the first cell from a list if it is equal to e | |
(macro cond-shift! (l e) `(if (eq (car ,l) ,e) (shift! ,l))) | |
;; appends e to the list l |
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
Contents/MacOS/main |
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
<?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>CFBundleDevelopmentRegion</key> <string>English</string> | |
<key>CFBundleExecutable</key> <string>upcase</string> | |
<key>CFBundleIdentifier</key> <string>com.caiochassot.services.upcase</string> | |
<key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> | |
<key>CFBundlePackageType</key> <string>BNDL</string> |
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 |