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
| 2012-09-27 18:08:53.258 growlnotify[83684:707] Got disconnected: Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo=0x7fb3e2a0f900 {NSLocalizedDescription=Connection refused, NSLocalizedFailureReason=Error in connect() function} | |
| 2012-09-27 18:08:53.260 growlnotify[83684:707] <GrowlGNTPRegistrationAttempt: 0x7fb3e2a0f770> failed because Error Domain=NSPOSIXErrorDomain Code=61 "Connection refused" UserInfo=0x7fb3e2a0f900 {NSLocalizedDescription=Connection refused, NSLocalizedFailureReason=Error in connect() function} | |
| 2012-09-27 18:08:53.260 growlnotify[83684:707] Failed to register with (null) |
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
| #!/bin/env ruby | |
| require 'rubygems' | |
| require 'pony' | |
| # total memory used | |
| total_memory_used = `free | awk '$1=="Mem:" {print $3 / $2 * 100}'`.to_i | |
| # active memory used | |
| used = `awk '$1=="Active:"{active=$2}$1=="MemTotal:"{total=$2}END{print active/total * 100}' /proc/meminfo`.to_i |
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 'timeout' | |
| Timeout.timeout(rand) do # random number between 0 and 1 (seconds) | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 |
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 do_jobs | |
| begin | |
| while true | |
| # do interesting things | |
| end | |
| rescue NoMoreDiskSpace | |
| # tidy things up | |
| 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 'thread' | |
| t = Thread.new{ | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| sleep 0.1 | |
| } |
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
| t = Thread.start{ | |
| begin | |
| puts "starting executing code!" | |
| sleep 1 | |
| puts "done executing code!" # we don't expect to reach here | |
| rescue Exception | |
| puts "rescuing!" # we don't expect to reach here | |
| ensure | |
| puts "ensuring!" # will we reach here????? (yes) | |
| 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
| def generate_continue_object(*args) | |
| args.each{|a| puts a.inspect} | |
| yield if block_given? | |
| continue_object = Object.new | |
| def continue_object.next_block | |
| if block_given? | |
| yield |
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
| self.class._create_callbacks.select { |callback| callback.kind.eql?(:after) }.collect(&:filter) |
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 subject(throws, catches) | |
| $inner_succeeded=nil | |
| $raised_in_inner=nil | |
| $caught_in_inner=nil | |
| $raised_in_outer=nil | |
| $not_raised_in_outer=nil | |
| begin | |
| Timeout.timeout(0.1, throws){ | |
| begin |
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 'timeout' | |
| def process_foos(error_to_rescue) | |
| begin | |
| # -> process Foos | |
| # -> if we run out of Foos, raise | |
| sleep 2 | |
| rescue error_to_rescue | |
| # -> email the manager that we ran out of Foos | |
| puts <<-MESSAGE |