Skip to content

Instantly share code, notes, and snippets.

View ophentis's full-sized avatar

Willy Tseng ophentis

View GitHub Profile
@ophentis
ophentis / nginx.conf
Created April 30, 2013 05:58
nginx proxy setup
server {
listen 80;
server_name www.playwithproxy.tw;
location / {
proxy_pass http://10.0.0.201;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@ophentis
ophentis / gist:5489621
Created April 30, 2013 15:52
change encoding of html to html entities, this can fix issue when using php domdocument
$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')
@ophentis
ophentis / gist:6774758
Created October 1, 2013 06:56
For a given date, get the ISO week number
/* For a given date, get the ISO week number
*
* Based on information at:
*
* http://www.merlyn.demon.co.uk/weekcalc.htm#WNR
*
* Algorithm is to find nearest thursday, it's year
* is the year of the week number. Then get weeks
* between that date and the first day of that year.
*
@ophentis
ophentis / gist:7890752
Created December 10, 2013 13:44
array dimension for javascript
//
// [1].dim() == 1
// [1,2].dim() == 1
// [[1]].dim() == 2
// [[1,2,3],4,[5,6,7],[8,9,0]].dim() == 2
// [[1,[2]],3,[[4,5],6,[7,8]]].dim() == 3
//
Array.prototype.dim = function dim() {
return this.reduce(function(a,b) {
@ophentis
ophentis / gist:9152346
Created February 22, 2014 11:24
js random hex color
(Math.random().toString(16) + '000000').slice(2, 8)
@ophentis
ophentis / parseLink
Created September 12, 2014 03:52
http link header parsing
@ophentis
ophentis / gist:4c34ae4ec5cbbff9aa9a
Created September 16, 2014 12:01
flush memcache
echo 'flush_all' | nc localhost 11211
@ophentis
ophentis / gist:5c18bb548d69d83e6176
Created September 19, 2014 02:44
rsync folders
time rsync -aOvz sandbox-02:/var/benchmark/ ~/benchmark
@ophentis
ophentis / gist:92d4cab77e0bf1c2c19d
Created September 19, 2014 03:09
build qcachegrind from github repository
git clone git://anongit.kde.org/kcachegrind
cd kcachegrind/qcachegrind
qmake -spec 'macx-g++'; make
@ophentis
ophentis / mongodb-cmd
Created October 4, 2014 06:31
mongodb commands
mongod --config /usr/local/etc/mongod.conf