Skip to content

Instantly share code, notes, and snippets.

Happily Hacking

Chris Penner ChrisPenner

Happily Hacking
View GitHub Profile
ChrisPenner /
Last active Aug 29, 2015
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"

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

ChrisPenner /
Last active Aug 29, 2015
Testing Gist [post]

Testing Gist Rendering

Here's some markdown

  • and a list
  • again more stuff

Here comes code:

lastly some code stuff
ChrisPenner / .env
Last active Sep 4, 2015
Autoenv + tmux workflow
View .env
# Echo the root folder of the current git repo.
echo `git rev-parse --show-toplevel`
# Reconnect tmux session
# Don't attach to tmux if already in tmux
ChrisPenner /
Last active Feb 15, 2016
"Don't argue" blog post
def main(first, second, keyword=42, *extras):
print first, second, keyword, extras
ChrisPenner /
Last active Mar 17, 2017
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 / copy
Last active Apr 4, 2017
Copy-pasta commands
View copy
# Use at your own risk :P
if [ $# -lt 1 ]; then
cat << EOF
usage: copy <files>
exit 1
ChrisPenner / Flux.hs
Created Jun 11, 2017
Fluctuation counting Monoid
View Flux.hs
-- | '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 / CommandRing.hs
Last active Jun 19, 2017
Commands as a Ring
View CommandRing.hs
module CommandRing where
class (Monoid g) => Ring g where
identity :: g
identity = mempty
plus :: g -> g -> g
plus = mappend
invert :: g -> g
View Sequenceable.hs
{-# 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
View FreeForget.hs
{-# language DeriveFunctor #-}
{-# language TypeFamilies #-}
{-# language MultiParamTypeClasses #-}
{-# language FlexibleInstances #-}
module FreeForget where
import Data.Distributive
import Data.Functor.Rep
import Data.Functor.Adjunction