Skip to content

Instantly share code, notes, and snippets.

@oparrish
oparrish / feedwrangler-unread.py
Created February 10, 2015 02:23
Outputs current unread count, feed title, and publish date of last read item in your Feed Wrangler account
import requests
import json
import time
import sys
def get_feed(access_token, feed_id, offset=0, limit=1000, read='false', published_since='1'):
feed_payload = {'access_token': access_token, 'read': read, 'feed_id': feed_id, 'offset': offset, 'published_since': published_since, 'limit': limit}
feed_r = requests.get('https://feedwrangler.net/api/v2/feed_items/list_ids', params=feed_payload)
feed_data = json.loads(feed_r.text)
@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 / 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
@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">'