Archive for the ‘work’ Category

GSoC Kick-start

Monday, May 26th, 2008

This summer, as part of the Google Summer of Code, I will be working on a CSS Addin for MonoDevelop. This will include adding support for syntax highlighting, code completition, support for CSS schemas and creating a UI to assist in development. My plan is to
complete the infrastructure first (css parser, schema builder and so on) and then move on to implement the UI.

In order to make the whole process more interested and transparent, I’ll post a post every week detailing what I’m planning to do, and what I have completed. This will also be sent to a Mono mailing list for the Summer of Code.

Achievements:
N/A (yet:-)

Objectives:

  • Create a wiki page (or a google docs document) and prepare a timeline for the project
  • Bootstrap a MonoDevelop Addin
  • Implement the CSS Parser
  • Add syntax highlighting
  • Start investigating possible UI solutions by reviewing existing implementations. Note possible features on the wiki.
  • That’s it for a start!

    Good luck to me and you with your projects!

All done, more coming

Saturday, May 10th, 2008

Well, I’ve finished the exams! Overall I did pretty well, however the final results will need to confirm that. The boring part is over, now it is time for some real work!

I will continue working for the ANA Project, on the Functional Composition Framework, porting a classifier to the framework and evaluating the results.

Of course, I will start working on my Google’s Summer of Code project as well, to create a CSS Editor plugin for MonoDevelop. More of details regarding the project will follow, as soon as I get started :-).

Aw, and I got a brand new Lenovo Thinkpad X300. First impressions: ultra light, solid, very fast and Linux powered!. I’ll dedicate a post for this, because I got a lot to write about.

Accepted in Google’s Summer of Code!

Tuesday, April 22nd, 2008

I’ve applied to Google’s Summer of Code this year for 3 organizations, and I was accepted on the Mono Project. The project is to develop a CSS editor for the MonoDevelop.

Summer of Code runs for 3 months, and the purpose is to develop an open-source program, after it got passed through a selection process. The best thing is that Google pays you for that :-).

It is going to be a very exciting summer (with lots of work :-).

Edit in TextMate (Mac OS X)

Wednesday, April 9th, 2008

TextMate editor is the right-hand for every Mac OS X programmer, designer and power user. Most of the times we require to put the whole folder into a TextMate project for easier editing, or open a log file for a quick look. In order to do this we have to open TextMate and then drag the folder into it, or drag the file, since most of the times weird files are not associated with TextMate (most of the times you don’t want them associated either).

In order to avoid this, and have a speedier way to launch TextMate with the file, I’ve written a simple AppleScript to do the above for me. I’ve packed it into an Application and dragged it into Finder’s menu-bar, so it can be available on all windows.

You can download the application here: EditInTextMate.app.zip.

Save the file anywhere you want (I’ve saved it into /Application/AppleScript), and then drag it on the Finder’s bar. Mine looks like this:

Based on: http://snippets.dzone.com/posts/show/1037

Java RSA Encryption: An example

Thursday, March 20th, 2008

I had to use asymmetric keys in order to finish a university assignment, and to my amazement Sun could not publish any examples of using RSA keys in Java, because they were restricted by one of the stupidest laws in existence: US Cryptographic Export Laws. After playing with the API for a little while, I’ve managed to figure it out, eventually.

So I’m writing this post for those who want a simple example on how the key generation and encryption process works using RSA asymmetric keys.

Just for introduction, RSA is an algorithm for public-key cryptography. It was the first algorithm known to be suitable for signing as well as encryption, and one of the first great advances in public key cryptography. RSA is widely used in electronic commerce protocols, and is believed to be secure given sufficiently long keys and the use of up-to-date implementations. For more information on how RSA works, please take a look at the relevant Wikipedia article.

