Skip to content

Instantly share code, notes, and snippets.

Gabriele Petronella gabro

Block or report user

Report or block gabro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View sublime.tex
\title{LaTeX is now Sublime}
\author{Gabriele Petronella}
\section{My first section}
gabro / main.tex
Created Dec 7, 2012
An example of a multi-part LaTeX document
View main.tex
\title{A long document}
\author{Gabriele Petronella}
gabro / gist:4322163
Created Dec 17, 2012
A parametric algebraic data type in Haskell
View gist:4322163
data UnionFindElement valueType =
RootElement valueType |
ElementWithParent valueType (UnionFindElement valueType)
deriving (Eq, Show)
gabro / Money Chicago
Last active Dec 11, 2015
Money Chicago
View Money Chicago
var money =
"@people: luca gio dani gabro claudio jaja mike paolo\n"+
"@group: luca gio dani gabro claudio jaja\n"+
"@date: debiti e payback\n"+
"~Debiti (Dani 52.13 Luca 356.37 Gabro 13.18) claudio 309.88 gio 28.98 jaja 17.25 mike 64.51\n"+
"15 gio -> dani\n"+
"400 claudio -> gabro\n"+
"10 dani -> jaja\n"+
gabro / user.js
Created Feb 27, 2013
View user.js
var userSchema = new Schema(
fb_id : String,
firstName : String,
lastName : String,
messages : [{
content : String,
positive : Boolean,
author : User,
created_at : {type : Date, default :},
updated_at : {type : Date, default :}
gabro / git-working-history
Last active Oct 21, 2019
Github-like working directory history
View git-working-history
FILES=`git ls-tree --name-only HEAD .`
IFS=$(echo -en "\n\b")
for f in $FILES; do
if [ ${#f} -gt $MAXLEN ]; then
View shapeless compilation time exploding
package buildo
import anorm._
import shapeless._
import shapeless.ops.hlist._
import shapeless.record._
import shapeless.syntax.std.traversable._
import shapeless.syntax.singleton._
gabro / gist:b192a7258ec5072bd1e0
Created Sep 12, 2014
Beautiful validation with scalaz. Fail fast in the for-comprehension and fail slow with the application builder
View gist:b192a7258ec5072bd1e0
def editResult(testId: LabOnlineId[Test], worklistId: LabOnlineId[Worklist], result: TestResult): Future[ActionResult] =
for {
test <- ensureExists(testId)(testData.findOne(_))
sample <- ensureExists(test._sampleId)(sampleData.findOneWithWorklist(_, worklistId))
} yield {
(ensureNotClosed(sample, worklistId) |@|
ensureNotClosed(test, worklistId))((_,_)) match {
case Failure(errors) => ActionResult.UserError(errors.toList: _*)
case Success(_) => /* run a stored procedure */ ActionResult.Ok
gabro / A
Created Sep 13, 2014
Var length generator
View A
def gen(n: Int, limit: Int, k: Int = 1): Iterator[List[Int]] = {
val range = (k until limit).iterator
n match {
case _ if n > 0 => for {
x <- range
y <- gen(n - 2, limit, x)
} yield x :: y
case _ =>
gabro / Main.scala
Last active Aug 29, 2015
Automatic get parameters generator from case class for spray routing
View Main.scala
package example
import scala.language.existentials
import shapeless._; import record._; import ops.record._; import ops.hlist._
import spray.routing.SimpleRoutingApp
trait AutoGetParametersModule { self: SimpleRoutingApp =>
import spray.routing.{ Directive, Directive1, Directive0, HListDeserializer }
You can’t perform that action at this time.