Digital Memo All begin with 0 & 1

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
10Nov/111

Clearing CakePHP Auth User cache

I am doing some updates to the table users by adding a new field.

However on my running server, calling $this->Auth->user('newfield') return a NULL value.

Solution

To fix this, you need to clear the user model cache file.

Go to app/tmp/ folder, and remove the file cake_model_default_users, which store the information of the user table.

pixelstats trackingpixel
Tagged as: , 1 Comment
23Sep/110

wget to stop output file in cpanel

WGET could be the easiest way to run the cron job in CPanel. The command is as simple as wget http://digitalmemo.neobie.net/cron.php .

However, in my hosted server (hostgator), WGET command generates output files and the root folder: /home/username/ every time the cron job runs. The files' name are something like scriptname.1, scriptname.2 and with the number increasing. All the files need to be manually deleted.

To stop generating the output files, we need to add some parameters after wget: -O /dev/null

And the new command line would look like such:

wget -O /dev/null http://groupasave.com/daily_digests/send_summary

pixelstats trackingpixel
17Aug/1155

Solving: Failed to install .NET Framework 4.0 with Error Code HRESULT: 0xc8000222

I am having problem installing .NET Framework 4.0 in my new notebook. Without any descriptive error message (this is what Microsoft always does!), there is no choice but to find the solution come out by non-microsoft guys.

Here come the solution:

Before installing .NET Framework 4.0,

  1. open cmd
  2. type in command "net stop WuAuServ" (disable windows update)
  3. Go to Run (you can do this by pressing Win + R) and type in "%windir%" (this command let you go to your windows system folder)
  4. Find the folder "SoftwareDistribution" and rename it as "SDold"
  5. Then, go back your previous command prompt and run the command "net start WuAuServ"
  6. Now, try to install .NET Framework again
pixelstats trackingpixel
Filed under: Microsoft 55 Comments
17Jul/110

Accessing websites blocked by government

Malaysian! Some of you are awared that Malaysia government has recently blocked some of the P2P websites.

Those websites include:

  • http://www.warez-bb.org
  • http://thepiratebay.org
  • http://www.movie2k.to
  • http://www.megavideo.com
  • http://www.putlocker.com
  • http://www.depositfiles.com
  • http://www.duckload.com
  • http://www.fileserve.com
  • http://www.filetube.com
  • http://www.megaupload.com

If you have trouble visiting website that is blocked by your government, try to change your DNS service IP. As you know every website can be visited via its IP.

For example, the domain like "neobie.net" is just the better meaningful name for people to remember the URL. DNS's job is to translate neobie.net to IP 119.110.111.23 which is harder to be remembered and regonized by users.

By default, you will be using DNS provided by your Internet Service Provider (ISP), such as Telekom. For now I am introducing a better DNS: Google DNS, with IP of 8.8.8.8 and secondary 8.8.4.4.

To change DNS settings in your own PC (Windows 7),

GO to Control Panel > Network and Internet > Network and Sharing Center > Change adapter settings

Right click the connection you are using, and choose properties

Double click on TCP/IPv6

Configure your DNS as provided in Screenshot below

* Note that this method only works if the IP of the websites are not banned.

pixelstats trackingpixel
15Jul/110

Incorrect .htaccess RewriteRule with double dots in filename

Previously my website is working fine with file naming scheme of more than a dot(.), such as sample.test.html

I was using .htaccess RewriteRule, for example: redirecting a URL of mydomain.com/sample/test to my html file sample.test.html

In my directory, I have:

  • sample.test.html
RewriteRule ^sample/test?$ sample.test.html

Until today, some miserable thing happens. The URL was giving me Error 404: Page cannot be found.

After tinkering for some times, finally I found that was because of the file sample.test.html.

It seem like some changes was done by my Host Provider, and the server redirect /sample/test to sample.html, instead of sample.test.html I want. It seem like some configuration has been done on extension of the file but I'm not too sure which is it.

To solve this, sample.test.html is renamed to sample_test.html and in .htaccess:

RewriteRule ^sample/test?$ sample_test.html
pixelstats trackingpixel
Filed under: Apache No Comments
4Jul/110

Making your website load faster: CPanel Configuration

Follow up the previous post Making your website load faster: Compress PHP file easily, now there is another even better way to gzip your files. If you are a CPanel user, go to CPanel control panel, select "Optimze Website"

By default, the compression is Disabled. Now, choose "Compress the specified MIME types". The original settings would be: 

text/html text/plain text/xml

The text/html would include all the PHP file which is loaded on your server. To optimize your website further, we choose to compress javascript and css files.

Now, append the following text to it:

text/css application/x-javascript application/javascript text/javascript

And of course, click "Update Settings" to save your changes. Now check your CSS and Javascript files which are automatically compressed as well!

If you wonder why should we put 3 kinds of javascript MIME Type above, that is because different browser interpret javascript Content/MIME Type differently. For safety, just put as many as content type which are known to you so that the files can be compressed on most of the modern browsers!

Another question is, why don't we choose to compress all contents?

I am afraid if we choose this option, all images are getting gzipped too which are totally unnecessary since no file size are reduced. Adding more unnecessary processes means it would bring down hosting CPU performance at the same time.

pixelstats trackingpixel
29Jun/110

Google+

Google+ is launched today, and the web page layout is much alike facebook.

Despite the failure of Google Wave, can Google+ takes up some market shares from Facebook ?

Unfortunately, for those who wants to test Google+, the service is opened for small chunk of users currently. Right now, the only possible way to get the invitation is through their web form: https://services.google.com/fb/forms/googleplusenuk/. Simply enter your First Name and Email, then wait for the invitation :(

Circles, Sparks, Hurdles, Hangouts... Google has definitely give some good branding for its upcoming SNS.

Interactive demo can be seen here: http://www.google.com/intl/en_uk/+/demo/, you can play around (but not the real one) with Google+.

Wanna know more? Check out the Google+ Project playlist on Youtube!

pixelstats trackingpixel
29Jun/110

PPLIVE 是流氓软件?

虽然本身不常看网络电视,即使有看也是看PPSTREAM,因为身在大马只有 PPSTREAM 能够给予最好的观看体验;其他的网络电视都不能给到很好的流程。

某然在360安全卫士:360流量监控发现上载的流量一直飙升,几乎占据了我所有的上载带宽。

现在我来列出 PPLIVE 的两大罪状:

1. PPAP.exe 吃掉了我的上载带宽:

即便是我将PPLIVE 关闭了几个小时,PPAP.exe 还是依旧运行,不明白为何PPlive 要这么做?是不是在收集用户的硬盘资料?

2. IE代理设置时发现使用自动配置脚本被篡改

看开始看到这个设置时,我简直傻了眼。我自问没随便安装软件,而且也用着我喜欢的360杀毒,中病毒木马的几率几乎是0。谷歌查询,才发现,原来这又是 pplive 干得好事!怪不得最近觉得 chrome 的浏览速度比 火狐慢了许多(chrome 使用 IE 的代理设置)

要彻底解决这个东西,只好卸装 PPLive Video Accelerator。

pixelstats trackingpixel