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 / gl.js
Last active Oct 14, 2017
Annotated WebGL sample.
View gl.js
/*
We're going to start by adding a canvas to the page and getting a context for it.
*/
var canvas = document.createElement("canvas");
canvas.width = canvas.height = 320;
document.body.appendChild(canvas);
var gl = canvas.getContext("experimental-webgl");
/*
WebGL doesn't know how to draw anything onscreen out of the box. We have to
View batjax.js
//taking a crack at it
//totally untested, probably doesn't work
var BatChannel = function(endpoint, interval) {
this.endpoint = endpoint;
this.pending = [];
this.interval = interval || 30000;
this.tick();
};
BatChannel.prototype = {
@thomaswilburn
thomaswilburn / caret-settings-upgrade.md
Created Dec 3, 2013
Caret is changing where settings are stored! Here's what you need to know.
View caret-settings-upgrade.md

Upgrading Settings in Caret: A Note

For most of its development, Caret has used Chrome's synchronized storage as the location for settings "files"--the JSON that gets loaded when you choose the Settings -> User Preferences, for example. In the past this has worked out well, but as these files have grown, they've started to migrate past the 4KB limit that's set on individual entries in sync storage. The first to do so was the Menus configuration. Nobody had submitted any bugs, which I suspect means that nobody actually changes the menus. But since user.json is creeping up on 4KB, we're going to have to make a change.

Sometime around December 4th, an update will roll out that will migrate your custom settings to Chrome's syncFileSystem API, which is backed by Google Drive. Due to some bugs in the way that Chrome handles these files, however, Caret won't actually read from them until a week or so later--it'll just back up the latest version of your settings. If it runs into any problems, you'll get a not

View gist:7974814
[...]
var loadEmmet = true;
//one-time startup
var init = function() {
aceConfig.themes.forEach(function(theme) {
var option = document.createElement("option");
option.innerHTML = theme.label;
option.setAttribute("value", theme.name);
@thomaswilburn
thomaswilburn / Code.gs
Created Aug 29, 2014
Apps Script example for handling custom forms
View Code.gs
var sheetID = "xxx-id-goes-here-xxx";
var rowConfig = "timestamp name location favorite note lifespan season contact lat lng zone approve feature".split(" ");
/***
Requests may come in with the following parameters:
name
favorite - player name (number?)
note
View caret_readme.rst

Caret

Caret is a serious, graphical programmer's editor running as a Chrome Packaged App. Inspired by Sublime and built on top of the Ace editing component, it offers powerful features like:

  • multiple cursors
  • tabbed editing and retained files
  • syntax highlighting and themes
  • command palette/smart go to
  • hackable, synchronized configuration files
@thomaswilburn
thomaswilburn / Repair.gs
Created Sep 6, 2014
Geocoding using Apps Script APIs
View Repair.gs
var sheet = SpreadsheetApp.openById(sheetID).getSheetByName("Responses");
var rowConfig = "timestamp name location favorite note lifespan season contact lat lng city zone approve feature".split(" ");
function getCol(row, param) {
return row[rowConfig.indexOf(param)];
}
function setCol(row, param, value) {
row[rowConfig.indexOf(param)] = value;
@thomaswilburn
thomaswilburn / global_menu.php
Created Nov 19, 2014
Multi-site menu attempt
View global_menu.php
<?php
//the slot is the menu location string you registered for the global menu
$slot = "menu_name_here";
function global_multisite_nav_menu_filter( $content, $args ) {
global $slot;
$registered = get_registered_nav_menus();
if( !isset( $registered[$slot] ) )
return $content;
@thomaswilburn
thomaswilburn / global_menu.php
Created Nov 20, 2014
Global menu for Wordpress that isn't a huge goddamn hack
View global_menu.php
<?php
//function for getting a global menu
//that caching plugin really was ridiculous, wasn't it?
if (is_multisite() && !is_main_site()) {
switch_to_blog(1); //should send us to the main site temporarily
}
wp_nav_menu("menu_id"); //get the nav menu from the main site context
if (is_multisite() && ms_is_switched()) {
restore_current_blog(); //revert to the network site if we switched it above
@thomaswilburn
thomaswilburn / idbtest.js
Last active Aug 29, 2015
oh god indexeddb why
View idbtest.js
var log = console.log.bind(console);
var Database = function(name, version, upgrade) {
var self = this;
this.ready = new Promise(function(ok, fail) {
var req = window.indexedDB.open(name, version);
req.onupgradeneeded = function(db) {
self.db_ = req.result;
if (upgrade) upgrade();
}
You can’t perform that action at this time.