Skip to content

Instantly share code, notes, and snippets.

-- | Parse string
-- >>> parse (parseString) "fail" "\"hello 'world' foobar\""
-- Right (String "hello 'world' foobar")
-- >>> parse (parseString) "fail" "\"hello \\\"world' \n\r \\\\ foobar\""
-- Right (String "hello \"world' \n\r \\ foobar")
parseString :: GenParser Char st Word
parseString = do char '"'
x <- many $ chars
char '"'
return $ String x
@munro
munro / Dockerfile
Last active August 29, 2015 14:04
Docker In Dock
FROM ubuntu:trusty
MAINTAINER Ryan Munro <[email protected]>
RUN apt-get update -qq
RUN apt-get install -qqy apt-transport-https
RUN echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
RUN apt-get update -qq
RUN apt-get install -qqy lxc-docker
import Control.Monad
import Control.Applicative
instance (Applicative f, Num a) => Num (f a) where
-- (+) <$> (return 123) <*> (return 321) now becomes:
-- ((return 123) + (return 321)) -- yipee!
(+) = liftA2 (+)
...
(<<) :: Monad m => m b -> m a -> m b
a << b = do
va <- a
_ <- b
return $ va
<a share="facebook" data-url="http://www.getringer.com/" class="btn btn-primary">Share to Facebook</a>
<span share="facebook" data-url="http://www.getringer.com/">Shares: {{share_count | humanCount}}</a>
fetchDependencies: (version, value) ->
promises = []
for x in version.dependencies
promise = @searchTerm(x.name).then (data) =>
d = _.first(data)
dep_search = _.last(d.versions)
if dep_search.scripts.length > 0
el = document.createElement("script")
el.setAttribute("data-require", value.name + "@*")
el.setAttribute("data-semver", version.semver)
@munro
munro / integerAddition.hs
Created August 22, 2014 20:38
Integer addition in Haskell without built in functions
data MyInteger = Zero MyInteger | One MyInteger | End
-- | Show integer
-- >>> show (One $ One $ Zero $ Zero $ Zero $ End)
-- "11000b"
-- >>> show (End)
-- "b"
instance Show MyInteger where
show (Zero rest) = "0" ++ show rest
show (One rest) = "1" ++ show rest
@munro
munro / integerAddition.rs
Last active August 29, 2015 14:05
Integer addition
use std::fmt;
#[deriving(Clone)]
enum MyInteger {
Zero(Box<MyInteger>),
One(Box<MyInteger>),
End
}
/**
@munro
munro / dom.html
Last active August 29, 2015 14:06
AngularJS Window Title
<html>
<head>
<title ng-bind="window_title"></title>
</head>
</body>
sudo ln -s /usr/bin/docker /usr/bin/donger