Skip to content

Instantly share code, notes, and snippets.

View kristianfreeman's full-sized avatar
🙃

Kristian Freeman kristianfreeman

🙃
View GitHub Profile
@kristianfreeman
kristianfreeman / lastfm.rb
Last active December 10, 2015 17:58
Wrap the lastexport tool and make nice things with it
#!/usr/bin/env ruby
require 'choice'
USERNAME = 'kristianfr'
# Get some command-line arguments (or one)
Choice.options do
option :export, :required => true do
short '-e'
@kristianfreeman
kristianfreeman / .tmux.conf
Created December 9, 2012 07:26 — forked from fholgado/.tmux.conf
Show iTunes current track/song in tmux
# Custom status bar
# # Powerline symbols: ⮂ ⮃ ⮀ ⮁ ⭤
set -g status-left-length 32
set -g status-right-length 150
set -g status-interval 5
set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]⮀'
set -g status-right '#[fg=colour245]⮃ %R ⮃ %d %b #[fg=colour254,bg=colour234,nobold]#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)⮂#[fg=colour16,bg=colour254,bold] #h '
# set -g status-right '#(~/Documents/AppleScripts/itunes-current-track-tmux.sh)'
set -g window-status-format "#[fg=white,bg=colour234] #I #W "
set -g window-status-current-format "#[fg=colour234,bg=colour39]⮀#[fg=colour16,g=colour39,noreverse,bold] #I ⮁ #W #[fg=colour39,bg=colour234,nobold]⮀"
require 'date'
require 'time'
dates = File.open('dates.txt')
csv_array = Array.new
dates.readlines.each_with_index do |line, i|
next if i == 0
t = Time.parse(line)
fixed_date = t.strftime("%F")
square = File.new "foursquare.kml"
date_array = Array.new
square.readlines.each do |line|
date = line.match(/<updated>\w*, \S* \w* \S* \S* \+0000<\/updated>/)
date_array << date
end
puts date_array
@kristianfreeman
kristianfreeman / tent.rb
Created October 2, 2012 03:48
Tent.is posts to Day One
## Tent.io work
require 'json'
require 'time'
# Change these to suit your needs
# You probably don't want my posts.
username = "kmf"
post_location = "/Users/kristian/Dropbox/ifttt/tent"
Dir.chdir post_location
@kristianfreeman
kristianfreeman / depart
Created September 5, 2012 08:02
Using mencoder to combine AVIs... legal AVIs.
#!/bin/sh
echo "Checking for mencoder..."
if ! type "mplayer" > /dev/null; then
echo "mencoder not found. Attempting install with brew"
if ! type "brew" > /dev/null; then
echo "Homebrew not installed. Fail."
exit
fi
@kristianfreeman
kristianfreeman / applescript-markdown-urls.md
Created August 30, 2012 04:35
Applescript TE snippet for automation of Safari link pulling
set linkText to "%fill:text%"

try
    tell application "Safari"
        set currentURL to URL of current tab of front window
    end tell
    set link to "[" & linkText & "](" & currentURL & ") "
    return link
on error

"None"

@kristianfreeman
kristianfreeman / instagram-captions.md
Created August 24, 2012 04:37
Adding captions to Instagram photos with Slogger/Day One

One of my gripes with Slogger is that when Instagram photos are added, they have no text captions. This makes sense though — the built-in system for adding photos is really as simple as passing the image as an argument.

Still, there had to be a way to make this work! I decided that with a little tweaking of my current IFTTT script, I could get captions included in my Day One entries.

The best way to do this is to setup your IFTTT script to download photos to Dropbox with good file-names. Mine's really simple; it's just CAPTION.jpg. Yep. With the text parsing I'm doing, this works just fine. If I want to sort by date, I can simply sort in Finder by "Date Added". No complaints there. Now for the code.

Let's start with slogger_image.rb, the file used for importing Instagram photos.

After line 12, we see where the file is added as a variable:

@kristianfreeman
kristianfreeman / subtitle-search
Created August 18, 2012 05:28
alfred search for subs on open subtitle
@kristianfreeman
kristianfreeman / gistsnip.md
Created August 13, 2012 20:15
TE snippet for iTunes Now Playing Output

A simple TextExpander snippet for pasting a nice-looking version of your "Now Playing" from iTunes. Uses Applescript — if you have a different music player (Spotify, for example), it probably has similar Applescript support.

For example: ♫ "My Favourite Things" - John Coltrane (The Very Best of John Coltrane, 2000)

set the_string to ""

tell application "iTunes"
   if player state is playing then
      set the_string to "\"" & name of current track & "\""

if artist of current track is not "" then