Skip to content

Instantly share code, notes, and snippets.

View kanru's full-sized avatar

Kan-Ru Chen kanru

View GitHub Profile
@kanru
kanru / weechat-osd.py
Created March 4, 2012 14:25
On Screen Display pluign of WeeChat
# -*- coding: utf-8 -*-
#
# Kan-Ru Chen <[email protected]>
# License: GPLv3
#
'''
On Screen Display pluign of WeeChat
'''
from os import popen
import weechat as w
@kanru
kanru / shake.lisp
Created March 4, 2012 04:03
shake-lisp-and-die
;;; THIS IS A PROOF OF CONCEPT. This has been "released" in case someone
;;; actually wants to develop it into a usable tool. Don't even think
;;; about using this version for any sort of production use.
;;; Author: Juho Snellman
;;; http://jsnell.iki.fi/blog/archive/2005-07-06.html
(defparameter *retain* (make-hash-table :test 'eq))
(defparameter *ignore* (make-hash-table :test 'eq))
(defparameter *classes* nil)
@kanru
kanru / org-emacs22.diff
Created March 2, 2012 06:18
org-mode Emacs 22 compat
diff --git a/lisp/org.el b/lisp/org.el
index abafde8..e1d1caa 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20745,7 +20745,9 @@ depending on context."
(not (y-or-n-p "Kill hidden subtree along with headline? ")))
(error "C-k aborted - would kill hidden subtree")))
(call-interactively
- (if visual-line-mode 'kill-visual-line 'kill-line)))
+ (if (and (boundp 'visual-line-mode)
@kanru
kanru / _hg_cmd_qqueue
Created February 14, 2012 05:53
Mercurial "qqueue" Zsh completion file
#compdef hg_cmd_qqueue
declare -A opt_args
_hg_queues() {
typeset -a queues
queues=(${(f)"$(_hg_cmd qqueue --quiet)"})
(( $#queues )) && _describe -t hg-queues 'queues' queues
}
_arguments -s -w \
@kanru
kanru / grep-id
Created February 9, 2012 08:57
grep-id
#! /bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This program uses id-utils[1] output as a hint for grep to quickly
# find the target term. Thus to use this program you have to create
# the ID database first.
#
@kanru
kanru / pdf-ocr.sh
Created January 19, 2012 08:19
PDF OCR
#! /bin/sh
# Batch OCR pdf files to text files
#
# Copyright (C) 2012 Kan-Ru Chen <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@kanru
kanru / repl.js
Created January 10, 2012 09:13
JS repl
const repl = "JS> ";
(function Repl() {
let output;
let reader = {
onInputStreamReady : function(input) {
var sin = Cc['@mozilla.org/scriptableinputstream;1']
.createInstance(Ci.nsIScriptableInputStream);
sin.init(input);
try {
@kanru
kanru / Android.mk
Created January 6, 2012 04:16
Android GPS using libhardware
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
gps_test.cpp
LOCAL_SHARED_LIBRARIES := \
libcutils libhardware
LOCAL_MODULE:= test-gps
@kanru
kanru / karma 100
Created February 8, 2010 07:47 — forked from c9s/gist:297919
#karma{color:rgba(0,0,0,0);background:url(http://omploader.org/vM2hoeQ/karma_hack.png) no-repeat;}
--- flint_database.cc 2009-12-08 13:34:24.790284881 +0800
+++ flint_database.cc 2009-12-10 14:22:14.493653956 +0800
@@ -1188,7 +1188,7 @@
termlist.next();
while (!termlist.at_end()) {
- string tname = termlist.get_termname();
+ string tname = termlist.get_termname();
position_table.delete_positionlist(did, tname);
termcount wdf = termlist.get_wdf();