Archive for the ‘Uncategorized’ Category

Ruby: What percentage of the code do I own?

mine = 0 total = 0 require ‘find’ Find.find(".") do |p| Find.prune if File.basename(p).downcase == ".git" next unless p =~ /\.java$/i system "git annotate #{p} > c:\\temp\\foo.txt"   lines = File.open("C:\\temp\\foo.txt","r") { |f| f.read.split(/\n/) } mine += lines.grep(/jfelice/).size total += lines.size print "#{p}: #{mine}/#{total}\n" # Just to show progress end   print "#{mine}\n"

Posted on August 6, 2010 at 1:44 pm by Jason Felice · Permalink · Comments Closed
In: Uncategorized

Ruby: Find ini files containing an entry

Ruby’s always good with the “find”: require ‘find’   Find.find(".") do |path| Find.prune if path =~ /\.svn$/ Find.prune if path =~ /XPay$/i next unless path =~ /\.ini$/i File.open(path,’r') do |f| f.each_line do |l| next unless l =~ /^\s*dasserver\.exe\s*=\s*(?:[0-9]+\.){3}([0-9]+)\s*$/ print "#{path} (2.0.2.#{$1})\n" if $1.to_i >= 1885 end end end

Posted on December 1, 2009 at 9:31 am by Jason Felice · Permalink · Comments Closed
In: Uncategorized

Scala: Ugly hairy rewrite C++ code jig

I think this might be the first time I’ve gotten to use a real algorithm at work in several years. This is also my first attempt at Scala (pretty nice!), and one ugly jig. It had to be adjusted every fourth or fifth component I used it on because of strangeness in the way that [...]

Posted on October 5, 2009 at 3:23 pm by Jason Felice · Permalink · Comments Closed
In: Uncategorized

Java: JFrame tester

Our first submission: So here is my silly Java JFrame that I use to test all sorts of things; Swing components, logging frameworks or just to see pretty colors on my screen. Really though, just follow the comments and play with what a JFrame can do. In addition there is a convenient comment that instructs [...]

Posted on June 18, 2009 at 8:34 pm by Jason Felice · Permalink · Comments Closed
In: Uncategorized