Skip to content

Instantly share code, notes, and snippets.

Florian Klein docteurklein

Block or report user

Report or block docteurklein

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
docteurklein / 0_setup.sql
Last active Jan 14, 2020
psql -v ON_ERROR_STOP=1 -c begin $(find . -name '*.sql' -printf ' -f %f\n' | sort -V | xargs) -c commit
View 0_setup.sql
create table if not exists migration (
id bigint primary key,
at timestamptz not null default clock_timestamp()
docteurklein / migrate.sql
Created Jan 13, 2020
postgres-only transactional migration script
View migrate.sql
create table if not exists migration (id bigint primary key, at timestamptz not null default clock_timestamp());
drop function if exists migrate;
create function migrate() returns bigint language plpgsql as $$
declare current_migration bigint;
select coalesce((select id from migration order by id desc limit 1), 0) into current_migration;
View gist:868dcd62c86d95e688130fea09f0e45a
create function es.project(event returns void
language plpgsql as $$
case event.type
when 'user_registered' then
insert into es.active_users
(user_id , name , sha256 , updated_at) values
(event.aggregate_id , event.payload->>'name' , event.payload->>'sha256' , event.added_at);
when 'user_changed_password' then
update es.active_users set
error[E0599]: no method named `map` found for type `postgres::notification::BlockingIter<'_>` in the current scope
  --> src/
24 ||notification| {
   |                   ^^^
   = note: the method `map` exists but the following trait bounds were not satisfied:
           `&mut postgres::notification::BlockingIter<'_> : fallible_iterator::FallibleIterator`
           `&mut postgres::notification::BlockingIter<'_> : std::iter::Iterator`
  • why is it that the haskell Text.CSV version is always around twice as slow?
  • how can I use ; as a column separator in the haskell Text.CSV version?
View gist:96ec8b7f126f92069e5a399acc5741cb
root@a77d04db26a6:/go/src/ GOOS=darwin hack/ binary
Removing bundles/
---> Making bundle: binary (in bundles/binary)
Building: bundles/binary-daemon/dockerd-dev
GOOS="darwin" GOARCH="" GOARM=""
vendor/ undefined: syscall.MNT_DETACH
View index.html
<script type="module">
export default class RemoteContent extends HTMLElement {
constructor() {
this.parser = new DOMParser();
this.shadow = this.attachShadow({mode: 'open'});
this.append = this.shadow.appendChild.bind(this.shadow);
this.shadow.innerHTML = 'loading…';
View Dockerfile
FROM alpine:edge as build
RUN apk add --no-cache ghc musl-dev
RUN wget -O - \
| tar -Oxzf - stack- > /usr/bin/stack
RUN chmod +x /usr/bin/stack
WORKDIR /usr/src/app
docteurklein /
Last active Oct 19, 2018
generate burndown charts with trello, R and jq
export TRELLO_TOKEN='<your trello token>' # found in web cookie
export TRELLO_DONE_ID='<the trello internal id of the "Done" list>'

curl -H "Cookie: token=$TRELLO_TOKEN;" -sL \
  | ./ 2018-06-01 2018-11-01 true | ./burndown.r "$(date --iso -d '+2 year')" && xdg-open burndown.svg
View overhead.php
$num = floatval($argv[1] ?? '1e6');
echo "iterations: $num\n";
function noop() {
$start = microtime(true);
printf("starting raw at:\t\t%.3F s\n", $start);
You can’t perform that action at this time.