Skip to content

Instantly share code, notes, and snippets.

@oparrish
oparrish / gist:1092990
Created July 19, 2011 16:31
Downloading Facebook profile picture
private static final String PROFILE_PICTURE_URL = "https://graph.facebook.com/%s/picture?type=large&access_token=%s";
private String downloadFacebookProfilePicture(String uid, String accessToken, String username) throws MalformedURLException, IOException {
//Get the picture url
HttpURLConnection.setFollowRedirects(false);
String profilePictureUrlString = new URL(String.format(PROFILE_PICTURE_URL, uid, accessToken)).openConnection().getHeaderField(
"location");
//Set up temp location for picture
String fileExtension = StringUtils.substring(profilePictureUrlString,
@oparrish
oparrish / gist:1134751
Created August 9, 2011 18:07
Move Message(s) to All Mail
tell application "Mail"
set theSelectedMessages to selection
set theMailbox to "[Gmail]/All Mail"
repeat with theMessage in theSelectedMessages
set messageAccount to account of mailbox of theMessage
tell application "Mail"
move the theMessage to mailbox theMailbox of messageAccount
end tell
end repeat
@oparrish
oparrish / Script.sh
Created August 25, 2011 12:57
Bash script for transcoding videos to AppleTV format to be used by an Alfred extension
#!/bin/bash
#transcode.sh
#By Don Southard aka @binaryghost
#
#[UPDATE 6/01/2011 08:01:15PM]
#Idea and initialcode for Alfred progress bar by Andreas Heiberg
#Completly rewritten code by Don Southard
#
#[UPDATE 6/02/2011 08:58:09PM]
#Support for queueing, added information about queue status and ETA'S and the move the old file to trash feature
@oparrish
oparrish / assets_deploy.rb
Created September 20, 2011 15:44
Rake task for copying Rails compiled assets to S3
require 'aws/s3'
require 'digest/md5'
require 'mime/types'
## These are some constants to keep track of my S3 credentials and
## bucket name. Nothing fancy here.
AWS_ACCESS_KEY_ID = ENV['S3_KEY']
AWS_SECRET_ACCESS_KEY = ENV['S3_SECRET']
AWS_BUCKET = ENV['S3_BUCKET']
@oparrish
oparrish / bootstrap_pagination_helper.rb
Created September 28, 2011 18:35
Link renderer to be used with will_paginate to render links to work with Twitter Bootstrap
module BootstrapPaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def page_number(page)
unless page == current_page
link(page, page, :rel => rel_value(page))
else
link(page, "#", :class => 'active')
end
@oparrish
oparrish / audio_tag.rb
Created March 6, 2012 15:55
Jekyll tag plugin for creating HTML 5 audio element based on a list of source files
module Jekyll
class AudioTag < Liquid::Tag
def initialize(tag_name, files, tokens)
super
@files = files
end
def render(context)
HTML << '<audio controls="controls">'
@oparrish
oparrish / podcast.rb
Created March 31, 2012 16:17
Create podcast from directory
require 'rss/maker'
require 'optparse'
require 'uri'
options={}
opts = OptionParser.new do |opts|
opts.on("-d", "--directory DIRECTORY", "Director of files") do |directory|
options[:directory] = directory
end
@oparrish
oparrish / cue_to_html.rb
Last active December 26, 2015 08:49
Ruby script to format a CUE sheet as HTML output
require 'rubycue'
require 'optparse'
options = {}
opts = OptionParser.new do |opts|
opts.on("-c", "--cue PATH", "Path to chesheet file") do |cue_file|
options[:cue] = cue_file
end
end
@oparrish
oparrish / SSH.py
Created November 14, 2013 16:34
AutoKey (https://code.google.com/p/autokey/) script to open a new tab in Terminator with SSH to selected IP.
import subprocess
import re
try:
host = clipboard.get_selection()
host = host.strip()
pattern = re.compile("^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$")
validHost = pattern.match(host)
if validHost:
@oparrish
oparrish / get_m4a_duration.py
Last active December 29, 2015 15:59
Output the duration for an M4A
#!/usr/local/bin/python
import sys
from mutagen.mp4 import MP4
m4a_file = sys.argv[1]
m4a = MP4(m4a_file)
length_secs = m4a.info.length