Skip to content

Instantly share code, notes, and snippets.

View nordfjord's full-sized avatar

Einar Norðfjörð nordfjord

View GitHub Profile
@nordfjord
nordfjord / processor.js
Created July 12, 2023 14:41
Span processor for json logs
export const processor = {
/**
* Forces to export all finished spans
*/
forceFlush() { return Promise.resolve() },
/**
* Called when a {@link Span} is started, if the `span.isRecording()`
* returns true.
* @param span the Span that just started.
*/
@nordfjord
nordfjord / app.controller.ts
Created October 15, 2022 17:48
Nestjs Configcat
import { ConfigCatClient } from 'configcat-common/lib/ConfigCatClient';
@Controller('travel')
export class AppController {
constructor(
private readonly appService: AppService,
private readonly flags: ConfigCatClient
) {}
@Get('mileage')
@nordfjord
nordfjord / rrule-test.fsx
Created August 10, 2022 15:14
RRule perf test
#r "nuget: Ical.Net"
open System
open Ical.Net
let rrule =
"BEGIN:VCALENDAR
BEGIN:VEVENT
DTSTART;TZID=Europe/London:20220811T090000
DTEND;TZID=Europe/London:20220811T093000
@nordfjord
nordfjord / Processor.cs
Created June 28, 2021 19:51
Processor in c#
using System;
using System.Collections.Generic;
using System.Linq;
namespace ProcessorDemo
{
public interface IProcessor<Event, Command, State>
{
public State InitialState { get; }
public State Evolve(State state, Event @event);
@nordfjord
nordfjord / machine.js
Last active June 4, 2021 11:02
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nordfjord
nordfjord / index.js
Created December 16, 2018 17:20
Syntax coding kata
const FeedParser = require("feedparser");
const request = require("request");
const feedRequest = request("https://feed.syntax.fm/rss");
const feedparser = new FeedParser();
feedRequest.on("response", function(res) {
var stream = this;
if (res.statusCode !== 200) {
@nordfjord
nordfjord / FactoryComponent.ts
Last active December 2, 2018 16:53
Mithril Components
export const FactoryComponent = <TAttrs>(
factory: (attrs: TAttrs, children?: Mithril.Child) => Component<TAttrs>
) =>
({
controller(attrs: TAttrs, children?: Mithril.Child) {
return factory(attrs, children);
},
view(component: Component<TAttrs>, attrs: TAttrs, children) {
return component.view(attrs, children);
},
@nordfjord
nordfjord / example.js
Created September 6, 2016 15:00
Subtree retain flyd streams
import m from 'mithril';
import f from 'flyd';
import retain from './flyd-retain';
function myComponent(){
let username = f.stream('');
let username_header = username.map(name => m('h1', name));
let username_input = username.map(name => m('input', {value: name, oninput: m.withAttr('value', username)}));
return retain(f.combine(function(h, i){
@nordfjord
nordfjord / mithril-ga.js
Created March 22, 2016 15:47
Google Analytics integration for mithril
var m = require('mithril');
var _mroute = m.route;
var type = {}.toString;
m.route = function(arg0, arg1){
var res = m_route.apply(this, [].slice.call(arguments));
if (type.call(arguments[0]) === '[object String]' || (arguments.length === 3 && type.call(arg1) === '[object String]')) {
ga('send', 'pageview', _mroute());

Introduction

You've been sat at this delightful little café for the best part of an hour and a half. You've not had a sip of coffee, but the pot plant next to you has been remarkably well fed as you keep asking for refills. The pastry in front of you has not entered your mouth, but you've occupied yourself peeling off the thin layers of its skin, flicking them away in the breeze.

Your attention here isn't on the patisserie, it's on that church on the other side of the piazza, that magnificent stone building, that edifice of religion, that monument to faith. In your breathing days you used to attend regularly, you took the sacrament, you spoke the words, but you weren't there because you were a believer, you were there because of a woman, as you so often were in life.