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
# 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) |
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
### 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
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
# config/locales/en.yml | |
en: | |
exception: | |
show: | |
not_found: | |
title: "Not Found" | |
description: "The page you were looking for does not exists." | |
internal_server_error: | |
title: "Internal Server Error" |
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
# Based on http://fearby.com/article/update-openssl-on-a-digital-ocean-vm/ | |
$ sudo apt-get update | |
$ sudo apt-get dist-upgrade | |
$ wget ftp://ftp.openssl.org/source/openssl-1.0.2h.tar.gz | |
$ tar -xvzf openssl-1.0.2h.tar.gz | |
$ cd openssl-1.0.2h | |
$ ./config --prefix=/usr/ | |
$ make depend |
The best way to safely and securely use local domains pointing to 127.0.0.1 is to edit your local settings (/etc/hosts) and add your own settings. Keep in mind if you want to use subdomains, you need to enter all variations.
Example:
# Adding bottom of your current file /etc/hosts
################# MY LOCAL DOMAINS
127.0.0.1 local.com admin.local.com
127.0.0.1 domain1.com
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
#!/usr/bin/ruby | |
class LCDNumber | |
def initialize(size, input_number) | |
@input_number = input_number | |
@size = size | |
@symbol_style = { | |
horizontal_line_yes: " " + "-" * @size + " ", | |
vertical_line_both: ["|" + " " * @size + "|"] * @size, |
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
#!/usr/bin/ruby | |
class LCDNumber | |
def initialize(size, input_number) | |
@input_number = input_number | |
@size = size | |
@display_code = [ | |
['horizontal_line_yes', 'vertical_line_both', 'horizontal_line_no', 'vertical_line_both', 'horizontal_line_yes' ], | |
['horizontal_line_no', 'vertical_line_right', 'horizontal_line_no', 'vertical_line_right', 'horizontal_line_no' ], |
OlderNewer