Pedro Assunção

Apple will remove java from OSX with Lion, so what?

I don’t get all the fuss about Apple no longer shipping java with OSX. Windows never did. Linux does not. So what?

Actually, with Lion, they will make it extremely easy to install anyways. According to early reports about the developer preview release, when a user tries to run a java application (or install one), the operating system will look online for the latest runtime virtual machine and prompt the user to install it. IT’S EVEN EASIER THAN ON WINDOWS, PEOPLE! :D

You can get more info in this article.


Stuff from movies: Transparent multi touch screen

Now this is what i call the future coming to us: Stuff previously only seen in movies coming to the real world. LG has demo’ed a transparent multi touch display. Can i have one? :)


Full list of Coca Cola brands – had no idea there were so many

As a part of my Ruby learning process, i decided to write something to retrieve the full list of brands that Coca Cola currently owns from their website. The list is split across multiple pages, but with some Ruby magic and a nice library called Hpricot to traverse the HTML it was 5 minutes of work :)

Here’s the script:

require 'open-uri'
require 'rubygems'
require 'hpricot'
require 'pp'

my_file = File.new("cola.txt", 'w')

('a'..'z').each do |letter|
open("http://www.thecoca-colacompany.com/brands/product_list_#{letter}.html") do |f|

    # meta info
    #pp f.meta

    #pp 'Content-Type: ' + f.content_type
    #pp 'Last modified: ' + f.last_modified.to_s

    doc = Hpricot.XML(f)
    div = doc/"#products_link_list"
    (div/:ul).each do |ul|
      (ul/:li).each do |li|
        if (li/:a).first
          my_file.puts((li/:a).first.inner_html)
        else
          my_file.puts li.inner_html.to_s
        end
      end
    end

  end
end

And here’s the full list of brands that belong to Coca Cola:

A&W
Acueducto
Ades
Agua Manantial
Ali
Alive
Alpina
Ambasa
Ameyal
Amorino
Andina/Andina light
Andina Fortified
Andina Fresh
Andina Frut
Andina Nectar
Apollinaris
Aqua+
Aquabona
Aquactivede by Aquarius
Aquana
Aquarius
Aquarius Active Diet
BACARDI Mixers*
BACARDI Premium Mixers*
Bajoru Gira
Bankia
Barq’s
Barrelitos
BEAT
Beautia
Bebere
Benedictino
Beverly
Bevi
Bibo
Big Crush
Big Tai
Bimbo
Bimbo Break
Biotime
Bird’s Nest*
Bistra
Bistrone
Bjare
Blackfire
Boco
Bogadera
Bom Bit Maesil
BonAqua/BonAqa
Borneo
Botaniq 1QQ
Botany
BPM
Brazzi
Bright & Early
Brisa Agua Pura
Brisa by Bonaqua
Brisa con un Toque de Gas
Brisa Spa
Bu
Bubbly
burn
buzz
CAFÉ ZU
caffeine-free Barq’s
caffeine-free Coca-Cola
caffeine-free Diet Coke/caffeine-free Coca-Cola light
Calypso
Canada Dry
Canning’s
Cappy
Caprice
Caribou Coffee*
Carioca
Cascal
Carver’s
Cepita
Chaqwa
Charrua
Chaudfontaine
Cheers
cherry Coke
cherry Coke zero
Chinotto
Chinotto light
Ciel
CITRA
Club
Coca-Cola
Coca-Cola Black Cherry Vanilla
Coca-Cola Blāk
Coca-Cola C2
Coca-Cola Citra
Coca-Cola light/Diet Coke
Coca-Cola with Lemon
Coca-Cola with Lime
Coca-Cola with Raspberry
Coca-Cola Zero
Cocoteen
Cola Guaraná Jesus
Country Club
Cresta
Cristal
Crush
Crusta
Crystal
Damla Minera
DANNON*
DASANI
DASANI Active
DASANI Balance
DASANI Flavors
DASANI Nutriwater
DASANI Plus
Del Valle
Del Valle Frut
Del Valle Frutsi
Del Valle Frutsi Desarrollo
Del Valle Kapo
Del Valle Mais light
Del Valle light
Delaware Punch
diet A&W
diet Andina Frut/Andina Frut light
diet Andina Nectar/Andina Nectar light
diet Barq’s
diet Canada Dry
Diet cherry Coke
Diet Coke/Coca-Cola light
Diet Coke Black Cherry Vanilla
Diet Coke Citra/Coca-Cola light Citra
Diet Coke Plus
Diet Coke Sweetened with Splenda®
Diet Coke with Lemon/Coca-Cola light with Lemon
Diet Coke with Lime/Coca-Cola light with Lime
Diet Coke with Raspberry
Diet Crush
diet Dr Pepper/Dr Pepper Zero
diet Fanta/Fanta light/Fanta Zero/Fanta Free
diet Freskyta
diet INCA KOLA
diet Kia Ora
diet Krest
diet Lift/Lift light
diet Lilt/Lilt Zero
diet Master Pour
diet Mello Yello
diet Mezzo Mix
diet Minute Maid Soft Drink
diet Nestea/Nestea light*
diet Northern Neck
diet Oasis
diet Quatro/Quatro light
diet Schweppes
diet Seagram’s*
diet Sprite/Sprite light/diet Sprite Zero/Sprite Zero
diet Squirt
diet Tai/Tai light
diet Vanilla Coke
Disney Xtreme Cooler*
Diva
Dobriy
Dogadan
Dorna
Dr Pepper
E2
Earth and Sky
Eight O’Clock
El Rayek
Enviga*
Epika
Escuis
Eva Water
Fanta
Fanta Verdia
Far Coast
Felicia
Finley
Fioravanti
Fire
Five Alive
Flavor Rage
Fontana
Fresca
Fresca 1
Frescolita
Freskyta
Fresquinha
Fress
Frestea*
Friolin
Frisco
Frugos
Frugos Fresh
Fruit Solutions
Fruitia
Fruitier
Fruitopia
Fruktime
Frutina
Frutonic
Full Throttle
Full Throttle Blue Demon
Full Throttle Sugar Free
Funchum Orange Drink
Furusato Dayori
FUZE Healthy Infusions
GEORGIA
GEORGIA Club
GEORGIA Gold
GEORGIA Grande
Gini
Girios Gira
glacéau smartwater
glacéau vitaminwater
glacéau vitaminwater zero
Gladiator
Godiva* Belgian Blends
Gold Peak
Gold Spot
Golden Crush
Goombay Punch
Goulburn Valley
Grapette
Groovy
Guaraná Kuat light
Guaraná Kuat Zero
Hajime
Haru No Mint Shukan
Hawai
Healthworks
Heppinger
Hero
Hi Spot
Hi-C
Hires
Hit
Horizon
Hot Point
Huang
Ice Dew
Ice Dew 3+
Ice Tea Leao
illy issimo*
INCA KOLA
Ipsei
Izvorul Alb
Jaz Cola
Jericho
Jet Tonic
Jolly Juice
Joy
Joya
Juan Valdez
Juices To Go
Just Juice
Kani
Kapo
Kapo Zero
Karada Meguri-Cha
Kashaya Tea
Keloco
Keri
Kia Ora
Kildevaeld
Kilimanjaro
Kin
Kinley
Kist
Kiwi Blue
Kochakaden
Kola Inglesa
Koumisoukai
Krest
Kristal
Kropla Beskidu
Krushka & Bochka
Kuat
Kuat Guaraná
Kuat light
Kuli
Kyun
La Jolla
La Vuelta
Lanitis
Lanitis Extra
Lanitis Filaraki
Leao Green Tea
Leao Guaraná Power
Leao Iced Tea
Less Is More, Kinley
Lift
Lift Plus
Lift Plus light
Lilia
Lilt
Limca
Limelite
Limonade
Linnuse
Lion
Love Body
Maaza
Mad River
Malvern
Manantial
Mare Rosso
Marocha
Master Chill
Master Pour
Matte Leao
Matusov Pramen
Mazoe
Mello
Mello Yello
Mer
Mezzo
Mezzo Mix
Miami
Mickey*
Migoro-Nomigoro
Minaqua
Mineragua
Minute Maid
Minute Maid Active
Minute Maid Antiox
Minute Maid Deli
Minute Maid Duofrutas
Minute Maid Fruit Plus
Minute Maid Heart Wise
Minute Maid Just 10
Minute Maid Light
Minute Maid Mais
Minute Maid Nutri+
Minute Maid Premium
Minute Maid Soft Drink
Minute Maid Splash
Mireille
Mission
Mone
Montefiore
Mori No Mizudayori
Morning Deli
Mother
Mr. Pibb
multiVita
Nada
Nagomi
Nalu
Namthip
Nanairo Acha
Naturaqua
Natures Own*
Nectarin
Nestea*
Nestea Choglit*
Nestea COOL*
Nestea Viteao*
Nevada
Neverfail
Next
Nico
Nordic Mist
Northern Neck
NOS
Nos Entendemos
Oasis
Odwalla
Olimpija
Orchy
Paani Treated Water
Pacific Orchard
Pampa
Paradise Sun
Parle
Pasazade
Pearona
Peats Ridge Springs
Pibb Xtra
Pibb Zero
Piko
Pilskania
Planet Java*
Play Energy Drink
Pocket Dr
Poiana Negri
Polar Brew
Poms
Ponkana
Pop
Portello
POWERADE
POWERADE Advance
POWERADE alive
POWERADE aqua+
POWERADE Balance
POWERADE light
POWERADE OPTION
POWERADE Zero
Powerplay
Premio
Presta
Presta light
Pulp Orange
Pulpy
Pump
Pumped Enhanced Hydration
Pura Sol
Qoo
Quatro
Quwat Jabal
R’fresh
Ramlosa
Real
Real Leaf
Real Gold
Rehab
Relentless
Rich
Richy
Riwa
Roemerquelle
Rosa
Rosalta
Roses
Royal Tru
Royal Tru light
Safety First
Safia
Sahtain
Samantha
Samurai
San Luis
Sarsi
Saryusaisai
Schuss
Schweppes
Schweppes Abbey Well
Seagram’s*
Seltz
Sensation
Sensun Gazoz
SENZAO
Shandy
Shangri-La
ShiZen*
Shock
Signature
Sim
Simba
Simply Apple
Simply Grapefruit
Simply Lemonade
Simply Limeade
Simply Orange
Smart
Sobo
Sokenbicha
Solo
Sonfil
Soonsoo 100
Southern Sun
Sparkle
Sparletta
Sparletta Iron Brew
Splash
Splice
Sport
Sprite
Sprite 3G
Sprite Duo
Sprite Flavors
Sprite Ice
Sprite Remix
Sprite Zero/diet Sprite/Sprite light /diet Sprite Zero
Spur
Squirt
Stoney Gold Ginger Beer
Sucos Mais
Sunfill
SURGE
Svali
Sveva
Sweecha
TaB
TaB energy
TaB X-Tra
TADAS
Tai
The Spirit of Georgia
The Wellness From Coca-Cola
Thextons
Thums Up
Tian Yu Di/Heaven and Earth
Tiky
Toppur
Top’s
Tropi
Tropical
Turkuaz
Ultra
Urge
Urun
V Florida 7
Valle Frut
Valpre
Valser
Valser Viva
Vanilla Coke
Vanilla Coke Zero
VAULT
VAULT Zero
Vegitabeta
VICA
Vio
Vita
Vital
Wilkins
Wink
Winnie the Pooh*
Yangguang
Yangguang Juicy T
Yo Conozco a Hugo
Yoli
Youki
Yuan Ye


