Skip to content

Instantly share code, notes, and snippets.

View thomaswilburn's full-sized avatar
🦝

Thomas Wilburn thomaswilburn

🦝
View GitHub Profile
@thomaswilburn
thomaswilburn / Code.gs
Created August 29, 2014 19:20
Apps Script example for handling custom forms
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

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 / global_menu.php
Created November 19, 2014 07:17
Multi-site menu attempt
<?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 November 20, 2014 06:53
Global menu for Wordpress that isn't a huge goddamn hack
<?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 August 29, 2015 14:13
oh god indexeddb why
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();
}
@thomaswilburn
thomaswilburn / localhost.rst
Created March 6, 2015 16:50
Instructions for AJAX testing

Local Hosting

Getting started

There are lots of ways to run a local host, which is necessary for testing AJAX (and useful when it comes to other tasks). This document covers setting up a simple Node-based HTTP server, but you may also choose to use one of the MAMP/WAMP applications to start a local Apache instance, or use Python's simple server.

Before doing anything else, install the latest version of NodeJS. Node is a runtime for desktop/server JavaScript (as opposed to running scripts in the browser), and many useful tools are built on top of it. If you find this helpful, you may also want to look into LESS, Grunt, and other Node-based development tools.

@thomaswilburn
thomaswilburn / button.js
Last active August 29, 2015 14:16
Sample code report for WEB150
/**
* Originally taken from:
* https://raw.githubusercontent.com/GoogleChrome/devsummit/7ba921827a7cd080e31291275c0eda394ec21c9d/src/static/scripts/components/button.js
*
* This code enables the "material ripple" animation on buttons for the Chrome Dev Summit
* site (https://developer.chrome.com/devsummit/). It finds all buttons on the page, and
* adds an animation to them that plays on click. Button elements tend to look like this:
*
* <button data-embed="..." class="paper-button session__fab">
* <div class="session__fab-inner">
@thomaswilburn
thomaswilburn / k&r-1-13.c
Created April 7, 2015 15:03
K&R Exercise 1-13
#include <stdio.h>
#define true 1
#define false 0
#define LEN 30
void main()
{
int c, length, highest;
int counts[LEN];
/*ROUTE CODE*/
server.route({
method:"GET",
path: "/books",
handler: function(request, reply){
fs.readFile("books.json", "utf8", function(err,data){
var links =[];
var list = JSON.parse(data);
reply.view("book-list", {
@thomaswilburn
thomaswilburn / index.html
Created July 10, 2015 15:36
Weekly JS Challenge #1
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Weekly JS Challenge #1</title>
<style>
.movie-container {
display: flex;
background: #333;
max-width: 620px;