Skip to content

Instantly share code, notes, and snippets.

Avatar
💬
icio is typing...

Paul Scott icio

💬
icio is typing...
View GitHub Profile
@icio
icio / get_prime.php
Created Mar 22, 2011
N-th Prime Numbers
View get_prime.php
<?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 Feb 19, 2021
usego script for installing any Go version (including tip) into ~/sdk using https://pkg.go.dev/golang.org/dl/
View usego
#!/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 Jan 14, 2021
Hooking into Go SQL drivers for triggering race conditions
View repo_test.go
package repo_test
import (
"database/sql"
"database/sql/driver"
"testing"
"./repo"
)
@icio
icio / .bashrc
Last active Jan 31, 2020
dotfiles
View .bashrc
#!/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 Dec 8, 2017
Example of using sentinel values with github.com/google/go-cmp
View ignore_test.go
package example_test
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/google/go-cmp/cmp"
)
View select.py
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 Feb 8, 2017 — forked from anonymous/run.sh
Go: Reflecting valid values
View run.sh
$ 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}}:
View go-diff.sh
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 / _readme.md
Created Nov 29, 2013
Dominos Slack notifier
View _readme.md

Dominos → Slack Notifier

Paste this snippet into your web browser's console when viewing the Pizza Tracker page offered after submitting a Dominos order. When the state changes it'll post the order state to your specified Slack Incoming Webhook. Use the URL at the top of your existing integration to paste into the prompt you receive when running the snippet. It should be in the form of: "https://TEAM.slack.com/services/hooks/incoming-webhook?token=TOKEN".

You'll need to leave your browser window open until it's done, of course. Tested in Chrome in the UK. Not tested with collections.

View 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: