Programming Tips & Insights

Pretend your scraper script as a browser when scraping in PHP

It’s easy to make a simple scraper script in PHP but it’s also easy for data-centric sites to detect and keep out suspiciously continued page accesses done in large amounts and a small period of time. There are usually 2 ways for a site to detect possible scraping activities. One is to make sure the …

Pretend your scraper script as a browser when scraping in PHP Read More »

Backup and recover a MySQL database under command line

Yes you can log into phpmyadmin, backup your database by simply using Export and recover it by using Import. However all lamp servers come with a max upload file size, limited by the smaller of upload_max_filesize and post_max_size while also restricted by php.ini configurations such as memory_limit and max_input_time. What if you’ve got a huge …

Backup and recover a MySQL database under command line Read More »

Using SQL to Find records existing in one table but not in another

The 2 tables are built with an identical data structure. Say you have records spread in both tables but neither of them are complete because both contain unique records. You need to consolidate the 2 tables into one with all unique records from each table. NOT EXISTS clause is just the way to do it …

Using SQL to Find records existing in one table but not in another Read More »

Warning: session_start(): Cannot send session cookie – headers already sent

It is known that you have to make sure nothing’s already sent to output to perform a successful http header modification. As such, in PHP, you will keep an eye on possible white spaces before the use of header() function to modify delivery headers. For example, <?php header(‘…’); ?> this tiny snippet would fail if …

Warning: session_start(): Cannot send session cookie – headers already sent Read More »

Cron jobs (Crontab jobs) tricks and tips on DreamHost

Crontab is a utility tool on Unix-like OS that enables you to make a program daemon scheduled to run at a specified interval. For example, to fetch news feed and import them into your own database every hour on the hour or to send pre-written newsletters at a given time everyday. With DreamHost you can …

Cron jobs (Crontab jobs) tricks and tips on DreamHost Read More »

One SSI directive to save all programming muggle’s effort and time

SSI stands for Server Side Includes that is a default module in Apache web server. In essence, it provides a very simple mechanism to include one HTML file in another one, thus tremendously reducing redundant coding and increase the ease of later maintenance. So, to get 80% out of SSI, the only directive you pretty …

One SSI directive to save all programming muggle’s effort and time Read More »

Differences of function.apply() and function.call() in JavaScript

Function object methods function.apply() and function.call() basically do the same job, that is to invoke the function as if it was the method of a specified object so that the ‘this’ keyword within the function is treated as that object rather than the global object. var x = 20; function f(s) { alert(this.x + s); …

Differences of function.apply() and function.call() in JavaScript Read More »

DOM event detection: event bubbling and event capturing

There’s essentially 2 ways for the DOM to detect any events, namely event capturing and event bubbling. Event capturing is a method that the browser captures the event from the top elements to the bottom where the event actually takes place. For example, the moment you click on an <img> which is the child of …

DOM event detection: event bubbling and event capturing Read More »

JavaScript: Changing Browser Window Width / Height

This petite JavaScript snippet defines several functions in the namespace of Geometry that will come handy when you need to manipulate window geometry, freeing you from the depressing chores of distinguishing different browsers for their distinct implementations of virtually the same features. /** * This module defines functions for querying window and document geometry. * …

JavaScript: Changing Browser Window Width / Height Read More »

What is PHP framework & Who are the Best PHP Frameworks?

Basically, PHP frameworks are programming layers that are promoted above PHP itself and that are much easier and quicker to deploy, normalizing and packaging 80% of the routines one is expected to work on without them, such as database interfaces. Therefore they free you from the chores of coding from very scratch line by line …

What is PHP framework & Who are the Best PHP Frameworks? Read More »

Scroll to Top