Skip to content

Instantly share code, notes, and snippets.

View lgh06's full-sized avatar

Daniel Liu lgh06

View GitHub Profile
@lgh06
lgh06 / nginx-php.conf
Last active June 17, 2018 15:41
nginx location rewrite proxy_pass
#39测试机
server {
listen 80;
server_name m.kankan.com;
root /data/vhosts/kankan.com/m/public_html;
location / {
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
index index.php index.html index.htm;
// 流程控制
class Step{
constructor(){
}
// 异步执行所有funcArray内的函数
// 返回Promise对象
static parallel(funcArray){
let funcPromiseArray = [];
funcArray.forEach((v)=>{
var rawframe = document.createElement('iframe');
document.body.appendChild(rawframe)
var framedoc = rawframe.contentDocument;
if (!framedoc && rawframe.contentWindow) {
framedoc = rawframe.contentWindow.document;
}
var script = document.createElement('script');
script.type = "text/javascript";
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js";
framedoc.body.appendChild(script);
@lgh06
lgh06 / .eslintrc.js
Last active February 15, 2017 12:20
eslint-demo
module.exports = {
"env": {
"browser": true,
"commonjs": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
@lgh06
lgh06 / simple-mvvm.js
Created February 7, 2017 15:17
mvvm base.
//hook console.log to web page.
var oldlog = console.log;
console.log = function() {
oldlog.apply(console, arguments);
let arr = Array.from(arguments);
let keys = arr.keys();
for (let v of keys) {
if(typeof arr[v] === 'object'){
arr[v] = JSON.stringify(arr[v]);
@lgh06
lgh06 / better-nodejs-require-paths.md
Created January 12, 2017 08:34 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@lgh06
lgh06 / uglifyjs-usage.md
Created January 11, 2017 12:12
uglifyjs-usage

uglifyjs kankan_click_pv_src.js --support-ie8 -o kankan_click_pv.js -c pure_getters=true,unused=false,dead_code=false,pure_funcs=['getCookie'],drop_console=true,drop_debugger=true

(function(window) {
var fn = function () {
var s = document.createElement('script');
s.src = './js/client.js';
s.async = true;
s.defer = true;
document.body.appendChild(s);
}
document.addEventListener('DOMContentLoaded', fn);
@lgh06
lgh06 / task.js
Created November 9, 2016 02:30 — forked from zmofei/task.js
cutwords
var fs = require('fs')
var trie = {}
var tempWords = {};
fs.readFile('./text.txt',function(err,callback){
var str = callback.toString();
str = str.replace(/[^\u4e00-\u9fa5]/g,'@');
str = str.replace(/@+/g,' ')
split(str);