Skip to content

Instantly share code, notes, and snippets.

View lgh06's full-sized avatar

Daniel Liu lgh06

View GitHub Profile
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2
mQENBFgTBlUBCACi5g8nS6cj3xY2YdDJMQWerK9gczhSmFsH/lRCx/qc/4rwMVmX
LRT8bQC9iHL++F0HWfMu7MXeUGVDtPKDLLy7OZH7aN2mtr0b+xBmQrNT9SYsmGJq
R+mq1jgD6p3z8DVAOHcYjG06JQhVXBW8h/s4UrXOidwltSqX6T0LSj01n4PLWAHO
4eO/u+tgBWWzls5o4fNqF6QKvxW/B3naglJ+DbdgXcxpjAS+b4h87KEDNn8T7xjk
AWdI6kuZZ2P0ayU1RUuY2u93O0dQtxbI4QQN5doJp1C63CT4NyrahNRGO7hgtnpK
zAZ51AB5q/sZgs2YYwLoSZ3Q38VJuBiiVLVFABEBAAG0GEdlaHVhbiBMaXUgPGhu
bmtAcXEuY29tPokBOQQTAQgAIwUCWBMGVQIbAwcLCQgHAwIBBhUIAgkKCwQWAgMB

Keybase proof

I hereby claim:

  • I am lgh06 on github.
  • I am lgh06 (https://keybase.io/lgh06) on keybase.
  • I have a public key ASDmLfMm573JbUC__Cmf4c8vKpuAcVQbCzIaDoUSqYkhJgo

To claim this, I am signing this object:

@lgh06
lgh06 / enable-cors-cdn.conf
Last active December 20, 2016 12:07
Nginx conf for CORS.
#
# The default server
#
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
@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);
(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 / 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

@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 / 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 / .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"
},
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);