Sep 9 2011

Remove Multiple Null Values From A List in Java

I’ve had situations where I’ve needed a list of foreign keys (fks) that I get from a result set and from that list make additional queries. Sometimes for whatever reason there are null values in the list and I have to remove them. You might had a similar problem where you needed to remove multiple occurring value from a lists in java. There are a few ways you can approach this problem. You you can remove each occurrence of a list element one at a time. The example below removes any null element in the list one at a time.

while(ids.contains(null)) {
	ids.remove(null);
}

There is another approach you can use to remove all instances of a given value from a list in one go. Instead of the remove method you can use the removeAll as in the following code sample.

ids.removeAll(Collections.singleton(null));

Of course, instead of null values you can remove all instances of any given value from a list based on your business needs.


Sep 8 2011

Launch Default Web Browser in Java

For the longest time I’ve used the BrowserLauncher library to open the default web browser to a specified web page from Java. BrowserLauncher is simple to use, just import edu.stanford.ejalbert.BrowserLauncher and call openURL method with the desired website URL.

Since Java 1.6, the JDK has introduced the java.awt.Desktop class to do the same so you don’t need an additional third party jar. The Desktop class has the ability to launch the desktop’s default email client and default web browser given a URI. Here is how you can launch the desktop’s default web browser in Java.

// Launch your default email client with ...
URI email = new URI("mailto:myemail@mydomain.com");
Desktop.getDesktop().mail(email);

// Launch your default web browser with ...
URI url = new URI("http://www.mydomain.com");
Desktop.getDesktop().browse(url);

Aug 15 2011

Google Make Its Largest Acquisition

Google announced that it was buying Motorola for a staggering $12.5 billion. This is the largest acquisition made by the online search and advertising giant to date. I was talking about this with a friend who said the following. “If I’m a typical Motorola employee I’m worried, if I’m HTC I’m pissed, if I’m Microsoft I’m making a bid for Nokia, if I’m Apple, I’m laughing it up.” I’m not entirely sure about my friend’s statement but I am positive that Google has changed it’s strategy and decided to fight fire with fire, patents with patents, lawyers with lawyers, and mind share with truck loads of hard cold cash.

Google went at great lengths on this deal, it not only paid top dollar for Motorola but it even created a special “Facts about Google’s acquisition of Motorola” SEO-rich webpage which includes choice quotes from Android partners and a message from Larry Page.

Larry, CEO of Google, wrote about the purchase…

Motorola has a history of over 80 years of innovation in communications technology and products, and in the development of intellectual property, which have helped drive the remarkable revolution in mobile computing we are all enjoying today.

The last Motorola phone I thought was ground breaking was the first generation RAZR. Since then I have not been impressed with their phone offering, including their Android versions. In the press release, Larry made several references of the StarTAC, which Motorola originally released in 1996.

To appease other Android partners and licensees, the press release stated that Motorola will e a independent business unit.

This acquisition will not change our commitment to run Android as an open platform. Motorola will remain a licensee of Android and Android will remain open. We will run Motorola as a separate business

For me, the key and most revealing sentence in the whole press release was the following.

Our acquisition of Motorola will increase competition by strengthening Google’s patent portfolio, which will enable us to better protect Android from anti-competitive threats from Microsoft, Apple and other companies.

What struck me about the above quote is how hard Google is spinning this. When competitors buy up patents, it’s anti-competitive but when Google itself pays top dollar for a turkey stuffed with patents it will “increase competition.”

It has been reported that Google is paying $40/share, over 50% on top of the price at the time of the announcement. The reason Google is paying this price is clearly for the over 14,000 granted patents and over 6,500 pending patents Motorola has acquired over time. These patents will add to patents Google has added to it’s patent portfolio.


Aug 5 2011

Retweet July 2011

From time to time I just blast tweets about software development, project planning, team dynamics, or whatever else comes to mind. Here is a synopsis of recent tweets and rants. If you want to follow the conversation follow me at techknow and/or juixe.

