The War of Art

I wasn’t sure what to expect when I picked up “The War of Art” by Steven Pressfield. It shows up on Hacker’s News and other entrepreneurs’ forums regularly as a recommended reading. Steven Pressfield is a novelist but this book is popular reading for anyone who is pursuing a goal.

The author’s main point is that the most important and the hardest thing is doing. Weather that be sitting down at desk to write a novel or software. Once you are at your desk, or at your office, the hard part is done. This can apply to anything; fitness, painting, photography, etc.

Things that make you the most nervous about doing; are probably the most important things. If these were not important to you, then you would not feel resistance when attempting these things.

One last piece of advice that I really liked was from Bhagwagita. It says that one has no right to their fruit of labor, only their labor. Basically, one should work hard without any expectations of reward. If they are lucky, their work will bring them all kind of rewards such money, fame, respect. But if they don’t get anything in return for their work, then so be it. They should do work for work’s sake and nothing else.

Lightroom & Smugmug Workflow

Now that I have a new fancy camera, I have tried to organize my photos better. Over years I have collected about 70GB of photos. It seems a lot to me but apparently there are many people with well over 1000 GB of photos. The biggest challenge with so many photos is that it is hard to organize them. Upon several recommendations and some searches on the web, it seems Lightroom is the best software for organizing and managing photos.

Then I want to share my photos in a slightly professional manner. I am still trying to decide between Smugmug, Zenfolio, or just sticking with free social media sites like Facebook or Flickr. But so far I am leaning towards Smugmug because I can customize it a bit and for occasional client work, I have a decent looking website.

I am still refining my workflow to organize my old photos but I wanted to share it, just so it can give someone else some ideas too.

Move Old Photos in One Folder

I bought Scott Kelby’s The Adobe Photoshop Lightroom CC Book for Digital Photographers (Affiliate link). So following his advice, I am keeping all my photos in one folder. Under that folder I created several folders like Events, Friends, Family, Travel, Personal, Clients, and Old Photos.

Delete Photos

The next steps is to go through 1000s of photos and reject any photo that should have been deleted long time ago. Some bad photos have nostalgic value; I keep those. But anything that is not a decent photo, I delete it.

Lightroom makes this process easy. Under Folders module, I browse to Old Photos, then a sub-folder under it. Then I press e & shift+tab for large view of photos. Then I simply use arrow keys to browse photos. Pressing x on a photo would mark it as rejected. I spent about 15-30 minutes a day on this process. Finally, I press control+backspace to permanently delete rejected photos.

Move Photos to Permanent Spot

After I have cleaned up a folder under Old Photos, I move it under proper top-level folder such as Events. Then I rename folder to something more informative such as 2012 Hina Birthday. I also rename photos with this format:YYYYMMDD-Custom-Text-Sequence. This should aid in searching for photos if using Windows Explorer or if browsing outside of Lightroom.

Edit Photos

Next step is to edit photos like crop, straighten, sharpen, adjust exposure etc.

Select Photos for Smugmug

I know a lot of people upload all their photos to Smugmug for backup. But I am using Backblaze for backup. So I don’t worry about backing up my photos on Smugmug. But now I have to decide which photos are good enough for public sharing and which should be shared privately.

To be honest, I am still refining this process. I have installed SmugMug plugin in Lightroom, which is actually very helpful.

Folder Structure on Smugmug

Using Lightroom, I created several galleries & folders on Smugmug including:

Select Photos to Share Privately

Now if subfolder has any photos that should be shared privately such as Birthday photos, I will upload almost all of photos in it to a new gallery under correct private sub-folder. I haven’t be able to decide if gallery should be password protected too or not. I hate to create bunch of unlisted or password protected galleries. But I know many of my friends or family members would not want their photos on the open web. Though I have password on top-level folder but some photos should not be shared with every member of family or every friend. Perhaps I should create multiple top-level private folders. Or maybe I should just stick with email/Dropbox method of sharing private photos. The problem with this method is that sometimes people lose their photos and then ask for them again and again. Also I want to make it easy for my family & friends to order prints online.

Pick the Best Photos for Public Sharing

Now I pick the best photos and upload to a public gallery. In case of Travel or Events, I create a new gallery per vacation or event.

