Skip to content

Instantly share code, notes, and snippets.

View clvrobj's full-sized avatar

Chi Zhang clvrobj

  • Singapore, Singapore
View GitHub Profile
# -*- coding: utf-8 -*-
import sys
import os
import fnmatch
def Walk(root='.', recurse=True, pattern='*'):
"""
Generator for walking a directory tree.
Starts at specified root folder, returning files
that match our pattern. Optionally will also
@clvrobj
clvrobj / gist:3795035
Created September 27, 2012 16:43
Check and add "# -*- coding: utf-8 -*-"
(defun add-py-header ()
"check and add # -*- coding: utf-8 -*-"
(interactive)
(let ((pyheader "# -*- coding: utf-8 -*-"))
(if (not (equal pyheader (buffer-substring-no-properties 1 (1+ (length pyheader)))))
(progn (goto-char 1)
(insert (concat pyheader "\n\n"))))))
@clvrobj
clvrobj / .emacs
Created October 11, 2012 06:49
.emacs
(cond
((= 23 emacs-major-version)
(if (file-exists-p "~/.emacs.d/emacs23.el")
(load-file "~/.emacs.d/emacs23.el")))
((= 24 emacs-major-version)
(if (file-exists-p "~/.emacs.d/emacs24.el")
(load-file "~/.emacs.d/emacs24.el")))
)
@clvrobj
clvrobj / gist:4167644
Created November 29, 2012 08:46 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
@clvrobj
clvrobj / douban.com.js
Created December 15, 2012 13:59
for the coming annoying douban's new nav bar
$('.nav').css({'margin-bottom':'30px'});
$('.nav-primary').css({'padding':0});
$('.nav-logo a').attr('href', 'http://www.douban.com/update/');
$('.nav-logo').css({'height':'52px'});
$('#db-nav-sns .nav-items ul').append('<li><a href="http://www.douban.com/group/">小组</a></li>');
@clvrobj
clvrobj / readme.md
Created January 7, 2013 08:18 — forked from liluo/readme.md

init

mkdir proj
cd proj
git init

config

git config user.name 'username'
(defun switch-same-buffer-other-window()
"Open same buffer and switch to the other window."
(interactive)
(let ((cur-buf (current-buffer)))
(other-window 1)
(switch-to-buffer cur-buf)))
(global-set-key "\C-x\C-o" 'switch-same-buffer-other-window)
@clvrobj
clvrobj / emacs24.el
Created October 11, 2013 02:37
My Emacs config
(menu-bar-mode 0)
(tool-bar-mode 0)
;; (scroll-bar-mode 0)
(blink-cursor-mode 0)
(set-default-font "Source Code Pro 13")
;; format title bar to show full path of current file
(setq-default frame-title-format
(list '((buffer-file-name " %f"
#!/bin/sh -xe
# Sets up m2crypto on ubuntu architecture in virtualenv
# openssl 1.0 does not have sslv2, which is not disabled in m2crypto
# therefore this workaround is required
PATCH="
--- SWIG/_ssl.i 2011-01-15 20:10:06.000000000 +0100
+++ SWIG/_ssl.i 2012-06-17 17:39:05.292769292 +0200
@@ -48,8 +48,10 @@
mContext.registerReceiver(
new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
synchronized(mMethodMap) {
resetStateIfCurrentLocaleChangedLocked();
}
}
}, filter);