Skip to content

Instantly share code, notes, and snippets.

@dhcole
dhcole / holidayCheck.js
Last active July 14, 2023 13:04
A Lambda handler to check whether today is a holiday, built to be used with Amazon Connect
/*
*
* Source: https://www.state.nj.us/nj/about/facts/holidays/
* Convert to JSON using ChatGPT prompt:
* "Convert this table to JSON, converting dates to ISO format (pasted table)"
*
*/
const HOLIDAYS = [
{
holiday: "New Year's Day",
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 November 3, 2012 19:31
Submit data from html form to Google Doc Spreadsheet. Uses Bootstrap components for auto-complete region list and date selection.
$(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 June 24, 2013 19:58
Akamai edge-side-include for wrapping a JSON file in a JSONP callback function
<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>
<?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 January 19, 2016 10:07
Profiling the `jekyll new` site
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

<!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 December 16, 2015 03:19
Layout for CSS-only slide-out mobile menu.
<!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;
}
#!/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 March 25, 2013 18:49
Make links on page bookmarkable
// 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;
}
};