Skip to content

Instantly share code, notes, and snippets.

View gucheen's full-sized avatar

Cheng Gu gucheen

View GitHub Profile
@gucheen
gucheen / random-bytes.js
Last active August 25, 2017 02:08
Generate random string/characters in JavaScript
// dec2hex :: Integer -> String
function dec2hex (dec) {
return ('0' + dec.toString(16)).substr(-2);
}
// generateId :: Integer -> String
function generateId (len = 40) {
const arr = new Uint8Array(len / 2);
window.crypto.getRandomValues(arr);
return Array.from(arr, dec2hex).join('');
@gucheen
gucheen / pbcopy.js
Created August 1, 2017 07:40
copy to clipboard in node under macOS
function pbcopy(data) {
const proc = childProcess.spawn('pbcopy');
proc.stdin.write(data); proc.stdin.end();
}
@gucheen
gucheen / 多态邀请码
Created May 31, 2017 04:56
多态邀请码
A15B-A7F3-A6A4-23
@gucheen
gucheen / chinese-body-font-family.css
Created May 11, 2017 02:29
中文网页 body 字体设置-airbnb
body {
font-family:"Hiragino Sans GB","华文细黑","STHeiti","微软雅黑","Microsoft YaHei",SimHei,"Helvetica Neue",Helvetica,Arial,sans-serif !important;
}
@gucheen
gucheen / gzip
Created March 30, 2017 09:50
gzip configuration for front end projects
gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_proxied any;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
var webpack = require('webpack');
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
// Webpack Config
var webpackConfig = {
entry: {
'polyfills': './src/polyfills.browser.ts',
'vendor': './src/vendor.browser.ts',
①商业特色街
  福州路文化街、东台路古玩街、多伦路文化名人街、北京东路生产资料街、茂名南路文化休闲街、黄河路美食休闲街、乍浦路美食街、七浦路服饰街、衡山路休闲娱乐街、云南路美食街、梅川路欧亚休闲街
  ②特色商品市场
  福佑路小商品市场、铜川路水产市场、军工路东方国际水产中心
  ③十大商业中心
@gucheen
gucheen / lazy-load-nvm.sh
Created July 26, 2016 03:46
lazy load nvm
nvm() {
unset -f nvm
export NVM_DIR=~/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
nvm "$@"
}
node() {
unset -f node
export NVM_DIR=~/.nvm
@gucheen
gucheen / vim
Created July 12, 2016 10:53
vim usage
# format json in vim
:%!python -m json.tool
@gucheen
gucheen / stuns
Created July 3, 2016 15:20 — forked from yetithefoot/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},