Replacing and Patching Java Application and Core classes

February 15th, 2010 by Alexandru Luchian No comments »

Why would you ever need that?

Say you get a jar file. After using the jar for a while you realise that there is a bug in a class in the jar file. Unfortunately you also find out that the jar is no longer supported and there is no way you will get a fix from the author (who is long gone fishing).

In order to solve this issue, you first need to get the source of the class. If you are lucky enough and the author did not obfuscate the class file you can decompile it with a decompiler (my favourite one is JD-GUI).

» Read more: Replacing and Patching Java Application and Core classes

IP Addresses in PHP/MySQL

February 12th, 2010 by Mark Ciecior No comments »

I’ve been working on a web-based tool that stores, among other network-related things, IP addresses. When I first started I stored each IP address as four TINYINTS (0-255 for each octet):

mysql> DESC ipaddresses;
+----------+---------------------+------+-----+---------+----------------+
| FIELD    | Type                | NULL | KEY | DEFAULT | Extra          |
+----------+---------------------+------+-----+---------+----------------+
| id       | int(10) UNSIGNED    | NO   | PRI | NULL    | AUTO_INCREMENT | 
| A        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
| B        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
| C        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
| D        | tinyint(3) UNSIGNED | NO   |     | NULL    |                | 
+----------+---------------------+------+-----+---------+----------------+
5 rows IN SET (0.00 sec)
 
mysql> SELECT * FROM ipaddresses WHERE id=1
+----+----+----+----+-----+
| id | A  | B  | C  | D   |
+----+----+----+----+-----+
|  1 | 10 | 20 | 30 | 131 |
+----+----+----+----+-----+
1 row IN SET (0.02 sec)

As I started manipulating these addresses I found it awkward to do common binary math (like bitwise ANDs). I decided instead to store these 32-bit values as unsigned integers (of length 32). To make my life easier yet, MySQL and PHP both have native functions to convert IP addresses between my old and new formats to make this migration extremely easy.
» Read more: IP Addresses in PHP/MySQL

Taking Advantage of Spring MVC’s Default Behavior

February 11th, 2010 by Travis Klotz 1 comment »

Over the last several months I have worked on several content heavy websites for one of our clients. When I say “content heavy”, I mean that 80%-90% of the pages in the application are static, or at least mostly static, a customer name, membership number, etc may need to be floated in, but not big data tables with dynamic data being pulled from the database. The marketing department manages this content with their content management system and publish fully formed HTML pages (layout, look and feel, etc is controlled in the CMS) which are then pulled into our /WEB-INF/jsp/content directory by our build process.

Our applications treat these HTML pages as JSPs (simple rename in the build script). This lets the marketing team work from a cheat sheet of EL expressions such as ${customerName} and keeps the IT department out of the day to day content management work. One of our goals with these systems was to easily and seamlessly deal with both static pages and very dynamic pages requiring custom controllers to be built. With just a little bit of work Spring MVC makes it easy to provide this functionality and also provides a sane set of defaults for building out these web sites one page at a time.
» Read more: Taking Advantage of Spring MVC’s Default Behavior

A Modern Parable

February 10th, 2010 by Roger Vincent 2 comments »

I recently ran across the following article on a blog:

A Japanese company (Toyota) and an American company (General Motors) decided to have a canoe race on the Missouri River. Both teams practiced long and hard to reach their peak performance before the race. On the big day, the Japanese won by a mile.
» Read more: A Modern Parable

Sonar – Code Quality Analysis Tool

February 9th, 2010 by Sanjay Shrestha No comments »

What is Sonar?

Sonar is a web based code quality analysis tool for Maven based Java projects. It covers a wide area of code quality check points which include: Architecture & Design, Complexity, Duplications, Coding Rules, Potential Bugs, Unit Test etc. Sonar has a rich set of features like what you would get with different tools such as Covertura, PMD, FindBugs, Check Styles combined.

http://sonar.codehaus.org/

Setting up Sonar

Magento Customization

February 8th, 2010 by Derek Arends 3 comments »

Magento is an e-commerce framework that is used as an online shopping cart. I am going to talk a little bit about Magento extensions and why they are useful when wanting to customize your shopping cart. Magento extensions allow you to change functionality of the shopping cart while modifying little to none of the source code.  Since you do not have to touch the source code it gives you the ability to upgrade to newer versions and not lose the custom code.  Another advantage of these extensions comes from Magento allowing you to run multiple websites from the same code base.  Now that you are using the same source code for multiple websites these extensions allow you to have certain features for one website and different features of another website by simply having the extensions in your website’s directory.  A good tutorial for creating an extension is provided by Magento.

Automating the Web with WWW::Mechanize

January 25th, 2010 by Joel Leyh No comments »

And yes, the double colon does mean Perl. However, I know that Python also has the same class modeled after the Perl module. So even if py- is your favorite prefix, this should still be useful.

WWW::Mechanize gives you basic access to a “web browser” from your Perl scripts. It has the concept of getting, putting, ticking and clicking. Use an image map, or enter text into a text box. It even has a back button! Using all these and more, one can make quite the script to do most anything. I’ve used this before to create a script that logged into a Google Search Appliance and download a backup file. (Since for some reason, there is no way to push backups from within a GSA)

More recently, I decided to automate the downloading of PDF statements from my bank’s website. This is a popular use for WWW::Mechanize, and I’ll go through a quick script which will do just this.
» Read more: Automating the Web with WWW::Mechanize

Creating Services using SMF in OpenSolaris

January 22nd, 2010 by Paris Holley No comments »

OpenSolaris has by far, one of the best service management interfaces that I have used. Below I am going to go over a simple way to turn in shell script into a service managed by the OS.
» Read more: Creating Services using SMF in OpenSolaris

Blue Monday

January 20th, 2010 by Mandy Smith No comments »

January 25th is an important day… it’s not a holiday, it’s not a paid day off… it is…

WinterBluesThe

L        o        n        g        e        s        t

and

most depressing

day of the year

» Read more: Blue Monday

Hibernate Embeddable Objects

January 18th, 2010 by Max Kuipers No comments »

Hibernate Embeddable Objects are a really neat way to organize your data model.  Especially, if you have the same few columns in a number of different tables, that all pertain to the same thing. The example commonly used is Addresses.  You may have a number of tables that each have fields pertaining to address information and you don’t want to have to do all the mappings for each entity again and again.  If the column names are the same across each table, you can just add an @Embeddable annotation.
» Read more: Hibernate Embeddable Objects