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
@quangtt-rks
quangtt-rks / moo.zsh-theme
Last active September 22, 2017 08:49
Incident theme for Oh-my-zsh
autoload -Uz vcs_info
GREEN="%{$fg_bold[green]%}"
YELLOW="%{$fg_bold[yellow]%}"
CYAN="%{$fg_bold[cyan]%}"
RED="%{$fg_bold[red]%}"
RESET="%{$reset_color%}"
zstyle ':vcs_info:*' stagedstr '%F{green}●'
zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
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 / sample_apache2_loadbalancer.conf
Created April 5, 2017 08:34
Sample config for load balancer on localhost
Listen 8080
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
ServerName 192.168.xxx.xxx
ProxyRequests Off
<Proxy balancer://mycluster>
BalancerMember http://192.168.xxx.yyy:8080 route=lb1
BalancerMember http://192.168.xxx.zzz:8080 route=lb2
ProxySet lbmethod=byrequests
@quangtt-rks
quangtt-rks / upgrade_ghost_blog.sh
Last active April 21, 2017 08:55
Auto upgrade Ghost blog (version 0.x.x). Tired of typing so many commands when upgrading? Write your own script!
#!/bin/sh
# This script works only on my system, edit it before apply to your system!
echo "\n Ghost Upgrader"
waiting_sign=" ⌛"
okay_sign=" ✓"
ng_sign=" ✗"
ghost_dir="/var/www/ghost"
@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