Skip to content

Instantly share code, notes, and snippets.


Leonard Lin gwokae

View GitHub Profile
// ==UserScript==
// @name switch languages
// @version 0.1
// @description keep the browseing path when switch language on
// @author Leonard Lin <>+
// @updateURL
// @match https://**
// @grant none
// ==/UserScript==
View Array.prototype.sample.js
Array.prototype.sample = function(count = 1){
let {length} = this;
if( count > length ){
count = length;
return (item, idx) => {
return {item, rnd: Math.random()};
.sort( (a, b) => a.rnd - b.rnd )
.slice( length - count )
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
CURL upload command:
`curl -X POST -F file=@<path-to-file> http://<host-ip>:8000`


cd $(git rev-parse --show-toplevel)/.git/hooks/
chmod a+x pre-commit

install all

View .jshintrc
// Settings
"passfail" : false, // Stop on first error.
"maxerr" : 100, // Maximum errors before stopping.
// Predefined globals whom JSHint will ignore.
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"node" : true,
View ubuntu-compass-ruby
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.2
rvm use 2.1.2 --default

How to: Allow Node to bind to port 80 without sudo


Only do this if you understand the consequences: all node programs will be able to bind on ports < 1024

sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/node

Important: your node location may vary. Use which node to find it, or use it directly in the command:

gwokae /
Last active Apr 26, 2021 — forked from tobiassjosten/
to quickly init my ubuntu dev environment

to boostrap my dev environment :D

gwokae / gist:5655095
Created May 27, 2013
Polling, which style you preferred ?
View gist:5655095
// type 1
var bar = foo || global.defaultObject;
if(bar) bar.exec();
// type 2
(foo || global.defaultObject) && (foo || global.defaultObject).exec();
View gist:5610978
// ==UserScript==
// @name getWin
// @namespace my.util
// @include
// @version 1
// ==/UserScript==
function createCookie(name,value,days) {