07
Feb
stored in: General and tagged:

A quick shout-out to a great product. Concrete5 is an excellent CMS. With easy theming, and even easier setup, it’s a snap solution for some of the most particular of tastes.

It’s open-source, which I really like, but the ease of getting it setup, and the polished look and feel just make me happy to use it.

Great work guys!

04
Feb
stored in: General and tagged:

At work, we’re developing an application that uses LDAP for authentication. Specifically, we’re using OpenLDAP. We use a VM for development, which allows each developer to have a copy of the ’standard’ environment, to ensure we’re on the same version of libraries, compilers, databases, etc. As part of managing the VMs, we write maintenance scripts to keep everyones VM in line with each other. I wrote a script to install a baseline installation of OpenLDAP. I thought I’d covered my bases with permissions, but upon startup OpenLDAP created a new file which was owned by root, and had 0600 permissions, which meant no one but root could read or write to that file. I had configured OpenLDAP to run as ‘openldap’, so of course, it couldn’t read the file. Unfortunately, the error message is less than helpful:

'0x50 (Other (e.g., implementation specific) error): updating: <my DN, etc etc>'

So, checking to see the file permissions under /var/lib/ldap, I see a file objectClass.bdb owned by root. Changed it to openldap:openldap, and all is well.

Moral of the story: Always check file permissions. Especially after starting up the server.

26
Jan

Recently, I was tasked with creating a single-sign-on solution for phpBB, where the user would login to our application, and when clicking a link to take them to a support forum, they’d already be logged in. phpBB isn’t known for having a great API with which to integrate, but the code works, and the product works. The authentication works on the premise of providing credentials, logging in, which creates a session in the phpBB database. A cookie value is set, which ties the user to the server-side session. When you have the 2 disparate systems, the domains might be different, but on the same top-level domain. This means if we could get the session ID and set a cookie on the next domain level up, we could be logged in.

The implementation is fairly simple, upon login, we use cURL or something similar and generate a POST request, using the username and password. The remote script grabs the session ID and user ID and returns the values to the originating server. We then, set the cookie values.

Now, the interesting bit. phpBB has multiple layers by which it validates the session. Since our remote server is originating the request, we don’t have the same IP as the user. Second, it uses the User-Agent string of the browser to validate the session. Using cURL, we don’t have a browser. Now, with cURL, you can set various settings (User-Agent string, X-Forwarded-For header, etc) – but if you’d rather not depend on that, you can simply un-check those settings in phpBB.

Of course, I’d recommend using the cURL settings, but to get you started and ensure the connectivity is working.

I’m evaluating a DataGrid for use in a project which is using the Zend Framework, and I came across the ZFDataGrid project.  Fantastic work, and the grid works wonderfully.  It enables you to filter your data and export it in various formats (PDF, Doc, Docx, OpenOffice, etc).  The sample on the site works exactly like this.  The only issue is the manual doesn’t exactly explain how to enable the export functionality.  It doesn’t ‘just work’, but it was reasonably easy to find since the code for the sample site is in Google Code.  But, it isn’t in an intuitive place like the manual or on the site itself.  So, to hopefully save someone else some time, I’ll post the code here – it is from the sample SiteController, and not originally written by me.

$export = $this->getRequest ()->getParam ( 'export' );
 
switch ($export)
{
    case 'odt' :
        $grid = "Bvb_Grid_Deploy_Odt";
        break;
    case 'ods' :
        $grid = "Bvb_Grid_Deploy_Ods";
        break;
    case 'xml' :
        $grid = "Bvb_Grid_Deploy_Xml";
        break;
    case 'csv' :
        $grid = "Bvb_Grid_Deploy_Csv";
        break;
    case 'excel' :
        $grid = "Bvb_Grid_Deploy_Excel";
        break;
    case 'word' :
        $grid = "Bvb_Grid_Deploy_Word";
        break;
    case 'wordx' :
        $grid = "Bvb_Grid_Deploy_Wordx";
        break;
    case 'pdf' :
        $grid = "Bvb_Grid_Deploy_Pdf";
        break;
    case 'print' :
        $grid = "Bvb_Grid_Deploy_Print";
        break;
    default :
        $grid = "Bvb_Grid_Deploy_Table";
        break;
}
 
$grid = new $grid (false, 'DataGrid Example', '/tmp', array('download'));
$grid->setDataFromCsv(dirname(__FILE__).'/Detail_Limited.csv');
$grid->imagesUrl = '/images/';
 
