Skip to content

Instantly share code, notes, and snippets.

View icio's full-sized avatar
💬
icio is typing...

Paul Scott icio

💬
icio is typing...
View GitHub Profile
(function() {
/* Allow timeline to fully expand. */
const s = document.querySelector('virtual-scroll');
function noscroll(s) { s.height = s.overflow = s.overflowY = 'unset'; }
for (let i = 0, p = s.parentNode; i < 5; i++, p = p.parentNode) noscroll(p.style);
s.removeChild(s.querySelector('.total-padding'));
s.querySelector('.scrollable-content:not(.header)').style.position = 'relative';
/* Sticky span details to right. */
const d = document.querySelector('trace-row-details');
package main
import (
"fmt"
"reflect"
"github.com/google/go-cmp/cmp"
)
type Response struct {
@icio
icio / README.md
Last active August 11, 2022 17:00
Converting integers to timestamps

Table of integers and how they convert into timestamps at different resolutions.

A indicates the timestamp is within the range 0000-00-00T00:00:00Z to 9999-12-31T23:59:59.9999 which is considered valid by Google BigQuery.

The number 253402300799 is the unix timestamp (number of seconds since 1970-01-01T00:00:00Z) until 9999-12-31T23:59:59.9999 and is the recommended switch to the next resolution.

               input @ unit = time                 |          input * 1ns   |             input * 1µs   |                input * 1ms   |                   input * 1s  
-9223372036854775808 @  1ns = 1677-09-21T00:12:43Z | 1677-09-21T00:12:43Z ✓ | -290308-12-21T19:59:05Z   | -292275055-05-16T16:47:04Z   | 292277026596-12-04T15:30:08Z  
  -62135596800000000 @  1µs = 0001-01-01T00:00:00Z | 1968-01-12T20:06:43Z ✓ |    0001-01-01T00:00:00Z ✓ |   -1967029-04-28T00:00:00Z   |  -1968996709-01-15T00:00:00Z  
@icio
icio / usego
Created February 19, 2021 12:14
usego script for installing any Go version (including tip) into ~/sdk using https://pkg.go.dev/golang.org/dl/
#!/bin/sh
set -eu
VERS="${1:?Usage: $0 1.x.x}"
test -d ~/sdk || mkdir ~/sdk
cd ~/sdk
unset GOROOT
go get golang.org/dl/go$VERS
go$VERS download
test -d go && rm go
ln -s go$VERS go
@icio
icio / repo_test.go
Created January 14, 2021 15:22
Hooking into Go SQL drivers for triggering race conditions
package repo_test
import (
"database/sql"
"database/sql/driver"
"testing"
"./repo"
)
@icio
icio / ignore_test.go
Last active December 8, 2017 22:27
Example of using sentinel values with github.com/google/go-cmp
package example_test
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/google/go-cmp/cmp"
)
from Queue import Queue
def select(source, selector, unselected, sentinel):
for item in source:
if selector(item):
yield item
else:
unselected.put(item)
unselected.put(sentinel)
@icio
icio / run.sh
Created February 8, 2017 19:23 — forked from anonymous/run.sh
Go: Reflecting valid values
$ go run valid.go
main.Thing{Age:sql.NullInt64{Int64:99, Valid:true}, Lender:(*sql.NullString)(nil), Blue:sql.NullBool{Bool:false, Valid:false}}:
- Age: 99
main.Thing{Age:sql.NullInt64{Int64:1, Valid:true}, Lender:(*sql.NullString)(0xc82008a000), Blue:sql.NullBool{Bool:false, Valid:false}}:
- Age: 1
&main.Thing{Age:sql.NullInt64{Int64:0, Valid:false}, Lender:(*sql.NullString)(0xc82008a020), Blue:sql.NullBool{Bool:false, Valid:false}}:
- Lender: "Friend"
&main.Thing{Age:sql.NullInt64{Int64:0, Valid:false}, Lender:(*sql.NullString)(nil), Blue:sql.NullBool{Bool:true, Valid:true}}:
- Blue: true
&main.Thing{Age:sql.NullInt64{Int64:44, Valid:true}, Lender:(*sql.NullString)(0xc82008a080), Blue:sql.NullBool{Bool:false, Valid:true}}:
function go-local-package() {
go list ./... | head -1 | xargs dirname
}
function go-diff() {
ROOT_PKG=$(go-local-package)
go list -f '{{.Name}} {{.ImportPath}} {{.Deps}}' $(go list $ROOT_PKG/...) | \
grep ^main | \
grep -w -f <(
git diff --dirstat ${2:-master}...${1:-HEAD} | \
@icio
icio / keybase.md
Created May 7, 2016 15:17
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object: