New retail trend – from online to offline?

Two of the biggest online tech companies have been rumoured to open offline retail stores.

Google – http://www.hindustantimes.com/technology/Events/Coming-soon-Google-s-retail-store/SP-Article1-809479.aspx

Amazon - http://blogs.ajc.com/business-beat/2012/02/07/report-amazon-to-open-retail-store/?cxntfid=blogs_business_beat

Is this the new trend in retail? While many offline retailers are struggling to get online, those who have primarily been an online entity are now moving into the offline ground.

Mind you, it seems only the established ones are able to afford such move, since for many small online retailers, it’s still far easier to stay on that course.

But it is indeed interesting to see that what is considered as a dead-end for some, offline still does have its place in our life, so long as you innovate.

Posted in Anything & Everything | Leave a comment

Implement a Pinterest-like layout!

Looks like Pinterest is one of the hot social sites right now. I think their main arsenal was their visual approach to presenting the content. It’s that infamous, infinite scrolling, tiled look, which works very well for the images.

So how does one go about implementing such a layout? Well, there are a few options.

First, there are some great jQuery plugins such as jquery Masonry and jQuery Isotope. They work brilliantly in putting a dynamic layout on the content that you want to present. Mind you Isotope will costs you if you are implementing this in a commercial site.

However, as far as making something very similar to Pinterest layout, I have come across a great little plugin from Wookmark – the Wookmark plugin.

If you implement the plugin as the instruction asks you, it may not work as you expect, because the whole point is to make your layout “fluid”, so when you resize the browser, the layout should adjust itself accordingly. However, the plugin itself won’t do that automatically.

What you must do is:

  1. Create a function that will enable the wookmark pluginresize : =>
      resize = function() {
    $(“.item_to_be_tiled”).wookmark {

          offset:5
        }
    }
  2. Detect resize event on the window to apply the plugin each time the browser is resized.$(window).resize =>
      @resize() 

And that, works great! Now go get yourself jQuery Waypoints plugin, so you can easily enable the inifinite scrolling feature and you have yourself a nicely working Pinterest-like layout.

By the way, I am using Coffeescript here. You should try it. Oh pleaes. :)

Posted in Anything & Everything | 5 Comments

New Freally – it’s about time.

“Neglected” would be an understatement in this case. Though I launched Freally in mid-2010, it was left to itself without much improvement over the years. Well, I finally went off my butt and did something about it and I am happy to announce that it’s nearly time for the re-launch. I cannot wait! And hopefully this time, I will learn from my mistakes and try to take a better care for it.

Posted in Anything & Everything | 2 Comments

Apply natural sorting on MySQL or Postgres

If you have a table with a varchar or text column, which may or may not contain text-based integer values, it’s sometimes hard to do natural sorting on MySQL or Postgres. By that what I mean is, if you have

col1
——
a1
a2
a10
a20

and if you apply “order by col1″, the sorting result would be something like

col1
——
a1
a10
a2
a20

The easiest way to go around this is to first order by the length of the value and then the actual value. So in MySQL, you will have

… order by LENGTH(col1) ASC, col1 ASC

and in Postgres

.. order by CHAR_LENGTH(col1) ASC, col1 ASC

WA~LA~ saved me time.

Posted in Anything & Everything | Leave a comment

SimplePie & ‘ampersand’ invalid XML error

I was using one of the APIs to process their XML file using SimplePie, but it happens so that their XML document was invalid since one of the fields contained the ampersand character.

How did I resolve it? SimplePie accepts “set_raw_data($feed_string)” as one of its options. This means that you don’t have to use the URL to parse the feed.

So first, download the content of the XML through file_get_contents() method in PHP, then replace the string using str_replace(‘&’, ‘&amp’, $feed) and then you are safe to go.

I’m not entirely sure what other implications this has, but it’s serving me well so far.

Posted in Anything & Everything | Leave a comment

Latest SimplePie 1.2.1 and CodeIgniter 2.1.0 working together.

