Skip to content

Instantly share code, notes, and snippets.

View shapr's full-sized avatar
🏃
VENTRE À TERRE

Shae Erisson shapr

🏃
VENTRE À TERRE
View GitHub Profile
@shapr
shapr / try.sh
Created February 7, 2021 20:49
param confusion
# for long running commands
function try () {
bloohm "/dev/ttyACM0" Yellow $PWD:A "$*"
time $* && fin || die; # cargo install tally, replacement for time
}
function play_sound () {
aplay -N -q $HOME/.bin/$1.au
}
@shapr
shapr / parsehack.py
Last active February 7, 2021 18:35
parsing bloom filter neopixel set
import time
import board
import busio
import adafruit_trellism4
import adafruit_adxl34x
import supervisor
# Set up Trellis and accelerometer
trellis = adafruit_trellism4.TrellisM4Express(rotation=0)
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
@shapr
shapr / config
Created May 23, 2020 17:09
improve your ssh usage! add these wizardly tricks! add this to ~/.ssh/config !
Host *
ServerAliveInterval 15
ServerAliveCountMax 3
ControlMaster auto
ControlPath ~/.ssh/ssh-%h-%p-%r
ConnectionAttempts 2
ForwardAgent yes
ControlPersist 2m
import time
import board
import busio
import adafruit_trellism4
import adafruit_adxl34x
import supervisor
# Set up Trellis and accelerometer
trellis = adafruit_trellism4.TrellisM4Express(rotation=0)
i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA)
@shapr
shapr / try.sh
Created February 27, 2020 15:20
my try command wrapper, updated for mac
# for long running commands
function try () {
tally $* && fin || die; # cargo install tally, replacement for time
}
function play_sound () {
afplay $HOME/.bin/$1.wav
}
function notify_success() {
@shapr
shapr / WordCount.lhs
Created January 11, 2020 18:35
Word Count program for a programming languages class
\documentclass{article}
\usepackage[margin=1.5in]{geometry}
\usepackage{fancyhdr}
%include lhs2TeX.fmt
%include lhs2TeX.sty
\pagestyle{fancy}
\lhead{\footnotesize November 1 2012}
\rhead{\footnotesize CS410W -- Word Frequency Count in Haskell -- Shae Erisson}
\begin{document}
\section*{Word frequency count in Haskell}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module Main where
import Data.ByteString.Lazy.Char8 (ByteString)
all the fio commands from https://askubuntu.com/a/991311/2598
with one of two drives in my laptop:
samsung 970 pro
READ: bw=3295MiB/s (3455MB/s), 3295MiB/s-3295MiB/s (3455MB/s-3455MB/s), io=10.0GiB (10.7GB), run=3108-3108msec
WRITE: bw=2530MiB/s (2653MB/s), 2530MiB/s-2530MiB/s (2653MB/s-2653MB/s), io=10.0GiB (10.7GB), run=4048-4048msec
READ: bw=55.3MiB/s (57.9MB/s), 55.3MiB/s-55.3MiB/s (57.9MB/s-57.9MB/s), io=3316MiB (3477MB), run=60001-60001msec
READ: bw=624KiB/s (639kB/s), 624KiB/s-624KiB/s (639kB/s-639kB/s), io=36.6MiB (38.4MB), run=60004-60004msec
WRITE: bw=624KiB/s (639kB/s), 624KiB/s-624KiB/s (639kB/s-639kB/s), io=36.5MiB (38.3MB), run=60004-60004msec
samsung 970 evo plus
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main where
import Data.Aeson
import qualified Data.ByteString.Lazy as BSL
import qualified Data.Text as T
main :: IO ()
-- | given a directory for a paper, read that json file into a Paper value
readPaper :: FilePath -> IO (Maybe Paper)
readPaper fp = do
f <- findPaper fp "paper.json"
let f' = listToMaybe f
bs <- mapM BS.readFile f' -- XXX this gonna be a problem at some point XXX
mapM decodeStrict bs -- is this right? do I need this pure? can I concat it with the previous line?