Saturday, October 29, 2005

Valores Invertidos?

0 comments
Um carro tem o seu vidro quebrado e o seu rádio roubado na frente de casa. Talvez a culpa seja do dono do carro, pois ele causou uma grande desigualdade social àquele que não tinha o carro nem o rádio, logo isso teve que ser combatido. Como diria alguns socialistas, certas situações não devem ser discutidas, devem ser _combatidas_. Fisicamente, se necessário.

E o que aconteceria se o dono tivesse encontrado o autor do furto e o agredido fisicamente? Certamente seria o seu ônus o custo do vidro, do rádio e de quaisquer consequências a esse indivíduo. E, se fosse um menor de idade ainda? Acho que certamente não consigo imaginar as consequências a esse dono do carro.

Que assistências sociais e religiosos mais fervorosos não me ataquem. Mas esse é o Brasil.

Intelligence

0 comments
"Intelligence is not an exclusive monopoly of genius; it is an attribute of all men, and the differences are only a matter of degree. If conditions of existence are destructive to genius, they are destructive to every man, each in proportion to his intelligence. If genius is penalized, so is the faculty of intelligence in every other man. There is only this difference: the average man does not possess the genius's power of self-confident resistance, and will break much faster; he will give up his mind, in hopeless bewilderment, under the first touch of pressure."
[Ayn Rand, "Requiem for Man," Capitalism: The Unknown Ideal]

"Look past the range of the moment, you who cry that you fear to compete with men of superior intelligence, that their mind is a threat to your livelihood, that the strong leave no chance to the weak in a market of voluntary trade. What determines the material value of your work? Nothing but the productive effort of your mind?if you lived on a desert island. The less efficient the thinking of your brain, the less your physical labor would bring you?and you could spend your life on a single routine, collecting a precarious harvest or hunting with bow and arrows, unable to think any further. But when you live in a rational society, where men are free to trade, you receive an incalculable bonus: the material value of your work is determined not only by your effort, but by the effort of the best productive minds who exist in the world around you . . . .

"Every man is free to rise as far as he's able or willing, but it's only the degree to which he thinks that determines the degree to which he'll rise. Physical labor as such can extend no further than the range of the moment. The man who does no more than physical labor, consumes the material value-equivalent of his own contribution to the process of production, and leaves no further value, neither for himself nor others. But the man who produces an idea in any field of rational endeavor?the man who discovers new knowledge?is the permanent benefactor of humanity. Material products can't be shared, they belong to some ultimate consumer; it is only the value of an idea that can be shared with unlimited numbers of men, making all sharers richer at no one's sacrifice or loss, raising the productive capacity of whatever labor they perform. It is the value of his own time that the strong of the intellect transfers to the weak, letting them work on the jobs he discovered, while devoting his time to further discoveries. This is mutual trade to mutual advantage; the interests of the mind are one, no matter what the degree of intelligence, among men who desire to work and don't seek or expect the unearned.

"In proportion to the mental energy he spent, the man who creates a new invention receives but a small percentage of his value in terms of material payment, no matter what fortune he makes, no matter what millions he earns. But the man who works as a janitor in the factory producing that invention, receives an enormous payment in proportion to the mental effort that his job requires of him. And the same is true of all men between, on all levels of ambition and ability. The man at the top of the intellectual pyramid contributes the most to all those below him, but gets nothing except his material payment, receiving no intellectual bonus from others to add to the value of his time. The man at the bottom who, left to himself, would starve in his hopeless ineptitude, contributes nothing to those above him, but receives the bonus of all of their brains. Such is the nature of the 'competition' between the strong and the weak of the intellect. Such is the pattern of 'exploitation' for which you have damned the strong."
[Ayn Rand, Atlas Shrugged]

Instead of typing the whole text, I found it here.

Errors of Knowledge and Breaches of Morality

0 comments
"Learn to distinguish the difference between the errors of knowledge and breaches of morality. An error of knowledge is not a moral flaw, provided you are willing to correct it; only a mystic would judge human beings by the standard of an impossible, automatic omniscience. But a breach of morality is the conscious choice of an action you know to be evil, or a willful evasion of knowledge, a suspension of sight and of thought. That which you do no know, is not a moral charge agains you; but that which you refuse to know, is an account of infamy growing in your soul. Make every allowance for errors of knowledge; do not forgive or accept any breach of morality. Give the benefit of the doubt to those who seek to know; but treat as potential killers those specimens of insolent depravity wo make demands upon you, announcing that they have and seek no reasons, proclaiming, as a license, that they 'just feel it' - or those who reject an irrefutable argument by saying: 'It's only logic', which means: 'It's only realit'. The only realm opposed to reality is the realm and premise of death."

Ayn Rand - "Atlas Shrugged"

Friday, October 28, 2005

Each day a new bug

