Skip to content

Instantly share code, notes, and snippets.

Björn Höhrmann hoehrmann

Block or report user

Report or block hoehrmann

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
View sqlite-3.25.1-window-function-in-view-bug.txt
Hi,
Using the sqlite-tools-linux-x86-3250100 Linux binaries I find that
Window functions in VIEWS behave differently from PostgreSQL 9.6 and
from what I expect.
DROP TABLE IF EXISTS example;
CREATE TABLE example(t INT, total INT);
INSERT INTO example VALUES(0,2);
INSERT INTO example VALUES(5,1);
@hoehrmann
hoehrmann / view_every_hour_past_six_months.sql
Last active Jul 28, 2018
view_every_hour_past_six_months.sql
View view_every_hour_past_six_months.sql
DROP VIEW IF EXISTS view_every_hour_past_six_months;
CREATE VIEW view_every_hour_past_six_months AS
WITH RECURSIVE
bounds AS (
SELECT
strftime('%s', 'now', 'start of day', '-6 month') AS lower,
strftime('%s', 'now', 'start of day', '+1 day') AS upper
),
samples AS (
SELECT lower AS sample FROM bounds
View c11-lexer-grammar
token = _
/ keyword
/ identifier
/ constant
/ string-literal
/ punctuator
preprocessing-token = _
/ header-name
/ identifier
View sqlite-cte-random-path.txt
SQLite version 3.11.0 2016-02-15 17:29:24
Enter ".help" for usage hints.
sqlite> EXPLAIN QUERY PLAN
...> WITH RECURSIVE path(pos, vertex) AS (
...> SELECT 0, ?
...> UNION ALL
...> SELECT path.pos + 1, (SELECT Edge.dst
...> FROM Edge
...> WHERE Edge.src = path.vertex
...> ORDER BY RANDOM()
@hoehrmann
hoehrmann / binops-all.txt
Created Jan 10, 2018
Binary boolean operation truth tables, various versions
View binops-all.txt
0 !| < > & A B ==
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
| 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 | | 0 | 0 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
View lab_color_distance_mask.sh
#!/bin/bash
#####################################################################
# Copyright (c) 2016 Bjoern Hoehrmann <bjoern@hoehrmann.de>. GPLv3+.
#
# Given image + color, creates mask encoding pixel's LAB color diff.
#####################################################################
path_in="$1"
color_rgb="$2"
path_out="$3"
@hoehrmann
hoehrmann / scriptrec.sh
Created Apr 26, 2016
Automatically record bash sessions
View scriptrec.sh
#####################################################################
#
# This script starts an automatically recorded session using `script`
# storing logs in `$log_dir`. Care should be taken to secure records
# generated by this script as they may easily contain passwords and
# other sensistive information.
#
#####################################################################
# FIXME(bh): make this configurable
@hoehrmann
hoehrmann / lastfm-user-toptracks-tags.pl
Last active Aug 29, 2015
For a given last.fm user, retrieves all their top tracks, and for each track, all tags for the track, and then prints out the 7 most-used tags for each track.
View lastfm-user-toptracks-tags.pl
#!/usr/bin/env perl -w
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use URI;
use URI::QueryParam;
my $ua = LWP::UserAgent->new;
View node-js-http-proxy-capturing-audio-mpeg-files.js
var httpProxy = require('http-proxy');
var http = require('http');
var fs = require('fs');
var proxy = httpProxy.createProxyServer({
target:'http://localhost:9005'
});
proxy.listen(8005);
@hoehrmann
hoehrmann / fetch-ngrams-data.pl
Created Mar 18, 2014
How to fetch Google Ngrams data
View fetch-ngrams-data.pl
my $url = URI->new('http://books.google.com/ngrams/graph');
$url->query_form(
year_start => 1800,
year_end => 2000,
corpus => $corpus,
smoothing => 30,
content => encode_utf8($q),
);
You can’t perform that action at this time.