Skip to content

Instantly share code, notes, and snippets.

View kanru's full-sized avatar

Kan-Ru Chen kanru

View GitHub Profile
@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 / 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 / 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 / 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 / Generated table
Created March 4, 2012 14:54
Generate password lookup table
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+----------------------------------------------------
A| U C " S a K n v } n : A n + s # ? @ _ d | 1 E { g J
B| W [ > F ^ i R k M N E < 3 d & L B s [ r l o u / w n
C| k c ] G G F ; Q O \ T G t X G = V 2 b ~ N [ 1 3 ^ O
D| x G A 0 ` Y v 6 2 y 3 w ~ ] b N ) 0 q ' ? J y + u Y
E| V j = c ^ ! R P z N c s R ? Z / K k c F J z \ ' J u
F| c 5 E q . K 6 F } z 9 = ( B = I 7 ( K H = \ + ' 0 Q
G| C ' : p % ~ q # 2 f { 7 | { { + [ z } p T 2 % l ( K
H| r v Z w m @ + k w S 0 ) J 7 + } ^ H ) t G ( f 9 A 3
@kanru
kanru / plurk.lisp
Created March 4, 2012 15:05
Plurk Client
;;;; plurk.lisp --- Plurk Client
;;; Copyright (C) 2012 Kan-Ru Chen
;;; Author(s): Kan-Ru Chen <[email protected]>
;;; Permission is hereby granted, free of charge, to any person obtaining a
;;; copy of this software and associated documentation files (the "Software"),
;;; to deal in the Software without restriction, including without limitation
;;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
@kanru
kanru / sudoku-test.lisp
Created March 4, 2012 15:51 — forked from hanshuebner/sudoku-test.lisp
Ruby book Sudoku solver in Common Lisp
(defmacro deftestpackage (package-name for-package &optional (test-library-package-name :unit-test))
"Define a new package PACKAGE-NAME used to test the package
designated by FOR-PACKAGE. The new package will import all symbols
from FOR-PACKAGE and :USE the package designated by
TEST-LIBRARY-PACKAGE-NAME which supposedly contains unit testing
functions and macros."
`(defpackage ,package-name
(:use ,test-library-package-name ,@(mapcar #'package-name (package-use-list for-package)))
(:import-from ,for-package
,@(let (symbols)
@kanru
kanru / gist:1975946
Created March 5, 2012 01:54
Trackpoint X11 auto config
Section "InputClass"
Identifier "Trackpoint Wheel Emulation"
MatchProduct "TrackPoint"
MatchDevicePath "/dev/input/event*"
Option "EmulateWheel" "true"
Option "EmulateWheelButton" "2"
Option "Emulate3Buttons" "false"
Option "XAxisMapping" "6 7"
Option "YAxisMapping" "4 5"
EndSection
@kanru
kanru / gist:2027952
Created March 13, 2012 10:04
B2G build dependency for Debian Squeeze
# gecko
build-dep iceweasel
libnotify-dev
yasm (>= 1.0.0)
libcurl4-openssl-dev
mesa-common-dev
# gonk
gcc-multilib
g++-multilib
@kanru
kanru / hgrep.py
Created March 15, 2012 05:47
hg grep
# from http://blog.axant.it/archives/283
import itertools, os, os.path
def hgrep(ui, repo, what, **opts):
files = []
status = repo.status(clean=True)
for f in itertools.chain(status[0], status[1], status[4], status[6]):
files.append(os.path.join(repo.root, f))