Digital Memo All begin with 0 & 1

20Jun/130

Importance of Header Response Content-type

Does header response content-type a matter?

There is a problem bugging me for a few months: a small bunch of users using my Android app are unable to view the content when they turn on their 3G. The content data is fetched as web services, either in XML or JSON format.

Pretty weird. First of all I suspect the problem could be due to routing problem, from my web services to the users. Few months later, I changed my web hosting and with different server and IP address, the problem still persist.

Further investigation found out that:

  1. They are from the same telco M.
  2. And it comes from the same range x.x.x.* .

Then I suspect that is there something wrong with the backbone ISP, or with the domain registrar.

Until two users told me the same thing: they managed to visit my website via browser, but were unable to see the drop down menu (my dropdown menu is base on JSON response).

Until then, I re-check my services, and put header response for each of the output.

For XML:


header("Content-type:application/xml");

For JSON:


header("Content-type:application/json");

And finally, users reported that they are able to view the contents.

Though the problems seem to be solved, but the mystery still remain: why is it only with Telco M, with that kind of IP range, is having problem viewing the JSON/XML format when the header content-type is not set?

pixelstats trackingpixel
Filed under: Uncategorized No Comments
19Mar/130

PHP Snippet: read files info and contents without extracting

A very useful PHP code snippet. It read the contents and info of the files in zip file without actually extracting them.


$zip = zip_open("D:tests".$outFile);
if ($zip) {
while ($zip_entry = zip_read($zip)) {
echo "Name: " . zip_entry_name($zip_entry) . "n";
echo "Actual Filesize: " . zip_entry_filesize($zip_entry) . "n";
echo "Compressed Size: " . zip_entry_compressedsize($zip_entry) . "n";
echo "Compression Method: " . zip_entry_compressionmethod($zip_entry) . "n";
if (zip_entry_open($zip, $zip_entry, "r")) {
echo "File Contents:n";
$buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
echo "$bufn";
zip_entry_close($zip_entry);
}
echo "n";
}
zip_close($zip);
}

For performance wise, I didn't really test it, as I did not feel any performance hit with a zip file of 20MB and 100MB+ uncompressed file.

Referrel link: http://www.whileifblog.com/2012/03/24/php-read-filescontentfile-details-from-a-zip-archive-without-extracting-them/

pixelstats trackingpixel
Filed under: PHP No Comments
8Feb/130

iOS development notes

Locating iOS Simulator folder location in Finder:

  1. from spotlight, open Activity Monitor
  2. Look for "your app name"
  3. Double click, and click on the tab "Open Files and Ports"
  4. Copy the first path
  5. Open finder window, press "Command + Shift + G", paste in the path and open.
    * Note that Users/username/Library folder is hidden.

Checking line number and filename from crash reports

  1. Need to locate file ".app.dSYM" of the release
    1. From XCode > Organizer > Archives
    2. Select the correct version that match the crash reports downloaded from itunes Connect
    3. Right click > Show in Finder
    4. On archive file, right click > Show package content
    5. folder dSYMs > copy the file to new folder of your convenient
  2. Open terminal
  3. Use the command below:
    dwarfdump --lookup 0x00107fef -arch armv7 yourappname.app.dSYM
  4. Command above might be different (might be armv6)
pixelstats trackingpixel
26Jan/130

Google Analytics: the Gone by Hours

Google Analytics had one of my favourite report before: the 00 to 24 hourly reports option in the past.

Google Analytics Hourly in old time

However, overtime when GA has changed and change, the option is now longer there. It's frustrating.

Though not as good as before, I am able to get the average views by hours over defined periods by using Custom Reports. Here is how:

  1. Click on Customization
  2. Fill in Title of your report
  3. Under Report Content, choose "Visits" (or PageViews, Unique Vistors, etc of your preference) for Metric, and choose "Hour" for Dimension Drilldown.
  4. Scroll to the bottom and click "Save"
Google Analytics Custom Report

Google Analytics Custom Report

Now you will able to see the report as follow:

Analytics by Table

Analytics by Plain Table

Analytics bar graph

Analytics bar graph

Unfortunately, one of the problem now is that, when you view by Graph, you can't sort the hour value. It can be sorted by the number of visits only. I have sent this report to GA team and lets hope they can fix this in near future. In the meantime, you may export the report as CSV and do the charting at Microsoft Excel.

pixelstats trackingpixel
21Jan/130

MySQL ODBC issue in C#

Recently I have migrated my office PC from Windows XP 32-bit to Windows 7 64-bit.