In order to start using RSA cryptography in Java, you will need to generate a key-pair: a public and a private key. The public key will be used to encrypt the data, and the private key will be used to decrypt the data. Without the private key, the data can not be decrypted, therefore it is suitable in cases where the clients want to send the server a shared-secret key or authentication information, in order to use for a session (kinda like SSL/TLS does). Java, starting version 1.5.0, provides a tool in the API for generating RSA key pairs.

The following code demonstrates how to use KeyPairGenerator to generate an RSA key-pair in Java:

// Get an instance of the RSA key generator
KeyPairGenerator kpg = KeyPairGenerator.getInstance(”RSA”);
// Generate the keys — might take sometime on slow computers
KeyPair myPair = kpg.generateKeyPair();

This will give you a KeyPair object, which holds two keys: a private and a public. In order to make use of these keys, you will need to create a Cipher object, which will be used in combination with SealedObject to encrypt the data that you are going to end over the network. Here’s how you do that:

// Get an instance of the Cipher for RSA encryption/decryption
Cipher c = Cipher.getInstance(”RSA”);
// Initiate the Cipher, telling it that it is going to Encrypt, giving it the public key
c.init(Cipher.ENCRYPT_MODE, myPair.getPublic());

After initializing the Cipher, we’re ready to encrypt the data. Since after encryption the resulting data will not make much sense if you see them “naked”, we have to encapsulate them in another Object. Java provides this, by the SealedObject class. SealedObjects are containers for encrypted objects, which encrypt and decrypt their contents with the help of a Cipher object.

The following example shows how to create and encrypt the contents of a SealedObject:

// Create a secret message
String myMessage = new String(”Secret Message”);
// Encrypt that message using a new SealedObject and the Cipher we created before
SealedObject myEncyptedMessage = new SealedObject( myMessage, c);

The resulting object can be sent over the network without fear, since it is encrypted. The only one who can decrypt and get the data, is the one who holds the private key. Normally, this should be the server. In order to decrypt the message, we’ll need to re-initialize the Cipher object, but this time with a different mode, decrypt, and use the private key instead of the public key.

This is how you do this in Java:

// Get an instance of the Cipher for RSA encryption/decryption
Cipher dec = Cipher.getInstance(”RSA”);
// Initiate the Cipher, telling it that it is going to Decrypt, giving it the private key
dec.init(Cipher.DECRYPT_MODE, myPair.getPrivate());

Now that the Cipher is ready to decrypt, we must tell the SealedObject to decrypt the held data.

// Tell the SealedObject we created before to decrypt the data and return it
String message = (String)test.getObject(myEncyptedMessage);
System.out.println(”foo = “+message);

Beware when using the getObject method, since it returns an instance of an Object (even if it is actually an instance of String), and not an instance of the Class that it was before encryption, so you’ll have to cast it to its prior form.

This is a small introductory example on how to generate RSA keys in Java and use them to encrypt objects. I’ll follow up with a tutorial on how to use asymmetric and symmetric keys in order to have secure network communication in Java.

MySQL DNS lookups

Thursday, December 6th, 2007

We’ve had a problem at work recently — very very slow MySQL performance. And I’ve tried everything, increase that buffer, decrease the other buffer. Nothing. MySQL refused to work optimally.

I had noticed tho, that local connections, that is over UNIX sockets — not TCP/IP, were blazing fast. Then I’ve realized that MySQL was trying to reverse lookup all incoming TCP/IP connections, before allowing any data pass-through.

Just by adding ’skip_name_resolve’ under [mysqld] section in our my.cnf the database became super-fast.

Bear in mind tho — all your users that have hostnames for authentication, won’t work with that line! Only IP-based hosts will work.

Time machine and Network Drives

Saturday, November 10th, 2007

As a reader pointed out, there is an easy way to enable Time Machine on non-supported drives.

The trick is to execute the command: “defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1″ in a terminal.

Before executing:

Before TM

After executing:

After TM

As you can see, you can now select a network drive to use as Time Machine backup. The “alouca” drive is a samba mount, on a Linux box.