Once again this part is not well-defined. Since I share only the best photos publicly, Travel or Event galleries tend to be sparse. Also I hate duplicating effort to upload photos multiple times.

Not using Collections

So far I haven’t figure out how to efficiently use collections. They seems to duplicate efforts. I am essentially maintaining my collections under Smugmug plugin.

The only problem with this approach is that if I switch to another platform for online photos sharing, then I will have to start over selection process.

This is it for now. As I learn more, I will update this post.

How to Fail at almost Everything & Still Win Big

How to Fail at almost Everything but still Win Big by Scott Adams (affiliate link) comes up on Hackers’ News a lot. Finally, I had a chance to read it.

This is a little different kind of book compared to my regular reads about ultra-successful business titans. I had no idea who Scott Adams was until I heard about this book. He created Dilbert comic. He gave very down to earth perspective on how he achieved success in this book.

Basically, he started various ventures throughout his life including restaurants, websites, etc. Eventually, he started getting traction on his Dilbert comics, so that became his number one focus which led to even more success. He developed passion for comics & art as his comic got more popular and earned him financial success.

The main takeaways for me are try try again, you will fail at most things, passion grows as project grows.


Magento – Get All Products with Categories in a Flat View

        w1.website_id, as website_name,
        s1.store_id, as store_name,
        p1.entity_id as product_id,
        pname.value as product_name,
        url.value as url_path,
        small_image.value as small_image,
        msrp.value as msrp_price,
        price.value as price,
        p1.created_at as product_created_at,
        p1.updated_at as product_updated_at,
        visibility.value as visibility,
        pstatus.value as status,
                (pstatus.value = 1
                    and visibility.value > 1)
            else 0
        end as enable_flag,
        c1.entity_id as category_id,
        cname.value as category_name,
        c1.created_at as category_created_at,
        c1.updated_at as category_updated_at
        catalog_product_entity p1
            inner join
        eav_attribute p_attr ON p1.entity_type_id = p_attr.entity_type_id
            and p_attr.attribute_code = 'name'
            inner join
        catalog_product_entity_varchar pname ON pname.entity_id = p1.entity_id
            and pname.attribute_id = p_attr.attribute_id
            inner join
        eav_attribute p_attr2 ON p1.entity_type_id = p_attr2.entity_type_id
            and p_attr2.attribute_code = 'url_path'
            inner join
        catalog_product_entity_varchar url ON url.entity_id = p1.entity_id
            and url.attribute_id = p_attr2.attribute_id
            and pname.store_id = url.store_id
            inner join
        eav_attribute p_attr3 ON p1.entity_type_id = p_attr3.entity_type_id
            and p_attr3.attribute_code = 'small_image'
            inner join
        catalog_product_entity_varchar small_image ON small_image.entity_id = p1.entity_id
            and small_image.attribute_id = p_attr3.attribute_id
            and pname.store_id = small_image.store_id
            inner join
        eav_attribute p_attr4 ON p1.entity_type_id = p_attr4.entity_type_id
            and p_attr4.attribute_code = 'msrp'
            inner join
        catalog_product_entity_decimal msrp ON msrp.entity_id = p1.entity_id
            and msrp.attribute_id = p_attr4.attribute_id
            and pname.store_id = msrp.store_id
            inner join
        eav_attribute p_attr5 ON p1.entity_type_id = p_attr5.entity_type_id
            and p_attr5.attribute_code = 'price'
            inner join
        catalog_product_entity_decimal price ON price.entity_id = p1.entity_id
            and price.attribute_id = p_attr5.attribute_id
            and pname.store_id = price.store_id
            inner join
        eav_attribute p_attr6 ON p1.entity_type_id = p_attr6.entity_type_id
            and p_attr6.attribute_code = 'visibility'
            inner join
        catalog_product_entity_int visibility ON visibility.entity_id = p1.entity_id
            and visibility.attribute_id = p_attr6.attribute_id
            and pname.store_id = visibility.store_id
            inner join
        eav_attribute p_attr7 ON p1.entity_type_id = p_attr7.entity_type_id
            and p_attr7.attribute_code = 'status'
            inner join
        catalog_product_entity_int pstatus ON pstatus.entity_id = p1.entity_id
            and pstatus.attribute_id = p_attr7.attribute_id
            and pname.store_id = pstatus.store_id
            inner join
        catalog_category_product ccp ON ccp.product_id = p1.entity_id
            inner join
        catalog_category_entity c1 ON c1.entity_id = ccp.category_id
            inner join
        eav_attribute c_attr ON c1.entity_type_id = c_attr.entity_type_id
            and c_attr.attribute_code = 'name'
            inner join
        catalog_category_entity_varchar cname ON cname.entity_id = c1.entity_id
            and cname.attribute_id = c_attr.attribute_id
            and pname.store_id = cname.store_id
            inner join
        catalog_category_product_index store1 ON store1.product_id = p1.entity_id
            and store1.category_id = c1.entity_id
            inner join
        core_store s1 ON store1.store_id = s1.store_id
            inner join
        core_website w1 ON s1.website_id = w1.website_id

