#!/usr/bin/env groovy
println "Hello World!"
Groovy is a neat language you can do curries and functional programming, typing is optional, and you can use it with Grails to generate up web apps really quick. The nifty thing is you can learn one set of API and carry them around with you. You don't have to relearn a bunch of new ways of doing things if you don't want to... or you can if you do want to. Groovy is neat stuff. Grails is getting good. Or you can just use Groovy as a way to dink around with Java API. For example if you have Java and Groovy that means you can play around with ldap from Groovy using the Java API like this:
#!/usr/bin/env groovy
import java.util.Hashtable
import javax.naming.*
import javax.naming.event.*
import javax.naming.directory.*
def ou = " System and Service Accounts"
// here, we're just reading in some parameters...
def stdin = new BufferedReader(
new InputStreamReader(System.in)
)
print "username: "// your username to access LDAP... not a real user
String username = stdin.readLine()
print "password: "// the password for that account...
String passwd = stdin.readLine()
// next we set up an environment for LDAP
Hashtable env = new Hashtable()
env.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory"
)
env.put(
Context.SECURITY_AUTHENTICATION,
"EXTERNAL"
)
/*// if only I had SSL working... *sigh* oh well...
env.put(
Context.SECURITY_PROTOCOL,
"ssl"
)//*/
// You'll want to put your server's name or IP here:
env.put(
Context.PROVIDER_URL,
"ldap://activedirectoryhost.mycompany.com:636/"
)
// Here, you'll want to set up your company's parameters for OU and DC...
env.put(
Context.SECURITY_PRINCIPAL,
"CN=" + username + ",OU=" + ou + ",DC=mycompany,DC=com"
)// username
env.put(
Context.SECURITY_CREDENTIALS,
passwd
)// and password
// Now we'll try and connect...
try {
def ctx = new InitialDirContext(env)
def attr = ctx.getAttributes("")
def srchInfo = new SearchControls()// you'll want to use your own search base
def searchBase= "OU=company,DC=mycompany,DC=com"// this is the magic search string sauce:
def searchFilter = "(&(objectClass=person))"// we strong type the next var because it is // used in a Java API that needs String[]
String[] objAttribs=[
"givenName",
"cn",
"sn",
"mail",
"mailNickname",
"userPrincipalName",
"displayName",
"manager",
"department",
"memberOf"
]
srchInfo.setSearchScope(SearchControls.SUBTREE_SCOPE)
srchInfo.setReturningAttributes(objAttribs)
// Now we get the results and loop through them...
NamingEnumeration dirObjects = ctx.search(searchBase,searchFilter,srchInfo)
def nodirObjects = 0
while (dirObjects != null && dirObjects.hasMoreElements()) {
def dirObject = dirObjects.next()
println("'" + dirObject.getName() + "':")
def attrs = dirObject.getAttributes()
for(name in objAttribs) {
println "\t * " + attrs.get(name)
}
nodirObjects++
}
ctx.close()
println("Number of entries identified: " + nodirObjects)
} catch (Exception e) {
println "Exception: " + e
}
TIOBE has published their yearly Programming Community Index and it got me thinking... What is the most commonly used programming language in the Slashdot community? What language did you learn in the last year?
Personally, I've just started working in Groovy this year which has entered the TIOBE list at number 35. The biggest mover on this list seems to be Lua and Lua's rank on this list is enough for me to decide to check it out.
jwagon sent me these mind bending groovy class manipulations in a chat today:
#!/usr/bin/env groovy
class AA {
def msg
AA(something){ msg = something }
}
def c = { a, b ->
def x =a.newInstance(b)
println x.msg
}
c(AA, "foo")
Or how about....
#!/usr/bin/env groovy
def m = java.lang.String
def n = m.newInstance("foo")
println n
I was remembering how much I loved working in Europe but how the exchange rates ruined my contract there making it impossible to stay. I was paid out of Texas in dollars but I was living physically in Germany. A bad combination.
I wonder how hard it would be to get a job in London, paid in British Pounds, living on the British economy... as an American citizen. Has anyone ever done this? Is it possible for a geek? Do they need Software Engineers or Informaticians over there bad enough to entertain the idea?
I just had a conversation with a promising young help desk attendant. He wanted to get into programming and asked if I could teach him. I told him that I could teach anyone to program... but just like singing... only some of us will ever do it well.
When someone shows up on American Idol and sings their heart out and the totally and utterly suck. How do you tell them? How do you tell the young bright and highly motivated student that they don't "think like a programmer" or that no matter how hard they work they will never become a great programmer. How do you tell?
I am convinced that anyone can learn to program and I can see a day in the not too distant future where every child is taught to program just as they are taught to use a keyboard and mouse today. The day is out there on the horizon.
Every child is taught science but only some will learn to become world changing scientists.
Every child may take music and art but only some will become musicians and artists. Their talent will be spotted early. They will be mentored to become better in their area of interest. They may even get to specialize on a particular skill.
One day programming will follow this path too. Just as promising young mathematicians and engineers are singled out and nurtured due to their skill. So too will the young budding programmer.
Today a child with an interest in medicine can visit a hospital and spend a day with a real nurse. An aspiring lawyer can visit a court room. An aspiring accountant (yes I've met children that aspire to be accountants) can visit an accounting firm and learn more about it.
Aspiring young technologists can visit Red Hat summer camp.
But, how do you evaluate that young dreaming no-talent that thinks he can be the next American Idol but clearly doesn't have the chops? What do you say to the young no-talent that wants to be a programmer?
I told my young charge that I can teach anyone to program but only some people will be great at it. Just as anyone can be taught the mechanics of writing and can write a 300 page novel if only they have the determination and willingness to learn. However, only the innate talent and skill developed by the pupil can turn them from merely a trained student into something great.
The teacher can give you voice lessons. The pupil can study. But only that intangible gift called talent can make them great. Study under the best. Work your hardest. And, it could pay off... if you don't try at all there is no way you will succeed. But, at the end of the day there is this intangible thing called talent that no one can give you.
You can paint a picture but no one may want to look at it.
You can write a book but no one may want to read it.
You can sing a song but no one may enjoy it.
You can write software but it may not be something others want to use.
Still, how else should you proceed? So you pour everything you have into your skill and into your art. You sculpt yourself and hone your abilities.
"Do you see a man skilled in his work? He will serve before kings; he will not serve before obscure men." Proverbs 22:29
You have to believe that or else not try at all. You have to believe that all your effort and sacrifice will pay off. You have to believe you can serve before kings.
New growth areas will continue to arise from rapidly evolving technologies. The increasing uses of the Internet, the proliferation of Web sites, and mobile technology such as the wireless Internet have created a demand for a wide variety of new products. As individuals and businesses rely more on hand-held computers and wireless networks, it will be necessary to integrate current computer systems with this new, more mobile technology.
You knew the job was dangerous when you took it, Fred. -- Superchicken