Skip to content

Instantly share code, notes, and snippets.


Greg Haygood greghaygood

View GitHub Profile
greghaygood / crossword-puzzle-keys.js
Created Sep 28, 2021
Crossword Puzzle Shortcut Keys UserScript
View crossword-puzzle-keys.js
// ==UserScript==
// @name Crossword Puzzle Shortcut keys
// @namespace
// @version 1.0
// @description Add keyboard shortcuts for UI controls on the WaPo crossword puzzle app
// @author Greg Haygood <>
// @match*
// @icon
// @license MIT
// ==/UserScript==
greghaygood / auto-assign-customers.php
Created Jun 6, 2017
Auto-assign custom Group to new WooCommerce customers
View auto-assign-customers.php
// When working with both WooCommerce and Groups plugins, I needed a way to auto-assign
// users with the Customer role to a specific group, separate from the default Registered group.
function my__edit_user_created_user( $user_id ) {
$user = get_userdata( $user_id );
$roles = empty( $user->roles ) ? array() : $user->roles;
if ( in_array( 'customer', $roles ) ) {
greghaygood /
Last active Aug 30, 2016
Reactotron debug logger

I wanted an easier way to format debug data for Reactotron that would render more easily, so I came up with this code snippet:

if (__DEV__) {
  console.tlog = (name, mainVal, ...otherVals) => {
    let vars = {_name: name, ...otherVals}
    if (typeof mainVal === 'object') {
      vars = {...vars, ...mainVal}
    } else {
 vars['_mainVal'] = mainVal

Keybase proof

I hereby claim:

  • I am greghaygood on github.
  • I am greghaygood ( on keybase.
  • I have a public key ASCsM60eyG5SOl2uX0uRfSxjhDQkDGC2fCJ3cOkLU9YnLQo

To claim this, I am signing this object:

greghaygood /
Last active Sep 21, 2015
'unistd.h' file not found for Xcode 7

After upgrading to Xcode7 and Command Line Tools 10.10, I can't compile standard programs anymore. The error is (from the cputhrottle package):

/tmp/cputhrottle% make
/usr/bin/g++ -c -g -Wall -I..///boost_1_43_0
In file included from
In file included from ./manip.h:4:
In file included from /usr/local/include/boost/shared_ptr.hpp:17:
In file included from /usr/local/include/boost/smart_ptr/shared_ptr.hpp:17:
In file included from /usr/local/include/boost/config.hpp:44:
greghaygood / index.html
Last active Dec 28, 2015
Template for the Week 7 homework
View index.html
<!DOCTYPE html>
<title>Week 7 Assignment</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
#wrapper { width: 90%; margin: 0 auto;}
#inputs { text-align: center;}
#map { width: 100%; height: 300px; }
.highlight { color: blue;}
View wd4-twitter-js-base
var TwitterApi = (function(options) {
var shared = {};
var options = options || {};
function setupListeners() {
var init = function() {
View get-coordinates.js
* Retrieve the coordinates of the given event relative to the center
* of the widget.
* @param event
* A mouse-related DOM event.
* @param reference
* A DOM element whose position we want to transform the mouse coordinates to.
* @return
View mq.css
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
View lark_template.rb
# download and git methods swiped from
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
puts "Can't get #{from} - Internet down?"