Skip to content

Instantly share code, notes, and snippets.

@teepark
teepark / wat.zig
Last active December 19, 2022 22:45
(minimal?) POC
const std = @import("std");
const debug = std.debug;
const heap = std.heap;
const mem = std.mem;
// $ zig run wat.zig
// (main) grid is 7x5
// (set) grid is 2x6159346672
// failure
// Segmentation fault at address 0x16f204000
@teepark
teepark / README.md
Last active March 5, 2021 18:38
pgtype #92 reproduction

This should just need a running postgresql 10.7 server and a PGURN environment variable with credentials that will support creating and using a temporary table.

[travis:~/tmp]$ go run .
::TEXT conversion produces 600.000000000000
decimal select error
2021/03/05 10:22:23 can't scan into dest[0]: 600000000000000e-12 is not a number
exit status 1
package finmath
import (
"github.com/ericlagergren/decimal"
"github.com/ericlagergren/decimal/math"
)
func CalculateFV(pv, pmt, i, n *decimal.Big) *decimal.Big {
if i.Cmp(zero) == 0 {
d := new(decimal.Big).Mul(pmt, n)
@teepark
teepark / proof.md
Created May 17, 2019 23:40
Keybase proof

Keybase proof

I hereby claim:

  • I am teepark on github.
  • I am teepark (https://keybase.io/teepark) on keybase.
  • I have a public key ASDmmFGjcuBjtmQFyU6miwTxSObFCxAwRF4koOcHPVyY9Ao

To claim this, I am signing this object:

macro compose M "\
<enter-command>set pipe_decode=yes<enter>\
<pipe-message>pandoc -s -f gfm -t html5 -o /tmp/mutt-pandoc-buf.html<enter>\
<enter-command>set pipe_decode=no<enter>\
<attach-file>^u/tmp/mutt-pandoc-buf.html<enter>\
<toggle-disposition>\
<edit-type>^utext/html<enter>\
<first-entry>\
<tag-entry>\
<tag-entry>\
@teepark
teepark / cnose
Created April 7, 2017 21:08
colorful nosetests wrapper
#!/usr/bin/env bash
set -euo pipefail
simple() {
sed -E \
-e "1 s/\./$(printf '\033[32m.\033[0m')/g" \
-e "1 s/S/$(printf '\033[33mS\033[0m')/g" \
-e "1 s/F/$(printf '\033[31mF\033[0m')/g" \
-e "s/^(FAILED.*)$/$(printf '\033[31m\\1\033[0m')/" \
@teepark
teepark / threads_signals.py
Created February 20, 2017 21:46
testing Thread.join from a signal handler
#!/usr/bin/env python
from datetime import datetime
import os
import signal
import sys
import threading
import time
@teepark
teepark / ip_client.py
Last active January 3, 2017 21:32
how fast are unix domain sockets with long-lived connections?
#!/usr/bin/env python
import socket
import time
server_addr = '127.0.0.1'
server_port = 5000
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((server_addr, server_port))
@teepark
teepark / multi-insert-composites.sql
Last active October 3, 2016 22:51
multi-insert with composite type fails?
create domain required_int as integer check (not null);
create type xypoint as (
name text,
x required_int,
y int
);
create table foo (
description text,
(<<<) : (c -> d) -> (a -> b -> c) -> a -> b -> d
(<<<) f g =
(\a b ->
g a b |> f
)