$this->view->grid = $grid->deploy();

The code at the end is mine, which basically tells the DataGrid where to render/save the exported file, which is then immediately sent for download. I also am not using the Zend_Db stuff for the data. As a proof-of-concept, I’m using a simple dataset in CSV, which works amazingly well. The filters, sorting, and pagination still work with CSV.

I’m thinking about writing an adapter for Doctrine, such that one could construct a Doctrine query object, pass it into the DataGrid, and everything would work, as it does with the Zend_Db counterparts.

23
Dec

In my previous post, I used a key style that is open to debate and has been for many years amongst DB folks. The idea of every table having a surrogate key, regardless of the purpose of the table. This says, that for any record in the table I have a single column that acts as the primary key. Given a many-to-many relationship, using a surrogate key on the linking table allows me to describe the relationship in terms of objects and how they’re represented. As shown in the below diagram – each user may have many user_role instances, which are tied to a single role instance. This makes the lives of ORMs much easier since you can create objects for the linking table, which has a simple key to reference.

The ORM then has a User, UserRole, and Role object to use in accessing these tables and adding / removing relationships with ease, since it only needs to worry about the single surrogate ‘id’ key on each table.  In the linking table (as a design concern), one should place a Unique Index on the user_id/role_id column combination.

The other option is using a composite candidate key.  I may have the specific terminology wrong, but the idea is that instead of the single surrogate key to identify a unique record in the linking table, you use a design like the diagram below, which combines the columns that are foreign keys to their respective tables to create the primary key.  The combination of the columns creates a unique identifying key.  The difficulty emerges with ORMs attempting to create objects out this design, and attempting to correctly generate the SQL required to make updates / deletes, etc, using each member of the composite key.

Personally speaking, I’m a fan of the surrogate key approach, but I’ve worked with both.  I won’t discuss the performance impacts of either design, since I don’t have nearly the research base to accurately describe it.  But, using simple integer based keys, the difference should be low.

MySQL provides cascading updates / deletes with the relationships, but I tend not to use them, specifically because I want to control just how far these updates and deletes cascade!  But, given a situation where I have a design similar to this:

multi-delete

I would like to be able to remove a single Foo, without having to first remove all the associated data from the other 3 tables.  Or, I know the ID of the Foo I want to remove, so instead of running multiple queries to find the associated rows, lets just knock it out with a single, multi-table delete!

DELETE
  db.zap as z,
  db.baz as bz,
  db.bar as z,
  db.foo as f
FROM
  db.zap as b,
  db.baz as bz,
  db.bar as z,
  db.foo as f
WHERE
  b.baz_id = bz.id AND
  b.zap_id = z.id AND
  bz.foo_id = f.id AND
  z.foo_id = f.id AND
  f.id = ?

This will then remove the rows associated with the single Foo record I’ve referenced, in one fell swoop.

ICD9 data are the diagnosis and procedure codes used by insurance companies to categorize, well, diagnoses and procedures to be determined / performed by medical professionals. Typically, if you visit the doctor for an ailment and file insurance, your provider will list the reason for the visit, any diagnoses, and any procedures performed. This is then sent to the insurance company for processing. They can then use codes to indicate if the procedure is covered, as well as, (for example) determine if the diagnosis was a pre-existing condition. The data is a simple hierarchical structure which is shown in the following diagram.

ERD for storing ICD9 data

ERD for storing ICD9 data

We see that diagnoses can have sub-diagnoses, etc. I used this simple structure, and added a qualifying column of ‘record_type’ to indicate if the code listed was an actual diagnosis, or a section header. Sections of diagnoses are part of the data, and can be used in searching the database. This diagram offers a simple and quick design to handle the data given.

Comments are welcome.

I’ve long neglected this blog, and the power behind it to discuss my feelings toward database design.  Proper database design is the backbone to a solid application.  Failing to correctly normalize tables and enforce business logic with foreign key relationships can cause undue headaches.

What I’ll be doing is going through some simple applications, and start modeling the tables and relationships, and intersperse some commentary where useful.  The discussion depends on interaction, and I’m of the opinion that a ‘good’ database designer can a) defend their design articulately and b) know when to concede a good point.

Database design is becoming organic.  Strict adherence to the normal forms isn’t required any longer.  Let me be clear though, denormalizing a table to make things easier for a developer is not a valid reason to denormalize.