0 comments
At this time, Xdoclet is our attention. Duplicate "unique" attribute generation. I should give Hibernate annotations a try.

http://opensource2.atlassian.com/projects/xdoclet/browse/XDT-1349

Simple to fix, but my xdoclet jar is already full of patches (I think at least more 2/3 in the past).

Thursday, October 27, 2005

Joelmir Beting, Sobre as Viagens de Lula

2 comments
Não sei se é verdade, mas aí vai.

JOELMIR BETING,SOBRE AS VIAGENS DE LULA

"... Até aqui, em 25 meses de governo, o presidente Lula já cometeu 62 viagens ao mundo.
Ou mais de duas por mês, tal como semana sim, semana não.
Sem contar, ora pois, as até aqui, 177 viagens pelo Brasil.
Hoje, dia 15, ele completa 115 dias fora do país desde a posse.
E pelo Brasil, no mesmo período, 335 dias fora de Brasília.
Total da itinerância presidencial, caso único no mundo e na História: exatos 450 dias fora do Palácio, em exatos 777 dias de presidência.
Governar ou despachar, nem pensar.
A ordem é circular.
A qualquer pretexto.
E sendo aqui deselegante, digo que o presidente não é (nem nunca foi) chegado ao batente, ao despacho, ao expediente.
Jamais poderá mourejar no gabinete, dez horas por dia, um simpático mandatário que tem na biografia o nunca ter se sentado à mesa nem para
estudar, nem para trabalhar."

Wednesday, October 26, 2005

ChoiceFormat

0 comments
For those of you that are used to properties files and use it for i18n, in particular with frameworks like Struts, you must know the ChoiceFormat, from Java API. Very interesting for scenarios where you want to make minor adjustments to the text according to the value you receive. The example in MessageFormat is excellent to show you this:

"There {0,choice,1#is one file|1<are {0,number,integer} files}."


In this case, the English message is adjusted according to the value you get.

Incoherence in Struts

0 comments
getMessages(HttpServletRequest) and getErrors(HttpServletRequest) methods from Action class are supposed to return the messages and errors from the request scope. However, you may have saved it in the session scope, since the saveMessages(HttpSession session, ActionMessages messages) method exists and allows you to do that. In this case, if you use saveMessages() (in session scope) and right after use a getMessages(), it will return a new ActionMessages(), with all the previous messages wiped out.

AppFuse has a BaseAction class that implements the correct version of getMessages() and getErrors() and this implementation should be integrated into Struts.

Apache Sofware Foundation Bugzilla: bug 34857

Sunday, October 23, 2005

Thursday, October 20, 2005

Aos Jovens

0 comments

Aos jovens

DANUZA LEÃO

Você, que tem 20, 30 ou 40 anos, fique alerta: essa idade vai passar, e mais depressa do que imagina. Não perca tempo, por favor, sofrendo porque a mãe ou o pai sei lá o quê.

Nada importa; quem tem 25 anos deve aproveitar a vida a cada segundo. Talvez seja inútil dizer isso, porque quem tem 25 não ouve os mais velhos, mas é muito bom ter 25. Não importa se o dinheiro está curto, se foi abandonada pelo namorado, se o futuro é incerto. Nessa idade, não há futuro certo ou incerto, há muito mais: há futuro.
Aproveite; se estiver triste em casa nesse domingo, sem amigos, nem amores nem dinheiro, pense: sou jovem, tenho uma vida pela frente. Isso é melhor do que todas as glórias do mundo, só que ninguém diz isso aos que têm 25. A mim, ninguém nunca disse.
Não dizem talvez por inveja; é mais fácil mostrar que a vida é dura, que é preciso estudar, trabalhar -o que também é verdade; mas ninguém pega uma menina ou um garoto de 25 pelos ombros, sacode, e diz: "Você tem 25, não se esqueça disso um só minuto, viva sua juventude. Aproveite e viva, porque ela vai passar".
E passa. Não que aos 50 não se tenham outras alegrias, outras compensações; mas saber que os de 25 não se dão conta do que estão vivendo é quase revoltante. Seria preciso que eles pensassem, de hora em hora, a cada minuto: "Tenho 25 anos".
Nessa idade não temos obrigação de nada, a não ser a de sermos felizes. Se o seu time perdeu o campeonato, se os juros estão altos, se o Waldomiro não foi preso, olhe para seu joelho, bote uma saia bem curta e vá dar uma volta no quarteirão. Coma um sanduíche bem engordativo, beba um refrigerante não-diet, deite num banco de praça, de preferência debaixo de uma árvore, e olhe o céu através das folhas, mais lindo do que a mais linda renda francesa. E respire fundo, muito fundo, pensando em tudo que pode e ainda vai poder fazer durante muito tempo, isto é: qualquer coisa.
Ache graça em tudo, ria de tudo. O dinheiro está curto, o namorado sumiu, a melhor amiga fez uma falseta? E daí? O dinheiro pode pintar, namorado é o que não vai faltar, e a amiga, esqueça. Tome um sorvete de casquinha, pegue aquele biquíni do ano passado -o único que você tem-, vá para uma praia, e, quando mergulhar, tenha a consciência de que não existem diamantes nem rubis que façam alguém mais feliz do que a sensação de mergulhar no mar.
Quando, à noite, for para a cama com sono, pense na felicidade que é botar a cabeça no travesseiro e dormir sem precisar de comprimido para esperar o sono vir; e, quando acordar e se olhar no espelho, pense em outra felicidade, que é não ter que pintar o olho, botar um blush nem fazer uma escova, pois, por menos bonita que se seja, sempre se é linda aos 25 anos. E, se alguma coisa te aborrecer, tire da cabeça e pense: "Sou jovem, e isso ninguém pode tirar de mim".
E viva, e sonhe, e seja feliz, porque um dia a juventude vai passar, e será uma tristeza se você não tiver aproveitado todos os minutos dela, ou os de quando tiver 30, 40, 50, 60, 70, 80 ou 90.
Para que nunca passe pela sua cabeça a pior de todas as coisas: "Eu não aproveitei a minha vida".