The migration was smooth until I am unable to connect to the MySQL via ODBC in my Visual Studio 2010 c# project.

The debugger throws the following message:

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
this.DbConnection.ServerVersion' threw an exception of type 'System.InvalidOperationException'

I have installed both 64-bit ODBC driver from MySQL  and surprisingly, not working at all. I have been tinkering with the connection string too, but without success too.

Finally, base on some information found online, I decided to install the 32-bit MySQL ODBC drivers and finally it works! It works on both version 5.1 and version 5.2.


<add name="databaseString" connectionString="Driver={MySQL ODBC 5.2a Driver};Server=localhost;Database=dbname;User=root;Password=;option=3" providerName="System.Data.Odbc" />

I am wondering what happen to 64-bit drivers?

pixelstats trackingpixel
Tagged as: , , No Comments
9Sep/122

SQLite drives me crazy

I have been using SQLite in Android development. Some calculation is needed through query, e.g:


SELECT sum(ColumnA* ColumnB) / sum(ColumnC) FROM table

In certain circumstance, when the ColumnA and Column B are both integer, the resulting simply give me an integer (which should be a number with decimal point).

For example, a value of 500 / 200 = 2.5, but the resulting value is simply 2.

Have been checking through coding and query to check what's wrong, taking me few hours due to slow Eclipse IDE during debugging.

To fix this, if we wish to return a decimal point number, always make the number as decimal point even if it is an integer, before any calculation.


SELECT sum(ColumnA * 1.0 * ColumnB) / sum(ColumnC) FROM table

pixelstats trackingpixel
5Sep/120

Review on Exabytes

I have been with Exabytes for around 1 month. Exabytes is well known in Malaysia thanks to its aggressive marketing strategy.

The basic small business exabytes hosting (EBiz Plus) offer 10GB of spaces, 50GB of monthly bandwidth, and 10 add on domains.

Some of the CPanel tools I found useful includes Resource Usage which let you check the CPU and Memory usage.

Plus, Exabytes offer a stable and better processing speed Server.

However, there is 2 things that I can hardly accept, technically:

 

The add on domain must be put under /public_html

This reduces the flexibility on how user can manage the domains and subdomains. Normally I like to put the domain folder in /domains, the folder which is created by myself.

 

Optimze Website tool is disabled (not available in CPanel)

What is this tool about? It offers a GZip (you can regard it as a zip) feature for any files downloaded to your browser, up to 95% shrinking in size, with an average of 70%-80%, base on my experience.

By enabling this feature, the HTML file, CSS, Javascript, etc can be GZipped before it is sent to your browser. It saves the bandwidth and download time on end user side, giving much better user experience.

Unfortunately, this feature is not offered by Exabytes shared hosting. According to them, only VPS (Virtual Private Server) or more advanced package can have this feature. Quite a disappointment.

 

pixelstats trackingpixel
12Jun/122

Unhappy experience with Minoors.com

Minoors is an online B2C commerce website, selling variety of products such as tablet, clothes, accessories, etc.

I approached minoors and bought a tablet. Jasmine, is minoors personnel who is working with me.

Here is how the things go:

  1. 8th May (Tuesday)
    - I made my payment via paypal on 8th May (Tuesday). I asked minoors to give me the tracking number.
  2. 14th May (Monday)
    - I am able to get the response as well as the tracking number. Minoors delivered the item via DHL.
  3. 16th May (Wednesday)
    - I received the notification from DHL after sign up for the notification services. However, I found out the written address is totally wrong. Immediately I contact Jasmine for the correction.
  4. 21st May (Monday)
    - I E-mail Jasmine regarding the shipment, unfortunately no response.
  5. 29th May (Tuesday)
    - Able to approach Jasmine via Skype. Only then she said the shipment has been sent out. It would take 2 days for tracking number feedback.
  6. 1st June ( Friday)
    - Jasmine did not update me with the tracking number. Try to approach her via Skype and E-mail but failed.
  7. 2nd June (Saturday)
    - Try to approach via Skype and E-mail again, still no response.
  8. 4th June (Monday)
    - Finally Jasmine response and give me the tracking number. That is 1 week after the shipment is sent out as told by Jasmine. Immediately I checked the tracking number, however found out that the CITY address is still wrong. I have to get the notification from DHL to have the full shipment address before I can confirm the shipment. Immediately I reply to Jasmine to voice out my doubt, however, no response anymore.
  9. 6th June (Wednesday)
    - The shipment has been one week without movement. I E-mail Jasmine but no reply. At the sasme time I report to DHL customer services.
  10. 7th June (Thursday)
    - Received the nofication from DHL and the address is still terribly wrong. E-mail the information to both Jasmine and Minoors Customer Centre, as well as DHL. DHL says the items have been sent back to minoors! At the same day, I decided to open the dispute for the transaction in PayPal.
  11. 8th June (Friday)
    - Minoors claim that they will contact DHL. At the same time, minoors request me to close the dispute before they do the shipment again. I reply them that I will close the dispute once I received the item.
  12. 11th June (Monday)
    - Minoors remain passive and no response. I E-mail them once again, and to DHL as well. DHL reply me that minoors side is unable to sign to clearance form and that's why the item is sent back to them.
  13. 12Th June (Tuesday)
    - Minoors once again insist me to close the dispute before they will do the 3rd shipment. I again reply them back immediately with my statements. After 3 E-mails gone out, no reply.

 

