Skip to content

Instantly share code, notes, and snippets.

View ThaddeusJiang's full-sized avatar

Thaddeus Jiang ThaddeusJiang

View GitHub Profile
@ThaddeusJiang
ThaddeusJiang / git_account.md
Last active October 27, 2017 07:11
git 多账号

取消 global

git config --global --unset user.name
git config --global --unset user.email

为每一个repo设置user.email

da

@ThaddeusJiang
ThaddeusJiang / .vimrc
Last active March 30, 2019 02:56
Vim 配置文件
syntax on
set nu!
set tabstop=4
set encoding=utf-8
set fileencodings=iso-2022-jp,euc-jp,sjis,utf-8
set nocompatible " be iMproved, required
filetype off " required
@ThaddeusJiang
ThaddeusJiang / escapeHtml.js
Last active May 7, 2020 01:42
XSS 对应 escapeHtml.js
// XSS 对应
function escapeHtml(value) {
if (typeof value !== 'string') {
return value
}
return value.replace(/[&<>`"'\/]/g, function(result) {
return {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
@ThaddeusJiang
ThaddeusJiang / mac_mongodb_guide.md
Last active October 4, 2017 04:46
Mac OS 安装 MongoDB

安装

$ brew install mongodb

创建数据库存储目录

$ sudo mkdir -p /data/owl

启动mongod(需要sudo)

@ThaddeusJiang
ThaddeusJiang / rh7_mongodb.md
Created October 4, 2017 06:38
RedHat7 install mongodb

install

$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.9.tgz
$ tar -zxvf mongodb-
$ sudo mv  mongodb- /usr/local/mongodb
$ export PATH=/usr/local/mongodb/bin:$PATH

setup

@ThaddeusJiang
ThaddeusJiang / js_closure_demo.js
Last active October 27, 2017 01:58
解释 JavaScript 闭包(Closure)
// 😎 JS闭包: 定义在函数内的子函数,子函数作为函数返回值返回。
// 效果:在函数外面通过子函数,可以访问函数的内部变量。
// 运行效果 http://runjs.cn/detail/mvhnvgsq
function test1() {
var name = "The Window";
var object = {
name: "My Object",
getNameFunc: function () {
return function () {
@ThaddeusJiang
ThaddeusJiang / js_prototype_chain.md
Created October 27, 2017 07:02
JS 继承和原型链

JS 是原型继承,因为它是动态的。 虽然ES6 引入class关键字,但只是语法糖,JavaScript 仍然是基于原型的。

原型继承导致JS的调用是沿着原型链(prototype chain)遍历进行的。

e.g.

如果对象 a = {var1: 1, var2: 2},而 a 的原型 b = {var2: 20000, var3: 3},那么:

console.log(a.var1) // 1
console.log(a.var2) // 2
@ThaddeusJiang
ThaddeusJiang / linux_install_node.md
Created October 27, 2017 07:10
Linux 安装 Node.js
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash
$ . ~/.nvm/nvm.sh

$ nvm install node
@ThaddeusJiang
ThaddeusJiang / centos6.md
Last active June 4, 2018 08:28
CentOS 安装 docker

EPEL源

$ sudo rpm -Uvh http://www.gtlib.gatech.edu/pub/fedora-epel/6/i386/epel-release-6-8.noarch.rpm

Install

$ sudo yum -y install docker-io
@ThaddeusJiang
ThaddeusJiang / set_alias.md
Last active July 25, 2018 01:21
Mac 设置命令别名

步骤

  1. 切换到用户主目录
  2. 编辑或新建.bash_profile文件
  3. 添加别名

命令别名设置语法:

alias [别名]='[指令名称]'