Skip to content

Instantly share code, notes, and snippets.

View kgorman's full-sized avatar

Kenny Gorman kgorman

View GitHub Profile
@kgorman
kgorman / sample2.sql
Created October 25, 2019 15:00
sample2.sql
-- detect multiple auths in a short window and
-- send to lock account topic/microservice
SELECT card,
MAX(amount) as theamount,
TUMBLE_END(eventTimestamp, interval '5' minute) as ts
FROM payments
WHERE lat IS NOT NULL
AND lon IS NOT NULL
GROUP BY card, TUMBLE(eventTimestamp, interval '5' minute)
HAVING COUNT(*) > 4 -- >4==fraud
@kgorman
kgorman / sample.sql
Created October 25, 2019 14:52
sample sql
-- new to my airspace
SELECT icao, pings FROM (
SELECT icao, speed,
COUNT(*) OVER (PARTITION BY icao ORDER BY eventTimestamp RANGE BETWEEN INTERVAL '60' SECOND PRECEDING AND CURRENT ROW) AS pings
FROM airplanes
) WHERE pings < 5
AND icao like 'A%'
@kgorman
kgorman / fraud.sql
Created June 7, 2019 21:22
sample fraud query
-- fraud processing on a stream of auths from a point of sale
SELECT card,
MAX(amount) as max_amount,
TUMBLE_END(eventTimestamp, interval '5' minute) as ts,
lat,
lon
FROM auth
GROUP BY card, TUMBLE(eventTimestamp, interval '5' minute)
HAVING COUNT(*) > 4
@kgorman
kgorman / foo.sql
Created June 7, 2019 19:07
foo.sql
SELECT * FROM FOO ORDER BY 'baz' limit 9;
SELECT * FROM FOO ORDER BY BAZ;
@kgorman
kgorman / test.md
Last active January 24, 2019 20:14

hello world

this is a code snippet

  • a list item
  • another item
@kgorman
kgorman / brewery_example.py
Last active November 14, 2018 16:18
Example Python Producer - Eventador.io
#!/usr/bin/env python
from __future__ import print_function
import json
import os
import random
import time
import sys
from kafka import KafkaProducer
@kgorman
kgorman / apache-flink.rb
Last active December 19, 2017 16:33 — forked from thirteen37/apache-flink.rb
Apache Flink 1.4 Homebrew formula
@kgorman
kgorman / georoutes.py
Last active February 22, 2017 16:26
georoutes.py
def build_routes():
""" return a geojson object with flight paths over last day """
conn = database_connect()
cur = conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
output = cur.execute(
"""
SELECT DISTINCT(tail)
AS tail
FROM planedemo_routes
WHERE lat != ''
Jun 21 20:54:52 vapipeline01 kernel: [2239310.896998] Out of memory: Kill process 1056 (pipelinedb) score 506 or sacrifice child
Jun 21 20:54:52 vapipeline01 kernel: [2239310.903418] Killed process 1056 (pipelinedb) total-vm:12751636kB, anon-rss:8306604kB, file-rss:128kB
Jun 21 20:54:52 vapipeline01 pipeline[15284]: [342-1] LOG: autovacuum launcher process (PID 1056) was terminated by signal 9: Killed
Jun 21 20:54:52 vapipeline01 pipeline[15284]: [343-1] LOG: terminating any other active server processes
Jun 21 20:54:52 vapipeline01 pipeline[1060]: [295-1] WARNING: terminating connection because of crash of another server process
Jun 21 20:54:52 vapipeline01 pipeline[1191]: [294-1] WARNING: terminating connection because of crash of another server process
Jun 21 20:54:52 vapipeline01 pipeline[1059]: [310-1] WARNING: terminating connection because of crash of another server process
Jun 21 20:54:52 vapipeline01 pipeline[1162]: [294-1] WARNING: terminating connection because of crash of another server proc