Skip to content

Instantly share code, notes, and snippets.

View algesten's full-sized avatar
😀
barcelona!

Martin Algesten algesten

😀
barcelona!
View GitHub Profile
set = (v) -> (f) -> f(v)
get = (f) -> f (v) -> v
t = set(42)
get(t) // 42
@algesten
algesten / gist:60e532d938111e8d4eec
Last active August 29, 2015 14:14
install logstash with lusis/chef-logstash 0.11.2

install logstash with lusis/chef-logstash 0.11.2

My json config file

Notice that java, elasticsearch and rabbitmq are already set up in my system.

{
    "name": "logstash-server",
module.exports = class Bundlr
FORMAT_TTNITF: 'ttnitf'
FORMAT_PICTURE: 'bild' # deliberate to match OFP
FORMAT_TTNINJS: 'ttninjs'
FORMAT_INDESIGN: 'indesign'
FORMAT_CUTPASTE: 'cutpaste' # txt-format in media-moj
FORMAT_TTNITFXML: 'ttnitfxml'
# ofp spec is "ttninf", "ttnintf+bild", "ttinjs" etc
1970-01-01 behandlas som null
versioncreated = datum dokumentet skapas. (sdl fotodatum med tidsdel 00:00)
versionstored = indexeringsdatum. om vi är master, eget annars ta källan (sdl typ)
date = datum dokumentet gäller (t.ex. framtid för planering
eller framtid grafik, men fotodatum för sdl)
if tidsdel för date finns
datetime = samma logik som date men med tidsdel. annars null.
@algesten
algesten / promiseApply.coffee
Last active August 29, 2015 14:26 — forked from scott-christopher/promiseApply.js
Promise applicative example
# Goals
#
# 1. Mix promise and non-promise arguments
# 2. Behaves like a normal function if all arguments are non-promise
# 3. Returns a promise if any non-promise argument
# 4. Use no promise library, rely on the fact that:
# promise.then(-> a1).then((a2) -> a1 === a2)
# promise.then(-> Promise(a1)).then((a2) -> a1 === a2)
#
@algesten
algesten / body_html5-spec.md
Last active September 11, 2015 13:39
body_html5-spec

body_html5 spec 1.2

This is a "loose" spec for the body_html5 part of [ttninjs][ttninjs].

Revision history

  • 1.3 Clarify html-doc structure
  • 1.2 alt-attribute in ``, div.byline before `figcaption` (to be html5-valid)
@algesten
algesten / plift-pseq.md
Last active September 18, 2015 18:25
plift and ppipe example

Implemented in https://github.com/algesten/fnuc/blob/master/src/fnuc.coffee#L202

Case for plift

This example shows how plift can help to treat functions dealing with promises as regular functions.

N.B. This code is a "handler" it is not intended to be side effect free.

  • userToDevices is a function looking up devices from a user id in a database. It returns a promise for the result.
@algesten
algesten / Procfile
Created January 31, 2012 13:52
heroku static hosting with node.js
web: node web.js
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("")
base = alphabet.length
exports.encode = (i) ->
return alphabet[0] if i is 0
s = ""
while i > 0
s += alphabet[i % base]
i = parseInt(i / base, 10)
@algesten
algesten / gist:5874476
Created June 27, 2013 06:55
Similarity that disregards the length of the field.
private final static Similarity NO_LENGTH_SIMILARITY = new DefaultSimilarity() {
// we are interested in length norm for the street number field.
// it's good if 10 is sorted before 10a and 10b.
//
// the "country" field is very important it has no document boost since that means
// simply turning Query.setCountry() on will make a different score. This is because
// a document boost will add to every field and country is matched in a MUST.
@Override
public float computeNorm(String field, FieldInvertState state) {