Skip to content

Instantly share code, notes, and snippets.

@bamanzi
bamanzi / evernote-search.py
Created November 21, 2012 06:03
search evernote notes by keywords in title
#!/usr/bin/python
#search evernote notes keywords in title
import sqlite3
def main(endbfile, keywords):
conn = sqlite3.connect(endbfile)
cursor = conn.cursor()
sql = """SELECT title, date_created, date_updated, source_url, uid
@bamanzi
bamanzi / cnblogs-ing.el
Last active December 9, 2015 21:08
cnblogs-ing-search (AutoIt & EmacsLisp)
(defun search-cnblogs-ing ()
(interactive)
(require 'hide-lines)
(let ((file (car (last (directory-files "d:\\Downloads"
t
"CNBlogs_Ing_Backup_[0-9]+.txt")))))
(find-file file)
(with-current-buffer (file-name-nondirectory file)
(local-set-key (kbd "C-c C-s") 'hide-non-matching-lines)
# batch install missing packages reported by `bundle package`
# When `bundle package', it might complain: "Could not find charlock_holmes-0.6.9.1.gem for installation",
# You have to run `gem install charlock_holmes -v 0.6.9.1' and run `bundle package` again
# And it might complain another package missing, then you have to run `gem install foobar -v xxxxx`
# Again, and again. Thus I have this little script
# Note: it would fail on packages like 'libv8-3.11.8.13-x86_64-linux.gem', which you can handle it manually
while true; do
@bamanzi
bamanzi / zsh-git-prompt.sh
Created June 27, 2013 09:43
zsh: show git repo name, branch in right prompt
# although StackOverflow has this answer http://stackoverflow.com/a/1128583
# but that code is unreadable, thus I have this (also based on a SO anower: http://stackoverflow.com/a/1128721 )
# get the name of the branch we are on
_git_repo_name() {
gittopdir=$(git rev-parse --git-dir 2> /dev/null)
if [[ "foo$gittopdir" == "foo.git" ]]; then
echo `basename $(pwd)`
elif [[ "foo$gittopdir" != "foo" ]]; then
echo `dirname $gittopdir | xargs basename`
@bamanzi
bamanzi / gist:6008825
Created July 16, 2013 13:45
[emacs] Toggle window split direction
(defun window-toggle-split-direction ()
"Switch window split from horizontally to vertically, or vice versa.
i.e. change right window to bottom, or change bottom window to right."
(interactive)
(require 'windmove)
(let ((done))
(dolist (dirs '((right . down) (down . right)))
(unless done
@bamanzi
bamanzi / SciTEUser.properties
Created July 31, 2013 07:08
Add grep/ack/grin to SciTE(-ru)
## Note: for scite.ShowParametersDialog, you need SciTE-ru (http://scite-ru.googlecode.com )
## and original SciTE allows only up to 50 commands (while SciTE-ru allows 300)
## on original SciTE, you can add this:
#command.name.260.*=Grep in current file...
#command.mode.260.*=subsystem:console,savebefore:no
#command.26.*=grep --line-number --with-filename "$(CurrentSelection)" "$(FileNameExt)"
##or:
#command.26.*=*grep --line-number --with-filename "$(1)" "$(2)"
@bamanzi
bamanzi / qtmstr-outline-margin.diff
Created October 17, 2013 06:26
Let qtmstr-outline.el support term (use margin instead of fringe)
@@ -153,19 +192,28 @@
(defvar qtmstr-outline-header-map
(progn (let ((km (make-sparse-keymap)))
- (define-key km [mouse-2] #'qtmstr-outline-on-header-click)
- (define-key km "\r" #'qtmstr-outline-on-header-return)
+ (define-key km [mouse-1] #'qtmstr-outline-on-header-click)
+ (define-key km [mouse-3] #'show-subtree)
+ (define-key km (kbd "C-c TAB") #'outline-toggle-children)
+;; (define-key km "\r" #'qtmstr-outline-on-header-return)
@bamanzi
bamanzi / anything-tabs.el
Created November 4, 2013 03:38
anything-tab-list
(defun anything-c-tab-list ()
"Return a list of buffer names of current tabbar group. "
(unless (and (featurep 'tabbar)
tabbar-mode)
(error "Error: tabbar-mode not turned on."))
(with-current-buffer anything-c-tab-current-buffer
(mapcar #'(lambda (tab) (buffer-name (tabbar-tab-value tab)))
(tabbar-tabs (tabbar-current-tabset t)))))
(setq anything-c-tab-current-buffer nil)
@bamanzi
bamanzi / anything-org-headings.el
Created November 14, 2013 13:45
[emacs] anything-org-headings
(setq anything-c-source-org-headings
'((name . "Org Headings")
(headline . "^[*]+ ")
(condition . (eq major-mode 'org-mode))
(migemo)
(persistent-action . (lambda (elm)
(anything-c-action-line-goto elm)
(show-subtree)))
@bamanzi
bamanzi / firefox-tango-colors.md
Created November 15, 2013 02:53
Firefox: tango colors