This file contains 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
#!/Users/duncanbeevers/.rvm/rubies/ruby-1.9.3-p0/bin/ruby | |
filenames = ARGV | |
abort "Usage: flac2mp3 FLACFILE, ( FLACFILE, ... )" if filenames.length < 1 | |
require 'open3' | |
FIELD_NAMES = %w(TITLE ARTIST ALBUM TRACKNUMBER GENRE) | |
FIELDS = FIELD_NAMES.map { |f| "(?:#{Regexp.quote(f)})" }.join("|") | |
MATCHER = /^(#{FIELDS})=([^\n]+)\n$/ |
This file contains 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
# Colors | |
txtred='\[\e[0;31m\]' # Red | |
txtgrn='\[\e[0;32m\]' # Green | |
txtylw='\[\e[0;33m\]' # Yellow | |
txtblu='\[\e[0;34m\]' # Blue | |
txtpur='\[\e[0;35m\]' # Purple | |
txtcyn='\[\e[0;36m\]' # Cyan | |
bldred='\[\e[1;31m\]' # Red | |
bldgrn='\[\e[1;32m\]' # Green | |
bldylw='\[\e[1;33m\]' # Yellow |
This file contains 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
fisherYates = (array) -> | |
cap = array.length | |
for e, i in array | |
j = Math.floor(Math.random() * (cap - i)) + i | |
[ array[i], array[j] ] = [ array[j], e ] unless i == j | |
array |
This file contains 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
(($) -> | |
# Finds the angle between the center of the first element | |
# and the provided point, or the center of another element | |
degreesPerRadian = 180 / Math.PI | |
$.fn.angleTo = () -> | |
args = arguments | |
if 1 == args.length | |
target = $ args[0] | |
position = target.offset() | |
targetX = position.left + target.outerWidth() / 2 |
This file contains 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 ApplicationModel | |
extend Feedable | |
end |
This file contains 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
(function(window){var i,$sound,$buttonGroup;var $sounds=$(".sound");var clientId=require("config").get("client_id");var oauthToken=require("lib/connect").getAuthToken();var conversionHelper=require("lib/helpers/conversion-helper");var $downloadButton,size;var params,downloadUrl,onSuccess;for(i=$sounds.length-1;i>=0;i--){$sound=$($sounds[i]);var soundcloudUrl="https://soundcloud.com"+($sound.find(".soundTitle__title").attr("href")||window.location.pathname);params={url:soundcloudUrl,client_id:clientId};onSuccess=function($sound){return function(data){var params={client_id:clientId};downloadUrl=require("lib/url").stringify({query:params},data.stream_url+".mp3");$buttonGroup=$($sound.find(".sound__soundActions .sc-button-group")[0]);size=$buttonGroup.find(".sc-button:first")[0].className.match(/sc-button-((?:small)|(?:medium))/)[1];$downloadButton=$('<a class="sc-button sc-button-download sc-button-icon sc-button-responsive">Download</a>').attr({title:"Download this sound ("+conversionHelper.bytesToMB(data.origi |
This file contains 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
namespace :db do | |
task :uptodate do | |
if pending_migrations.blank? | |
puts "Migrations are up-to-date" | |
else | |
puts "The following migrations are pending:" | |
puts pending_migrations.map { |mp| "%s\t\t%s" % [ mp.version, mp.name ] }.join("\n") | |
end | |
end | |
This file contains 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
namespace :db do | |
desc "Populate Users Table with images from /public/feedimg" | |
task :populate => :environment do | |
require "populator" | |
require "faker" | |
image_filenames = Dir.glob(File.join(Rails.root, '/public/feedimg', '*')) | |
User.populate 1 do |user| | |
user.username = Faker::Name.first_name.downcase | |
user.email = Faker::Internet.user_name + "@myhost.com".downcase |
This file contains 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
# UpdateOrCreate makes it simple to to perform updating or creating models | |
# without a lot of boilerplate. | |
# | |
# It can be used in several forms. In its simplest form, it can be used with a | |
# single OrderedHash. | |
# | |
# User.update_or_create(username: 'Admin', admin: true) | |
# | |
# The first key/value pair from the provided hash is used to look up any existing record. | |
# In this case, it will look for a user with the username 'Admin' |
This file contains 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 Loop | |
attr_accessor :name | |
def initialize name | |
self.name = name | |
end | |
end | |
module LoopDecoratorHelper | |
def loop_delete_link loop | |
"Delete #{loop.name}" |