Skip to content

Instantly share code, notes, and snippets.

View AoiYamada's full-sized avatar
:octocat:

AoiYamada AoiYamada

:octocat:
View GitHub Profile

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.
@AoiYamada
AoiYamada / extensions-check.sh
Created March 16, 2026 17:00
Check if your vscode extensions are malware
#!/bin/sh
# VS Code 擴充功能安全檢查工具
# 動態取得並檢查 VS Code 擴充功能是否在已知的感染清單中
# data source (Huli 隨意聊):
# https://www.facebook.com/share/p/1L5gHwjaAV/
# 顏色定義
RED='\033[0;31m'
GREEN='\033[0;32m'
@AoiYamada
AoiYamada / keyBasedDebounce.test.ts
Created September 2, 2024 11:22
Key based debounce
import keyBasedDebounce from '../keyBasedDebounce'
jest.useFakeTimers().setSystemTime(new Date('2024-09-01'))
describe('keyBasedDebounce', () => {
beforeEach(() => {
jest.clearAllMocks()
})
it('should debounce the function call', () => {
@AoiYamada
AoiYamada / routes plan.md
Last active March 16, 2024 18:14
routes plan

API Routes Plan

User

Note: /my/* routes requires cognito user token

GET /users # Return list of users, for admin purpose only

GET /users/:userId/profile # For viewing other's profile

@AoiYamada
AoiYamada / index.html
Created February 20, 2024 19:04
CodePen Home Pure CSS waterfall grid layout
// credit to: https://codepen.io/michellebarker/pen/RwMWYpb
<div class="grid">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
const DataLoader = require("dataloader");
const users = new Map([
[
1,
{
id: 1,
name: "Tom",
},
],
const DataLoader = require("dataloader");
const users = new Map([
[1, { id: 1, name: "Tom" }],
[2, { id: 2, name: "John" }],
[3, { id: 3, name: "Ann" }],
[4, { id: 4, name: "Peter" }],
[5, { id: 5, name: "May" }],
]);
const DataLoader = require("dataloader");
const stories = new Map([
[1, { id: 1, title: "story 1" }],
[2, { id: 2, title: "story 2" }],
[3, { id: 3, title: "story 3" }],
[4, { id: 4, title: "story 4" }],
[5, { id: 5, title: "story 5" }],
]);
@AoiYamada
AoiYamada / n+1.sql
Last active April 4, 2021 13:02
N + 1 Problems
SELECT * FROM singers LIMIT 5;
SELECT * FROM songs WHERE singer_id = 1;
SELECT * FROM songs WHERE singer_id = 2;
SELECT * FROM songs WHERE singer_id = 3;
SELECT * FROM songs WHERE singer_id = 4;
SELECT * FROM songs WHERE singer_id = 5;
@AoiYamada
AoiYamada / post-receive.sh
Created December 11, 2019 17:07 — forked from benfrain/post-receive.sh
post-receive hook for multiple branches
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi