Skip to content

Instantly share code, notes, and snippets.

View dam5s's full-sized avatar

Damien LeBerrigaud dam5s

View GitHub Profile
@dam5s
dam5s / Maybe.kt
Last active April 29, 2018 23:31
Union types in Kotlin 1.1 using sealed classes and data classes.
sealed class Maybe<T> {
object Nothing: Maybe()
data class Some<T>(val value: T): Maybe<T>()
}
@dam5s
dam5s / ReadInputStream.java
Created October 5, 2015 19:04
Convert InputStream to String.
public static String read(InputStream inputStream) {
Scanner s = new Scanner(inputStream).useDelimiter("\\A");
return s.hasNext() ? s.next() : "";
}
@dam5s
dam5s / object_creation_methods.rb
Created January 20, 2013 03:33
Object Creation Methods to easily make objects for testing, replacing the magic of Factory Girl and still keeping a nice syntax
module ObjectCreationMethods
# def make_user
# def make_user!
define User do
{
username: 'dam5s',
email: 'dam5s@example.com',
password: 's0m3pwd',
password_confirmation: 's0m3pwd'
}
call pathogen#runtime_append_all_bundles()
set wildmenu
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set smarttab
set autoindent
set nu