Skip to content

Instantly share code, notes, and snippets.

Avatar

Greg Haygood greghaygood

View GitHub Profile
View lark_template.rb
# download and git methods swiped from http://github.com/Sutto/rails-template/blob/07b044072f3fb0b40aea27b713ca61515250f5ec/rails_template.rb
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!
@greghaygood
greghaygood / fix-xcode7-command-line.md
Last active Sep 21, 2015
'unistd.h' file not found for Xcode 7
View fix-xcode7-command-line.md

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 cputhrottle.cc
In file included from cputhrottle.cc:5:
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:
View mq.css
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
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 get-coordinates.js
// http://acko.net/blog/mouse-handling-and-absolute-positions-in-javascript/
/**
* 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 wd4-twitter-js-base
var TwitterApi = (function(options) {
var shared = {};
var options = options || {};
function setupListeners() {
console.log('setupListeners()');
}
var init = function() {
@greghaygood
greghaygood / index.html
Last active Dec 28, 2015
Template for the Week 7 homework
View index.html
<!DOCTYPE html>
<html>
<head>
<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 keybase.md

Keybase proof

I hereby claim:

  • I am greghaygood on github.
  • I am greghaygood (https://keybase.io/greghaygood) on keybase.
  • I have a public key ASCsM60eyG5SOl2uX0uRfSxjhDQkDGC2fCJ3cOkLU9YnLQo

To claim this, I am signing this object:

@greghaygood
greghaygood / reactotron-config.md
Last active Aug 30, 2016
Reactotron debug logger
View reactotron-config.md

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
@greghaygood
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.
$AUTO_ASSIGNED_GROUP_NAME = 'General';
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
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 https://github.com/greghaygood
// @version 1.0
// @description Add keyboard shortcuts for UI controls on the WaPo crossword puzzle app
// @author Greg Haygood <haygoodg@gmail.com>
// @match https://www.washingtonpost.com/crossword-puzzles/*
// @icon https://www.google.com/s2/favicons?domain=tampermonkey.net
// @license MIT
// ==/UserScript==