Skip to content

Instantly share code, notes, and snippets.

View fortytw2's full-sized avatar
🕶️

Ian fortytw2

🕶️
View GitHub Profile
@fortytw2
fortytw2 / r.sql
Created July 6, 2015 07:57
recursive sql
WITH RECURSIVE cte (id, body, op_id, path, comment_id, depth) AS (
SELECT id,
body,
op_id,
array[id] AS path,
comment_id,
1 AS depth
FROM comments
WHERE comment_id = 0 AND post_id = $1
UNION ALL
@fortytw2
fortytw2 / excuses.txt
Last active April 14, 2024 04:59
programming excuses
Actually, that's a feature
Don't worry, that value is only wrong half of the time
Even though it doesn't work, how does it feel?
Everything looks fine my end
How is that possible?
I broke that deliberately to do some testing
I can have a look but there's a lot of if statements in that code!
I can't make that a priority right now
I can't test everything
I couldn't find any examples of how that can be done anywhere else in the project
@fortytw2
fortytw2 / main.go
Created November 16, 2015 13:10
Encapsulated, gracefull goroutine shutdown in
package main
import (
"log"
"os"
"os/signal"
"sync"
"syscall"
"time"
)
@fortytw2
fortytw2 / leaktest.go
Created April 26, 2016 15:05
Goroutine Leak Test Helper
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package leaktest provides tools to detect leaked goroutines in tests.
// To use it, call "defer util.LeakTest(t)()" at the beginning of each
// test that may use goroutines.
// copied out of the cockroachdb source tree
package util
@fortytw2
fortytw2 / agnoster.zsh-theme
Created October 12, 2016 08:48
kube + go + agnoster zsh
# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline

Keybase proof

I hereby claim:

  • I am fortytw2 on github.
  • I am fortytw2 (https://keybase.io/fortytw2) on keybase.
  • I have a public key whose fingerprint is 30CE 29C8 C62F E18E D789 8D41 9FE0 138C 1DDD 46B8

To claim this, I am signing this object:

#!/bin/bash
## Last modified 2016-12-09 - Just Add Power
## Sets the 3G Receiver to operate as a fully functional 3G device
## Once applied the 3G unit will reboot and ONLY be compatible with other 3G units in 3G mode
astparam s soc_op_mode 3
astparam s remote_edid_patch 00000001
astparam save
echo '/usr/local/bin #'
sleep 5
reboot
@fortytw2
fortytw2 / determinism.go
Last active April 12, 2023 12:05
shutdown
package main
type Server struct {
shutdown chan struct{}
close chan struct{}
}
func NewServer() *Server {
s := &Server{
shutdown: make(chan struct{}, 0),