Skip to content

Instantly share code, notes, and snippets.


Sam Atman mnemnion

  • Haiku, Maui, HI
View GitHub Profile
mnemnion / curry.lua
Created Nov 7, 2020
Simple currying in Lua, partial application
View curry.lua
-- Simple currying module
-- With a bit of extra complexity, so that
-- currying several times gives only one
-- level of function indirection for up to
-- five parameters.
-- weak table to store a reference to the curried
-- function, with the parameters and original function
local _curried = setmetatable({}, { __mode = 'k' })
mnemnion /
Last active Sep 8, 2020
change git trunk-branch name from master to trunk
git checkout master
git branch -m master trunk
git fetch
git branch --unset-upstream
git branch -u origin/trunk
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/trunk
mnemnion / sparse.lua
Last active Mar 4, 2020
Sparse multidimensional tables in Lua
View sparse.lua
local Sparse = {}
local function new(dimension)
local sparse = {}
sparse._dimension = dimension
return setmetatable(sparse, Sparse)
function Sparse.__index(sparse, key)
if sparse._dimension == 1 then
mnemnion /
Last active Jan 28, 2020
Move files to a different repo with history
#! /bin/bash
# Usage:
# ./ path1/ path2/... path/to/destination/repo
# All but last argument:
# Last argument:

Keybase proof

I hereby claim:

  • I am mnemnion on github.
  • I am atman ( on keybase.
  • I have a public key ASAWKn9EMHtlfAZz2a4lbuFStIGWdm56UzfAcl7--TsUwwo

To claim this, I am signing this object:

// instead of having to do this all the time:
let maybe_utf8 = match stream.fill_buf() {
Ok(filehandle) => filehandle,
Err(_) => return captures,
let phrase = match from_utf8(maybe_utf8) {
Ok(utf8) => String::from(utf8),
Err(_) => return captures,
mnemnion /
Last active Jul 16, 2016
The essential 'jump' family of bash functions
#Essential jump code
export MARKPATH=$HOME/.marks
#jump to a directory
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
#mark the current directory as a jump destination
function mark {
mnemnion /
Created Jul 16, 2016
Simple Bash functions: file -> .file, and .file -> file
#lazyfuncs for dotting and undotting stuff
function dt {
for file in "$@"; do
if [[ ${file:0:1} != "." ]]
then mv $file ".$file"
else echo "$file is already dotted"
View hello.go
package main
import "fmt"
import ""
type pegger peg.Peg {
func main() {
mnemnion / nilortwelve.lua
Created Dec 4, 2014
Inconsistent behavior between Lua 5.1 and LuaJit
View nilortwelve.lua
function advise (adviceFn, ogFn)
return function (...) adviceFn(unpack(arg)) ogFn(unpack(arg)) end
function foo (x)
print ("foo")
print (x)
You can’t perform that action at this time.