Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hoehrmann
hoehrmann / evolveProtocol.ts
Last active April 18, 2019 21:15
Idea for JSON-RPC 2.0 interface definitions using TypeScript
export namespace api {
export interface Request<T extends string> {
params: any;
result: any;
__name: {
[name in T]: T
}
}
@hoehrmann
hoehrmann / fdpassing.ts
Created April 14, 2019 21:49
node <> Perl communication over additional fds
import { spawn } from 'child_process';
import { Writable, Readable } from 'stream';
const child = spawn(
'perl',
['-e', `
use IO::Handle;
my $in = IO::Handle->new_from_fd($ENV{JIPE_RHS_STDIN_FD}, 'r');
my $out = IO::Handle->new_from_fd($ENV{JIPE_RHS_STDOUT_FD}, 'w');
@hoehrmann
hoehrmann / sql-json-style-sheets.sql
Created October 6, 2018 16:44
Complex table formatting of SQL Query results using JSON formatting objects
-- styles for CPAN module Text::ANSITable
SELECT
time, priority, message
,
json_object(
'priority',
json_object(
'fgcolor',
CASE
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);
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 |
+---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+ +---+---+
@hoehrmann
hoehrmann / Xirip.pas
Created June 5, 2013 12:18
XiRip is a 1997 Turbo Pascal program that takes .xm music files and extracts the embedded instruments.
uses StrngTol;
type
parameter=record
FileName:String;
ExtractPath:String;
ShowHelpScreen:Boolean; {/?}
KeepInstName:boolean; {/K}
KeepSampName:boolean; {/S}
QuitOutput:Boolean; {/Q}
end;
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
int
main(int argc, char *argv[]) {
char* buffer;
BOOL bStatus;
COORD coords;
HANDLE hConsole;
@hoehrmann
hoehrmann / Automaton JSON
Created November 10, 2013 21:16
Rough sketch for a flexible JSON format to store and exchange state automata.
{
"start": "State0",
"alphabet": {
...
},
"symbols": {
"aA": {
Request for status information
* ?action=about&...
* CAPABILITIES
* DATE
* ...
Retrieve some basic information about the service. For instance,
which authentication method the service would like to use, or if
some optional protocol features are implemented. Can also be used
to support the DATE command by looking at the Date header. If