Software Development

  • I can’t take an IDE seriously if it looks like iTunes.
  • Beta at your own risk.
  • Refactor and remix yourself.

Team Leadership

  • Moving on to plan b, section iii, revision 10, update 8, …
  • Everything happens for a reason but not every reason is meant to be understood.
  • The key to being cost effective is first being effective.
  • To change your life, try to change your trajectory.
  • Who is in your development dream team?
  • Originality is dead. I know this because I copied it from someone else.

Product Placement

  • Install Lion, Xcode 4.0 not supported, need to upgrade to Xcode 4.1, a 3GB install.
  • Apple already working on next OS X release, tentatively known as Sea Lion.
  • Google Plus going after Facebook is like an 800 pound gorilla going after a 800 pound rhinoceros.
  • Google’s motto: Do no evil without cresting a algorithm to automate evil.
  • G+: don’t be a square join a circle.
  • The next release of Windows should come with one key feature: a 100GB DropBox like cloud spaces for free integrated into the OS, Office, etc
  • I wish I could use Google to search my memories to find where I last placed my keys.

Question

  • What is the speed of time?
  • Isn’t Captain America wearing the big Scarlet Letter on his forehead?
  • Which is worse: different day, same shit or same day, different shit?
  • Is it just me or is it hot in herre?
  • Fruit by the Foot or Sugar by the Pound?
  • Why does it feel like Friday when it should feel more like Wednesday?
  • What is the weather report on cloud computing?
  • Is Jack Dorsey the web 2.0 version of Steve Jobs?
  • If you had 8 more hours a day what would you do with them?

Randumb

  • There is no God particle. Sub atomic particles are atheists.
  • A live police chase is the human equivalent of a lolcat watching a light beam.
  • When time flies it does so in first class.
  • Frankie Says Chillax
  • Bay Area Forecast: Fog-Drizzle My Nizzle Fo Shizzle.
  • I’ma power up with a power nap.
  • It is what it is and it do what it do.
  • La Gaga has jumped the outer space shark.

In Da Future

  • In the future, a picture will be 90% filters and photoshop and 10% reality.
  • If the future could travel faster than the speed of time then it would travel back in time.
  • In the future, the revolution will be fought with tweets.
  • In the future, every other word in a sentence will be a registered trademark.
  • In the future, the exercise of free speech will be deemed suspicious.
  • In the future, a large portion of the president’s state of the union speech will be redacted.
  • In the future, action figures will be illegal and replaced by diversity and cooperation figures.

Summertime

  • Happy 4th of July. Let keep America free!
  • Long live freedom, death to red coats.
  • It’s going to be one hot fourth of July.
  • Beerbeque.
  • There is no freedom without choice.
  • I’m so cool that the heat don’t get to me.
  • Beans and cornbread.
  • This heat is like kryptonite.

Aug 3 2011

Google Starts Towards The Path of Evil

The unofficial motto at Google has been Don’t Be Evil. Google’s philosophy states that “You can make money without doing evil.” The funny thing about being evil is that there is no technical IEEE standard of evil. That said, Google is on a slippery slope sliding towards impish and evilish behavior. As Google has a lock on the search and online advertising market, it has started to tailgate other industry leaders. Most notably, Google has started to tailgate Facebook and Twitter with different incarnations and versions of a social networking site. Depending on how you count, Google Plus is their fourth attempt at creating a social networking site. Google is also trying to compete with Apple in the mobile space. Well after a year into Apple revolutionizing the mobile phone market, Google got into the arena with their free mobile Operating System Android. In trying to compete in these two distinct markets, they have started to make decisions whose moral compass points towards evil-like behavior.

Even though Google’s latest attempt at a Facebook killer, Google Plus, has been well received it has also generated some of the most passionate arguments against any of their policies. Google Plus does not allow users to use pseudonyms, alias, nicknames, or any online handle other than their real names. There has been opposition against this stance from even within Google engineers tasked with implementing such draconian technology. The reasoning behind this rule makes no sense, and goes against a fundamental human right of self identity. I have the right to go and respond by any name I wish to be known as. In fact, many celebrities often use names other than their real names. Vic Gundotra, the Senior Vice President of Engineering at Google does not go by his real name that was given at birth so this all seems hypocritical.

