Skip to content

Instantly share code, notes, and snippets.

View diegopacheco's full-sized avatar

Diego Pacheco diegopacheco

View GitHub Profile
@diegopacheco
diegopacheco / monad.hs
Created March 6, 2012 23:37
Haskell Monad
class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
x >> y = x >>= \_ -> y
fail :: String -> m a
fail msg = error msg
@diegopacheco
diegopacheco / haskell-monad-maybe.hs
Created March 6, 2012 23:41
Monad Maybe Haskell
instance Monad Maybe where
return x = Just x
Nothing >>= f = Nothing
Just x >>= f = f x
fail _ = Nothing
@diegopacheco
diegopacheco / monad-state.hs
Created March 7, 2012 01:41
Haskell Monad state that Works! GHCI 7.0.4 = 2012
import Control.Monad.State
import Control.Monad
data FibState = F {previous, current :: Integer}
fibState0 = F {previous = 1, current = 0}
currentFib :: State FibState Integer
currentFib = gets current
nextFib :: State FibState Integer
@diegopacheco
diegopacheco / times.log.txt
Created March 16, 2012 23:57
Scala Times
PURE JAVA Arch(2.8.7.7) JBoss Boot Up
=======================================
21:49:04,594 INFO [ServerImpl] JBoss (Microcontainer)
[5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 29s:278ms
Scala/JAVA Arch(3.0.0)Jboss Boot UP
====================================
21:39:15,830 INFO [ServerImpl] JBoss (Microcontainer)
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@viktorklang
viktorklang / swingactors.scala
Created April 19, 2012 17:25
Swing Actors using Akka
// ©2012 Viktor Klang
package akka.klang
import akka.dispatch.{ DispatcherPrerequisites, ExecutorServiceFactory, ExecutorServiceConfigurator }
import com.typesafe.config.Config
import java.util.concurrent.{ ExecutorService, AbstractExecutorService, ThreadFactory, TimeUnit }
import java.util.Collections
import javax.swing.SwingUtilities
@jboner
jboner / latency.txt
Last active May 21, 2025 00:32
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@diegopacheco
diegopacheco / Polt.terran.build.sc2.md
Last active December 10, 2015 03:28
cc first / double rax FE

TSL POLT ::

cc first / double rax FE (Emtombed valley / Ohana ER)

10 depo
11 scout
14 2cc expand low ground
15 rax
16 rax