Skip to content

Instantly share code, notes, and snippets.

View yloiseau's full-sized avatar

Yannick Loiseau yloiseau

View GitHub Profile
@yloiseau
yloiseau / curryfails.mkd
Created October 9, 2014 12:55
curryfy fails in decorator
module curry

----
Function to curryfy a diadic function
----
function curry = |f| -> |a| -> |b| -> f(a, b)

@curry
@yloiseau
yloiseau / listings-http-addon.tex
Created September 10, 2014 10:09
Adding HTTP to LaTeX listings package
\lstdefinelanguage{http}{%
morekeywords=[1]{HTTP,%
GET,POST,PUT,HEAD,DELETE,PATCH,OPTIONS,CONNECT,TRACE,%
OK,Precondition,Failed,Not,Modified,Acceptable,%
Created,Found,Accepted,No,Content,Gone,Multiple,Choices,See,Other,Method,Allowed,%
Unsupported,Media,Type,Required%
},%
morekeywords=[2]{%
Accept,Accept-Encoding,Accept-Language,Alternates,%
Content-Type,Content-Language,Content-Encoding,Content-Location,Content-Length,%
@yloiseau
yloiseau / gist:7212fc97a23155a444c5
Created September 1, 2014 17:39
Try on a unit test golo mini framework

the unit test framework itself

module gololang.unittest

struct TestCase = {
  desc,
  verbose,
  failed,
  errors,

improved

module memoizedeco

import java.lang.System

function memoizer = {
  var cache = map[]
  return |fun| {

more functional, generic and dsl-ish version of https://gist.github.com/k33g/1dfb5bf477b7e121422d ;D

module prepostdeco

import java.lang.Math

# Decorator: apply checkers to parameters and result
function checkThat = |preTests...| {
    return |postTest| {
# Decorator
def checkparams(*checkers):
def _deco_(fun):
def _wrapped_(*args):
print("I check {} params".format(fun.__name__))
assert all(f(v) for f,v in zip(checkers, args))
return fun(*args)
return _wrapped_
return _deco_