Skip to content

Instantly share code, notes, and snippets.

View nZac's full-sized avatar

Nick Zaccardi nZac

View GitHub Profile
@nZac
nZac / openttd.cfg
Created February 18, 2024 02:14
OpenTTD Config
[version]
version_string = 13.4
version_number = 1D486D64
ini_version = 2
[network]
commands_per_frame = 2
max_commands_in_queue = 16
bytes_per_frame = 8
@nZac
nZac / r53-export-validation.py
Created November 14, 2023 04:25
Simple validation script for Route 53 record-set JSON outputs
"""Simple validation script for Route 53 record-set JSON outputs
Only validates some record types
aws route53 list-resource-record-sets --hosted-zone-id zone-id-old > old-dns.json
aws route53 list-resource-record-sets --hosted-zone-id zone-id-new > new-dns.json
"""
from __future__ import annotations
@nZac
nZac / .vimrc
Last active February 16, 2021 16:24 — forked from simonista/.vimrc
A basic .vimrc file that will serve as a good template on which to build.
" Don't try to be vi compatible
set nocompatible
" Helps force plugins to load correctly when it is turned back on below
filetype off
" Plugin Settings
let g:clang_library_path='/usr/lib/x86_64-linux-gnu/libclang-6.0.so.1'
" Turn on syntax highlighting
@nZac
nZac / tmux.conf
Last active December 18, 2020 14:49
.tmux.conf
# curl https://gist.githubusercontent.com/nZac/e200b656539b0aa311b579e25c258e36/raw > ~/.tmux.conf
# Prett Colors! Make sure iTerm2 is setup with "xterm-256color"
set -g default-terminal "screen-256color"
set -g terminal-overrides ""
set -g status-bg '#666666'
set -g status-fg '#aaaaaa'
set-option -g renumber-windows on
set -g update-environment "SSH_AUTH_SOCK"
@nZac
nZac / TempDropFKContraint.py
Last active November 26, 2020 20:21
Temporarily Drop a Foreign Key Constraint, Python, SQLAlchemy
class TempDropConstraint(object):
def __init__(self, table, column):
self.table = table
self.table_name = table.__tablename__
self.column = column
self.constraint = list(self.table.__table__.columns[column.name].foreign_keys)[0]
self.constraint_name = self.constraint.name
self.referred_table = self.constraint.column.table.name
@nZac
nZac / importdns.py
Created May 27, 2020 17:17
Convert R53 to TF
#!/usr/bin/env python3
import argparse
from typing import List, Optional
import dataclasses
import enum
INDENT = ' '
@nZac
nZac / example.py
Last active December 30, 2019 03:53
Simple Text Media Handler in Falcon
import falcon
import falcon.media
import falcon.testing
class TextHandler(falcon.media.BaseHandler):
def serialize(self, media, content_type):
return str(media).encode()
@nZac
nZac / api.py
Created May 19, 2019 22:23
Falcon SQLAlchemy Integration
import falcon
import sqlalchemy
from .middleware import SQLAlchemyMiddleware
from .db import session
def create_app(config: dict):
session.configure(bind=sqlalchemy.create_engine(config.get('DATABASE_URL', 'sqlite://')))
return falcon.API(middleware=[SQLAlchemyMiddleware(session)])
@nZac
nZac / sqlalchemy_debugger.py
Last active April 16, 2019 13:07
SQLAlchemy query to compiled SQL string
try:
import sqlparse.format as sqlformat
except ImportError:
def sqlformat(query, **kwargs):
"""Monkey patch sqlparse.format if package not installed"""
return query
def debug_query(query, engine):
"""Return a parametrized and formated sql query for debugging
@nZac
nZac / commands.sql
Created November 12, 2018 22:35
Permissioned Template Based PG Database Creation
---------------------------
-- SERVER LEVEL COMMANDS --
---------------------------
-- Create a new template database (we could alter template1 as well).
CREATE DATABASE "template2";
-- This avoids possibly droping the template table
UPDATE pg_database SET datistemplate = true WHERE datname='template2';