This file contains 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
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoding.rb:28:raise_on_circular_reference | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoding.rb:20:encode | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb:42:to_json | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb:41:map | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb:41:to_json | |
[GEMS]/activesupport-2.2.2/lib/active_support/core_ext/object/misc.rb:39:returning | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoders/hash.rb:40:to_json | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoding.rb:21:send | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoding.rb:21:encode | |
[GEMS]/activesupport-2.2.2/lib/active_support/json/encoding.rb:31:raise_on_circular_reference |
This file contains 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 Float | |
def to_percent | |
(self*100).to_s.gsub(/(.\.)(\d\d).*/,'\1\2') | |
end | |
end | |
$stdout.sync = true | |
def spinner(i) | |
return(['\\','|','/','-'][i%4]) | |
end |
This file contains 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
# Lo-fi client for the Facebook API. E.g.: | |
# | |
# fb = FacebookClient.new(:api_key => 'api-key', :secret => 'secret') | |
# fb.call 'users.getInfo', :session_key => 'session-key', :uids => 'user-id', :fields => 'birthday' | |
# | |
class FacebookClient | |
def initialize(default_params={}) | |
@default_params = default_params.reverse_merge({ | |
:rest_server => 'http://api.new.facebook.com/restserver.php', | |
:format => 'JSON', |
This file contains 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
# first arg is goal time in either seconds or ##:## | |
# second arg is distance in meters (optional) | |
# EXAMPLE ruby running_pace.rb 15:30 5000 | |
class Float | |
def seconds_to_minutes | |
"#{self.to_i/60}:#{(self.to_f%60.0).rjust}" | |
end | |
def rjust |
This file contains 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
# oauth gem 0.3.5 send oob as the oauth_callback parameter which forces twitter into desktop mode | |
# this patches oauth gem to send a blank value instead | |
module OAuth | |
if defined?(OUT_OF_BAND) | |
self.send('remove_const','OUT_OF_BAND') | |
OUT_OF_BAND = "" | |
end | |
end |
This file contains 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
# To demo in irb: | |
# load 'spinner.rb' ; include Spinner ; spinner_demo | |
# | |
# To use, include this module in a class and then wrap something in with_spinner | |
# It has two params, both optional. See spinner_demo for usage examples. | |
module Spinner | |
def with_spinner total=nil, message="Working...", &blk | |
current=0 | |
shown=buildstr(message,current,total) |
This file contains 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
# ** how to call from rails app ** | |
# put this file in the lib directory | |
# REQUIRES a central Cache store across all your webservers (i.e. mem_cache_store) | |
# paste the following inside the Rails initializer block in environment.rb | |
# config.middleware.use "LiveStats" | |
# create the following controller action | |
# def live | |
# html = Rails.cache.fetch("live_stats", :expires_in => 30.seconds) do | |
# ls = LiveStats.new | |
# ls.chart+"<br />"+ls.referrer_chart+"<br />"+"<pre>"+ls.referrer_histogram.to_yaml+"</pre>" |
This file contains 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
<IfModule mpm_prefork_module> | |
StartServers 10 | |
MinSpareServers 10 | |
MaxSpareServers 80 | |
MaxClients 230 | |
MaxRequestsPerChild 3000 | |
</IfModule> |
This file contains 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 SomeJob | |
def perform | |
do_some_stuff | |
Delayed::Job.enqueue(SomeJob.new, 0, 1.minute.from_now) | |
end |
This file contains 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
# you'd obviously have more settings somewhere | |
set :scm, :git | |
set :repository, "git@github.com:defunkt/github.git" | |
set :branch, "origin/master" | |
set :migrate_target, :current | |
set(:latest_release) { fetch(:current_path) } | |
set(:release_path) { fetch(:current_path) } | |
set(:current_release) { fetch(:current_path) } |
OlderNewer