Skip to content

Instantly share code, notes, and snippets.

View gavinblair's full-sized avatar

Gavin Blair gavinblair

View GitHub Profile
@gavinblair
gavinblair / labels.css
Created October 20, 2010 17:09
Adds : after labels and * after required labels
/* Adds : after labels */
form label:after{
content:":";
}
/* Adds * after required labels */
form label.required:after{
content:"*";
}
This bookmarklet takes you to a random screen grab of a random movie.
Press it once to go to the movie listing.
Press it a second time to go to a random movie.
Press it a third time to go to a random part of the movie.
Press it one last time to go to a random screencap of that part of the movie.
To install, add a bookmark and use the following as the URL:
javascript: if(!window.location.href.startsWith("https://movie-screencaps.com/")) { window.location = "https://movie-screencaps.com/movie-directory/"; } if(window.location.href == "https://movie-screencaps.com/movie-directory/") { var movies = jQuery('.links a'); var movie = movies[Math.round(Math.random() * (movies.length + 1))]; movie.click(); } var parts = window.location.href.split('/'); if(window.location.href != "https://movie-screencaps.com/movie-directory/" && window.location.href.startsWith("https://movie-screencaps.com/") && parts[4] == "") { var page = jQuery('.paginate:first option[value='+Math.round(Math.random() * jQuery('.paginate:first opt
@gavinblair
gavinblair / random_math_question_positive_only.php
Created June 6, 2011 17:26 — forked from SeanJA/random_math_question_positive_only.php
Generate a random math question that always has a positive answer
<?php
$ops = array('-', '+');
$answer = -1;
while($answer < 0 || $answer > 99) {
$num1 = rand(0, 100);
$num2 = rand(0, 100);
$num1 -= 50;
$num2 -= 50;
@gavinblair
gavinblair / template.php
Created April 7, 2011 15:14
Use the latest jQuery with your Drupal theme
<?php
function {theme_name}_preprocess(&$vars, $hook) {
if (arg(0) != 'admin' && $hook == "page") {
// Get an array of all JavaScripts that have been added
$javascript = drupal_add_js(NULL, NULL, 'header');
// Remove the original jQuery library and Drupal's JS include
unset($javascript['core']['misc/jquery.js']);
unset($javascript['core']['misc/drupal.js']);
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig\.save)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
@gavinblair
gavinblair / resend.php
Created June 13, 2011 21:22
Drupal - resend activation email
<?php
$uid = 120;
$user = user_load(array('uid' => $uid));
$op = 'status_activated';
_user_mail_notify($op, $user);
@gavinblair
gavinblair / gist:a0760c778c43e6318a3c
Last active February 25, 2016 19:48
Bookmarklet: Random Character Design References board on Pinterest
javascript:var urls = ["https://www.pinterest.com/characterdesigh/character-design-references","https://www.pinterest.com/characterdesigh/character-design-challenge","https://www.pinterest.com/characterdesigh/character-anatomy","https://www.pinterest.com/characterdesigh/character-anatomy-ratio","https://www.pinterest.com/characterdesigh/character-anatomy-bones","https://www.pinterest.com/characterdesigh/character-anatomy-organs","https://www.pinterest.com/characterdesigh/character-anatomy-male","https://www.pinterest.com/characterdesigh/character-anatomy-female","https://www.pinterest.com/characterdesigh/character-anatomy-skin","https://www.pinterest.com/characterdesigh/character-anatomy-head","https://www.pinterest.com/characterdesigh/character-anatomy-hair","https://www.pinterest.com/characterdesigh/character-anatomy-eyes","https://www.pinterest.com/characterdesigh/character-anatomy-nose","https://www.pinterest.com/characterdesigh/character-anatomy-ears","https://www.pinterest.com/characterdesigh/character-
@gavinblair
gavinblair / wanted.md
Last active January 4, 2016 03:59
Wanted: #ldnont Council Meeting Vote Parser

Open Council

Open Council is happening! Currently a London implementation of Kevin O'Donnell's OttWatch system is working hard on pulling meetings from London's SIRE system, making it so you can discuss individual council meetings publicly.

A very important part of the original vision for Open Council was the ability to view council votes by councillor. We are almost there! London records their votes in a very different way than Ottawa, however, and we've run into a bit of a snag.

So, I have a programming challenge for you!

Given a council meeting's minutes from London's implementation of SIRE, output the motions made and the voting results in a machine-readable format.

@gavinblair
gavinblair / post.md
Last active December 29, 2015 15:59
Gluten Free Lunch

Gluten Free Lunch

I found out that I had a problem with gluten in February 2012. It wasn't as difficult as I thought it would be to go gluten free. There are only really three recurring issues that I constantly face:

  • If something is gluten free, it doesn't mean that I will like it - There are a LOT of gluten free products out there. A lot of it tastes like sand.
  • I miss beer. - I have taken to drinking White Russians. That's a hell of a caucasian, Jackie
  • If I don't pack a lunch, I'm screwed. - I have about four go-to lunches in downtown London. This list starts to feel pretty short after a while, and it severely limits options when going out with others.

While I can't do much about the first two (besides becoming The Dude), I can at least crowdsource some options for lunch downtown! Check it out, and if you know any gluten free meals downtown, please add to the list.

@gavinblair
gavinblair / post.md
Created November 28, 2013 16:11
QRapt