Fonte: Folha de S. Paulo, 13/03/2005

Saturday, October 15, 2005

Weekend Movie

0 comments
http://us.imdb.com/title/tt0415978/

Me and You and Everyone We Know

Wednesday, October 12, 2005

Saint-Säens and the Carnival of the Animals

0 comments
This orchestral suite by Camille Saint-Säens is composed of many parts, each for an animal:
  1. Lions
  2. Hens and Cocks
  3. Wild Asses
  4. Tortoises
  5. Elephant
  6. Kangaroos
  7. Aquarium
  8. Persons with Long Ears
  9. Cuckoo
  10. Aviary
  11. Pianists
  12. Fossils
  13. Swan
  14. Finale
Check the animals from items 8 and 11. Very curious. Although I had listened to this suite several times, never paid enough attention to its pieces' names.

Tuesday, October 11, 2005

Struts and Indexed Properties

4 comments
http://www.developer.com/java/ejb/article.php/2233591

http://struts.apache.org/faqs/indexedprops.html

Check those links in case you have an indexed property (like an array or list). It is very useful when you have a table that you want struts to link their properties automatically to the form.

In my case, it is a list (java.util.List) of item beans in the form that is iterated in the JSP, like this:

<logic:iterate id="items" name="orderEditForm" property="items">

<html:text name="items" indexed="true" property="product"/>
<html:text name="items" indexed="true" property="quantity"/>
<html:text name="items" indexed="true" property="amount"'/>

</logic:iterate>

This "items" property is defined in the orderEditForm as a List. Note the "indexed" property of html:text element.

Thursday, October 06, 2005

Using JasperReports Scriptlet

41 comments
In a few steps:
  • Create a class that extends the following class:
    • net.sf.jasperreports.engine.JRDefaultScriptlet.
  • Either:
    • Add this class name (qualified name, actually) in the scriptletClass attribute of jasperReport element of your .jrxml file;
    • Or, in case you are using iReport, declare this class in Project/Project Options menu, Scriptlet tab and "Use this scriptlet class..." option.
  • After that, if you created a new method, call it using the following syntax:
    • "$P{REPORT_SCRIPTLET}.methodName()".
      • In my case, I added to the group header the call to the method "priorityDescription()".
The scriptlet I created uses a field value to return a more complex description, what I am unable to do using only the variable declaration. It is also possible to override many of the methods that JRDefaultScriptlet provides, such as:
  • beforeReportInit()
  • afterReportInit()
  • beforeGroupInit()
  • afterGroupInit()
  • among many others...
Very interesting possibility to extend your report processing.

See an example in this more recent post. Drop me a note if you want to receive these example files and I will send them whenever I have some spare time. Thanks for your interest.

Monday, October 03, 2005

Hibernate: Criteria and Join problems

3 comments
Link 1

Link 2

Two interesting links in case you had the famous "org.hibernate.QueryException: could not resolve property" for a property like "customer.name" or any kind of composed property.

Hibernate: reusing the Criteria object used to count the records

2 comments
criteria.setProjection(null);
criteria.setResultTransformer(Criteria.ROOT_ENTITY);

Then you can reuse the Criteria object. I use it to count all the records, then I reuse it to perform the query, limiting the number of results (setMaxResults) and the start index (setFirstResult).

Sunday, October 02, 2005

Hibernate Criteria API

2 comments
http://www.devx.com/Java/Article/28754

Sometimes we use Hibernate but don't know exactly why it is there, since all the work is done as we were using JDBC directly. Check this article for a very nice feature when you are doing a multi-criteria search in your application.

Note that the Expression class is deprecated. Use the Restrictions instead.