Skip to content

Instantly share code, notes, and snippets.

@hmurraydavis
hmurraydavis / jsonbSQLAccessorGenerator.py
Created August 30, 2023 02:54
Divvy JSONB accessor generator
import json
import typing
import sys
'''
What this does:
Take in a representative jsonb blob and generate hierarchical sql accessors for
all its fields. You can use this with a querry like:
select twi.workflow_state, twi.workflow_type from temporal_workflow_indicies twi where twi.workflow_type = 'siteVisitWorkflow' limit 5;
to grab some representative JSON and then put it into Sigma with something like:
@hmurraydavis
hmurraydavis / jsonbSQLAccessorGenerator.py
Created August 30, 2023 02:54
jsonb SQL accessor generator
import json
import typing
import sys
'''
What this does:
Take in a representative jsonb blob and generate hierarchical sql accessors for all its fields.
Usage:
python3 jsonbSQLAccessorGenerator.py 'representative json blob'
@hmurraydavis
hmurraydavis / shelfTopForceCalc.py
Created February 20, 2019 02:28
Shelf Front Loaded Ceiling Force Math
from math import sin, atan, degrees
numberOfShelves = 13
shelfSpacing = 8.0 ##inches
shelfBaseOffsetFromFloor = 4.0 ##inches
l_s = 5.0 ## inches, length of the shelf before the pole to the books
poleHeight = 106.0 ## inches, 8' 8" in inches
sumM_b = 0
for shelfNumber in range(0,numberOfShelves):
@hmurraydavis
hmurraydavis / errorAnalysisColor.py
Last active June 23, 2016 04:51
Automated Error Analysis by Color
import cv2
import numpy as np
import pyscreenshot as ss
import matplotlib.pyplot as plt
im=ss.grab()
im = np.array( im.convert('RGB') )
numPixels = 1.0 * im.shape[0] * im.shape[1]
@hmurraydavis
hmurraydavis / computeRiskTime.py
Created March 23, 2016 04:00
Project Management Math
def actualTime(a, m, b):
te = (a + (4*m) + b )/6
return te
def variance(a, b):
var = ( (b-a)/6 )**2
return var
@hmurraydavis
hmurraydavis / cesarShift.py
Created January 23, 2016 21:24
Cesar Shift
message = raw_input('Message to code is: ')
shift_value = 1
newMessage = ''
for letter in message:
letter = ord(letter) + shift_value
newMessage = newMessage + chr(letter)
print 'Message is: ', newMessage
@hmurraydavis
hmurraydavis / barGraph.py
Created November 9, 2014 13:40
Python Bar Graph Base
import pylab as plt
plt.clf(); plt.close()
coNos = [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]
readingScores=[526,493,500,494,483,481,459,449,405]
mathScores = [562,496,487,492,466,483,468,421,387]
scienceScores=[542,501,502,514,470,488,478,447,415]
countries = ["Singapore",
"OECD\nAverage",
@hmurraydavis
hmurraydavis / calculateElasticModulusInstron.m
Last active August 29, 2015 14:00
Calculate the elastic modulus from raw CSV separated data from instron tests
function calculateElasticModulusInstron(x,y)
%%%% Compute the elastic modulus from experamental data.
%%%% INPUT VARIABLE DEF: x=load of sample from experamental data,
%%%% y=elongation of sample from experamental data.
%%prep matlab environment:
clc; clf;
%% Define length of the slope which you want to calculate Elastic Modulus for:
lengths1 = 300:1800;
@hmurraydavis
hmurraydavis / Thermo WAH10
Last active August 29, 2015 13:58
Thermo WAH 10 -- simulating a inner-vascular cooling system
%% Prepare environment
clear all; clc; clear figure;
%initialize vecctors for plotting:
Tgraph=[];
Wgraph=[];
%cycle through temperature range:
for T1=273.6:340.6
Tgraph=[Tgraph,T1];
@hmurraydavis
hmurraydavis / Bridge.py
Created January 24, 2014 04:33
phidgets bridge board sail bot
#! /usr/bin/python
"""Copyright 2011 Phidgets Inc.
This work is licensed under the Creative Commons Attribution 2.5 Canada License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/2.5/ca/
"""
__author__="Adam Stelmack"
__version__="2.1.8"
__date__ ="14-Jan-2011 2:29:14 PM"