Skip to content

Instantly share code, notes, and snippets.

View hiddenist's full-sized avatar
:octocat:

Devin Elrose hiddenist

:octocat:
View GitHub Profile
@hiddenist
hiddenist / wpm.py
Created March 9, 2017 17:43
Measure WPM on free-form text
import time
def main():
print "Starting test now: begin typing free-form text."
print "Press enter to send. Send an empty message to exit."
avg = 0
tests = 0
try:
avg = wpm_test()
@hiddenist
hiddenist / strip_BOM.asp
Last active August 29, 2015 14:01
Function to detect and strip UTF-8 BOM from a string in ASP/VBScript
<%
Function stripBOM(ByVal content)
stripBOM = content
If Len(content) > 2 Then
If AscW(Mid(content, 1, 1)) = &HEF AND _
AscW(Mid(content, 2, 1)) = &HBB AND _
AscW(Mid(content, 3, 1)) = &HBF _
Then
stripBOM = Mid(content, 4)
@hiddenist
hiddenist / max_consecutive_sum_idx.py
Last active March 31, 2023 22:09
Calculate the maximum consecutive sum in a sequence of numbers, keeping track of the range producing the max. Fork of https://gist.github.com/hiddenist/6926596
# Finds the maximum consecutive sum in a list of numbers.
# Returns a three-value tuple containing:
# 0: Starting index of the max sum
# 1: Ending index of the max sum
# 2: The maximum sum
def max_consecutive_sum_idx(values):
if not values:
return None
maxval = None
@hiddenist
hiddenist / max_consecutive_sum.py
Last active December 25, 2015 05:39
Calculate the maximum consecutive sum in a sequence of numbers
# Return the maximum consecutive sum in a list of numbers
def max_consecutive_sum(values):
m = None
prev = None
for value in values:
cur = value + max(prev, 0)
m = max(cur, m)
prev = cur
return m