Skip to content

Instantly share code, notes, and snippets.

View divarvel's full-sized avatar

Clément Delafargue divarvel

View GitHub Profile
data Dependency : String -> Type -> Type
where MkDep : (name: String) -> a -> Dependency name a
DepWrapper : Type -> Type
DepWrapper t = (String ** Dependency _ t)
dep1 : Dependency "toto" Int
> var m = require('minimist')
undefined
> m(["test.js", "23"])
{ _: [ 'test.js', 23 ] }
> m(["test.js", "23"], { "string": ["_"] })
{ _: [ 'test.js', '23' ] }
> m(["test.js", "--option", "23"], { "string": ["_"] })
{ _: [ 'test.js' ], option: 23 }
> m(["test.js", "--option", "23"], { "string": ["_", "option"] })
{ _: [ 'test.js' ], option: '23' }
@divarvel
divarvel / mailjet.js
Created March 13, 2015 16:31
Mailjet API
var mailjet = require('mailjet');
var Promise = require('bluebird');
var _ = require('lodash');
var request = require('request');
var Mailjet = function(key, secret) {
return {
makeRequest: function(endPoint, args, method, creds) {
return new Promise(function(resolve, reject) {
var casper = require("casper").create();
casper.start();
var screenSize = [1024, 768];
var frameCount = 68;
function slideUrl(i) {
return 'http://localhost:9000/slides.html#'+i+'.0'
}
function frameName(i) {
var n = i < 10 ? '0' + i : i;
class A() {
def b(c: C): Unit = ()
}
class C() {
def >>:(a: A): Unit = ()
}
object test {
val a = new A()
@divarvel
divarvel / enums.scala
Created January 23, 2015 22:23
Enums
package models
import scalaz._
import Scalaz._
import anorm._
import org.postgresql.util.PGobject
import org.postgresql.jdbc4.Jdbc4Array
@divarvel
divarvel / Email.scala
Last active August 29, 2015 14:13
Mailjet + Play mailer plugin
import play.api.Play.current
import scala.concurrent.duration._
import play.api.libs.concurrent.Akka
import play.api.libs.concurrent.Execution.Implicits._
import play.api.Logger
import play.api.libs.mailer._
object email {
val senderAddress = ("name", "email@example.com")
just value = Cont ($ value)
nothing def = Cont (const def)
result = do
x <- just 5
just (x + 5)
result' = do
x <- nothing(0)
just (x + 5)
@divarvel
divarvel / continuation.js
Last active May 27, 2023 08:12
implementation of the continuation monad in JS
console.log("\033[39mRunning tests…");
function assertEquals(actual, expected, description) {
if(typeof actual === "undefined") {
console.error("\033[31m" + description + " not implemented\033[39m");
} else {
if(actual !== expected) {
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m");
} else {
console.log(description + " \033[32m ok\033[39m");
}
@divarvel
divarvel / continuation.js
Last active May 11, 2018 08:57
Continuation monad in JS. just run $ node continuation.js
console.log("\033[39mRunning tests…");
function assertEquals(actual, expected, description) {
if(typeof(actual) === "undefined") {
console.error("\033[31m" + description + " not implemented\033[39m");
} else {
if(actual !== expected) {
console.error("\033[31m" + description + " failed, expected " + expected + ", got " + actual + "\033[39m");
} else {
console.log(description + " \033[32m ok\033[39m");
}