Skip to content

Instantly share code, notes, and snippets.

View jletourneau's full-sized avatar

Jack Letourneau jletourneau

View GitHub Profile
@jletourneau
jletourneau / ruck-beer.py
Last active January 27, 2018 05:04
Ruck beer list scraper
#!/usr/bin/python
from pyquery import PyQuery as pq
import re
import datetime
print datetime.datetime.now().strftime('%c')
print
doc = pq(url='http://www.beermenus.com/places/4733-the-ruck')

Keybase proof

I hereby claim:

  • I am jletourneau on github.
  • I am jlet (https://keybase.io/jlet) on keybase.
  • I have a public key whose fingerprint is 4B2D AA0A 3C84 DD6C 05D5 DA48 C307 2D17 4882 FA40

To claim this, I am signing this object:

@jletourneau
jletourneau / gist:4950200
Created February 14, 2013 02:40
AppleScript to eject all ejectable volumes. Useful for quickly disconnecting a laptop from external drives etc. for traveling.
tell application "Finder"
eject (every disk whose ejectable is true)
end tell
@jletourneau
jletourneau / unfill.el
Last active November 19, 2015 13:57
Unfilling paragraphs in Elisp
(defun unfill-region (start end)
"Unfill the current region; i.e. remove all newlines within paragraphs.
If an active region is not present, unfill the entire buffer."
(interactive "r")
(let ((fill-column (point-max)))
(if (use-region-p)
(fill-region start end)
(fill-region (point-min) (point-max)))))
@jletourneau
jletourneau / hydra-intro.md
Created October 24, 2012 15:02
Plugging Hydra into your game

Plugging Hydra into your game

This documentation explains how to build Hydra profile support into an existing game. As our example, we’ll be working with a very simple “game” called Masher, written in Python, which prompts the user for their name, reads lines of input one at a time, and adds up the number of characters the user has entered.

The original version of the game stores the user’s name, rounds played, and count of characters typed in a data structure which is saved to a file on disk using Python’s pickle module. Our goal is to modify this game to store the player’s data in Hydra instead.

Setting up Hydra to start accepting data

@jletourneau
jletourneau / masher.py
Created October 24, 2012 14:50
Masher, pre-Hydra integration
#!/usr/bin/env python
import sys, os, pickle
from collections import defaultdict
class Masher:
def __init__(self, savefile):
self._savefile = savefile
self._read_profile()
@jletourneau
jletourneau / battery-info.py
Created October 10, 2012 17:24
OS X battery info in Python
#!/usr/bin/env python
import subprocess, re
def battery_info():
ioreg = subprocess.check_output(
['ioreg', '-r', '-w0', '-cAppleSmartBattery']
).split("\n")
d = dict()
for line in ioreg:
@jletourneau
jletourneau / tesla.py
Created July 11, 2012 17:24
Demo code sample
import utils
@utils.memoize
def fib(n):
if n < 3:
return 1
return fib(n - 2) + fib(n - 1)
(i, sum) = (1, 0)
while True:
@jletourneau
jletourneau / helper.rb
Created June 29, 2012 17:46
Haml helper for IE conditional comments visible to non-IE browsers
def iecc_visible(condition, &block)
output = capture_haml(&block)
"<!--[#{condition}]><!-->#{output.chomp}<!--<![endif]-->\n"
end
@jletourneau
jletourneau / gist:808186
Created February 2, 2011 19:04
Extract GitHub URL from Git config file and open with system default web browser
perl -ne 'print "https://$1/$2" if (/(github\.com):(.+)\.git/)' .git/config | xargs open