Skip to content

Instantly share code, notes, and snippets.

View jletourneau's full-sized avatar

Jack Letourneau jletourneau

View GitHub Profile
@jletourneau
jletourneau / bg_gradient.html
Created February 20, 2015 15:32
CSS text background gradients
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CSS text gradient</title>
<style type="text/css">
h1 {
display: inline;
font: bold 72px 'Helvetica Neue', Helvetica, sans-serif;
line-height: 1;
@jletourneau
jletourneau / timed_mute.scpt
Last active August 29, 2015 14:22
Timed mute AppleScript
global mute_time
global wait_complete
on run
display dialog "Mute for how many seconds?" default answer "120"
set mute_time to text returned of result as number
set volume with output muted
set wait_complete to 0
@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
@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 / 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 / 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 / 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 / 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 / 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 / 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