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
| 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 |
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
| # >> 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 |
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
| 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 |
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
| <form onsubmit="new Ajax.Request('/subscriptions/800', {asynchronous:true, evalScripts:true, onComplete:function(request){replace_all_duplicate_buttons("subscribeForm-Show52", | |
| "SubscribeForm-Show52");}, onLoading:function(request){subscription_loading_subscribed('SubscribeForm1-Show52')}, onSuccess:function(request){unsubscribe('SubscribeForm1-Show52', 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> |
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
| // 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); |
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 FeelMyFlow < Widget | |
| def initialize | |
| stack do | |
| para "new" | |
| para "lines" | |
| para "plz" | |
| 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
| >> 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 |
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
| 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 |
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 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 |
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
| 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) |