Skip to content

Instantly share code, notes, and snippets.

@dvoiss
dvoiss / challenge.py
Created Aug 9, 2012
Reddit Daily Programmer Challenge: Run Length Encoding
View challenge.py
#!/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 / gist:3177030
Created Jul 25, 2012
VirtualBox/Ubuntu stuff: shared-folder and mounting / installing wine for older IE test
View gist:3177030
# 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 / check_site.sh
Created Apr 16, 2012
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.
View check_site.sh
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 / play-itunes-stream.sh
Created Mar 27, 2012
Applescript aliases to play radio streams
View play-itunes-stream.sh
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 / search.rb
Created Mar 27, 2012
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
View search.rb
# 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 / podcast-feed-generator.sh
Created Mar 19, 2012
Made this for a friend - generates an xml feed for a podcast directory, didn't exactly finish it...reads id3v1 tags (id3v2 requires external libraries), runs applescript to open iTunes and load feed for testing, serves feed over http (iTunes required)
View podcast-feed-generator.sh
#!/bin/bash
# generate an xml podcast file for a directory of files
#
# I parse id3v1 tags but only for the artist and track title,
# most of the samples did not have reliable meta-data, so the
# file-name is used.
#
# I don't process id3v2 tags because an external library would be needed
# such as id3lib.
@dvoiss
dvoiss / gist:1920206
Created Feb 27, 2012
Quick bare .project file for a directory or list of directories for importation into Eclipse as stand alone "project"...
View gist:1920206
#!/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 \