The modeling tool I’ll be using for generating the images is MySQL Workbench.  Workbench is a very powerful tool, from the source of one of the most powerful (and used) databases today.  I cut my teeth on database design with DBDesigner4, whose creator went on to work for MySQL Workbench.

Stay tuned.

16
Sep
stored in: General and tagged: , , , ,

Stef and I recently switched phone providers, and thus, could take advantage of the latest deals. Well, Verizon had a buy one get one free offer on Blackberry phones. Step went with a Curve and I went with a Storm. Not having a physical keyboard takes some getting used to, but the Storm screen actually clicks, which makes it really feel like you’re typing. Compared to the typing I’ve done in the iphone, I really prefer the feedback.

I’m still looking for a calendar sync (online, but not Google) that I can setup on my own server. If anyone has an idea, please leave a comment.

27
Jul

This weekend, I watched (again) one of my childhood favorite movies, WarGames. This is a classic, and a must see for anyone involved in technology. Some of the concepts used, are accurate (war-dialing) while others, a little far-fetched (war-dialing into NORAD). Anyways, in one scene the WOPR  is running a simulation of a USA/Russia attack. One of the computer technicians views his screen and sees the continental US surrounded by 10 – 15 ‘red’ submarines. He turns to his colleague and says “Hope you like vodka…”. 

I then thought to myself, what an interesting state of mind to be in. Growing up, and even today, I would laugh at the idea of another country attacking us, and having any sort of success.  But, I realize there was/is a time in our history (and today) where we have vulnerabilities, and we’re not necessarily the huge powerhouse I grew up thinking we were.  That said, it was interesting to see the characters in the movie, playing technicians in one of the safest places in the world, and they assume the Russians would clean up.

My boss used an analogy today, which struck me as quite accurate for the position we’re currently in.  We’re moving at a fairly rapid pace, quick releases, and plenty of improvements / changes.  Along with this, there is new business, new ideas, and new potential sources of revenue that we’re working on.

Assuming that the speed of the vehicle is constant, and the winding is fairly unknown, how do you best prevent hitting the walls?  This part of the analogy is talking about software quality.  While no one is perfect, reducing the amount of churn on bugs and enhancements allows for time better spent on other things, be it additional bugs, new enhancements, or time to re-design the credit card processing module to be more efficient.

In keeping with the analogy, I tried to think of various methods to implement, which prevent hitting the wall.  The first, posed by my direct superior was to ‘increase the accuracy of the driver’.  This is the ideal solution, all things the same.  But, what other factors contribute?

Part 1 – Size of the car

Reducing the size of the car will generally improve the accuracy of the car.  Now, with this analogy, I’m thinking in terms of relative extremes, and I won’t delve into the nit-picks of which 2-door sport coup is the best for suspension.  So, consider 2 vehicles.  1 – a smaller 4-door sedan, low-profile, but consistent acceleration / braking.  2 – an eighteen wheeler – hauls, but reaction time is limited, and said reactions are greatly exaggerated.

A smaller car here represents a focused small unit of developers.  These developers are typically the medium-high to high performers, able to deliver on quality in terms of fixing an issue, and in terms of overall design and architecture.  They work closely together in a nice cohesive environment, with limited distractions.  This allows for quick reactions to change, more rapid context-switches between projects, and good performance.  But, the amount of total ‘fixing’ they can do is limited (they’re in a sedan, for petes sake!).

A big rig here represents a bigger team, with a wider range of skillsets.  You have the higher performers, but also the medium-lows (no lows here, that’s just not pleasant).  Likewise, the medium-lows can deliver, and the solutions work, but they may not be fully thought out, they may not consider some design flaws in their solution which could impact maintainability down the line, but they _can_ deliver a solution.  This team moves along quickly, making a lot of changes, but with unexpected turns ahead, the reactions and turns cause turmoil and disruption.  But, at the end of the day, there is quite a bit of things being fixed, the worry though is, is it being _really_ fixed?

Is the amount of items being fixed the goal?  Or, can you afford to delay a while, but in the end deliver a more solid product?  Over time, the lines will converge, and the products will more than likely appear similar, and operate fine, but did your reputation suffer along the way?  Are customers willing to wait, if they know the problem will be resolved to their complete satisfaction?  Or, do customers accept a partial solution, and potential headaches, but know that eventually the problem will be fully resolved?

07
Jul
stored in: General and tagged:

In health news – I’m getting my gallbladder removed tomorrow.  It should be interesting, as it will be my first official surgery.  I had my wisdom teeth out (3 of which were impacted) and was put under for it, but I didn’t really consider it a sugery-surgery.