Dropbox plus Mercurial -driven development. Anyone tried that?

One of the biggest pains of any developer is maintaing the source code. Especially if you – like me – have a gazillion pet projects that need to be updated whenever you come up with “cool idea #20000″ for one of them.

Version control systems like Mercurial are awesome, but they are only part of the equation; there’s still the time consuming process of deploying the changes to “production”. So i wonder if it would be a good idea to have a Mercurial repository sitting on a dropbox account and develop directly there. This way any changes to the source code would be instantly reflected on production.

I am aware that this is unthinkable for serious projects (the kind you get paid to do), but it can probably work for fun pet projects.

Do you have any experience with something like that? Share your thoughts, if you have any :)


Random notes on India

Some random notes i scribbled down in my little paper notepad, on my trip from Bangalore to Goa, this weekend:

  • Saw 10 people inside a car that could normally only hold 5;
  • Took me 2 hours to drive 17Km inside Bangalore;
  • Saw a movie theater that was only showing Indian movies;
  • Products usually have a date of manufacture, as opposed to expiry date;
  • You don’t see many foreigners on the streets (i was pretty much the only one everywhere i went);
  • There are drinking water trucks distributing on the streets;
  • From times to times there are cows roaming between the cars, especially on smaller roads;
  • Indians are very humble and seem not to get pissed off easily (if you see the traffic here, you’ll understand why stress cannot possibly affect them);
  • Highways are a place of gathering; There are people walking, you can go in reverse, get into the opposite lanes;
  • People get into and out of buses while it’s still moving, usually taking the times when it’s turning or slowing down for other cars to pass;
  • Our bus – at some point during the night – had to reverse in the highway, because the driver overshot the place where we were supposed to stop for a break;
  • At some point there was this really thick fog (you could not see 5 meters in front of the bus), but the driver still kept going at the same (insane) speed :)
  • The second stop was in some remote place that had nothing but a road and a farm. Peaceful;
  • Food at the hotel in Goa (Marigold – Panaji) is around 3 Euro per meal; Some dishes are even cheaper (around 1.5 Euro);
  • One single bed room there was around 2000 Rupees for 1 night (40 euro);
  • On the way there, more hardware stores could be seen than places with food;
  • In Goa is also rare to find foreigners on the streets;
  • From Panaji to Calangute (beaches) is about 30 minutes by scooter;
  • Aguada fort is great :)
  • Cricket is the national sport; You can find a lot of people watching the games on TV shops’ stands;
  • Domino’s pizza in Goa: found a pizza that is not spicy;
  • Correction, after pouring the so-called Oregano condiments, it is a bit spicy. Turns out the “Oregano” also contained white and black pepper;
  • A lot of the tourism is internal. Which makes sense, considering the size of the country;
  • 60 cl of Cola = 30 rupees = 60 euro cents; 1 cent = 1 cl :)
  • It’s very funny that there is a guard at the church door, keeping people from entering the “house of the lord” after the service has started.

