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 / manifest.json
Created March 17, 2011 17:44
Chrome extension to list all tab locations and copy them to the clipboard
{
"name": "Open URL Collector",
"version": "1.0",
"description": "Creates a list of the URLs of open tabs.",
"browser_action": {
"default_icon": "famfamfam_silk_cut_tab.png",
"popup": "popup.html"
},
"permissions": ["tabs"]
}
@icio
icio / get_prime.php
Created March 22, 2011 22:37
N-th Prime Numbers
<?php
/**
* A method for finding n-th prime numbers. Usage example follows at the end.
* @author Paul Scott <paul.scotto@gmail.com>
*/
/**
* Calculate the n-th prime number(s).
*
@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 / .bashrc
Last active January 31, 2020 16:54
dotfiles
#!/usr/bin/env bash
function run_scripts() {
for script in $1/*; do
# skip non-executable snippets
[ -x "$script" ] || continue
# execute $script in the context of the current shell
. $script
@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)