Skip to content

Instantly share code, notes, and snippets.

@munro
munro / foo.js
Created September 19, 2015 19:34
webpack_config.entry.unshift(
'webpack-dev-server/client?' + argv.root_url,
'webpack/hot/dev-server'
);
webpack_config.plugins.unshift(
new webpack.HotModuleReplacementPlugin()
);
webpack_config.devtool = '#source-map';
webpack_config.pathInfo = true;
@munro
munro / app.js
Created September 17, 2015 07:36
var config = require('./config');
{-|
>>> uriToFTPPort <$> parseURI "ftp://foo:[email protected]:50021/hello"
Just 50021
>>> uriToFTPPort <$> parseURI "ftp://foo:[email protected]/hello"
Just 21
>>> uriToFTPPort <$> parseURI "ftp://192.168.1.11/hello"
Just 21
-}
uriToFTPPort :: Num a => URI -> a
uriToFTPPort uri = port maybePort
-- |
-- >>> runNetworkOverTCP testNetwork
-- "hello"
-- >>> runNetworkOverHTTP testNetwork
-- "hello"
-- >>> runNetworkInMemory testNetwork
-- "hello"
testNetwork = do
userA <- createConnection
userB <- createConnection
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE GADTs #-}
module Main where
import Control.Concurrent
import Control.Concurrent.STM
#!/usr/bin/env python
from logentries import LogentriesHandler
import logging
import time
handler = LogentriesHandler(LOGENTRIES_TOKEN)
log = logging.getLogger('logentries')
log.addHandler(handler)
@munro
munro / MyState.hs
Last active August 29, 2015 14:20
Monads with no built in functions or type classes
module MyState where
import Control.Monad.State.Lazy
data MyState s a = MyState { state :: s, carry :: a } deriving Show
data MyMonadState s a = MyMonadState (s -> (MyState s a))
myGet :: MyMonadState s s
myGet = MyMonadState (\s -> (MyState s s))
@property
@memoize
def db_connection():
return DBConnection()
In [3]: def foo(): yield 1; yield 2; return
In [4]: def foo(): yield 1; yield 2; return 3
File "<ipython-input-4-e56b14727cad>", line 1
def foo(): yield 1; yield 2; return 3
SyntaxError: 'return' with argument inside generator
/* build recursive category */
create table category (
id uuid primary key default uuid_generate_v4(),
name text not null,
parent uuid,
foreign key (parent) references category(id)
);
insert into category values (default, 'food', null);
insert into category values (default, 'snacks', (select id from category where name = 'food'));