OpenShift Error: Layer 7 Wrong Status, Invalid Response

I have been playing with OpenShift for past several hours. It looks great. But a while back I started to get 503 Internal Server error.

When I checked logs using rhc tail , I saw this error: Layer 7 Wrong Status, Invalid Response 404.

I spent an hour or so troubleshooting. Turns out the issue was Netbeans had added src/main/web/app/WEB-INF/jboss-web.xml when I ran the application locally on my machine. I committed this file, thinking I might need it. Deleting it from repo fixed the issue.

How to Tell if a Number Is Whole in Php

if ($num == (int) $num) {
    // It's whole
} else {
    // It's not

Filter Some Keys in Multi Dimensional Arrays in Php

 * Cleans up multi-dimensional arrays.
 * 1st dimension is a simple index
 * 2nd dimension includes the desired keys
 * @param mixed $array
 * @param mixed $keysToInclude
public function cleanUpArray($array, $keysToInclude) {
    $returnArray = array();
    $i = 0;

    foreach($array as $item){
        foreach($keysToInclude as $key){
            $returnArray[$i][$key] = $item[$key];


    return $returnArray;

4 Hour Body by Tim Ferris

Slow Motion Workout

The technical term is 5/5 Cadence (5 seconds up, 5 seconds down). I tried this for the first time on Sunday, it is really intense. Momentum is not there to help you. You will feel every part of your muscle throughout the motion.


Tim Ferris showed a simple formula to figure out what should be the starting weight to workout with. Simply do regular sets. If you can do 5 rep, wait a minute & then increase the weight by 10 lb or 10%. When you fail a set, then take 70% of last 5 rep set and use that weight for slow motion workout. You can figure out weights to use by trial and error. This should prevent injuries or wasted time.

The other part of choosing weights is to monitor progress. Every time to you finish a set with 7 reps, next time increase weight by 10% or 10 lb.

Rest Days

I never knew importance of rest days until I read it in this book. Your muscles grow during rest period. I used to workout everyday & not really gain any muscle.

Cat Vomit abs workout

You exhale as deeply as you can, hold for 10 seconds and then inhale. Repeat 10 times.

Do not drink calories

Not drinking calories is easy. Sweet stuff is disgusting anyways.

Bike Shed Effect

This is one of the best advice in the book. Basically, if you say you are building a nuclear power plant, no will tell you how to build it. If you tell them, you are building a bike shed, everyone will tell you how to do it even if they never build it.

Same thing happen when working out & eating healthy. Everyone thinks they know the best way of eating & working out. Ignore them.

MySQL Update If Exist Else Insert Procedure

Are you tired of checking data in your code before inserting? Well MySQL procedures are here to rescue. This simple procedure shows how you can do that:

CREATE PROCEDURE `update_insert_user`( IN uid2 int  )
SELECT `last_login` INTO last_login2 FROM `user` WHERE `uid` = uid2 LIMIT 1;
IF last_login2 IS NULL THEN
INSERT INTO `user` (`uid`,`last_login`) values (uid2, now());
UPDATE `user` SET `last_login` = now() WHERE `uid` = uid2 LIMIT 1;

Codeigniter Creates a New Session With Each Page Load

Just spent 3 hours debugging a session bug in my webapp. CodeIginter was creating a brand new session with each page load. The issue was a misconfiguration with my config file.

Fix was simple, in /application/config/config.php, make sure correct domain is set for $config['cookie_domain'].