Linux console program in Python, that scrolls binary numbers vertically in your terminal. Inspired by the movie: The Matrix
a screenshot:
in action:
the Code:
https://gist.github.com/4530348Linux console program in Python, that scrolls binary numbers vertically in your terminal. Inspired by the movie: The Matrix
a screenshot:
in action:
the Code:
https://gist.github.com/4530348PhantomJS is a headless WebKit with JavaScript API. It can be used for headless website testing.
PhantomJS has a lot of different uses. The interesting bit for me is to use PhantomJS as a lighter-weight replacement for a browser when running web acceptance tests. This enables faster testing, without a display or the overhead of full-browser startup/shutdown.
I write my web automation using Selenium WebDriver, in Python.
In future versions of PhantomJS, the GhostDriver component will be included.
GhostDriver is a pure JavaScript implementation of the WebDriver Wire Protocol for PhantomJS. It's a Remote WebDriver that uses PhantomJS as back-end.
So, Ghostdriver is the bridge we need to use Selenium WebDriver with Phantom.JS.
Since it is not available in the current PhantomJS release, you can try it yourself by compiling a special version of PhantomJS:
It wes pretty trvial to setup on Ubuntu (12.04):
$ sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev $ git clone git://github.com/ariya/phantomjs.git $ cd phantomjs $ git checkout 1.8 $ ./build.sh $ git remote add detro https://github.com/detro/phantomjs.git $ git fetch detro && git checkout -b detro-ghostdriver-dev remotes/detro/ghostdriver-dev $ ./build.sh
Then grab the `phantomjs` binary it produced (look inside `phantomjs/bin`). This is a self-contained executable, it can be moved to a different directory or another machine. Make sure it is located somewhere on your PATH, or declare it's location when creating your PhantomJS driver like the example below.
for these examples, `phantomjs` binary is located in same directory as test script.
Example: Python Using PhantomJS and Selenium WebDriver.
#!/usr/bin/env python
driver = webdriver.PhantomJS('./phantomjs')
# do webdriver stuff here
driver.quit()
Example: Python Unit Test Using PhantomJS and Selenium WebDriver.
#!/usr/bin/env python
import unittest
from selenium import webdriver
class TestUbuntuHomepage(unittest.TestCase):
def setUp(self):
self.driver = webdriver.PhantomJS('./phantomjs')
def testTitle(self):
self.driver.get('http://www.ubuntu.com/')
self.assertIn('Ubuntu', self.driver.title)
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main(verbosity=2)
resources:
(a small rant on asking answerable questions)
At a certain online QA/Testing Forum I regularly visit, the Selenium forum is one of the most active.
I continuously see newbie questions like: "How I do I learn Selenium?", with little or no other context given.
Then, helpful responders chime in with tangentially related answers. That's about as good as you can do, based on the lack of information given in the original post. This happens often and wastes significant brain activity in the responders, while generally giving no value to the OP or forum community.
So first... a clarification:
Selenium WebDriver is a system for automating browser interaction. It is accessed via programming library/API. If you want to use it without touching code, it is not possible (record/replay/export-madness via IDE aside). You can abstract away most of the programming aspects with higher level frameworks, but at that point you are no longer really dealing with Selenium anymore.
Here was my response to a recent forum example:
Question asked:
"Best way to start learning Selenium - I would like to know what is the best practice to start with Selenium for non programmers. Is there any books or ebooks?"
The responses compelled me to chime in with a rant:
To anyone on this thread looking for the "Best way to start learning Selenium":
Think of it this way:
Selenium (WebDriver) provides language bindings and a similar API for several programming languages. It gives you a programming library that can manipulate a browser and web elements/controls.
You can't "learn" a library for a programming language if you don't know the language itself (syntax, idioms, etc).
So the question shouldn't be: "How do I learn Selenium?", with no other information or context given.
Selenium should be used with either: the supported language that you are most comfortable with, or the language of the system under test you are working against.
If you are looking for information, be specific about what you want to learn. General understanding of the components that make up Selenium is great, but really, using the API's from any language is the best way to learn. If you specify a programming language along with your question, at least answers can be directed towards frameworks, code samples, documentation, tutorials, etc, that are *relevant* to you.
Diving into the main Selenium docs can be confusing at first, as it covers things from a general level... mixing in code samples from various languages.
So, my question to you: Which programming language are you going to use Selenium with? If you define that, someone can surely help point you in the right direction.
How are your programming skills? Which language do you want to learn in? If you know several, switching is trivial down the line, as the API's are similar between languages.
If you don't have skills in any Selenium supported programming language (java, c#, python, ruby, php, etc), then learn one of those before you even touch Selenium. If you have a language in mind, please phrase your question using that in context.
happy hacking,
-Corey
p.s. now go RTFM: http://seleniumhq.org/docs/
Here is a handy Python Timer class. It creates a context manager object, used for timing a block of code.
from timeit import default_timer
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
self.timer = default_timer
def __enter__(self):
self.start = self.timer()
return self
def __exit__(self, *args):
end = self.timer()
self.elapsed_secs = end - self.start
self.elapsed = self.elapsed_secs * 1000 # millisecs
if self.verbose:
print 'elapsed time: %f ms' % self.elapsed
To use the Timer (context manager object), invoke it using Python's `with` statement. The duration of the context (code inside your `with` block) will be timed. It uses the appropriate timer for your platform, via the `timeit` module.
Timer is used like this:
with Timer() as target:
# block of code goes here.
# result (elapsed time) is stored in `target` properties.
Example script:
timing a web request (HTTP GET), using the `requests` module.
#!/usr/bin/env python
import requests
from timer import Timer
url = 'https://github.com/timeline.json'
with Timer() as t:
r = requests.get(url)
print 'fetched %r in %.2f millisecs' % (url, t.elapsed)
Output:
fetched 'https://github.com/timeline.json' in 458.76 millisecs
`timer.py` in GitHub Gist form, with more examples:

