Skip to content

Instantly share code, notes, and snippets.

package org.photon.login
import com.twitter.util.Future
import org.photon.common.Async
import java.sql.{PreparedStatement, Timestamp, ResultSet}
import org.joda.time.Instant
trait RepositoryComponentImpl[T, RepoT] {
implicit def timestamp2instant(t: java.sql.Timestamp) = new Instant(t.getTime)
implicit def instant2timestamp(i: org.joda.time.Instant) = new Timestamp(i.getMillis)
@vendethiel
vendethiel / do.sjs
Last active January 2, 2016 01:29 — forked from puffnfresh/do.sjs
do.sjs fixed for new sweet.js
macro $do {
rule { { $y:expr } } => {
$y
}
rule { { $x:ident <- $y:expr $rest ... } } => {
λ['>=']($y, function($x) {
return $do { $rest ... }
});
}
}
@vendethiel
vendethiel / scheme.sjs
Last active January 2, 2016 01:29 — forked from disnet/scheme.sjs
scheme.sjs (forked from https://gist.github.com/disnet/3854258)
macro sexp {
rule {()} => {
;
}
rule {($p)} => {
$p
}
rule {($x $y)} => {
$x($y);
}
@vendethiel
vendethiel / do.sjs
Last active January 2, 2016 01:29 — forked from int3/gist:4013740
coffee's do, fix for new sweet.js
macro $do {
rule {($($x = $y) (,) ...) $body} => {
(function ($x (,) ...) $body)($y (,) ...)
}
rule {$name ($($x = $y) (,) ...) $body} => {
(function $name ($x (,) ...) $body)($y (,) ...)
}
}
$do (a = 1, b = 2) {
macro to_string {
case $x => { (JSON.stringify({ $x: 0 }).slice(2, -4)) }
}
macro enum {
case [ $val:ident (,) ... ] => {
(function () {
var e = {
$( $val : (to_string $val) ) (,) ...
};
// y-combinator
macro $y {
rule {( $var )} => {
function(){
return function (f){
return f(f)
}(function(f){
return $var(function(x){
return f(f)(x);
})
macro null_helper {
rule {($processed ...) ($rest)} => {
$processed (.) ... . $rest
}
rule {($processed ...) ($rest_head $rest ...)} => {
$processed (.) ... . $rest_head
&& null_helper ($processed ... $rest_head) ($rest ...)
}
}
macro $do {
rule {($($x = $y) (,) ...) $body} => {
(function ($x (,) ...) $body)($y (,) ...)
}
rule {$name ($($x = $y) (,) ...) $body} => {
(function $name ($x (,) ...) $body)($y (,) ...)
}
}
macro $var {
my @a = ('99 bottles', 'take one down', '98 bottles');
for @a {
say "$^a of beer on the wall, $^a of beer.$^b, $^c of beer on the wall.".tc;
}
my @b = ('99 bottles', 'take one down', '98 bottles'), ('98 bottles', 'take one down', '97 bottles');
say @b.perl;
for @b {
say "$^a of beer on the wall, $^a of beer.$^b, $^c of beer on the wall.".tc;
}
@vendethiel
vendethiel / Commentated.scala
Last active May 26, 2020 11:02 — forked from SystemFw/Lib.scala
Shapeless: derive Slick's GetResult for arbitrary case classes
import slick.jdbc.{GetResult, PositionedResult}
import scala.annotation.implicitNotFound
import scala.reflect.runtime.universe.TypeTag
/**
* A type class that allows the user of GenericGetResult to support their own type.
* This is mostly used to support `newtype`s (like wrappers around UUIDs).
*
* A user just has to use the helper to make the type known to GenericGetResult.