Archive for category Software
Writing a daemon in linux
Needed some online tutorial writing a daemon process. The links below helped.
Using color blend mode in Photoshop
Posted by therider in Photography, Software on March 13, 2010
Over the years, I have been processing thousands of images in photoshop, but the various layer blending modes don’t get used much. Except for overlay and soft light for when I do high pass output sharpening.
Very recently, I came across a specific requirement. A favorite photo had abrupt vignetting and the color of the sky in the upper corners were different in hue from the rest. I would normally use the clone stamp tool with low opacity, but I had one problem, there were some power lines that went right through the corner. Then I tried using clone stamping in a new transparent layer with blending mode set to color instead of normal. That gave me exactly what I needed, the color mismatch was fixed without doing anything funky with the power lines. The photos below illustrate this technique.
Speeding up Pixelpost blog browsing
Pixelpost is a very popular framework for photoblogs due to its simplicity and ease of tweaking. A while back I posted an article on how to enable keyboard navigation on a pixelpost photoblog. It works very well considering it allows mouse free browsing. But the browsing experience can be improved even more.
Lets consider how a photoblog is browsed most of the time. A visitor typically lands on a home page showing the latest image and goes through the previous images sequentially, spending a few seconds on each image. Leveraging this fact, if the “previous” image is downloaded in the background using javascript right after the current image, it will be almost if not completely ready for viewing when the visitor is on the “previous” image page. The same can be done for the “next” image, but in most of the cases that image will already be in the browser cache.
This is a very simple change for a tangible usability benefit. Below are my tweaks:
index.php:
// expose the previous image name through tags, so previous images can be
// pre-downloaded in the background for faster browsing experience
$tpl = ereg_replace("<IMAGE_PREVIOUS_NAME>",$image_previous_name,$tpl);
templates/theworldin35mm/image_template.html:
window.onload = function() {
...
var prevImg = new Image(); // for downloading prev image in background
img.onload = function(evt) {
...
// after current image load, load previous image in the background
if('<IMAGE_PREVIOUS_NAME>' != '') {
prevImg.src = '<SITE_URL>images/<IMAGE_PREVIOUS_NAME>';
}
}
...
};
To verify that this extra javascript is actually doing its job, look at the Net section in Firebug (in Firefox browser, ofcourse). Clear the cache first. On first page load it will show several items getting downloaded. On left arrow, the previous image page will load, and then you can see that an extra image got downloaded at the bottom. Compare with and without my code. Here is a screenshot:
MAMP 403 issue and fix
Posted by therider in Software, Technology on February 20, 2010
I have been using MAMP for a while. For no apparent reason today, I got a 403 message for the start page (http://localhost:8888/MAMP/):
Forbidden
You don’t have permission to access /MAMP/ on this server.
Apache/2.0.59 (Unix) PHP/5.2.6 DAV/2 Server at localhost Port 8888
Figured out the solution by a little search but it is useful enough to share.
1. Quit MAMP or stop servers.
2. Open /Applications/MAMP/conf/apache/httpd.conf file in vim or any text editor.
3. Find this section of code:
<Directory /> Options Indexes FollowSymLinks AllowOverride All </Directory>
4. Change “AllowOverride All” to “AllowOverride None”.
5. Save the httpd.conf file.
6. Launch MAMP or start servers, then open up the start page.
It works !
Linkgen – A webdev tool
During web development and debugging, developers often need to compare the locally modified version with what is in production. Most of the time this involves copy and paste to make the urls for dev and production in two side-by-side tabs on a browser. This is not only tedious, but poses serious ergonomic injury risk as well.
I figured that a bare bones html with a few bits of javascript can go a long way towards making a custom tool just for this task. So if you got a set of paths (e.g. /blog?p=23 or /blog/2009/05/12/hello-world) just put them in the tool alongwith two hostnames, and you will instantly get urls in pairs to be opened on sequential tabs.
The tool is now hosted here: http://joydutta.com/projects/linkgen/
Feedbacks are most welcome. I can add more features on request if they prove to be absolutely essential.
Wordpress blog development tip
Posted by therider in Software, Technology on February 16, 2010
When I started this personal blog, it was a matter of a few clicks in a tool called fantastico and everything was up and running. Whatever development and style modifications I have done over the time were directly on the server. As a matter of fact, I still do.
Clearly, it is not the best idea for incremental development, not without inevitable “production downtime”. Working in a big internet company at least taught me this truth among other things. So, when I started my photoblog using pixelpost, I set everything up in my local MAMP stack and pushed the data to server one time.
joy@localhost ~ $ mysqldump -u user -ppass db > db.sql joy@localhost ~ $ scp -C db.sql joy@server: joy@server ~ $ mysql -u user -ppass db < db.sql
Afterwards all code pushes happen by rsync.
joy@localhost photoblog $ rsync -avz . joy@server:public_html/photoblog
This way, even though locally I have a small set of data, I can change code and test all features before doing a production push. Works very well for me. Also I check in my code in a local git repository. Double win.
I am in the middle of setting up another wordpress blog right now, and forgetting a small detail cost me a bunch of time. After getting the blog running locally, I took a mysql dump and synced it with the db in the server. It just won’t load. I mucked around here and there and figured that the blog url is set as “http://localhost:8888/newblog” in the local db. I modified the .sql file and re-synced to production and voila, it worked.
I suspect that I might need to do the db sync a few more times before I have enough volume of data to keep it growing in the server. I will probably set up a sed script to do the search-and-replace in command line.
Epson 2200 in Snow Leopard
Posted by therider in Mac, Photography, Software on January 27, 2010
The upgrade to Snow Leopard a few months back was smooth, except for one fatal thing. The colors from my Epson 2200 went from awesome in Leopard to downright awful, thanks to the third party Gutenprint driver. I only realized this mess today since I had been printing black and whites using the Quad Tone Rip (QTR) driver which kept producing neutral prints.
So I hit google and there it was, a pretty long forum thread on the very same issue. To my surprise I found that Epson indeed released Snow Leopard driver for the 2200 printer sometime in Nov 2009. I installed it, then removed and re-added the printer and voila, the colors are almost back to normal. The interface is actually much better than what I expected, and the advanced color setting panel actually worked (it was mangled up in the Gutenprint driver).
Now that I still had a little magenta cast (as opposed to horrible), I tweaked with the advanced color settings panel. Took down magenta to -9 and suddenly the grays started to look like gray. There is just one thing to be done in photoshop prior to printing. The brightness of the image has to be increased a little bit. A foolproof way to do this is to have a curves layer, with no adjustment, then setting the blending mode to screen with 50% opacity. That makes my color prints about same as what I see on my monitor. For black and white prints using QTR, the last step is not necessary, or maybe about 20% opacity will do.
Looking forward to some print sessions in the coming days.
Update: Magenta -12 works even better.
Stackoverflow.com: A programmer’s dream
While google has always served me to find answers to a wide array of programming and technical issues, I don’t recall any one tech QA site which was consistently reliable. I regularly dug out answers from google group discussions to some old bulletin board archives to the typical flashy QA sites infested with scammy ads.
Stackoverflow.com provides a spot-on solution to this very precise problem. Not only it is a clean and functional site free of annoying ads, it actually engages the users to help others more. The reputation scoring logic is a feedback loop, which gets a programmer addicted in no time. I think it works marvelously well.
To top it off, Joel Spolsky and Jeff Atwood, the founders of stackoverflow made their software reusable. There is also superuser.com and serverfault.com based on the same platform but geared more towards sysadmin crowd. And slowly, many other sites are adopting this very successful platform, for example: answers.onstartups.com.
I am very happy to be involved with helping the programming community and learning at the same time. I guess I have nearly stopped spending time on facebook and twitter. I recommend all my coworkers and techie friends to start contributing in these platforms already.
Wordpress fusion theme: twitter widget link problem
The twitter sidebar widget in the fusion theme of wordpress shows weird in Firefox browser, due to the encoding of the double quotes in the href attribute. For example, a link from a twitter post shows like this in source:
Safari in quite intelligent regarding this and displays the links right.
A look in the code revealed that the output from twitter webservice call is not completely decoded. The function fusion_TwitterWidget() in wp-content/themes/fusion/functions.php looks like this after an easy fix:
-
// theme widget: Twitter
-
function fusion_TwitterWidget($args){
-
extract($args);
-
echo $before_widget;
-
print $before_title.__(‘Twitter posts’,'fusion’).$after_title; ?>
-
-
<?php
-
$username = get_option(‘fusion_twitterid’);
-
$limit = get_option(‘fusion_twitterentries’);
-
if($username<>”) {
-
$feed = file_get_contents("http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit);
-
-
// joyd: fix for the broken hyperlinks of twitter plugin due to encoded quotes
-
// $feed = str_replace("<", "< ", $feed);
-
// $feed = str_replace(">", ">", $feed);
-
-
print ‘<ul id="twitterupdates">’;
-
for ($i = 1; $i < = $amount; $i++) {
-
print ‘<li class="entry">’;
-
echo $cleaner[0];
-
print ‘</li>’;
-
}
-
print ‘</ul>’;
-
}
-
-
echo $after_widget;
-
}
Thanks a lot to Francesco to point this out !
Pixelpost mod: Edit image link
As my pixelpost photoblog is growing by the day, it is pretty painful to edit info for images that are a little old. In the admin page, go to the images section, then navigate a couple pages to find the image from the small thumbnail then click edit. Too much work for me. A simple tag expansion should solve this.
So I made this new tag and inserted it right after the Admin link in the footer page (my template is theworldin35mm):
<EDIT_IMAGE_LINK_ITEM>
And then the following piece of code in index.php to ensure expansion of the tag only on a image page and when logged in:
-
$edit_image_link_item = "<li><a href=\"<SITE_URL>admin/index.php?view=images&id=$image_id\" title=
-
\"Edit Image\">Edit Image</a></li>";
-
} else {
-
$tpl = ereg_replace("</edit_image_link_item><edit_image_link_item>","<!– Edit image link only for image page when logged in –>",$tpl);
-
}
The above code goes right after the following block:
-
…
-
}
Image management (editing category/tags) is a breeze now.







Recent Comments