In the past few years, mobile devices have turned into amazing little pocket computers. I'm blown away by the hardware (ARM) and software (Android) evolution.
For smartphone wireless service, I was a Verizon customer (USA) for the past decade. I've owned the flagship Droid series devices by Motorola since their first launch (currently running on the 4G LTE network). It started with a clunky original Droid, followed by a Droid X, and then the sleek Droid Razr... every year another generation of better, faster devices.
Device Specs:Motorola Droid - Nov 2009
Motorola Droid X - July 2010
Motorola Droid Razr - Nov 2011
However, my life with the Moto Droids is coming to an end. I just signed up with a new wireless carrier and pre-ordered a new Sammy GS3!:

Samsung Galaxy S3 - June 2012
I work from my apartment and listen to music or talk-radio nearly 24-hours a day (even at soft volume while I sleep). My home audio setup is pretty important to me.
Here is a description of the current rig for home listening:
The Gear:
The Content:
Streaming Radio Networks:
MP3 Collection:
Tablet interface (Logitech Squeezebox Controller):
Web interface (Logitech Media Server 7.7.2):
I made a new visualization. Have a look!
History of Python - Gource - development visualization (august 1990 - june 2012)
[HD video, encoded at 1080p. watch on YouTube in highest resolution possible.]
What is it?
This is a visualization of Python core development. It shows growth of the Python project's source code over time (August 1990 - June 2012). Nearly 22 years! The source code history and relations are displayed by Gource as an animated tree, tracking commits over time. Directories appear as branches with files as leaves. Developers can be seen working on the tree at the times they contributed to the Python project.
Video:
Rendered with Gource v0.37 on Ubuntu 12.04
Music:
Chris Zabriskie - The Life and Death of a Certain K Zabriskie Patriarch
Repository:
cpython 3.3.0 alpha, retrieved from mercurial on June 2 2012
for more visualizations and other videos, check out my YouTube channel.
SST version 0.2.1 has been released.
SST (selenium-simple-test) is a web test framework that uses Python to generate functional browser-based tests.
SST version 0.2.1 is on PyPI: http://pypi.python.org/pypi/sst
install or upgrade with:
pip install -U sst
Changelog: http://testutils.org/sst/changelog.html
SST Docs: http://testutils.org/sst
SST on Launchpad: https://launchpad.net/selenium-simple-test
SST downloads | (Jan 1 2012 - April 23 2012)
1600+ downloads from PyPI since initial release.