Skip to content

Instantly share code, notes, and snippets.

View mrc's full-sized avatar

Matt Curtis mrc

  • Melbourne
View GitHub Profile
@mrc
mrc / 12-bit-unpack.fth
Last active November 15, 2026 11:17
State machine using Leo Brodie's DOER/MAKE to unpack 12-bit data from an 8-bit stream
\ State machine using Leo Brodie's DOER/MAKE to unpack 12-bit data from an 8-bit stream
\ DOER/MAKE: https://archive.org/details/thinking_forth/page/n286/mode/1up
\ 3 packed bytes = 2 12-bit words.
\ byte -- word bits
\ 0 -- 0 (8)
\ 1 -- 0 (4) 1 (4)
\ 2 -- 1 (8)
variable buffer
@mrc
mrc / linc-notes.md
Last active October 25, 2026 07:13
linc notes
@mrc
mrc / waitForKeyElements.js
Created July 5, 2019 19:13 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
-module(index).
-export([get_file_contents/1,show_file_contents/1, index/1, index_map/1, index_helper/3, add_line_number/2]).
% Used to read a file into a list of lines.
% Example files available in:
% gettysburg-address.txt (short)
% dickens-christmas.txt (long)
% Get the contents of a text file into a list of lines.
-module(assignment).
-export([area/1, perimeter/1, enclose/1,
testArea/0, testPerimeter/0, testEnclose/0,
bits/1, bitsDirect/1, bitsTailRecursive/1,
testBits/0,
testAll/0, allTestsPass/0]).
%% circle: {circle, Radius}
%% square: {square, Length}
%% rectangle: {rectangle, Length, Width}
@mrc
mrc / ine.zsh
Created May 2, 2016 02:20
Copy stdin to emacsclient
function ine() {
local tmpfile
tmpfile=$(mktemp "ine-XXXX.${1:-tmp}")
echo "$tmpfile"
touch "$tmpfile"
tee "$tmpfile"
emacsclient -n "$tmpfile"
( sleep 5 ; rm "$tmpfile" ) &
}
@mrc
mrc / live-cricket-score.el
Created February 2, 2014 12:43
Emacs: Retrieve a page from cricinfo and extract the score from the title
(require 'deferred)
(require 'request)
(require 'request-deferred)
(defun extract-title ()
(goto-char (point-min))
(let* ((start-string "<title>")
(end-string "</title>")
(start (search-forward start-string))
(end (- (search-forward end-string) (length end-string))))
@mrc
mrc / mrc-helm-context-info.el
Created February 2, 2014 03:37
Context-sensitive info index lookup with helm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helm info
(defvar mrc-helm-context-info-alist
'(((emacs-lisp-mode lisp-interaction-mode inferior-emacs-lisp-mode)
. (helm-source-info-elisp helm-source-info-cl helm-source-info-emacs))
((org-mode) . (helm-source-info-org))
((lisp-mode) . ((name . "Hyperspec") (info-index . "ansicl")
((name . "Iterate") (info-index . "iterate")))))
"Alist of modes to Helm sources.
@mrc
mrc / gist:8021085
Created December 18, 2013 11:50
"And what was terrifying was not that they would kill you for thinking otherwise, but that they might be right."
% python
Python 2.7.5 (default, Jun 4 2013, 21:44:14)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2+2
5
' '.join([w for i,w in enumerate(sentence.split(),1) if i in (17,23)])