Jester
House of pamelafox

pamelafox's hand

The top 100 gists by star count
A
exportjson.js966

Google Spreadsheet JSON ExportHow-to at http://blog.pamelafox.org/2013/06/exporting-google-spreadsheet-as-json.html

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.

var FORMAT_ONELINE   = class="_tkStr_1klyn_166">'One-line';
var FORMAT_MULTILINE = class="_tkStr_1klyn_166">'Multi-line';
var FORMAT_PRETTY    = class="_tkStr_1klyn_166">'Pretty';

var LANGUAGE_JS      = class="_tkStr_1klyn_166">'JavaScript';
var LANGUAGE_PYTHON  = class="_tkStr_1klyn_166">'Python';

var STRUCTURE_LIST = class="_tkStr_1klyn_166">'List';
var STRUCTURE_HASH = class="_tkStr_1klyn_166">'Hash (keyed by "id" column)';
A
K
countryinfo.py149

Python list of country codes, names, continents, capitals, and pytz timezones

countries = [
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'Europe/Andorra'], class="_tkStr_1klyn_166">'code': class="_tkStr_1klyn_166">'AD', class="_tkStr_1klyn_166">'continent': class="_tkStr_1klyn_166">'Europe', class="_tkStr_1klyn_166">'name': class="_tkStr_1klyn_166">'Andorra', class="_tkStr_1klyn_166">'capital': class="_tkStr_1klyn_166">'Andorra la Vella'},
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'Asia/Kabul'], class="_tkStr_1klyn_166">'code': class="_tkStr_1klyn_166">'AF', class="_tkStr_1klyn_166">'continent': class="_tkStr_1klyn_166">'Asia', class="_tkStr_1klyn_166">'name': class="_tkStr_1klyn_166">'Afghanistan', class="_tkStr_1klyn_166">'capital': class="_tkStr_1klyn_166">'Kabul'},
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'America/Antigua'], class="_tkStr_1klyn_166">'code': class="_tkStr_1klyn_166">'AG', class="_tkStr_1klyn_166">'continent': class="_tkStr_1klyn_166">'North America', class="_tkStr_1klyn_166">'name': class="_tkStr_1klyn_166">'Antigua and Barbuda', class="_tkStr_1klyn_166">'capital': class="_tkStr_1klyn_166">"St. John's"},
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'Europe/Tirane'], class="_tkStr_1klyn_166">'code': class="_tkStr_1klyn_166">'AL', class="_tkStr_1klyn_166">'continent': class="_tkStr_1klyn_166">'Europe', class="_tkStr_1klyn_166">'name': class="_tkStr_1klyn_166">'Albania', class="_tkStr_1klyn_166">'capital': class="_tkStr_1klyn_166">'Tirana'},
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'Asia/Yerevan'], class="_tkStr_1klyn_166">'code': class="_tkStr_1klyn_166">'AM', class="_tkStr_1klyn_166">'continent': class="_tkStr_1klyn_166">'Asia', class="_tkStr_1klyn_166">'name': class="_tkStr_1klyn_166">'Armenia', class="_tkStr_1klyn_166">'capital': class="_tkStr_1klyn_166">'Yerevan'},
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'Africa/Luanda'], class="_tkStr_1klyn_166">'code': class="_tkStr_1klyn_166">'AO', class="_tkStr_1klyn_166">'continent': class="_tkStr_1klyn_166">'Africa', class="_tkStr_1klyn_166">'name': class="_tkStr_1klyn_166">'Angola', class="_tkStr_1klyn_166">'capital': class="_tkStr_1klyn_166">'Luanda'},
{class="_tkStr_1klyn_166">'timezones': [class="_tkStr_1klyn_166">'America/Argentina/Buenos_Aires', class="_tkStr_1klyn_166">'America/Argentina/Cordoba', class="_tkStr_1klyn_166">'America/Argentina/Jujuy', class="_tkStr_1klyn_166">'America/Argentina/Tucuman', class="_tkStr_1klyn_166">'America/Argentina/Catamarca', class="_tkStr_1klyn_166">'America/Argentina/La_Rioja', class="_tkStr_1klyn_166">'America/Argentina/San_Juan', class="_tkStr_1klyn_166">'America/Argentina/Mendoza', class="_tkStr_1klyn_166">'America/Argentina/Rio_Gallegos', '
K
Q
showspreadsheet.php51

PHP for parsing the JSON output a published Google spreadsheet and displaying columns from each row.

<?php

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Parsing this spreadsheet: https://spreadsheets.google.com/pub?key=0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc&hl=en&output=html
$url = class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json';
$file= file_get_contents($url);

$json = json_decode($file);
$rows = $json->{class="_tkStr_1klyn_166">'feed'}->{class="_tkStr_1klyn_166">'entry'};
foreach($rows as $row) {
  echo class="_tkStr_1klyn_166">'<p>';
  $title = $row->{class="_tkStr_1klyn_166">'gsx$title'}->{class="_tkStr_1klyn_166">'$t'};
  $author = $row->{class="_tkStr_1klyn_166">'gsx$author'}->{class="_tkStr_1klyn_166">'$t'};
Q
J
zepto-extras.js47

My Zepto Extras - more info @ http://blog.pamelafox.org/2011/11/porting-from-jquery-to-zepto.html

(function($) {
  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Used by dateinput
  $.expr = {class="_tkStr_1klyn_166">':': {}};

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Used by bootstrap
  $.support = {};

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Used by dateinput
  $.fn.clone = function(){
      var ret = $();
      this.each(function(){
          ret.push(this.cloneNode(true))
J
10
senderror.js43

Sending JS errors to server

function sendError(message, url, lineNum) { 
    var i;

    class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// First check the URL and line number of the error
    url = url || window.location.href;
    lineNum = lineNum || class="_tkStr_1klyn_166">'None';

    class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// If the error is from these 3rd party script URLs, we ignore
    class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// We could also just ignore errors from all scripts that aren't our own
    var scriptURLs = [
      class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Facebook flakiness
      class="_tkStr_1klyn_166">'https:class="_tkCom_1klyn_170">//graph.facebook.com',
10
9
tumlbr_template.html20

Twitter Bootstrap Tumblr Theme

<!doctype html>
<!--[if lt IE class="_tkNum_1klyn_175">7 ]> <html class=class="_tkStr_1klyn_166">"no-js ie6" lang=class="_tkStr_1klyn_166">"en"> <![endif]-->
<!--[if IE class="_tkNum_1klyn_175">7 ]>    <html class=class="_tkStr_1klyn_166">"no-js ie7" lang=class="_tkStr_1klyn_166">"en"> <![endif]-->
<!--[if IE class="_tkNum_1klyn_175">8 ]>    <html class=class="_tkStr_1klyn_166">"no-js ie8" lang=class="_tkStr_1klyn_166">"en"> <![endif]-->
<!--[if (gte IE class="_tkNum_1klyn_175">9)|!(IE)]><!--> <html class=class="_tkStr_1klyn_166">"no-js" lang=class="_tkStr_1klyn_166">"en" xmlns:fb=class="_tkStr_1klyn_166">"http:class="_tkCom_1klyn_170class="_tkStr_1klyn_166">">//www.facebook.com/class="_tkNum_1klyn_175">2008/fbml" xmlns:og=class="_tkStr_1klyn_166">"http://ogp.me/ns#"> <!--<![endif]-->
  <head>
    <meta charset=class="_tkStr_1klyn_166">"utf-class="_tkNum_1klyn_175">8">
    <meta http-equiv=class="_tkStr_1klyn_166">"X-UA-Compatible" content=class="_tkStr_1klyn_166">"IE=edge,chrome=class="_tkNum_1klyn_175">1">
    <meta name=class="_tkStr_1klyn_166">'description'  content=class="_tkStr_1klyn_166">'{MetaDescription}'>
    <meta name=class="_tkStr_1klyn_166">"viewport" content=class="_tkStr_1klyn_166">"width=device-width, initial-scale=class="_tkNum_1klyn_175">1.0">
    <meta http-equiv=class="_tkStr_1klyn_166">"X-UA-Compatible" content=class="_tkStr_1klyn_166">"chrome=class="_tkNum_1klyn_175">1">
    <link rel=class="_tkStr_1klyn_166">"stylesheet" media=class="_tkStr_1klyn_166">"screen" href=class="_tkStr_1klyn_166">"http:class="_tkCom_1klyn_170class="_tkStr_1klyn_166">">//twitter.github.com/bootstrap/assets/css/bootstrap.css" />
9
8
util.js17

JavaScript Utility Libraries (Scroll down!)

var ED = ED || {};

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Utility functions

ED.util = (function() {

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Data structure functions

  function each(object, callback) {
    if (object === null) return;
    if (object instanceof Array) {
      for (var i = class="_tkNum_1klyn_175">0, item; i < object.length; i++) {
8
7
browser.js17

Browser banner warning

(function(wndw) {
  var Browsers, OS, Platform, Versions, browser_name, browser_version, os, platform;
  Versions = {
    Firefox: /firefox\/([\d\w\.\-]+)/i,
    IE: /msie\s([\d\.]+[\d])/i,
    Chrome: /chrome\/([\d\w\.\-]+)/i,
    Safari: /version\/([\d\w\.\-]+)/i,
    Ps3: /([\d\w\.\-]+)\)\s*$/i,
    Psp: /([\d\w\.\-]+)\)?\s*$/i
  };
  Browsers = {
    Konqueror: /konqueror/i,
7
6
ajax-exercises.txt16

AJAX Exercises

Exercise: Nutrition Facts

    Create an empty webpage.
    Download nutrition.xml from https:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//gist.github.com/class="_tkNum_1klyn_175">3000322 and place in your project folder.
    Use AJAX via jQuery or JS API to fetch the file into the page.
    Create a table. For each <food> in the XML file, create a row in the table with the food name and nutritional facts - serving size, calories, carbs.
    Bonus: Use the tablesorter jQuery plugin to make the table sortable by the nutritional facts.

Exercise: Lady Gaga News

    Create an empty webpage.
    Download the RSS feed at http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//www.ladygaga.com/feeds/artist/content/ and store it in your project folder.
6
5
selenium_dom.py12

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)

    def reload_page(self):
        self.driver.refresh()
5
4
view.html12

Google Maps AutoComplete for Profile Location Field

<div class=class="_tkStr_1klyn_166">"control-group">
   <label class=class="_tkStr_1klyn_166">"control-label">Location</label>
   <div class=class="_tkStr_1klyn_166">"controls">
     <input name=class="_tkStr_1klyn_166">"location" type=class="_tkStr_1klyn_166">"text" placeholder=class="_tkStr_1klyn_166">"City, State, Country" value=class="_tkStr_1klyn_166">""> 
     <input name=class="_tkStr_1klyn_166">"location_city" type=class="_tkStr_1klyn_166">"hidden" value=class="_tkStr_1klyn_166">"">
     <input name=class="_tkStr_1klyn_166">"location_state" type=class="_tkStr_1klyn_166">"hidden" value=class="_tkStr_1klyn_166">"">
     <input name=class="_tkStr_1klyn_166">"location_country" type=class="_tkStr_1klyn_166">"hidden" value=class="_tkStr_1klyn_166">"">
     <input name=class="_tkStr_1klyn_166">"location_lat" type=class="_tkStr_1klyn_166">"hidden">
     <input name=class="_tkStr_1klyn_166">"location_lng" type=class="_tkStr_1klyn_166">"hidden">
    </div>
</div>
4
3
email_logger.py10

Email Logging for App Engine

#!/usr/bin/env python
#
# based on XMPPLoggingHandler, Copyright class="_tkNum_1klyn_175">2011 Calvin Rien,
# based on ExceptionRecordHandler, Copyright class="_tkNum_1klyn_175">2007 Google Inc.
#
# Licensed under the Apache License, Version class="_tkNum_1klyn_175">2.0 (the class="_tkStr_1klyn_166">"License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//www.apache.org/licenses/LICENSE-class="_tkNum_1klyn_175">2.0
#
# Unless required by applicable law or agreed to in writing, software
3
2
personalize.js10

Javascript grammatical personalization library

/**
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * A function that takes a template and grammatical options (class="_tkStr_1klyn_166">'gender', class="_tkStr_1klyn_166">'person', class="_tkStr_1klyn_166">'name') and returns the computed string.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * See below for examples.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * See wikipedia for more on grammar: 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * http://en.wikipedia.org/wiki/English_personal_pronouns
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * http://en.wikipedia.org/wiki/Grammatical_conjugation
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> */
function personalize(template, options) {
  var GENDERS = [class="_tkStr_1klyn_166">'neutral', class="_tkStr_1klyn_166">'female', class="_tkStr_1klyn_166">'male'];
  var PERSONS = [class="_tkStr_1klyn_166">'first', class="_tkStr_1klyn_166">'second', class="_tkStr_1klyn_166">'third'];
2
A
phonegap-photofetcher.js10

PhoneGap Convert Photo File URI to Data URI

function getPhoto() {
  navigator.camera.getPicture(onPhotoSuccess, onPhotoFail, 
    {quality: class="_tkNum_1klyn_175">70,  targetWidth: class="_tkNum_1klyn_175">500, targetHeight: class="_tkNum_1klyn_175">500,
     sourceType: navigator.camera.SourceType.PHOTOLIBRARY,
     destinationType: navigator.camera.DestinationType.FILE_URI,
    });
}

function onPhotoSuccess(imageUri) {
  var $img = $(class="_tkStr_1klyn_166">'<img/>');
  $img.attr(class="_tkStr_1klyn_166">'src', imageUri);
  $img.css({position: class="_tkStr_1klyn_166">'absolute', left: class="_tkStr_1klyn_166">'0px', top: class="_tkStr_1klyn_166">'-999999em', maxWidth: class="_tkStr_1klyn_166">'none', width: class="_tkStr_1klyn_166">'auto', height: class="_tkStr_1klyn_166">'auto'});
A
K
usermodel.py9

SimpleGeo Timezone Calculation on Python App Engine

class User(db.Model):
  location      = db.StringProperty()
  timezone      = db.StringProperty(default=class="_tkStr_1klyn_166">'America/Los_Angeles')

  # Do this once per user
  def calculate_timezone(self):
    from simplegeo import Client
    client = Client(class="_tkStr_1klyn_166">'oauth key', class="_tkStr_1klyn_166">'oauth secret SHH')
    response = client.context.get_context_by_address(self.location)
    for feature in response[class="_tkStr_1klyn_166">'features']:
      if feature[class="_tkStr_1klyn_166">'classifiers'][class="_tkNum_1klyn_175">0][class="_tkStr_1klyn_166">'category'] == class="_tkStr_1klyn_166">'Time Zone':
        timezone = feature[class="_tkStr_1klyn_166">'name']
K
Q
views.py9

CORS on Python/Flask

from flask import request, make_response,

def any_response(data):
  ALLOWED = [class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//localhost:class="_tkNum_1klyn_175">8888']
  response = make_response(data)
  origin = request.headers[class="_tkStr_1klyn_166">'Origin']
  if origin in ALLOWED:
    response.headers[class="_tkStr_1klyn_166">'Access-Control-Allow-Origin'] = origin
  return response
Q
J
selenium_page.py9

Selenium Utility Funcs

from selenium.common.exceptions import NoSuchElementException, TimeoutException, WebDriverException


class SeleniumPage(object):
    driver = None
    waiter = None

    def open_page(self, url):
        self.driver.get(url)

    def reload_page(self):
        self.driver.refresh()
J
10
autoresizer.js9

TextArea AutoResizer (Bootstrap jQuery/Zepto Plugin)


var AutoResizer = function (textArea, options) {
  var self = this;

  this.$textArea = $(textArea);
  this.minHeight = this.$textArea.height();

  this.options = $.extend({}, $.fn.autoResizer.defaults, options)

  this.$shadowArea = $(class="_tkStr_1klyn_166">'<div></div>').css({
      position: class="_tkStr_1klyn_166">'absolute',
      top: -class="_tkNum_1klyn_175">10000,
10
9
catalog_test.js8

Coursera catalog view test

describe(class="_tkStr_1klyn_166">'catalogyBody', function() {

  var chai        = require(class="_tkStr_1klyn_166">'chai');
  var path        = require(class="_tkStr_1klyn_166">'path');
  var env         = require(path.join(testDir, class="_tkStr_1klyn_166">'lib', class="_tkStr_1klyn_166">'environment'));
  var requirejs   = env.requirejs(staticDir);
  var sinon       = requirejs(class="_tkStr_1klyn_166">'js/lib/sinon');
  var fs          = require(class="_tkStr_1klyn_166">'fs');
  var server;
  var router;

  describe(class="_tkStr_1klyn_166">'catalog list', function(){
9
8
send.js7

CORS XHR (jQuery/Flask)

  function sendData(url, data, onSuccess, onError) {

    $.ajax({
        url: url,
        type: class="_tkStr_1klyn_166">'POST',
        data: data,
        dataType: class="_tkStr_1klyn_166">'json',
        xhrFields: {
          withCredentials: true
        },
        success: function(responseJSON) {
          onSuccess(processJSON(responseJSON));
8
7
twitter-bootstrap.scss7

Bootstrap Android Overrides

body.android {
  .modal {
    @include box-shadow(none);
    @include background-clip(border-box);
    @include border-radius(0px);
    border: 1px solid black;
  }
  .alert {
    @include border-radius(0px);
    text-shadow: none;
  }
  .nav-pills {
7
6
geonames.py7

Geonames Python wrapper

import sys
import urllib
import urllib2
import json
import logging


class GeonamesError(Exception):
    
    def __init__(self, status):
        Exception.__init__(self, status)        # Exception is an old-school class
        self.status = status
6
5
Makefile6

JS/CSS Compressor Makefile

# Javascript/CSS Compressor Makefile
# Original by Benjamin class="_tkStr_1klyn_166">"balupton" Lupton (MIT Licenced)
# Modified by Pamela Fox

MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)

BUILDDIR = ./.build

CLOSUREURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
5
4
Makefile6

Closure/YUI/JsHint Makefile

# Makefile for JS/CSS:
# Uses Closure for JS compiling, YUI for CSS compiling, and JsHint for code quality checking

MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)

BUILDDIR = ./.build

CLOSUREURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//yui.zenfs.com/releases/yuicompressor/yuicompressor-class="_tkNum_1klyn_175">2.4.class="_tkNum_1klyn_175">6.zip
4
3
bootstrap.datepicker.js6

jQuery/Zepto Bootstrap Datepicker

/* ===========================================================
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * bootstrap-datepicker.js v1.class="_tkNum_1klyn_175">3.0
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * http://twitter.github.com/bootstrap/javascript.html#datepicker
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * ===========================================================
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Copyright class="_tkNum_1klyn_175">2011 Twitter, Inc.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Licensed under the Apache License, Version class="_tkNum_1klyn_175">2.0 (the class="_tkStr_1klyn_166">"License");
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * you may not use this file except in compliance with the License.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * You may obtain a copy of the License at
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * http://www.apache.org/licenses/LICENSE-class="_tkNum_1klyn_175">2.0
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
3
2
gistfile1.py5

Sendgrid Python Web API example

import urllib2, urllib
import logging

def send_mail_sendgrid(from, to, subject, body):
  base_url = class="_tkStr_1klyn_166">'https:class="_tkCom_1klyn_170">//sendgrid.com/api/mail.send.json'
  params = {
    class="_tkStr_1klyn_166">'api_user': class="_tkStr_1klyn_166">'you@you.com',
    class="_tkStr_1klyn_166">'api_key': class="_tkStr_1klyn_166">'yourpassword',
    class="_tkStr_1klyn_166">'from': from,
    class="_tkStr_1klyn_166">'to': to,
    class="_tkStr_1klyn_166">'subject':  subject,
    class="_tkStr_1klyn_166">'text': body
2
A
withings.py5

Withings Python OAuth Wrapper

# -*- coding: utf-class="_tkNum_1klyn_175">8 -*-
# Based on https:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//github.com/ikasamah/withings-garmin/blob/master/withings.py

import urllib
from datetime import datetime
import urlparse
import oauth2 as oauth

try:
    import json
except ImportError:
    import simplejson as json
A
K
_ie_warning.html5

IE ChromeFrame conditional prompt and alert

    <!--[if lt IE class="_tkNum_1klyn_175">7]>
    <script type=class="_tkStr_1klyn_166">"text/javascript" 
   src=class="_tkStr_1klyn_166">"http:class="_tkCom_1klyn_170class="_tkStr_1klyn_166">">//ajax.googleapis.com/ajax/libs/chrome-frame/class="_tkNum_1klyn_175">1/CFInstall.min.js"></script>
    <script>
     class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// The conditional ensures that this code will only execute in IE,
     class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Therefore we can use the IE-specific attachEvent without worry
     window.attachEvent(class="_tkStr_1klyn_166">"onload", function() {
       CFInstall.check({
         mode: class="_tkStr_1klyn_166">"overlay"
       });
     });
    </script>
K
Q
datepicker.scss4

Zepto Bootstrap Datepicker SASS


.datepicker {
    background-color: $white;
    border-color: #class="_tkNum_1klyn_175">999;
    border-color: rgba(class="_tkNum_1klyn_175">0, class="_tkNum_1klyn_175">0, class="_tkNum_1klyn_175">0, class="_tkNum_1klyn_175">0.2);
    border-style: solid;
    border-width: 1px;
    @include border-radius(4px);
    @include box-shadow(class="_tkNum_1klyn_175">0 2px 4px rgba(class="_tkNum_1klyn_175">0,class="_tkNum_1klyn_175">0,class="_tkNum_1klyn_175">0,.class="_tkNum_1klyn_175">2));
    @include background-clip(padding-box);
    display: none;
    position: absolute;
Q
J
touch.js4

Touch Events

 dom.each(function() {
        $(this).unbind(class="_tkStr_1klyn_166">'tap', callback);
        $(this).bind(class="_tkStr_1klyn_166">'tap', callback);

        $(this).bind(class="_tkStr_1klyn_166">'touchstart', function(e) {
          e.preventDefault();

          var item = e.currentTarget;
          if (ISTOUCHING) return;
          item.moved = false;
          ISTOUCHING = true;
          item.startX = e.touches[class="_tkNum_1klyn_175">0].pageX;
J
10
README.md4

Instagram Python API Reference

python-instagram
======
A Python client for the Instagram REST and Search APIs

Installation
-----
pip install python-instagram

Requires
-----
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">  * httplib2
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">  * simplejson
10
9
grunt.js4

Grunt for a CSS/JS WebApp

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">/*global module:false*/

module.exports = function(grunt) {

  var CSS_DIR   = class="_tkStr_1klyn_166">'src/css/';
  var JS_DIR    = class="_tkStr_1klyn_166">'src/js/';
  var BUILD_DIR = class="_tkStr_1klyn_166">'../build/';

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Project configuration.
  grunt.initConfig({
    lint: {
      files: [JS_DIR + class="_tkStr_1klyn_166">'appclass="_tkCom_1klyn_170">/**/*.js']
9
8
yahoogeocoder.py4

YahooGeocoder

import urllib
import settings
try:
	import json
except ImportError:
	import simplejson as json


class YahooException(Exception): 
	pass 

8
7
focus.js4

Hack for Android focus() on PhoneGap

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// From Lindsey Simon
/**
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * This is a hack to make text input focus work in Android/PhoneGap
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * where calling el.focus() doesn't actually have the blinking cursor
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * effect = scumbag.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * @param {Zepto} $el A zepto element.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> */
ws.focus = function($el) {
  var el = $el.get(class="_tkNum_1klyn_175">0);
  el.focus();
  el.setSelectionRange && el.setSelectionRange(class="_tkNum_1klyn_175">0, class="_tkNum_1klyn_175">0);
};
7
6
newtalk.html3

Calculating timezone from city/country

<!DOCTYPE html> 
<html"> 
  <head>
    <script src=class="_tkStr_1klyn_166">"/static/js/jquery.min.js"></script> 
    <script type=class="_tkStr_1klyn_166">"text/javascript" src=class="_tkStr_1klyn_166">"http:class="_tkCom_1klyn_170class="_tkStr_1klyn_166">">//maps.google.com/maps/api/js?sensor=false"></script> 
  </head> 
  <body>
 
  <h2 class=class="_tkStr_1klyn_166">"headline">New Talk</h2> 
 
  <form id=class="_tkStr_1klyn_166">"talkform-form" method=class="_tkStr_1klyn_166">"post" action=class="_tkStr_1klyn_166">"/admin/talks/add"> 
 
6
5
jsonexport.js3

JSON Export Apps Script

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Exports current sheet as JSON and displays in message box.
function exportJSON() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  var rowsData = getRowsData(sheet);
  ss.msgBox(Utilities.jsonStringify(rowsData));
}

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// getRowsData iterates row by row in the input range and returns an array of objects.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Each object contains all the data for a given row, indexed by its normalized column name.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Arguments:
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//   - sheet: the sheet object that contains the data to be processed
5
4
qunit_tests.py3

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
    waiter = None
    failed = False
4
3
phonegap-mock.js3

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){
         class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// height is the problem
        if (img.height > maxHeight){
          img.width = Math.round(img.width*(maxHeight/img.height));
          img.height = maxHeight;
        }
    } else {
3
2
redirect.py3

App Engine Redirect Handler

class="_tkStr_1klyn_166">"""
 Licensed under the Apache License, Version class="_tkNum_1klyn_175">2.0:
 http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//www.apache.org/licenses/LICENSE-class="_tkNum_1klyn_175">2.0
class="_tkStr_1klyn_166">"""
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app


redirects = {
 class="_tkStr_1klyn_166">'/learning': class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//blog.pamelafox.org',
 class="_tkStr_1klyn_166">'/learning/reusing-html-css-js.html': class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//blog.pamelafox.org/class="_tkNum_1klyn_175">2011/class="_tkNum_1klyn_175">12/reusing-htmlcssjs-across-web-mobile.html',
 class="_tkStr_1klyn_166">'/learning/using-oauth-apis-appengine.html': class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//blog.pamelafox.org/class="_tkNum_1klyn_175">2011/class="_tkNum_1klyn_175">12/using-class="_tkNum_1klyn_175">3-legged-oauth-apis-with-flask.html',
2
A
Completely Static App2

For App Engine

application: oliverfoxmurals
version: class="_tkNum_1klyn_175">1
runtime: python
api_version: class="_tkNum_1klyn_175">1

handlers:
- url: /
  static_files: static/index.html
  upload: static/index.html
  
- url: /
  static_dir: static/
A
K
friendsearch.html2

Facebook API + jQuery Autosuggest

<!doctype html> 
<head> 
  <link rel=class="_tkStr_1klyn_166">"stylesheet" href=class="_tkStr_1klyn_166">"/css/style.css"> 
<body> 

  <input class=class="_tkStr_1klyn_166">"friend-search"></input> 
  <div id=class="_tkStr_1klyn_166">"fb-root"></div> 
 
  <script>window.jQuery || document.write(class="_tkStr_1klyn_166">"<script src='/js/libs/jquery-class="_tkNum_1klyn_175">1.5.class="_tkNum_1klyn_175">1.min.js'>\x3C/script>")</script> 
  <script src=class="_tkStr_1klyn_166">"/js/jquery.autosuggest.js"></script> 
  <script>
window.fbAsyncInit = function() {
K
Q
models.py2

Using SendGrid Incoming API with Python Flask

# Setup datastore model for storing mail
class ParsedMail(db.Model):
  from_address   = db.StringProperty()
  to_address     = db.StringProperty()
  text           = db.TextProperty()
  subject        = db.StringProperty()
Q
J
gistfile1.js2

Sending JS errors to server

window.onerror = function(message, url, line_num) {

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Standard error information
  var error = class="_tkStr_1klyn_166">'\n JS Error: ' + message + class="_tkStr_1klyn_166">' from ' + url + class="_tkStr_1klyn_166">':' + line_num;
  error += class="_tkStr_1klyn_166">'\n URL: ' + document.URL;
  
  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// User agent info, using https://github.com/caseyohara/user-agent
  var user_agent = new UserAgent();
  error += class="_tkStr_1klyn_166">'\n Browser: ' + user_agent.browser_name + class="_tkStr_1klyn_166">' ' + user_agent.browser_version + class="_tkStr_1klyn_166">' | OS: ' + user_agent.os + class="_tkStr_1klyn_166">' | Platform: ' + user_agent.platform;

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// User information - I find it useful to know who's logged in, so I can contact them for more info. Modify for your own use.
  if (USER_INFO) error += class="_tkStr_1klyn_166">'\n User: ' + USER_INFO.email + class="_tkStr_1klyn_166">' http:class="_tkCom_1klyn_170">//' + window.location.host + class="_tkStr_1klyn_166">'/user/' + USER_INFO.id; 
J
10
phonegap.html2

PhoneGap Timing Template

<!doctype html>
<html>
 <head>
  <meta name=class="_tkStr_1klyn_166">"viewport" content=class="_tkStr_1klyn_166">"initial-scale=class="_tkNum_1klyn_175">1.0, user-scalable=no, width=device-width" />
  <title>PhoneGap App</title>
  <script>
  var timedEvents = [];
  function timeEvent(name) {
    timedEvents.push({class="_tkStr_1klyn_166">'name': name || class="_tkStr_1klyn_166">'unnamed', time: Date.now()});
  }

  function showTimedEvents() {
10
9
button.html2

Changing button states (Bootstrap)

<button class=class="_tkStr_1klyn_166">"btn save-button primary" type=class="_tkStr_1klyn_166">"submit" data-startmsg=class="_tkStr_1klyn_166">"Save" data-loadingmsg=class="_tkStr_1klyn_166">"Saving..." data-successmsg=class="_tkStr_1klyn_166">"Saved!">Save</button>
9
8
superfeedr_client.py2

SuperFeedr Python Client

import urllib
import logging
import base64
from httplib2 import Http

API_URL = class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//superfeedr.com/hubbub'
MODE_SUBSCRIBE   = class="_tkStr_1klyn_166">'subscribe'
MODE_UNSUBSCRIBE = class="_tkStr_1klyn_166">'unsubscribe'    
MODE_RETRIEVE    = class="_tkStr_1klyn_166">'retrieve'

class SuperFeedrClient(object):
8
7
impressflow.js2

impress.js: Attempt at flowchart generation

 class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Each DIV has data-parent=class="_tkStr_1klyn_166">"parentid" (except the top)
 class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Go through all steps, make hierarchy of parent to children
 var childrenIds = {};
 var topId;
 $(class="_tkStr_1klyn_166">'.step').each(function() {
  var id = $(this).attr(class="_tkStr_1klyn_166">'id');
  var parentId = $(this).attr(class="_tkStr_1klyn_166">'data-parent');
  if (!parentId) { 
    topId = id;
  } else {
    if (!childrenIds[parentId]) {
      childrenIds[parentId] = [];
7
6
queue.yaml2

Geocoding with named task queue parameters on App Engine

queue:
- name: geocoding
  rate: class="_tkNum_1klyn_175">1/m
  retry_parameters:
    task_retry_limit: class="_tkNum_1klyn_175">60
    task_age_limit:   3d
    min_backoff_seconds: class="_tkNum_1klyn_175">120
6
5
form.html2

Functions for showing form save messages and errors

<form id=class="_tkStr_1klyn_166">"coursera-form" action=class="_tkStr_1klyn_166">"/api/save" enctype=class="_tkStr_1klyn_166">"multipart/form-data" method=class="_tkStr_1klyn_166">"POST" class=class="_tkStr_1klyn_166">"form-horizontal">
      <!-- form inputs here -->

     <div class=class="_tkStr_1klyn_166">"form-actions"><button type=class="_tkStr_1klyn_166">"submit" data-default-message=class="_tkStr_1klyn_166">"Save Changes" data-inflight-message=class="_tkStr_1klyn_166">"Saving..." data-success-message=class="_tkStr_1klyn_166">"Saved!" class=class="_tkStr_1klyn_166">"coursera-save-button btn btn-primary" disabled=class="_tkStr_1klyn_166">"disabled">Saved!</button></div>

</form>
5
4
header.html2

Handlebars Design Prototyping

<html>
<head>
  <style>
    .w100percent {
    }
    .w1280px {
    }
    .w900px {
    }
    .w768px {
    }
    .w480px {
4
3
visibleimages.js2

Load Visible Images

  function loadVisibleImages() {
    var placeholders = {
      class="_tkStr_1klyn_166">'meal': class="_tkStr_1klyn_166">'img/meal.png',
      class="_tkStr_1klyn_166">'avatar': class="_tkStr_1klyn_166">'img/blankpic.png'
    };

    $(class="_tkStr_1klyn_166">'img').each(function() {
      var $img = $(this);
      var realUrl = $img.attr(class="_tkStr_1klyn_166">'data-src');
      if (!realUrl) return;

      class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// If the image is visible and in view, try to load the real image.
3
2
greasemonkey-exercises.txt2

GreaseMonkey Exercises

GreaseMonkey

    Read this tutorial to learn how to make GreaseMonkey scripts for Firefox, you should have a basic script by the end.
    Read this article to learn how to get them working in Chrome and check yours works.


Amazon Linker
In this exercise, you’ll make a GreaseMonkey script that will run on Amazon product pages for movies and TV shows (e.g., The Matrix), and add a link to your favorite review site, like Rotten Tomatoes or MetaCritic. The steps:

    Make sure your script only runs on Amazon URLs.
    Verify that the page is in the class="_tkStr_1klyn_166">"Movies & TV" department.
    Extract the movieclass="_tkStr_1klyn_166">'s title from the page. Watch out for extra information in () and [] that isn't part of the title (e.g., the entry for class="_tkStr_1klyn_166">"Batman Begins" is actually class="_tkStr_1klyn_166">"Batman Begins [Blu-ray] (class="_tkNum_1klyn_175">2005)").
2
A
googl.py1

Shortening URLS using goo.gl

import cgi
import urllib, urllib2
import logging

from django.utils import simplejson

class Googl():
  def __init__(self, api_key):
    self.api_key = api_key
    self.base_url = class="_tkStr_1klyn_166">'https:class="_tkCom_1klyn_170">//www.googleapis.com/urlshortener/v1/url?key=%s' % self.api_key

  def shorten(self, long_url):
A
K
models.py1

App Engine Photo Upload (with BlobStore)

from __future__ import with_statement
from google.appengine.ext import db, blobstore
from google.appengine.api import memcache, files, images

class Photo(db.Model):
  created         = db.DateTimeProperty(auto_now_add=True)
  updated         = db.DateTimeProperty(auto_now=True)
  blob_key        = blobstore.BlobReferenceProperty()
  url             = db.StringProperty()
  thumbnail_url   = db.StringProperty()

  def upload_blob(self, file):
K
Q
gistfile1.txt1

Click/touchstart wrapper

function addClickHandler(dom, callback, logThis) {

    if (useTouchEvents()) {
      dom.each(function() {
        $(this).unbind(class="_tkStr_1klyn_166">'tap', callback);
        $(this).bind(class="_tkStr_1klyn_166">'tap', callback);

        $(this).bind(class="_tkStr_1klyn_166">'touchstart', function(e) {
          var item = e.currentTarget;
          if (ISTOUCHING) return;
          item.moved = false;
          ISTOUCHING = true;
Q
J
Makefile1

Android PhoneGap Workflow

MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)

BUILDDIR = ./.build

CLOSUREURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//yui.zenfs.com/releases/yuicompressor/yuicompressor-class="_tkNum_1klyn_175">2.4.class="_tkNum_1klyn_175">6.zip
YUIDIR = $(BUILDDIR)/yui
YUIFILE = $(YUIDIR)/yuicompressor-class="_tkNum_1klyn_175">2.4.class="_tkNum_1klyn_175">6/build/yuicompressor-class="_tkNum_1klyn_175">2.4.class="_tkNum_1klyn_175">6.jar
JSHINTURL = https:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//github.com/jshint/jshint/zipball/master
J
10
render_index.py1

PhoneGap Index Renderer (Jinja2)

import sys

sys.path.append(class="_tkStr_1klyn_166">'/Library/Python/class="_tkNum_1klyn_175">2.7/site-packages')

from jinja2 import Environment, FileSystemLoader

if __name__ == class="_tkStr_1klyn_166">"__main__":
  env = Environment(loader=FileSystemLoader(class="_tkStr_1klyn_166">'application/templates/'))
  template = env.get_template(class="_tkStr_1klyn_166">'phonegap/index.html')
  print template.render(debug=False, mobile=True, native=True)
10
9
phonegap.html1

Phonegap Index (Jinja2)

<!doctype html>
<html>
 <head>
  <meta name=class="_tkStr_1klyn_166">"viewport" content=class="_tkStr_1klyn_166">"initial-scale=class="_tkNum_1klyn_175">1.0, user-scalable=no, width=device-width" />
  <meta name=class="_tkStr_1klyn_166">"apple-mobile-web-app-capable" content=class="_tkStr_1klyn_166">"yes" />
  <title>everyday.io</title>
  {% if g and g.debug %}
  <link rel=class="_tkStr_1klyn_166">"stylesheet" href=class="_tkStr_1klyn_166">"css/colorslider.css" />
  <link rel=class="_tkStr_1klyn_166">"stylesheet" href=class="_tkStr_1klyn_166">"css/dateinput.css" />
  <link rel=class="_tkStr_1klyn_166">"stylesheet" href=class="_tkStr_1klyn_166">"css/bootstrap-class="_tkNum_1klyn_175">1.3.class="_tkNum_1klyn_175">0.min.css">
  <link rel=class="_tkStr_1klyn_166">"stylesheet" href=class="_tkStr_1klyn_166">"css/phonegap.css" />
  {% else %}
9
8
touch.js1

Touch/click events wrapper

  ISTOUCHING = false;

  function useTouchEvents() {
    return isTouchDevice();
  }

  function triggerClick(dom) {
    if (useTouchEvents()) {
      dom.trigger(class="_tkStr_1klyn_166">'tap');
    } else {
      dom.trigger(class="_tkStr_1klyn_166">'click');
    }
8
7
base_tests.py1

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):
    driver = None
    waiter = None
7
6
fancybox.diff1

Zepto + FancyBox Diffs

diff --git a/application/static/js/libs/jquery.fancybox.js b/application/static/js/libs/jquery.fancybox.js
index be77275..c1d74b7 class="_tkNum_1klyn_175">100755
--- a/application/static/js/libs/jquery.fancybox.js
+++ b/application/static/js/libs/jquery.fancybox.js
@@ -class="_tkNum_1klyn_175">359,class="_tkNum_1klyn_175">7 +class="_tkNum_1klyn_175">359,class="_tkNum_1klyn_175">6 @@
 							this.style.visibility = class="_tkStr_1klyn_166">'inherit';
 						});
 					}
-
 					overlay.show();
 				}
 			} else {
6
5
zepto.js1

Zepto Port (Bootstrap-friendly, Plugin-friendly, etc)

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//     Zepto.js
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//     (c) class="_tkNum_1klyn_175">2010, class="_tkNum_1klyn_175">2011 Thomas Fuchs
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//     Zepto.js may be freely distributed under the MIT license.

(function(undefined){
  if (String.prototype.trim === undefined) class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// fix for iOS class="_tkNum_1klyn_175">3.2
    String.prototype.trim = function(){ return this.replace(/^\s+/, class="_tkStr_1klyn_166">'').replace(/\s+$/, class="_tkStr_1klyn_166">'') };

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// For iOS class="_tkNum_1klyn_175">3.x
  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
  if (Array.prototype.reduce === undefined)
    Array.prototype.reduce = function(fun){
5
4
hearty.user.js1

TxJS Hearty User Extension

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Also requires jQuery pasted in the top in Chrome

function loadHearts() {
	$(class="_tkStr_1klyn_166">'#speakers').hide();
	$(class="_tkStr_1klyn_166">'#scene').hide();
	
	$(class="_tkStr_1klyn_166">'#schedule td').each(function() { 
		var $talkCell = $(this);
		var rateLink = $talkCell.find(class="_tkStr_1klyn_166">'a');
		if (!rateLink.length) return;
		
		var id = rateLink.attr(class="_tkStr_1klyn_166">'href').split(class="_tkStr_1klyn_166">'/t/')[class="_tkNum_1klyn_175">1];
4
3
nutrition.xml1

Sample XML: Foods

<?xml version=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">1.0"?>
<nutrition>
<daily-values>
	<total-fat units=class="_tkStr_1klyn_166">"g">class="_tkNum_1klyn_175">65</total-fat>
	<saturated-fat units=class="_tkStr_1klyn_166">"g">class="_tkNum_1klyn_175">20</saturated-fat>
	<cholesterol units=class="_tkStr_1klyn_166">"mg">class="_tkNum_1klyn_175">300</cholesterol>
	<sodium units=class="_tkStr_1klyn_166">"mg">class="_tkNum_1klyn_175">2400</sodium>
	<carb units=class="_tkStr_1klyn_166">"g">class="_tkNum_1klyn_175">300</carb>
	<fiber units=class="_tkStr_1klyn_166">"g">class="_tkNum_1klyn_175">25</fiber>
	<protein units=class="_tkStr_1klyn_166">"g">class="_tkNum_1klyn_175">50</protein>
</daily-values>
<food>
3
2
thirdparties.js1

isDefined

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// isDefined(window, class="_tkStr_1klyn_166">'google');
  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// isDefined(window, class="_tkStr_1klyn_166">'google.maps.places'); 
  var isDefined = function(parent, name) {
      var parts   = name.split(class="_tkStr_1klyn_166">'.');
      var part    = parts.shift();
      var cur     = parent;

      while (part) {
        if (cur[part]) {
            cur = cur[part];
            part = parts.shift();
        } else {
2
A
project.txt1

JavaScript Data Visualization Project

Project: JavaScript Data Visualization

The purpose of this project is to find some interesting data, display that data in JS, give users a way to do calculations on it, and visualize it using graphics libraries and/or APIs.

    Create a folder for the project.
    Initialize a git repository for the project and create a Github repo for it, so that you can push commits to the remote Github repo. Commit for each stage of the project (or even more often than that, if you’d like)
        See slides: Git
    Find an interesting dataset in some sort of text format (XML, JSON, CSV, etc). Store the dataset in your project folder. Truncate it to a reasonable length if it’s very long (i.e. class="_tkNum_1klyn_175">1000 rows). Some possible sources are:
        https:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//explore.data.gov/
        http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//www.usgovxml.com/
        http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//geocommons.com/
    Create an empty webpage and load the dataset into your webpage using an AJAX or JSONP request.
A
K
player.js1

Changing Playback of HTML5 Video

    this.isSetSpeedEnabled = function() {
        if(typeof(this.mediaElement) === class="_tkStr_1klyn_166">'object'
                && this.mediaElement !== null
                && typeof(this.mediaElement.playbackRate) === class="_tkStr_1klyn_166">'number'
                && this.mediaElement.playbackRate > class="_tkNum_1klyn_175">0){
            return true;
        }
        else{
            return false;
        } 
    }
K
Q
gistfile1.txt1

Detect and change playbackRate


    /** function set_speed(speed)
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">      * Set the video speed
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">      *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">      * @param double speed - target speed
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">      *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">      * @return void
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">      */
    this.is_set_speed_enabled = function(){
        if(typeof(this.mediaelement_media) === class="_tkStr_1klyn_166">'object'
                && this.mediaelement_media !== null
                && typeof(this.mediaelement_media.playbackRate) === class="_tkStr_1klyn_166">'number'
Q
J
linkify.js1

linkify


  function linkifyText(string){
    if (string) {
      string = string.replace(
        /((https?\:\/\/)|(www\.))(\S+)(\w{class="_tkNum_1klyn_175">2,class="_tkNum_1klyn_175">4})(:[class="_tkNum_1klyn_175">0-class="_tkNum_1klyn_175">9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,
        function(url){
            var full_url = url;
            if (!full_url.match(class="_tkStr_1klyn_166">'^https?:\/\/')) {
                full_url = class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//' + full_url;
            }
            return class="_tkStr_1klyn_166">'<a target="_blank" href="' + full_url + class="_tkStr_1klyn_166">'">' + url.substring(class="_tkNum_1klyn_175">0, Math.min(full_url.length, class="_tkNum_1klyn_175">20)) + class="_tkStr_1klyn_166">'...</a>';
        });
J
10
gistfile1.txt1

truncate based off offscreen

  function truncateText(string, nMaxChars) {
    if (string.length <= nMaxChars)
      return string;

    var xMaxFit = nMaxChars - class="_tkNum_1klyn_175">3;
    var xTruncateAt = string.lastIndexOf(class="_tkStr_1klyn_166">' ', xMaxFit);
    if (xTruncateAt == -class="_tkNum_1klyn_175">1 || xTruncateAt < nMaxChars / class="_tkNum_1klyn_175">2)
      xTruncateAt = xMaxFit;

    return string.substr(class="_tkNum_1klyn_175">0, xTruncateAt) + class="_tkStr_1klyn_166">"&hellip;";
  }
10
9
gistfile1.js0

Finding component in maps api geocoder result

function findComponent(result, type) {
      for (var i = class="_tkNum_1klyn_175">0; i , result.address_components.length; i++) {
        var component = result.address_components[i];
        for (var j = class="_tkNum_1klyn_175">0; j < component.types.length; j++) {
          if (component.types[j] == type) {
            return component.short_name;
          }
        }
      }
    }
9
8
jsonp.js0

jsonp + lscache

class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//Lightweight JSONP fetcher - www.nonobtrusive.com
var JSONP = (function(){
  var counter = class="_tkNum_1klyn_175">0, head, query, key, window = this;
  function load(url) {
    var script = document.createElement(class="_tkStr_1klyn_166">'script'),
      done = false;
    script.src = url;
    script.async = true;

    script.onload = script.onreadystatechange = function() {
      if ( !done && (!this.readyState || this.readyState === class="_tkStr_1klyn_166">"loaded" || this.readyState === class="_tkStr_1klyn_166">"complete") ) {
        done = true;
8
7
deferred.py0

Deferred handler for Flask

class="_tkStr_1klyn_166">"""
deferred.py

Primary App Engine app handler

class="_tkStr_1klyn_166">"""

import sys, os

package_dir = class="_tkStr_1klyn_166">"packages"

# Allow unzipped packages to be imported
7
6
gistfile1.js0

Loading fonts CSS

  var fontNum = class="_tkNum_1klyn_175">0;
  var maxCharacters = class="_tkNum_1klyn_175">1730;
  var cssBaseUrl = class="_tkStr_1klyn_166">'http:class="_tkCom_1klyn_170">//fonts.googleapis.com/css?family=';

  function addCss() {
    var cssUrl = cssBaseUrl;
    while ((cssUrl.length + allFontNames[fontNum].length) < maxCharacters && (fontNum < (allFontNames.length-class="_tkNum_1klyn_175">1))) {
      class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// dont load khmer, no point
      if (fonts[allFontNames[fontNum]].subsets[class="_tkNum_1klyn_175">0] != class="_tkStr_1klyn_166">'khmer') {
        cssUrl += escape(allFontNames[fontNum]) + class="_tkStr_1klyn_166">'|';
      }
      fontNum++;
6
5
index_renderer.py0

Jinja2 Rendering Templates

from jinja2 import Environment, FileSystemLoader

if __name__ == class="_tkStr_1klyn_166">"__main__":
  env = Environment(loader=FileSystemLoader(class="_tkStr_1klyn_166">'application/templates/'))
  template = env.get_template(class="_tkStr_1klyn_166">'phonegap/index.html')
  print template.render()

5
4
Makefile0

My phonegap/web/gae makefile

# Javascript/CSS Compressor Makefile - By Benjamin class="_tkStr_1klyn_166">"balupton" Lupton (MIT Licenced)

MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)

BUILDDIR = ./.build

CLOSUREURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//yui.zenfs.com/releases/yuicompressor/yuicompressor-class="_tkNum_1klyn_175">2.4.class="_tkNum_1klyn_175">6.zip
YUIDIR = $(BUILDDIR)/yui
4
3
views.py0

Facebook logout (Flask)

@login_required
def handle_logout():
    import facebook

    if g.user.facebook_id:
        base_domain     = util.get_base_domain()
        default_fb_data = FB_DATA[class="_tkStr_1klyn_166">'appspot.com']
        fb_app_id       = FB_DATA.get(base_domain, default_fb_data).get(class="_tkStr_1klyn_166">'appid')
        fb_app_secret   = FB_DATA.get(base_domain, default_fb_data).get(class="_tkStr_1klyn_166">'appsecret')
        cookie = facebook.get_user_from_cookie(request.cookies, fb_app_id, fb_app_secret)

        if cookie:
3
2
dimensions.js0

outer/inner/Width/Height


  [class="_tkStr_1klyn_166">'width', class="_tkStr_1klyn_166">'height'].forEach(function(dimension) {
    var offset, Dimension = dimension.replace(/./, function(m) { return m[class="_tkNum_1klyn_175">0].toUpperCase() });
    $.fn[class="_tkStr_1klyn_166">'outer' + Dimension] = function(margin) {
      var elem = this;
      if (elem) {
        var size = elem[dimension]();
        var sides = {class="_tkStr_1klyn_166">'width': [class="_tkStr_1klyn_166">'left', class="_tkStr_1klyn_166">'right'], class="_tkStr_1klyn_166">'height': [class="_tkStr_1klyn_166">'top', class="_tkStr_1klyn_166">'bottom']};
        sides[dimension].forEach(function(side) {
          size += parseInt(elem.css(class="_tkStr_1klyn_166">'padding-' + side), class="_tkNum_1klyn_175">10);
          size += parseInt(elem.css(class="_tkStr_1klyn_166">'border-' + side + class="_tkStr_1klyn_166">'-width'), class="_tkNum_1klyn_175">10);
          if (margin) size += parseInt(elem.css(class="_tkStr_1klyn_166">'margin-' + side), class="_tkNum_1klyn_175">10);
2
A
dateinput.js0

Zepto jQueryTools DateInput

/**
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * @license                                     
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * jQuery Tools @VERSION Dateinput - <input type=class="_tkStr_1klyn_166">"date" /> for humans
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * http://flowplayer.org/tools/form/dateinput/
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Since: Mar class="_tkNum_1klyn_175">2010
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Date: @DATE 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> */
(function($, undefined) {   
A
K
flask_tests.py0

Python Flask App Engine Unit Test

import unittest
import sys
import os
import logging

# locate app-engine SDK
AE_PATH = class="_tkStr_1klyn_166">"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/"

# path to app code
APP_PATH = os.path.abspath(class="_tkStr_1klyn_166">".")

# load the AE paths (as stolen from dev_appserver.py)
K
Q
log.html0

Jinja2 Template Example (Everyday.io Log)

{% extends class="_tkStr_1klyn_166">"yourbase.html" %}

{% block subheader %}
<div class=class="_tkStr_1klyn_166">"page-header">
<h1>
  <span id=class="_tkStr_1klyn_166">"log-date">{{ title }}</span>
  <a data-tooltip=class="_tkStr_1klyn_166">"Change the date" id=class="_tkStr_1klyn_166">"log-date-button" href=class="_tkStr_1klyn_166">"javascript:void(class="_tkNum_1klyn_175">0);" style=class="_tkStr_1klyn_166">"margin-left: 10px;"><img src=class="_tkStr_1klyn_166">"img/calendar.png"></a>
</h1>
</div>
{% endblock %}

{% block content %}
Q
J
facebook_tests.py0

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()

    def setUp(self):
J
10
facebook_dom.py0

Facebook Selenium Dom Helper Functions

import dom_helper
import test_defaults

FBEMAIL     = class="_tkStr_1klyn_166">'#email'
FBPASS      = class="_tkStr_1klyn_166">'#pass'
FBLOGIN     = class="_tkStr_1klyn_166">'input[name="login"]'
FBGRANT     = class="_tkStr_1klyn_166">'input[name="grant_clicked"]'

class FacebookDom(dom_helper.DomHelper):

    def is_window_open(self):
        return len(self.driver.window_handles) > class="_tkNum_1klyn_175">1
10
9
gistfile1.js0

Moving average calculation

      class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Calculate moving average
      var averageData = [];
      var lastValue = null;
      var movingAverage = null;
      for (var i = class="_tkNum_1klyn_175">0; i < dates.length; i++) {
        var value = measurementData[i] || missingData[i];
        if (!movingAverage) {
          movingAverage = value;
        } else {
          movingAverage = ((value - movingAverage)/class="_tkNum_1klyn_175">7) + movingAverage;
        }
        if (isNaN(movingAverage)) {
9
8
Makefile0

Phonegap/App Engine Makefile

# Javascript/CSS Compressor Makefile - By Benjamin class="_tkStr_1klyn_166">"balupton" Lupton (MIT Licenced)

MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)

BUILDDIR = ./.build

CLOSUREURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//yui.zenfs.com/releases/yuicompressor/yuicompressor-class="_tkNum_1klyn_175">2.4.class="_tkNum_1klyn_175">6.zip
YUIDIR = $(BUILDDIR)/yui
8
7
fancybox.js0

Zepto + FancyBox

/*
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * FancyBox - jQuery Plugin
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Simple and fancy lightbox alternative
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Examples and documentation at: http://fancybox.net
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Copyright (c) class="_tkNum_1klyn_175">2008 - class="_tkNum_1klyn_175">2010 Janis Skarnelis
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Version: class="_tkNum_1klyn_175">1.3.class="_tkNum_1klyn_175">4 (class="_tkNum_1klyn_175">11/class="_tkNum_1klyn_175">11/class="_tkNum_1klyn_175">2010)
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Requires: jQuery v1.class="_tkNum_1klyn_175">3+
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *
7
6
mobilelogpage.js0

MobileLogPage

  MobileLogPage.prototype = MobilePage.prototype;

  MobileLogPage.prototype.getForm = function() {
    return ED.shared.logForms[this.id];
  };

  MobileLogPage.prototype.getErrorDOM = function() {
    return $(class="_tkStr_1klyn_166">'#mobile-' + this.id + class="_tkStr_1klyn_166">'-page .log-error');
  };

  MobileLogPage.prototype.getErrorMessage = function() {
    return $(class="_tkStr_1klyn_166">'#mobile-' + this.id + class="_tkStr_1klyn_166">'-page .log-error-message');
6
5
impl_example.js0

impl example

  function MobilePage() {
    this.initialized = false;
  }

  MobilePage.prototype.setup = function() {};

  MobilePage.prototype.setupOnce = function() {
    if (this.initialized !== true) this.setup();
    this.initialized = true;
  };

  MobilePage.prototype.show = function() {};
5
4
mobile_photo.js0

Getting/rotating photos in PhoneGap

  function getPhoto(mealId, sourceType, saveOnSuccess) {
    var $mealDiv = $(class="_tkStr_1klyn_166">'#log-meal-' + mealId);
    var $mealImg = $mealDiv.find(class="_tkStr_1klyn_166">'.log-meal-photo-button img');
    var $quickpicStatus = $(class="_tkStr_1klyn_166">'#mobile-quickpic-link span');

    function resetQuickPicStatus() {
      $quickpicStatus.html(class="_tkStr_1klyn_166">'').addClass(class="_tkStr_1klyn_166">'icon-camera');
    }


    function getDataUri(imageUri, onSuccess, onFail) {
      var $img = $(class="_tkStr_1klyn_166">'<img/>');
4
3
util_log.js0

ED.util.log()

  class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Logging
  var allLogs = [];
  function log(something) {
    class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">// Store
    var storedSomething = something;
    if (window.JSON) {
      storedSomething = JSON.stringify(something);
    }
    storedSomething = class="_tkStr_1klyn_166">'LOG @ ' + new Date().toString() + class="_tkStr_1klyn_166">': ' + truncateText(storedSomething, class="_tkNum_1klyn_175">200);
    allLogs.push(storedSomething);
    $(class="_tkStr_1klyn_166">'#mobile-feedback-logs').html(allLogs.reverse().join(class="_tkStr_1klyn_166">'<br>'));
3
2
phonegap.html0

Android localStorage in PhoneGap timing test

<!doctype html>
<html>
 <head>
  <meta name=class="_tkStr_1klyn_166">"viewport" content=class="_tkStr_1klyn_166">"initial-scale=class="_tkNum_1klyn_175">1.0, user-scalable=no, width=device-width" />
  <meta name=class="_tkStr_1klyn_166">"apple-mobile-web-app-capable" content=class="_tkStr_1klyn_166">"yes" />
  <base target=class="_tkStr_1klyn_166">"_blank">
  <title>eatdifferent</title>
  <script>
  var ED = ED || {};
  ED.VERSION = class="_tkStr_1klyn_166">'class="_tkNum_1klyn_175">36'
  ED.timing = (function() {
    var timingOn  = true;
2
A
CameraLauncher.java0

PhoneGap Camera.java (Hacked up)

/*
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version class="_tkNum_1klyn_175">2.0 (the
       class="_tkStr_1klyn_166">"License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http:class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//www.apache.org/licenses/LICENSE-class="_tkNum_1klyn_175">2.0

       Unless required by applicable law or agreed to in writing,
A
K
IframeViewer.js0

IframeViewer for Brackets

/*
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Copyright (c) class="_tkNum_1klyn_175">2012 Adobe Systems Incorporated. All rights reserved.
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *  
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Permission is hereby granted, free of charge, to any person obtaining a
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * copy of this software and associated documentation files (the class="_tkStr_1klyn_166">"Software"), 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * to deal in the Software without restriction, including without limitation 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * the rights to use, copy, modify, merge, publish, distribute, sublicense, 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * and/or sell copies of the Software, and to permit persons to whom the 
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * Software is furnished to do so, subject to the following conditions:
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> *  
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * The above copyright notice and this permission notice shall be included in
class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170"> * all copies or substantial portions of the Software.
K
Q
editorhack.diff0

EditorManager + CommandManager

diff --git a/src/brackets.js b/src/brackets.js
index 39e30b2..cb20367 class="_tkNum_1klyn_175">100644
--- a/src/brackets.js
+++ b/src/brackets.js
@@ -class="_tkNum_1klyn_175">199,class="_tkNum_1klyn_175">7 +class="_tkNum_1klyn_175">199,class="_tkNum_1klyn_175">8 @@ define(function (require, exports, module) {
                     class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//{class="_tkStr_1klyn_166">"Ctrl-X": Commands.EDIT_CUT},
                     class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//{class="_tkStr_1klyn_166">"Ctrl-C": Commands.EDIT_COPY}, 
                     class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">//{class="_tkStr_1klyn_166">"Ctrl-V": Commands.EDIT_PASTE},
-
+                    {class="_tkStr_1klyn_166">"Ctrl-I": Commands.SHOW_OTHER_STUFF},
+                  
                     {class="_tkStr_1klyn_166">"Ctrl-A": Commands.EDIT_SELECT_ALL},
Q
J
gistfile1.txt0

JS Errors and Causes

These arent always the causes, just in the cases I saw them.

Unexpected {    
Cause: mismatched curly braces, count your braces

Unexpected token . 
Cause: var buttonDiv.bla = class="_tkNum_1klyn_175">4

SyntaxError: Unexpected string  
Cause: var bla = bla + class="_tkStr_1klyn_166">' hi ' class="_tkStr_1klyn_166">' you'

Cannot read property stuff of null
J
10
render_handlebars.py0

Handlebars Folder Renderer Script

import os

input_path  = class="_tkStr_1klyn_166">'application/templates'
output_path = class="_tkStr_1klyn_166">'application/static/js/templates'

os.system(class="_tkStr_1klyn_166">'mkdir %s' % output_path)
dir_list = os.listdir(input_path)
for file_name in dir_list:
    if file_name.endswith(class="_tkStr_1klyn_166">'.handlebars'):
        cmd = class="_tkStr_1klyn_166">'handlebars %s/%s -f %s/%s' % (input_path, file_name, output_path, file_name.replace(class="_tkStr_1klyn_166">'handlebars', class="_tkStr_1klyn_166">'js'))
        print cmd
        os.system(cmd)
10
9
idiomatic_JA.md0

Idiomatic.JS, japanese translation from Mashashi

                                                                     
                                                                     
                                                                     
                                             
#慣用的なJavaScript, 矛盾しないコードの書き方


## これは現在使っているドキュメントです。私達が使っているコードを向上させるためのアイディアはいつでも歓迎です。意見を述べるには、fork, clone, branch, commit, push, pull requestなどをしてください。



9
8
restaurants.xml0

Sample XML: Seattle Restaurants

<?xml version=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">1.0"?>
<restaurants>
<restaurant name=class="_tkStr_1klyn_166">"Pan Africa Market" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">1521 1st Ave, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.608940" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.340141" type=class="_tkStr_1klyn_166">"sitdown"/>
<restaurant name=class="_tkStr_1klyn_166">"Buddha Thai & Bar" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">2222 2nd Ave, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.613590" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.344391" type=class="_tkStr_1klyn_166">"bar"/>
<restaurant name=class="_tkStr_1klyn_166">"The Melting Pot" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">14 Mercer St, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.624561" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.356445" type=class="_tkStr_1klyn_166">"sitdown"/>
<restaurant name=class="_tkStr_1klyn_166">"Ipanema Grill" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">1225 1st Ave, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.606365" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.337654" type=class="_tkStr_1klyn_166">"sitdown"/>
<restaurant name=class="_tkStr_1klyn_166">"Sake House" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">2230 1st Ave, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.612823" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.345673" type=class="_tkStr_1klyn_166">"bar"/>
<restaurant name=class="_tkStr_1klyn_166">"Crab Pot" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">1301 Alaskan Way, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.605961" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.340363" type=class="_tkStr_1klyn_166">"sitdown"/>
<restaurant name=class="_tkStr_1klyn_166">"Mama's Mexican Kitchen" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">2234 2nd Ave, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.613976" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.345467" type=class="_tkStr_1klyn_166">"bar"/>
<restaurant name=class="_tkStr_1klyn_166">"Wingdome" address=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">1416 E Olive Way, Seattle, WA" lat=class="_tkStr_1klyn_166">"class="_tkNum_1klyn_175">47.617214" lng=class="_tkStr_1klyn_166">"-class="_tkNum_1klyn_175">122.326584" type=class="_tkStr_1klyn_166">"bar"/>
<resta
8
7
test_hand_val.py0

Basic unit test of function in Python

import unittest

BUST_VAL = class="_tkNum_1klyn_175">22
ACE_HIGH = class="_tkNum_1klyn_175">11
ACE_LOW = class="_tkNum_1klyn_175">1

def calculate_hand_val(low_hand_val, num_aces):
    hand_val = low_hand_val

    for x in range(class="_tkNum_1klyn_175">1, num_aces + class="_tkNum_1klyn_175">1):
        if (hand_val + (ACE_HIGH - ACE_LOW)) < BUST_VAL:
            print class="_tkStr_1klyn_166">'adding high'
7
6
table.html0

An accessible table


<style type=class="_tkStr_1klyn_166">"text/css">
  .hidden-accessible {
    position: absolute !important;
    height: 1px; width: 1px;
    overflow: hidden;
    clip: rect(1px 1px 1px 1px); class=class="_tkStr_1klyn_166">"_tkCom_1klyn_170">/* IE6, IE7 */
    clip: rect(1px, 1px, 1px, 1px);
  }
</style>

<table>
6