Skip to content

Instantly share code, notes, and snippets.

View redirect-with-preserved-paths.js
var oldDomain = "businessnj.webflow.io";
var newDomain = "business.nj.gov";
if (location.hostname === oldDomain) {
location.replace("https://" + newDomain + location.pathname + location.search);
}
@dhcole
dhcole / form.js
Created Nov 3, 2012
Submit data from html form to Google Doc Spreadsheet. Uses Bootstrap components for auto-complete region list and date selection.
View form.js
$(function(){
var formUrl = '/* ex: https://docs.google.com/a/developmentseed.org/spreadsheet/formResponse?formkey=... */';
// Set up map
var m = mapbox.map('map').addLayer(mapbox.layer().id(' /* mapbox-account.id */ '));
// Set up map ui features with point selector
var ui = mapbox.ui().map(m).auto().pointselector(function(d) {
// Remove all points except the most recent
@dhcole
dhcole / jsonp.xml
Created Jun 24, 2013
Akamai edge-side-include for wrapping a JSON file in a JSONP callback function
View jsonp.xml
<assign:extract-value>
<variable-name>CALLBACK</variable-name>
<location>Query_String</location>
<location-id>callback</location-id>
<location-id-prefix-match>off</location-id-prefix-match>
<separator>=</separator>
<add-prefix>none</add-prefix>
<add-suffix>none</add-suffix>
</assign:extract-value>
View gist:2853853
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>foursquare :: Explore Sample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" id="jquery"></script>
@dhcole
dhcole / profile.md
Last active Jan 19, 2016
Profiling the `jekyll new` site
View profile.md
posts seconds time
1 0.824 0:0.824
100 2.644 0:2.644
1000 25.071 0:25.071
5000 186.715 3:6.715
10000 536.904 8:56.904

chart

View index.html
<!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="liquid.js"></script>
</head>
<body>
<div id="content"></div>
@dhcole
dhcole / index.html
Last active Dec 16, 2015
Layout for CSS-only slide-out mobile menu.
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<style>
body {
margin: 0;
}
View makeapp.sh
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
@dhcole
dhcole / script.js
Created Mar 25, 2013
Make links on page bookmarkable
View script.js
// loop through the node list to get the innerHTML from each node
// copy that as the id for the node
var addId = function(list){
for (i = 0; i < list.length; i++) {
element = list[i];
sectionCopy = element.innerHTML.toLowerCase().replace(/ /g, '-').replace(/([^0-9a-z-])/g,''); //substitute space with dash
element.id = sectionCopy;
}
};