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
#!/usr/bin/env python | |
import os | |
import os.path | |
import sys | |
from collections import namedtuple, defaultdict | |
ResultSpec = namedtuple('ResultSpec', ('subdir', 'file_filter', 'join')) | |
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 Foo(object): | |
def __init__(s, foo): | |
s.wrapped = foo | |
def __getattr__(s, attr): | |
target = attr | |
if attr.startswith('__') and not attr.endswith('__'): | |
target = '_{}{}'.format(s.wrapped.__class__.__name__, attr) | |
return getattr(s.wrapped, target) |
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
#!/usr/bin/env bash | |
wrap() { | |
local old_name="${1:?get fuct}" | |
local new_name="${2:?get fuct}" | |
_temp_function() { | |
echo "wrapping the old one!" | |
_old_function_call_placeholder param |
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
/* | |
Optimized potential-anagram identifier function. | |
Runs in O(N) time on the supplied string, with several o(N) optimizations as well. | |
Consumes at worst half of the supplied string's space in memory (additionally), plus overhead. | |
This algorithm uses two paths: a reusable array of integer values (it could just as well be a bitfield, | |
but that probably won't save any performance since memory has to be written in whole words anyway) | |
with a known, fixed size: it will store the first, most common, 512 characters of the alphabet and |
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
function testshit { | |
local testname="${1:?Test name needs to be first parameter bro}" | |
local url="${2:?URL needs to be second parameter bro}" | |
local regex="${3:?Regex needs to be third parameter bro}" | |
# Can do this multiple times if you want with different CURL args to e.g. test the headers/response code/body: | |
local curlout=$(curl -whatever "$url") | |
if echo "$curlout" | grep -P "$regex" >/dev/null; then | |
echo "$testname ($url): all good" | |
else | |
echo -e "$testname ($url): failed\nexpected to match: $regex\nInstead, got output:$curlout" |
NewerOlder