Skip to content

Instantly share code, notes, and snippets.

View simlegate's full-sized avatar
🎯
Focusing

Devin Zhang simlegate

🎯
Focusing
View GitHub Profile
@simlegate
simlegate / fetch.js
Created March 14, 2017 08:14
Fetch Api Wrapper
function http(method, url, request) {
let init = { method: 'GET' }
if(method != 'GET') {
init.body = request.body
}
return fetch(url, init).
then(function(response){
if(response.ok){
response.json().then(function(json){
@simlegate
simlegate / node-module-require
Created March 18, 2016 11:14
The require of Node Module
From https://nodejs.org/api/modules.html
require(X) from module at path Y
1. If X is a core module,
a. return the core module
b. STOP
2. If X begins with './' or '/' or '../'
a. LOAD_AS_FILE(Y + X)
b. LOAD_AS_DIRECTORY(Y + X)
3. LOAD_NODE_MODULES(X, dirname(Y))
@simlegate
simlegate / _service.md
Created January 16, 2016 11:54 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@simlegate
simlegate / kill.sh
Created December 11, 2015 05:26
the command of killing process
kill $(ps aux | grep '[p]ython csp_build.py' | awk '{print $2}')
@simlegate
simlegate / sec_websocket_key_rule.rb
Last active November 16, 2015 15:56
something important about Websocket handshaking
require 'digest/sha1'
require 'base64'
# client request
# GET / HTTP/1.1
# Upgrade: websocket
# Connection: Upgrade
# Host: example.com
# Origin: null
# Sec-WebSocket-Key: sN9cRrP/n9NdMgdcy2VJFQ==
zh-CN:
admin:
home:
name: "首页"
pagination:
previous: "« 上一页"
next: "下一页 »"
truncate: "…"
misc:
filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
@simlegate
simlegate / custom-error-page
Created October 31, 2014 05:35
Nginx return custom json
error_page 400 404 405 =200 @40*_json;
location @40*_json {
default_type application/json;
return 200 '{"code":"1", "message": "Not Found"}';
}
error_page 500 502 503 504 =200 @50*_json;
location @50*_json {
@simlegate
simlegate / ref.java
Created October 20, 2014 08:01
Java垃圾回收机制循环引用问题
class A{
public B b;
}
class B{
public A a;
}
public class Main{
public static void main(String[] args){
A a = new A();
<?php
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
@simlegate
simlegate / linux-command
Last active July 16, 2017 10:01
Linux常用命令
# 查看网络端口占用情况
netstat -an | grep 9000
# 通过list open file命令可以查看到当前打开文件,在linux中所有事物都是以文件形式存在,包括网络连接及硬件设备。
lsof -i:9000
# 查看php.ini文件的位置
php --ini