Skip to content

Instantly share code, notes, and snippets.

@zigzag
zigzag / newpost.rb
Created December 12, 2009 13:38 — forked from al3x/newpost.rb
New post command shell for Jekyll
#!/usr/bin/ruby
unless ARGV[0]
puts 'Usage: np "the post title"'
exit(-1)
end
title = ARGV.join ' '
date_prefix = Time.now.strftime("%Y-%m-%d")
postname = title.strip.downcase.gsub(/ /, '-')
#Dir.glob("**/*.java").map{|it| it.split('/').last[0..-6]}.map{|it| [it, it.length]}.sort{|a, b| b[1] <=> a[1]}[0..5]
# A bit short version:
Dir['**/*'].grep(/(\w*)\.java/){$1}.sort_by(&:length).reverse.first(5).map{|it| [it,it.length]}