This is the long long story dealing with minoors. They promise me that I will get the item within 8 - 11 business days which is around 2 weeks. However, it has been over a month and the item is still with Minoors. What's more, when I decided to open the dispute in paypal, they want me to close it before they do the shipment.For your knowledge, once the dispute is closed, there is no way to open it again and I can't get back the refund anymore if I still didn't receive anything. The dispute is for the merchant to check the problem and  to assure that the customer to get the items. Can you imagine what kind of nonsense requested by Minoors?

Immediately I reply them telling the reason I do not wish to close the dispute. It was in the morning and until evening, they still did not reply me though I have sent 3 E-mails in total to them. Now I tell them I will request paypal for refund if I still didn't get reply by Wednesday and Tracking Numbers by Friday.

In conclusion, Minoors remains very passive in replying customer E-mail, and they feel nothing wrong by delaying the shipment again and again. No explanation is given from their side. And I don't think they bother to give customer any explains. They do not respect customer services at all. So why should we dealing with such commerce website? There is a lot more website selling same products and I wouldn't want to waste my time dealing with minoors again. It's a hell suffering month and I bet it is hard to find another lousy services same as minoors.

 

Another note: beware of pickrice.com too. They are sister company, sharing the same database and servers (I can find the pickrice information in minoors website, and I am the one who contacted them and correct them). On 8th June Friday, minoors.com and pickrice.com has been down at the same time. If you enter the website with Google Chrome, you will find the following:

And after 5 days they still unable to resolved the problem. Not professional and Scams perhaps? I am not sure, as I never purchase anything successfully from them. However it is still your decision whether or not you want to deal with them.

pixelstats trackingpixel
6May/120

CakePHP to populate created / modified value

Faced some problem today; cakePHP doesn't populate the created and modified value automatically.

I have been with cakephp for almost a year and this is the first year I faced such problem. Searching online for the solutions, many people suggested that the default value of the fields should be set to NULL. However this does not work for me.

Taking a walk and a relax in the washroom, I was reminded that I add in the fields created and modified only in later time.

The solution: I am using cache, so I deleted the model file cache for that table, then only the problem solved. The cakephp isn't able to refresh its memory rested inside the cache file :) Best practice: remember ALWAYS delete the model cache file whenever a table fields change.

pixelstats trackingpixel
28Jan/120

Creating a count buttonless Facebook like/recommend button

In contrast with Google +1, Facebook like button doesn't provide an attribute to turn off the counting.

To make this happen, we have to give up the xfbml coding provided by facebook. Instead, we use the traditional html way to display the facebook button, using iframe.

By using the iframe that provides the facebook button, we can limit the width of the iframe to match exactly with the width of the button.

The sample code is provided as below: change the href parameter to suit your own needs.

<iframe
src="http://www.facebook.com/plugins/like.php?href=http://digitalmemo.neobie.net&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=recommend&amp;colorscheme=light&amp;font=segoe+ui&amp;height=35"
scrolling="no" frameborder="0"
style="border:none; overflow:hidden; width:92px !important; height:24px; margin-top:6px;" allowTransparency="true">
</iframe>

Take note of the "style" attribute: I have set the width to 92px which is exactly the same width as the fb recommend button; it would be 49px for fb like button. Furthermore, I have put "!important" after the style width attribute to enforce the width, to prevent it overwritten by other style sheets.

An example is provided below, taken from a project I am working on. When user click on Recommend button, no counting is shown.

I hope you enjoy the new countless button!

pixelstats trackingpixel