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
| class Foo | |
| attr_reader :a, :b | |
| def initialize | |
| @a = 'a-Foo' | |
| @b = 'b-Foo' | |
| end | |
| end | |
| class Bar | |
| attr_reader :a, :c |
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 'rubygems' | |
| require 'sinatra' | |
| require 'json' | |
| get '/', :provides => 'json' do | |
| data = {"key1" => ["a", "b"], | |
| "key2" => 10} | |
| JSON::dump(data) | |
| 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
| val (scalatestArtifact, scalatestVersion) = buildScalaVersion match | |
| { | |
| case "2.7.7" => ("scalatest", "1.2") | |
| case "2.8.0" => ("scalatest", "1.3") | |
| case "2.8.1" => ("scalatest", "1.3") | |
| case "2.9.0" => ("scalatest_2.9.0", "1.4.1") | |
| case n => error("Unsupported Scala version " + n) | |
| } | |
| val scalatest = "org.scalatest" % scalatestArtifact % scalatestVersion % "test" |
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
| # Test of Goo.gl Ruby gem. Install via: | |
| # | |
| # $ gem install googl | |
| # | |
| # See | |
| # http://code.google.com/apis/urlshortener/v1/getting_started.html#shorten | |
| # for Goo.gl API info. | |
| require 'rubygems' | |
| require 'googl' |
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
| # Test of Goo.gl Python front-end available at | |
| # http://code.google.com/p/python-googl/source/checkout | |
| # | |
| # Some kind of JSON parser must be installed. 'simplejson' works fine. | |
| # | |
| # See | |
| # http://code.google.com/apis/urlshortener/v1/getting_started.html#shorten | |
| # for Goo.gl API info. | |
| import googl |
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 | |
| # | |
| # Fix an EPUB document generated by Pandoc to have a title page. | |
| # | |
| # Usage: fixepub epub_in epub_out cover_png | |
| # | |
| # Only supports PNG at the moment, but easily hacked to support JPEG. | |
| # | |
| # Requires these gems: | |
| # |
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
| # Override the SMTP settings, for local testing. | |
| $smtp_address = 'mail.inside.ardentex.com' | |
| $smtp_domain = 'inside.ardentex.com' | |
| $smtp_auth_type = nil | |
| $smtp_user = nil | |
| $smtp_password = nil | |
| $smtp_port = 25 |
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
| Rails::Initializer.run do |config| | |
| # The following globals define the default SMTP configuration. To | |
| # change the configuration in your environment, simply set these globals | |
| # in your environment configuration (config/*.rb) file. | |
| $smtp_address = 'smtpserver.example.com' | |
| $smtp_domain = 'example.com' | |
| $smtp_auth_type = :plain | |
| $smtp_user = '[email protected]' | |
| $smtp_password = 'secret' |
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
| class CallableHash < Hash | |
| def initialize(h) | |
| h.each do |k, v| | |
| self[k] = v | |
| end | |
| @@methods = {} | |
| end | |
| def respond_to?(sym) | |
| true |
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
| puts("Caller PID = #{Process.pid}") | |
| puts("Caller UID = #{Process.uid}") | |
| as_user "bmc" do |user| | |
| puts("In child process. User=#{user}, PID=#{Process.pid}, UID=#{Process.uid}") | |
| end |