Skip to content

Instantly share code, notes, and snippets.

View imchao9's full-sized avatar
🎯
Focusing

JunChao imchao9

🎯
Focusing
View GitHub Profile
@imchao9
imchao9 / sort_by_specify_array.js
Last active December 5, 2016 08:44
use lodash sortby to sort the array by specifc array
var sortedCollection = _.sortBy(collection, function(item){
return firstArray.indexOf(item.id)
});
@imchao9
imchao9 / init-server.sh
Created January 7, 2017 08:54
change ssh config & install docker
#! /bin/bash
#echo 'Add user';
#adduser codemao
#usermod -a -G sudo codemao
#passwd codemao
#su codemao
#
#echo 'Apt update';
#sudo apt-get update
#
@imchao9
imchao9 / perf-flame-graph-notes.md
Created February 25, 2017 16:17 — forked from sericaia/perf-flame-graph-notes.md
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@imchao9
imchao9 / shell
Created March 15, 2017 03:05
stop nginx when the system boot
update-rc.d nginx defaults disable
@imchao9
imchao9 / shell,mac
Last active March 22, 2017 07:42
mac: run the command to delete the match string in all files
find . -name "*.ts" -exec sed -i '' '/tsd\.d/d' {} \;
@imchao9
imchao9 / javascript
Created March 31, 2017 08:22
output the table in html
var table = document.getElementById('abc');
var text = "";
var rowLength = table.rows.length;
var cell1,cell2 = 0;
for(var i=0; i<rowLength; i+=1){
var row = table.rows[i];
//your code goes here, looping over every row.
//cells are accessed as easy
@imchao9
imchao9 / gist:9182a73d2d335cc27f391314ee6ed04a
Created April 18, 2017 06:38
get all urls in a csv file
npm install -g get-urls-cli
get-urls sqlResult_1183013.csv >> urls.txt
awk {'print $1'} new_urls.txt | xargs wget -P bcms
@imchao9
imchao9 / shell,mac
Last active April 19, 2017 04:05
find the similar file name and delete them
#! /bin/bash
find . -name "*.js" -type f -exec sh -c 'for i do declare match_file=$i; if [ -f $i.map ]; then rm -rf $match_file.map; rm -rf $match_file; echo $match_file.map;fi;done' sh {} +
@imchao9
imchao9 / multiple_ssh_setting.md
Created July 5, 2017 04:05 — 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 "[email protected]"
@imchao9
imchao9 / javascript
Created September 28, 2017 03:04
import lodash.js in the browser
function import_lodash() {
var jq = document.createElement('script');
jq.src = "https://lodash.com/vendor/cdn.jsdelivr.net/lodash/4.17.4/lodash.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
}
import_lodash();