Skip to content

Instantly share code, notes, and snippets.

import scala.collection.mutable.ListBuffer
class Ummutable[T] private (buf: ListBuffer[T]) {
def this(xs: T*) = this(ListBuffer() ++= xs)
def append(ys: T*): this.type = { buf ++= ys ; this }
final val xs: List[T] = buf.toIterable match { case xs: List[T] => xs }
override def toString = s"Ummutable(xs = ${xs mkString ", "})"
}
@fiadliel
fiadliel / ZipReader.scala
Created August 30, 2015 23:23
Reading Zip files with scalaz-stream
import java.io.{File, FileNotFoundException, IOException, InputStream}
import java.util.zip.{ZipEntry, ZipException, ZipFile}
import org.http4s.DateTime
import scodec.bits.ByteVector
import scalaz._
import scalaz.Scalaz._
import scalaz.concurrent.Task
autoCompilerPlugins := true
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % "2.9.1")
scalacOptions += "-P:continuations:enable"
@persson
persson / tmuxed_pipelines.sh
Created October 4, 2011 04:28
tmux script to create single local tmux session attached to many remote tmux sessions
#!/bin/sh
#Yes, there is no six
hosts=(pipe1 pipe2 pipe3 pipe4 pipe5 pipe7 pipe8 pipe9)
names=(pipe1 pipe2 pipe3 pipe4 pipe5 pipe7 pipe8 pipe9)
sessions=(1 2 3 4 5 7 8 9)
tmux new-session -d -s pipelines
i=0
@ryanlecompte
ryanlecompte / gist:5537188
Last active December 17, 2015 02:38
Pimping Iterable to have zipMany/unzipMany operations
// Usage examples:
val a = Vector(1,2,3).zipMany(Vector(1,2,3), Vector(5,6,7), Vector(8,9,10), Vector(11,12,13))
Vector(Vector(1, 1, 5, 8, 11), Vector(2, 2, 6, 9, 12), Vector(3, 3, 7, 10, 13))
a.unzipMany
Vector(Vector(1, 2, 3), Vector(1, 2, 3), Vector(5, 6, 7), Vector(8, 9, 10), Vector(11, 12, 13))
// Implementation
import scala.collection._
import scala.collection.generic.CanBuildFrom

@aredridel

Thought of the moment: I never use === in javascript. I find that every time I need it, I've made a boneheaded design flaw elsewhere.

‏@chris__martin

@aredridel === is a promise to the maintainer who comes after you that you knew what you were doing.

‏@aredridel

@5outh
5outh / events.hs
Created May 3, 2016 22:14
Event System in Haskell
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Monad.State
import Data.Text
import Data.Monoid
import qualified Data.Map as M
import Control.Monad

Step one

curl https://nixos.org/nix/install | sh

Step two

Add the following lines to the end of ~/.zshrc:

source $HOME/.nix-profile/etc/profile.d/nix.sh

@TomasMikula
TomasMikula / Lazy.scala
Created November 26, 2013 01:14
lazily { expr }: Scala lazy vals that can be checked for having been evaluated. It is adapted from this StackOverflow answer: http://stackoverflow.com/a/17057490/1572599
import scala.language.implicitConversions
object Lazy {
def lazily[A](f: => A): Lazy[A] = new Lazy(f)
implicit def evalLazy[A](l: Lazy[A]): A = l()
}

Haskell projects with lots of dependencies on Travis CI

If your Haskell project has lots of dependencies, you can find yourself reaching the timeout while compiling them - the free service has a timeout of 50 minutes. How do we address this?

First, a quick reminder of build statuses in Travis CI:

All builds finish with one of four possible statuses: succeeded, failed, errored, or (manually) cancelled. The difference between a failed and errored