Skip to content

Instantly share code, notes, and snippets.

@jtwalters
jtwalters / quit-and-relaunch.applescript
Created March 4, 2014 22:21
Quit and relaunch an application in AppleScript, e.g., Google Chrome—to finish installing updates.
set appName to "Google Chrome"
tell application appName to quit
repeat
tell application "System Events"
if appName is not in (name of application processes) then exit repeat
end tell
do shell script "sleep 0.5"
end repeat
tell application appName to launch
/**
* For jQuery versions less than 3.4.0, this replaces the jQuery.extend
* function with the one from jQuery 3.4.0, slightly modified (documented
* below) to be compatible with older jQuery versions and browsers.
*
* This provides the Object.prototype pollution vulnerability fix to Drupal
* installations running older jQuery versions, including the versions shipped
* with Drupal core and https://www.drupal.org/project/jquery_update.
*
* @see https://github.com/jquery/jquery/pull/4333
@jtwalters
jtwalters / alter-table-node.sql
Created February 27, 2019 23:59
Use this SQL statement below on your _LOCAL_ environment to make the next created node match a specific NID.
/*
Use the SQL statement below on your _LOCAL_ environment to make the next created node match a specific NID.
*/
ALTER TABLE node AUTO_INCREMENT = 123456
@jtwalters
jtwalters / sticky-list-heading.js
Last active February 5, 2019 23:28
List with sticky headings/titles, where each sticky element is constrained/bound to its parent. Requires jQuery, Waypoints (http://imakewebthings.com/waypoints/)
/**
* Sticky, single elements bound to their containers.
* Parent: .sticky-single
* Child: .sticky-single__element
*/
$('.sticky-single__element').each(function initializeStickySingle() {
// Create an "enter" sticky-single waypoint handler.
new Waypoint({
element: this,
offset: 0,
@jtwalters
jtwalters / README.md
Last active April 21, 2017 17:30
Better Filters for GitHub — Provides filters for GitHub Projects.

Better Filters for GitHub was written to help a large Project board more manageable, by toggling the label display, and filtering down to issues tagged with a certain label or assignee.

It looks like this:

Install

@jtwalters
jtwalters / cross-browser-window-load-function.js
Last active November 16, 2016 22:04
Cross browser addEvent function (window load, ready, etc.)
(function () {
//////////////////////////////
// Add event (cross browser)
// From http://stackoverflow.com/a/10150042
//////////////////////////////
function addEvent(elem, event, fn) {
if (elem.addEventListener) {
elem.addEventListener(event, fn, false);
} else {
elem.attachEvent('on' + event, function() {
@jtwalters
jtwalters / LakeUnion10K.csv
Last active August 15, 2016 16:39
2016 Lake Union 10K Results (as of 8/15) — CSV Download
Rank Name Bib Time Time (Minutes) Pace Pace (Minutes) Hometown Division Div Rank
1 Andrew Ivanov 698 00:33:40 33.667 05:25 5.417 apt 534, WA m30-34 1
2 Jonathan Youell 1522 00:33:59 33.983 05:29 5.483 Boise, ID m25-29 1
3 Jalen Chase 299 00:34:11 34.183 05:30 5.500 New Town, ND m15-19 1
4 Lance Thompson 1387 00:34:18 34.300 05:32 5.533 US m35-39 1
5 Jacob Marsh 890 00:35:17 35.283 05:41 5.683 Seattle, WA m30-34 2
6 Zach Chupik 317 00:37:24 37.400 06:02 6.033 Bothell, WA m15-19 2
7 James Ebberson 425 00:37:27 37.450 06:02 6.033 Seattle, WA m30-34 3
8 Jamie Miller 952 00:37:29 37.483 06:02 6.033 Seattle, WA m35-39 2
9 Eduardo Carrillo 278 00:37:33 37.550 06:03 6.050 Lynnwood, WA m35-39 3
@jtwalters
jtwalters / git-grepwords
Last active July 19, 2016 09:11
Grep multiple words in your git commit message history
# Example use: find commit messages that contain pattern1 and pattern2
# $ git grepwords pattern1 pattern2
# Ensure we have at least one param (a pattern)
[ -n "$1" ] || { echo "usage: $0 PATTERN..." >&2; exit 1; }
pattern=""
# Append all remaining patterns
while [ -n "$1" ]; do
/**
* New Tabia/Components JS-pattern.
*/
// Loose augmentation pattern. Creates top-level namespace variable if it
// doesn't already exist.
var Tabia = Tabia || {};
// Create a base for this module's data and functions.
Tabia.myBehavior = {};
@jtwalters
jtwalters / parse-duration-to-seconds.js
Last active March 21, 2016 18:09
Parse DOM element's h:mm:ss to seconds and replace (in place).
// Parse duration value from table cell, replacing as seconds...
$table.find('td:nth-child(7)').each(function () {
var value = this.innerHTML.trim(),
seconds = moment.duration(value).asSeconds();
this.innerHTML = seconds;
});