Skip to content

Instantly share code, notes, and snippets.

@jasonrdsouza
jasonrdsouza / sqliteSchemaDiagram.sql
Created March 23, 2024 15:30
SQLite Schema Diagram Generator
-- Generates a diagram of table schema relationships in
-- GraphViz DOT format (https://graphviz.org/doc/info/lang.html)
-- via a SQLite query
-- To run:
-- > sqlite3 path/to/database.db -init sqlite-schema-diagram.sql "" > schema.dot
-- > dot -Tsvg schema.dot > schema.svg
-- Fork of: https://gitlab.com/Screwtapello/sqlite-schema-diagram/
@jasonrdsouza
jasonrdsouza / declarative_migrator.py
Created May 3, 2022 21:35
Proof of Concept declarative schema migration script for SQLite
# coding: utf-8
"""Simple declarative schema migration for SQLite.
See <https://david.rothlis.net/declarative-schema-migration-for-sqlite>.
Author: William Manley <[email protected]>.
Copyright © 2019-2022 Stb-tester.com Ltd.
License: MIT.
"""
@jasonrdsouza
jasonrdsouza / expenses_appscript.js
Last active March 3, 2021 14:23
Google AppsScript script to automate splitting expenses and sending a monthly email requesting payment
/*
* Script to automate sending the monthly debt emails.
*/
var EMAIL_RECEPIENT = "[email protected]"
var COLUMNS = {
"date": 0,
"paid": 1,
"total": 2,
@jasonrdsouza
jasonrdsouza / compressFolder.go
Created February 27, 2021 16:29
Demonstration of how to compress a folder and all of its contents in Go
// Original source: https://github.com/mimoo/eureka/blob/master/folders.go
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"fmt"
"io"
"os"
@jasonrdsouza
jasonrdsouza / smart_connect.go
Last active February 27, 2021 16:23
Simple HTTP server to intelligently route and multiplex requests over a collection of backing network connections
// Small exploration into the ease of implementing an interface (and server) to abstract
// away the complexities of dealing with cumbersome and non-standardized network
// protocols.
//
// The resulting server exposes a simple HTTP API to clients, routing and forwarding
// their requests behind the scenes to a collection of raw network streams. The goal
// is to hide the underlying communication protocol and network multiplexing from
// clients, instead exposing a simple request/response API spoken in the lingua franca
// of the web.
//
@jasonrdsouza
jasonrdsouza / island_counter.py
Created April 24, 2020 21:36
Snippet to count contiguous islands in a grid
from collections import namedtuple
Node = namedtuple('Node', 'row col')
class IslandCounter:
def __init__(self, ocean_map):
self.map = ocean_map
self.max_row = len(ocean_map)
self.max_col = len(ocean_map[0])
@jasonrdsouza
jasonrdsouza / choose_winner.dart
Last active June 9, 2020 22:31
Dartpad Gist to Choose a Random Winner
import 'dart:math';
List<String> contestants = [
'Jason',
'Matt',
'Gabe',
'Ishan',
'Luis',
'Katie',
'Andrew',
@jasonrdsouza
jasonrdsouza / nest_thermostat_info.py
Created January 4, 2019 00:12
Snippet to pull thermostat info from the Nest API
import nest # https://pypi.org/project/python-nest/
import configparser
config = configparser.ConfigParser()
config.read('config.ini')
napi = nest.Nest(client_id=config['NEST']['client_id'], client_secret=config['NEST']['client_secret'], access_token_cache_file='token_cache')
if napi.authorization_required:
print('Go to ' + napi.authorize_url + ' to authorize, then enter PIN below')
@jasonrdsouza
jasonrdsouza / GroceryLogic.dart
Last active July 7, 2018 15:30
Grocery List App Brainstorm
/*
* The basic idea is to make a Grocery List progressive web app in Dartlang,
* using Firestore (https://firebase.google.com/docs/firestore/) as the backend.
* This pad is a quick sketch of the logic necessary to get the app working.
*/
enum Categories {
produce,
dairy,
household,
@jasonrdsouza
jasonrdsouza / aws-restarter.py
Created December 13, 2016 23:18
Helper script to quickly restart all of the instances of an app running in AWS under a load balancer
'''
Helper script to quickly restart all of the instances of a specific app
Assumes lots of things about the setup of the app (load balancer, ssh access, supervisor, etc.)
'''
import boto3
import subprocess
import argparse
def load_balancer_instances(name):