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 'spec_helper' | |
| describe YourClass do | |
| describe "some functionality that depends on YourClass::your_method" do | |
| # YourClass.stub(:your_method).and_return(true) is equivalent to: | |
| YourClass.stub(:your_method) { true } | |
| 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
| # a typical controller spec | |
| require 'spec_helper' | |
| describe PaymentsController do | |
| # A typical model mock object (with memoization ftw): | |
| def mock_customer_user(stubs={}) | |
| @mock_customer_user ||= mock_model(CustomerUser, stubs).as_null_object | |
| 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
| crickets: "hears crickets chirping" | |
| drama: "https://123.campfirenow.com/images/drama.jpg" | |
| greatjob: "https://123.campfirenow.com/images/greatjob.png" | |
| live: "is DOING IT LIVE" | |
| nyan: "https://123.campfirenow.com/images/nyan.gif" | |
| ohmy: "raises an eyebrow :smirk:" | |
| pushit: "https://123.campfirenow.com/images/pushit.gif" | |
| rimshot: "plays a rimshot" | |
| secret: "found a secret area :key:" | |
| tada: "plays a fanfare :flags:" |
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 Array | |
| def max_subarray_last_index | |
| max_sum = new_maxium = last_index = 0 | |
| each_with_index do |value, i| | |
| new_maxium = [new_maxium + value, 0].max | |
| # update everything if we found a truly new maximum =) | |
| max_sum, last_index = new_maxium, i if max_sum < new_maxium | |
| 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
| 1.9.2p290 :026 > @hold = Balanced::Hold.find :first | |
| => #<Balanced::Hold:0x000001030cf6f8 @attributes={"account"=>#<Balanced::Account:0x00000102f809c8 @attributes={"holds_uri"=>"/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC5xQY0AdN6Ex8i7QOIsbPZQ/holds", "name"=>"New Buyer", "roles"=>["buyer"], "created_at"=>"2012-07-06T19:28:06.379052Z", "uri"=>"/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC5xQY0AdN6Ex8i7QOIsbPZQ", "bank_accounts_uri"=>"/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC5xQY0AdN6Ex8i7QOIsbPZQ/bank_accounts", "refunds_uri"=>"/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC5xQY0AdN6Ex8i7QOIsbPZQ/refunds", "meta"=>{}, "debits_uri"=>"/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC5xQY0AdN6Ex8i7QOIsbPZQ/debits", "transactions_uri"=>"/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC5xQY0AdN6Ex8i7QOIsbPZQ/transactions", "email_address"=>"david+new+buyer@bizeebee.com", "id"=>"AC5xQY0AdN6Ex8i7QOIsbPZQ", "credits_uri"=>"/v1/marketpl |
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
| {"status":402,"error":{"status":"Payment Required","category_code":"card-declined","status_code":"402","category_type":"banking","request_id":"OHMa0f08dee188711e2b2ae026ba7d31e6f","description":"Processor did not accept this card. Your request id is OHMa0f08dee188711e2b2ae026ba7d31e6f."}} |
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
| HTML colors are broken into 3 components: | |
| R: Red | |
| G: Green | |
| B: Blue | |
| These 3 components may be represented in hexadecimal. | |
| A hexadecimal representation of the 3 components is called a triplet, or group of 3 numbers. | |
| R G B R G B |
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
| { | |
| "status": "Payment Required", | |
| "category_code": "card-declined", | |
| "additional": "Generic decline - No other information is being provided by the issuer.", | |
| "status_code": 402, | |
| "category_type": "banking", | |
| "extras": {}, | |
| "request_id": "OHMf496075c292211e2ad35026ba7d31e6f", | |
| "description": "R530: Do Not Honor. Your request id is OHMf496075c292211e2ad35026ba7d31e6f." | |
| } |
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 you are on a mac, please follow these instructions to get your sublime link set up appropriately. | |
| Run this command if you have sublime text 2: | |
| echo "alias subl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl'" >> ~/.bash_profile | |
| Or, if you have sublime text 3, run this command: | |
| echo "alias subl='/Applications/Sublime\ Text\ 3.app/Contents/SharedSupport/bin/subl'" >> ~/.bash_profile |
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
| /* | |
| Functions containing no free/unbound variables are called pure functions. | |
| Functions containing one or more free variables are called closures. | |
| Adapted from the quick exercise in https://leanpub.com/javascript-allonge/read#closures | |
| If pure functions can contain closures, can a closure contain a pure function? | |
| Attempt to compose a closure that contains a pure function. | |
| Many thanks to @raganwald! |