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
| synchronized (JobTracker.this) { | |
| synchronized (jobs) { | |
| synchronized (taskScheduler) { | |
| for (JobInProgress job: retiredJobs) { | |
| removeJobTasks(job); | |
| jobs.remove(job.getProfile().getJobID()); | |
| for (JobInProgressListener l : jobInProgressListeners) { | |
| l.jobRemoved(job); | |
| } | |
| String jobUser = job.getProfile().getUser(); |
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
| #optimizeContent{:class=>"{url: '#{url_for :overwrite_params =>{:action => action_state }}'}"} |
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 #v1 | |
| def initialize(value) | |
| @value = value | |
| end | |
| def add | |
| 37 + @value | |
| 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
| if true | |
| foo = 1 | |
| else | |
| bar = 2 | |
| end | |
| puts foo.inspect # output is "1" | |
| puts bar.inspect # output is "nil" - bar is defined even though the if statement always fails | |
| puts baz.inspect # raises NameError |
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 CacheInstrumentation | |
| def self.filter(controller) | |
| begin | |
| cache_timing = { :min => nil, :max => nil, :keys => [], :count => 0, :total => 0.0 } | |
| # redefine Rails.cache.fetch for this request | |
| real_fetch_method = Rails.cache.method(:fetch) | |
| Rails.cache.metaclass.send(:define_method, :fetch) do |*args, &block| | |
| begin | |
| start_time = Time.now.to_f |
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
| # TMail was crashing trying to process very large messages in a regexp | |
| # match to check to see if the message body is UTF-8 or something | |
| # crazy like ShiftJIS or some other Japanese thing. Let's just go | |
| # ahead and assume that we're always dealing with UTF8 messages to fix | |
| # the crash. | |
| # | |
| # This will probably break lots of other things. I am going straight | |
| # to hell for this. | |
| class String | |
| def isutf8 |
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' | |
| # wow that's a lot of unnecessary dependencies | |
| %w(builder nokogiri rubyzip google-spreadsheet-ruby spreadsheet roo).each { |g| gem g } | |
| require 'roo' | |
| in_file = ARGV.shift | |
| spreadsheet = Excelx.new(in_file) |
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
| source /usr/local/share/doc/git-core/contrib/completion/git-completion.bash | |
| # git status with a dirty flag | |
| function __git_status_flag { | |
| git_status="$(git status 2> /dev/null)" | |
| remote_pattern="^# Your branch is (.*) of" | |
| diverge_pattern="# Your branch and (.*) have diverged" | |
| if [[ ! ${git_status}} =~ "working directory clean" ]]; then | |
| state="⚡" | |
| spacer=" " |
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
| brad@brad-laptop:~ $ macirb | |
| irb(main):001:0> framework 'Cocoa' | |
| => true | |
| irb(main):002:0> app = NSApplication.sharedApplication | |
| => #<NSApplication:0x8003a8500> | |
| irb(main):003:0> status_bar = NSStatusBar.systemStatusBar | |
| => #<NSSystemStatusBar:0x8003b8ec0> | |
| irb(main):004:0> item = status_bar.statusItemWithLength(NSVariableStatusItemLength) | |
| => #<NSStatusItem:0x8003b7c00> | |
| irb(main):005:0> item.title = "Hello MacRuby!" |
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 'histogram' | |
| class AutoHistogram | |
| def initialize | |
| @values = [] | |
| end | |
| def push(values) | |
| if values.kind_of? Numeric | |
| @values << values |
OlderNewer