Skip to content

Instantly share code, notes, and snippets.

@jmaccabee
jmaccabee / pip_virtualenvs.sh
Last active October 19, 2016 16:41
Script to run Pip across multiple Virtual Environments
#!/bin/bash
######################################################################
# Useful script when you want to run `pip` in virtual environments #
# you have in a common directory with a provided Python package. #
# Note: Requires VirtualWrapper to be managing your environments #
# #
# Usage: #
# ./pip_virtualenvs.sh [-i | -u | -z] pkg_name [-a | -l] [env1 env2] #
# #
# Example: #
@jmaccabee
jmaccabee / XPath Cheat Sheet
Created October 10, 2018 23:21
Common XPath tips and tricks
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// Credit to the original author: https://gist.github.com/LeCoupa/8c305ec8c713aad07b14
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
@jmaccabee
jmaccabee / mixpanel_api_py3.py
Last active January 8, 2019 09:58
A Python3 compatible mixpanel_api client
import base64
import urllib.request, urllib.parse, urllib.error # for url encoding
import urllib.request, urllib.error, urllib.parse # for sending requests
from http.client import IncompleteRead
from ssl import SSLError
import io
import logging
import gzip
import shutil
import time
@jmaccabee
jmaccabee / regex_reference.md
Last active November 7, 2019 22:09
Regex Quick Reference

Regular Expression Quick Reference

Match pattern

Special characters

. ? + * ^ $ \ ( ) [ ] { } | Need to be escaped with a backslash () to match the actual character

  • Any other character matches itself

. Matches one of any character

(...) Groups elements into a single element (also captures contents)

@jmaccabee
jmaccabee / extract_json_from_javascript.py
Created January 24, 2020 16:48
A utility function for extracting the JSON blob from Javascript tag text in the DOM.
import json
import re
def extract_json(text):
maybe_match = re.search('({.*:.*})', text)
if maybe_match:
match = maybe_match.groups(1)[0]
return json.loads(match)
return {}