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
| require 'encryption_contract' | |
| # Naive and totally lame encrypter that just reverses the string. | |
| class ReverseEncrypter | |
| include EncryptionContract | |
| def encrypt(s) | |
| s.reverse | |
| 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
| <?xml version="1.0"?> | |
| <kml xmlns="http://earth.google.com/kml/2.1"> | |
| <Document> | |
| <Placemark> | |
| <name>Reston, Va</name> | |
| <description>Anchor_Name: Reston, Va<br/> Canonical Name: <br/>Country Name: US<br/>Population: 6829<br/></description> | |
| <Point> | |
| <coordinates>17,47</coordinates> | |
| </Point> | |
| </Placemark> |
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
| def parse(input_array, max_elements, output_array = []) | |
| (input_array && (! input_array.empty?)) \ | |
| ? parse(input_array[max_elements..-1], max_elements, output_array << input_array[0...max_elements]) \ | |
| : output_array | |
| 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
| Success : Yes | |
| Total Resistance : 16 | |
| Row Numbers : 1, 2, 3, 4, 4, 5 | |
| . | |
| Success : Yes | |
| Total Resistance : 11 | |
| Row Numbers : 1, 2, 1, 5, 5, 5 | |
| . |
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
| import org.jruby.Ruby; | |
| import org.jruby.RubyArray; | |
| import org.jruby.RubyFixnum; | |
| import org.jruby.RubyInstanceConfig; | |
| import org.jruby.RubyModule; | |
| import org.jruby.anno.JRubyMethod; | |
| import org.jruby.ast.executable.AbstractScript; | |
| import org.jruby.ast.executable.RuntimeCache; | |
| import org.jruby.internal.runtime.methods.CallConfiguration; | |
| import org.jruby.javasupport.util.RuntimeHelpers; |
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
| =begin | |
| Reference: $100,000 from table, single status -> $21,330, $78,670 | |
| Income: 100000.00 Tax: 21617.00 After Tax: 78383.00 | |
| Income: 100010.00 Tax: 21619.80 After Tax: 78390.20 | |
| Income: 100020.00 Tax: 21622.60 After Tax: 78397.40 | |
| Income: 100030.00 Tax: 21625.40 After Tax: 78404.60 | |
| Income: 100040.00 Tax: 21628.20 After Tax: 78411.80 | |
| Income: 100050.00 Tax: 21631.00 After Tax: 78419.00 |
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
| # This file is an rspec runnable file. | |
| # (I didn't name it with _spec because its primary purpose is to provide | |
| # the method, not run the test.) | |
| # Here's the function that solves the problem, and the require needed to run it. | |
| require 'uri' | |
| def query_to_hash(query) |
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
| # Shouldn't this fail with the 'include Runnable' disabled? | |
| require 'java' | |
| java_import 'java.lang.Runnable' | |
| class SampleRunnable | |
| # include Runnable | |
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
| require 'java' | |
| java_import 'java.lang.Runnable' | |
| class SampleRunnable | |
| include Runnable | |
| def initialize(greeting) | |
| @greeting = greeting |
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 | |
| # Mails a file using GMail's SMTP Server. | |
| # For illustrative purposes; error checking and testing intentionally omitted for brevity. | |
| # | |
| # Requirements: | |
| # 1) the 'mail' gem must be installed | |
| # 2) a file named 'pw.txt' containing the Google password must be present | |
| # in the current directory. | |
| # | |
| # Ruby versions: tested on 1.9.3, 1.8.7, JRuby |