Tom Peters
Software developer and product manager from Buffalo, NY. I build products people love using. Huge fan of Go. Creator of SqMGR, Names in a Hat, and Monday Night Poker.
Software developer and product manager from Buffalo, NY. I build products people love using. Huge fan of Go. Creator of SqMGR, Names in a Hat, and Monday Night Poker.
My primary language for building reliable, performant backend services and APIs.
func (l *RateLimiter) Limit(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ip := getIP(r)
limiter := l.getVisitor(ip)
if !limiter.Allow() {
http.Error(w, http.StatusText(http.StatusTooManyRequests),
http.StatusTooManyRequests)
return
}
next.ServeHTTP(w, r)
})
}
Building beautiful, mobile-friendly front-ends with Vue, React, and vanilla JS.
send(action, subject, cards, additionalData) {
const context = uuid()
this.ws.send(JSON.stringify({
action, subject, cards, additionalData, context,
}))
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject('did not receive response from server')
delete(this.context[context])
}, 2000)
this.context[context] = { resolve, reject, timeout }
})
}
Two apps on the App Store, kept current with Apple's best practices.
// Draw all names ahead of time to avoid the scenario
// where the last two names are the same person
func drawForSecretSanta() {
outerLoop: while true {
resetDraw()
var secretSantaResults = [DrawingResult]()
for name in hat.names {
while true {
guard let result = super.draw() else {
fatalError("could not call draw()")
}
if name != result.name {
result.giverName = name
secretSantaResults.append(result)
break
}
if super.isComplete() { continue outerLoop }
guard super.undoDraw() else {
fatalError("could not undoDraw()")
}
}
}
// ...
Over 15 years of experience writing highly performant, modern Perl.
Test::MockPackages for unit test development.sub called {
my ( $self, $called ) = @ARG;
if ( !looks_like_number( $called ) || $called < -1 ) {
croak( '$called must be an integer >= -1' );
}
$self->{_called} = $called;
return $self->_validate();
}
PostgreSQL is my go-to RDBMS, with experience in MySQL/MariaDB, Solr, Riak, and Cassandra.
CREATE FUNCTION adjust_balance(
_players_tables_id bigint, _current_balance int,
_adjustment int, _game_id bigint, _reason text
) RETURNS boolean LANGUAGE plpgsql AS $$
DECLARE
_previous_balance int;
_next_balance int;
BEGIN
SELECT INTO _previous_balance balance
FROM players_tables WHERE id = _players_tables_id FOR UPDATE;
IF _previous_balance != _current_balance THEN
RAISE EXCEPTION 'balance has changed';
END IF;
_next_balance := _previous_balance + _adjustment;
INSERT INTO players_tables_transactions (...) VALUES (...);
UPDATE players_tables SET balance = _next_balance WHERE id = _players_tables_id;
RETURN TRUE;
END; $$;
Docker and Kubernetes advocate. Using GitHub Actions for CI/CD pipelines.
apiVersion: apps/v1
kind: Deployment
metadata:
name: sqmgr-api
spec:
template:
spec:
containers:
- name: sqmgr
image: ghcr.io/sqmgr/sqmgr-api:latest
args: ['-migrate']
envFrom:
- secretRef:
name: sqmgr-config
volumeMounts:
- mountPath: /opt/sqmgr/jwt-keys
name: jwt-keys
readinessProbe:
httpGet:
port: 8000
path: /
volumes:
- name: jwt-keys
secret:
secretName: sqmgr-jwt-keys