Skip to content

Instantly share code, notes, and snippets.

View ChrisPenner's full-sized avatar
:bowtie:
Happily Hacking

Chris Penner ChrisPenner

:bowtie:
Happily Hacking
View GitHub Profile
@ChrisPenner
ChrisPenner / shell-reminders.md
Last active August 29, 2015 14:19
Reminders in Terminal

Throw this at the bottom of your .profile file (or .bashrc). Quick and easy reminders for yourself that are displayed every time you fire up a terminal prompt.

# Sticky-notes:
alias note="vim ~/dotfiles/messages"
alias notes="cat ~/dotfiles/messages"
notes

I usually use this to remind myself of some new Vim commands I'm trying to integrate into my workflow.

@ChrisPenner
ChrisPenner / other.md
Last active August 29, 2015 14:20
Testing Gist [post]

Testing Gist Rendering

Here's some markdown

  • and a list
  • again more stuff

Here comes code:

lastly some code stuff
@ChrisPenner
ChrisPenner / .env
Last active September 4, 2015 18:58
Autoenv + tmux workflow
#!/bin/sh
# Echo the root folder of the current git repo.
gitroot(){
echo `git rev-parse --show-toplevel`
}
# Reconnect tmux session
tmuxproj(){
# Don't attach to tmux if already in tmux
@ChrisPenner
ChrisPenner / new_syntax.py
Last active February 15, 2016 18:53
"Don't argue" blog post
@supply_args
def main(first, second, keyword=42, *extras):
print first, second, keyword, extras
@ChrisPenner
ChrisPenner / Adjunctions.md
Last active March 17, 2017 05:44
Exploring Adjunctions

This might all be old-hat for you, but typing it out helps be understand it better anyways :)

Let's consider two examples as we talk about it, the first being curry/uncurry, the second being the case Hardy mentioned in an earlier episode where he had an adjunction between annotated/highlighted text and non-highlighted text.

Considering two Categories A and B; The definition of an adjunction (at least according to wikipedia) is a pair of Functors; F:A -> B and G:B -> A; so basically a pair of functors which map back and forth between categories. We also need

@ChrisPenner
ChrisPenner / copy
Last active April 4, 2017 20:34
Copy-pasta commands
#!/bin/bash
# Use at your own risk :P
FOLDER="/tmp/copy-pasta"
if [ $# -lt 1 ]; then
cat << EOF
usage: copy <files>
EOF
exit 1
fi
@ChrisPenner
ChrisPenner / Flux.hs
Created June 11, 2017 17:20
Fluctuation counting Monoid
-- | 'Flux' is a monoid which counts the number of times an element changes
-- values (according to its Eq instance)
-- This is useful for gaining associativity (and its associated performance improvements)
-- for tasks where you'd otherwise use `group` or `groupBy`
data Flux a = Flux
-- We keep track of the last value we saw on the left and right sides of the accumulated
-- sequence; `Nothing` is used in the identity case meaning no elements have yet
-- been encountered
{ sides :: Maybe (a, a)
-- We have a counter which increments each time we mappend another Flux who's
@ChrisPenner
ChrisPenner / CommandRing.hs
Last active June 19, 2017 04:23
Commands as a Ring
module CommandRing where
class (Monoid g) => Ring g where
identity :: g
identity = mempty
plus :: g -> g -> g
plus = mappend
invert :: g -> g
{-# language DeriveFunctor #-}
{-# language FlexibleInstances #-}
{-# language FlexibleContexts #-}
module Rasa.Ext.Views.Internal.CoTree where
import Data.List as L
class Monoid g => Group g where
identity :: g
identity = mempty
{-# language DeriveFunctor #-}
{-# language TypeFamilies #-}
{-# language MultiParamTypeClasses #-}
{-# language FlexibleInstances #-}
module FreeForget where
import Data.Distributive
import Data.Functor.Rep
import Data.Functor.Adjunction