Skip to content

Instantly share code, notes, and snippets.

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

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@cgoldberg
cgoldberg / timer.py
Created June 16, 2012 23:06
Python Timer Class - Context Manager for Timing Code Blocks
#!/usr/bin/env python
#
# Python Timer Class - Context Manager for Timing Code Blocks
# Corey Goldberg - 2012
#
from timeit import default_timer
@cgoldberg
cgoldberg / test_xvfb_selenium.py
Created November 20, 2012 14:07
headless Selenium WebDriver tests. Python unittest launching browser inside Xvfb.
#!/usr/bin/env python
#
# Corey Goldberg - 2012
#
# requires:
# * Xvfb
# * X Windows
# * xvfbwrapper (pip install xvfbwrapper)
#
@cgoldberg
cgoldberg / mailbox.py
Created November 26, 2012 18:33
MailBox class for processing IMAP email (Gmail from Python example)
#!/usr/bin/env python
"""MailBox class for processing IMAP email.
(To use with Gmail: enable IMAP access in your Google account settings)
usage with GMail:
import mailbox
@cgoldberg
cgoldberg / selenium_xvfb.py
Created November 27, 2012 00:09
Headless Selenium WebDriver with xvfbwrapper
#!/usr/bin/env python
from selenium import webdriver
from xvfbwrapper import Xvfb
# create a virtual display
vdisplay = Xvfb(width=1280, height=720)
vdisplay.start()
# do selenium stuff. look ma, no browser displayed!
@cgoldberg
cgoldberg / test_selenium_xvfb.py
Created November 27, 2012 00:12
Python xvfbwrapper example: Headless Selenium WebDriver Tests
#!/usr/bin/env python
from selenium import webdriver
from xvfbwrapper import Xvfb
import unittest
class TestHomepages(unittest.TestCase):
@cgoldberg
cgoldberg / merge_junit_results.py
Last active January 10, 2024 19:19
Merge multiple JUnit XML results files into a single results file.
#!/usr/bin/env python
"""Merge multiple JUnit XML results files into a single results file."""
# MIT License
#
# Copyright (c) 2012 Corey Goldberg
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@cgoldberg
cgoldberg / camel.pl
Created December 18, 2012 21:26
Perl Camel code - render 4 ascii camels from camel-styled source code.
#!/usr/bin/perl -w # camel code
use strict;
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda
@cgoldberg
cgoldberg / pypi_tarball.py
Created December 19, 2012 17:19
Download latest package release from PyPI.
#!/usr/bin/env python
import json
import os
import urllib
"""Download latest source release from PyPI.
@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
""""Create "The Matrix" of binary numbers scrolling vertically in your terminal.
original code adapted from juancarlospaco:
- http://ubuntuforums.org/showpost.php?p=10306676
Inspired by the movie: The Matrix
- Corey Goldberg (2013)
Requires: