Skip to content

Instantly share code, notes, and snippets.

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.
@ringate
ringate / react-project-setup.md
Created June 26, 2020 09:13
Create React project without using create-react-app template.

Step 1: Manual Setup Project

  • Create project directory
mkdir yourproject && cd yourproject
  • npm package init
npm init -y
  • Define node version for this project (if using with nvm, e.g. node version 12.18.1)
@ringate
ringate / ssl-generate.md
Created June 11, 2020 12:08
SSL Certificate Generate

SSL Certificate Generate

Step 1

Command for generate CSR & KEY files.

openssl req -new -newkey rsa:2048 -nodes -out www_yourdomain_com.csr -keyout www_yourdomain_com.key

Step 2

@ringate
ringate / bot-v1.py
Created April 22, 2020 09:03
Telegram bot with reddit
import telegram
from telegram.ext import Updater, CommandHandler
import praw
import json
# connect and authorize with Reddit API
reddit = praw.Reddit(
client_id='REDDIT_APP_CLIENT_ID',
client_secret='REDDIT_APP_CLIENT_SECRET',
user_agent='pytgbot1 by /u/ringate'
@ringate
ringate / mysql_table2json.php
Created September 22, 2018 12:04
Select data from mysql table as JSON format.
<?php
$host = 'localhost';
$username = 'dbuser';
$password = 'dbpass';
$db_name = 'dbname';
$table_name = 'tablename';
$db_conn = mysql_connect($host, $username, $password) or die('Error: Could not connect.');
mysql_select_db($db_conn, $db_name) or die('Error: Could not select database.');
$result = mysql_query($db_conn, "SELECT * from " . $table_name) or die('Error: Could not query.');
@ringate
ringate / mysqli_table2json.php
Created September 22, 2018 12:01
Select data from mysql table as JSON format. (mysqli version)
<?php
$host = 'localhost';
$username = 'dbuser';
$password = 'dbpass';
$db_name = 'dbname';
$table_name = 'tablename';
$db_conn = mysqli_connect($host, $username, $password) or die('Error: Could not connect.');
mysqli_select_db($db_conn, $db_name) or die('Error: Could not select database.');
$result = mysqli_query($db_conn, "SELECT * from " . $table_name) or die('Error: Could not query.');
@ringate
ringate / order-uncancel.php
Created March 22, 2018 10:02 — forked from derak-kilgo/order-uncancel.php
One-off tool to uncancel an order in magento 1.x
<?php
if(php_sapi_name()!=="cli"){
echo "Must be run from the commend line.";
};
/**
* Setup a magento instance so we can run this export from the command line.
*/
require_once('app/Mage.php');
umask(0);
if (!Mage::isInstalled()) {
@ringate
ringate / multi-git.md
Created May 25, 2017 08:39 — forked from rosswd/multi-git-win.md
Setting up a Github and Bitbucket account on the same computer.

Setting up github and bitbucket on the same computer

Github will be the main account and bitbucket the secondary.

Create SSH Keys

ssh-keygen -t rsa -C "github email"

Enter passphrase when prompted. If you see an option to save the passphrase in your keychain, do it for an easier life.

@ringate
ringate / multiple_ssh_setting.md
Created May 25, 2017 08:15 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"