Archive for the 'Software' Category

Hibernate Schema Update Problems

Saturday, July 5th, 2008

I’ve been using Hibernate for relational persistence for a while now, and I have to say it’s been working out pretty well.

That was, until I went to do a SchemaUpdate.

The moment I did an alternation of a table, or created a new entity, things went sour, and I was unable to read my old data. Was it me, or was it Hibernate?

could not initialize a collection
PSQLException: ERROR: permission denied for relation newtablejustadded

It was me.

Turns out Hibernate’s update was working just fine. There was no magic versioning or class hashing going on, detecting the change to the database.

The problem was the ACL was blank for the newly created entity table (I was using Postgres).

By issuing this command, all was fine again:

GRANT INSERT, SELECT, UPDATE, DELETE, REFERENCES ON newtable TO GROUP agroupIwasusing;

Since it took a while to figure out what was going on, I thought I’d post this to help others that follow a similar, yet frustrating, path.

Jaw Dropping Photo Retouching

Saturday, June 28th, 2008

In addition to capturing the perfect image and having the perfect lighting, you also need to know how to do photographic retouching.

While many of these sources revolve around Adobe’s Photoshop, you can also use Corel’s Painter, Gimp, GimpShop, or even Pixelator.
Yes, you know to shoot in RAW mode.

You may even know about Raw Developer, to eek out what your photo editing software can’t.

Huey Pro by PantoneYou might even know about the Pantone Huey Pro, which is the dual-monitor color calibration device.

Forget everything you know or think you know, here are the sources you need for high-end professional photo retouching!

Color Correction


A good photo has to take into account its color space, and it turns out the simple color wheel model is actually fairly simplistic. A color space looks more like a stretched and distorted multi-dimensional field. By deliberately contorting the color space, it’s possible to do everything from white-balance to invoke moods to increasing contrast.

Additionally, your camera has the ability to pick up more detail that you’re able to discern or your monitor can display. By stretching and twisting the color space, you can draw out more details in areas where you need it.


Digital Color Correction


The Complete Guide to
Digital Color Correction

(1-57990-543-9)

Instead of using the Levels control, building a strong command of advanced Curves will do wonders. Curves can be used on different channels. And, with selective masking, it’s possible to create images that are physically impossible for a camera to capture.

Curves effectively do a translation, but instead of linear relationship, the change can be dramatic in some places, less so in others. Think of it like a color spectrum on a rubber band, you can stretch portions of it.

The eye dropper tools in the Curves dialog help identify what should be considered white, what should be considered midtone, and what should be considered black for transformation. It may come as a surprise that it might not be ideal to have a pure black or a pure white.

Mastery of Curves allows you to deal with under exposed, over exposed, and color casted images. With a well exposed picture, it will help make the subject pop. It also affords some very clever use of creative coloring. And let’s not forget controlled desaturation can lead to many splendid images.

Once you learn how to really use Curves, you’ll have no need for Levels.

Photoshop LAB Color


Photoshop LAB Color
(0-321-35678-0)

Certain color-space models play off of different strengths. Color need not be RGB.

Print, for instance, looks great when CMYK is used.

It turns out that for drawing out detail, LAB color space makes a world of difference.

LAB space is magical because it puts the luminance on it’s own channel. The tradeoff is that red/green become opposites on the ‘a’ channel, and blue/yellow become opposites on the ‘b’ channel. This works well, as often it’s the brightness you want to affect without washing out the color. For instance, LAB mode can remove unwanted fog and haze, magically pulling color out of seemingly nowhere.

Additionally, the Unsharp Mask can be applied to just the luminosity channel, pulling out extra details. If there’s noise in an RGB’s blue channel, one can covert to LAB, apply the Dust’n'Scratches filter to the B channel, and convert back. Blurring A and B will hide imperfections.

The A and B channels can be used to accent color. And if an image has an unwanted color cast, moving the curve out of A’s or B’s center point removes it.

LAB also has another amazing use: getting amazing selection masks from the channels.

Color Enhancement


Scott Kelby, a Photoshop guru, has identified that there’s really only seven steps needed to really push an image to the limits. This can make a horrible picture acceptable, and a well exposed image astounding.


Scott Kelby's 7-Point System


