Skip to content

Instantly share code, notes, and snippets.

Avatar
:bowtie:
Happily Hacking

Chris Penner ChrisPenner

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

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 Aug 29, 2015
Testing Gist [post]
View other.md

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 Sep 4, 2015
Autoenv + tmux workflow
View .env
#!/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 Feb 15, 2016
"Don't argue" blog post
View new_syntax.py
@supply_args
def main(first, second, keyword=42, *extras):
print first, second, keyword, extras
@ChrisPenner
ChrisPenner / Adjunctions.md
Last active Mar 17, 2017
Exploring Adjunctions
View Adjunctions.md

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 Apr 4, 2017
Copy-pasta commands
View copy
#!/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 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
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