Skip to content

Instantly share code, notes, and snippets.

@kriyative
kriyative / destructuring-bind-1.lisp
Created July 6, 2011 18:23
A lightweight `bind' macro 1
(destructuring-bind (x y)
point
(destructuring-bind (x1 y1 w h)
frame
(let ((x2 (+ x1 w))
(y2 (+ y1 h)))
(and (>= x x1) (<= x x2) (>= y y1) (<= y y2)))))
@kriyative
kriyative / parse-relative-time.el
Created July 6, 2011 18:21
Displaying a daily Org-mode agenda reminder in Emacs 2
(defun parse-relative-time (time-str)
(destructuring-bind (sec min hour day month year dow dst zone)
(parse-time-string time-str)
(destructuring-bind (sec1 min1 hour1 day1 month1 year1 dow1 dst1 zone1)
(decode-time)
(encode-time (or sec sec1)
(or min min1)
(or hour hour1)
(or day day1)
(or month month1)
@kriyative
kriyative / org-mode-agenda-hack.el
Created July 6, 2011 18:14
Displaying a daily Org-mode agenda reminder in Emacs 1
(defvar daily-agenda-timer (parse-relative-time "9:00 am"))
;; (decode-time daily-agenda-timer)
(defun show-daily-agenda ()
(unless (time-less-p (current-time) daily-agenda-timer)
(setq daily-agenda-timer (time-add daily-agenda-timer
(seconds-to-time 86400)))
(org-agenda-list)))
(add-hook 'display-time-hook 'show-daily-agenda)
@kriyative
kriyative / tail-f.el
Created May 31, 2011 02:51
Emacs Lisp function `tail-f`
(defun tail-f (file)
"Create a COMINT mode buffer running the `tail -f` command on
specified FILE. If FILE is a ssh/scp style remote file spec,
e.g.,
[email protected]:/path/to/file.txt
then a ssh connection is opened to remote.host.com, and `tail -f`
is invoked on the remote server."
(interactive "fFile: ")
@kriyative
kriyative / myapp.clj
Created January 20, 2011 19:43
server side Clojure for setting up routes etc.
;;; -*- Mode: Clojure -*-
;; This is clojurejs code which is translated to javascript and runs in the browser
(defn login-submit! []
(.text ($ ".error") "")
(.text ($ "#login-message") "submitting ..."))
(defn dialog-close [] (.dialog ($ this) :close))