January 13th, 2012
Quants: the alchemists of Wall Street
Very interesting and also possible kind of eye-opener.
August 25th, 2011
Java generic surprise
This behavior of Java generics surprised me pretty a lot: if you call method which gets untyped list as a parameter and supply typed list, the expected datatype check is not performed inside unchecked method:
1: import java.util.ArrayList;
2: import java.util.List;
3:
4: public class GenericsTest {
5:
6: public static void main(String[] args) {
7: GenericsTest gt = new GenericsTest();
8: gt.test();
9: }
10:
11: public void test() {
12: List<Integer> li = new ArrayList<Integer>();
13: li.add(12);
14: li.add(15);
15: Inserter ii = new Inserter();
16: ii.insert(li);
17:
18: for (Integer i : li) {
19: System.out.println(i.intValue());
20: }
21:
22: }
23:
24: public class Inserter {
25:
26: public void insert(List a) {
27: a.add("test");
28: }
29: }
30:
31: }
This code compiles just fine but the error appears in the runtime. But not during add of "test" inside the list. The exception occurs when trying to write down the contents of the list.
January 9th, 2011
writing xml file groovy way
I am currently trying to get into Groovy and Grails a little bit so I am going through Grails in Action book (btw, excellent one) and found this interesting example:
1: import groovy.xml.MarkupBuilder
2: import groovy.util.XmlSlurper
3:
4: def file = new File("list.xml")
5: def objs = [
6: [quantity: 10, name: "Orange", type: "Fruit"],
7: [quantity: 6, name: "Apple", type: "Fruit"],
8: [quantity: 2, name: "Chair", type: "Furniture"]
9: ]
10:
11: def b = new MarkupBuilder(new FileWriter(file))
12:
13: b.root {
14: objs.each { o ->
15: item(qty: o.quantity){
16: name(o.name)
17: type(o.type)
18: }
19: }
20: }
21:
22: def xml = new XmlSlurper().parse(file)
23: assert xml.item.size() == 3
24: assert xml.item[0].name == "Orange"
25: assert xml.item[0].@qty == "10"
26: println "Fruits: ${xml.item.findAll{it.type=='Fruit'}*.name}"
27: println "Total: ${xml.item.@qty.list().sum{it.toInteger()}}"
It is cool how much work can be done within just a couple of commands.
Lines 1-20 create complete xml file out of object structure and the rest of code does existing xml file processing. It is cool that you can go through the object structure of xml file without any explicit casting or creating object according to the content of xml file.
Summed up: Groovy eases xml processing tasks which are quite complicated (or at least not so straightforward) in Java and does it with elegance.
December 17th, 2010
JAXB2 empty object hierarchy serialization
You might face the issue that you would like to marshall java objects into xml and need to force jaxb2 to create elements even for classes that are not filled in (are null actually). Example might be Person class with empty Address field.
The solution can be found on stackoverflow. I am really happy for the help of Blaise Doughan.
December 11th, 2010
Interesting java generics feature
If you make generic java class and add static field into it, the field remains common for all instances no matter which target type they implement.
October 20th, 2010
Picasa upload–BSOD
Na notebooku Dell Latitude D505 se mi stala zvláštní věc: během uploadu fotek na picasa server z programu Picasa se najednou zjevila modrá obrazovka a systém se restartoval. Na obrazovce bylo něco na způsob čtení z paměti v bloku nula..
Trochu jsem pohledal a našel řešení – bylo potřeba aktualizovat ovladač k wifi kartě PRO/Wireless 2200BG. Potom všechny problémy zmizely a upload začal zase normálně fungovat.
April 14th, 2010
Co ted
Vsechny moje aktivity se ted toci okolo diplomky, skoly celkove a mx3 Holice. Proto tady ted neni moc mouder, ale neco snad zas pridam.
March 9th, 2009
Odkazy pro wordpress
http://digg.com/software/17_Useful_Wordpress_Plugins_That_Probably_Are_Essential
http://www.staska.net/2007/03/27/top-30-wordpress-plugins-in-blogosphere/
http://theblogjoint.com/2006/08/29/top-wordpress-plugins/
http://digg.com/search?section=all&s=wordpress
http://www.smashingmagazine.com/2009/01/15/45-new-jquery-techniques-for-a-good-user-experience/
http://www.smashingmagazine.com/2008/09/15/wordpress-developers-toolbox/