Observations on vehicle traffic in India

Cow in Bangalore

I’ll keep this one short. I am currently visiting Bangalore – in the context of a business trip – and these are my observations/thoughts about the traffic in the streets here :)

  • Most trucks don’t have tail lights. I mean, who needs to see trucks in the highway anyways? :)
  • There are trucks parked in the highway. On a lane. Not kidding!
  • There are cars going in reverse in the middle of the road (also saw it once in a highway)
  • Some people bike their way *against* the traffic flow (on the highway as well)!
  • Lane marks are basically useless. If you have 3 lanes, you will probably have 5 cars side by side :)
  • Using the horn is a form of communication. Seems to be analogous to the Sonar systems in the submarines. During the night lights are also used intensively for this purpose :)
  • Roads have close to no illumination, which makes it much easier to run people over. You know, the ones that are crossing the highway on foot.
  • Drivers will pass you wherever there is space open. Left, right, middle, doesn’t really matter. Use the sonar :)
  • There are signs saying “Please respect the traffic rules”, hehe :)
  • You can spot the occasional tractor in the highway.
  • Most people don’t speak a lot of English, but they all drive like Nigel Mansell or Damon Hill :)

Will operating systems become user interface agnostic?

After reading a post in PCPro.co.uk, about the dual core ARM phone that can run both Android and Ubuntu at the same time, i can’t help being excited about the possibilities that the near future holds for us, mobile-wise.

I’m pretty sure that – at some point in time – we will not need laptops or desktop computers anymore; we can just go around with our tablets and/or phones and – when we need more screen space to work – just plug it into an external setup (screen, mouse, keyboard) and hack away.

Which brings me to think that the next versions of mobile operating systems will become more and more full fledged operating systems as we traditionally think of them on the desktop. Sure, right now they are being tailored to suit touch screen interfaces (tablets, phones), but i think we might get to a point where they will have to become user interface agnostic, to allow this type of hybrid behavior.


Will there ever be a segway device that looks cool?

There’s a new segway-like vehicle: It’s called SoloWheel and it’s basically a simpler version of the former. It does look like much harder to “drive” than the segway, though, so i seriously doubt this will pick up any momentum, if you catch my drift :)

Here’s the link to the engadget article and the essential videos. The first is basically an ad, and the second is an interaction of a normal person with the device for the first time:


Installing Ruby on Rails on OSX (snow leopard)

Just some notes i might update while going through the procedure.

To start with, gem might complain that bundler requires a higher version. Something like this might happen, when you run “sudo gem install rails”:

ERROR:  Error installing bundler:
bundler requires RubyGems version >= 1.3.6
ERROR:  Error installing bundler:        bundler requires RubyGems version >= 1.3.6

If you run into that, you need to ask gem to update itself:

sudo gem update --system

Then rails’ installation should work. Actually i get errors installing the documentation for some gems. Should look into that…


