Skip to content

Instantly share code, notes, and snippets.

@durango
durango / fully-typed-context.ts
Created December 1, 2018 15:55 — forked from icanhasjonas/fully-typed-context.ts
Fully Type Checked and Filtered configuration context for components
type PropertyNames<T> = keyof T
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
type Filtered<T, C> = { [K in keyof T]: T[K] extends C ? K : never }[keyof T]
class ConfigurationPageContext<T> {
addTextSetting<K extends PropertyNames<T>>(
field: Extract<K, Filtered<T, string>>,
title: string,
defaultValue: string = null
): ConfigurationPageContext<Omit<T, K>> {
@durango
durango / Math-UTF8.md
Created December 1, 2018 16:04 — forked from stanislaw/Math-UTF8.md
Common Math Symbols in Unicode, my cheatsheet for writing notes.
@durango
durango / zigzag-encoding.README
Created December 12, 2018 22:36 — forked from mfuerstenau/zigzag-encoding.README
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
@durango
durango / Price-Time Matching Engine.c
Created December 15, 2018 04:50 — forked from Jud/Price-Time Matching Engine.c
Price-Time Matching Engine
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@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:
@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 / 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 / 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 / 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