Skip to content

Instantly share code, notes, and snippets.

View quelgar's full-sized avatar
🇦🇺

Lachlan O'Dea quelgar

🇦🇺
View GitHub Profile
@pchiusano
pchiusano / buffer.scala
Created August 6, 2014 01:21
Buffer type with purely functional API, using a mutable buffer and cheap copy-on-write scheme
import java.util.concurrent.atomic._
import collection.mutable.ArrayBuffer
/**
* Buffer type with purely functional API, using mutable
* `ArrayBuffer` and cheap copy-on-write scheme.
* Idea described by Bryan O'Sullivan in http://www.serpentine.com/blog/2014/05/31/attoparsec/
*/
class Buffer[A](id: AtomicLong, stamp: Long, values: ArrayBuffer[A], size: Int) {
@mchakravarty
mchakravarty / ylj14-instructions.md
Last active August 29, 2015 14:01
YOW! Lambda Jam 2014 — Foreign Inline Code in Haskell — Instructions for the workshop

Installation instructions

Prerequisites: OS X with the latest Xcode and command line tools installed (or just the command line tools)

(If you haven't got a machine with OS X, please pair up with a participant who has got a Mac at the workshop.)

Install the Haskell Platform (2013.2.0.0, 64 bit): http://www.haskell.org/platform/mac.html (Note the special installation instructions for using the Haskell Platform with Xcode 5.)

Now, that you have got a Haskell system, install language-c-inline, the library implementing inline C code for Haskell.

@etorreborre
etorreborre / md5-stream.scala
Created March 7, 2014 06:22
Computing the MD5 hash of a file and writing it using scalaz-stream
import scalaz.stream.{Process1, Process, io, process1}
import Process._
import java.security._
import scalaz._
import scala.collection.mutable
import java.math.BigInteger
val P = Process
@non
non / gist:4064198
Created November 13, 2012 05:47
Add map + flatMap to Function1-3 with no overhead
object RichF {
implicit class RichF1[A, Z](val f: A => Z) extends AnyVal {
def map[Y](g: Z => Y): A => Y =
(a: A) => g(f(a))
def flatMap[Y](g: Z => A => Y): A => Y =
(a: A) => g(f(a))(a)
}
implicit class RichF2[A, B, Z](val f: (A, B) => Z) extends AnyVal {
def map[Y](g: Z => Y): (A, B) => Y =
@clayzermk1
clayzermk1 / README.md
Created August 10, 2012 19:54
jQuery / Twitter Bootstrap List Tree Plugin

jQuery / Twitter Bootstrap List Tree Plugin

Demo: http://jsfiddle.net/clayzermk1/QD8Hs/

Overview

I needed a simple plugin to build a two-tier collapsible list with checkboxes. I wanted it to fit well with Twitter's Bootstrap. I couldn't find one that was simple enough. I hope you enjoy =) Feel free to send feedback.

@tankchintan
tankchintan / gist:1335220
Last active November 30, 2019 00:17
Procedure for installing and setting Sun JDK Java on Default Amazon Linux AMI
# First verify the version of Java being used is not SunJSK.
java -version
# Get the latest Sun Java SDK from Oracle http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html
wget http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-i586.rpm
# Rename the file downloaded, just to be nice
mv jdk-7u1-linux-i586.rpm\?e\=1320265424\&h\=916f87354faed15fe652d9f76d64c844 jdk-7u1-linux-i586.rpm
# Install Java
@etorreborre
etorreborre / gist:958304
Created May 6, 2011 01:29
A great configuration trick with implicits and default values!
case class Config(name: String="none")
def methodNeedingAConfig(implicit config: Config = Config()) = config.name
// by default there is no config
methodNeedingAConfig === "none"
// just add one in the current scope
implicit val myConfig = Config("some")