Skip to content

Instantly share code, notes, and snippets.

@durango
durango / LICENSE
Created May 22, 2023 17:10 — forked from spuder/LICENSE
Script to help recover nomad servers that have lost leadership
Mozilla Public License, version 2.0
1. Definitions
1.1. "Contributor"
means each individual or legal entity that creates, contributes to the
creation of, or owns Covered Software.
1.2. "Contributor Version"
@durango
durango / notes.md
Created April 24, 2021 18:48 — forked from ian-whitestone/notes.md
Best practices for presto sql

Presto Specific

  • Don’t SELECT *, Specify explicit column names (columnar store)
  • Avoid large JOINs (filter each table first)
    • In PRESTO tables are joined in the order they are listed!!
    • Join small tables earlier in the plan and leave larger fact tables to the end
    • Avoid cross joins or 1 to many joins as these can degrade performance
  • Order by and group by take time
    • only use order by in subqueries if it is really necessary
  • When using GROUP BY, order the columns by the highest cardinality (that is, most number of unique values) to the lowest.
@durango
durango / walg-pitr.md
Created February 27, 2020 00:14 — forked from pohzipohzi/walg-pitr.md
PostgreSQL Point-In-Time-Recovery (PITR) with WAL-G

WAL-G PITR

This gist summarises a way to simulate point-in-time recovery (PITR) using WAL-G. Most of the material is adapted from Creston's tutorial.

Setup

First we initialize a database cluster

pg_ctl init -D cluster
@durango
durango / firebase-hook.js
Created January 23, 2020 02:24 — forked from dsafreno/firebase-hook.js
React Hooks for loading Firebase Data
import React, { useReducer, useEffect, useRef } from 'react';
import firebase from 'firebase/app';
import equal from 'deep-equal';
function filterKeys(raw, allowed) {
if (!raw) {
return raw;
}
let s = new Set(allowed);
return Object.keys(raw)
@durango
durango / postgres_queries_and_commands.sql
Created January 1, 2020 16:26 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@durango
durango / event_emitter.go
Created January 31, 2019 15:57 — forked from miguelmota/event_emitter.go
Golang event emitter example
package main
import (
"fmt"
)
type MyEmitter map[string]chan string
func main() {
myEmitter := MyEmitter{}
@durango
durango / acl.adoc
Created January 3, 2019 20:10 — forked from jexp/acl.adoc
Neo4j directed path through multiple relationships with property filter

Neo4j directed path through multiple relationships with property filter

Being new to Cypher and Neo4j, I am having trouble constructing my query for my use-case. I am building a simple ACL (access control list) and am looking for a path through permission relationships an up a hierarchy as well. A picture may better explain it:

cC8KN

Key: