Skip to content

Instantly share code, notes, and snippets.

View algesten's full-sized avatar
😀
barcelona!

Martin Algesten algesten

😀
barcelona!
View GitHub Profile
@algesten
algesten / _stream-forensics.md
Last active November 27, 2016 11:22
Stream Forensics

Stream Forensics

A quick analysis of the event order for interconnected nodejs streams.

Whilst the events themselves are well documented, We wanted to find out exactly in what order events happen for interconnected streams where the readable stream ends (since this is different from reading from a never-ending input such as stdin).

input.pipe(middle).pipe(output)

<newsMessage xmlns="http://iptc.org/std/nar/2006-10-01/"
xmlns:tt="http://tt.se/spec/newsml">
...
<contentMetaExtProperty rel="tt:revisions">
<tt:revisions>
<tt:revisionItem reluri="http://tt.se/media/text/20160318_panda_1">
<tt:slug>panda</tt:slug>
</tt:revisionItem>
<tt:revisionItem reluri="http://tt.se/media/text/20160318_panda_2">
<tt:slug>pandaUV</tt:slug>
@algesten
algesten / ttninjs-revisions.md
Last active March 16, 2016 08:44
Revisions section in ttninjs

Revisions section in ttninjs

Motivation

TT publishes news stories using what internally is referred to as "takes". A take is a part of a news story, as it develops, and is in itself not a complete article for web publication or print. Eventually a "full story" will follow that replaces all individual "bits".

A full news story from TT is often a result of a chain of

uri: "http://tt.se/media/text/1"
slug: "usa-val"
history: [
# first version also has an entry in the history
{uri:"http://tt.se/media/text/1", slug:"usa-val"}
]
@algesten
algesten / ttninjs-dates.md
Last active June 9, 2016 13:43
ttninjs-dates external and internal

TTNINJS Dates

This is an attempt to document the interpretation of various date fields in the ttninjs spec. Some fields are internal to TT and not visible in metadata delivered to customers. Internal fields are prefixed _.

versioncreated

@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 / 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)
#
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 / tt_newsml-spec.md
Last active April 11, 2016 17:00
tt_newsml-spec.md

TT NewsML spec

TT:s main content format is ttninjs. The XML variant is a IPTC NewsML G2 2.20 compliant translation of ttninjs where each field somehow relates back to the original ttninjs.

Revision history

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