- GitHub Staff
- https://tippybits.com
- @dtaivpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
posts = [ | |
{ | |
'Post': { | |
'title':'Other today post', | |
'date': 43750, | |
'claps': 200 | |
} | |
}, | |
{ | |
'Post': { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from time import time | |
random.seed(time()) | |
#### List Access Tests #### | |
times = {'colsAndRows': 0, 'rowsAndCols': 0} | |
def generateArray(size): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from time import time | |
import numpy as np | |
import pandas as pd | |
# Initilize Random | |
random.seed(time()) | |
#### List Tests #### |