Skip to content

Instantly share code, notes, and snippets.

View Fauntleroy's full-sized avatar

Timothy Kempf Fauntleroy

View GitHub Profile
@Fauntleroy
Fauntleroy / bindevents.js
Created October 23, 2012 00:42
bindEvents pattern
var Cat = Backbone.Model.extend({
initialize: function(){
_(this).bindAll( 'bindEvents', 'action', 'dispose' );
this.bindEvents();
},
@Fauntleroy
Fauntleroy / gist:4515956
Created January 12, 2013 03:49
JavaScript Basics - 1
//
// What Javascript is Made of
// It ain't sugar, spice, and everything nice, but it'll do
//
///////////////////////////////////////////////////////////////////////////////////////
// Variables
// Javascript is reference based, meaning that variables only ever point to a piece of data. Defining a variable lets you use a piece of data elsewhere.
@Fauntleroy
Fauntleroy / markup.html
Created February 28, 2013 16:59
A terse gist
<h1>Isn't Terse <strong>awesome</strong>?!!!</h1>
<a href="http://www.youtube.com/watch?v=ygI-2F8ApUM">Yes</a>
<a href="http://www.youtube.com/watch?v=cRrdP8bUZI4">No</a>
@Fauntleroy
Fauntleroy / markup.html
Created March 1, 2013 18:35
A terse gist
<h1>I AM <em>TRANSFORMED</em></h1>
@Fauntleroy
Fauntleroy / markup.html
Created March 1, 2013 19:02
A terse gist
<img src="http://upload.wikimedia.org/wikipedia/commons/2/2a/Wikipe-tan_in_navy_uniform2_transparent.png" />
@Fauntleroy
Fauntleroy / script.js
Created March 6, 2013 04:29
A terse gist
var myFunc = function( a, b ){
return a+b;
};
// OR!!!!
var myFunc = function( a, b ){
return arguments[0] + arguments[1];
};
@Fauntleroy
Fauntleroy / gist:5167736
Created March 15, 2013 05:48
Convert the YouTube v3 API's insane duration to something reasonable
var convertYouTubeDuration = function( yt_duration ){
var time_extractor = /([0-9]*)M([0-9]*)S$/;
var extracted = time_extractor.exec( yt_duration );
var minutes = parseInt( extracted[1], 10 );
var seconds = parseInt( extracted[2], 10 );
var duration = ( minutes * 60 ) + seconds;
return duration;
};
@Fauntleroy
Fauntleroy / constructing.js
Created March 18, 2013 05:38
An (almost) practical example of custom JavaScript constructors.
var PlaylistItem = function( params ){
// ensure params exists
params = params || {};
// cache a reference to this
var playlist_item = this;
// attach arguments to new PlaylistItem instance
this.title = params.title;
@Fauntleroy
Fauntleroy / markup.html
Created April 23, 2013 06:38
Tic Tac Toe
<div id="game">
<table id="board">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
@Fauntleroy
Fauntleroy / markup.html
Created April 24, 2013 01:16
A terse gist
<form id="placeholder_test">
<input name="test" type="text" placeholder="Placeholder Text" />
<button type="submit">Submit</button>
</form>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-placeholder/2.0.7/jquery.placeholder.min.js"></script>