Skip to content

Instantly share code, notes, and snippets.

View timkeller's full-sized avatar

Tim Keller timkeller

View GitHub Profile
@timkeller
timkeller / redbull-stratos-api-log.php
Created October 14, 2012 17:44
Logging the Redbull Stratos API
<?php
/*
Log RedBullStratos Telemetry
Each telemetry data point is in the form:
[AltitudeImperial] => 103477.69028871
[AltitudeIsValid] => 1
@timkeller
timkeller / count-in-a-week.sql
Created March 2, 2012 13:10
For a simple user awards system: Show all users who received more than 3 awards in a single calendar week. Exclude awards that have already been issued.
SELECT user_id,
COUNT(*) AS num,
date_format(creation_date, '%Y%u') AS theweek,
FROM awards
WHERE issued = 0
GROUP BY user_id, theweek
HAVING num >= 3;
@timkeller
timkeller / multidb-alter-syntax-generator.sql
Created March 1, 2012 14:49
Quick generator, in sql, to create ALTER sql instructions for a set of databases of the same schema on the same MySQL server
SELECT
CONCAT(
'ALTER TABLE `',
TABLE_SCHEMA,
'`.`',
TABLE_NAME,
'` ADD `change-field-name` VARCHAR(5) NULL DEFAULT NULL',
';'
) AS sql_string
FROM
@timkeller
timkeller / gist:1870762
Created February 20, 2012 19:04
A few quick timezone conversions for a friend (and his co-workers)
<?php
/*
PARSE CSVs OF SHIFT DATA
FORMAT: Note that spaces outside of < >'s are significant. ( )'s indicate optional
<Shift Number>, <start-end>(,<start-end>), <Days of the week off>
eg. Shift 16, 0700-1200,1700-2200, Mon,Tue,Wed off
eg. Shift 102, 0900-1930, Wed,Thu,Sat off
@timkeller
timkeller / application.js
Created February 9, 2012 11:23
JS to make .subnav sticky
!function ($) {
$(function(){
// fix sub nav on scroll
var $win = $(window)
, $nav = $('.subnav')
, navTop = $('.subnav').length && $('.subnav').offset().top - 40
, isFixed = 0