Skip to content

Instantly share code, notes, and snippets.

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 January 10, 2018 22:42
Binary boolean operation truth tables, various versions
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 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
#!/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 April 26, 2016 22:47
Automatically record bash sessions
#####################################################################
#
# 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 August 29, 2015 14:24
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.
#!/usr/bin/env perl -w
use strict;
use warnings;
use JSON;
use LWP::UserAgent;
use URI;
use URI::QueryParam;
my $ua = LWP::UserAgent->new;
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 March 18, 2014 23:18
How to fetch Google Ngrams data
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),
);
@hoehrmann
hoehrmann / google-phonetic.pl
Created February 14, 2014 17:11
Google Translate phonetic (english-only?) transliterations
#!perl -w
use strict;
use warnings;
use LWP::UserAgent;
use URI;
use JSON;
use YAML::XS;
my $uri = URI->new('http://translate.google.com/translate_a/t');
{
"results" : [
{
"address_components" : [
{
"long_name" : "\u003ca href=http://localhost:20000/form/DataTool.view_region?submit=Send+to+RPC&3=t&3.1=-22.467512&3.1.=y&3.2=-42.655755&3.2.=y&3.3=2.500000&3.3.=y&3.4=0.000000&3.4.=y&3.5=0.071465&3.5.=y&3.6=-1.143429&3.6.=y&database=mapmaker_prod\u003eSV pose\u003c/a\u003e",
"short_name" : "\u003ca href=http://localhost:20000/form/DataTool.view_region?submit=Send+to+RPC&3=t&3.1=-22.467512&3.1.=y&3.2=-42.655755&3.2.=y&3.3=2.500000&3.3.=y&3.4=0.000000&3.4.=y&3.5=0.071465&3.5.=y&3.6=-1.143429&3.6.=y&database=mapmaker_prod\u003eSV pose\u003c/a\u003e",
"types" : [ "route" ]
},
{
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int
main(int argc, char *argv[]) {
char* buffer;
BOOL bStatus;
COORD coords;
HANDLE hConsole;