Skip to content

Instantly share code, notes, and snippets.

View HauptJ's full-sized avatar
:octocat:
Tschüss STL

Joshua Haupt HauptJ

:octocat:
Tschüss STL
View GitHub Profile
@HauptJ
HauptJ / config.rb
Created August 4, 2020 21:37
Config file for the Vagrantfile used to test Hyper-V and Virtualbox coexistence - https://gist.github.com/HauptJ/2e3e2413482591822fd2425c22fba20d
# VM Config
$ssh_user = "vagrant"
$vcpus = "4"
$vmem = "4096"
$centos8_box = "generic/centos8"
$centos8_box_ver = "3.0.10"
# Synced Folders
@HauptJ
HauptJ / Vagrantfile
Last active August 4, 2020 21:39
Vagrantfile to test Hyper-V and Virtualbox coexistence - Config: https://gist.github.com/HauptJ/5210bf544cd90eb8e8dd4a2c1624d294
# -*- mode: ruby -*-
# vi: set ft=ruby :
# NOTE: Variable overrides are in ./config.rb
require "yaml"
require "fileutils"
# Use a variable file for overrides:
CONFIG = File.expand_path("config.rb")
if File.exist?(CONFIG)
require CONFIG
@HauptJ
HauptJ / wordCount.py
Created June 26, 2020 17:14
Python Word Count using Dictionary
"""
Find repeating words within text file
return:
word and count
Sentence is here. Sentence two is here.
"""
def find_grants_cap(grantsArray, newBudget):
cap = float(0)
grantsArray.sort(reverse = True)
# pad the array with a zero at the end to cover the case where 0 <= cap <= grantsArray[i]
grantsArray.append(0)
# calculate the total amount we need to cut back to meet the reduced budget
surplus = sum(grantsArray) - newBudget
@HauptJ
HauptJ / bracketMatch.py
Last active June 24, 2020 20:27
bracketMatch
def bracket_match(text):
stack = []
for char in text:
if char == ")":
if stack:
if stack[-1] == "(":
stack.pop()
else:
@HauptJ
HauptJ / ansible.sh
Last active June 17, 2020 19:38
Vagrant Ansible self provisioning shell script for EL 8
#!/bin/bash -eux
pushd /tmp
sudo dnf -y install python3 git ansible
#sudo python3 -m pip install pyyaml ansible
pushd /tmp/ansible
import sys
import os
import pandas as pd
NARRATIVE = "Consumer complaint narrative"
inFile = str(sys.argv[1])
label = str(sys.argv[2])
outFile = label.replace(" ", "_")
@HauptJ
HauptJ / image.py
Created March 28, 2020 11:03
OVH API Re-Imaging Script
#!/usr/bin/env python3
import ovh
import json
import argparse
def reimage(ovhClient, ovhServerName, sshKeyName, hostName, ovhTemplateName, useDistribKernel=False):
@HauptJ
HauptJ / maxSubarraySum.py
Created March 14, 2020 21:04
Maximum Subarray Sum
class Solution:
# Dynamic Programming: Time: O(n) Space O(n)
def maxSubArrayDP(self, nums: List[int]) -> int:
if not nums:
return 0
maxSum = nums[0]
DP = [0]*len(nums) # DP will hold the max sum so far
@HauptJ
HauptJ / LinkedListPalindromeStack.py
Created March 14, 2020 16:10
LinkedList Palindrome - Stack
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def isPalindrome(self, head: ListNode) -> bool:
# low hanging fruit