Skip to content

Instantly share code, notes, and snippets.

View ftrain's full-sized avatar

Paul Ford ftrain

View GitHub Profile
@ftrain
ftrain / list->structuredlist.clj
Created December 15, 2013 20:25
List to structured list scratchpade
;; I have
(def events ["== A ==" "=== A.1 ===" "* One" "* Two" "** Two.A" "** Two.B" "== B =="])
;; (i.e. wikipedia markup) And what I want is:
;; (("== A =="
;; ("=== A.1 ==="
;; ("* One"
;; "* Two"
;; ("** Two.A"
@ftrain
ftrain / .emacs
Last active July 16, 2021 17:26
a nice .emacs for when you are on a terminal. Respects scroll wheel events. Very useful when run inside of tmux and combined with this tmuxconf: https://gist.github.com/ftrain/8443744
;; .emacs
;;; uncomment this line to disable loading of "default.el" at startup
;; (setq inhibit-default-init t)
;; enable visual feedback on selections
(setq transient-mark-mode t)
;; default to better frame titles
(setq frame-title-format
@ftrain
ftrain / .tmux.conf
Created January 15, 2014 20:18
A tmux that respects mouse events.
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
set -g base-index 1
setw -g aggressive-resize on
set-option -g status-utf8 on
@ftrain
ftrain / rhymes.clj
Last active July 14, 2023 22:20
Annotated rhyming dictionary
;; This is at: https://gist.github.com/8655399
;; So we want a rhyming dictionary in Clojure. Jack Rusher put up
;; this code here:
;;
;; https://gist.github.com/jackrusher/8640437
;;
;; I'm going to study this code and learn as I go.
;;
;; First I put it in a namespace.
(def date-parsers [nil (java.text.SimpleDateFormat. "yyyy") (java.text.SimpleDateFormat. "yyyy-M") (java.text.SimpleDateFormat. "yyyy-M-dd")])
(def grains [:decade :year :month :day]) ;; what's decade doing?
(map #(let [[_ year month day] (re-find #"(\d{2,4})[-_]([\dx]{2})[-_]([\dx]{2})" %)
date (first (split-with (partial not= "xx") [(if (= (count year) 2) (str "19" year) year) month day]))]
[(.parse (parsers (count date)) (clojure.string/join "-" date)) (grains (count date))])
["thefilehasaname__1939-xx-01.mp3"
"thefilehasaname__39_01_01.mp3"
"thefilehasaname__39-01-01.mp3"
;; simplest fold definition
(define (fold f init l)
(if (null? l) init (fold f (f init (car l)) (cdr l))))
;; by this time you are almost certainly comfortable with signatures like:
;; Int -> Int
(fold + 0 '[1 2 3 4 5])
;; => 15
@ftrain
ftrain / actually.js
Last active November 10, 2023 01:16
A program that generates actuallies
/*
actually.js
_ _ _
__ _ __ _ __ _ __ _ ___| |_ _ _ __ _| | |_ _
/ _` |/ _` |/ _` |/ _` |/ __| __| | | |/ _` | | | | | |
| (_| | (_| | (_| | (_| | (__| |_| |_| | (_| | | | |_| |_
\__,_|\__,_|\__,_|\__,_|\___|\__|\__,_|\__,_|_|_|\__, ( )
|___/|/
*/
#!/bin/bash
#
# _ _ __
# __ _ __ _ _ __| |__ (_)/ _|_ _
# / _` |/ _` | '__| '_ \| | |_| | | |
#| (_| | (_| | | | |_) | | _| |_| |
# \__, |\__,_|_| |_.__/|_|_| \__, |
# |___/ |___/
#
#
@ftrain
ftrain / bing-gobble.pl
Created April 27, 2015 02:54
Get the counts for words on sites with bing!
#!/usr/bin/perl
# Copyright (c) 2015, Paul Ford, [email protected]
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
Sometimes there's a terrible penalty for telling the truth.
—The Great Lie (1941)
Sometimes even Cupid needs a little help!
—The Model and the Marriage Broker (1951)
Sometimes any man can be a giant . . .
—Giant (1956)
Sometimes murder is just a way to pass the time.