Skip to content

Instantly share code, notes, and snippets.

View simlegate's full-sized avatar
🎯
Focusing

Devin Zhang simlegate

🎯
Focusing
  • ChengDu
View GitHub Profile
@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 / 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 / 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){