Monthly Archives: May 2007

PERL Programing

PERLBy training, I am a programmer. Its something I enjoy and use to my advantage whenever possible. In this case, I had a repetitious task to perform and so I made a PERL program to solve it. 

This past Monday, while working from home, my DSL went out for several hours. Since I was stuck on site fielding questions from the Support team, I started tinkering with a program I use to copy Nikon NEF files from a flashcard reader. 

Basically, I like to sort my files in directories by camera model and date. That is, if I take a photo with my Nikon D80 on May 20th, 2007, I'd copy them into:

C:StuffStefanNikonD802007-05-20

Sounds simple, but suppose I put two weeks of photos on a 2 GB memory card? Doing it manually is a pain and I'm lazy. So I wrote a PERL program to do it.  

Here's How it works:

  1. Get a directory of the memory card (G:DCIM100ND80)
  2. Load the EXIF info from each file, one at a time
  3. From the file, determine the Camera Model and  Date it was taken.
  4. Get some stats from the EXIF Info.
  5. If the destination directory does not exist, create it (c:StuffStefanNikonD802007-05-20)
  6. Copy the file
  7. Go to the next file.

A colleague asked for a copy, so I niced it up, commented it, added command line parameters and I'm releasing it into the wild.

Prerequisites: PERL, of course and  ExifTool by Phil Harvey. Frankly,  Phil Harvey did all the heavy lifting here. He wrote a great PERL module and I'm only using a little bit of it. The rest is just simple file manipulation.

From a command line:
c:> perl copyNEFJPEG.pl -?
USAGE: copyNEFJPEG.pl
 [–from X:] (e.g. –from i:) Default = i:
 [–to X:somedirectory] (e.g. –to X:somedirectory)
                             Default = d:StuffStefan
 [–writecfg] Write config file to "copyNEFJPEG.cfg".
 [–nothing] Do Nothing, just show me.
 [–usage|help|?] This message.

Example:
c:> perl copyNEFJPEG.pl –from g: –to c:stuffStefan –writecfg –nothing

In this case, it will write a file called  copyNEFJPEG.cfg to the same location as copyNEFJPEG.pl and set the defaults to the command line (Assuming "c:stuffStefan" exists in advance). The "–nothing" parameter  shows what it would do without doing any copying (other then the config file that is) . Next time, you would simply use:

c:> perl copyNEFJPEG.pl

and it will just copy the files (Did I mention I'm lazy??). Once the config is done, you could just set it up as a shortcut. This program won't overwrite anything or delete the source files. It's fairly harmless, but if you use it, do so at your own risk. I've used this on Nikon NEF files and JPEG files. Likely it would work on CANON RAW files, but I don't have any to test. If anyine wants me to test with CANON RAW files, leave me a comment.

You can download it in a zip here

Music I'm listening to right Now:
"The Taste" by Five for Fighting from "The Battle for Everything". Five for Fighting is John Ondrasik.

A Really Rotten Situation…

JPG LogoAn Odd title, but the best way to describe it, IMO.

Fairly recently Derek Powazek and Heather Powazek Champ association with JPG Magazine came to an end (read response here, here , and here).

I'm not going into details about what happened because, among other things, I wasn't there. If I had to take a Really Wild Assed Guess: People made assumptions and/or were really unhappy with one thing or another.

I do think that Paul Cloutier (the CEO, publisher and now editor) really screwed up how he handled the aftermath. When the founder of a company is no longer with said company, at the
least, some announcement needs to be put out. Other than pulling ALL
reference of Derek and maintaining that this is a "New" JPG Magazine (I disagree, I thought it was a growing endeavor),
there was no information other than what Derek and Heather put out. Some of the staff of JPG have expressed their consternation at Derek and Heather going public with what they consider an internal problem. I think that's wrong as JPG Magazine is a community based business. IMO, that means the community are like shareholders that need to know what's going on. 

Paul's
initial lack of any damage control was a big mistake. To make life more entertaining, when he finally did say something, it was, IMO, lacking to say the least.

As of this writing, I don't think I have answers to questions I posed:

  • Did Paul force Derek out? If so, Why??
  • Did Paul invent a new story about how JPG came to be that was all about 8020?
  • Did Paul tell people not to speak of that walk in Buena Vista, Heather, or anything that came before 8020?

I'm not the only one that wants to know. Part of the appeal of JPG Magazine was this it is a startup by two interesting people. I was pleased to see it grow and evolve into a mature company with a great submission system and a great staff of people working there. Knowing that the creator of such an endeavor was forced out without any explanation put forth by Paul leaves a bad taste in my mouth. That's why I deleted my JPG account.

As I said on a flickr discussion, Regardless of whatever happened that led to Derek's departure, JPG was originally Derek's and Heather's creation. I may be naive, but I'm still really hoping for a resolution that include Paul and Derek working it out.

I'm not marginalizing the Staff. As a programmer, I can say the site is a great work, as an amateur photographer, I certainly appreciate the behind the scenes work of all the staff.

I just think they (Paul and Derek both) need to work it out where Derek can have a role in JPG Magazine especially since Derek owns a part of it.

Update: I will say this: I'm very close to re-creating my JPG Magazine account. Rather than deleting them, I've struck out the questions above (IMO, It's part of the record and I think it would be wrong to just delete them). I don't have them directly answered, but I feel they are no longer relevant to the issue. 

Music I'm listening to right Now:
"New Thing" by Fuel from "Sunburn"

Met Samantha Bee Tuesday night

Samantha BeeWhile on a photo walk with Jerry Tuesday night, we ran into The Daily Show's Samantha Bee. She was with her child and I certainly didn't want to harass her so I just said "Excuse me, aren't you Samantha Bee from The Daily Show?"

She said yes and I mentioned I watch that show regularly. She was nice and friendly. 

"The Daily Show" is one of my favorite shows, but I think It's sad state of the News industry that the most intelligent conversations on TV are on "The Daily Show" on Comedy Central. If you have any doubt, See the recent interview of Sen. John McCain or Former Iraq Minister Ali Allawi or Andy Card just to name a few. 

Music I'm listening to right Now:
"The Taste" by Five For Fighting from the "The Battle For Everything"

SELinux and Type Enforcement

FedoraAs some people know, one of the many hats I wear on the job is security. That being the case, I figured I should learn SELinux.

Turns out, Easier said than done. If your doing anything unusual (What are the odds in my case?) you need to make Policies and ensure that the programs are the proper file context with the proper access. Think of a default deny firewall and you'll see the issue. Nothing is allowed unless permission is explicitly given. Fedora comes with a lot of default policies, but for unusual web server CGI scripts, chances are you need to write a policy for it. 

1st problem: I don't have the proper package to create policies and install them. A little research and I find I need "selinux-policy-devel". 


$ yum install selinux-policy-devel

2nd Problem: While I'm familiar with Type Enforcement, I have no idea what rights to give each application. The only way I know of finding out what rights each app needs is to run it, and see what audit errors pop up in the log.

3rd problem: I'm not used to the syntax of the policy files, or the various types and classes that I need to use to grant the exact access I need. 

After a few hours work: I mostly configured ONE application. This is going to be a long project…

Music I'm listening to right Now:
"Midnight Show" by The Killers from the "Hot Fuss"