Skip to content

Instantly share code, notes, and snippets.

@seamusjr
seamusjr / backbone_template.html
Created July 8, 2011 03:31
Backbone HTML template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<!-- CSS -->
<style type="text/css">
@seamusjr
seamusjr / JS Util solution using underscore.js
Created July 7, 2011 19:54 — forked from HenrikJoreteg/JS Util solution using underscore.js
Rather than creating some other util global, just extend underscore.js with any additional methods you want.
// If you don't use underscore.js, use it (http://documentcloud.github.com/underscore/)
// Then, use underscore's mixin method to extend it with all your other utility methods
// like so:
_.mixin({
escapeHtml: function () {
return this.replace(/&/g,'&amp;')
.replace(/>/g,'&gt;')
.replace(/</g,'&lt;')
.replace(/"/g,'&quot;')
.replace(/'/g,'&#39;');
@seamusjr
seamusjr / SpecRunner.html
Created June 24, 2011 17:00
Jasmine/JQuery/jasmine-jquery test runner html template
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Test Runner</title>
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.0.2/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.0.2/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.0.2/jasmine-html.js"></script>
<script src="lib/jquery-1.6.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jasmine-jquery-1.2.0.js" type="text/javascript" charset="utf-8"></script>
@seamusjr
seamusjr / insertCoords
Created April 3, 2011 16:32
get latLng has string of coords from google.maps latLng insert into node
function getCoords() {
var latlng_str = marker.getPosition().toString();
document.getElementById("coords").textContent = latlng_str;
};
@seamusjr
seamusjr / getGoogleMapsLatLng
Created April 2, 2011 20:25
return latLng on click
google.maps.event.addListener(map, 'click', function(event) {
console.log(event.latLng);
});
@seamusjr
seamusjr / replaceHtml.js
Created January 6, 2011 17:33
From http://blog.stevenlevithan.com/archives/faster-than-innerhtml using innerHTML and dom methods to replace elements
function replaceHtml(el, html) {
var oldEl = typeof el === "string" ? document.getElementById(el) : el;
/* @cc_on // Pure innerHTML is slightly faster in IE
oldEl.innerHTML = html;
return oldEl;
@*/
var newEl = oldEl.cloneNode(false);
newEl.innerHTML = html;
oldEl.parentNode.replaceChild(newEl, oldEl);
// Since we just removed the old element from the DOM, return a reference