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
// ==UserScript==
// @name get-urls-from-kuai.xunlei.js
// @description get urls from kuai.xunlei.com
// @namespace http://yourwebsite.com
// @version 0.1.0
// @author Jokester ( github/jokester )
// @license MIT
// @released 2013-04-02
// @updated 2013-04-02
// @match *://kuai.xunlei.com/*
@jokester
jokester / Chinese family names.js
Last active December 16, 2015 14:39
JS snippet to extract Chinese family names from wikipedia.
// http://zh.wikipedia.org/wiki/%E7%99%BE%E5%AE%B6%E5%A7%93
JSON.stringify(
$.makeArray(
$("table.wikitable td:nth-child(2)").map( function(_,node){ return node.textContent; } )
)
)
@jokester
jokester / Rakefile
Last active December 16, 2015 14:48
a Rakefile to compile tex to pdf. idea from http://rkj.github.io/LaTeX/rake/2010/01/15/LaTeX-with-Rakefile.html
#!/usr/bin/env ruby
TEX = FileList["*.tex"]
PDF = TEX.ext ".pdf"
DEP = FileList["*/*.tex"]
TEX.zip(PDF).each do |tex,pdf|
file pdf => [ tex, DEP ].flatten do
begin
@jokester
jokester / test_bisect.py
Last active December 17, 2015 20:29
test correctness and speed of linear search and bisect search in list
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import random
from array import array
from bisect import bisect_left, bisect_right
from timeit import repeat
class Distribution:
"""Generate random integers according to a specific function.
#!/usr/bin/env ruby
def merge_cidr(segments_regex)
segments = segments_regex.map do |s|
(0..255).map(&:to_s).grep(/^#{s}$/).map(&:to_i)
end
memo = []
segments.each do |s|
// ==UserScript==
//
// @id www.amazon.com-b556bb6f-ee56-4bea-b588-998dc5bb4777@scriptish
//
// @namespace http://userscript.org/~hitsmaxft
//
// @name Kindle Library Powerpack
//
// @version 2.6.1
//
@jokester
jokester / .gvimrc
Created November 5, 2013 17:58
vimrc
" vim: ft=vim
"appearance
set guioptions-=T
set guioptions-=m
"platform dependent settings
if(has("win32") || has("win95") || has("win64") || has("win16"))
"win
set lines=40
set columns=120
# vim: ft=perl
use File::Which qw/ which /;
use Data::Dumper;
$pdf_mode = 1; # use pdflatex
$pdflatex = "pdflatex -file-line-error -halt-on-error";
&find_pdf_previewer(\$pdf_previewer);
do ->
String.prototype.to_proc = (args...)->
method = @
(obj)->obj[method].apply(obj, args...)
console.log "a b c".split(/\s/).map (i)->i["toUpperCase"]()
# => [ "A", "B", "C" ]
console.log "a b c".split(/\s/).map "toUpperCase".to_proc()
# => [ "A", "B", "C" ]
@jokester
jokester / .vimrc.bundle
Created May 14, 2014 03:33
my vim bundle
" vim: ft=vim
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
" detect / switch encoding
Bundle 'mbbill/fencview'