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 'zlib' | |
| require 'json' | |
| Zlib::GzipReader.open(ARGV[0]) do |gz| | |
| foo = "[#{gz.read}]" | |
| puts JSON.parse(foo)[0].to_s | |
| 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 ruby | |
| require 'logger' | |
| # rotatelogs required... | |
| # http://httpd.apache.org/docs/2.2/programs/rotatelogs.html | |
| logger = Logger.new("|rotatelogs ./foo.log.%Y-%m-%d-%H 3600", 0, 0) | |
| 10.times do | |
| logger.error "testing..." |
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 main | |
| raise "oh crap!" | |
| end | |
| main | |
| at_exit { puts $! if $! } | |
| # at_exit_example.rb:3:in `main': oh crap! (RuntimeError) | |
| # from at_exit_example.rb:6:in `<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
| #!/usr/bin/env ruby | |
| require 'net/http' | |
| http = Net::HTTP.new('www.iana.org') | |
| http.set_debug_output $stderr | |
| http.start do |http| | |
| request = Net::HTTP::Get.new('/domains/example') | |
| response = http.request request | |
| 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 ruby | |
| require 'net/http' | |
| require 'pp' | |
| string_output = StringIO.new | |
| http = Net::HTTP.new('www.iana.org') | |
| http.set_debug_output string_output | |
| http.start do |http| | |
| request = Net::HTTP::Get.new('/domains/example') |
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
| <%= raw CGI.unescapeHTML(Mustache.render(@bio.madlib.body, Hash[@bio.madlib.values.map{|k,v| [k, content_tag(:div, text_field_tag("bio[values][#{k}]", (@bio.values[k] if @bio.values), :placeholder => v), :class => 'input-container')]}])) %> |
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
| Is a directory - lib | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429/gems/flog-4.1.0/lib/flog.rb:177:in `binread' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429/gems/flog-4.1.0/lib/flog.rb:177:in `block in flog' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429/gems/flog-4.1.0/lib/flog.rb:174:in `each' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429/gems/flog-4.1.0/lib/flog.rb:174:in `flog' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429/gems/flog-4.1.0/lib/flog_task.rb:55:in `block in define' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `call' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429@global/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `each' | |
| /Users/scott/.rvm/gems/ruby-1.9.3-p429@global/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute' |
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 rspec | |
| class Foo | |
| def foo! | |
| File.open("foo.txt", "w") do |f| | |
| f.write "hello!" | |
| end | |
| 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
| require 'rubygems' | |
| require 'rack' | |
| app = Rack::Builder.new | |
| app.run Rack::Directory.new(Dir.pwd) | |
| Rack::Server.start :app => app, :Port => 3000 |
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 'webrick' | |
| server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => Dir.pwd | |
| trap 'INT' do server.shutdown end | |
| server.start |