Ctrl+KB | toggle side bar |
Ctrl+Shift+P | command palette |
Ctrl+` | python console |
Ctrl+N | new file |
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 WebhooksController < ActionController::Base | |
WEBHOOK_KEY = "some_key" # You could also use an API request to lookup the key | |
before_filter :verify_request_signature | |
# See: http://help.mandrill.com/entries/23704122-Authenticating-webhook-requests | |
def verify_request_signature | |
signed_data = request.url | |
post_params = request.request_parameters.dup # POST parameters |
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
### Method 1 | |
gem install oauth2 | |
require 'oauth2' | |
client = OAuth2::Client.new(GOOGLE_KEY, GOOGLE_SECRET, {:site => 'https://accounts.google.com', :authorize_url => "/o/oauth2/auth", :token_url => "/o/oauth2/token"}) | |
response = OAuth2::AccessToken.from_hash(client, :refresh_token => REFRESH_TOKEN).refresh! |
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
# app/controllers/users/password_controller.rb | |
class Users::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(:user).permit(:email, :password, :password_confirmation) | |
end | |
private :resource_params | |
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
# Traversing arrays and objects in CoffeeScript | |
# The array and object we use for testing | |
arr = [1, 2, 3, 4, 5] | |
obj = {a: 1, b: 2, c: 3, d: 4, e: 5} | |
# 'in' has a different meaning in CoffeeScript than in JavaScript | |
# CS: element in array -> JS: array.indexOf(element) >= 0 | |
console.log '5 in arr: ' + (5 in arr) |
NewerOlder