The second misstep is their self serving stance on patents as written in a recent corporate blog post When Patents Attack Android. In this post, David Drummond, Senior Vice President and Chief Legal Officer at Google, practically accuses Microsoft, Apple, and Oracle of conspiring against Android with “bogus patents.” These are the same “bogus patents” that Google itself had tried to purchased from Novell for $3.14 billion. I doubt that any publicly traded company would bid $3.14 billion on “bogus patents” and in fact publicly complaining about having lost those patents demonstrates that they are not entirely bogus. Having lost the auction for said “bogus patents” Google went on to buy over 1000 patents from IBM for an undisclosed amount.


Jul 25 2011

Google Plus Begins to Stumble

Since it’s initial private launch, Google Plus has received mostly positive reviews from tech insiders that were able to score an invite early on. I was able to get my hands to an invite a day or two after Google Plus, often abbreviated as G+, launched. This is not my first social network, I was an early adopter on Twitter, I was there before @aplusk, and I had the same experience with Tumblr and Quora. Each time a new social network is launched and before the mob of celebrities and social media marketing experts join, these services are often seeded with early adopters from the tech scene. Even with it’s 20 million users, G+ is still in this early adopter stage and this is evident by the list of most followed users on the network. The most followed profiles are those from technologists and tech pundits, including former first friend on MySpace Tom Anderson. A few years ago, this was virtually the same list of most followed users on Twitter.

Google Plus does innovate on a few areas where Facebook has lagged and dragged it’s feet, such as in the concept of circles. That said, Google Plus is largely a clone+ of Facebook, which is a derivative of whatever social trend we’ve seen in the last five years. Depending on how you count, Google Plus is Google’s fourth attempt at this social networking thing. The current trend in social networking sites is that anonymity is to be banned. Facebook was the first social network to demand users use their real and legal names in their profiles and Google Plus has followed this trend.

Since Google Plus is the newest social networking site to see an exponential growth, it is now going through some growing pains in the way Google is policing the community. There have been a large number of reports of Google banning and disabling Google Plus profiles that don’t use “real names.”

The worst part, for those whose accounts have been locked out, is that there is no customer support, no due process, and not even a G+ profile to contact if your Google account is disabled or banned our right. If your Google account is disabled you may be locked out of GMail, Google Docs, and other Google products you may use, which might be have years of data.

The natural progression of these policies is that in the near future people will need to show their government issued identification card, passport, DNA sample, work history and resume, retinal scan, and perhaps a Google history scan to use Google Plus or similar social network. I can appreciate that Google wants to encourage people to use their real names, but there are so many instances beyond their automated algorithmic logic that people use nicknames, pen names, aliases, alternative spellings, stage names, witness protection name, and more. Is Google Plus going to force Jon Stewart to use his birth name? What about Lady Gaga? What about Dear Abby? Larry Brin uses the short form for Lawrence, is that okay? And don’t get me started with folks that are known by their initials or by their profession title such as Dr. Dre.

So why is Google, and Facebook for that matter, so against anonymity? It’s all about the data. The more data Google has on each user, the better they can serve ads targeting them. Google Plus is a user data collection service as much as it is a social network. Google Plus gives Google a new platform to collect even more data that it can then sell, trade, and use to target ads. Currently, most of Google’s ads work on the intent of the user. The more Google knows about the people in your circles, their name, age, background, location, work history, interests, trends, and communication patterns it can easily develop social ads that target you and your inner most circle members.

This whole debate is a red herring, the real issue is about the identifying data that Google is collecting on each profile.  There are already a large number of third parties that are forming a “fourth bureau” of sorts that collects any and every piece of information such as if you pay a phone bill on time or if you spend 6 hours in the middle of the day playing FarmVille.