Skip to content

Instantly share code, notes, and snippets.

@emiaj
emiaj / curry.ts
Created August 17, 2018 12:44
Curry
declare type Curry<P, V> =
P extends [infer A, infer B, infer C, infer D] ? (a: A) => Curry<[B, C, D], V> :
P extends [infer A, infer B, infer C] ? (a: A) => Curry<[B, C], V> :
P extends [infer A, infer B] ? (a: A) => Curry<[B], V> :
P extends [infer A] ? (a: A) => V :
() => V; // could be unknow, but this allows to safely pass parameterless functions
declare function curry<T extends any[], R>(fn: (...args: T) => R): Curry<T, R>;
// Builders
class SimpleBuilder {
constructor(private current = {}) {
}
prop(key: string, value: any) {
return new SimpleBuilder({ ...this.current, ...{ [key]: value } });
}
@emiaj
emiaj / app.html
Last active May 21, 2016 05:37 — forked from charlespockert/add-suffix.js
Base Aurelia Gist
<template>
<require from="nav-bar.html"></require>
<require from="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></require>
<nav-bar router.bind="router"></nav-bar>
<div class="page-host" style="margin-top:50px">
<router-view></router-view>
</div>
</template>
require.config({
paths: {
'rest': '/webjars/Rest/' + webjars.versions['Rest'],
'when': '/webjars/when-node/' + webjars.versions['when-node']
},
map: {
'rest': {
'when': 'when/when',
'when/lib':'when/lib'
}
server {
access_log /var/logs/nginx/a/access.log;
error_log /var/logs/nginx/a/error.log;
listen 443 ssl;
server_name ServiceA.local.io;
location / {
proxy_pass http://10.0.0.2$request_uri;
}
ENV NGINX_SERVICES_A_ADDRESS 10.0.0.2
ENV NGINX_SERVICES_A_NAME ServiceA
ENV NGINX_SERVICES_A_SHORTNAME a
ENV NGINX_SERVICES_B_ADDRESS 10.0.0.3
ENV NGINX_SERVICES_B_NAME ServiceB
ENV NGINX_SERVICES_B_SHORTNAME b
from busybox
VOLUME /var/shared
RUN touch /var/shared/placeholder
@emiaj
emiaj / Experiments.purs
Last active August 29, 2015 14:05
>> Make failed: >> Error at src/Data/Experiments.purs line 9, column 20: >> Error in module Data.Experiments >> Unknown data constructor 'Directory'
module Data.Experiments where
import Data.Array
import Data.Foldable
import Data.Path
import FileOperations
onlyFiles :: Path -> [Path]
onlyFiles (Directory name paths) = []
onlyFiles _ = []
module Data.Experiments where
import Math
import Data.Array
import Control.MonadPlus
(..) :: Number -> Number -> [Number]
(..) = range
triples :: Number -> [[Number]]
triples n = do
@emiaj
emiaj / index.js
Last active August 29, 2015 14:05
"use strict";
var Prelude = require("Prelude");
var Math = require("Math");
var isEven = function (__copy__36) {
var _36 = __copy__36;
tco: while (true) {
if (_36 === 0) {
return false;
};
if (_36 === 1) {