This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import path from 'path'; | |
const modules = {}; | |
fs | |
.readdirSync(__dirname) | |
.filter((file) => { | |
const fileArray = file.split('.'); | |
// 排除[隐藏文件]、[非js文件]、[index.js本身] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const clone = (origin) => { | |
//Object.create 创建一个指定原型的对象,可选若干参数 | |
return Object.assgin(Object.create(Object.getPrototypeOf(origin)), origin); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return [ | |
// INFORMATIONAL CODES | |
100 => 'Continue', | |
101 => 'Switching Protocols', | |
102 => 'Processing', | |
// SUCCESS CODES | |
200 => 'OK', | |
201 => 'Created', | |
202 => 'Accepted', | |
203 => 'Non-Authoritative Information', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/var/log/app.log { | |
weekly | |
missingok | |
su root root # 切换到某个用户\组 | |
create 0664 root utmp # 指定日志用户以及 模式 | |
rotate 52 | |
compress | |
delaycompress | |
notifempty | |
copytruncate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// open syslog, include the process ID and also send | |
// the log to standard error, and use a user defined | |
// logging mechanism | |
openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0); | |
$access = date("Y/m/d H:i:s"); | |
syslog(LOG_WARNING, "Unauthorized client: $access"); | |
closelog(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http from 'http'; | |
import cluster from 'cluster'; | |
import os from 'os'; | |
const port = 3001; | |
// cpu核数 | |
const numCpus = os.cpus().length; | |
console.log(`The num of cpu: ` + numCpus); | |
// 实现Load balancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* stream解释: 将数据从开始位置传送到目的位置, 可以是大流量文件传输 | |
* 1. stream的过程: | |
* 开始通信 | |
* 读取数据 | |
* 写入数据 | |
* 结束通信 | |
* ## 可以说stream是这一过程的抽象 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class A(object): | |
def foo(self): | |
print 'hello A' | |
@classmethod | |
def demo(cls): | |
s = cls() | |
s.foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
def dummy_decorator(injection): | |
print 'dummy' | |
return injection | |
def test_decorator(injection): | |
print 'foooo' | |
def wrapper(params): | |
print 'barrrr' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
# -*- coding: utf-8 -*- | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>py.h</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> | |
<!-- <scope>source.python</scope> --> | |
</snippet> |
OlderNewer