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
#!/usr/bin/env python | |
"""Python unit test using PhantomJS and Selenium WebDriver.""" | |
# requires: selenium python bindings, phantomjs 1.8+ | |
# | |
# if you have phantomjs installed and on your PATH, | |
# you can instantiate a PhantomJS WebDriver like this: | |
# | |
# from selenium import webdriver |
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
#!/usr/bin/env python | |
"""Selenium WebDriver - Browser Benchmark | |
run 10 iterations of simple local test case with each driver: | |
Firefox (webdriver) vs. Chrome (chromedriver) vs. PhantomJS (ghostdriver). | |
""" | |
import unittest |
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
#!/usr/bin/env python | |
import struct | |
def get_image_info(data): | |
if is_png(data): | |
w, h = struct.unpack('>LL', data[16:24]) | |
width = int(w) |
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
[tox] | |
envlist = | |
py26 | |
py27 | |
[testenv] | |
deps = | |
nose | |
commands = | |
{envpython} setup.py install |
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
#!/usr/bin/env python | |
# | |
# Example using `concurrencytest`: | |
# https://github.com/cgoldberg/concurrencytest | |
import time | |
import unittest | |
from concurrencytest import ConcurrentTestSuite, fork_for_tests |
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
#!/usr/bin/env python | |
# | |
# Example using `concurrencytest`: | |
# https://github.com/cgoldberg/concurrencytest | |
import unittest | |
from concurrencytest import ConcurrentTestSuite, fork_for_tests | |
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
#!/bin/bash | |
# Launch XBMC in windowed mode, then use wmctrl to remove the titlebar | |
# Select display 1 | |
DISPLAY=:0.0 | |
# Start XBMC without blocking this script | |
xbmc & | |
# Wait for the XBMC window to appear |
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
hamburger bash shell-prompt! | |
http://boingboing.net/2013/04/03/howto-turn-your-shell-prompt-i.html | |
to do this on Ubuntu: | |
- open terminal: | |
- $ sudo apt-get install ttf-ancient-fonts | |
- $ export PS1="\\u@\h \\w 🍔 " |
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
#!/usr/bin/env bash | |
# Generate gource video out of bzr repositories for Ubuntu Touch Core Apps. | |
# | |
# Corey Goldberg 2013 | |
# | |
# Usage: | |
# gource-ubuntu-core-apps.sh /path/to/repo1 /path/to/repo2 | |
# | |
# Example - generate video for all Ubuntu Touch Core Apps: |
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 login(email, password, base_url='https://courses.edx.org'): | |
"""Login via HTTP and parse sessionid from the cookie.""" | |
r = requests.get('{}/login'.format(base_url)) | |
csrf = r.cookies['csrftoken'] | |
payload = {'email': email, 'password': password} | |
cookies = {'csrftoken': csrf} | |
headers = {'referer': '{}/login'.format(base_url), 'X-CSRFToken': csrf} | |
r = requests.post('{}/user_api/v1/account/login_session/'.format(base_url), | |
data=payload, cookies=cookies, headers=headers) | |
try: |