Skip to content

Instantly share code, notes, and snippets.

View cgoldberg's full-sized avatar
☠️
¯\_(ツ)_/¯

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@cgoldberg
cgoldberg / selenium_webdriver_phantomjs.py
Created January 7, 2013 18:06
Python unit test using PhantomJS and Selenium WebDriver. Headless web acceptance testing.
#!/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
#!/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
@cgoldberg
cgoldberg / png_info.py
Last active December 11, 2015 20:59
utilities for analyzing PNG image files.
#!/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)
@cgoldberg
cgoldberg / tox.ini
Created February 11, 2013 15:01
Tox (Python) boilerplate config/ini file.
[tox]
envlist =
py26
py27
[testenv]
deps =
nose
commands =
{envpython} setup.py install
#!/usr/bin/env python
#
# Example using `concurrencytest`:
# https://github.com/cgoldberg/concurrencytest
import time
import unittest
from concurrencytest import ConcurrentTestSuite, fork_for_tests
#!/usr/bin/env python
#
# Example using `concurrencytest`:
# https://github.com/cgoldberg/concurrencytest
import unittest
from concurrencytest import ConcurrentTestSuite, fork_for_tests
@cgoldberg
cgoldberg / xbmc.sh
Created August 31, 2013 14:33
launch XBMC one one screen in fullscreen mode, in multi-monitor setup.
#!/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
@cgoldberg
cgoldberg / hamburger_bash_shell_prompt_ubuntu.txt
Last active December 22, 2015 11:38
hamburger bash shell-prompt
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 🍔 "
@cgoldberg
cgoldberg / gource-ubuntu-core-apps.sh
Last active December 28, 2015 14:39
Generate gource video out of bzr repositories for Ubuntu Touch Core Apps.
#!/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:
@cgoldberg
cgoldberg / grab-sessionid.py
Created May 11, 2015 16:17
grab session id from edX cookie
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: