Skip to content

Instantly share code, notes, and snippets.

View willtim's full-sized avatar

Tim Williams willtim

  • London
View GitHub Profile
@djspiewak
djspiewak / 0introduction.md
Last active November 28, 2023 15:03
Scala Collections Proposal

Collections Redesign Proposal

I'm going to start off by motivating what I'm doing here. And I want to be clear that I'm not "dissing" the existing collections implementation or anything as unproductively negative as that. It was a really good experiment, it was a huge step forward given what we knew back in 2.8, but now it's time to learn from that experiment and do better. This proposal uses what I believe are the lessons we can learn about what worked, what didn't work, and what is and isn't important about collections in Scala.

This is going to start out sounding really negative and pervasively dismissive, but bear with me! There's a point to all my ranting. I want to be really clear about my motivations for the proposal being the way that it is.

Problems

Generic Interfaces

@paulbdavis
paulbdavis / i3zenburn-colors
Created February 14, 2013 20:55
i3 zenburn colors
# colors
client.focused #688060 #688060 #303030 #ffcfaf
client.focused_inactive #3f3f3f #3F3F3F #7f9f7f #3f3f3f
client.unfocused #3f3f3f #3F3F3F #DCDCCC #3f3f3f
client.urgent #dca3a3 #dca3a3 #DCDCCC #3f3f3f
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
@akshaal
akshaal / macro.scala
Created August 18, 2012 17:59
Scala 2.10: annotated fields macro
/** Akshaal, 2012. http://akshaal.info */
import language.experimental.macros
import scala.reflect.macros.Context
import scala.annotation.Annotation
/**
* Macros for traversing over annotated elements.
*
* See http://www.akshaal.info/2012/08/scala-210-annotated-fields-macro.html for more information.
@jboner
jboner / latency.txt
Last active November 19, 2024 14:58
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
@pchiusano
pchiusano / GADTs.scala
Created November 16, 2011 04:30
GADT support in Scala
/** GADTs in Scala and their limitations */
/** Background: what is an algebraic data type (ADT) ?
* ADT: (possibly) recursive datatype with sums and products
* In scala - a trait with case classes (case class is product, subtyping is sum)
*/
/** Motivation: untyped embedded DSL doesn't prevent nonsensical expressions */
sealed trait Expr {
def apply(other: Expr) = Ap(this, other)
@gertjana
gertjana / mapreduce_akka.scala
Created August 3, 2011 20:45
MapReduce example using Akka Actors
package net.addictivesoftware.scala.akkaactors
import akka.actor.{Actor, PoisonPill}
import Actor._
import akka.routing.{Routing, CyclicIterator}
import Routing._
import collection.mutable.{HashMap, Map}
import java.util.concurrent.CountDownLatch
--
-- Play a song and flash LEDs on alternate notes.
-- Lee Pike <lee pike @ gmail . com> (remove spaces)
-- See http://leepike.wordpress.com/?p=427
-- BSD3 License
--
-- Note timing issues: http://www.arduino.cc/en/Tutorial/PlayMelody
--
module CopilotSing where
@petermarks
petermarks / Rope Intranet benchmark
Created September 5, 2010 21:02
Benchmark of Rope Intranet counting function
-- | This program benchmarks different versions of the counting function for
-- the Rope Intranet problem for Google Code Jam
-- http://code.google.com/codejam/contest/dashboard?c=619102#.
--
-- To compile:
-- >>> ghc -O2 --make bench.hs
--
-- To run (Windows):
-- >>> Bench
anonymous
anonymous / Crossing.hs
Created August 16, 2010 08:10
import Data.List
main = interact $ unlines . map showSolution . zip [1..] . map solve . parseProblems
parseProblems = parse . map (map read . words) . tail . lines
where parse [] = []
parse ([n]:xs) = map (\ [x,y] -> (x,y)) (take n xs) : parse (drop n xs)
showSolution (n, s) = "Case #" ++ show n ++ ": " ++ show s