Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dvoiss's full-sized avatar
👋

David Voiss dvoiss

👋
View GitHub Profile
@dvoiss
dvoiss / gist:1920206
Created February 27, 2012 00:52
Quick bare .project file for a directory or list of directories for importation into Eclipse as stand alone "project"...
#!/bin/sh
# generates an empty .project file with just the name of the directory
# being used as the project name
# USAGE:
if [ "$1" = "-h" -o "$1" = "--help" ]; then
echo; echo "Usage: $0 [options]"
echo; echo "== Options"
echo; echo -e "Pass the string \"sub\" to generate empty .project files for \
@dvoiss
dvoiss / search.rb
Created March 27, 2012 06:22
Command-line script parses my Amazon wishlist with Nokogiri, gets related ISBNs for each book from the library-thing API, then searches Chicago Public Library for the books
# This script accepts an email address to use to retrieve an Amazon wishlist
# for, and an optional branch-ID for the Chicago Public Library system. The
# script parses the wishlist and finds the books that are available for
# *CHECK OUT* (unavailable books, in-transit, on hold, etc. are ignored).
require 'net/https'
require "open-uri"
require 'uri'
require 'zlib'
@dvoiss
dvoiss / play-itunes-stream.sh
Created March 27, 2012 06:30
Applescript aliases to play radio streams
alias npr="osascript -e 'tell application \"iTunes\" to activate' \
-e 'tell application \"iTunes\" to play playlist \"NPR\"'"
alias di="osascript -e 'tell application \"iTunes\" to activate' \
-e 'tell application \"iTunes\" to play playlist \"DI.fm\"'"
@dvoiss
dvoiss / check_site.sh
Created April 16, 2012 11:01
Run this script specifying a URL. The script will check the URL every 60 seconds to see if the contents change. If the contents change the script will beep and will continue until aborted.
function check_site()
{
local stored_hash=''
local changed=false
while sleep 60; do
# beep a bunch of times:
if $changed; then
if [[ "$(command -v osascript)" ]]; then
osascript -e "beep 5"
elif [[ "$(command -v tput)" ]]; then
@dvoiss
dvoiss / gist:3177030
Created July 25, 2012 16:16
VirtualBox/Ubuntu stuff: shared-folder and mounting / installing wine for older IE test
# enable guest additions for virtualbox
# in settings > shared folders, add a shared-folder
# make folder to mount windows/mac shared-folder to
mkdir windows-share-folder
# where 'Shared' below matches the name from the settings dialog
sudo mount -t vboxsf Shared ~/windows-share-folder
# testing old IE in Ubuntu:
sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
@dvoiss
dvoiss / challenge.py
Created August 9, 2012 07:09
Reddit Daily Programmer Challenge: Run Length Encoding
#!/usr/bin/python
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/xxbbo/882012_challenge_86_easy_runlength_encoding/c5qf7af
# Run code online: http://ideone.com/DwxRr
import sys
import re
if len(sys.argv) == 1:
@dvoiss
dvoiss / script.py
Created August 9, 2012 10:46
Reddit Daily Programmer Challenge: Weekday Calculations
#!/usr/bin/python
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/xx97s/882012_challenge_86_intermediate_weekday/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/xx97s/882012_challenge_86_intermediate_weekday/c5qgu1k
# Run code online: http://ideone.com/HIyf7
import sys
# this example assumes proper dates are entered (there are no safety checks performed)
if len(sys.argv) == 1:
@dvoiss
dvoiss / piglatin.py
Created August 11, 2012 13:18
Programming Praxis: Convert English text to Pig Latin and back again (with tests)
#!/usr/bin/env python
# convert english to pig-latin and pig-latin to english
# solution for: http://programmingpraxis.com/2009/06/02/pig-latin/2/
# rules:
# words that start with a consonant and followed immediately by a vowel,
# such as 'sorry' become 'orry-say', (first letter plus 'ay')
# words that start with vowels: 'amazing' => 'amazing-way' ('way' is appended)
@dvoiss
dvoiss / sokoban.py
Created August 12, 2012 06:11
Reddit Daily Programmer Challenge: Sokoban in the terminal
#!/usr/bin/python
# For the reddit daily programmer challenge
# Challenge: http://www.reddit.com/r/dailyprogrammer/comments/y2lbv/8102012_challenge_87_difficult_sokoban_game/
# Solution: http://www.reddit.com/r/dailyprogrammer/comments/y2lbv/8102012_challenge_87_difficult_sokoban_game/c5rv38d
# by @dvoiss on github / @daveasaurus on reddit
# Uses curses and plays in the terminal. This started out pretty minimal but
# then grew a bit in complexity, so it isn't very clean: the grid is a
@dvoiss
dvoiss / code-jam.py
Created August 12, 2012 09:42
Programming Praxis: Google Code Jam Qualification Round Exercises (2010)
# programming praxis:
# http://programmingpraxis.com/2011/02/15/google-code-jam-qualification-round-africa-2010/
# "Today's three programming exercises come from the Google Code Jam Qualification Round Africa 2010"
# 1.
# find the index of the two items that add up to the total credit amount
def store_credit(sample, credit):
for i, x in enumerate(sample):
for j, y in enumerate(sample):
if x + y == credit and i != j: