Skip to content

Instantly share code, notes, and snippets.

View alphapapa's full-sized avatar

Adam Porter alphapapa

  • USA
View GitHub Profile
@alphapapa
alphapapa / w
Created November 7, 2014 05:02
w: Print summary of Wikipedia article to STDOUT
#!/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 "$1.wp.dg.cx"'
# doesn't work anymore. But this works well.
@alphapapa
alphapapa / python-mode-outline-mode.el
Last active September 7, 2023 00:03
Emacs: Python: outline-minor-mode headings for both Python keywords and standard commented-starred headings
(defun python-mode-outline-hook ()
(setq outline-level 'python-outline-level)
(setq outline-regexp
(rx (or
;; Commented outline heading
(group
(* space) ; 0 or more spaces
(one-or-more (syntax comment-start))
(one-or-more space)
@alphapapa
alphapapa / outline-mode-folding-python-elisp-shell.el
Created March 22, 2015 08:23
Emacs: outline-mode folding for Python, elisp, and shell
(defun my/python-mode-outline-hook ()
(setq outline-level 'my/python-outline-level)
(setq outline-regexp
(rx (or
;; Commented outline heading
(group
(* space) ; 0 or more spaces
(one-or-more (syntax comment-start))
(one-or-more space)
@alphapapa
alphapapa / print-firefox-session.py
Last active September 17, 2015 06:39
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>",
entry['url'].encode('utf8'),
datetime.datetime.fromtimestamp(
int(tab['lastAccessed']) / 1000).strftime('%Y-%m-%d %H:%M:%S'))
@alphapapa
alphapapa / _percol_bind_keys.fish
Last active September 30, 2015 03:21
Fish functions and bindings for finding directories and files with Percol and locate
#!/usr/bin/fish
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
end
@alphapapa
alphapapa / pyt.sh
Last active March 29, 2020 09:50
#!/bin/bash
# * pyt
# ** TODOS
# *** TODO Branch for downloading audio/video separately and playing with mplayer or something
# Both VLC and mplayer can play separate audio and video files
# together, but VLC doesn't have a command-line option for
@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.

(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))
(start)
(end)
(move-point-by (if (> prefix 1) 0 1)))
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
alphapapa / mangle
Last active June 21, 2021 16:03
Mangle man pages to show just the parts you need (suitable for aliasing to "man")
#!/bin/bash
less_command='| less $less_no_init -aiF -Ps"Manual page\: $man_page (?ltline %lt?L/%L.:byte %bB?s/%s..? (END):?pB %pB\%..)"'
# Get section
if [[ $1 =~ [0-9]+ ]]
then
section=$1
shift
fi