Skip to content

Instantly share code, notes, and snippets.

View gavinblair's full-sized avatar

Gavin Blair gavinblair

View GitHub Profile
@gavinblair
gavinblair / script.js
Created January 23, 2012 15:57
Get hash of an anchor
$("<a href='http://www.google.com#hello'>gavin</a>")[0].hash //returns "#hello"
$("#mylink")[0].hash //jquery selector
document.getElementById("mylink").hash //no jquery
@gavinblair
gavinblair / query.sql
Created January 23, 2012 19:51
Add to a date in MySQL
SELECT date_add('2012-01-23', INTERVAL 7 DAY) -- returns 2012-01-30
@gavinblair
gavinblair / style.css
Created February 2, 2012 21:46
heading with bullets
h3 {
display: table;
width: 100%;
}
h3:before,
h3:after {
content: '\00a0';
width: 20%;
display: table-cell;
background: url(../img/320/bullet.gif) repeat-x 1px;
@gavinblair
gavinblair / index.html
Created February 7, 2012 22:59
"randomly" angled highlights
<p class='highlighted'>
<span>This is a line</span>
<span>This is a line</span>
<span>This is a line</span>
</p>
@gavinblair
gavinblair / index.php
Created February 9, 2012 19:01
I always forget the syntax for this
<?php
//copy and paste me
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
@gavinblair
gavinblair / LICENSE.txt
Created February 16, 2012 15:44 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@gavinblair
gavinblair / gist:2353893
Created April 10, 2012 19:33
Birthday Wishes
Hello Gavin, the father. This is Past Gavin. I went ahead and renewed your licence sticker to 2013 since you probably have a lot on your mind already. Happy Birthday!
P.S. Next year you will have to renew the sticker AND your licence, so please pay it forward.
@gavinblair
gavinblair / click.js
Created April 16, 2012 15:13
difference between simulated click and actual click
setInterval(function(){
$("#mybutton").click();
}, 1000);
$("#mybutton").click(function(e){
if(e.originalEvent === undefined) {
@gavinblair
gavinblair / gist:2512556
Created April 27, 2012 20:12
Really simple programming project ideas
var ideas = [
"Calculator",
"To-Do List",
"Address Book",
"Nickname Generator",
"Text-Based RPG",
"Password Generator",
];
@gavinblair
gavinblair / script.js
Created April 30, 2012 15:47
disable scrolling
// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = [37, 38, 39, 40];
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}