I’m getting it done laparoscopically so the recovery time is actually quite limited.

For anyone with a strong stomach – you can watch a video of how this is done here: http://www.dailymotion.com/video/x1merv_laparoscopic-gall-bladder-removal_shortfilms

I had a HIDA scan which confirmed the diagnosis that my gallbladder was busted.  A normal person has an ejection fraction of about 35% – which means, your gallbladder squeezes out 35% of it’s contents during normal operation.  My ejection fraction was 2% – so, either something is blocking the duct, or my gallbladder is, well, busted.

Either way, the recommended course of action was removal.  Being young and it good health, it’s the best time to do it.

As another aside – the HIDA scan uses a radioactive isotope to trace the gallbladder function.  Injected via IV, it is taken up by the liver and deposited into the gallbladder.  Then, a technician can watch the isotope as it leaves the gallbladder into the digestive tract.  Anyways, the radioactive bit – I took a full day for the scan, since the College World Series was also in town, and I wanted to catch a game.  Well, on my way to a seat, a Omaha Firefighter runs past me with a beeper looking device which was…beeping.  I thought little of it, thinking there must be a medical emergency.  As I found a seat, I noticed the same man, walking the rows with his beeper.  He narrows down to my area, and then I see his colleague with a geiger counter.  At this point, I’m still thinking, no way is this related to me and the HIDA scan.  Well, when the man with the geiger counter sat down behind me, I could read the awkward look on his face.  He then asked in a kind voice, “Hi, have you had any radiation treatment recently?” – I then explained the HIDA scan, etc.  I reassured them that, no, I was not a terrorist, nor was I hiding radioactive materials / weapons.

06
Jul
stored in: General and tagged:

I use VirtualBox fairly regularly for virtual machines of various types (XP under Debian, FreeBSD, etc) on my main desktop. Compared to VMWare I have no complaints. It works flawlessly, and with the latest release things are just polished.

Also, it now supports OpenGL for guest VMs. This is huge for graphics work / gaming, etc. No more dual-booting. With RAM as cheap as ever – there isn’t a reason why VMs don’t fit the bill for servers anymore.

Lastly, but more importantly, VirtualBox is free.  Yes, free.  It’s a quality product, and really meets my expectations for virtualization.

04
Jul
stored in: General and tagged:

Today is the day we remember our freedom and the rights we enjoy as citizens of this great nation.  I’d like to take this opportunity to thank any and all members of the military – as well as anyone who has contributed to the continued fight for freedom.  The rights we enjoy as citizens should never be taken for-granted, nor should they be compromised for any reason.  I won’t turn this into a political post about rights infringement, but, I am grateful for the freedoms I have – and pray they’re never taken away.

Have a safe and happy 4th of July.

03
Jul
How much math Ive used past grade school.

Today’s ‘Friday Fun Post’ maybe be an old one for some of you, but it is something I have continually found amusing.  It is somewhat of a sad truth, but a truth nonetheless for the majority.

Happy Friday!

02
Jul

I have an older laptop, which I brought back out of storage for fun and to keep it updated. It runs Debian Lenny, so it’s a pretty stable machine, and very handy. A recent purchase of a new battery gives me ~2.5 hours of time with it, which isn’t bad for a laptop from Fall 2002.

Anyways, with running Linux, sometimes you’ll run into small glitches which become slight annoyances when you realize how life could be. In the case of our HP Mini – I know suspend to RAM works in the latest kernels, and my older laptop supports ACPI. So, I ventured to solve the suspend to RAM problem. I found that after suspending, upon resume, the laptop would appear alive, but only the backlight would be on. No graphics, no text, nothing. I could SSH into it, and noticed that an XOrg process was eating the CPU. After researching a bit of history on XOrg and nVidia, I found a forum post noting that this particular user had encountered success by turning off nVidia’s AGP handling. Upon testing the following config (/etc/X11/xorg.conf – In the ‘Device’ or ‘Screen’ section)

Option "NvAGP" "0"

I found I could suspend, and resume with ease. What a great community behind these types of things.

I’ve been thinking about obligations to software customers lately.  I don’t have any of my own (yet) but it is something typically on the front of my mind.  At my day job, we maintain various versions of our software, while not directly on the client – in our backend systems.  This means that our backoffice must be able to handle multiple versions (major and minor) for our customers.  Why is this an issue, or something worth writing about?  Because it is such a pain – and customers expect things to ‘just work‘.