SimplePie is a popular RSS parser and it was always easy to integrate it with other PHP frameworks.

However, I was not able to find the latest SP (1.2.1) integrated with the latest CI (2.1.0). So I decided to upload it to GitHub and make it available for all to use. The repo is available at

https://github.com/ericbae/SimplePie_CodeIgniter

There are two things I did to make this work, which weren’t too difficult.

First is to ensure that SP references are correctly fixed up when porting to CI. This is well documented with links in

http://www.smartango.com/blog/simplepie-and-codeigniter

Secondly, when I was running this, it was giving the following error.

cURL error 6: name lookup timed out

It seemed like cURL was timing out when trying to access the remote RSS feed. The value for timeout is set to 10 seconds by default. Maybe this is a bit too strict. I changed this to 20 and it worked well.

Finally, here’s the snippet of my code to get this thing working. Make sure you include Simplepie.php in your libraries folder and also set your “cache” folder as writable.

public function aus_conf()
{
$this->load->library('Simplepie');
$this->simplepie->set_cache_location(APPPATH.'cache');
$this->simplepie->set_feed_url('http://feeds.feedburner.com/TheAustralianArt?format=xml');
$this->simplepie->init();
$this->simplepie->handle_content_type();
foreach( $this->simplepie->get_items(0, 5) as $item)
{
echo $item->get_title() . '
';
echo $item->get_description();
}
}

Posted in Anything & Everything | 3 Comments

What’s Happenic!

Today I am launching Happenic v0.1. This is the second iteration of this project, yet I spent last 4 weeks refining the primitive first iteration.

The interface now boasts full-screen calendar and event listing with easy-to-use search features and best of all, now I don’t have to go and search for all different sites to get what is happenic (get it get it?) around my city.

For now, I am making it available for Australian cities, obviously, I will slowly expand the site to include other cities.

http://www.happenic.com

Posted in Anything & Everything | 1 Comment

Calendar v2?

Calendar web app was something I was working on for about 4 weeks now. This is actually the second version I am trying to release.

After the intitial one, I re alised how “slow” it was due to some serious novice Javascript coding. I spend few weeks refreshing my knowledge in JS, plus kicking myself with Backbone and things are finally looking a-ok.

Hopefully I can get this out before 2011 ends. Can’t wait!

Posted in Anything & Everything | Leave a comment

Small fixes to CodeIgniter, Facebook FQL via Graph with cURL (Phil Sturgeon’s library)

I went absolutely bonkers on trying to get CodeIgniter with Facebook Graph API via cURL.

Firstly, the problem here was the fact that everything was indeed working fine. Then when I tested my code again, things started breaking. Here’s my scenario.

I am using CodeIgniter 2.1.0 (the latest one) and I am trying to get the list of all the albums I have on Facebook via Facebook Graph API. In particular, I am running FQL to get these data, since I only need a few data fields.

In addition, I am also using Phil Sturgeon’s cURL library, so I don’t have to worry about all the nitty gritty details.

Here are TWO fixes I had to implement in my code to get things rolling.

  1. Specify “http_build_query” in Curl.php to handle ampersand character correctly.  According to the PHP site, this is what it states.

    As noted before, with php5.3 the separator is & on some servers it seems. Normally if posting to another php5.3 machine this will not be a problem. But if you post to a tomcat java server or something else the & might not be handled properly. To overcome this specify: http_build_query($array, ”, ‘&’).

    Looks like when interacting with Facebook Graph, you need to specify this.

  2. Specify options in cURL – Previously, I called a “simple_get( URL, array(‘q’ => my_fql, ‘access_token’ => my_access_token))”. When talking to FB, you need to specify the following options

    $this->curl->option(CURLOPT_SSL_VERIFYPEER, false);

    A little bit strange, since I didn’t have to do this before. But if Facebook is tweaking their systems all the time, which I imagine they do, we just need to adapt.

Hope that alleviates pain for some people who are doing similar things as me.

Posted in Coding, Question everything | 2 Comments