Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Blake VandeMerwe blakev

🎯
Focusing
View GitHub Profile
@blakev
blakev / r-pihole_top10.txt
Last active May 29, 2020
/r/pihole's Top 10 blocklist. 2020-04-07
View r-pihole_top10.txt
# Compilation of r/pihole User's Top-10 blocked domains.
ssl-bbcsmarttv.2cnt.net
tlx.3lift.com
graph.accountkit.com
app.adjust.com
ib.adnxs.com
fls-na.amazon.com
mads.amazon.com
unagi-na.amazon.com
View map_join_str.py
import timeit
print(timeit.Timer("'+'.join([str(x) for x in range(10000)])").repeat(3, 1000))
print(timeit.Timer("'+'.join(map(str, range(10000)))").repeat(3, 1000))
# [1.843802978983149, 1.838354193023406, 1.8291272450005636]
# [1.4447947760345414, 1.442527316045016, 1.4384180280612782]
@blakev
blakev / gist.py
Last active Sep 26, 2017
Are we running in a docker container? (Python)
View gist.py
import os
import subprocess
def in_container():
# type: () -> bool
""" Determines if we're running in an lxc/docker container. """
out = subprocess.check_output('cat /proc/1/sched', shell=True)
out = out.decode('utf-8').lower()
checks = [
'docker' in out,
@blakev
blakev / only_if.py
Created Jul 19, 2017
Dinking around with decorators
View only_if.py
import time
import json
import random
from functools import wraps
def only_if(condition, args_=None, *, pass_value=False, cache=False):
_fn = condition if callable(condition) else lambda: condition
if args_ is None:
@blakev
blakev / slack_handler.py
Last active Apr 3, 2020
Python logging handler for publishing to a slack channel.
View slack_handler.py
import os
import time
import json
import socket
import logging
from slacker import Slacker, Error as SlackerError
class SlackChannelHandler(logging.Handler):
@blakev
blakev / cc_extras.py
Created Nov 17, 2016
cookiecutter helper function that will replace |FILENAME,filter,filter,..| patterns with the contents of FILENAME, each line being applied with filters.
View cc_extras.py
import os
import re
RE_CONTENT = re.compile(r'(\|[\w\.\,]+\|)', re.I)
fns = {
'blockquote': lambda s: '> ' + s,
'code': lambda s: ' ' + s,
'comment': lambda s: '# {}'.format(s).rstrip() + '\n',
'list': lambda s: ' - ' + s
@blakev
blakev / scratch.py
Last active Jul 1, 2016
selenium scratch on dynamic page objects
View scratch.py
import string
from selenium.webdriver import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
CSS = By.CSS_SELECTOR
def split_case(n):
ret = []
@blakev
blakev / background_tasks.py
Last active Oct 19, 2017
Background tasks manager for gevent Greenlets
View background_tasks.py
#!/usr/bin/env python3
# ~*~ coding: utf-8 ~*~
#
# >>
# .. created: 5/20/16
# .. author: blake.vandemerwe
#
# LICENSE
# <<
View social counter totals
import os
import re
import sys
import json
import time
import requests
from bs4 import BeautifulSoup
from requests_oauthlib import OAuth1Session
from jinja2.environment import Environment
View keybase.md

Keybase proof

I hereby claim:

  • I am blakev on github.
  • I am blakev (https://keybase.io/blakev) on keybase.
  • I have a public key whose fingerprint is E3B1 28F0 8A95 AAE9 8848 9EDE 5F45 7ACC AE59 619A

To claim this, I am signing this object:

You can’t perform that action at this time.