Skip to content

Instantly share code, notes, and snippets.

View jrdmcgr's full-sized avatar

Jared McGuire jrdmcgr

  • Qgiv
  • Central Florida, USA
  • 12:44 (UTC -04:00)
View GitHub Profile
//
// How to Extend Validity
//
// Setup validity and get the private validation function.
$.validity.setup({debugPrivates: true})
var validate = $.validity.__private.validate
// Add our message
$.validity.messages.myCustomValidationMessage = 'You fail.'

This now works with the latest Selenium bindings. (pip install selenium)

from selenium import webdriver
driver = webdriver.Firefox() # or webdriver.Chrome()
driver.get('http://user:password@example.com')

The eqivalent with Splinter doesn't work.

from splinter import Browser
browser = Browser()
@jrdmcgr
jrdmcgr / concurrency-bench.py
Created February 14, 2013 19:13
Time some trivial work using various concurrency mechanisms.
""" Time some trivial work using various concurrency mechanisms. """
import time
from threading import Thread
from multiprocessing import Process
def timeit(f):
""" Time a function with this decorator. """
def timed(*args, **kw):
start_time = time.time()
#!/usr/bin/env python
concurrency_impl = 'gevent' # single process, single thread
##concurrency_impl = 'threading' # single process, multiple threads
##concurrency_impl = 'multiprocessing' # multiple processes
if concurrency_impl == 'gevent':
import gevent.monkey; gevent.monkey.patch_all()
import logging
import time
@jrdmcgr
jrdmcgr / LocalDateTime.py
Created November 5, 2012 14:58
timezone validator
class LocalDateTime(formencode.FancyValidator):
""" This class is a formencode validator that will localize a date-time.
By default python date-time objects don't have any time zone information
associated with them, but they provide abstract support for time zones.
The pytz module provides concrete timezones to use with date-time objects.
This class will ensure that all dates have a timezone associated with them.
It will wite dates to the DB with the UTC time zone; it will convert dates
read from the DB to the client's local time zone defined in their config