This file contains 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
class Queue | |
def initialize | |
@head = HeadNode.new | |
end | |
def size | |
find_size(@head) | |
end | |
def push(object) |
This file contains 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
require 'test/unit' | |
require './queue' | |
class TestQueue < Test::Unit::TestCase | |
def setup | |
@q = Queue.new | |
end | |
def test_should_create_a_new_queue | |
assert @q |
This file contains 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/macruby | |
# Update the creation date on all Evernote notes to match the date in their title | |
# The date format in the title must be 'yyyymmdd' | |
# Requires macruby to run | |
require 'date' | |
require 'optparse' | |
framework "ScriptingBridge" |
This file contains 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
for f in *.pdf ; do new=$(mdls -name kMDItemFinderComment $f -raw) ; touch -t ${new}0000 $f; echo $f ; done |
This file contains 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/macruby | |
# Update the creation date on all Evernote notes to match the date in their title | |
# The date format in the title must be 'yyyymmdd' | |
# Requires macruby to run | |
require 'date' | |
require 'optparse' | |
framework "ScriptingBridge" |
This file contains 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
# Perform an in-place (with backup) global search and replace on one or more files | |
$ ruby -i.bak -ple '$_.gsub!(/..../, "::::")' * | |
# Replace the ... with the regular expression that you're searching for, | |
# and the ::: with what you want to replace it with. | |
# Replace the file glob with whatever is appropriate. |
This file contains 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
# Convert all files (*) from DOS endings to UNIX endings, and create a back-up of each | |
ruby -i.bak -ple '' * |
This file contains 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 | |
require 'find' | |
usage = <<EOF | |
Usage: ack.rb <regexp> <directory or filename> | |
The regular expression can be across multiple lines, and is _not_ escaped by default. | |
For example: | |
ack.rb 'end\\nend' . | |
will find all files in the current directory that have two 'end' statements across two lines |
This file contains 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 | |
require 'rubygems' | |
require 'nokogiri' | |
# This is a simple program that reads in a Ruby ERB file, and parses | |
# it as an XHTML file. Specifically, it makes a decent attempt at | |
# converting the ERB tags (<% %> and <%= %>) to XML tags (<erb-disp/> | |
# and <erb-eval/> respectively. | |
# |