Scott Kelby’s 7-Point System
(0-321-50192-6)


  1. Use Open the file in RAW mode, even if it’s a JPEG, and pre-process there.
    Fix the white balance, and then do things like warm it up. Fix the exposure and twiddle the details. Information that’s clipped can be brought back into the color space.

  2. Perform the Curves adjustments.
    Bring out detail.

  3. Adjust the Shadows and Highlights.
    Pull out more detail, and set the mood. Good contrast makes a dramatic photo.

  4. Paint with light.
    Layers, gradients, and layer blending can simulate camera filters. A neutral density, for instance, can bring out the blues in your skies. In a more controlled sense, this is non-destructive dodging and burning.

  5. Channels Adjustments using LAB color space.
    By applying an image to itself with soft light, in LAB mode this produces aesthetic contrasts.

  6. Use Layer Blends and Layer Masks.
    Often the whole image won’t need uniform changes, this step brings all the elements together.

  7. Sharpening with the Unsharp Mask and fading the Luminosity afterward.
    Extra sharpness can be pulled out to provide what looks like a really in focus image. Doing it this way removes color halos that may appear.
You don’t apply every step for every photo, and it’s important to recognize less can be more. The cumulative effect of these steps is what get results. Also worth mentioning, the order is important.

Professional Retouching


Most retouching instructions inadvertently make a model’s skin look like plastic. They focus on the Gaussian Blur filter, screening layers, and use the Clone tool, and the Spot Heal Brush. This might be acceptable for small web images, assuming you want that look.

It’s not what the professional do.

Why not? Those activities destroy information in the image. That means the image looks fake and retouched when viewed up close or when it appears in print.

Retouching Techniques


High End-Industry
Retouching Techniques

Series One

To do things right, you need a solid command of color spaces, the Healing Brush, the History Brush, Dodge/Burn brush, Warp/Liquify tools, and Unsharp Mask. Most changes are made with Adjustment Layers, so the image is actually a composite of small, controlled alterations. This is time consuming and can be tedious if you don’t know the numerous shortcuts of your post-processing application.

To make a clean image, one uses the Healing Brush with sampling from all over the image. Reshaping parts of an image requires the Liquify tool, and to alter the whole image the Warp tool is used. These activities can damage data, which is why after using them cleanup with the History Brush is necessary. The goal is to preserve detail and remove imperfections.

Since the magic of photography is in capturing the light, not the subject, having controlled contrast makes an image stand out from the rest. What makes a good professional photo retoucher isn’t the blemish removal or pushing of pixels, it’s the re-sculpting of the image in 3D.

In this context, I’m not talking about modeling tools like Poser, Blender, Animation:Master, or DAZ:3D. No, I’m talking about the illusion of depth created with shadows and light.

Face Painters are do this to reshape the face, using smooth gradient blending and edges to create fantastic illusions. The dodge and burn tools, along with an decent understanding of human anatomy, will let you get a model closer to that perfect body.

The insight comes when you realize things that are further away are darker, and things that are closer are lighter. By performing slight emphasis on naturally falling light, shadow, and edges, it’s possible to enhance the perceived depth of the photo’s subject. By adding or removing light, it’s possible to alter the shape of the subject in very flattering ways that are not perceptible unless you compare the image to the original.

Total reconstruction is possible when sampling can be used to build the right textures, hue and saturation can set the right colors, and dodging and burning can create the right shadows to convey a shape or edge.

Bringing It All Together


The name of the game is contrast and sharpness, and with the resources above, you’ll be able to produce some jaw dropping images.

Mind you, there’s no magical automated formula. One image can take literally hours, but the results are worth it.


Photo by Walt Stoneburner

Firefox Slow Page Load - Solved

Friday, March 28th, 2008

A co-worker showed me an interesting problem with Firefox today. He loaded a page from our application (running on localhost) and the page content loaded instantly, but the page load itself didn’t end until a time out 20 seconds later. Literally.

Everything we saw a measured from the browser or from the sending application showed that the content was sent in milliseconds, and the page load was just sitting there doing nothing. We were even using the latest Firefox beta.

Other browsers had no such problem.

Turns out, we figured out what was going on using the Tamper Data add-on.

Turns out there was a Connection: keep-alive in the header. When we changed it from keep-alive to close, the browser behaved as expected. That is, it loaded the page instantly.

