Back to WordPress

Last year, I moved my blog to Github pages. The main reason was that it was programmer centric way of blogging. I could write blog posts using Markdown in SublimeText, my natural habitat. To publish a post, I simply commit and push. And it would be fun to see git log history. I could edit old posts and not only me but everyone can see how it changed overtime. And most of all it was elegantly simple.

But there were some cons. I could not auto-post to social accounts without signing up for another service. If I wanted comments,  I would have to sign up on another different service. That would be no longer elegantly simple.

Then a few months ago, Github disabled a few Markdown plugins which meant I had to update a few posts. Not a big deal but I didn’t want to deal with it again.

So after some contemplation, I decided to move back to WordPress. My biggest concern with WordPress is security issues but most of these issues come from insecure plugins or themes. As long as, I am mindful of which plugins or themes to install, it should not be a big issue.

SublimeText is awesome but WordPress’s editor is also nice. It is pleasure to be using it right now. It generating pretty clean HTML too.

I liked the automatic backup when using git to publish a site but my hosting provides automatic backups and then I have scheduled job to do my own backups. So using Github pages just for backup purposes was not that important.

Then of course, WordPress provides easy ways to post to various social sites, manage comments, categorize posts, and, search capabilities, etc.

The big advantage of WordPress is that I can now just focus on writing blog posts instead of looking for ways to add features to Github pages.

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 and repushing, fixed the issue.

Setting up Glassfish Server on CentOS

All these steps are based on tutorial from

  1. yum install java-1.7.0-openjdk-devel
  2. Add following lines to /etc/profile: export PATH=$PATH:/usr/lib/jvm/java-1.7.0-openjdk- export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-
  3. Run this command to reload environment variables: source /etc/profile
  4. wget
  5. unzip -d /opt/oracle
  6. cd /opt/oracle/glassfish4/bin/
  7. ./asadmin start-domain
  8. ./asadmin create-service Found the Linux Service and successfully uninstalled it. The Service was created successfully. Here are the details: Name of the service:domain1 Type of the service:Domain Configuration location of the service:/etc/init.d/GlassFish_domain1 User account that will run the service: root You have created the service but you need to start it yourself. Here are the most typical Linux commands of interest:* /etc/init.d/GlassFish_domain1 start
    • /etc/init.d/GlassFish_domain1 stop
    • /etc/init.d/GlassFish_domain1 restart For your convenience this message has also been saved to this file: /opt/oracle/glassfish4/glassfish/domains/domain1/PlatformServices.log Command create-service executed successfully.
  9. ./asadmin change-admin-password . Initial admin password is blank. You need to change it to something else.
  10. ./asadmin --host --port 4848 enable-secure-admin
  11. Enjoy!

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;