Skip to content

Instantly share code, notes, and snippets.

@akccakcctw
akccakcctw / pr.md
Created April 2, 2018 07:32 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@akccakcctw
akccakcctw / brew_cask_install_list.sh
Created March 21, 2018 08:44
Homebrew 安裝清單
brew cask install font-hanamina
brew cask install font-noto-serif-cjk
brew cask install font-noto-sans-cjk
brew cask install vagrant
brew cask install iterm2
brew cask instll virtualbox
brew cask install xquartz
@akccakcctw
akccakcctw / mysql-docker.sh
Created March 21, 2018 08:09 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@akccakcctw
akccakcctw / json_prettifier.py
Last active January 4, 2019 06:22
JSON prettifier with python
#!/usr/bin/env python3
# coding=utf-8
"""
usage example: `./json_prettifier.py input.json > output.json`
"""
import sys
import json
with open(sys.argv[1], "r") as f:
@akccakcctw
akccakcctw / deep_clone.js
Last active February 22, 2018 16:19
深拷貝的幾種方法
// ref: https://mobile.twitter.com/DasSurma/status/955484341358022657
// https://dassur.ma/things/deep-copy/
// performance: https://deep-copy.glitch.me/
// JSON
function structuredCloneJSON(obj) {
return JSON.parse(JSON.stringify(obj));
}
// History API
@akccakcctw
akccakcctw / download_repo.sh
Created December 3, 2017 03:05
Download repo files from GitHub
# 下載 repo files 並解壓縮至資料夾
cd $HOME
mkdir <repo>
cd <repo>
curl -L https://github.com/<user>/<repo>/archive/master.tar.gz | tar -xz --strip-component=1
/**
* A node in the DOM tree.
*
* @external Node
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node Node}
*/
/**
*
* @param {external:Node} el - Element want to scroll
@akccakcctw
akccakcctw / CSS-variable-with-support.scss
Created September 30, 2017 07:42
CSS variable mixin with @supports
$colors: (
origin: grey,
warning: orange,
danger: red
);
:root {
@each $key, $color in $colors {
--#{key}: $color;
}
@akccakcctw
akccakcctw / checkurls.sh
Last active September 26, 2017 08:30
check URLs in a file and get HTTP status code
#!/bin/bash
# -----------------------
# |###| version 1.3.1
# |###| Rex Tsou
# |###| 2017/09/26
# usage------------------
# $ ./checkurls.sh [file]
# -----------------------
output_file='url_status.md'
@akccakcctw
akccakcctw / imageCompress.sh
Last active January 9, 2017 10:38
利用 ImageMagick 壓縮圖片
#!/bin/bash
# version 1.3.2
# Rex Tsou
# 2017/01/09
echo --------------------
echo 圖片壓縮工具 v1.3.2
echo Author: Rex Tsou
echo --------------------