Skip to content

Instantly share code, notes, and snippets.

import os
import re
import sys
CITE_KEY_RE = re.compile(ur"\s*:CITE-KEY:\s*(\w+)(-\d+)?", re.IGNORECASE)
PROPERTIES_RE = re.compile(ur"(\s*):PROPERTIES:\s*", re.IGNORECASE)
END_RE = re.compile(ur"\s*:END:\s*", re.IGNORECASE)
GENRE_RE = re.compile(ur"\s*:GENRE:\s*(note|preface|section)\b", re.IGNORECASE)
@priyadarshan
priyadarshan / cite_key.py
Last active December 18, 2015 20:48
Fix CITE-KEY regex
import os
import re
import sys
CITE_KEY_RE = re.compile(ur"\s*:CITE-KEY:(?:\s*(\w+)(-\d+)?)?", re.IGNORECASE)
PROPERTIES_RE = re.compile(ur"(\s*):PROPERTIES:\s*", re.IGNORECASE)
END_RE = re.compile(ur"\s*:END:\s*", re.IGNORECASE)
META_GENRE_RE = re.compile(ur"\s*:GENRE:\s*(note|preface|section)\b", re.IGNORECASE)
import os
import re
import shutil
import sys
TITLE_RE = re.compile(r"^\s*#\+TITLE:\s*([^\n]+)\n")
PROPERTIES_RE = re.compile(r"^\n?[ \t]*:PROPERTIES:[ \t]*\n", re.MULTILINE)
END_RE = re.compile(r"^[ \t]*:END:[ \t]*\n\n", re.MULTILINE)
PROPERTY_RE = re.compile(r"^[ \t]*:[\w\-]+:[^\n]*\n", re.MULTILINE)
ITALICS_RE = re.compile(r"^/([^\n]+)/", re.MULTILINE)
;;;; regenerate.lisp - script for regenerating [redacted] static HTML from template files.
(ql:quickload "cl-emb")
(ql:quickload "cl-fad")
(ql:quickload "cl-ppcre")
(defparameter *configuration* '() "plist containing config parameters passed to EMB templates.")
(defparameter *essays* '() "plist containing essay descriptors generated by `defessay'.")
(defconstant +default-properties+ '(:title nil :url nil :orig-title nil :orig-url nil :date nil :orig-date nil :alt-translations nil :translators nil :editors nil :disabled nil :additional-html nil :part-of-hnp nil :description ""))
@priyadarshan
priyadarshan / 0_reuse_code.js
Created November 12, 2013 18:35
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
PROMPT='%{$fg_bold[red]%}>%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}x%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%}) 0"
javascript:(function(){ document.body.innerHTML = document.getElementById("readme").getElementsByTagName("article")[0].outerHTML; })();

Reader Macros in Common Lisp

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros allow even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

Macros and read-macros see your program at different stages. Macros get hold of the program when it has already been parsed into Lisp objects by the reader, and read-macros operate on a program while it is still text. However, by invoking read on this text, a read-macro can, if it chooses, get parsed Lisp objects as well. Thus read-macros are at least as powerful as ordinary macros.

(require 'ido-at-point)
(defun ido-at-point-x-prompt (prompt choices &optional display-fn)
"Display choices in a x-window prompt."
(when (and window-system choices)
(let ((chosen
(let (menu d) ;; d for display
(dolist (c choices)
(setq d (or (and display-fn (funcall display-fn c))
c))
import os
import re
import shutil
import sys
TITLE_RE = re.compile(r"^\s*#\+TITLE:\s*([^\n]+)\n")
PROPERTIES_RE = re.compile(r"^\n?[ \t]*:PROPERTIES:[ \t]*\n", re.MULTILINE)
END_RE = re.compile(r"^[ \t]*:END:[ \t]*\n\n", re.MULTILINE)
PROPERTY_RE = re.compile(r"^[ \t]*:[\w\-]+:[^\n]*\n", re.MULTILINE)
ITALICS_RE = re.compile(r"^/([^\n]+)/", re.MULTILINE)