Skip to content

Instantly share code, notes, and snippets.

View dtaivpp's full-sized avatar

David Tippett dtaivpp

View GitHub Profile
posts = [
{
'Post': {
'title':'Other today post',
'date': 43750,
'claps': 200
}
},
{
'Post': {
class DiscordHandler(logging.Handler):
"""
Custom handler to send certain logs to Discord
"""
def __init__(self):
logging.Handler.__init__(self)
self.discordWebhook = DiscordWebhook(url=config.DISCORD_URL)
def emit(self, record):
"""
import random
from time import time
random.seed(time())
times = {'listComprehension': 0, 'append': 0, 'preAllocate': 0}
for i in range(0,100):
endRange = random.randint(100_000, 10_000_000)
startTime = time()
import random
from time import time
random.seed(time())
#### List Access Tests ####
times = {'colsAndRows': 0, 'rowsAndCols': 0}
def generateArray(size):
@dtaivpp
dtaivpp / iterate_the_filetree.py
Last active December 16, 2019 13:48
Iterate a directory looking for certain TypeScript and JavaScript files
import os
walk_dir = 'C:\\Directory\\ForWalking\\'
# If the file path contains these we dont want them
# eg. C:\\Directory\\ForWalking\\node_modules will be ignored
exclusions = ["node_modules", "SolutionFiles", ".bin", "Test"]
# Array to store all our file paths
file_paths = []
# Occurances will track each time an offensive bit of code is found
# Its format will be:
# File Path, Function, Num Occurances
occurances = []
# Methods that need to be update
nogos = [
".SetFocus(",
".IsValid(",
".Clear",
# Courtesy of https://stackabuse.com/sorting-algorithms-in-python/
def partition(nums, low, high):
# We select the middle element to be the pivot. Some implementations select
# the first element or the last element. Sometimes the median value becomes
# the pivot, or a random one. There are many more strategies that can be
# chosen or created.
pivot = nums[(low + high) // 2]
i = low - 1
j = high + 1
# Courtesy of https://stackabuse.com/sorting-algorithms-in-python/
def merge(left_list, right_list):
sorted_list = []
left_list_index = right_list_index = 0
# We use the list lengths often, so its handy to make variables
left_list_length, right_list_length = len(left_list), len(right_list)
for _ in range(left_list_length + right_list_length):
# Courtesy of https://stackabuse.com/sorting-algorithms-in-python/
def heapify(nums, heap_size, root_index):
# Assume the index of the largest element is the root index
largest = root_index
left_child = (2 * root_index) + 1
right_child = (2 * root_index) + 2
# If the left child of the root is a valid index, and the element is greater
# than the current largest element, then update the largest element
import random
from time import time
import numpy as np
import pandas as pd
# Initilize Random
random.seed(time())
#### List Tests ####