Skip to content

Instantly share code, notes, and snippets.

View stephennancekivell's full-sized avatar

Stephen Nancekivell stephennancekivell

View GitHub Profile
@stephennancekivell
stephennancekivell / pgbench.md
Created August 21, 2023 10:15
pgbench examples

Insert data

insert.sql

\set id random(1, 100000 * :scale)
\set uuid gen_random_uuid()


insert into my_table (id, uuid)
values
@stephennancekivell
stephennancekivell / postgres.md
Created August 21, 2023 10:02
Postgres queries

Running queries

SELECT pid, age(clock_timestamp(), query_start), usename, state, query 
FROM pg_stat_activity 
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' 
ORDER BY query_start desc;

Blocked pids

terraform {
required_providers {
http = {
source = "terraform-aws-modules/http"
version = "2.4.1"
}
}
required_version = ">= 0.13"
}
#!/usr/bin/env bash
IP=$(curl ifconfig.me)
echo "ip is $IP"
MSG="{
\"Changes\": [
{
\"Action\": \"UPSERT\",
\"ResourceRecordSet\": {
@stephennancekivell
stephennancekivell / gist:fb5a3113daa6d47a1350cc25721f386f
Created February 18, 2020 04:58
terraform docker 2.7.0 rebuild debug
terraform apply
2020/02/18 15:58:02 [INFO] Terraform version: 0.12.13
2020/02/18 15:58:02 [INFO] Go runtime version: go1.12.9
2020/02/18 15:58:02 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/1.0.2/versions/0.12.13/terraform", "apply"}
2020/02/18 15:58:02 [DEBUG] Attempting to open CLI config file: /Users/stephen/.terraformrc
2020/02/18 15:58:02 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/02/18 15:58:02 [INFO] CLI command args: []string{"apply"}
2020/02/18 15:58:02 [DEBUG] checking for provider in "."
2020/02/18 15:58:02 [DEBUG] checking for provider in "/usr/local/Cellar/tfenv/1.0.2/versions/0.12.13"
2020/02/18 15:58:02 [DEBUG] checking for provider in ".terraform/plugins/darwin_amd64"
@stephennancekivell
stephennancekivell / gist:39eeabe0ef085cbcb7a06816628c7994
Created February 18, 2020 04:57
terraform docker 2.7.0 rebuild
terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# docker_container.nginx will be created
+ resource "docker_container" "nginx" {
@stephennancekivell
stephennancekivell / diffjavamap.scala
Created June 7, 2018 23:37
scala diff recursive java Map[String,Any]
val skip = Set.empty[String]
import java.util.{Map => JMap, List => JList}
def diff(a: JMap[String, Any], b: JMap[String, Any], prefix: String = ""): Unit = {
(a.keySet().asScala.toSet ++ b.keySet().asScala.toSet).filterNot(skip.contains).foreach { key =>
val prefixKey = s"$prefix.$key"
(Option(a.get(key)), Option(b.get(key))) match {
case (Some(av), Some(bv)) if av.isInstanceOf[JMap[String, Any]] && bv.isInstanceOf[JMap[String, Any]] =>
diff(av.asInstanceOf[JMap[String, Any]], bv.asInstanceOf[JMap[String, Any]], prefixKey)
# results from https://github.com/stephennancekivell/circe-argonaut-compile-times
# 100 case classes with up to 15 values
play-json 2.12
23
19
play-json.topic 2.12
17
20
circe 2.12
@stephennancekivell
stephennancekivell / gatherUnordered.js
Created December 5, 2017 02:32
GatherUnordered.js
/*
* gather unordered takes an Array of promise's running them in parallel returning a single promise of their result and cancel function.
*
* If a error is encountered the first error will be returned, remaining unordered thunks will not be executed.
*
* @inputThunks Array[() => Promise[A]] an array of promises not yet started, thunks () => Promise
* @parallism number of promises to run at once
* @returns Object {
* promise: Promise[Array[A]]
* cancel: Function() to cancel
@stephennancekivell
stephennancekivell / traverseCancellable.js
Created December 1, 2017 06:05
javascript traverse cancellable
/*
* traverse cancellable takes an Array of promise's running them in parallel returning a single promise of their result and cancel function.
*
* @inputThunks Array[() => Promise[A]] an array of promises not yet started, thunks () => Promise
* @returns Object {
* promise: Promise[Array[A]]
* cancel: Function() to cancel
* }
*/
export function traverseCancellable(inputThunks) {