Skip to content

Instantly share code, notes, and snippets.

View zacharybell's full-sized avatar

Zachary Bell zacharybell

View GitHub Profile
@zacharybell
zacharybell / website.tf
Created April 13, 2022 02:23
Google Cloud static site deployment with Terraform
resource "google_storage_bucket" "website" {
name = "${local.prefix}-sbt-website"
location = "US"
force_destroy = true
website {
main_page_suffix = "index.html"
}
}
@zacharybell
zacharybell / acm.tf
Created April 13, 2022 02:09
Full AWS static site deployment with terraform (includes cloudfront, route53, and ACM cert creation)
provider "aws" {
region = "us-east-1"
alias = "us_east_1"
}
resource "aws_acm_certificate" "cert" {
provider = aws.us_east_1
domain_name = var.site_domain
subject_alternative_names = ["*.${var.site_domain}"]
validation_method = "DNS"
@zacharybell
zacharybell / webpack.config.ts
Created April 13, 2022 02:04
Multi-Project Webpack with Typescript
import { Configuration } from 'webpack';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';
const electron: Configuration = {
target: 'electron-main',
entry: './src/main/index.ts',
output: {
filename: 'main.js',
from datetime import datetime
import re
long_date = r"(January|February|March|April|May|June|July|August|September|October|November|December) (0?[1-9]|1[0-9]|2[0-9]|30|31), (19|20)[0-9][0-9]"
short_date = r"(0?[1-9]|1[0-2])(-|\/)(0?[1-9]|1[0-9]|2[0-9]|30|31)\2(19|20)[0-9][0-9]"
extra_long_date = r"the (1st|2nd|3rd|[4-9]th|1[0-9]th|20th|21st|22nd|23rd|2[4-9]th|30th|31st) of (January|February|March|April|May|June|July|August|September|October|November|December), (19|20)[0-9][0-9]"
def convert_long_date(long_date):
return datetime.strptime(long_date, '%B %d, %Y').strftime('%Y-%-m-%-d')
@zacharybell
zacharybell / hogs.py
Last active April 10, 2018 00:16
Functions for processing images using HOGS
import numpy as np
def get_region(matrix, x1, x2, y1, y2):
return matrix[y1:y2,x1:x2]
def compute_gradients(matrix, axis):
gradients = np.zeros(shape=matrix.shape)
if axis == 0:
for i in range(matrix.shape[0] - 1):
gradients[i,:] = matrix[i+1,:] - matrix[i,:]
@zacharybell
zacharybell / cross_val.py
Last active March 20, 2018 07:24
CooperativeBewitchedMainframe created by zacharybell1 - https://repl.it/@zacharybell1/CooperativeBewitchedMainframe
def k_fold(X, y, estimator, k):
# assuming that the data is already shuffled
n = len(X)
s = n / k
score = 0
for i in range(k):
X_train = X[0:i*s] + X[(i+1)*s:-1]
y_train = y[0:i*s] + y[(i+1)*s:-1]
@zacharybell
zacharybell / mean_iou.py
Last active February 16, 2018 05:35
Intersection over union for two numpy arrays
import numpy as np
def mean_iou(labels, predictions, n_classes):
mean_iou = 0.0
seen_classes = 0
for c in range(n_classes):
labels_c = (labels == c)
pred_c = (predictions == c)
set shiftwidth=2
set tabstop=2
set smarttab
set autoindent
set smartindent
set number
highlight LineNr ctermfg=green