- The folks behind this article didn't go far enough to put some visual teeth into it (for us lay people), and
- Once again, Julian Barbour and his work come to my rescue to explain what could be going on...
Life is so cool...
Discrete is defined as constituting a separate entity : individually distinct.
Discrete Passions is a collection of statements and stories reflecting why I love life, starting before time and evolving with every new bit of awareness I acquire. People, Software development, Physics often top my list of discrete passions.
I'm working on a service in Grails that offers all kinds of methods for getting dates or formats of dates with single line calls. For example, dateTimeService.getBracketDates()
which will return the first and last dates for the current month (e.g., 2/1/2011 and 2/28/2011). It's not rocket science but I have no desire to re-invent the wheel every time I'm creating a new monthly report for our marketing folks.
One of the awesome things about groovy is that it's a lot like script programming. That makes it very convenient to try pieces of code and functionality you're not sure about before adding it to your project. Be forewarned. I'm a vi nut. I'm aware that dev tools have snippet support. I just find this works for me, and perhaps for you too.
The nice side-effect of this practice is that you build up a semi-structured collection of groovy and coding knowledge to reference in times of need and senior moments (not you, me!). Guess you could use it for old girl (or boy) friend names too. Another nice side-effect might be "instant book" once you insert a few paragraphs between each snippet!
Put a System.exit(0)
at the end of your snippet so that your groovy interpreter doesn't try to execute all the accrued code below. This won't protect you against
using variables that have already been defined lower in the file. All I usually do is attach a number to the end of the variable name to get rid of the name collision. Afterall, all I'm trying to do is validate my code. I used this little practice of mine to refinethe How-to below before subjecting you to what might have been buggy code.
Here is one of many ways to accomplish this task. I found this old code snippet from my snippet file and thought I'd share it. By the way, a site I love to consult on little basics like this is Pleac Groovy. It's not the most groovy-tized site in the world, but I like it's get-it-done blue collar perspective.
So this bit of code returns a list of log files that use the the naming convention of <directory path>/<year><month><day>.log
. In particular, this code winnows the list of files down to the files stored in the month of February (i.e., 201102.*\.log). The regular expression is pretty lame. I'm sure you could improve it.
def baseDir = '/tmp/logs'
def originalFiles = new File(baseDir).listFiles()
println "number of files found:"+originalFiles.size()
// here's our closure, a match expression
def screener2 = { it.name =~ /.*201102.*\.log$/}
def screenedList = originalFiles.findAll(screener2)
println "Number of files matching :"+screenedList.size()
println "screenedList :"+screenedList
This is one of those little kid inside me takes over posts.
I was lucky enough and old enough to see the Beatles from their (U.S.) beginnings, but I consider myself even more fortunate to have seen Willie Mays, Willie McCovey, Orlando Cepeda, Jimmy Davenport, Juan Marichal and Jack Sanford all through the 60's. Those Candlestick memories have dominated my thoughts the past few weeks and re-introduced my Dad in my day-to-day thoughts as well. I'm a pretty private person and don't intend to blog much about that, but I will say that I absolutely love my past as a young kid. I was pretty damn lucky.
The even better part of the whole Giants-Rangers-Phillies-Braves experience was hanging out with my New York daughter Amanda over the phone. She kicked things off by calling me from a downtown pub in Philadelphia the evening the Giants won that last game... wearing her Giants hat! Brave young woman and a TRUE Giants fan. Will Clark, Kevin Mitchell and Rod Beck were the guys during Amanda's early days. It was wonderful to feel so connected between PA, NY and ABQ! Thanks Amanda!
This is from the San Francisco Chronicle website @ http://www.sfgate.com :