The Lucid Developer

Wednesday, June 04, 2008

After Dark

These where both taken about 40 minutes after the sun has gone down. I was just out playing around.

What am I doing here??

I recently was on a photo shoot for a friend of mine and came across a perfect shoot, but didn't have a model to stand in it for me. So I grabbed the next best thing. My brother who just happened to be the one that lets us onto this location. Included are the two treatments, the original color and a black and white.


Friday, May 02, 2008

That which is lost is now found.

fo·cus[foh-kuhs] Pronunciation Key -Pronunciation noun, plural
–noun
1. a central point, as of attraction, attention, or activity: The need to prevent a nuclear war became the focus of all diplomatic efforts.
2. Physics. a point at which rays of light, heat, or other radiation, meet after being refracted or reflected.
3. Optics.
    a. the focal point of a lens.
    b. the focal length of a lens.
    c. the clear and sharply defined condition of an image.
    d. the position of a viewed object or the adjustment of an optical device necessary to produce a clear image: in focus; out of focus.



Last weekend I had my inlaws in town. It was a great time and we had lots of wonderful family outings. During there visit my mother-in-law saw a few of my photos and commented on wanting a few of them for Mothers day. So in the spirit of sharing I took her to my computer to show her a few things I didn't have prints of. In that process she saw a picture that I had never really liked or given much thought to. Because so many people have liked it I figured I would share it with you.

That which was lost is now found.

Post processing:
  1. Slight Orton Effect added
  2. Adjusted the lighting and color balance
  3. Added a darkened halo effect to draw the attention to the flower.
Shot information:

    Camera: Canon EOS 10D
    Exposure: 0.05 sec (1/20)
    Aperture: f/4
    Focal Length: 29 mm
    ISO Speed: 400
    Exposure Bias: 0/2 EV

Labels: , , , ,

Thursday, May 01, 2008

Breaking up an Address (Perl)

con·vo·lut·ed Pronunciation Key - Pronunciation[kon-vuh-loo-tid]
–adjective
1.twisted; coiled.
2.complicated; intricately involved: a convoluted way of describing a simple device.


Still working on this API. For some strange reason they require that all address be submitted to them in parts. So for example 164 N Cherry Lane would have to be submitted to them as:
Number: 164
Direction: N
Street: Cherry
Type: Ln

Other then the reasoning behind this boggles my mind, I pressed forward and found a wonderful perl module to accomplish the desired task. See my sample code below.

use Geo::StreetAddress::US;
   my $full_address = "164 N Cherry Ln, 84660";
   my $address_parts = Geo::StreetAddress::US->parse_address($full_address);
   my $xml = ' <address streetno="'.$address->{number}.'" streetDir="'.$address->{prefix}.'" streetName="'.$address->{street}.'" streetType="'.$address->{type}.'" unit="" zip="'$address->{zip}'" yearsAtAddress=""/&rt;'
;

Make sure that you include city/state or Zip. Without it it will return undefined every time.
Thats it kiddies. Good luck and I hope that you never have to build an api for this client.

Labels: , , , , , , ,

Wednesday, April 30, 2008

In Deep Waters with Perl API's

clar·i·ty [klar-i-tee] Pronunciation Key
–noun
1.clearness or lucidity as to perception or understanding; freedom from indistinctness or ambiguity.
2.the state or quality of being clear or transparent to the eye; pellucidity: the clarity of pure water.


For those of you that don't know what an API is. Then please move onto a post about photography, because this will mean nothing to you. But if you do lets jump in with both feet.

Last week I was asked to write an API with another software Client. I don't like to name names so we will keep it on the low down. But there instructions where this:

The general process for making a request of an XYZ system is:
1) Gather information from user
2) Construct an XML data structure for request with REQUEST root element
3) Open HTTP 1.1 connection to XYZ ‘service’ URL
4) Send XML request to XYZ with content type “text/xml”
5) Get XML response from XYZ
6) Close connection

I figured that with perl this was going to be easy. So I create a perl script to do this. I was going to use my good old tools LWP and just submit a STRING over as the content of the lwp::useragent. Here is my code:

my $xml = '
SOME XML HERE
SOME XML HERE
SOME XML HERE
';
my $cgi_url= "http://THE_URL/DIR_OF_SERVICE";

my $ua = LWP::UserAgent->new(keep_alive =>1);
$ua->timeout(10);
$ua->env_proxy;