A statement, a question, and a cool car

Let’s start with the question: Who the hell can live happily in negative temperatures? Maybe i’m biased, given my warmer origins but – man – there’s no way i could be happy living in a dark, cold place. It’s no wonder people who work in dark places (miners, underground train drivers, etc) tend to be more depressed than people that live in warm climates. I mean, take South America for instance; even though they are not amongst the world’s richest populations, they are all extremely positive and happy people.

Which brings us to the statement: If we were meant to live in the cold, we would not have been losing body hair along the centuries like we have. And yes, that’s my 2 cents of “guessing” science to back up the previous question :)

Finally, i have to say i found this car really intriguing. If i didn’t love my Citroen AX so much i might be tempted to buy one of these Daihatsu Materia:


Idea for a better customer satisfaction/feedback service

Recently i had to fill one of those client/customer satisfaction surveys. Endless pages of “how well do you grade feature X” questions that frustrate you beyond the point of killing yourself and your colleagues.

And that got me thinking: how about a simple form that asks “Are you happy? Yes/No”? If you answer “yes”, case closed. And some people are just plainly happy with the service/product/job so this is definitely a time saver. If you answer “no”, you are presented with a text field where you can start typing what you are not happy about and, as you do, it queries for responses from other people to suggest you with stuff that might be a problem to you. If you find one that applies to what you are trying to complain about, you choose it and another text field presents itself to complain about something else. If you don’t find one previous reply, yours is added. Repeat until done.

How’s that for simplicity?

And while we’re are it, why not make it an online survey service and make tons of cash?

Who’s your friend? Now start coding! ;)


Adventures at the Indian embassy (or how Portuguese services suck)

Disclaimer: I’m not complaining specifically against the way the Indian embassy works so, before calling a xenophobic or some crap like that, keep in mind that i’m just venting out something that could have happened in pretty much any other Portuguese public bureau.

Where should i start? Ah, yes, the motivation: In about a month i am supposed to go to India in a business trip and – as such – i will require a visa.

I went to the embassy on Wednesday morning only to find out that visa applications are not handled on Wednesdays. Just my luck! It was clearly my fault, since i did not properly check the opening times on their – extremely hard to find – website. Did i mention you spend one hour in traffic just to get there? Suffice to say i was pissed, though mostly at myself. I did try to call them, but the automated response only directed people to their website. Why they bother having a phone is beyond me.

The next day i went back again (1 more hour in traffic) and finally got a ticket. The system works like this: You wait in the streets until a security guard calls you. Then he checks to see if your papers are all in order, and finally gives you a numbered ticket and sends you into the actual waiting/service room where you… wait some more. I arrived at the gate at around 11 am. I got ticket number 35. The embassy opens at 9.30 and they only had served around 19 tickets. I did my math and promptly went back home, at the risk of spending the entire day waiting. Again – probably my fault – but one should take some time to see the number of people that uses our services and get the appropriate amount of workers to be able to deal with them in a timely fashion. Two workers for 50 people, when the average time per person is 20 minutes, will not work.

Third day: Decided that i should be one of the first people to get there and get a ticket. Left home around 8 am. Arrived at the embassy at 9:15. Got ticket number 4. Not bad. Funny fact about lines in portugal: they don’t exist. I arrived at the embassy gate and there were around 10 people there already (the embassy opens at 9.30, though they only started actually working at 10). I asked politely “is there a line?” and was greeted with the response “not really, you know how it is with us portuguese, we just remember who came first”. This is exactly the kind of crap that pisses me off: lack of order and organization. But then again, looking at my living room right now, i shouldn’t really complain :)

So, i got my number and went ahead into the waiting room. Now, the website states that – for business visas – one is required the following:

- Invitation letter from the Indian partner,

OR

- Invitation letter from the Portuguese company explaining the details of the visit.

Note the emphasized “OR”.

After waiting for roughly 30 minutes, the lady tells me that i’m missing a letter from my company (i only had the one from the Indian company). I tried to explain that the website said i only needed that one but there was nothing that could be done. She told me how long it would take, explained that it had to be analyzed by two different entities and told me how much it would cost. Since – up until then – i saw everyone paying in cash i decided it would be a good idea to ask if they accepted cards. No cards. Really? What century is this? And you could put out a sign explaining that so that i would know about it – oh call me crazy – before i waited in line or – i don’t know – you could put it IN YOUR WEBSITE?

