Saturday, February 28, 2009

Confessions of an Irish Gamer

I just want to recommend to those of you who like videogames, to visit the blog homonym with this entry:

Confessions of an Irish Gamer

The authors are not really prolific, but the posts are quality ones.

Enjoy.

Sunday, February 22, 2009

WIFI WPA Encryption with Ubuntu 6.10

Connecting to a WIFI network that uses WEP encription is a pretty straight forward task using UBUNTU, you only have to use the "Wireless Assistant" tool integrated with the system. However, when you try to connect to a network using WPA encryption things get more complicated. For some reason the "Wireless Assistant" do not let you select a other encryption than WEP.

After some research, i.e. google search, I found an entry in ubuntuforums.org that explain how to connect to WIFI networks that use WPA encryption. This process involves mainly editing text files, there is no "Windowzed" application to help:

http://ubuntuforums.org/showthread.php?t=202834

In my case I'm using a network with DHCP activated, and my computer runs a KUBUNTU 6.10. My laptop is an old Toshiba Satellite M70-165 with an integrated WIFI adapter. My /etc/network/interfaces looks like this:

auto lo
iface lo inet loopback

auto eth1
iface eth1 inet dhcp
wpa-driver wext
wpa-ssid $your essid here$
wpa-ap-scan 1
wpa-proto WPA
wpa-pairwise TKIP
wpa-group TKIP
wpa-key-mgmt WPA-PSK
wpa-psk $your hex key code here$


Just follow the procedure explain in the forum, it's easy and it worked for me with at the first attempt.

Sunday, February 08, 2009

XSLT with Java and Dom4j-1.6

Feeling geeky again!!

Today I´ll show you how to perform an XSLT (XSL transformation) on an XML file using Java and Dom4j. In contrast with the last Java/Dom4j post in this i´ll only show the class that acually performs the transformation. Dom4j is not able to perform the transformation on its own, it needs the help of JAXP:



1 package com.julio.xml;
2
3 import java.io.File;

4 import java.io.FileWriter;
5 import java.io.IOException; // dom4j import
6 import org.dom4j.Document;
7 import org.dom4j.DocumentException;

8 import org.dom4j.io.SAXReader;
9 import org.xml.sax.ErrorHandler;
10 import org.xml.sax.SAXException;
11 import org.xml.sax.SAXParseException;

12
13 import javax.xml.transform.Transformer;
14 import javax.xml.transform.TransformerConfigurationException;
15 import javax.xml.transform.TransformerException;
16 import javax.xml.transform.TransformerFactory;

17 import javax.xml.transform.stream.StreamSource;
18
19 import org.dom4j.io.DocumentResult;
20 import org.dom4j.io.DocumentSource;
21 import org.dom4j.io.DocumentSource;

22 import org.dom4j.io.XMLWriter;
23 import org.dom4j.io.OutputFormat;
24
25 public class XmlTransformer {

26 // The input XML file
27 private File input;
28 // The DOM document for the imput file

29 private Document inputDoc;
30 // Guess what!!!!
31 private File output;

32 // The xslt file
33 private File transformation;
34
35 public XmlTransformer(File input, File transformation) {

36 this.input = input;
37 this.transformation = transformation;

38 }
39
40 public File transform() throws IOException {

41 // Need to create a factory using JAXP
42 TransformerFactory factory = TransformerFactory.newInstance();

43 try {
44 // Now get a transformer using the facory
45 Transformer transformer = factory.newTransformer(new StreamSource(

46 transformation));
47 // Convert the input file into a DOM document
48 this.createDoc();

49 // Dom4j support for trasnformations
50 DocumentSource source = new DocumentSource(this.inputDoc);

51 DocumentResult result = new DocumentResult();
52 try {

53 // OK lets do the actual transformation
54 transformer.transform(source, result);
55 // The rest is boiler plate code!!!

56 Document outputDoc = result.getDocument();
57 OutputFormat format = OutputFormat.createPrettyPrint();

58 output = new File("output.xml");
59 XMLWriter writer = new XMLWriter(new FileWriter(output), format);

60 writer.write(outputDoc);
61 writer.close();

62 } catch (TransformerException e) {
63 // TODO Auto-generated catch block

64 e.printStackTrace();
65 }
66 } catch (TransformerConfigurationException e) {

67 // TODO Auto-generated catch block
68 e.printStackTrace();
69 }

70 return output;
71 }
72
73 private void createDoc() {

74 SAXReader reader = new SAXReader(false);
75 try {

76 this.inputDoc = reader.read(this.input);

77 } catch (DocumentException e) {
78 // TODO Auto-generated catch block

79 e.printStackTrace();
80 }
81 }

82 }




syntax highlighted by Code2HTML, v. 0.9.1

Labels: , , ,

Monday, February 02, 2009

New songs

I´ve published a new recording in my Myspace:

http://www.myspace.com/sinnoticiasdedios


Enjoy!!!!

Labels: