Skip to content

Instantly share code, notes, and snippets.

@paultyng
paultyng / keybase.md
Created April 1, 2020 20:46
Keybase proof

Keybase proof

I hereby claim:

  • I am paultyng on github.
  • I am paultyng (https://keybase.io/paultyng) on keybase.
  • I have a public key whose fingerprint is 5C7F DE00 84B8 A02C 1571 545F 7E44 81B7 24D4 4C66

To claim this, I am signing this object:

@paultyng
paultyng / aws_presign.go
Created March 24, 2020 14:52
Create AWS IoT MQTT Presign URL in Go
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"net/url"
"strings"
"time"
@paultyng
paultyng / cmd.sh
Last active September 10, 2018 09:21
Gopkg.lock to vendor.json - dep to govendor
# tomljson from https://github.com/pelletier/go-toml
tomljson Gopkg.lock \
| jq '{ comment: "", ignore: "test", package: [.projects[] | . as $project | .packages[] | { path: ($project.name + if . == "." then "" else ("/" + .) end), revision: $project.revision } + if $project.version then { version: $project.version, versionExact: $project.version } else {} end], rootPath: "github.com/..." }'
@paultyng
paultyng / document.js
Last active June 15, 2017 12:23
Algolia - Material Document
{
"asset": {
"url": "https://underarmour.scene7.com/is/image/Underarmour//1299081-025_LA?$size=279,360&hei=400&wid=310&$extend=0"
},
"catalogs": [
1824,
1825,
1897,
1898,
1899,
@paultyng
paultyng / jwtRS256.sh
Created April 17, 2017 19:27 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
package auth
import (
"encoding/json"
"io/ioutil"
"net/http"
"net/url"
"os"
"regexp"
"time"
- name: update-user-email
title: Update User's Email
description: Update a user's email address.
db:
connection: users
sql: update users set email = :email where id = :id
schema:
properties:
id:
type: integer
#!/bin/bash
remote="${1:-origin}"
echo "Using remote $remote"
branches="$(git ls-remote --heads $remote | awk '{print $2}' | awk -F'/' '{print $3}' | grep '^v' | sort | uniq)"
echo "$branches" | while read branch; do
echo "Branch: $branch"
@paultyng
paultyng / kube-restart-counts.sh
Last active September 29, 2016 20:57
Get kubernetes restart counts > 0
kubectl get pods -o json |
jq '.items[] | .metadata.name + " " + (.status.containerStatuses[].restartCount | tostring)' -r |
awk '$2 > 0 { print $1 " " $2 }'
@paultyng
paultyng / password.tf
Last active November 30, 2017 22:52
Terraform Random Password Module
variable "length" {
default = "20"
}
resource "random_id" "password" {
byte_length = "${var.length * 3 / 4}"
}
output "password" {
value = "${random_id.password.b64}"