Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@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 / 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 / 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 / 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 / facebook_tests.py
Created January 17, 2012 02:41
Facebook Python Selenium Tests
import base_tests
import dom_helper
import facebook_dom
class FacebookTests(base_tests.BaseTests):
@classmethod
def setUpClass(cls):
super(StartTests, cls).setUpClass()
StartTests.clear_data()
@pamelafox
pamelafox / facebook_dom.py
Created January 17, 2012 02:42
Facebook Selenium Dom Helper Functions
import dom_helper
import test_defaults
FBEMAIL = '#email'
FBPASS = '#pass'
FBLOGIN = 'input[name="login"]'
FBGRANT = 'input[name="grant_clicked"]'
class FacebookDom(dom_helper.DomHelper):
@pamelafox
pamelafox / _ie_warning.html
Created January 25, 2012 00:06
IE ChromeFrame conditional prompt and alert
<!--[if lt IE 7]>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>
// The conditional ensures that this code will only execute in IE,
// Therefore we can use the IE-specific attachEvent without worry
window.attachEvent("onload", function() {
CFInstall.check({
mode: "overlay"
});
@pamelafox
pamelafox / gist:1719238
Created February 1, 2012 20:52
Moving average calculation
// Calculate moving average
var averageData = [];
var lastValue = null;
var movingAverage = null;
for (var i = 0; i < dates.length; i++) {
var value = measurementData[i] || missingData[i];
if (!movingAverage) {
movingAverage = value;
} else {
movingAverage = ((value - movingAverage)/7) + movingAverage;
@pamelafox
pamelafox / bootstrap.datepicker.js
Created February 8, 2012 05:12
jQuery/Zepto Bootstrap Datepicker
/* ===========================================================
* bootstrap-datepicker.js v1.3.0
* http://twitter.github.com/bootstrap/javascript.html#datepicker
* ===========================================================
* Copyright 2011 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@pamelafox
pamelafox / datepicker.scss
Created February 8, 2012 05:49
Zepto Bootstrap Datepicker SASS
.datepicker {
background-color: $white;
border-color: #999;
border-color: rgba(0, 0, 0, 0.2);
border-style: solid;
border-width: 1px;
@include border-radius(4px);
@include box-shadow(0 2px 4px rgba(0,0,0,.2));
@include background-clip(padding-box);