Skip to content

Instantly share code, notes, and snippets.

@fxp
fxp / install_nodejs_6.x_on_ubuntu.sh
Created November 10, 2016 07:41
Install Nodejs 6.x on Ubuntu
# 4.x
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
# 6.x
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
@fxp
fxp / filter_password_with_tcpdump.sh
Last active November 16, 2016 05:38
Filter password from tcpdump
# Reference https://wroot.org/posts/quick-and-dirty-tcpdump-credential-usernamepassword-sniffer/
tcpdump -i wlan1 port http or port ftp or port smtp or port imap or port pop3 -l -A | egrep -i 'pass=|pwd=|log=|logi
n=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|username:|password:|login:|pass |user '
@fxp
fxp / javascript_review.md
Last active November 29, 2016 15:03
Javascript reviews
  1. 无限循环。万一条件不符合,这段代码就会一直跑了,直到耗尽资源。
for (var i = 0; ; i++) {
  ...
  if(...){
    break;
  }
}
@fxp
fxp / install_docker_on_ubuntu_1404.sh
Last active December 8, 2016 05:44
Install Docker on Ubuntu
sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv \
--keyserver hkp://ha.pool.sks-keyservers.net:80 \
--recv-keys 58118E89F3A912897C070ADBF76221572C52609
# Ubuntu version Repository
# Precise 12.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-precise main
# Trusty 14.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-trusty main
# Wily 15.10 deb https://apt.dockerproject.org/repo ubuntu-wily main
# Xenial 16.04 (LTS) deb https://apt.dockerproject.org/repo ubuntu-xenial main
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" | sudo tee /etc/apt/sources.list.d/docker.list
@fxp
fxp / install_eclipse_che_on_ubuntu.sh
Created December 8, 2016 06:06
Install Eclipse Che on ubuntu
# https://www.eclipse.org/che/getting-started/download/
curl -sL https://raw.githubusercontent.com/eclipse/che/master/che.sh > /usr/local/bin/che
chmod +x /usr/local/bin/che
che start
@fxp
fxp / base.js
Created December 25, 2016 09:32
Basic expressjs project
# http://expressjs.com/en/api.html
var app = require('express')();
var bodyParser = require('body-parser');
var multer = require('multer'); // v1.0.5
var upload = multer(); // for parsing multipart/form-data
app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
@fxp
fxp / gist:0dc03fac5e544aebaea9417556e5661e
Created February 7, 2017 05:10
Import CSV into neo4j
# REF http://stackoverflow.com/questions/27898805/how-to-load-all-the-columns-from-a-csv-into-neo4j-nodes
LOAD CSV WITH HEADERS FROM "file:///data.csv" AS line FIELDTERMINATOR ',' CREATE (n:MyLabel) SET n += line
@fxp
fxp / gist:4325965421230184bbb9c55f48134b72
Created February 7, 2017 06:48
Error like "RangeError: Invalid string length" "SyntaxError: Unexpected end of JSON input"
If you got error like "RangeError: Invalid string length" "SyntaxError: Unexpected end of JSON input" with npm "json2csv" "json2csv-stream" "write-json-file",
try write-csv instead.
@fxp
fxp / npm_mirror_taobao.sh
Created May 25, 2017 08:52
Change npm repo to taobao mirror
npm config set registry https://registry.npm.taobao.org
@fxp
fxp / install_teamcity_ubuntu16
Last active June 22, 2017 09:41
Install Teamcity
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
// Download teamcity file
// https://download-cf.jetbrains.com/teamcity/TeamCity-2017.1.2.tar.gz
// https://download-cf.jetbrains.com/charisma/youtrack-2017.2.33766.jar