Skip to content

Instantly share code, notes, and snippets.

View mwerner's full-sized avatar

Matthew Werner mwerner

  • Oakland, CA
View GitHub Profile
artist_name=`arch -i386 osascript -e'tell application "Spotify"' -e'get artist of current track' -e'end tell'`
song_title=`arch -i386 osascript -e'tell application "Spotify"' -e'get name of current track' -e'end tell'`
artist=`echo $artist_name | sed "s/[[:space:]]/%20/g"`
title=`echo $song_title | sed "s/[[:space:]]/%20/g"`
song=`curl -s "http://makeitpersonal.co/lyrics?artist=$artist&title=$title"`
echo -e "$artist_name - $song_title\n$song" | less
@mwerner
mwerner / cronlist.sh
Created April 26, 2012 18:26
cronlist
#!/bin/bash
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
CRONDIR='/etc/cron.d'
# Single tab character. Annoyingly necessary.
tab=$(echo -en "\t")
# Given a stream of crontab lines, exclude non-cron job lines, replace
@mwerner
mwerner / gist:3085657
Created July 10, 2012 19:24
Display all attributes and link any associations
resource.attributes.each_pair do |key, value|
associations = resource.class.reflect_on_all_associations.map &:name
content_type = key[0..(key.index('_id') || -1)-1].to_sym
return value unless associations.include?(content_type)
association = resource.send(content_type)
link_to(association, [:admin, association])
end
@mwerner
mwerner / gist:3229294
Created August 1, 2012 18:01
List postgres databases
psql -U postgres -h somehost --list
@mwerner
mwerner / gist:3229308
Created August 1, 2012 18:01
Turn off postgres paged results
/pset pager off
@mwerner
mwerner / gist:3801526
Created September 28, 2012 18:55
XBMC Time Seek Config
~/Library/Application Support/XBMC/userdata$ cat advancedsettings.xml
<advancedsettings>
<video>
<timeseekforward>10</timeseekforward> <!-- Defaults to 30. -->
<timeseekbackward>-10</timeseekbackward> <!-- Defaults to -30. -->
<timeseekforwardbig>300</timeseekforwardbig> <!-- Defaults to 600 (10 minutes). -->
<timeseekbackwardbig>-300</timeseekbackwardbig> <!-- Defaults to -600 (10 minutes). -->
</video>
</advancedsettings>
@mwerner
mwerner / README.md
Created October 13, 2013 03:43 — forked from nikcub/README.md
@mwerner
mwerner / prompt.zsh
Last active December 25, 2015 13:19
Make your prompt remind you you're currently in an ssh session
current_machine(){
if [[ $(echo $SSH_CONNECTION 2>/dev/null | tail -n 1) != '' ]]; then
echo "%{$fg_bold[yellow]%}($(hostname))%{$reset_color%} "
fi
}
export PROMPT=$'$(current_machine)$(pwd)› '
@mwerner
mwerner / unsplash.rb
Created December 5, 2013 23:51
Scrape Unsplash
require 'open-uri'
require 'nokogiri'
require 'fileutils'
class Scraper
attr_accessor :url, :selector, :page
def initialize(url, selector)
@url = url
@mwerner
mwerner / hello.go
Last active December 30, 2015 20:29
Hello Go
package main
import (
"fmt"
"log"
"net/http"
)
const listenAddr = "localhost:4000"