Skip to content

Instantly share code, notes, and snippets.

View mhornbacher's full-sized avatar
📈
Ramping Up

Menachem Hornbacher mhornbacher

📈
Ramping Up
View GitHub Profile
@mhornbacher
mhornbacher / cors.json
Created February 28, 2024 03:25
Update a Bucketer bucket in Heroku to allow CORS GET requests from any domain via Bash Script
{
"CORSRules": [
{
"AllowedOrigins": ["*"],
"AllowedHeaders": ["Authorization"],
"AllowedMethods": ["GET"],
"MaxAgeSeconds": 3000
}
]
}
@mhornbacher
mhornbacher / BaseViewEngine.cs
Last active March 8, 2021 20:17
WebForms and Razor View Engine Example
public class BaseViewEngine : RazorViewEngine
{
protected BaseViewEngine()
{
this.AreaViewLocationFormats = new string[4]
{
"~/Areas/{2}/Views/{1}/{0}.cshtml",
"~/Areas/{2}/Views/{1}/{0}.aspx",
"~/Areas/{2}/Views/{1}/{0}.ascx",
"~/Areas/{2}/Views/Shared/{0}.cshtml",
@mhornbacher
mhornbacher / hai_parser.py
Last active August 21, 2019 00:54
Parser for Healthcare_Associated_Infections.csv file
import csv
cities = dict()
counties = dict()
hosptials = dict()
with open('Healthcare_Associated_Infections.csv', 'r') as f:
reader = csv.reader(f, delimiter=",")
for i, row in enumerate(reader):
<#
.SYNOPSIS
Uses Win32_Fan class to return information about fans in a system.
.DESCRIPTION
This script first defines some functions to decode various
WMI attributed from binary to text. Then the script calls
Get-WmiObject to retrieve fan details, then formats that
information (using the functions defined at the top of the script.
.NOTES
@mhornbacher
mhornbacher / insertion_sort.rb
Created June 16, 2017 15:22
A ruby implementation of insertion sort
def insertionSort(input_list)
alist = input_list.clone # copy the array to sort its values. If this is not done it WILL sort in place (modify the list that was passed in)
1.upto(alist.size - 1) do |index| # from index 1 to the last do the following
current_value = alist[index] # the value of the item we are sorting
position = index # its index in the array
# while we are not at the begining of the array or the previous value is greater then this one (a.k.a it is in the wrong position)
while position > 0 && alist[position - 1] > current_value do
alist[position] = alist[position - 1] # move the previous item up one
position -= 1 # and move the index of our item back
@mhornbacher
mhornbacher / hanoi.rb
Created June 13, 2017 00:54
Towers of Hanoi
@counter = 0
def move(n, source, target, spare)
print('.') if @counter % 1000000 == 0 # let the user know that we are working for each 1,000,000th call
if n > 0
@counter += 1
move(n - 1, source, spare, target) # move it to the spare so it is out of the way
target << source.pop() # in place memory manipulation, equivilent to pass by refrence.
move(n - 1, spare, target, source) # move the n - 1 disks that we left on spare onto target
else
return [source, target, spare]
@mhornbacher
mhornbacher / build_edges.py
Created June 9, 2017 14:26
Takes a list of X, and Y coordinates and calculates the edge cost between all of them. X^2 runtime
def build_edges(x, y):
edges = []
for i in range(len(x)):
for k in range(len(x)):
dist = math.sqrt(((x[i] - x[k]) ** 2) + ((y[i] - y[k]) **2))
edges.append([i, k, dist])
return edges
@mhornbacher
mhornbacher / AddNumbers.java
Last active May 9, 2017 21:26
Help for Catastrophiq on Silicon Discourse
import java.util.Scanner;
import java.util.InputMismatchException;
import java.lang.Math;
public class AddNumbers {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("Please enter two numbers:");
try{
System.out.print("A: ");
@mhornbacher
mhornbacher / AccountManager.py
Created April 19, 2017 16:03
A basic python script for managing username password combos
import pickle, os.path, sys
filename = "Accounts.picklefile"
if os.path.isfile(filename):
fileload = open(filename, 'rb')
try:
database = pickle.load(fileload)
except EOFError:
print("Error reading file")
database = []
@mhornbacher
mhornbacher / MP3Editor.pyw
Created March 31, 2017 19:46
A small self contained python script to standardize with either .MP3 or .mp3. Replaces text in mp3 filenames as well
import os
from os.path import join
from tkinter import *
from tkinter import messagebox
def replace(subdir, string1, string2):
cwd = os.getcwd()
location = join(cwd, subdir)
for file in os.listdir(location):
os.rename(join(location, file), join(location, file.replace(string1, string2)))