graph git history by month

git_history.rb, accepts two optional arguments, the first sets the bar size, the second is the graph type, which can be horizontal or vertical (defaults to horizontal) an example:
$ ./git_history.rb 
2008-03 |########                                           5 commits
2008-04 |########################################          25 commits
2008-05 |                                                   0 commits
2008-06 |                                                   0 commits
2008-07 |####                                               3 commits
2008-08 |###                                                2 commits
2008-09 |############                                       8 commits
2008-10 |                                                   0 commits
2008-11 |######                                             4 commits
2008-12 |                                                   0 commits
2009-01 |#                                                  1 commits
2009-02 |######################                            14 commits
2009-03 |########                                           5 commits
2009-04 |############                                       8 commits
2009-05 |##############                                     9 commits
2009-06 |                                                   0 commits
another example, using arguments:
./git_history.rb 30 vertical
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                                          
                                             #                                                 #                        
                                             #                                                 #                        
                                             #                                                 #                        
                                             #                                                 #                        
                                             #                                                 #                        
                                             #                                                 #                        
                                             #                                                 #              #         
     #                                       #                        #                        #         #    #         
     #                                       #                        #                        #         #    #         
     #                                       #                        #                        #         #    #         
     #    #              #              #    #                        #                        #    #    #    #         
     #    #              #              #    #                        #                        #    #    #    #         
     #    #              #    #         #    #                        #         #              #    #    #    #         
     #    #              #    #    #    #    #              #         #         #              #    #    #    #         
     #    #              #    #    #    #    #              #    #    #         #              #    #    #    #         
#    #    #         #    #    #    #    #    #              #    #    #         #         #    #    #    #    #         
#    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    #    
07   08   09   10   11   12   01   02   03   04   05   06   07   08   09   10   11   12   01   02   03   04   05   06   
2007 2007 2007 2007 2007 2007 2008 2008 2008 2008 2008 2008 2008 2008 2008 2008 2008 2008 2009 2009 2009 2009 2009 2009  

Posted by Maximiliano Guzman Thu, 04 Jun 2009 03:32:00 GMT


Railscasts downloader script

run it to download all railscasts, re-run it to update with newly released ones. Just run it in the folder where you want to keep them. yes, I could have used the word run a couple more times.
#!/usr/bin/ruby
require 'rss'

p 'Downloading rss index'

rss_string = open('http://feeds.feedburner.com/railscasts').read
rss = RSS::Parser.parse(rss_string, false)
videos_urls = rss.items.map { |it| it.enclosure.url }.reverse

videos_filenames = videos_urls.map {|url| url.split('/').last }
existing_filenames = Dir.glob('*.mov')
missing_filenames = videos_filenames - existing_filenames
p "Downloading #{missing_filenames.size} missing videos"

missing_videos_urls = videos_urls.select { |video_url| missing_filenames.any? { |filename| video_url.match filename } }

missing_videos_urls.each do |video_url|
  filename = video_url.split('/').last
  p filename
  p %x(wget #{video_url} -O #{filename}.tmp )
  p %x(mv #{filename}.tmp #{filename} )
end
p 'Finished synchronization'
it's on github

Posted by Maximiliano Guzman Tue, 26 May 2009 16:23:00 GMT


autofile, un pequeño script para suites enredadas

Cuando te levantaste dijiste, este va a ser un gran día. Te hiciste un desayuno con todo y llegaste temprano al trabajo.

Mirás la lista de tareas para ver cual agarrás, y lleno de coraje te metés con la tarea difícil.

A pesar de que la suite de tests del proyecto está descuidada, vos querés hacer TDD/BDD. Corrés ./autotest solo para encontrarte un tsunami de fallos y errores.

Un clavo.

Así que, hay mucha mugre en la suite de tests, y no podés quitarla, muchos de esos tests son de otros. Decidís correr solo los tests de lo que estas implementando (si, sé que es feo), pero no querés correrlos manualmente

Y por eso, escribí autofile.rb.

./autofile.rb path/to/your/lonely/test

...y cada vez que escribís en el archivo del test, autofile lo corre de nuevo

#!/usr/bin/ruby
@mtime=nil
while true
  current_mtime = File.stat(ARGV.first).mtime
  if current_mtime != @mtime
   puts "found change, running test"
   puts `ruby #{ARGV.first}`
   @mtime = current_mtime
 end
 sleep 0.01
end
Ojo! es solo un parche (como los de nicotina), hasta pasar a algo mas sano; limpiar la suite y usar ZenTest.

Posted by Maximiliano Guzman Sat, 23 May 2009 23:56:00 GMT


autofile, a little script for big hairy test suites

So, when you woke up today, you decided to make this a better day than yesterday; you started with a big healthty breakfast, and arrived to work early.

You look at your todo list to see what needs to be done next, and full of courage take that difficult task at the middle of the list.

Even though your project's test suite has been neglected, you know the way to go is TDD/BDD. You run ./autotest only to be greeted by a tsunami of failing tests and errors.

Bummer.

So, there's a lot of failing stuff on the test suite. You cannot remove it, as it's not yours. You decide to just run the tests for your new stuff (yeah, I know it's an ugly compromise), but don't want to run it manually.

Enter autofile.rb

./autofile.rb path/to/your/lonely/test

...and every time you write to the test file, it gets run again

#!/usr/bin/ruby
@mtime=nil
while true
  current_mtime = File.stat(ARGV.first).mtime
  if current_mtime != @mtime
   puts "found change, running test"
   puts `ruby #{ARGV.first}`
   @mtime = current_mtime
 end
 sleep 0.01
end

Posted by Maximiliano Guzman Sat, 23 May 2009 00:45:00 GMT