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 | |
# Usage: ./remove-javadoc.sh < [file-name] | |
print $<.to_a.join.gsub(/\/\*\*(.*)\*\//m, '') |
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
Ingredients: | |
* 230 grams bittersweet chocolate (I prefer < 70%; anything more I find too bitter) | |
* ½ cup brewed coffee (optional) | |
* 4 eggs, separated | |
Directions: | |
1. In a double boiler, melt the chocolate and set aside to cool. | |
2. Separate the eggs. | |
3. In a medium size bowl beat the egg whites until peaks form. | |
4. In a separate bowl, mix together the chocolate, coffee, and egg yolks until well incorporated. |
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
######################################### | |
# Run the following to generate some input: | |
# find . -iname '*.java' -type f -exec cat {} \; | grep -E '^(package|import)' | |
# Then run this script to generate a .dot file for importing into graphiz | |
require 'set' | |
@dependencies = Hash.new { |hash, key| hash[key] = Set.new } | |
def add_dependency?(from, to) |
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
# Simplified from the original to exemplify the badness | |
begin | |
transaction do | |
@record.save! if @record.valid? | |
end | |
rescue ActiveRecord::RecordInvalid | |
end |
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
tax n | |
| n > 60000 = calc n 60000 0.45 | |
| n > 30000 = calc n 30000 0.30 | |
| n > 15000 = calc n 15000 0.15 | |
| otherwise = 0 | |
where calc n t r = ((n - t) * r) + tax t | |
> tax 72000 | |
=> 16500.0 |
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
taxRate threshold rate (total, amount) | |
| amount > threshold = (total + (amount - threshold) * rate, threshold) | |
| otherwise = (total, 0) | |
taxTable = [taxRate 60000 0.45, taxRate 30000 0.30, taxRate 15000 0.15] | |
tax amount = fst (calc(0, amount) taxTable) | |
where calc (total, remainder) [] = (total, remainder) | |
calc (total, remainder) (f:fs) = calc (f (total, remainder)) fs |
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
Welcome to interactive ruby! | |
irb --> RUBY_VERSION | |
==> "1.9.1" | |
irb --> {} == {} | |
==> true | |
irb --> {}.eql?({}) | |
==> true |
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
Merriam-Webster notes, "Recent criticism of the use of myriad as a noun, both | |
in the plural form myriads and in the phrase a myriad of, seems to reflect a | |
mistaken belief that the word was originally and is still properly only an | |
adjective.... however, the noun is in fact the older form, dating to the 16th | |
century. The noun myriad has appeared in the works of such writers as Milton | |
(plural myriads) and Thoreau (a myriad of), and it continues to occur | |
frequently in reputable English. There is no reason to avoid it." | |
(via http://en.wikipedia.org/wiki/Myriad) |
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 'rack' | |
module Rack | |
class Obama | |
CONTENT_TYPE = "nobel-prize/peace".freeze | |
def initialize(app) | |
@app = app |
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 'rack' | |
module Rack | |
class Pot | |
CONTENT_TYPE = "application/coffee-pot-command".freeze | |
def initialize(app) | |
@app = app |
OlderNewer