Skip to content

Instantly share code, notes, and snippets.

View eparejatobes's full-sized avatar

Eduardo Pareja Tobes eparejatobes

View GitHub Profile
@fanf
fanf / DependencyInjection.scala
Created July 18, 2013 16:06
Simple, Static Scala dependency injection with Shapeless
package test_shapeless
object DI {
import shapeless._
trait Injecter[L <: HList, A] {
def apply(l: L) : A
}
trait InjecterAux[L <: HList, A] {
@chrisjacob
chrisjacob / README.md
Created March 24, 2011 14:20
QUICK setup Github Pages + Cloud9 IDE for HTML/CSS/JavaScript hacking

QUICK setup Github Pages + Cloud9 IDE for HTML/CSS/JavaScript hacking

GitHub + GitHub Pages

  1. Get a GitHub account: https://github.com/
  2. Github > Dashboard > New Repository ... https://github.com/repositories/new
  3. Enter a Project Name and Description; click "Create Repository"
  4. On the project page ignore the suggested setup instructions... instead click on the "Admin" button
  5. Check the "GitHub Pages" checkbox... You'll get a popup.
  6. Click the "Automatic GitHub page Generator" button.
  7. Choose a funky colour... or go safe with just white... then click "Create Page" button
@smarter
smarter / projection-proposal.md
Created January 5, 2016 12:49
Type projection proposal

NOTE: This is a sketch of the proposal, many details need to be filled out and the scheme hasn't been implemented yet.

G |- T <: S
--------------------
G |- T#L <: S#L

------------------------------
G |- {L: X..Y, ...}#L <: Y
@non
non / cost.md
Last active January 16, 2019 17:12
Basic explanation of the difference between Machinist's macros and value classes.

Introduction

Machinist Issue #2 asks:

Is it correct, that this stuff is completely obsolete now due to value classes or are there still some use cases? An example of using value class for zero-cost implicit enrichment: [...]

The short answer is that Machinist is not obsolete: value classes existed before the Machinist macros were implemented, and they do not solve the

@newlandsvalley
newlandsvalley / index.scala.html
Created March 7, 2016 19:18
Simple integration of elm with the Play Framework (Scala)
@*
* This template takes a single argument, a String containing a
* message to display.
*@
@(message: String)
@main("The Interactive ABC Tutorial", "abc", "Main") {
<h1>The Interactive ABC Tutorial</h1>
@travisbrown
travisbrown / kata-bank-ocr.scala
Created September 21, 2012 18:09
KataBankOCR checksum at the type level
/**
* We can use the Scala type system (with help from Miles Sabin's Shapeless
* library) to solve the bank account number validation problem in the second
* user story of the KataBankOCR kata on Coding Dojo:
*
* http://codingdojo.org/cgi-bin/wiki.pl?KataBankOCR
*
* By Travis Brown in response to a question by Paul Snively on the Shapeless
* Dev mailing list:
*
@milessabin
milessabin / gist:2500326
Created April 26, 2012 15:22
Scala collection extension methods made easy (dependent types FTW!)
/*
* Copyright (c) 2012 Miles Sabin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@non
non / transducers.scala
Created October 30, 2014 00:39
Slightly simpler example of typed transducers in Scala. See http://blog.podsnap.com/ducers2.html for more context.
object Transducer {
type RF[R, A] = (R, A) => R
def apply[A, B](f: A => B) =
new Transducer[B, A] {
def apply[R](rf: RF[R, B]) = (r, a) => rf(r, f(a))
}
}
import Transducer.RF
@knshiro
knshiro / release.sbt
Last active June 1, 2016 22:08
Make sbt-release work with sbt-git versioning.
import sbtrelease._
import ReleaseKeys._
import Utilities._
import ReleaseStateTransformations._
val gitVersionString = """enablePlugins(GitVersioning)
git.baseVersion := "%s""""
def writeVersion(st: State, versionString: String) {
@rmmeans
rmmeans / DynamoJson.scala
Created October 19, 2015 16:29
Play Framework DynamoDB Json
object DynamoReader {
def typeReader[A](f: (JsObject => JsResult[A])) = new Reads[A] {
def reads(json: JsValue): JsResult[A] = json match {
case obj: JsObject => f(obj)
case _ => JsError(Seq(JsPath() -> Seq(ValidationError("error.expected.jsobject"))))
}
}
}
object DynamoString {