So here’s my summary of improvements, if anyone closely related to the Indian embassy in Portugal reads this and cares enough to help people not waste their time and money getting a freaking visa:

  1. Update your website! Seriously, read that again: Update your website. It’s the 21st century and pretty much everyone uses the web to know information about this kind of things;
  2. Put up a sign that you do not take cards as a method of payment. I do understand why you make the entrance process so explicitly phased, but people need to know what to count on when they get in there. I don’t want to stand in line for 1 hour (a very typical case, trust me) only to find out i cannot pay with my card. Also, see point number 1!
  3. Get more people working there. Clearly the waiting times should tell you that you are understaffed.

There, ended up being constructive. I feel much better now :)

UPDATE: As a good friend of mine very well pointed out, i should help other people find their website :)


Review: TotalFinder – Finder on steroids

Today i want to tell you about the best thing since canned tuna: a fantastic application that extends Finder’s functionality to provide you with features like tabs, cut-and-paste, dual-mode, and more. You know, the things that all of us have missed in Finder, one time or another. It’s appropriately named TotalFinder (in honor, i’m guessing, of the TotalCommander application).

Here’s a rundown of the features that i love and the ones i kind of like, as well as a few suggestions on what could be added or improved:

What i kind of like, but would probably change

Tabs

Tabs

Tabs : It’s nice to have the possibility of endless tabs, but i have trouble imagining having more than 2-3 open in any given window. It’s not a bad thing, but i think TotalFinder could totally get away with the dual-mode (maybe throwing in a tri-mode into the mix).

What i love

Cut and paste : Been missing this feature ever since i bought my first mac. I love Apple, but i think sometimes they just assume that people are dumb and fail to provide some tools that we consider basic needs. This is one of them and TotalFinder brings it back to us.

Dual mode

Dual mode

The dual mode : The ability to look at two different folders in the same window is something that you will never want to live without again. Sure, you can open two finder windows and put them side by side. But it’s a much slower process. In TotalFinder all you need to do is press Command + T (opens a new tab, so you have 2) and then Command + U. Presto! Dual mode goodness.

