Archive for March, 2008

Bishma FTW

Teh Winner

I beat Amazon!

Okay… not so much beat as figured out, and not so much Amazon as my own scripting. A mentioned in my last post I was having issues with corrupted images ongetting stored on S3 during my migration process. I determined that errors were being introduced during the transfers between our old image server via ftp AND during the REST upload to AWS.

I implemented the MD5 check I mentioned in my last post and added a step to the S3 upload. After transferring the file to S3 I perform a HEAD request on the object which sends my back a header containing, among other things, content-type and content length. I can then make sure that the content-length matches the size of the image I downloaded and that the content type is some type of image (useful since all errors are delivered as application/xml).

Little by little I’m developing a rock solid PHP class for S3 file handling.

Thanks to Lumaxart for the image


By Bishma in Code Talk, Work  .::. Read Comment (1)

Amazon Fail

floppy fail

 

I’ve been having S3/EC2 problems over the last couple of days. I was migrating photos for an MLS in Washington and after 2 days of moving images in the background I found that a third of them were errored in some fashion. What’s worse is that I haven’t been able to track down the issue yet. S3 gives an AccessDenied error despite my script setting the access control at public-read… I hope.

My S3 class isn’t fully formed yet. And the holes are now staring back at me from the ether. The biggest issue is that I can’t currently read or edit the ACL for any object already on S3. The AccessDenied error make me think that my script improperly set the control level to start during upload. There also the possibility that errors were introduced into the image while it was being moved from the old image server and that S3 is erroring because the headers and content-type say it’s a jpg, but it’s actually gibberish.

In the mean time migration is halted because I can’t risk losing images. When I resume migration I’ll put a simple hash checker in place. On the old image server I’ll have a script that will accept a file name from _GET and run an MD5 on the request file file like so:
$file = $_GET['file'];
echo md5_file('my/base/path/'.$file);

Then I can read that output via curl and compare it to the MD5 of the file I just got via FTP. Images are our bread and butter. I have to be sure that I have an error free system before I continue.

Image from the Fail Blog


By Bishma in Code Talk, Work  .::. (Add your comment)

New look

It’s looking a little different over here at web 4.0 beta. I upgraded to the latest version of wordpress this morning and I decided to change the theme. The old one was custom build by me and never really got finished, so rather than bring it over to the new install I let it fade into the ether. This is a clean and simple theme that will be easy to customize when I’m slightly better equipped and motivated.



Photoshop CS2 on Ubuntu 7.10 Gutsy

I had a little time to kill this morning while waiting for scripts to execute so I decided to undertake what I thought would be an arduous task of getting Photoshop CS2 running on my work machine’s install of Ubuntu 7.10. Turns out that with the latest version of wine it’s no problem at all. What got me thinking about this was the recent news that Google had funded some wine improvements for the specific purpose of getting Photoshop to run in Linux. All the instructions I’m about to lay out are available on the WineHQ site, but I’ve consolidated them here for ease.

First I recommend that you uninstall any existing installations of wine you might have. This may be problematic if you have existing applications running through wine, but I was working on a clean system. Once you’re wine free install the latest version of wine by adding the their repositories thusly:
wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
sudo wget http://wine.budgetdedicated.com/apt/sources.list.d/gutsy.list -O /etc/apt/sources.list.d/winehq.list
sudo apt-get update
sudo apt-get install wine

As of the time of this writing that will install wine version 0.9.57

Next you’ll need to make sure that the times32 font is installed in wine for Photoshop to be able to run properly:
wget http://heanet.dl.sourceforge.net/sourceforge/corefonts/times32.exe
wine times32.exe

Now you’ll need your Photoshop CS2 CD. Locate the Setup.exe file on the CD and run it using:
wine Setup.exe

That’s it. Once setup has run through you should have a working copy of CS on your system. You can now run photoshop using the command:
wine ~/.wine/drive_c/Program\ Files/Adobe/Adobe\ Photoshop\ CS2/Photoshop.exe

In order for the clone tool to work properly you’ll need to set the Movement Key in Ubuntu to “Super” aka the windows key. To do this open the systems window preferences by going to System->Preferences->Window

You also may want to increase Photoshops UI font size by going to (in CS2) Edit->Preferences->General, and change UI Font Size from Small to Medium.

When I first attempted to use Linux as a desktop operating system back in `96 or early `97  I remember it being a giant hassle to even get X-Windows to recognize my serial mouse. Flash forward a few years and everything is getting so easy that I almost miss the old days. At least back then you had to be a proper geek to run MS-Free.


By Bishma in OS, Work  .::. Read Comments (2)

Every 5th Day Ago

Dates Bad

It took me the better part of 45 minutes for figure this out so I thought I’d share in the hopes of saving someone else the hassle. I was confronted with the problem of getting all records from a mysql table that were added today or any multiple of 5 days the the past (March 6th, March 1st, February 25th, etc.). This is what I finally came up with.

SELECT * FROM myTable WHERE MOD(DATEDIFF(CURDATE,`dateAdded`),5) = 0 ORDER BY dateAdded DESC;

DATEDIFF gets the number of days that have happened between todays date (CURDATE) and the date field in my table (`dateAdded`). The number is then modulused (not a word) by 5 to see if it is some multiple of 5. Hooray for man pages.

Thanks to dier madrid for the photo up top.


By Bishma in Geek Life  .::. Read Comment (1)


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.