my $response = $ua->post($cgi_url, Content_Type => 'text/xml', Content=>$xml);
if ($response->is_success) {
$c->log->dumper($response->as_string);
} else {
$c->log->dumper($response->status_line);
}

Every time that I ran this code I would get a 200 code response and NO body back from the other service. So onto trouble shooting the problem. Here are a few things to keep in mind when working on an issue with a third party vendor api:

  1. Always Assume that the problem is in your code and fix that first.
  2. Start with the simplest of things.
  3. Warn, Warn, Warn the crap out of your code.
  4. Don't go changing the core of your code until you know it isn't a problem with the vendor.
  5. Contact the vendor to have them check there end of the code.
  6. When all else fails goto lunch.
  7. After lunch if you still don't know what is wrong then change how your doing it.
I didn't follow any of these rules on this issue. Had I have I would have saved my self two days of programming. So when it was all said and done this is what I ended up doing. I contacted a friend that has also made an api into this same vendor but in PHP. Once I saw his code I noticed that he was opening a socket and submitting the info over. Had he been using Curl to do this I would have know my code was fine. Because useing LWP is pretty much the same as using Curl. So off to using IO::Socket. Here is the new code:

my $xml = '
SOME XML HERE
SOME XML HERE
SOME XML HERE
';
my $len = length($xml);
my $sock = IO::Socket::INET->new(PeerAddr =>'ROOT_DOMAIN_OR_IP',
PeerPort => '80',
Proto => 'tcp'
);
die "Could not create socket: $!\n" unless $sock;

if ($sock){
print $sock "POST PATH_FROM_ROOT HTTP/1.1\r\n ";
print $sock "HOST: ROOT_DOMAIN_OR_IP \r\n";
print $sock "Content-Type: text/xml \r\n";
print $sock "Content-Length: $len \r\n";
print $sock "Connection: close \r\n";
print $sock "\r\n";
print $sock $xml;
my $stuff ;
while (<$sock>){
$stuff .= $_;
}
close $sock;

$c->log->dumper($stuff);

When that was completed two days later, I got a 200 success and no body of the message. WTF. At this point I decided to follow my steps for trouble shooting the issue. So onto the simplest answers first. Maybe they can only get XML that doesn't have new lines. So I added
$xml =~ s/\n//ig;

Submitted the code and low and behold it worked. Got a response from there server.

THE PROBLEM:
There are two sides of this issue, mine and theres. Any good perl guy will have already caught my problem so lets start with theres.

There code will only respond when it received completed post, with a proper close. In other words if I say I am going to be sending a specific content_length then it will only respond if it gets it.

My problem is that when I was sending my $xml it would only send the first line tell it reached the first \n or new line. Had I submitted my xml one line at a time it would have been fine.

So todays lesson is, KISS. Keep it simple stupid. It could save your life.

Labels: , , , , , , , , , ,

Monday, April 28, 2008

Borders or not

I decided to try something a little different on one of my photos. Borders. I don't know if I should or not. But I see more and more people putting them on, on there web photos. So I am going to give it a try. What do you think?

Sunny Blossoms

This was taken off a few trees in the back yard of a neighbors house. I had been looking at them for sometime and just wanted to get out and take a few pics. After words I did a little post processing on it to make it back and white.

Labels: , , , ,

Wednesday, March 19, 2008

Been a while (Mysqldump Replace into vs Insert into)

It has been a while since I have posted. I believe you are going to see more then you have in the past. One reason is that I want to start posting answers to some of my biggest problems I run into here at work with programming. For example today I needed to do a mysqldump to move data from my development environment to my production environment. The problem was I only needed to do an update not a drop and replace. So I did a bunch of research and here is what I found.

If you use the linux command sed you can change all of your insert statements into replace statements like this..

mysqldump -u DATABASE_USER -p DATABASE_NAME |sed -e "s|INSERT INTO|REPLACE INTO|" > OUTPUTFILE.EXT

Labels: , , , , , , ,

Thursday, March 01, 2007

Flickr Explorer, The Quest.

I have recently set out on a quest. That quest was to get one of my photo's on the Flickr Explorer top 500. I have finished Photo one's attempt and will be detailing what I did and where I went wrong. For those that haven't figured it out I didn't make it. Below is my photo I tried to get in.

Sulfer Springs Fall

Labels: , , , , ,