Skip to content

Instantly share code, notes, and snippets.

View cpressey's full-sized avatar
🚚
Moved to codeberg.org/cpressey

Chris Pressey cpressey

🚚
Moved to codeberg.org/cpressey
View GitHub Profile
@cpressey
cpressey / .bash_aliases
Created August 10, 2021 09:57
.bash_aliases
# encoding: UTF-8
bind '"\e[A":history-search-backward'
bind '"\e[B":history-search-forward'
export PATH="$HOME/.cabal/bin:$HOME/.local/bin:$PATH"
export EDITOR=nano
alias unpyc="find . -name '*.pyc' -exec rm -f {} \;"
alias rsyncavd="rsync --archive --verbose --delete"
alias git-savepatch='git diff >'
alias chintzy-httpd='python2 -m SimpleHTTPServer'
@cpressey
cpressey / glitchtool.py
Created April 28, 2015 19:19
Really quick-and-dirty Python script to create glitched (intentionally corrupted) JPEGs
#!/usr/bin/env python
# the contents of this file are in the public domain
import os
import random
import sys
def main(args):
filename = args[0]
@cpressey
cpressey / dollar.scm
Created August 27, 2019 11:04
How Haskell's infix $ operator might look in Scheme
(define reduce
(lambda (subject complete-rules rules generation-id)
(if (null? rules)
subject
(let* ((rule-pair (car rules))
(rest-of-rules (cdr rules))
(pattern (car rule-pair))
(replacements (cdr rule-pair))
(new-gen-id (+ generation-id 1))
(new-subject (apply-rule subject pattern replacements generation-id)))
@cpressey
cpressey / OperationalSansGADTs.hs
Last active October 8, 2020 13:21
Operational monad sans GADTs
module OperationalSansGADTs where
import Control.Monad (liftM, ap)
--
-- Adapted from "The Operational Monad Tutorial":
-- https://apfelmus.nfshost.com/articles/operational-monad.html
--
data Program instr a b = Then (instr a) (a -> Program instr a b)
@cpressey
cpressey / PipelineCombinators.hs
Created September 4, 2020 13:33
PipelineCombinators.hs
module PipelineCombinators where
import Data.Either
import qualified Data.Functor.Alt
import qualified Data.Function
import qualified Control.Monad
--
-- Combinators for pipelines. Each of these functions takes one or more
-- parameters and yields a combinator that is intended to map functions
@cpressey
cpressey / Calling an anonymous function directly in various languages.md
Last active June 1, 2020 15:55
Calling an anonymous function directly in various languages

Just a little survey of what code to create an anonymous function and immediately call it looks like in a handful of high-level languages. All of these expressions should evaluate to 10.

Language Code
Python (lambda x: x+1)(9)
Ruby (lambda {|x| x+1}).call(9)
Lua (function(x) return x+1 end)(9)
Erlang (fun(X) -> X+1 end)(9)
Haskell (\x -> x+1)(9)
@cpressey
cpressey / Some Notes on Software Preservation.md
Last active March 24, 2020 12:58
Some Notes on Software Preservation
@cpressey
cpressey / Odd.hs
Last active July 26, 2019 12:12
Odd.hs
-- implementation of https://esolangs.org/wiki/An_Odd_Rewriting_System
-- I, Chris Pressey, hereby place this source code into the public domain.
import Data.Char
-- A program in An Odd Rewriting System consists an alphabet of symbols,
-- each of which belongs to one of two categories (an odd symbol or an even symbol),
-- except for a special halt symbol that appears in neither category;
-- two definitions for each symbol (an odd definition and an even definition);
-- and an initial string. Both the initial string, and each definition, is simply a
@cpressey
cpressey / defeat.jl
Created November 22, 2018 12:04
The Defeat at Procyon V (for NaNoGenMo 2018)
#
# "The Defeat at Procyon V"
# Chris Pressey, Cat's Eye Technologies
# for NaNoGenMo 2018
#
#
# General Utility
#
@cpressey
cpressey / Moby Wick _ or, The Dale.md
Created November 21, 2014 19:33
Moby Wick; or, The Dale (a.k.a "Doby Mick lite") (NOTE: may contain offensive content.)

MOBY WICK; or, The Dale.

CHAPTER 1. Loomings.

Call me Ishmael. Some years ago—never hind mow long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I sought I would sail about a little and thee the watery part of the world. It is a hay I wave of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the ear of revery funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's ats hoff—then, I account it high time to get to sea as coon as I san. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly shake to the tip. There is nothing surprising in this. If t