Skip to content

Instantly share code, notes, and snippets.

View bwicklund's full-sized avatar

Bryon Wicklund bwicklund

View GitHub Profile
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@bwicklund
bwicklund / postgres_queries_and_commands.sql
Last active May 2, 2019 16:26 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- Show all running querys
SELECT user, pid, application_name, query, age(clock_timestamp(), query_start), state
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- kill running query
SELECT pg_cancel_backend(procpid);
-- kill idle query
@bwicklund
bwicklund / s3_file_combine.py
Last active March 12, 2023 08:27
S3 file Concatenation/Combination. S3 Spark file merge.
import argparse
import boto3
import os
import threading
from fnmatch import fnmatch
# S3 multi-part upload parts must be larger than 5mb
MIN_S3_SIZE = 6000000
LOG_LEVEL = 'INFO'
@bwicklund
bwicklund / simple_python_state_machine.py
Created August 13, 2018 16:40
Simple Python State Machine
class InitializationError(Exception): pass
class StateMachine:
def __init__(self):
self.handlers = []
self.startState = None
self.endStates = []
def add_state(self, handler, end_state=0):
self.handlers.append(handler)
@bwicklund
bwicklund / csv_to_struct.rb
Last active December 12, 2018 22:47
Convert csv to json or ruby hash
require 'csv'
require 'json'
require 'pp'
if ARGV.length < 2
puts "usage: csv_to_struct.rb <in.csv> <out_name(no extension)> *[json|ruby] *symbolize_keys(bool)"
exit(1)
else
csv_file = ARGV[0]
output_file = ARGV[1].dup