You are viewing bpfurtado

Following 'Functional' sources

José Valim creator of Elixir and Benjamin Tan Wei Hao as himself puts (Elixir|Ruby)ist.

Entering the functional world

It's been a long while, well, here I am again. I'm getting back to my Scala studies of a long forgotten past, also with Akka and Hadoop. Getting into the functional paradigm, between all three entities listed above I got this morning at a good article describing Elixir. What is more alien to me is the Pattern matching, the immutable aspect of the data structures I could grasp reading the second chapter of Akka Concurrency by Wyatt, but pattern matching I couldn't yet and it seems it is really core among the languages that adopt this paradigm.

from [Gosling Emacs] to Oracle's CTO

From the TSS article Gosling focuses on Jave EE 6 in TSS JS keynote:

modularity in JEE comes from use of OSGi blueprints

Good to hear that JEE is making use of the OSGi module system.

Gosling emphasized Java's ubiquity. He cited estimates that there are now more than 6.5 million Java developers in the world. He said Glassfish application server downloads were now running at about 1 million per month. As well, he indicated confidence in the progress of the Oracle-Sun merger.

1 million of downloads per month? I'd never guess Glassfish to be so popular.

Interesting is to think that Gosling created the very foundations of EMACS (the not so well know Gosling_Emacs) to become the CTO for Oracle's Client Software Group :-)

It seems that Miguel de Icaza loves some strongly typed code :-)

So this is good news for everyone that wants to consume the information. The bindings for .NET are in particular great since you get strongly typed client-side code that you can use to invoke remote servers.

This comes from his last post about the Open Data Protocol (oData).

For those who do not know him (and you should!), here is a brief description of his work as a free software developer (from Wikipedia):

De Icaza started the GNOME project with Federico Mena in August 1997 to create a completely free desktop environment and component model for Linux and other Unix-like operating systems.[3] Earlier, De Icaza had worked on the Midnight Commander file manager and the Linux kernel. He also created the spreadsheet program Gnumeric.
In 1999, De Icaza, along with Nat Friedman, co-founded Helix Code, a GNOME-oriented free software company that employed a large number of other GNOME hackers. In 2001, Helix Code, later renamed Ximian, announced the Mono Project, to be led by De Icaza, with the goal to implement Microsoft's new .NET development platform on Linux and Unix-like platforms. In August 2003, Ximian was acquired by Novell, Inc. There, De Icaza is currently the Vice President of Developer Platform.

Quite impressive...

JDK7 {syntax: enhancements}

I was listening to the Java Posse #296 (Interview with Stephen Colebourne) yesterday, and they were talking among other things about the different Closures proposals for JDK 7 and their different aims, very interesting information indeed.

A few moments ago I was seeing the last posts of my friend Rafael Naufal who wrote this post (JDK7 Tackles Java Verbosity) about also a new syntax for maps and lists to be used on Java 7, something I was not aware at all.

Simplified Generics and Automatic Resource Management, as the original post says, will also be very handy.

I must say I'm still much more fond of Groovy syntax for Collections and being Ruby one's for Maps the worst one, the => is as bad as 2 characters could be :)

This is the code from the post '.svn'.listFolders { it.delete } now using a named parameters flavour of Groovy, which kinda let me down, as we end up using Maps and not real named params, but it's still pleasant to the eyes.

   1 purge folder: '.svn', from: '/home/bpfurtado/devel/grails/sandbox'
   2 
   3 def purge(params) {
   4     new File(params.from).listFiles().toList().each {
   5         if (it.name == params.folder)
   6             println "$it ${it.deleteDir()}"
   7         else if(it.isDirectory())
   8             purge folder: params.folder, from: it.absolutePath
   9     }
  10 }

Groovy flavour of Clipper&'Macro'

This script I made yesterday reminded me how dynamic the Clipper Language was soooo many years ago, where you could define the identifier of a variable in runtime using the famous 'macro' operator. Not to mention the Clipper 'code blocks' and it eval() function. Yeah baby, Clipper had closures!!! ;)

Take a look at the line 6 of the script bellow, amazing how Groovy let's you define the identifier of some object attribute using a String, that could also be as powerful as a GString!

   1 def home = 'C:/devel/groovy/tmp/score'
   2 
   3 new File("$home/insertsHit.sql").withWriter() { inserts ->
   4     def text = new File("$home/Score_Model_20090824154043500").text
   5     def xml = new XmlSlurper().parseText(text)
   6     xml.'instance-selection'.item.'instance-list'.item.each {
   7         def (charLabel, binLabel) = [null, null]
   8         it.instance.each {
   9             charLabel = getField(it, '__ND_CharacteristicLabelVH', charLabel)
  10             binLabel  = getField(it, '__ND_BinLabelVH', binLabel)
  11         }
  12         if(binLabel) {
  13             inserts << "INSERT INTO SCOREMODELBINBASELINE " +
  14             "(scoremodelname, characteristicname, binlabel, baseline) \n" +
  15             "\tVALUES ('sc_ScoreRVHit', '$charLabel', '$binLabel', 0);\n"
  16         }
  17     }
  18 }
  19 
  20 def getField(obj, String name, String defaultValue) {
  21     if(obj.@ref == name) {
  22         return obj.text()
  23     }
  24     return defaultValue
  25 }

This script basically reads the proprietary XML format of a Rules Engine tool I work with, in order to generate some SQL inserts to prepare a testing database, requested by a colleague of mine who was tired of writing every 'INSERT' manually.

'.svn'.listFolders { it.delete }

A simple script to delete all .svn folder given a root folder:

   1 purgeSVNFolder(new File('/home/bpfurtado/devel/grails/sandbox'))
   2 
   3 def purgeSVNFolder(folder) 
   4 {
   5     folder.listFiles().toList().each {
   6         if (it.name == '.svn') {
   7             println "$it ${it.deleteDir()}"
   8         } else if(it.isDirectory()) {
   9             purgeSVNFolder(it)
  10         }
  11     }
  12 }

stackoverflow debut

Yesterday I have created my account at StackOverFlow and answered my first 2 quest ions:

The last question I replied is basically about how to get random numbers (from a determined set) to be equally and randomly distributed to another set of objects. For instance, I have the codes {A, B, C} and I want to spread them equally to a collection of 3000 objects.

I need the Service_Types to be distributed uniformly in all the 30 tables. Similarly I need feedback value of 1 to be generated many times other than 0 and -1.

This is a simple Groovy code that does the trick (here I'm using 3 different codes to distribute among 99 objects):

   1 feedbacks = []
   2 3.times {
   3     feedback = it
   4     33.times {
   5         feedbacks << feedback
   6     }
   7 }
   8 
   9 rnd = new Random()
  10 
  11 idx = 0
  12 services = [:]
  13 99.times {
  14     services["Service_${idx++}"] =
  15         feedbacks.remove(rnd.nextInt(feedbacks.size()))
  16 }
  17 
  18 println Collections.frequency(services.values(), 0)
  19 println Collections.frequency(services.values(), 1)
  20 println Collections.frequency(services.values(), 2)
  21 
  22 println services

For the sake of simplicity I'm using a simple Map to represent the 99 objects, the key would be the object id and the value would be its code.

Latest Month

January 2014
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Syndicate

RSS Atom
Powered by LiveJournal.com
Designed by Tiffany Chow