Skip to content

Instantly share code, notes, and snippets.

View jdillick's full-sized avatar

John Dillick jdillick

View GitHub Profile
@jdillick
jdillick / service-workers.md
Created July 10, 2023 17:03 — forked from Rich-Harris/service-workers.md
Stuff I wish I'd known sooner about service workers

Stuff I wish I'd known sooner about service workers

I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.

I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.

Use Canary for development instead of Chrome stable

Chrome 51 has some pretty wild behaviour related to console.log in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.

@jdillick
jdillick / unlock-mac-system-preferences-pane.md
Last active March 2, 2016 17:08
Unlock a Mac System Preferences Pane

Unlock Pesky System Preference Pane Lockdown

Note, you're local mac account must have sudo privs for this to work. If you're in the same boat I'm in, there is some piece of management software (e.g. casper) installed on your system that removes access to system preference panes when you login (to a domain).

In my case, the "Security and Privacy" pane was removed by a network admin for I'm sure they believed to be very important reasons, but this prevents me from using my window management tool (BetterSnapTool).

On to the steps

In this example, I'm unlocking the "Security and Privacy" pane. You will need to substitue your locked panes plist below.

@jdillick
jdillick / fix-image-location.php
Created June 9, 2015 15:35
Migrates Drupal managed image to new directory specified in the field instance settings. Takes argument entity and bundle containing the image field.
<?php
$args = drush_get_arguments();
$entities = array();
$entity_info = entity_get_info();
foreach ($entity_info as $name => $info) {
$entities[$name] = array_keys($info['bundles']);
}
@jdillick
jdillick / .gitconfig
Created January 8, 2015 14:21
Create local branch from Stash Pull-Request
[alias]
prstash = "!f() { git fetch $1 refs/pull-requests/$2/from:$3; } ; f"
@jdillick
jdillick / generate-strongarms.php
Last active August 29, 2015 13:56
Drush script to generate strongarm variables module for a site
<?php
$args = drush_get_arguments();
if ( ! isset($args[2]) ) {
drush_set_error('Usage: drush @<alias> scr generate-strongarm.php <module_name> <base_path>');
exit();
}
$module_name = $args[2];
if ( ! isset($args[3]) ) {
@jdillick
jdillick / makefile-parse.php
Created January 27, 2014 19:40
drush script for parsing makefiles
<?php
$stuff = make_parse_info_file('makefiles/highlights.make');
print_r($stuff);
@jdillick
jdillick / aliases.drushrc.php
Last active December 24, 2015 02:39
Dynamic drush aliases. Just modify $paths to include the directory to your drupal installs, and you have instant aliases.
<?php
// the current environment
$env = $_ENV['ENVTYPE'] ? $_ENV['ENVTYPE'] : '';
// paths to search for drupal sites
$paths = array(
'/var/www/multisites/',
'/var/www/schoolyard/',
);
@jdillick
jdillick / find_closest_sha1.py
Created January 17, 2013 16:06
Found this little gem of python for comparing a git repo to an un-versioned copy of the code. I returns the closest commit hash from the git repository corresponding to your code. This works great when you don't know what version of the code you have running.
#!/usr/bin/env python
import subprocess
import shlex
import sys
import os
import operator
gitdir,workdir=map(os.path.realpath,sys.argv[1:3])
os.chdir(gitdir)
proc=subprocess.Popen(shlex.split('git rev-list --all'),stdout=subprocess.PIPE)