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 / 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 / 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.
@antonga23
antonga23 / FullExample.php
Created June 22, 2021 16:51 — forked from IamSmith/FullExample.php
Fully working example
<?php
require_once("PHPExcel/PHPExcel.php");
$phpExcel = new PHPExcel();
$styleArray = array(
'font' => array(
'bold' => true,
)
);
@antonga23
antonga23 / Privilege Escalation.md
Created May 7, 2021 14:52 — forked from A1vinSmith/Privilege Escalation.md
Privilege Escalation: Systemctl (Misconfigured Permissions — sudo/SUID)
@antonga23
antonga23 / forwardport.sh
Created November 18, 2020 19:32 — forked from debashisbarman/forwardport.sh
Forward port 80 to 8080 on EC2 instance.
sudo iptables -t nat -L
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000