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
["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
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
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
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
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
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 | |
request = urllib2.Request('http://www.discogs.com/release/123?f=xml&api_key=111') | |
request.add_header('Accept-Encoding', 'gzip') | |
request.add_header('User-Agent', 'MyDiscogsClient/1.0 +http://mydiscogsclient.org') | |
response = urllib2.urlopen(request) | |
data = response.read() | |
unzipped_data = gzip.GzipFile(fileobj = cStringIO.StringIO(data)).read() |
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
{ | |
"resp":{ | |
"status":true, | |
"release":{ | |
"status":"Accepted", | |
"styles":[ | |
"Deep House" | |
], | |
"genres":[ | |
"Electronic" |
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
{ | |
"resp":{ | |
"status":true, | |
"version":"2.0", | |
"artist":{ | |
"namevariations":[ | |
"A-F-X Twin", | |
"A.F.X.", | |
"A.Twin", | |
"AFX", |