Skip to content

Instantly share code, notes, and snippets.

@autocracy
autocracy / gist:49f833a0329b7056e236d4531ff5a90b
Last active February 10, 2023 01:07
Example Terraform S3 bucket with KMS, courtesy of ChatGPT
provider "aws" {
region = "us-west-2"
}
resource "aws_s3_bucket" "example_bucket" {
bucket = "example-bucket"
versioning {
enabled = true
}
@autocracy
autocracy / gist:e8733116f38ed8e3cefa36814c9be642
Created September 4, 2020 07:05
Apache drill vpc flow logs
create table dfs.tmp.flow as select cast(version as integer) as version, account_id, interface_id, srcaddr, dstaddr, cast(srcport as integer) as srcport, cast(dstport as integer) as dstport, cast(protocol as int) as protocol, cast(packets as bigint) as packets, cast(bytes as bigint) as bytes, from_unixtime(cast(start as bigint)) as start, from_unixtime(cast(end as bigint)) as end, action, log_status, intstance_id, pkt_srcaddr, pkt_dstaddr from dfs.`Users/jferland/scratch/vpc_flow` where log_status = 'OK';
SRCS := $(wildcard *.gz)
OBJS := $(patsubst %.gz,%.zst,$(SRCS))
zstd: $(OBJS)
%.zst: %.gz
gunzip -c $< | zstd -9 -q -o $@
import sys
emotion = sys.argv[1]
if emotion == "rage":
output = " ".join([":rage%s:" % i for i in range(1,5)])
if emotion == "clap":
output = ":clap: " + \
" ".join([":clap::skin-tone-%s:" % i for i in range(2,7)])
if emotion == "time":
hours = [str(i) for i in ["12"] + list(range(1,12))]
faces = []
#pre-commit
for file in $(git diff --cached --name-only --diff-filter=ACM); do
if [[ $file =~ \.sls$ ]]
then $(git rev-parse --show-toplevel)/$GIT_DIR/hooks/check-jinja.py $file
fi
done
#check-jinja.py
#!/usr/bin/env python
from __future__ import print_function
# *** ERROR ***
#
# There is a templating error preventing this file from rendering correctly.
#
# This is most likely not due to a bug in Cobbler and is something you can fix.
#
# Look at the message below to see what things are causing problems.
#
# (1) Does the template file reference a $variable that is not defined?
# (2) is there a formatting error in a Cheetah directive?
import futures
import boto
region=foo
bucket=bar
c = boto.s3.connect_to_region(region)
b = c.get_bucket(bucket)
pool = futures.ThreadPoolExecutor(max_workers=5)
@autocracy
autocracy / gist:611fe3e2ae5147508846
Created July 15, 2015 18:14
Logging stops DB startup
2015-07-15 05:22:59
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode):
"Attach Listener" #1824 daemon prio=9 os_prio=0 tid=0x00007fa7dc425000 nid=0x37fa waiting on condition [0x0000000000000000]
java.lang.Thread.State: RUNNABLE
"RMI TCP Connection(29)-10.0.1.201" #1762 daemon prio=5 os_prio=0 tid=0x00007fa7dc1a7800 nid=0x34db runnable [0x00007fa459197000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
I'd say the median parking space in San Francisco runs about $300 per month, or $10 per day. At $3 million dollars rent, they'd need to store an average of 833 cars to get that income. At $57.25 + $140 in towing fees, they need to process roughly 60 cars per day just to make the rent. Of consideration, though is, is that a car towed for an unlicensed driver or driver with a suspended license is the vehicle is held for 30 days, so now they only need to process 2 of those per day. What's missing is information about how many cars per day they do process.
Now, while I don't know how much area they have I do know that they can't pack vehicles as efficiently as a regular lot, nor can they handle the in/out process as efficiently. Yet even with that in mind, something just seems wrong about it all.
EDIT 1: Every year, approx. 70,000 cars are towed, giving us an average of 191 vehicles processed per day. They auction roughly 200 vehicles per month (checking a few weeks of auctions from their site) with a recovery ra
import re
# Holy crap this library is so unoptimized ...
import spans
class longrange(spans.intrange):
type = long
class longrangeset(spans.intrangeset):
type = longrange