Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@pamelafox
pamelafox / selenium_dom.py
Created January 17, 2012 02:36
Python Selenium Dom Helper Functions
from selenium.common.exceptions import NoSuchElementException, TimeoutException
class DomHelper(object):
driver = None
waiter = None
def open_page(self, url):
self.driver.get(url)
@pamelafox
pamelafox / base_tests.py
Created January 17, 2012 02:29
Python Selenium Base TestCase
import unittest
import datetime
from sys import *
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import login_dom
class BaseTests(unittest.TestCase):
@pamelafox
pamelafox / phonegap-mock.js
Created January 9, 2012 23:40
Phonegap Mock Camera API getPicture
var navigator = window.navigator || {};
navigator.camera = (function() {
function resizeImage(img, maxHeight, maxWidth) {
var ratio = maxHeight/maxWidth;
if (img.height/img.width > ratio){
// height is the problem
if (img.height > maxHeight){
img.width = Math.round(img.width*(maxHeight/img.height));
img.height = maxHeight;
@pamelafox
pamelafox / touch.js
Created January 6, 2012 18:25
Touch/click events wrapper
ISTOUCHING = false;
function useTouchEvents() {
return isTouchDevice();
}
function triggerClick(dom) {
if (useTouchEvents()) {
dom.trigger('tap');
} else {
@pamelafox
pamelafox / superfeedr_client.py
Created December 26, 2011 22:02
SuperFeedr Python Client
import urllib
import logging
import base64
from httplib2 import Http
API_URL = 'http://superfeedr.com/hubbub'
MODE_SUBSCRIBE = 'subscribe'
MODE_UNSUBSCRIBE = 'unsubscribe'
MODE_RETRIEVE = 'retrieve'
@pamelafox
pamelafox / qunit_tests.py
Created December 26, 2011 19:07
Python Selenium QUnit Runner
import unittest
from sys import *
import os
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException, TimeoutException
class QUnitTests(unittest.TestCase):
driver = None
@pamelafox
pamelafox / phonegap.html
Created December 24, 2011 00:16
Phonegap Index (Jinja2)
<!doctype html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>everyday.io</title>
{% if g and g.debug %}
<link rel="stylesheet" href="css/colorslider.css" />
<link rel="stylesheet" href="css/dateinput.css" />
<link rel="stylesheet" href="css/bootstrap-1.3.0.min.css">
@pamelafox
pamelafox / render_index.py
Created December 24, 2011 00:12
PhoneGap Index Renderer (Jinja2)
import sys
sys.path.append('/Library/Python/2.7/site-packages')
from jinja2 import Environment, FileSystemLoader
if __name__ == "__main__":
env = Environment(loader=FileSystemLoader('application/templates/'))
template = env.get_template('phonegap/index.html')
print template.render(debug=False, mobile=True, native=True)
@pamelafox
pamelafox / log.html
Created December 24, 2011 00:10
Jinja2 Template Example (Everyday.io Log)
{% extends "yourbase.html" %}
{% block subheader %}
<div class="page-header">
<h1>
<span id="log-date">{{ title }}</span>
<a data-tooltip="Change the date" id="log-date-button" href="javascript:void(0);" style="margin-left: 10px;"><img src="img/calendar.png"></a>
</h1>
</div>
{% endblock %}
@pamelafox
pamelafox / Makefile
Created December 23, 2011 02:03
Android PhoneGap Workflow
MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)
BUILDDIR = ./.build
CLOSUREURL = http://closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http://yui.zenfs.com/releases/yuicompressor/yuicompressor-2.4.6.zip
YUIDIR = $(BUILDDIR)/yui