If you select a network drive, Time machine creates a sparse image on that drive, mounts it, and it begins to backup there. Quite smart eh?

Mac OS X Leopard: Love and Hate

Friday, November 9th, 2007

Recently Apple released their new Mac OS X version 10.5, Leopard. Of course, as a geek, I rushed to install it. My feelings are mixed with love and hate.

After running the OS for 2 weeks or so, I’ve compiled to love n’ hate lists.

I love:

  • The new finder, absolutely marvelous
  • Time machine, truly remarkable
  • The new Safari is blazing fast
  • On my Mac Mini (Core 2 Duo) it feels snappier. Same speed on my MacBook Pro tho (Core Duo)
  • Spaces and Dock Stacks!
  • The new System Preferences has improved a lot

I hate:

  • Safari keeps crashing on some websites
  • Pubsubagent keeps crashing
  • Time machine doesn’t support network drives
  • The new dock look isn’t that nice

Conclusion: Leopard delivers a bunch of improvements and handful of new features. I believe its worth upgrading to Leopard, tho not a must. Although, no matter how shiny a new release is, always wait for the first point (10.5.1) release to replace your primary OS.

OpenBSD and WRAP Board

Tuesday, November 6th, 2007

As a router, I had a modified Linksys WRT54GL running DD-WRT as a wireless router, and I also run an OpenVPN session on that. As you understand that router couldn’t handle that much.

I had a WRAP board doing nothing, so I thought it would be nice if I used that, since it has a 233MHz x86-class CPU and 128MB RAM. Enough to handle a lot.

I tried several firewall distributions for that platform, but I couldn’t get them to do what I wanted, so the solution was to install a vanilla distribution of an OS and customize it as I wanted.

The operating system of choice in such cases is usually OpenBSD. The only problem was how to get it installed on such a board, since no CD Drive or monitor was available. The only way to do it was using net boot and serial console.

By default, OpenBSD does not start the serial console for installation, but thankfully this guy has some images with the Serial Console enabled. The next problem was how to net boot. The WRAP board supports PXE, but then again you will need to configure your DHCP and setup a TFTP server in order to do this, adding more complications.

So, I tried writing the floppy installation image directly to my microdrive and booting the drive. Since OpenBSD was creating a ram drive to store the installation, it should be no problem to overwrite the drive with the installation.

The WRAP board booted happily from the microdrive and the installation of OpenBSD 4.1 was completed without any problems on the board. All of the hardware was completely supported, and the device was ready to route traffic within minutes thanks to the powerful pf. The board also serves as a DHCP and DNS server. I will post a follow-up post regarding the services.

Overall, this is a nice setup for a firewall. With OpenBSD 4.2 and the promised upgrades, you may archive up to 50Mbit/sec throughput on such a board, which you need several thousand pounds to do that with a commercial firewall.

The path to 1.1.1 - iPhone upgrade

Friday, October 12th, 2007

After waiting (patiently) for a Jailbreak for 1.1.1 to be released I have upgraded successfully my iPhone to 1.1.1.

iPhone-1.1.1

While the jailbreak and re-activation is a tricky process, if you follow the jailbreak guide you should be fine.

One thing to notice is that my iPhone was unlocked using iPhone Sim Free, after having a little adventure with the unlocks. So iPSF claims
that their unlock survive the upgrade is true, and you’re safe if you have unlocked using their solution.

So, whats new in 1.1.1? Here’s a small list of what I observed:

  • Some apps don’t work, such as Customize and Summerboard. While this is expectable, we’ll have to wait until the new version
  • Nice home button and space double-click tricks. Nothing exciting tho.
  • Phone functions (e.g.: Sending an SMS) appear a bit faster.

Verdict: If you are not waiting for something specific to be fixed, don’t bother upgrading now to 1.1.1, since the jailbreak is a lengthy and tricky process with no much to gain.

UPDATE 13/10/2007: A new (alpha) version of Summerboard for iPhone/iPod Touch 1.1.1 has just released!