A little web investigation showed that when you use the keep-alive attribute, you must also use Content-Length: header, which the sending application wasn’t doing.

A quick application tweak to send the content length, and everything ran super spiffy.

Now, if you don’t have access to the application that’s sending you web pages, you can twiddle with the about:config and change the network.http.keep-alive setting to false.

SQLite Functions

Tuesday, March 25th, 2008

Seems silly, but I’ve been using SQLite and was having the darnedest time try to convert an integer into a time. Problem was, I knew the functions for Sqlite3 had to be out there, but all I kept getting from search engines and exploring the developer Wiki were the C/C++ API functions, not the ones needed for SQL. I guess the way the pages are indexed, the source pages score higher than the user manual pages.

Anyhow, located the SQL functions and wanted to document their location for myself so I could locate them again later.

Seems they are called Core Functions.

They hide under the language expression page, which is under the SQL language page.

I was thrilled to find that the SQLite C Interface allowed the creation of your own functions. Brilliant!

Turns out, that the date and time functions were hiding in a different part on the Wiki.

The magic I wanted, given a time stored in an integer, was:
SELECT datetime(timevalue, 'unixepoch', 'localtime');

iChat Problems: Fixed

Saturday, December 15th, 2007

iChat and Parallels
While trying to iChat using Leopard to a system running Tiger, I ran into a problems that I never had using OS X 10.4 before: bad video quality to downright refusing to connect.

With a little research, I ran across this article and that was enough to resolve the problem.

Here’s how to get iChat working on OS X 10.5
…if you’re running Parallels.

See, turns out that Parallels, I’m using 3.0 Build 5582 (Dec 5, 2007), appears to be running some services, even when the virtual machine is active, that gets in the way of iChat.

Get out of iChat.

Go to Apple / System Preferences…, select Network, and click on Parallels NAT and change the Configure drop down to Off; then go to Parallels Host-Guest an change the Configure drop down to Off. Press Apply.

Get back into iChat and try again. For me, it instantly fixed the problem.

Why Managers Hate MS-Project

Sunday, December 9th, 2007
Did you hear the Microsoft was making a new Office bundle available? It is designed for specifically for software development planning, including only PowerPoint, Excel, and Project; it’s called MS-Fiction for Managers.



Almost every manager I’ve known shakes their fist at project management tools. And while pretty Gantt charts, views of progress reports, and tasks lists appear in presentations, most of it is trickery. That is, all the real work is done by hand on paper or in a spreadsheet, and once figured out, is transcribed to a project tool to product the pretty charts.

What gives?

Project isn’t a drawing tool; it’s supposed to give and track useful information, not get in the way.

Isn’t project management software supposed to let you enter in your task list, assign resources, and produce an optimal schedule?

Well, yes. And, frankly, most people can get past that part. The problems kick in after that point.

Leveling Issues

Managers ditch project management tools when they start getting unexpected behaviors.

I’ve identified several problems that crop up frequently. Here’s some things to be aware of to help reign in the gremlins that like to scramble your projects.

Loss of Historical Information


If your project tool moves a completed task to a new point in the timeline, then it’s broken. You’ve found a bug. Completing a task anchors it in time.

Mysterious Chronological Task Reordering


When you list tasks, unless you explicitly state otherwise with a direct dependency, the software is allowed to reorder when a task begins. The software you’re using may have a different take on what makes sense.

I often see this problem happen when a time estimate is replaced with a more discrete breakdown of the task. For instance, deleting a 3 day task and replacing it with three 1 day tasks. Because project tools often assume you plan today and do tomorrow, you can sometimes end up with a hole in the schedule you want backfilled and that’s when the trouble starts.

In some cases, the software may decide to move one task from the end of the task list up to the front to fill in the hole; the justification is that it’s better to move one task than shuffle the whole schedule back. This may, or may not, be what you want.

More realistically, if you find tasks being shuffled out of order, the problem has more to do with when a task starts. Some software will force a task to start at a particular date in order to coerce the schedule; the problem is, if you’re unaware it’s done that, and you change some tasks, it might have imposed a schedule requirement upon you that isn’t real. You need to be diligent about such conditions.

Very intelligent schedulers will recognize the difference between a start constraint that you mandated, versus one that it derived.

