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 / domains.js
Last active Aug 29, 2015
Federal agency domains from USA.gov
View domains.js
var _ = require('underscore');
var async = require('async');
var request = require('request');
var domains = [
// Federal non-.gov domains
{
url: 'http://govt-urls.usa.gov/tematres/vocab/services.php?output=json&task=fetchDown&arg=17',
json: true,
},
@dhcole
dhcole / _config.yml
Created Jun 2, 2015
Jekyll defaults for collections
View _config.yml
defaults:
-
scope:
path: ""
values:
layout: "page"
-
scope:
path: "news"
values:
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Foo</title>
<meta charset='utf-8' />
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' />
<style type='text/css'>
body {
font-family: 'Helvetica';
letter-spacing:-5px;
View jekyll_get.rb
require 'open-uri'
module Jekyll_Get
class Generator < Jekyll::Generator
def generate(site)
config = site.config['jekyll_get']
if !config
return
end
if !config.kind_of?(Array)
@dhcole
dhcole / gist:e62d831e009b827fca07
Created Sep 10, 2014
List files in a directory by type (audit an archived website)
View gist:e62d831e009b827fca07
find . -type f | sed 's/^.*\(\.[a-zA-Z0-9][a-zA-Z0-9][a-zA-Z0-9]\).*$/\1/' | sort | uniq -c > ../files.dat
@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 / 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>
@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;
}