Skip to content

Instantly share code, notes, and snippets.

@thisirs
thisirs / gist:6938075
Created October 11, 2013 16:44
Get rid of empty directories in firefox bookmarks
-- Get rid of empty directories in firefox bookmarks
DELETE FROM moz_bookmarks
WHERE type = 2
AND id > 5
AND id NOT IN (
SELECT DISTINCT parent FROM moz_bookmarks)
@thisirs
thisirs / gist:4655411
Created January 28, 2013 13:15
Alert user that a job finished
# Alert user that a job finished:
# lengthycmd; alert
# or
# lengthycmd
# <CTRL-Z>
# fg; alert
function alert() {
JOB=$(history 1)
if [[ "$JOB" == *fg\;* ]]
then
@thisirs
thisirs / gist:4169777
Created November 29, 2012 15:25
Seeing a diff when writing a commit in magit
;; look at diff when writing a commit message
(defun magit-log-show-diff ()
(interactive)
(let ((content (magit-cmd-output "git" '("diff" "--cached" "-U5"))))
(with-current-buffer (get-buffer-create "*vc-diff*")
(let ((buffer-undo-list t)
(inhibit-read-only t))
(erase-buffer)
(insert content))
(diff-mode)
@thisirs
thisirs / gist:4162463
Created November 28, 2012 16:48
Function returning the place of an element in a tree
(defun place-of (item tree)
(let ((place (place-of-1 item tree "")))
(and place
(intern (concat "c" place "r")))))
(defun place-of-1 (item tree place)
(cond
((null tree))
((consp tree)
(let (found)
@thisirs
thisirs / gist:3697342
Created September 11, 2012 09:57
hippie-expand and flyspell
(defun try-complete-flyspell (old)
(when (not old)
;; use the correct dictionary
(flyspell-accept-buffer-local-defs)
(setq he-next-expand 0)
(he-init-string (he-dabbrev-beg) (point))
;; now check spelling of word.
(ispell-send-string "%\n") ;put in verbose mode
(ispell-send-string (concat "^" he-search-string "\n"))
;; wait until ispell has processed word