Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Tschüss STL

Joshua Haupt HauptJ

:octocat:
Tschüss STL
View GitHub Profile
@HauptJ
HauptJ / config.rb
Created Aug 4, 2020
Config file for the Vagrantfile used to test Hyper-V and Virtualbox coexistence - https://gist.github.com/HauptJ/2e3e2413482591822fd2425c22fba20d
View config.rb
# 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 Aug 4, 2020
Vagrantfile to test Hyper-V and Virtualbox coexistence - Config: https://gist.github.com/HauptJ/5210bf544cd90eb8e8dd4a2c1624d294
View Vagrantfile
# -*- 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 Jun 26, 2020
Python Word Count using Dictionary
View wordCount.py
"""
Find repeating words within text file
return:
word and count
Sentence is here. Sentence two is here.
"""
View budgetCuts.py
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
View bracketMatch.py
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 Jun 17, 2020
Vagrant Ansible self provisioning shell script for EL 8
View ansible.sh
#!/bin/bash -eux
pushd /tmp
sudo dnf -y install python3 git ansible
#sudo python3 -m pip install pyyaml ansible
pushd /tmp/ansible
View label.py
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 Mar 28, 2020
OVH API Re-Imaging Script
View image.py
#!/usr/bin/env python3
import ovh
import json
import argparse
def reimage(ovhClient, ovhServerName, sshKeyName, hostName, ovhTemplateName, useDistribKernel=False):
@HauptJ
HauptJ / maxSubarraySum.py
Created Mar 14, 2020
Maximum Subarray Sum
View maxSubarraySum.py
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 Mar 14, 2020
LinkedList Palindrome - Stack
View LinkedListPalindromeStack.py
# 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