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 'active_model' | |
| class Foo | |
| include ActiveModel::Validations | |
| attr_accessor :name | |
| validates :name, :presence => true | |
| def initialize(options={}) |
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
| TEST_ACCOUNT_SID = 'whatever' | |
| TEST_AUTH_TOKEN = 'ha' | |
| require 'faraday' | |
| require 'base64' | |
| post_response = Faraday.post do |request| | |
| request.url "https://api.twilio.com/2010-04-01/Accounts/#{TEST_ACCOUNT_SID}/SMS/Messages.json" | |
| request.headers['Authorization'] = "Basic " + Base64.strict_encode64("#{TEST_ACCOUNT_SID}:#{TEST_AUTH_TOKEN}") | |
| request.body = URI.encode_www_form({'From' => '+15005550006', 'To' => '+14155551212', 'Body' => 'hello world!'}) |
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 'launchy' | |
| CLIENT_ID = 'a3506a51a28b4d639ca680123c43f88d' | |
| REDIRECT_URI = 'http://www.epicodus.com/' | |
| puts 'To use InstaCommandLine, you need to grant access to the app.' | |
| puts 'Press enter to launch your web browser and grant access.' | |
| gets | |
| Launchy.open "https://instagram.com/oauth/authorize/?client_id=#{CLIENT_ID}&redirect_uri=#{REDIRECT_URI}&response_type=token" |
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 'oauth' | |
| require 'launchy' | |
| CONSUMER_KEY = 'your_consumer_key' | |
| CONSUMER_SECRET = 'your_consumer_secret' | |
| CALLBACK_URL = 'oob' | |
| consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => "https://api.twitter.com/") | |
| request_token = consumer.get_request_token(:oauth_callback => CALLBACK_URL) |
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
| stub_request(:post, "https://api.twitter.com/oauth/request_token"). | |
| to_return(:body => "oauth_token=t&oauth_token_secret=s") | |
| stub_request(:post, "https://api.twitter.com/oauth/access_token"). | |
| to_return(:body => "oauth_token=at&oauth_token_secret=as&screen_name=sn") |
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 Triangle | |
| def initialize(sides) | |
| @sides = sides | |
| end | |
| def type | |
| @sides.sort! | |
| if @sides[0] + @sides[1] <= @sides[2] | |
| :invalid | |
| else |
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
| # run this block as root to avoid typing password | |
| sudo rm -rf /Applications/GarageBand.app/ /Applications/iMovie.app/ /Applications/iPhoto.app/ /User\ Information | |
| mkdir /usr/local | |
| curl -L https://github.com/Homebrew/homebrew/tarball/master | tar xz --strip 1 -C /usr/local | |
| sudo chown -R epicodus /usr/local | |
| xcode-select --install | |
| # manually click to start command line tools install, then run everything else as current user |
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
| var Player = { | |
| setNumber: function(number) { | |
| this.number = number; | |
| }, | |
| addPoints: function(points) { | |
| this.score += points; | |
| }, | |
| score: 0 | |
| }; |
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
| // VARIABLES | |
| // assign a variable to something - use the `var` keyword | |
| var myVariable = "i love variables"; | |
| // change the value of an existing variable - don't use `var` | |
| myVariable = "i REALLY love variables"; | |
| // change the value of a variable in place | |
| myVariable = myVariable + " - don't you?"; |
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
| // include a space after most keywords (eg var, if, else, for, return) | |
| var foo = "bar"; | |
| // include a space around operators | |
| foo === "bar"; | |
| foo += "qux"; | |
| // put a space after most closing parentheses | |
| // indent within if statements |