Skip to content

Instantly share code, notes, and snippets.

@eatonphil
eatonphil / withDocker.js
Created July 26, 2022 15:39
A Node wrapper around scheduling Docker containers for NodeJS tests
const cp = require('child_process');
function runCmd(opts, containerId, cmd) {
console.log('[DEBUG withDocker] docker exec ' + containerId + ' ' + cmd);
cp.execSync('docker exec ' + containerId + ' ' + cmd, {
stdio: 'inherit',
});
process.stdout.write('\n');
}
@eatonphil
eatonphil / psql-srv.py
Last active March 25, 2024 17:01 — forked from matteobertozzi/psql-srv.py
postgres "server" wire protocol example (ported python3)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---
@eatonphil
eatonphil / keys.ahk
Last active July 25, 2020 20:36
Autohotkey defaults for Windows 10 on Surface Book 2
; Make Caps -> Esc
Capslock::Esc
; Make Ctrl+Windows+Alt+Left -> media backward
#^!Left::Send {Media_Prev}
; Make Ctrl+Windows+Alt+Right -> media forward
#^!Right::Send {Media_Next}
; Give back a right control
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"log"
"os"
@eatonphil
eatonphil / emulator.js
Created July 20, 2019 21:05
Emulator basics
const fs = require('fs');
function parse(program) {
const labels = {};
const instructions = [];
const lines = program.split('\n');
for (let i = 0; i < lines.length; i++) {
let line = lines[i].trim(); // Remove any trailing, leading whitespace
(../../drivers/bus/acpi/main.c:316) Unsupported IOCTL: 294040
(../../dll/ntdll/ldr/ldrutils.c:1311) LDR: LdrpMapDll Relocating Image Name LIBEAY32.dll (10000000-1014F000 -> 00230000)
(../../dll/ntdll/ldr/ldrutils.c:1350) Overlapping DLL: C:\Program Files\ROSBE\bin\SSLEAY32.dll
(../../dll/ntdll/ldr/ldrutils.c:1311) LDR: LdrpMapDll Relocating Image Name MSVCP120.dll (10000000-10071000 -> 00380000)
(../../dll/ntdll/ldr/ldrutils.c:1350) Overlapping DLL: C:\Program Files\ROSBE\bin\SSLEAY32.dll
(../../dll/ntdll/ldr/ldrutils.c:1311) LDR: LdrpMapDll Relocating Image Name MSVCR120.dll (10000000-100EE000 -> 00730000)
(../../dll/ntdll/ldr/ldrutils.c:1350) Overlapping DLL: C:\Program Files\ROSBE\bin\SSLEAY32.dll
(../../dll/ntdll/ldr/ldrutils.c:1311) LDR: LdrpMapDll Relocating Image Name LIBEAY32.dll (10000000-1014F000 -> 00230000)
(../../dll/ntdll/ldr/ldrutils.c:1350) Overlapping DLL: C:\Program Files\ROSBE\bin\SSLEAY32.dll
(../../dll/ntdll/ldr/ldrutils.c:1311) LDR: LdrpMapDll Relocating Image Name MSVCP120.dll (10000000
@eatonphil
eatonphil / naive.c
Created May 20, 2018 23:36
Cython compiled C output
/* Generated by Cython 0.28.2 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
#error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
#error Cython requires Python 2.6+ or Python 3.3+.
#else
#define CYTHON_ABI "0_28_2"
> val h = fun a b = b;
poly: : error: Expression expected but fun was found
Static Errors
> fun a b = b;
val a = fn: 'a -> 'a
(define-syntax my-let*
(syntax-rules ()
((_ ((p v)) b ...)
(let ((p v)) b ...))
((_ ((p1 v1) (p2 v2) ...) b ...)
(let ((p1 v1))
(my-let* ((p2 v2) ...)
b ...)))))
@eatonphil
eatonphil / cl-docker.asd
Last active December 21, 2022 19:49
cl-docker
(defsystem :cl-docker
:depends-on (:cl-ppcre)
:serial t
:components ((:file "package")
(:file "docker")))