Skip to content

Instantly share code, notes, and snippets.

View iwinux's full-sized avatar
👽

Limbo Peng iwinux

👽
View GitHub Profile
@iwinux
iwinux / pick-works.js
Last active March 19, 2016 13:39
选择困难症患者专用的 Chrome 脚本,在豆瓣阅读征文大赛作品列表里随机挑一本作品
// ==UserScript==
// @name pick-works
// @namespace http://tampermonkey.net/
// @version 0.1
// @author E.T
// @match https://read.douban.com/competition/2015/works*
// @grant none
// ==/UserScript==
;(function () {
@iwinux
iwinux / CSS line behind title text.markdown
Created March 2, 2016 14:08
CSS line behind title text
@iwinux
iwinux / a-warning.md
Created March 1, 2016 04:18 — forked from spion/a-warning.md
C++ versus V8 versus luajit versus C benchmark - (hash) tables

Warning

This benchmark has been misleading for a while. It was originally made to demonstrate how JIT compilers can do all sorts of crazy stuff to your code - especially LuaJIT - and was meant to be a starting point of discussion about what exactly LuaJIT does and how.

As a result, its not indicative of what its performance may be on more realistic data. Differences can be expected because

  1. the text will not consist of hard-coded constants
@iwinux
iwinux / pep8.rst
Last active December 20, 2015 13:09
just for rst preview - -
@iwinux
iwinux / argparse.cpp
Created June 15, 2013 10:25
A naive implementation of command argument parser in C++
#include <iostream>
#include <map>
#include <stdexcept>
#include <sstream>
#include <string>
#include <vector>
using std::cout;
using std::endl;
using std::istringstream;
@iwinux
iwinux / xdg-open.py
Created June 3, 2013 16:26
sudo ln -s $PWD/xdg-open.py /usr/bin/xdg-open
#!/usr/bin/env python
from os.path import isdir, splitext
from urlparse import urlparse
from urllib import unquote
import sys
import os
openssl s_client -connect github.com:443 -showcerts 2>&1 < /dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed -ne '1,/-END CERTIFICATE-/p' > /tmp/github.com.pem
openssl x509 -in /tmp/github.com.pem -sha1 -noout -fingerprint
;; Usage: racket quick-find.rkt < pairs.txt
#lang racket/base
(require racket/list)
(require racket/string)
(require profile)
(provide make-qf-set qf-connected? qf-find qf-count qf-items qf-connect!)
(module+ main (profile-thunk main))
@iwinux
iwinux / dump-doit-im.py
Created January 14, 2013 16:19
Dump Doit.im to JSON (can be imported to Taskwarrior) **BACKUP YOUR DATA BEFORE TRYING**
# encoding: utf-8
from __future__ import print_function
from json import dumps as to_json
from datetime import datetime, timedelta
import requests
URL_BASE="https://i.doit.im/tasks/%s"
DOIT_BOXES = ('inbox', 'today', 'next', 'tomorrow', 'scheduled', 'someday', 'waiting')
COOKIES = { 'autologin': 'Your Autologin Cookie Here' }
@iwinux
iwinux / _form.html.haml
Created January 5, 2013 05:32
A sample Rails form definition
= simple_form_for([:admin, @event]) do |f|
= f.error_notification
.form-inputs
= f.input :is_active
= f.input :name_en, label: 'Name (in English)', input_html: { class: 'input-xxlarge' }
= f.input :name_cn, label: 'Name (in Chinese)', input_html: { class: 'input-xxlarge' }
= f.input :category_id, as: :hidden