This file contains 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 concurrent.futures | |
from datetime import datetime, timedelta | |
import os | |
import json | |
def decorator_with_args(decorator): | |
"""A decorator for decorators, allowing them to be used with or without arguments.""" | |
def wrapper(*args, **kwargs): | |
if len(args) == 1 and callable(args[0]): | |
return decorator(args[0]) |
This file contains 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
from collections import UserDict | |
import re | |
import warnings | |
def to_snake_case(s): | |
return re.sub(r'(?<!^)(?=[A-Z])', '_', s).lower() | |
class NormalizedItem(UserDict): | |
field_names = {} | |
This file contains 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
function allVisibleElements(root=document.body){ | |
const iter = document.createNodeIterator(root, NodeFilter.SHOW_ELEMENT, { | |
acceptNode(e){ | |
if(e.offsetWidth && e.offsetHeight && e.getClientRects().length) | |
return NodeFilter.FILTER_ACCEPT | |
} | |
}) | |
const nodes = [] | |
let node; | |
while(node = iter.nextNode()) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=900, initial-scale=1.0"> | |
<title>JSON Tables</title> | |
<style> | |
table, th, td { | |
border-collapse: collapse; |
This file contains 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 re | |
def parse_timespan(str): | |
SECOND = 1000 | |
MINUTE = SECOND*60 | |
HOUR = MINUTE*60 | |
DAY = HOUR*24 | |
multiplier = { | |
'ms': 1, | |
's':SECOND, 'sec':SECOND, 'second':SECOND, 'seconds':SECOND, | |
'm':MINUTE, 'min':MINUTE, 'mins': MINUTE, 'minute': MINUTE, 'minutes':MINUTE, |
This file contains 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
def find_sessions(table, groupby_col, time_col, max_time_diff='P0DT0H30M0S'): | |
time_diff = table.groupby(groupby_col)[time_col].diff() | |
new_sessions = np.where(time_diff.isnull() | (time_diff > max_time_diff))[0] | |
sessions = pd.Series(dtype=np.float64, index=table.index) | |
sessions.iloc[new_sessions] = new_sessions | |
sessions = sessions.fillna(method='ffill').astype(int) | |
return sessions |
This file contains 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
def find_sub_networks(table, columns): | |
aliases = {} | |
networks = {} | |
n_networks = 0 | |
def get_network(item): | |
network = aliases.get(item) | |
while network in aliases: | |
network = aliases[network] | |
return network |
This file contains 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
def deserialize_dynamodb_object(raw): | |
def deserialize(val, dynamodb_type): | |
if dynamodb_type == 'NULL': | |
return None | |
elif dynamodb_type == 'N': | |
return float(val) if '.' in str(val) else int(val) | |
elif dynamodb_type == 'M': | |
return deserialize_dynamodb_object(val) | |
elif dynamodb_type == 'L': | |
return [deserialize_dynamodb_object(n) for n in val] |
This file contains 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
<script> | |
var custom_field_name = 'ecid'; | |
var mcmid = document.cookie.match(/MCMID%7C(\w+)%7C/); | |
var current_query = window.location.search; | |
if(!current_query.includes(custom_field_name) && mcmid){ | |
current_query += current_query ? '&' : '?'; | |
window.location.search = current_query+custom_field_name+'='+mcmid[1]; | |
} | |
</script> |
NewerOlder