Skip to content

Instantly share code, notes, and snippets.

View gillibrand's full-sized avatar

Jay Gillibrand gillibrand

  • Southern California, USA
View GitHub Profile
@gillibrand
gillibrand / air_hockey.py
Created August 6, 2012 05:38
An Air Hockey game for Pythonista on iPad and iPhone. Yes, I typed this all on my iPad. A little painful.
# Hockey
#
# A air hockey game for two players. First to
# seven wins.
# Most of the game is drawn with the scene
# module. Goal and winner messages are animated
# with layers.
from scene import *
from sound import *
@gillibrand
gillibrand / two_equal_columns_in_css.html
Last active December 15, 2015 21:58
A way to get two equal sized columns in CSS that works in IE 8. You could just give up and use a <table>, but I'm not sure how to get the columns equal and get a fixed gutter (maybe make them 50%,0,50% but a fixed size div in the middle column to rubber band it open?).
<!DOCTYPE html>
<html>
<head>
<title> Two Equal Columns in CSS </title>
<style type="text/css">
.twoColumns {
position: relative;
}
@gillibrand
gillibrand / tab_out_of_paired_characters.sublime-keymap.js
Last active December 16, 2015 10:59
Sublime Text key bindings to make auto-paired characters more useful. Lets you can `tab` out of a string (and `[]` and `()`) if the cursor is before the closing character. Only used these for a few hours... may need some tweaking.
// Move out of common paired characters () and [] with `Tab`
{
"keys": ["tab"],
"command": "move",
"args": {"by": "characters", "forward": true},
"context":
[
// Check if next char matches (followed by anything)
{ "key": "following_text", "operator": "regex_match", "operand": "(:?`|\\)|\\]).*", "match_all": true },
// ...and that there is a paid character before it on the same
@gillibrand
gillibrand / gist:5898505
Created July 1, 2013 05:16
A URL to get Mr. Reader to send links to Pinbook, then switch back to Mr. Reader. Add it as the URL Scheme Template of a new Services entry.
pinbook://x-callback-url/add?url=[URL]&title={[TITLE]}&description={[TEXT-SELECTED]}&x-success={mrreader://}
@gillibrand
gillibrand / totalhours.py
Last active January 2, 2016 01:59
A custom preprocessor for Marked.app that makes it into a super simple time tracker. Finds all the hours in a document (e.g., +1h, +2h, +3h, etc.) and shows the total in a floating badge. Only looks for whole number hours (no minutes or fractions). See a screenshot at http://cl.ly/TB7D
#!/usr/bin/env python
import sys, re
hours_re = re.compile(r'([-+] \d+)h \b', re.X)
total = 0
for line in sys.stdin:
total += sum(int(hour) for hour in hours_re.findall(line))
print line.strip()
@gillibrand
gillibrand / Pinner URL Scheme
Created January 26, 2014 18:26
A URL to get Mr. Reader to send links to Pinner, then switch back to Mr. Reader. Add it as the URL Scheme Template of a new Services entry. Defaults to `Shared` and not `To Read`.
pinner://x-callback-url/bookmark?x-source=Pinner&href={[URL]}&title={[TITLE]}&extended={[TEXT-SELECTED]}&toread=0&x-success={mrreader://}&x-cancel={mrreader://}&shared=1
// javascript:(function()%20{if%20(window.___focusInterval)%20{clearInterval(window.___focusInterval);delete%20window.___focusInterval;return;}window.___focusInterval%20=%20setInterval(function()%20{console.debug(document.activeElement);}%2C%202000);})();
// Logs the :focus-ed element every few seconds. This can be helpful when
// debugging why the focus is getting lost or is on a visually hidden element.
// Toggles the logging on or off.
(function() {
if (window.___focusInterval) {
clearInterval(window.___focusInterval);
delete window.___focusInterval;