Skip to content

Instantly share code, notes, and snippets.

Thomas Wilburn thomaswilburn

Block or report user

Report or block thomaswilburn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thomaswilburn
thomaswilburn / component.js
Last active Feb 25, 2020
So you want to make a primary results component
View component.js
var ElementBase = require("../elementBase.js");
var Retriever = require("../retriever.js");
/*
Let's make a web component the elections20-primaries way! We're going to start by
subclassing our base element, since it makes the setup a little more declarative.
You'll see how that works in a minute.
*/
class DemoElement extends ElementBase {
@thomaswilburn
thomaswilburn / unpinner.vbs
Created Jan 29, 2020
Unpin taskbar icons
View unpinner.vbs
Set ShellApp = CreateObject("Shell.Application")
Set FSO = CreateObject("Scripting.FileSystemObject")
homeFolder = ShellApp.NameSpace(&H28).Self.Path
PinnedPath = homeFolder & "\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
Set PinnedNS = ShellApp.NameSpace(PinnedPath)
Set PinnedFolder = FSO.GetFolder(PinnedPath)
Set PinnedFiles = PinnedFolder.Files
View loadDocs.js
var { google } = require("googleapis");
var async = require("async");
var os = require("os");
var path = require("path");
var { authenticate } = require("./googleauth");
module.exports = function(grunt) {
grunt.registerTask("docs", "Load Google Docs into the data folder", function() {
View index.js
var http = require("http");
var https = require("https");
var { SourceMapConsumer } = require("source-map");
var fs = require("fs").promises;
var path = require("path");
var fetch = function(address) {
return new Promise(function(ok, fail) {
var parsed = new URL(address);
var remote = parsed.protocol == "http:" ? http : https;
View gist:76a1a519a76f3e8ef897271bbdb8e6e4
var request = require("request");
var dateFormat = require("dateformat");
var today = new Date();
/* Format the date to be todays date in mm-dd-yyy format for later use */
today = dateFormat(today, "mm-dd-yyyy");
onCallDateFormat = dateFormat(today, "yyyy-mm-dd");
var jiraUrl = "";
@thomaswilburn
thomaswilburn / index.html
Created Jul 7, 2019
Demo of making a D3 chart
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello!</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
This space intentionally left blank. Test
@thomaswilburn
thomaswilburn / main.js
Created May 16, 2019
Code excerpts from White Lies
View main.js
var directors = {
"image": require("./image-scene"),
"audio": require("./audio-scene"),
"map": require("./map-scene")
};
// state of the last block and director
var lastBlock = null;
var director = null;
// check blocks in reverse order
@thomaswilburn
thomaswilburn / htmlparser.js
Last active Jun 20, 2019
A terrible HTML parser that you might be able use to scrape (well-constructed) pages from Google Apps Script
View htmlparser.js
var Node = function(type) {
this.type = type;
this.tagName = null;
this.attributes = {};
this.children = [];
this.parentElement = null;
this.textContent = "";
};
Node.prototype = {
@thomaswilburn
thomaswilburn / commonmark.js
Last active Apr 10, 2019
CommonMark-ish rendering into Google Docs
View commonmark.js
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
function renderMD(body, lines) {
if (typeof lines == "string") {
lines = lines.split("\n");
}
lines.forEach(function(line) {
if (line.match(/^[-=+]+$/)) {
return body.appendHorizontalRule();
@thomaswilburn
thomaswilburn / k&r-1-24.c
Last active Nov 7, 2018
K&R exercise 1-24
View k&r-1-24.c
#include <stdio.h>
//I really want to use exit(), so sue me.
#include <stdlib.h>
#define true 1
#define false 0
//machine states
#define SOURCE 1 //regular code
#define COMMENT 2 //currently in a comment
You can’t perform that action at this time.