Skip to content

Instantly share code, notes, and snippets.

☠️
¯\_(ツ)_/¯

Corey Goldberg cgoldberg

☠️
¯\_(ツ)_/¯
View GitHub Profile
@cgoldberg
cgoldberg / timer.py
Created Jun 16, 2012
Python Timer Class - Context Manager for Timing Code Blocks
View timer.py
#!/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 Nov 20, 2012
headless Selenium WebDriver tests. Python unittest launching browser inside Xvfb.
View test_xvfb_selenium.py
#!/usr/bin/env python
#
# Corey Goldberg - 2012
#
# requires:
# * Xvfb
# * X Windows
# * xvfbwrapper (pip install xvfbwrapper)
#
@cgoldberg
cgoldberg / mailbox.py
Created Nov 26, 2012
MailBox class for processing IMAP email (Gmail from Python example)
View mailbox.py
#!/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 Nov 27, 2012
Headless Selenium WebDriver with xvfbwrapper
View selenium_xvfb.py
#!/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 Nov 27, 2012
Python xvfbwrapper example: Headless Selenium WebDriver Tests
View test_selenium_xvfb.py
#!/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 Jun 1, 2020
Merge multiple JUnit XML results files into a single results file.
View merge_junit_results.py
#!/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 Dec 18, 2012
Perl Camel code - render 4 ascii camels from camel-styled source code.
View camel.pl
#!/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 Dec 19, 2012
Download latest package release from PyPI.
View pypi_tarball.py
#!/usr/bin/env python
import json
import os
import urllib
"""Download latest source release from PyPI.
@cgoldberg
cgoldberg / selenium_webdriver_phantomjs.py
Created Jan 7, 2013
Python unit test using PhantomJS and Selenium WebDriver. Headless web acceptance testing.
View selenium_webdriver_phantomjs.py
#!/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
View matrix_terminal_python.py
""""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:
You can’t perform that action at this time.