This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'zlib' | |
require 'open-uri' | |
url = "http://www.discogs.com/release/123?f=xml&api_key=111" | |
headers = {'Accept-Encoding' => 'gzip', 'User-Agent' => 'MyDiscogsClient/1.0 +http://mydiscogsclient.org'} | |
begin | |
response = open(url, headers) | |
begin | |
data = Zlib::GzipReader.new(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2, gzip, cStringIO | |
url = 'http://www.discogs.com/release/123?f=xml&api_key=1111' | |
headers = {'Accept-Encoding': 'gzip', 'User-Agent': 'MyDiscogsClient/1.0 +http://mydiscogsclient.org'} | |
request = urllib2.Request(url, None, headers) | |
try: | |
response = urllib2.urlopen(request) | |
data = response.read() | |
try: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListItem < ActiveRecord::Base | |
belongs_to :list | |
serialize :data | |
def method_missing(meth) | |
if list.fields.map { |f| f.name.parameterize.underscore }.include?(meth) | |
data[meth.to_sym] if data | |
else | |
super | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def public_url_to(resource) | |
if resource.respond_to?(:slug) | |
if resource.is_a?(Article) | |
yield post_url(resource.to_url) | |
elsif resource.is_a?(Page) | |
yield page_url(resource.slug) | |
else | |
yield resource | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def w(t); t.grouping = s(t) unless s?(t); end | |
def s?(t); t.grouping.to_s == s(t); end | |
def s(t); t.grouping.to_s.split(', ').sort.join(', '); end | |
require 'osx/cocoa' | |
OSX.require_framework 'ScriptingBridge' | |
a = OSX::SBApplication.applicationWithBundleIdentifier("com.apple.iTunes") | |
l = a.sources.first.playlists.detect { |p| p.name == 'Library' } | |
l.tracks.each_with_index { |t,i| print "\r\e[0KProcessing: #{i}/#{l.tracks.size}"; w(t); $stdout.flush; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["1.2.2", "1.2.3", "1.2.5", "1.2.6", "2.0.2", "2.1.0", "2.2.2", "2.3.2", "2.3.3", "2.3.4"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir['*'].map { |d| `cat #{d}/config/environment.rb | grep RAILS_GEM_VERSION`.scan(/[\d\.]+/) }.flatten.uniq.sort |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LoadModule passenger_module /Users/wes/src/passenger/ext/apache2/mod_passenger.so | |
PassengerRoot /Users/wes/src/passenger | |
PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby | |
NameVirtualHost *:80 | |
# Added by the Passenger preference pane | |
# Make sure to include the Passenger configuration (the LoadModule, | |
# PassengerRoot, and PassengerRuby directives) before this section. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:update_sources: true | |
:sources: | |
- http://gems.rubyforge.org/ | |
- http://gems.github.com | |
:benchmark: false | |
:bulk_threshold: 1000 | |
:backtrace: false | |
:verbose: true | |
gem: --no-ri --no-rdoc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Last.fm Tagger v0.7 | |
# | |
# Author: | |
# [email protected] | |
# | |
# Abstract: | |
# For each selected track in iTunes, retrieve the genre from Last.fm and accordingly tag the track. | |
# Use -q to subdue confirmations | |
# | |
# Todo: |