Skip to content

Instantly share code, notes, and snippets.

@jdnavarro
jdnavarro / fedora-nspawn.markdown
Created January 27, 2016 14:19
Bootstrap systemd-nspawn Fedora container from an Arch Linux host

Install yum from AUR

$ yaourt -Sy yum

Add bootstrap repos to /etc/yum.d/boot.repo

[fedora]
name=fedora
baseurl=https://archives.fedoraproject.org/pub/fedora/linux/releases/23/Everything/x86_64/os/
enabled=1
@markus1189
markus1189 / switch.scala
Created January 24, 2016 18:56
Lightswitch
sealed trait Power { type Toggle <: Power }
trait On extends Power { type Toggle = Off }
trait Off extends Power { type Toggle = On }
class LightSwitch[State <: Power] private {
def on(implicit ev: State =:= Off) = new LightSwitch[On]
def off(implicit ev: State =:= On) = new LightSwitch[Off]
def toggle = new LightSwitch[State#Toggle]
}
@shajra
shajra / church.py
Last active December 8, 2015 17:04
Church-encodings in Python
# coding=UTF-8
# Python Goes To Church
# =====================
# What would Python be like if all we had was simple (single argument) lambda
# expressions? We could write some helpful functions like these:
id = lambda a: a
@milessabin
milessabin / tuplegeneric.scala
Last active March 13, 2023 20:27
Convert (small enough) case classes to and from tuples using shapeless ...
import shapeless._
import ops.hlist.Tupler
trait TupleGeneric[C <: Product] extends Serializable {
type Repr <: Product
def to(t : C) : Repr
def from(r : Repr) : C
}
@runarorama
runarorama / gist:87a53916f82c39ce4305
Last active October 4, 2015 20:20
Icelandic place names if they were in Britain
Reykjavík - Reekswich
Þingvellir - Thingweald
Akureyri - Ackerearth
Mývatn - Midgewater
Skaftafell - Shaftfell
Ísafjörður - Icefirth
Vík í Mýrdal - Wick in Miredale
Jökulsárlón - Icemere Loch
Keflavík - Caeflwick
Heimaey - Hamey
@sa7dse
sa7dse / aur4 pre-commit hook
Last active June 24, 2016 15:41
Pre commit hook to sync changes from the PKGBUILD to the .SRCINFO file. For aur4.
#!/bin/sh
# Pre commit hook to sync changes from the PKGBUILD to the .SRCINFO file.
# Depends on: pkgbuild-introspection
if git diff --cached --stat --name-only | grep PKGBUILD 2>&1
then
mksrcinfo
git add .SRCINFO
fi
@maxtaco
maxtaco / ICS_in_ES6.md
Last active November 16, 2016 00:32
IcedCoffeeScript ES6 Implementation

ES6 IcedCoffeeScript Implementation

It's been a real challenge to continuously merge my IcedCoffeeScript branch with the CoffeeScript mainline. The more progress Jeremy and the team make in master, the harder a time I have in the branch. The core issue here is the the iced transform is quite deep. It's doing a CPS translation of the entire abstract syntax tree, rendering the emitted code all but unrecognizable if iced features are at play.

Whenever ES6 is ready for primetime, yield and generators can do all of this heavy lifting, meaning the ICS patch can much simpler. Here's an example that I hand-coded. The input is the first file input.iced, which does basic ICS loops and if/else control flow exercises. The hypothetical output

@xuwei-k
xuwei-k / Scataz.md
Last active December 28, 2015 00:40
Scalaz Cats
Cobind CoflatMap
Bind FlatMap
MonadPlus MonadCombine
PlusEmpty MonoidK
Foldable1 Reducible
Plus SemigroupK
These Ior
Validation Validated
@tobert
tobert / 0000README.md
Last active January 31, 2022 15:22
G1GC / CMS

G1GC v.s. CMS for Cassandra 2.0

Many people have asked me about using the G1 garbage collector with Cassandra. Since most of my customers are running 2.0 in production the test is with 2.0 for now. Once I script it up I'll re-run the numbers with 2.1.

I also need to re-test with Java 7 and the Oracle JDKs.

TL;DR

@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