Skip to content

Instantly share code, notes, and snippets.

@blippy
blippy / test
Created October 26, 2014 21:42
test
what does this do, exaclty?
# fuzsli.py
# use python 3 so that floats are used
#####################################
### INTERNAL DEFINITIONS AND SETUP
from pprint import pprint
@blippy
blippy / gist:cdf0e2972c3f73538a3e
Created November 24, 2014 15:01
ipython graphical startup
%matplotlib inline
import matplotlib.pyplot as plt
import pylab
import numpy
@blippy
blippy / test
Created December 6, 2014 14:31
foo
bar
@blippy
blippy / mymonad.hs
Created October 14, 2015 12:20
Re-implementation of Haskell's Maybe monad
-- Maybe Just Nothing
data Smurf a = Foo a | Bar deriving (Eq, Ord, Show)
-- fmap :: Functor f => (a -> b) -> f a -> f b
instance Functor Smurf where
fmap f (Foo x) = Foo (f x)
fmap f Bar = Bar
-- fmap (+ 2) (Foo 10) => Foo 12
-- fmap (+ 2) Bar => Bar
@blippy
blippy / test.lhs
Last active October 15, 2015 12:53
Testing Haskell literate code
In Bird-style you have to leave a blank before the code.
> fact :: Integer -> Integer
> fact 0 = 1
> fact n = n * fact (n-1)
And you have to leave a blank line after the code as well.
Lorem ipsum dolor sit amet, ea per vitae mentitum, mei ne latine vocibus docendi. Te vim odio dolore, nec facete vocibus ex, in aeque alienum eum. In vel saepe nostrud. Hendrerit suscipiantur in vel, ex adhuc aliquam vocibus pro. Eu zril civibus mei.
@blippy
blippy / egeither.lhs
Last active October 15, 2015 13:32
Exploring Haskell monads using Either
Exploring Haskell monads using Either
Stephan Boyer explained it well why you would want to use monads:
http://www.stephanboyer.com/post/9/monads-part-1-a-design-pattern
"In each example, we had some functions which we wanted to compose,
but their type signatures were incompatible. Our functions took a
value of some type and returned a value in the corresponding monadic
type."
@blippy
blippy / allun.png
Created October 31, 2015 19:13
scp tv
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA54AAAIsCAYAAACa+nYtAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3woeEwoRW/XpBgAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUHAAAgAElEQVR42uy9W5OkyXEldtwjvszqnmsPhuAAWJAEl+CCFxMlGU3L5er6sra7WpleZLb6xTLTgyTTix5oRhMpYEFiMJx7d1XmF+GuB/e4fHmpyqyu6q7qCjdrYPpSmd8lwsP9+PHjwLBhw4YNGzZs2LBhw4YNGzZs2LBhw4YNGzZs2LBhw4Y9VqPyH8/ef6HjcTxWk2teL43H86RM/ddYC8PGWhg21sSwsRaG3XYtjPUw1sTdrYXL778iAODxcIcNGzZs2LBhw4YNGzZs2H3aSDyHDRs2bNiwYcOGDRs2bNhIPIcNGzZs2LBhw4YNGzZs2Eg8hw0bNmzYsGHDhg0bNmzYsJF4Dhs2bNiwYcOGDRs2bNiwN2/xyT+BQyJN1wl8DRs2bNiwYePsXJ6dD+HcLNd0yrWc82+HjVhq2LDX2RNjL1QbFc9hw4YNGzZs2PlB1XW/fwjXdFf/dtj9v49hw8ZeeBI2Kp4DhRg2bNiwYcPOM3nk1yTjFY5YatiwsSfetI2K57Bhw4YNGzZs2LBhw4YNG4nnsGHDhg0bNmzYsGHDhg17vNZRbQWHu8PfdTtUCx/P4Wk/i0PP5ak+h6d+/8Nu9hHA08Qw5YnvC3mAZ0W/Rq+7Hnnia/cprYlhI5Ycz+GBJp7YcdgP4aXhxOvRO75mfUcXxm3e70NZE6dcx11eqx5Yh4/B6MTr1hP3lT7QPXHq9dzFdes1z/ld8gun7q/H6tvuwj/oA/WPb3PNPOVn8a77hsfuH8699rs+K0Yc+WBjSaIjirPvavz/ts/do4nnQ0w0Trmp+7jmd23x6ZnJ/EN6Fqdc++
@blippy
blippy / scp.txt
Created November 11, 2015 14:43
SCP: Do not adjust your set (2015-11-11)
[[tabview]]
[[tab Set]]
[[>]]
[[module Rate]]
[[/>]]
[[include component:image-block
name=https://pbs.twimg.com/media/CSqxueMWUAEuHbK.png|
caption=SCP-XXXX in operation
@blippy
blippy / frequency.hs
Created November 11, 2015 21:08
Count the number of alphabetical characters in a file
import Data.Array
import Data.Char
outputs text =
let arr = accumArray (+) 0 (0, 255) $ map (\c -> (ord c, 1)) text
hits = filter (\(c, qty) -> (isAlpha $ chr c) && (qty > 0) ) $ assocs arr
in
map (\(c, qty) -> [chr c] ++ " (" ++ (show qty) ++")") hits
main = do