Skip to content

Instantly share code, notes, and snippets.

-- https://gist.github.com/pufuwozu/5550437
import Prelude hiding ((.), id)
import Control.Arrow
import Control.Category
import Data.Monoid
{-
class Monoid m where
mappend :: m -> m -> m
mempty :: m
@cheecheeo
cheecheeo / use_git_rebase.md
Last active December 17, 2015 15:19
Use git rebase
@cheecheeo
cheecheeo / bible_cranium.txt
Last active December 19, 2015 17:48
Bible cranium
act - person - Jesus
act - person - Moses
act - person - Zaccheus
act - person - David
act - person - Goliath
act - person - Adam
act - person - Eve
act - verb - forgive
act - verb - resurrection
@cheecheeo
cheecheeo / gist:6472795
Last active December 22, 2015 12:29
HOWTO gif

Make a bunch of gifs from the video (scaled appropriately)

ffmpeg -i <movie_file> -vf scale=iw/2:ih/2 /tmp/<fun_name>%03d.gif

Animate all those gifs

convert -delay 4 -loop 0 /tmp/*.gif /tmp/animated_.gif
@cheecheeo
cheecheeo / LocalMinima.hs
Created November 22, 2013 01:10
local minimums
module LocalMinima where
import Control.Applicative
minima :: Maybe Int -> Maybe Int -> Int -> (Maybe Int, Maybe Int, Maybe Bool)
minima ma mb c =
(mb, Just c, (&&) <$> ((>) <$> ma <*> mb) <*> ((<) <$> mb <*> Just c))
minimums = foldl (\(prevprev, prev, acc) cur ->
case minima prevprev prev cur of
@cheecheeo
cheecheeo / MonoidFun.hs
Created November 26, 2013 03:37
Somebody said that lists are the "free monoid" in Haskell
module MonoidFun where
-----------------------------------------------------------------------------
-- |
-- Inspirition from: http://stackoverflow.com/a/13357359/1019205 lists are
-- the "free monoid" and http://hackage.haskell.org/package/newtype
import Data.Monoid
import Data.Foldable
import Control.Newtype
@cheecheeo
cheecheeo / HtmlParsing.scala
Last active December 30, 2015 07:49
Easy parsing html as xml in scala
// run like so: cat /tmp/HtmlParsing.scala | scala -cp /home/jchee/.m2/repository/org/ccil/cowan/tagsoup/tagsoup/1.2.1/tagsoup-1.2.1.jar
import java.net.URI
import org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl
import scala.xml.XML
val loader = XML.withSAXParser(new SAXFactoryImpl().newSAXParser())
val elem = loader.load(URI.create("http://www.x.org").toURL)
(elem \\ "span" \\ "@class").distinct.length
@cheecheeo
cheecheeo / setup.sh
Created January 10, 2014 21:53
New computer setup
# Terminal colors
# https://github.com/sigurdga/gnome-terminal-colors-solarized
module Compositions where
import Prelude hiding (id, (.))
import Data.Foldable (Foldable)
import qualified Data.Foldable as F
import Control.Category
import Control.Arrow
import Control.Applicative (Applicative, (<*>), pure)
-- | @compositions fs@ composes all @fs@ together
@cheecheeo
cheecheeo / go.sh
Last active August 29, 2015 13:57
Thrift Haskell testing
#!/bin/bash -x
cabal sandbox hc-pkg unregister thrift
rm -rf ./tutorial/hs/dist/ ./tutorial/gen-hs &&
cabal sandbox init &&
pushd lib/hs &&
ln -sf ../../.cabal-sandbox . &&
ln -sf ../../cabal.sandbox.config . &&
popd &&