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-03)

Wang Guan jokester

🌛
not my photo / still alive and with a cat now!!! (as of 2024-03)
View GitHub Profile
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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 / irb log.txt
Last active December 17, 2015 01:39
BCrypt uses first 72 bytes instead of 72 chars.
irb(main):011:0> pass1 = "あ" * 50
=> "ああああああああああああああああああああああああああああああああああああああああああああああああああ"
irb(main):012:0> pass1.size
=> 50
irb(main):013:0> pass1.bytes.size
=> 150
@jokester
jokester / screw-dell.sh
Created December 12, 2015 03:31
how to extract download link from the download list of dell's crappy support site
#!/bin/bash
set -o pipefail
set -e
# the link to download list can be obtained with "send the list via mail"
# mine was https://www.dell.com/support/home/jp/ja/jpdhs1/Drivers/DownloadListDetails?downloadListId=81a3eea8-706d-4fc4-bb41-a17754e291c5
curl "https://www.dell.com/support/home/jp/ja/jpdhs1/Drivers/DownloadListDetails?downloadListId=81a3eea8-706d-4fc4-bb41-a17754e291c5" \
| egrep --only-match 'http.*?\.exe' -i \
| xargs wget