Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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`
# 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 / 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)
@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 / gist:3945989
Created October 24, 2012 13:15
Dreampie configuration causing this bug https://github.com/noamraph/dreampie/issues/3
[DreamPie]
show-getting-started = False
font = Courier New 10
current-theme = Dark
pprint = True
use-reshist = True
reshist-size = 30
autofold = True
autofold-numlines = 30
viewer = ''
@bamanzi
bamanzi / gist:3774144
Created September 24, 2012 04:07
check whether all notes in evernote3 are migrated to 3 to 4
# coding: utf-8
# check whether all notes in evernote3 are migrated to 3 to 4
# 1. open an evernote 4.x database (sqlite)
# 2. open an evernote 3.x export (.enex)
# 3. check for each note in enex, if not in evernote 4 database, then print out the title
import sqlite3
from lxml import etree
@bamanzi
bamanzi / projectile-anything.el
Created August 23, 2012 08:36
projectile-anything.el
(require 'projectile)
(require 'anything)
;; helper for anything
(defun anything-c-projectile-files ()
"Generates a list of files in the current project"
(projectile-get-project-files
(projectile-get-project-root)))
(defvar anything-c-source-projectile-files
@bamanzi
bamanzi / no-cedet-imenu.el
Created August 9, 2012 14:05
[emacs] get rid of cedet's imenu creator
(defun bmz/restore-imenu-index-function ()
"Restore `imenu-create-index-function' for current major-mode.
Note this would reset to `imenu-default-create-index-function', but some modes
have its own implementation."
(interactive)
(let* ((func-name (cond
((eq major-mode 'python-mode)
'python-imenu-create-index)
((eq major-mode 'js2-mode)