Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added 2 new utils

  • Loading branch information...
commit 69d3255824d701e1971a1052c03f1fae92a7ad85 1 parent ce3af02
@amit authored
Showing with 42 additions and 0 deletions.
  1. +16 −0 get_lattitude.rb
  2. +26 −0 mp3len.rb
View
16 get_lattitude.rb
@@ -0,0 +1,16 @@
+#!/bin/env ruby
+# Simple ruby script to get lattitude and longitude of any place
+# Specify the address in a line with any level of detail
+# It also shows ZIP+4 for a given street address
+require 'open-uri'
+require "rexml/document"
+include REXML
+url='http://api.local.yahoo.com/MapsService/V1/geocode?appid=yahoomap.rb&location='
+puts 'Enter Location: '
+address=gets
+address=URI.escape(address)
+result=URI(url+address).read
+doc = Document.new result
+r=doc.elements["/ResultSet/Result"]
+print "Precision: ", r.attributes["precision"],"\n"
+r.children.each { |c| print c.name, " : ",c.text,"\n"}
View
26 mp3len.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+# A script to sort a list of mp3 files sorted by the duration of the audio file
+# Needs the gem ruby-mp3info
+# gem install ruby-mp3info
+
+require "rubygems"
+require 'mp3info'
+def mp3len(dirname)
+summary=[]
+Dir[dirname].each do |f|
+Mp3Info.open(f) do |info|
+summary.push([f,info.length])
+end
+end
+summary
+end
+
+puts "Enter directory containing mp3 files"
+dirname=gets.chomp
+dirname = File.expand_path(dirname)
+puts "Searching #{dirname}"
+dirname += "/**/*.mp3"
+
+s=mp3len(dirname).sort {|a,b| a[1] <=> b[1]}
+s.each{|q| puts "#{q[0]} => #{q[1]} seconds"}
+
Please sign in to comment.
Something went wrong with that request. Please try again.