Skip to content

Instantly share code, notes, and snippets.

View quangtt-rks's full-sized avatar
🎸
Rocking

Quang Tran quangtt-rks

🎸
Rocking
View GitHub Profile
display: ;
visibility: ;
float: ;
clear: ;
position: ;
top: ;
right: ;
bottom: ;
left: ;

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@quangtt-rks
quangtt-rks / devise.rb
Created June 30, 2016 09:32 — forked from nicalpi/devise.rb
Omniauth multiple facebook login strategy
# initializers/devise.rb
config.omniauth :facebook, [APP_ID], [APP_SECRET]
config.omniauth :facebook_app1, [APP_ID], [APP_SECRET], :iframe => true, :scope => 'publish_stream,offline_access,email'
config.omniauth :facebook_app2, [APP_ID], [APP_SECRET], :iframe => true, :scope => 'publish_stream,offline_access,email'
@quangtt-rks
quangtt-rks / build_mysql.sh
Last active July 4, 2017 01:23 — forked from shichao-an/build_mysql.sh
Build and install MySQL 5.1 from source on Ubuntu 14.04, 12.04
#!/bin/bash
# Run as root
set -e
apt-get update
apt-get install -y build-essential
apt-get install -y libncurses5-dev
useradd mysql
@quangtt-rks
quangtt-rks / gist:5505f46c5bd6343df3d7862acd1a6e41
Created October 11, 2017 01:31
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@quangtt-rks
quangtt-rks / gist:2f6d96f2e8512d75b1794c406028fa9b
Last active October 11, 2017 09:16 — forked from bentonporter/gist:2891463
Ruby - HMAC-SHA256 example
require 'openssl'
require 'Base64'
key = "secret-key"
data = "some data to be signed"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip()
@quangtt-rks
quangtt-rks / gist:edd92249b41fd1e0b957b20d7771c2a8
Created October 11, 2017 09:16 — forked from ericchen/gist:3081968
ruby openssl AES encrypt and decrypt
require 'base64'
require 'digest'
require 'openssl'
module AESCrypt
def AESCrypt.encrypt(password, iv, cleardata)
cipher = OpenSSL::Cipher.new('AES-256-CBC')
cipher.encrypt # set cipher to be encryption mode
cipher.key = password
@quangtt-rks
quangtt-rks / downgrade.sh
Created January 31, 2018 03:58 — forked from 1v/downgrade.sh
Apache 2.2.22 + PHP 5.3.10 on Ubuntu 14.04
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
apt-get update
apt-get remove \
apache2 \