Skip to content

Instantly share code, notes, and snippets.

alphapapa / w
Created Nov 7, 2014
w: Print summary of Wikipedia article to STDOUT
View w
#!/usr/bin/env python
# Requires wikipedia module. '$ pip install wikipedia' Put it in your
# path and 'chmod +x'. Then just 'w whatever' and find out what
# something is! :D
# I couldn't find a good command-line utiity to do this.
# wikipedia2text is okay but it does the whole page, which isn't
# always what I want. The old command 'dig +short txt "$"'
# doesn't work anymore. But this works well.
alphapapa /
Last active Sep 17, 2015
Pretty-print the last Firefox session's windows, tabs, and URLs. Useful for when Firefox fails to correctly reload a tab on start, and you have no idea what was loaded in that tab, but you know it was important.
#!/usr/bin/env python
import datetime, json, sys
def formatEntry(entry):
return "%s (%s) (%s)" % (entry['title'].encode('utf8')
if entry.has_key('title') else "<untitled>",
int(tab['lastAccessed']) / 1000).strftime('%Y-%m-%d %H:%M:%S'))
alphapapa /
Last active Sep 30, 2015
Fish functions and bindings for finding directories and files with Percol and locate
set -g percolOptions --prompt-bottom --result-bottom-up
# This is simply too slow right now, so using Bash instead
function onlyDirs
while read dir
test -d $dir
and echo $dir
alphapapa /
Created Oct 26, 2015 — forked from chaitanyagupta/
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide 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. do their work at read-time.

View change-inner.el
(defun change-inner (prefix character)
"Kill region inside delimiters, using either beginning or
ending delimiter. With prefix arg, kill including delimiters."
(interactive "p\nc")
(let ((initial-point (point))
(move-point-by (if (> prefix 1) 0 1)))
View readingplan.txt
Read ESV in 90 sessions (Ultimate: Gosp+Ac, Rom-Rev)
[ ] October 31, 2015 Gen 1–9, Matt 1–2, Rom 1, Ps 1–3, Prov 1:1–7
[ ] November 01, 2015 Gen 10–19, Matt 3:1–5:12, Rom 2:1–3:8, Ps 4–6, Prov 1:8–19
[ ] November 02, 2015 Gen 20–26, Matt 5:13–6:15, Rom 3:9–4:12, Ps 7–8, Prov 1:20–33
[ ] November 03, 2015 Gen 27–32, Matt 6:16–7:29, Rom 4:13–5:21, Ps 9, Prov 2:1–10
[ ] November 04, 2015 Gen 33–41, Matt 8–9, Rom 6–7, Ps 10–12, Prov 2:11–22
[ ] November 05, 2015 Gen 42–50, Matt 10, Rom 8, Ps 13–16, Prov 3:1–12
[ ] November 06, 2015 Exod 1–8, Matt 11:1–12:21, Rom 9:1–29, Ps 17, Prov 3:13–18
[ ] November 07, 2015 Exod 9–16, Matt 12:22–13:30, Rom 9:30–10:21, Ps 18, Prov 3:19–26
alphapapa / org-agenda-subtree-or-region.el
Last active Mar 21, 2016
Emacs: Display org-agenda for current subtree or region
View org-agenda-subtree-or-region.el
(defun org-agenda-subtree-or-region (prefix)
"Display an agenda view for the current subtree or region.
With prefix, display only TODO-keyword items."
(interactive "p")
(let (header)
(if (use-region-p)
(setq header "Region")
(put 'org-agenda-files 'org-restrict (list (buffer-file-name (current-buffer))))
(setq org-agenda-restrict (current-buffer))
alphapapa / ap-comment-dwiw.el
Last active Apr 2, 2016
Yet another comment-do-what-I-want function
View ap-comment-dwiw.el
(defun ap/comment-dwiw (prefix)
"Add/remove comments from code.
With prefix, uncomment region or remove commented lines.
More specifically:
With active region:
* With prefix: Uncomment region.
* Without prefix: Comment/uncomment region.
# Brad's el-ghetto do-our-storage-stacks-lie?-script
sub usage {
die <<'END';
Usage: -s <server[:port]> verify <file> -s <server[:port]> create <file> <size_in_MB> -l [port]
alphapapa / filter-buffer.el
Created Apr 22, 2016 — forked from wasamasa/filter-buffer.el
Emacs buffer filtering
View filter-buffer.el
(defun my-filter-current-buffer (program &rest args)
(let* ((stdout-buffer (generate-new-buffer " stdout"))
(ret (apply 'call-process-region (point-min) (point-max) program
nil (list stdout-buffer) nil args)))
(when (zerop ret)
(let ((output (with-current-buffer stdout-buffer
(insert output)))
(kill-buffer stdout-buffer)))