Skip to content

Instantly share code, notes, and snippets.

Avatar

Travis Parker teepark

  • Facta
  • San Francisco, CA
View GitHub Profile
@teepark
teepark / README.md
Last active Mar 5, 2021
pgtype #92 reproduction
View README.md

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
View finmath.go
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
Keybase proof
View proof.md

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:

View gist:8977bcb6b8b3972e4534bc79cd58d31b
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 Apr 7, 2017
colorful nosetests wrapper
View cnose
#!/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 Feb 20, 2017
testing Thread.join from a signal handler
View threads_signals.py
#!/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 Jan 3, 2017
how fast are unix domain sockets with long-lived connections?
View ip_client.py
#!/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 Oct 3, 2016
multi-insert with composite type fails?
View multi-insert-composites.sql
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,
View threeArrow.elm
(<<<) : (c -> d) -> (a -> b -> c) -> a -> b -> d
(<<<) f g =
(\a b ->
g a b |> f
)
@teepark
teepark / gotest
Last active Aug 19, 2016
colorful go test output
View gotest
#!/usr/bin/env bash
set -euo pipefail
go test "$@" | \
sed -E \
-e "/^((--- PASS:.*)|(ok.*)|(PASS.*))$/s//$(printf '\033[32m\\1\033[0m')/" \
-e "/^(\\?.*\\[no test files\\])$/s//$(printf '\033[33m\\1\033[0m')/" \
-e "/^(FAIL.*|--- FAIL:.*)$/s//$(printf '\033[31m\\1\033[0m')/"