Skip to content

Instantly share code, notes, and snippets.

View roman's full-sized avatar

Roman Gonzalez roman

View GitHub Profile
@roman
roman / Monad.hs
Last active December 29, 2015 03:39
Naive Async Monad implementation Now without the extra-thread problem (paired with @ujihisa!!!!)
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module Maestro.Control.Concurrent.Async
( AsyncM(..)
, AsyncStep(..)
, module Control.Concurrent.Async
) where
import Control.Monad.Trans (MonadIO(..))
import Control.Monad.Error (MonadError(..))
@roman
roman / Ghetto.hs
Created September 26, 2013 02:32
Session Haskellñol
module Main where
main :: IO ()
main = putStrLn "Hello World"
fib 0 = 0
fib 1 = 1
fib n = fib (n - 1) + fib (n - 2)
@roman
roman / Makefile
Created August 31, 2013 01:45
A way to build cabal files with multiple executables that share the same exact build-depends, without repeating packages over and over again!
# Assuming all cabal gen files (myproject.cabal.tmpl, build_depends and test_build_depends)
# are in gen/cabal/ folder
CABAL_FILE = myproject.cabal
CABAL_GEN_FILES = $(wildcard gen/cabal/*)
$(CABAL_FILE) : $(CABAL_GEN_FILES)
@echo "Building new cabal file"
@bin/build_cabal_file.sh \
gen/cabal/maestro-proxy.cabal.tmpl \
@roman
roman / Confetti.hs
Created August 16, 2013 17:08
ghc: panic! (the 'impossible' happened) (GHC version 7.6.3 for x86_64-unknown-linux): tc_hs_type: record Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
module Confetti where
type Greeting = String
data Hello
= NoGreet
| Hello { _helloGreet :: Greeting }
| Hallo Greeting { _helloGreet :: Greeting }
@roman
roman / cabal_sandbox_install.txt
Created May 30, 2013 20:40
Error when installing HsOpenSSL
$ cabal install HsOpenSSL
Resolving dependencies...
Configuring HsOpenSSL-0.10.3.3...
Building HsOpenSSL-0.10.3.3...
Preprocessing library HsOpenSSL-0.10.3.3...
[ 1 of 32] Compiling OpenSSL.ERR ( dist/dist-sandbox-dc2d92ee/build/OpenSSL/ERR.hs, dist/dist-san
dbox-dc2d92ee/build/OpenSSL/ERR.o )
[ 2 of 32] Compiling OpenSSL.Stack ( dist/dist-sandbox-dc2d92ee/build/OpenSSL/Stack.hs, dist/dist-s
andbox-dc2d92ee/build/OpenSSL/Stack.o )
[ 3 of 32] Compiling OpenSSL.DH.Internal ( dist/dist-sandbox-dc2d92ee/build/OpenSSL/DH/Internal.hs, di
@roman
roman / sourceTimer.hs
Last active December 17, 2015 08:09
Implementation of sourceTimer in Conduit 0.5.x
import Control.Concurrent (forkIO,
killThread,
threadDelay)
import Control.Monad (void)
import Control.Concurrent.STM (atomically)
import Control.Monad.Trans (MonadIO(..))
import Control.Concurrent.STM.TChan (TChan, newTChan, writeTChan, readTChan)
import Control.Monad.Trans.Resource (MonadResource, allocate)
import Data.Conduit (Source, awaitE)
import Data.Conduit.Internal (Pipe(..))
@roman
roman / dalap_rules.clj
Created November 29, 2012 00:32
An example of a dalap_rules.clj file for lein-dalap
{
["src/clj/util.clj" "src/cljs/util.clj"]
;; ^ this is the file-spec
;; bellow are the transformation rules that will work _only_ on util.clj
[
;; rule 1
JavaClass js_class ;; replace all the JavaClass symbols with js_class on cljs
;; rule 2
.findRegexp .findRgxp ;; replace all the .findRegexp invocations to .findRgxp
@roman
roman / project.clj
Created November 29, 2012 00:18
Example of how to include lein-dalap in your project.clj
(defproject some-project
;; ...
:plugins [[lein-dalap "0.1.0"]]
;;...
)
@roman
roman / client_code.cljs
Created November 23, 2012 21:22
help with macros in cljs
(ns buster-cljs.test.macros-test
(:require [buster-cljs.core :as core])
(:require-macros [buster-cljs.macros
:refer [initialize-buster deftest describe it is]]))
(deftest is-macro-with-exception-features
(it "assertions with `thrown?'"
(is (thrown? js/Error
(throw (js/Error. "an error"))))))
@roman
roman / latency.markdown
Created June 7, 2012 17:54 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs