Skip to content

Instantly share code, notes, and snippets.

View mnemnion's full-sized avatar

Sam Atman mnemnion

  • Eastern Standard Tribe
View GitHub Profile
@mnemnion
mnemnion / jump.sh
Last active July 16, 2016 02:30
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 {
// 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,
};

Keybase proof

I hereby claim:

  • I am mnemnion on github.
  • I am atman (https://keybase.io/atman) on keybase.
  • I have a public key ASAWKn9EMHtlfAZz2a4lbuFStIGWdm56UzfAcl7--TsUwwo

To claim this, I am signing this object:

@mnemnion
mnemnion / git-move.sh
Last active January 28, 2020 14:25
Move files to a different repo with history
#! /bin/bash
# Usage:
# ./git-move.sh path1/ path2/... path/to/destination/repo
args=("$@")
# All but last argument:
paths=("${args[@]::${#args[@]}-1}")
# Last argument:
dest="${args[${#args[@]}-1]}"
@mnemnion
mnemnion / sparse.lua
Last active February 17, 2021 17:55
Sparse multidimensional tables in Lua
local Sparse = {}
local function new(dimension)
local sparse = {}
sparse._dimension = dimension
return setmetatable(sparse, Sparse)
end
function Sparse.__index(sparse, key)
if sparse._dimension == 1 then
@mnemnion
mnemnion / clone-to-trunk.sh
Last active September 8, 2020 17:51
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
mnemnion / curry.lua
Created November 7, 2020 05:16
Simple currying in Lua, partial application
-- 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
mnemnion / git-move.sh
Created August 15, 2022 11:35
Move files from one git repo to another, following renames
#! /bin/bash
# Usage:
# ./git-move.sh path1/ path2/... path/to/destination/repo
args=("$@")
# All but last argument:
paths=("${args[@]::${#args[@]}-1}")
# Last argument:
dest="${args[${#args[@]}-1]}"
@mnemnion
mnemnion / trunk-create-table.svg
Created August 28, 2022 16:45
create-table statement rendered with Pikchr trunk
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mnemnion
mnemnion / class-tags-create-table.svg
Created August 28, 2022 16:47
create-table statement rendered with Pikchr class-tags branch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.