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.
@antonga23
antonga23 / full_join.sql
Created October 25, 2022 12:24 — forked from ebta/full_join.sql
How to do FULL [OUTER] JOIN in MySQL (MariaDB)
-- First method
SELECT * FROM t1
LEFT JOIN t2 ON t1.id = t2.id
UNION
SELECT * FROM t1
RIGHT JOIN t2 ON t1.id = t2.id
-- Second Method
-- The query above works for special cases where a FULL OUTER JOIN operation would not produce any duplicate rows.
-- The query above depends on the UNION set operator to remove duplicate rows introduced by the query pattern.
const pause = (data, time) => new Promise(resolve => setTimeout(() => resolve(data), time));
const pauseReject = (data, time) =>
new Promise((resolve, reject) =>
setTimeout(() => reject(new Error(`Something went wrong in the ${data} promise`)), time)
);
const parallelErrorHandlingWrong = () => {
const firstPromise = pause('first', 3000);
const secondPromise = pauseReject('second', 2000);
const thirdPromise = pause('third', 1000);
@antonga23
antonga23 / digital_ocean_droplet_user_config.sh
Created June 2, 2022 15:09
basic script to seed new user on digital ocean and transfer ssh keys
#!/bin/bash
set -euo pipefail
USERNAME=ubuntu # TODO: Customize the sudo non-root username here
# Create user and immediately expire password to force a change on login
useradd --create-home --shell "/bin/bash" --groups sudo "${USERNAME}"
passwd --delete "${USERNAME}"
chage --lastday 0 "${USERNAME}"
@antonga23
antonga23 / superset_pass_change.sh
Created April 1, 2022 14:01
Superset change password
docker exec -it superset_app /bin/bash
superset fab reset-password --username admin --password yourpassword
@antonga23
antonga23 / example.md
Created March 29, 2022 08:42 — forked from devdrops/example.md
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯
@antonga23
antonga23 / git-ssh.txt
Created January 7, 2022 15:17
A simple way to authenticate to github using ssh across multiple accounts
1. Generate keys for github accounts
eg.
ssh-keygen -t ed25519 -C "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
2. Start ssh-agent in background and add keys
@antonga23
antonga23 / facebook.py
Created December 31, 2021 10:31 — forked from ezl/facebook.py
Are there any put-call parity opportunities? Lets check facebook options
"""
Checking for put-call parity mispricings in facebook.
fb is American, so put call parity doesn't actually apply, but
this is a short term option, with no dividends between now and the
expiration (apr 17, 1 week option), in a low interest rate environment
so you can expect the trees to act almost european.
easier to find this data on yahoo than actual european data and
everyone knows what facebook is so i went with it.
@antonga23
antonga23 / coinId.php
Created July 1, 2021 11:08 — forked from crcrcr999/coinId.php
XCH(chia) getCoinId by PHP
<?php
function hexToStr($hex){
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2){
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
return $string;
}
function getCoinId($parent_coin_info,$puzzle_hash,$amount){
@antonga23
antonga23 / git.migrate
Created June 23, 2021 15:22 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.