Skip to content

Instantly share code, notes, and snippets.

View greatseth's full-sized avatar

Seth Thomas Rasmussen greatseth

View GitHub Profile
Given /^(the|a|another) user sets his (activity|videos|subscriptions|subscribers) to (public|private)/ do |pronoun, privacy_type, setting|
bool = if setting == 'private'
false
elsif setting == 'public'
true
end
@user2.send((privacy_type + '_public=').to_sym, bool)
@user2.save
@user2.reload
# >> Video 1
# => #<Video ...>
def method_missing msg, *args, &block
model = begin;
Object.const_get msg
rescue NameError
end
if model and model.descends_from_active_record?
model.find args.first
next_hour = begin
Time.mktime( Time.now.year, Time.now.month, Time.now.day, Time.now.hour+1 )
rescue ArgumentError
# this will keep it from failing when run between 11pm and midnight :\
Time.mktime( Time.now.year, Time.now.month, Time.now.day+1, Time.now.hour+1 )
end
<form onsubmit="new Ajax.Request(&#39;/subscriptions/800&#39;, {asynchronous:true, evalScripts:true, onComplete:function(request){replace_all_duplicate_buttons(&quot;subscribeForm-Show52&quot;,
&quot;SubscribeForm-Show52&quot;);}, onLoading:function(request){subscription_loading_subscribed(&#39;SubscribeForm1-Show52&#39;)}, onSuccess:function(request){unsubscribe(&#39;SubscribeForm1-Show52&#39;, request.responseText.evalJSON());}, parameters:Form.serialize(this)}); return false;" method="post" id="new_subscription" class="subscriptionForm" action="/subscriptions/800">
<input type="submit" value="Unsubscribe from Show" title="Unsubscribe from Show" name="commit" class="submitButton input_submit unsubscribe"/>
<label><span>New Saturday Night Live videos will be posted to your subscriptions feed in your profile.</span></label>
<input type="hidden" name="_method" value="delete"/><input type="hidden" name="format" value="js"/></form>
// form posts to a different url
// change 'subscribe' callback to 'unsubscribe'
// change loading
var form_element = obj.down('form');
var onsubmit = form_element.getAttribute('onsubmit').toString();
var onloading = 'onLoading:function(request){subscription_loading_unsubscribed(\'' + container_id + '\')}';
var new_onsubmit = onsubmit.gsub(/'\/subscriptions\/[\d]+'/, "'\/subscriptions'").gsub(/\{unsubscribe\(/, '{subscribe(').gsub(/onLoading:function\(request\)\{[^}]+\}/, onloading);
form_element.setAttribute('onsubmit', new_onsubmit);
class FeelMyFlow < Widget
def initialize
stack do
para "new"
para "lines"
para "plz"
end
end
end
>> j.to_json
=> "{\"current_status\": \"completed\", \"downloading_progress\": 100, \"complete?\": true, \"id\": 74, \"downloading_status\": \"Download complete\", \"encoding_progress\": 100, \"encoding_status\": \"complete\", \"delivering_progress\": 100, \"current_progress\": null, \"delivering_status\": \"Delivery complete\"}"
>> { :jobs => [j] }.to_json
TypeError: wrong argument type Hash (expected Data)
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb:21:in `to_json'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb:21:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb:21:in `encode'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb:31:in `raise_on_circular_reference'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/json/encoding.rb:20:in `encode'
from /usr/local/lib/ruby/ge
Shoes.app :width => 300, :height => 300 do
(1..9).each do |n|
stack :width => 100, :height => 100 do
border black
click { alert "clicked stack #{n}" }
end
end
end
def inject_status_in_response
yield
case request.format.to_sym
when :json
json = JSON.parse response.body
json["status"] = {
:code => response.status[/\d+/],
:message => @status_message
}
response.body = json.to_json
ruby(2802) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
ruby(2802) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
ruby(2802) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
ruby(2802) malloc: *** mmap(size=2097152) failed (error code=12)