Skip to content

Instantly share code, notes, and snippets.

View pamelafox's full-sized avatar

Pamela Fox pamelafox

View GitHub Profile
@pamelafox
pamelafox / player.js
Created October 26, 2012 23:45
Changing Playback of HTML5 Video
this.isSetSpeedEnabled = function() {
if(typeof(this.mediaElement) === 'object'
&& this.mediaElement !== null
&& typeof(this.mediaElement.playbackRate) === 'number'
&& this.mediaElement.playbackRate > 0){
return true;
}
else{
return false;
}
@pamelafox
pamelafox / greasemonkey-exercises.txt
Created October 21, 2012 08:41
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.
@pamelafox
pamelafox / ajax-exercises.txt
Created October 21, 2012 08:40
AJAX Exercises
Exercise: Nutrition Facts
Create an empty webpage.
Download nutrition.xml from https://gist.github.com/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
@pamelafox
pamelafox / project.txt
Created October 21, 2012 08:39
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. 1000 rows). Some possible sources are:
https://explore.data.gov/
http://www.usgovxml.com/
@pamelafox
pamelafox / visibleimages.js
Created September 17, 2012 04:22
Load Visible Images
function loadVisibleImages() {
var placeholders = {
'meal': 'img/meal.png',
'avatar': 'img/blankpic.png'
};
$('img').each(function() {
var $img = $(this);
var realUrl = $img.attr('data-src');
if (!realUrl) return;
@pamelafox
pamelafox / focus.js
Created September 1, 2012 17:05
Hack for Android focus() on PhoneGap
// From Lindsey Simon
/**
* This is a hack to make text input focus work in Android/PhoneGap
* where calling el.focus() doesn't actually have the blinking cursor
* effect = scumbag.
* @param {Zepto} $el A zepto element.
*/
ws.focus = function($el) {
var el = $el.get(0);
el.focus();
@pamelafox
pamelafox / thirdparties.js
Created August 25, 2012 00:40
isDefined
// isDefined(window, 'google');
// isDefined(window, 'google.maps.places');
var isDefined = function(parent, name) {
var parts = name.split('.');
var part = parts.shift();
var cur = parent;
while (part) {
if (cur[part]) {
cur = cur[part];
@pamelafox
pamelafox / view.html
Created August 21, 2012 14:30
Google Maps AutoComplete for Profile Location Field
<div class="control-group">
<label class="control-label">Location</label>
<div class="controls">
<input name="location" type="text" placeholder="City, State, Country" value="">
<input name="location_city" type="hidden" value="">
<input name="location_state" type="hidden" value="">
<input name="location_country" type="hidden" value="">
<input name="location_lat" type="hidden">
<input name="location_lng" type="hidden">
</div>
@pamelafox
pamelafox / header.html
Created August 8, 2012 04:51
Handlebars Design Prototyping
<html>
<head>
<style>
.w100percent {
}
.w1280px {
}
.w900px {
}
.w768px {
@pamelafox
pamelafox / form.html
Created August 1, 2012 20:42
Functions for showing form save messages and errors
<form id="coursera-form" action="/api/save" enctype="multipart/form-data" method="POST" class="form-horizontal">
<!-- form inputs here -->
<div class="form-actions"><button type="submit" data-default-message="Save Changes" data-inflight-message="Saving..." data-success-message="Saved!" class="coursera-save-button btn btn-primary" disabled="disabled">Saved!</button></div>
</form>