This is an especially difficult problem when writing reports, let alone, multi-location reports – where the data is brought in and aggregated from multiple sources into a single report.  The reports become a mess of if/else based on the structure of one location compared to another.

So, this leads into the topic of End-Of-Life for versions.  As stated above, these reports specifically, become large and painful to update.  What is the solution?  In my opinion, it is having sane expiration dates on the software you support.  This has a couple benefits, some direct and some indirect.

Direct:

  • More errors fixed in later versions
  • More features

Indirect:

  • Less maintenance on the backend
  • Quicker feedback on software – if user base is larger.
  • Reduced support costs (ie, helpline) for archaic versions where knowledge experts may be limited.

There are some drawbacks though.  Fear of change is sometimes warranted with business critical applications.  Sometimes, customers are just fine running the current version, and don’t want to change for fear of unknown issues, loss of data, or worse yet, loss of customer data.  Likewise, if this process isn’t started from the beginning, the upgrade processes may not be ironed out, and this causes great heartburn if the process is not seamless for the end-user.

But, back on topic – what is a sane value for end-of-lifeing a software package?  Is it six-months? 18-months?

In my opinion, it largely depends on the rate at which you update your software.  But, largely, 1 major versions back from the current major/minor version is sufficient.  So, if your current release is 5.1 – anything beyond 4.1 should be end-of-lifed.  Your customers should have enough time within the minor releases to react, prepare for any upgrades, and your support staff / developers will appreciate the forward momentum.  This of course assumes a reasonable release cycle.  If you’re releasing more often than a minor version every 3 months or so, increase the number of versions you wait.

What do you think?  Too aggressive?  Not aggressive enough?

01
Jul
stored in: Development and tagged:

With the recent license change at Nokia/Trolltech for Qt – I’ve grown more interested in learning proper GUI development, specifically with C++. I know there are bindings to other languages, but for simplicity of deployment, I think C++ will be easiest to test / depend on, as well as protect in the event that I create something of actual value.

So, outside of the context of Qt, specifically, what are the best practices for organizing C++ projects? I’m used to packages in Java for code organization, do people follow similar suit with C++? In looking at a large project like KDE, it seems that for the bulk of utilities / applications, the code is organized in a single directory, not necessarily split out (as might be the case with a Java project).

Are namespaces worth it? At what size of a project would they add value.

Recently I encountered an issue at work.  I had recently merged some code, and someone who tested from start to finish said there was an error right off the bat.  Crap.

Looking at the error, my blood began to boil:

PHP Fatal error: Column count doesn't match value count at row 1

So, I investigated where this was happening, and found it.  Effectively, when you write an INSERT like this:

INSERT INTO table VALUES ('1', '2', '3');

The DB will automatically match your values up with the columns.  Except, you’ve effectively broken the code because any change to the schema will change the number of columns.  Second, you cannot guarantee the column order on a table, so you just broke any chance of compatibility with another DB back-end.  Especially, in the case of multiple branches of a project being updated, you must be defensive about coding practices against the database.  You cannot assume anything about the mainline of development beyond your branch.

So, a small lesson.  Anytime you’re writing an INSERT, always, always, always, declare the column listing like so:

INSERT INTO table (col_1, col_2, col_3) VALUES ('1', '2', '3');

Now, you see that the DB doesn’t have to think about which columns you’re populating, you told it directly.  This also guards against the change in column order, as well as, the addition of new columns.  Remember, if you’re adding columns that are set to ‘NOT NULL’, be sure to set a sane acceptable default, and you shouldn’t have compatibility issues with your old inserts.

Closing side benefit, I can look at this new INSERT, and know what the columns are.  Given the first, I’d have to go check the DB, and verify the column order, etc.  Always put column names in.  Always.

22
Dec
stored in: General and tagged:

I recently purchased a new HP Mini.  Love the form factor, as does Stef.  It’s great for checking e-mail, web surfing, etc in the living room while watching TV.

First thing I did was drop Windows in favor of Linux.  In this case, Ubuntu.  I found that everything worked flawlessly except I couldn’t SSH out.  After searching around a bit, I found the solution, which I’ll post here in hopes that it saves others some time.

In /etc/network/if-pre-up.d/wireless-tools , add the following line at the end of the file:

/sbin/iwpriv eth1 set_vlanmode 0

And restart networking.  You should now be able to SSH in/out of the HP Mini.