Skip to content

Instantly share code, notes, and snippets.

View jokester's full-sized avatar
🌛
not my photo / still alive and with a cat now!!! (as of 2024-05)

Wang Guan jokester

🌛
not my photo / still alive and with a cat now!!! (as of 2024-05)
View GitHub Profile
@jokester
jokester / curry-example.js
Last active October 21, 2016 23:07
curry in javascript
var curry = function(foo, arity) {
var curried = function() {
// parameters by far are passed with `this`
// slice()-ing it here makes the curried function stateless
var new_args = this.slice();
for(arg_key in arguments) {
new_args.push(arguments[arg_key]);
}
if (new_args.length >= arity) {
@jokester
jokester / php-5.4-profiler-build.sh
Created February 19, 2016 01:57
A script to build (apache2.2 / PHP5.4 / APD Extension) locally.
#!/bin/bash
set -ue
build-apache () {
local prefix="$PWD/local"
mkdir -pv build
wget --continue http://www.apache.org/dist/httpd/httpd-2.2.31.tar.bz2 -O build/httpd-2.2.31.tar.bz2
tar xf build/httpd-2.2.31.tar.bz2 -C build/
pushd build/httpd-2.2.31
./configure --prefix="$prefix" --enable-mods-shared=all
@jokester
jokester / hash_accessor.js
Created February 22, 2016 05:42
Save and load JSON value with URL hash (aka URL fragment)
/**
* Save and load JSON value with URL hash (aka URL fragment)
*
* hash_accessor.load() -> load
* hash_accessor.save(obj) -> save serialized obj into hash
*/
var hash_accessor = (function (window) {
return {
load: function () {
@jokester
jokester / proof.md
Created April 8, 2016 01:07
keybase proof

Keybase proof

I hereby claim:

  • I am jokester on github.
  • I am jokester (https://keybase.io/jokester) on keybase.
  • I have a public key whose fingerprint is FC7D 5D44 6E96 ADBC C963 2742 80F9 9BAF 519A 8ABE

To claim this, I am signing this object:

@jokester
jokester / update-android-sdk.sh
Last active May 8, 2016 17:21
Update headless android sdk
#!/bin/bash
set -e
if [[ -d "$ANDROID_HOME" ]]; then
cd "$ANDROID_HOME"
elif [[ -f "$(dirname "$0")/tools/android" ]]; then
cd "$(dirname "$0")"
else
echo "FAILED: Cannot find ANDROID_HOME/tools/android"
exit 1
@jokester
jokester / android-build-settings.md
Last active March 20, 2018 06:15
Android build settings that works in both IDE and CI server

What is this for

  • Auto-generated version number for release builds
  • No need to include keystore / password in repository
  • The code should still build with no extra configuration

How it works

  • Version code / number are generated from the commit itself
  • Version / sign settings are injected as environment variables
@jokester
jokester / jquery.eager-load.js
Created May 13, 2016 14:16
Reverse of jquery.lazy-load.js
// ==UserScript==
// @name Buka eager load
// @description Reverse of jquery.lazy-load.js
// @include http://www.buka.cn/view/*/*
// @version 1.0
// ==/UserScript==
// inject the function as a <script> node, so it get executed in page context.
var execute = function (body) {
if(typeof body === "function") { body = "(" + body + ")();"; }
@jokester
jokester / enable-bbr.conf
Created March 15, 2017 14:51
/etc/sysctl.d/enable-bbr.conf
# Requires kernel 4.9 and up
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
0 == 588 * 0 + 0
1 == 586 * 0 + 1
2 == 584 * 0 + 2
3 == 582 * 0 + 3
4 == 580 * 0 + 4
5 == 578 * 0 + 5
6 == 576 * 0 + 6
7 == 574 * 0 + 7
8 == 572 * 0 + 8
9 == 570 * 0 + 9

01.道可道,非常道。名可名,非常名。无名天地之始。有名万物之母。故常无欲以观其妙。常有欲以观其徼。此两者同出而异名,同谓之玄。玄之又玄,众妙之门。

02.天下皆知美之为美,斯恶矣;皆知善之为善,斯不善已。故有无相生,难易相成,长短相形,高下相倾,音声相和,前後相随。是以圣人处无为之事,行不言之教。万物作焉而不辞。生而不有,为而不恃,功成而弗居。夫唯弗居,是以不去。

03.不尚贤, 使民不争。不贵难得之货,使民不为盗。不见可欲,使民心不乱。是以圣人之治,虚其心,实其腹,弱其志,强其骨;常使民无知、无欲,使夫智者不敢为也。为无为,则无不治。

04.道冲而用之,或不盈。渊兮似万物之宗。解其纷,和其光,同其尘,湛兮似或存。吾不知谁之子,象帝之先。

05.天地不仁,以万物为刍狗。圣人不仁,以百姓为刍狗。天地之间,其犹橐迭乎?虚而不屈,动而愈出。多言数穷,不如守中。