Around the trouble spots, make sure that the tasks are set to be scheduled as soon as possible, depending on their assigned resources, and not an arbitrary date.

Never Trust Undo


While undo is supposed to put things back the way they were, it can be tricky to get right. Some operations may affect the properties of the tasks on your schedule. When you undo, it might undo what you’ve done, but keep the changes and constraints that it made.

A mature product will implement undo perfectly, but it never hurts to save a historical copy.

Put another way, just because the tasks return to their original positions after an undo, does not mean that new dependencies and criteria were properly cleared from the task properties.

Too Many User Supplied Dependencies


A dependency should only reflect inter-task dependencies, and that means you should use only the minimum required.

If you are using dependencies to force an ordered sequence to tasks that have no relationship, just to get them done in a certain order, you’re doing it wrong.

If you are using dependencies to coerce the software into producing a schedule ordering you want, you’re doing it wrong.

The problem with these two hack-it-til-it-works approaches is that when the schedule changes and you need to re-level it again, some dependencies are real and others are bogus. The software will account for all of them, and that will cause the scheduling algorithms to make bad decisions.

Any others spring to mind? Please write me.

Five Things I Can’t Do with OS X Mail’s RSS

Friday, November 30th, 2007

I notice with OS X 10.5 (Leopard)’s new Mail integrated RSS reader, once I have a feed there’s a few minor annoying limitations that aren’t available.

OS X Mail RSS1) While I can review what the RSS feed URL is by hovering over it, I can’t copy it to the clipboard.

2) If the RSS feed location changes, I can’t change the feed’s URL.

3) I’d love to be able to drag the RSS icon to a browser and have it open the page.

4) Or, I’d like to be able to right click the feed and have it open it in a browser or my default RSS reader (NetNewsWire).

5) Drag the RSS feed icon, or an article from the feed, into an open Mail message to share the URL.

I hope Apple will enhance the feature capabilities soon.

Reasonable Trial Durations: 30/30/30

Friday, October 19th, 2007

30/30/30While doing Java development, I was looking for a new IDE for Windows. Naturally, my hunt ended with IntelliJ, with Eclipse and NetBeans close on its heels.

What started the whole chain of thought for me, though, was IntelliJ’s trial period. Frankly, I really respect a company that has enough faith in their products that they let you use them, unencumbered, for a month in order to make an informed purchasing decision.

Oddly enough, though, it wasn’t enough. Allow me to explain.

The purpose behind a trial period is to allow end users to “log enough flight time” with the product that they know whether or not it meets their needs.

And here’s the problem. I have an existing code base of inter-related projects that I need to import into the IDE. And, since this is for work, my schedule is fairly swamped. I can only come up for air to do an evaluation once every week or two just for an hour or so.

What inevitably happens is this: I install the software, validate it installs, then a week or so later, I try to import; it fails, so I table the project until I have more time. A week or two goes by, and I try again, getting closer. Then, when I come up for air and try to get a bit further, the evaluation period is over. I’ve realistically had about less than three hours using the software, and none of it in the IDE writing code.

This happened to me last year as well.

And, what’s the natural conclusion at this point? I don’t know if it will meet my needs or not. Thus, a purchase doesn’t happen.

From marketing’s perspective, they think that the following scenario is the norm: a user downloads the project, tries creating a project, slings a bit of code, gets married to the IDE, and is willing to pay to keep the experience. In fact, I’ve done just this, and I really love IntelliJ.

But, no matter how much love I have for the product, if I can’t move our corporate applications into it from an existing source base, I can’t justify the site-wide purchase. End of story.

Oh sure, I could talk with the kind folks at JetBrains and ask for an extension, and I’m sure they’d give me one.

But that isn’t the point.

Being a software provider myself, I see this as a generic problem. What if I want to produce trial software that’s fair. I can’t have my customers not being able to make a well informed decision for running out of time.

Here’s my solution… 30 days, 30 invocations, 30 hours - Whichever Comes Last

Here’s how it works:

  • You’re guaranteed at least a month of physical time.
  • You’re guaranteed at least 30 invocations.
  • You’re guaranteed at least 30 hours.
  • When all three of the above goals are hit, stop the trial.

Implementing this isn’t be hard at all. It’s also quite fair and balanced.

