Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@alphapapa
alphapapa / _reader-macros.md
Created October 26, 2015 04:34 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

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. ...read-macros... do their work at read-time.

@alphapapa
alphapapa / diskchecker.pl
Created April 18, 2016 04:11 — forked from bradfitz/diskchecker.pl
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
@alphapapa
alphapapa / filter-buffer.el
Created April 22, 2016 09:44 — forked from wasamasa/filter-buffer.el
Emacs buffer filtering
(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
(buffer-string))))
(erase-buffer)
(insert output)))
(kill-buffer stdout-buffer)))
@alphapapa
alphapapa / createshortcut.js
Created October 23, 2016 01:26 — forked from amzyang/createshortcut.js
create pentadactyl commandline options
// createshortcut.js -- ++pentadactyl
// @Author: eric.zou (frederick.zou@gmail.com)
// @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
// @Created: Tue 29 Nov 2011 01:24:05 PM CST
// @Last Change: Tue 29 Nov 2011 02:23:36 PM CST
// @Revision: 41
// @Description:
// @Usage:
// @TODO:
// @CHANGES:
@alphapapa
alphapapa / emacsconf2013-sacha.org
Created March 9, 2017 15:21 — forked from sachac/emacsconf2013-sacha.org
Source code for my Emacs conference talk

Comments? sacha@sachachua.com

  • Emacs learning curve?

Meta information

Assumptions

  • Mix of Emacs geeks skewed towards people who’ve been using this for a while (after all, takes a certain commitment to come all the way to an Emacs conference!)

Outcomes

#!/usr/bin/env zsh
# -*- coding: UTF8 -*-
# Author: Guillaume Bouvier -- guillaume.bouvier@ens-cachan.org
# 2016-05-10 15:36:06 (UTC+0200)
format_duration()
{
diff=$1 # Duration in seconds
if test $diff -ge 86400; then
@alphapapa
alphapapa / README.md
Created June 24, 2017 21:23 — forked from Fuco1/README.md
org-graph

Relations

Relations are maintained through the outline hierarchy and special properties on the entries so we can model arbitrary graphs instead of only DAGs. This means you can define parents or children completely outside the hierarchy or even in different files.

Relations are kept in sync bidirectionally so please only use the API to maintain them otherwise things might get lost. Because the relations are bidirectional the graph traversal and querying is extremly fast.

Parents

Parents are defined by the GRAPH_PARENTS property as list of IDs and implicitly through the org outline hierarchy: all headlines above this one are this entry's parents.

;;; Neat convenience function for working with Elisp's EIEIO objects
(defmacro oref* (object &rest slots)
"Like `oref', but each slot in SLOTS is applied in sequence.
For example,
\(oref* obj :inner :property)
is equivalent to
@alphapapa
alphapapa / pp-debug.el
Created December 6, 2017 19:04 — forked from felipeochoa/pp-debug.el
Pretty print emacs debug frames
;;; pp-debug.el --- Pretty-print debug frames -*- lexical-binding: t -*-
;; Copyright (C) 2017 Felipe Ochoa
;; Author: Felipe Ochoa
;; Created: 5 Dec 2017
;; License: GPL
;;; Commentary:
;;; Pretty-print debugger frames.
@alphapapa
alphapapa / .gitignore
Created September 11, 2016 07:52 — forked from wzhd/.gitignore
Parsing Evernote export file (.enex) using Python
*.enex