Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@pamelafox
pamelafox / redirect.py
Created February 16, 2012 00:56
App Engine Redirect Handler
"""
Licensed under the Apache License, Version 2.0:
http://www.apache.org/licenses/LICENSE-2.0
"""
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
redirects = {
'/learning': 'http://blog.pamelafox.org',
@pamelafox
pamelafox / impressflow.js
Created February 15, 2012 23:37
impress.js: Attempt at flowchart generation
// Each DIV has data-parent="parentid" (except the top)
// Go through all steps, make hierarchy of parent to children
var childrenIds = {};
var topId;
$('.step').each(function() {
var id = $(this).attr('id');
var parentId = $(this).attr('data-parent');
if (!parentId) {
topId = id;
} else {
@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);
@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 / 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 / _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 / 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 / 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 / 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)