The visor : Combine the dual mode above with the Visor and you have the best Finder experience ever! The visor is something like the Quake terminal (remember? the one that slided into view so you could type all the cheats in? :) ); It sits out of sight until you press a global shortcut (typically ALT + `) and then slides from the bottom of the screen. It’s the best way to always have a Finder window around.

Folders on top : Call me old fashioned, but i do believe that folders should always be shown before files in any list. I can’t explain why, but it just makes sense to me. And if it also makes sense to you, then TotalFinder allows you to set this option :)

Hidden files/folders

Hidden files/folders

Show hidden/system files : Again, Apple is protecting us from ourselves. I understand the motivation but sometimes i really want to see the hidden files. Especially for developers and powerusers who, from times to times, need to edit those dotSomething files (i.e. .bash_profile) this is a must-have!

Suggestions

Dual mode button in the bar : It wasn’t immediately apparent to me how to activate the dual-mode. I think it would be much simpler if there was a button in the bar, next to the quick-look and view mode buttons. Maybe it’s not even possible to implement, due to the Finder’s restrictions, so i’m just throwing it out there :)

Quick find folder feature : One thing i keep coming back to, when using file explorers, is the lack of a nice way to find a certain folder. I know i can use Finder’s search field, but then i have to specify that i’m searching by filename, and in the entire drive, and bla bla bla. A “find folder by name” feature would be a great addition to Finder, in my opinion.

Conclusion

TotalFinder is a great addition to your file/folder handling arsenal. It will bring back features that you missed for a long long time and are surprised Apple does not provide out-of-the-box. It’s not free. But then again, it’s a one man operation building a great product that will definitely give you more than the $15 you’ll pay for it. You can also get a 3 pack for $30 and offer 2 licenses to your friends :)

Bottom line: totally worth it!


Learning to sit-fly

Free flying is hard work, i’ll tell you that. It’s always very easy to watch guys like the Skywalkers, Omar Alhegelan, Tim Porter, and other skydiving idols and think: “hey, i could do that”. But what we tend to forget is that, like most things in life that are worth doing, it takes time, dedication, and a lot of hard work to make them look easy.

Last weekend at the DZ me and my pal “totaly” tried a couple of exits in a sitting grip and the result, though undisputedly hilarious, was not what i was expecting. I feel i’m getting a lot better at sit flying, but when it comes to grips, man, do i need to practice.

Enjoy the video, we know we did love creating it, hehe!

Blue skies! ;)

Évora – 2010-12-19 from Pedro Assunção on Vimeo.


Spring and hibernate: Lazy loading collections in desktop (swing) applications

So here’s something you can’t find on the internets. Or at least i couldn’t, when i was trying to find a way to do this.

The problem:

Traditionally, spring and hibernate have been mostly used in web applications. In this case, you can easily define your domain objects to have lazy collections because spring/hibernate will keep an open session during the whole handling of each web request. This means that you can access lazy loading objects even in your views (provided you use the open session in view filter ;) ).

Now, in desktop applications you usually don’t go around having open sessions all the time which means that, unfortunately, when you try to get a lazy loading collection, hibernate will give you a big finger in the form of a LazyInitializationException due to the fact of no open sessions existing.

One solution:

My application’s structure is such that no UI classes are being managed by spring (and by this i mean your mileage may vary with this solution), only my services and data access objects (DAOs) are. The UI accesses the services by use of a ServiceLocator pattern (which can be more or less complex, depending on your needs) and the DAOs in the services are autowired. The rest is just spring plumbing.

The way i found more elegant to deal with the lazy loading problem is the following. Take this bean (for the sake of simplicity some annotations or methods might be missing, beware):

@Entity
public class MyBean {
  @Column(name = "NAME")
  private String name;

  @CollectionOfElements(fetch = FetchType.LAZY)
  private Set<AnotherBean> children;

  public Set<AnotherBean> getChildren() {
    return children;
  }
}

If you try to access getChildren() hibernate will complain so i changed the method to this:

public Set<AnotherBean> getChildren() {

  children = DBUtils.initializeIfNeeded(this, children);
  return children;
}

And here’s the definition of that static method:

public static <T> Set<T> initializeIfNeeded(Object obj, Set<T> collection) {

  if (!(collection instanceof PersistentCollection)) {

    return Sets.newHashSet();
  }

  if (!((PersistentCollection) collection).wasInitialized()) {

    ServiceLocator.get(CompanyDA.class).initializeLazyCollection(obj, collection);
  }

  return collection != null ? collection : Sets.<T>newHashSet();
}

What we are doing is checking whether this collection is a instance of hibernate’s PersistentCollection and, if not, getting out. If it is, and hasn’t been initialized, we call a special method in the super of all my DAO’s that is responsible for asking hibernate to initialize the collection. Take into account that this method has to be inside a spring managed bean (i.e. non static) otherwise it won’t be able to open a new session and you’re back to square one.

Here’s the definition of that method in the DAO:

public void initializeLazyCollection(Object obj, Collection<? extends Object> collection) {
  sessionFactory.getCurrentSession().lock(obj, LockMode.NONE);
  new HibernateTemplate(sessionFactory).initialize(collection);
}

Hope this helps anyone and if you know of a better way to do the same thing, please share :)

Peace out.


Lighter naval ships made of aluminum foam

I can’t believe this is so hard to find on Google. Someone sent me a documentary video (in Portuguese – unfortunately – but, if you understand German, the creators of this idea speak in their native language) and i can find hardly any references to this online.

It’s basically about using a special aluminum powder that, when heated, transforms into a foam that is – check it out – lighter than water. Yes, imagine ships 30% lighter, that can carry many many more tons of materials. Less trips = less pollution = win/win ;)

Here’s a link to a 1998 paper about this.

I wonder if this technology is already in use in today’s ships and, if not, why?


Is your Safari 5 slow? Here’s a probable problem and solution.

I could not figure out why the hell Safari 5 was running so slow in my personal mac, when compared with the one i use for work. Until i read some nice tips on the subject, namely this one article.

To make the story short: I had installed (a long long time ago) a couple of plugins (not to be confused with the new extensions) and completely forgot about them. One of them was the cause for Safari to completely block for 5-10 seconds at a time and show me the spinning color onion. I don’t care which one but, bottom line is, one probable cause for your problem is a misbehaved plugin.

The safest way to check is to go to Preferences -> Security and disable the plugins. Then restart the browser and check if the problem went away. If so, point Finder to ~/Library/Internet Plug-Ins and move the files to another folder. Enable the plugins again in the browser and restart. If it’s still fast, then that was your problem. Now the only thing left to do is to re-add them to the folder one by one, until you figure out which one is making Safari suck ;)

Happy hunting :)