Skip to content

Instantly share code, notes, and snippets.

View thomaswilburn's full-sized avatar
🦝

Thomas Wilburn thomaswilburn

🦝
View GitHub Profile
@thomaswilburn
thomaswilburn / letsencrypt.sh
Last active September 16, 2016 23:04
A wrapper for acme-tiny to request and update certificates
#!/usr/bin/env bash
#Crash on any failed command
set -e
dir=`dirname $0`
# the domains directory should contain one config file per domain
# each file contains a list of subdomains
# for example, here's domains/thomaswilburn.net:
# thomaswilburn.net
# www.thomaswilburn.net
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# This sets the VM that we want to use - in this case, a classic Ubuntu 12.01 box
config.vm.box = "hashicorp/precise32"
# This makes the VM available in your browser on port 8080, and on MySQL's default port
config.vm.network "forwarded_port", guest: 80, host: 1234 #HTTP
#config.vm.network "forwarded_port", guest: 3306, host: 3306 #MySQL
@thomaswilburn
thomaswilburn / scroll-class.js
Created February 10, 2016 20:56
Scroll-triggered effects without jQuery
/*
This causes any elements with scroll-class attributes to add be updated either when they
reach the halfway point of the window, or when a target element (matching the selector in
the scroll-trigger attribute) reaches that point. For example:
<div class="example" scroll-class="activated" scroll-trigger=".trigger">
This element will gain the "activated" class when the following element scrolls halfway:
<span class="trigger">TRIGGER ELEMENT</span>
</div>

Using <custom-elements> in production

Who am I?

  • Thomas Wilburn
  • News Developer at the Seattle Times
  • @thomaswilburn on Twitter, GitHub
@thomaswilburn
thomaswilburn / demo.js
Last active April 27, 2016 23:30
A template literal tag that lets you write verbose regex syntax
var r = require("./verboseRegex.js");
var regex = r`
^ # from the start of the string
\s* # with any number of spaces
\(\s+ # find the first paren, followed by whitespace
([^)]+) # capture anything that's not a closing paren
\s*\) # followed by whitespace and a closing paren
`;
@thomaswilburn
thomaswilburn / snippet.js
Last active August 23, 2016 16:38
document-register-element v1 shim test
var F = function(self) {
//being called from the shim
if (self) {
HTMLElement.call(self);
return self;
}
//must be native, use Reflect.construct() to perform super()
//this code is untested, came from rniwa
return Reflect.construct(HTMLElement, [], F);
};
@thomaswilburn
thomaswilburn / code.js
Created August 23, 2016 19:33
Apps Script Lock demo
// This is the main web handler, and uses the lock service
var sheetID = "xxxx";
var rowConfig = "timestamp name location favorite note lifespan season contact lat lng city zone approve feature".split(" ");
/***
Requests may come in with the following parameters:
name
@thomaswilburn
thomaswilburn / index.js
Last active July 22, 2017 21:23
ASP page scraper with comments
// Built-in modules
var csv = require("csv");
var fs = require("fs");
var url = require("url");
// Loaded from NPM
var $ = require("cheerio"); // jQuery-like DOM library
var async = require("async"); // Easier concurrency utils
var request = require("request"); // Make HTTP requests simply
@thomaswilburn
thomaswilburn / a.js
Last active March 10, 2017 00:30
AMD promises
define(async function() {
console.log("a loaded");
var b = await require("b.js");
return { a: true, b };
});
@thomaswilburn
thomaswilburn / index.js
Created April 26, 2017 23:22
Methode to Markdown
var minimist = require("minimist");
var sax = require("sax");
var fs = require("fs");
var args = minimist(process.argv);
var input = fs.createReadStream(args.i);
var parser = sax.createStream();