Skip to content

Instantly share code, notes, and snippets.

View betehess's full-sized avatar

Alexandre Bertails betehess

View GitHub Profile
@pchiusano
pchiusano / LinkedMap.scala
Created November 12, 2015 16:33
Simple purely functional map that efficiently tracks insertion order
/**
* A Map which tracks the insertion order of entries, so that entries may be
* traversed in the order they were inserted. Uses just two purely functional
* maps.
*/
import scala.collection.immutable.LongMap
class LinkedMap[K,V](
entries: Map[K,(V,Long)],
#!/bin/bash
# This script is the reference implementation of how to start the
# ENSIME server given an ENSIME config file, bootstrapping via sbt[1].
# It is not intended to be portable across operating systems, or
# efficient at caching the results of previous invocations.
# Typically it is best to take the basic concepts of this script and
# to port it to the natural language of the extensible editor that
# intends to support ENSIME.
@timperrett
timperrett / unfiltered-webjars.md
Created April 29, 2015 20:01
Using WebJars with Scala Unfiltered

Add the relevant webjars to your build file:

  libraryDependencies += "org.webjars.bower" % "angular" % "1.3.15"

Add the resources to your server definition:

unfiltered.netty.Server
@djspiewak
djspiewak / streams-tutorial.md
Created March 22, 2015 19:55
Introduction to scalaz-stream

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

@milessabin
milessabin / gist:c51b6851548dae403abf
Created May 9, 2014 10:11
Type safe selectDynamic without macros
miles@frege:~$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_55).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scala.language.dynamics
import scala.language.dynamics
scala> case class Assoc[K, V](value: V)
defined class Assoc
@channingwalton
channingwalton / shapelessy.scala
Last active August 29, 2015 14:00
Replacing boilerplate with shapeless
case class Foo[T](x: T) {
def map[B](f: T => B) = Foo(f(x))
}
object OldWay {
def combineLatest[T1, T2](e1: Foo[T1], e2: Foo[T2]): Foo[(T1, T2)] = Foo((e1.x, e2.x))
def combineLatest[T1, T2, T3](e1: Foo[T1], e2: Foo[T2], e3: Foo[T3]): Foo[(T1, T2, T3)] =
combineLatest(combineLatest(e1, e2), e3) map {
@wsargent
wsargent / genclient
Last active October 23, 2019 18:43
Create a working(!) client certificate for use with nginx, using only keytool
#!/bin/bash
export PW=`pwgen -Bs 10 1`
echo "$PW" > password
# Create a self signed certificate & private key to create a root certificate authority.
keytool -genkeypair -v \
-alias clientCA \
-keystore client.jks \

Hi, looking for scalac flags?

This gist has been upgraded to a blog post here.

@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@syllog1sm
syllog1sm / bootreact
Created January 13, 2014 15:09
Draft proposals for wrapping Bootstrap components with React.js
/** @jsx React.DOM */
'use strict';
// Components wrapping Twitter Bootstrap stuff
//
var BSNames = {
// This isn't exhaustive. Need to think through what should go here. Should
// be exclusive.
bsClass: {'column': 'col', 'button': 'btn', 'btn-group': 'btn-group', 'label': 'label',