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
require 'xmlsimple' | |
# XML file was retrieved using TVDB api | |
doc = XmlSimple.xml_in('/Users/xyz/smurfs.xml') | |
doc['Episode'].each do |episode_hash| | |
# Find the next valid episode (with a season and episode number) | |
if episode_hash['SeasonNumber'][0].class == String && episode_hash['SeasonNumber'][0].to_i == 5 | |
episode_season = episode_hash['SeasonNumber'][0].rjust(2, "0") | |
episode_num = episode_hash['EpisodeNumber'][0].rjust(2, "0") |
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
require 'rubygems' | |
require 'json' | |
require 'open-uri' | |
require 'active_support' | |
require 'net/http' | |
def save_video_metadata | |
# x = ZencoderJob.find_by_sql("select Z.* from zencoder_jobs as Z inner join items as I on I.id = Z.item_id where I.file_content_type like 'video%' and Z.status = 'finished'") | |
# x.each do |job| | |
ZencoderJob.where(status:"finished").joins(:item).where("items.file_content_type LIKE 'video%'").find_each do |job| |
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
cdrs = File.readlines ARGV[0] | |
cdrs.shift 1 # Delete the header row | |
cdrs.map! { |x| x.split(',')[3] } # Keep only the callid puts | |
duplicate_callids = cdrs.group_by(&:freeze). # Group by occurence | |
sort_by { |k, v| v.length}.reverse. # Sort by number of occurences desc | |
map { |x| "#{x[0]} - #{x[1].length}" if x[1].length > 1 }. # Format for printing compact | |
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
#!/usr/bin/env ruby | |
# Tested in REE 1.8.7. To run from command line, type - | |
# ruby AddLeadingZeroToSongFile.rb | |
`ls -1 *.mp3`.split("\n").each do | songfile | | |
x = /^(\d .*)/.match(songfile) | |
`mv "#{x.captures[0]}" "0#{x.captures[0]}"` if x | |
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
cards = [*'2'..'10', 'J', 'Q', 'K', 'A'] | |
suits = ['C', 'D', 'H', 'S'] | |
deck = cards.product(suits).map(&:join) | |
hand = deck.shuffle.each_slice(13).first |