Skip to content

Instantly share code, notes, and snippets.

View jamesbursa's full-sized avatar

James Bursa jamesbursa

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jamesbursa
jamesbursa / generate_data.pl
Created March 28, 2018 19:40
Dimensional modeling demo database (for PostgreSQL)
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
my @BRANDS = qw(Acme Best Costlo Deluxe Essential Fresh Great Harvest Indigo);
my @PRODUCTS = qw(Almonds Eggs Milk Apple Pear Orange Carrot Pepper Bread
Croissant Chocolate Cola Potato Cream Tomato Chips

Keybase proof

I hereby claim:

  • I am jamesbursa on github.
  • I am jamesbursa (https://keybase.io/jamesbursa) on keybase.
  • I have a public key ASAY_NkgZGEm-1yURb70bbVlYHX1pZrNV7FL47UuFoKHdgo

To claim this, I am signing this object:

@jamesbursa
jamesbursa / timezones.sql
Created March 19, 2020 21:56
PostgreSQL TIMESTAMPs and time zones
james=> SHOW TimeZone;
TimeZone
------------------
America/New_York
(1 row)
james=> CREATE TEMPORARY TABLE test (t TIMESTAMP WITH TIME ZONE);
CREATE TABLE
james=> INSERT INTO test VALUES ('2020-03-20 12:30:00 America/New_York'), ('2020-03-20 15:30:00 Europe/London');
INSERT 0 2
@jamesbursa
jamesbursa / example.sh
Created September 16, 2021 17:54
Bash functions and scripts
#!/usr/bin/env bash
#
# Example script structure.
#
set -o errexit -o pipefail
source "$(dirname "$0")/util"
main() {
...
@jamesbursa
jamesbursa / parse_events.py
Created December 2, 2022 16:10
Convert CloudTrail of ModifyDBInstance to Markdown.
#
# Convert CloudTrail of ModifyDBInstance to Markdown.
#
# Usage:
# aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=ModifyDBInstance >ModifyDBInstance_events.json
# python3 parse_events.py ModifyDBInstance_events.json
#
from dataclasses import dataclass
import json
@jamesbursa
jamesbursa / override_logging_levels.py
Created March 8, 2023 17:24
Override logging levels
def override_logging_levels():
"""Override default logging levels using settings in LOGGING_LEVEL environment variable.
The format is "name1=level,name2=level". For example:
LOGGING_LEVEL="requests=DEBUG,sqlalchemy=INFO"
"""
for override in os.environ.get("LOGGING_LEVEL", "").split(","):
if "=" not in override:
continue
@jamesbursa
jamesbursa / local.py
Created March 8, 2023 17:36
Configuration override as python
#
# Configuration for local development.
#
# If you need to make local changes, add them to override.py instead to avoid
# conflicts.
#
logging_level = {
"sqlalchemy": "INFO",
}
@jamesbursa
jamesbursa / labeler.yml
Created May 2, 2023 19:04
GitHub pull request labeler configuration
#
# Pull request label rules.
#
# Runs in action pull-request-labeler.yml.
#
# See https://github.com/marketplace/actions/labeler
#
# Labels for programming languages.
javascript: "**/*.js"