Skip to content

Instantly share code, notes, and snippets.

View xxswingxx's full-sized avatar
🏠
Working from home

John Wu xxswingxx

🏠
Working from home
View GitHub Profile
@frane
frane / ArrayObjectDemo.coffee
Created December 31, 2011 02:19
Traversing arrays and objects in CoffeeScript
# 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)
@Belgand
Belgand / gist:2856947
Created June 2, 2012 06:18 — forked from hileon/gist:1311735
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Ubuntu)

General

Ctrl+KB toggle side bar
Ctrl+Shift+P command palette
Ctrl+` python console
Ctrl+N new file

Editing

@kazpsp
kazpsp / passwords_controller.rb
Created August 14, 2012 16:40 — forked from guilleiguaran/passwords_controller.rb
StrongParameters with Devise
# 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
@selvan
selvan / oauth2-google-refresh-token
Created January 23, 2013 08:42
Geting new access token using refresh token - Google oauth2
### 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!
@joost
joost / webhooks_controller.rb
Last active February 4, 2021 13:39
Mandrill API Webhook signature verification. This shows how you could verify a Mandrill signature in a Rails Controller.
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
@wojtha
wojtha / Locales.yaml
Created January 15, 2014 10:13 — forked from s-andringa/Locales.yml
config.exceptions_app and ExceptionController
# 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"
@ArturT
ArturT / Fix OpenSSL Padding Oracle vulnerability (CVE-2016-2107) - Ubuntu 14.04
Last active June 20, 2018 11:46
Fix OpenSSL Padding Oracle vulnerability (CVE-2016-2107) - Ubuntu 14.04
# 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
@tinogomes
tinogomes / DNS_TO_LOCALHOST.markdown
Last active July 18, 2024 14:08
Public DNS Pointing to localhost (127.0.0.1)

Available Public Wildcard DNS Domains pointing to localhost (127.0.0.1)

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
@Pablo-R
Pablo-R / lcd.rb
Created September 19, 2017 10:49
LCD Numbers
#!/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,
@Pablo-R
Pablo-R / lcd.rb
Created September 19, 2017 10:50
LCD Numbers Another Version
#!/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' ],