If you are doing real work, making use of the application for 30 days, then you’re going to quickly chew through the 30 invocations and 30 hours.

If you have just haven’t even tried the software enough, you get 30 attempts.

Finally, the 30 hour rule recognizes if you haven’t had time to actually experience the software.

I’d like to see vendors start taking this approach. It’s a good one, too. It would certainly result in more sales.

Vista DeFrag Sucks

Wednesday, September 26th, 2007

Well before Vista was even real, I wrote about the problematic issues, bad practices for customers, and locked in formats that would make Apple Mac a highly attractive option. Pretty much most of the things people said couldn’t or wouldn’t happen have. It’s no wonder that the US Government would rather keep XP than move to Vista, that students on college campuses are reporting terrible problems interfacing with the IT departments and campus infrastructure, and that even Office formats are in dispute.

Even in our own offices, Vista has been one disaster after another, causing us all kinds of heart ache and productivity loss.

We thought the nightmare was over when we found a clever hack to make Vista think our networked HP LaserJet was a local printer (and we’d given up on being able to even use sound). However, we’ve been getting terrible disk performance on a laptop with Vista installed. Turns out the drive is badly fragmented.

Obviously, an XP user would simply run Disk Defrag and let that be that.

Not so with Vista. Sure, it has the program, but it provides no indicator of how much work needs to be done, and no visual interface at all about what’s being done. All you get is a stupid message that says the operation could take minutes to hours to complete.

So, we let Vista run overnight. And performance didn’t improve. At all.

You’ve got to see the conversation over on the Microsoft Developer Network about Vista’s defrager.

It seems that Microsoft expects you to leave your machine running all the time, and at some time like 2am on Wednesday, it will run the defrag automatically for you. Whether you want it to or not. And it will do the same crappy job.

If you’re running an enterprise service, you do not want to take an I/O channel hit “just because.” If you’re an IT administrator, you don’t want to screw with scheduling. If you’re a laptop user, you don’t want to leave your machine running.

Now I know I said I wasn’t going to give Microsoft support anymore. But I occasionally will share tips.

Grab the free version of Auslogic’s Disk Defrag. It will impress you. It’s clean, crisp, visual, astoundingly fast, and most importantly: it solved our fragmentation problems.

Hibernate: Duplicate Mapping and Imports

Tuesday, September 25th, 2007

<GEEK BLOG ENTRY>
I ran into a very frustrating problem this evening, causing me to stay much later than I had intended, and to miss out on some fun socializing event that I was looking forward to. Unfortunately, there was little to no useful information on the Internet as Google was coming up with few and useless results.

I hope this post saves some poor soul from the same fate.

The Problem


I’m using the Hibernate library for persistence with a JBoss EJB using JPA. My code is sprinkled with annotations, my hibernate.cfg.xml file is clean, and I have no *.hbm.xml files. My code compiles. And it runs.

However.

When I try to access something that uses the Hibernate library, I get an odd message about “Duplicate Collection Role Mapping“.

The class in question contained a Set interface and a HashSet implementation for a member.

So, I commented out this container and tried again, hoping to simplify the problem.

This time I was greeted with a “[Mappings] duplicate import” and a “DuplicateMappingException: Duplicate class/entity mapping” set of error messages.

The only related web pages was a handful of archive with people asking similar questions in various online forums.

Almost always these fell into one of three responses:

  1. You’ve got a problem with the mapping element in your hibernate config file.
  2. You’ve got annotations and and class.hbm.xml file doing something wrong.
  3. This is an old bug in JBoss.

None of the symptoms existed in my case.

Here’s How I Solved It


Turns out that Hibernate makes the recommendation that you build a HibernateUtil helper class. Inside it, you’re supposed to make a singleton of the SessionFactory (and in the case of JBoss, you should use JNDI).

A co-worker had refactored the AnnotationConfiguration() to store a single copy, however, the routine that returned it happened to call .configure() on it before returning it each time. An honest mistake, which got integrated silently into my code when I pulled the latest version from version control.

Because .configure() was being called twice, to Hibernate it did look as if I had duplicate mapping directives in my hibernate config file.

Correcting the HibernateUtil method, which handled setting up and returning the AnnotationConfiguration solved the problem.

</GEEK BLOG ENTRY>


Bad Behavior has blocked 1977 access attempts in the last 7 days.