Wayne Khan

Generally PHP musings.

Attended this yesterday. I was terribly late, but Blair Layton did give a good presentation on Oracle technologies. I do not have much practical experience with websites that require hardware load balancing, a hundred web/database servers so I can’t comment on what 11g brings to the table, but I’ll certain explore the developer DVD they so kindly provided.

Also demo-ed was the Oracle Application Express, which is a step-by-step (simple) web application builder. From a CSV file, a CSS-styled, one-table application with list(sortable)/add/edit/delete functionality was built in a matter of minutes. That’s pretty impressive.

If you’d like to attend more of such events, do check out: blog.php.com.sg. The presentation was videoed, so the slides/video should be up on the website fairly quickly.

Received this in the email today. As you know, Singapore is hosting the races this weekend, so I got worried, for nought!

Terrible F1 accident

Terrible F1 accident

I’ve had to write a number of .htaccess files over the past week or so. My uses of mod_rewrite are simple enough, but I thought to post here since there in case anybody just wants to accomplish something quickly. Ask your server administrator to set the “AllowOverride” property to “FileInfo” or “All”, so as to enable .htaccess overrides.

<IfModule mod_rewrite.c>
Permanent (301) redirect everything:
RewriteEngine On
RewriteRule ^(.*)$ http://waynekhan.com/v2/ [R=301,L]
</IfModule mod_rewrite.c>

Permanent (301) redirect some_page.htm (note to prefix your URL with “^/” and escape fullstops (.) with “\”):

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/some_page\.htm
RewriteRule ^(.*)$ http://waynekhan.com/v2/some/page [R=301,L]
</IfModule mod_rewrite.c>

That’s all for now, folks!

WARNING: The following set of instructions is based on my on experiences setting up my wireless card, which was a big pain. No guarantees that anything mentioned below should work, of course.

The S7110 uses the IntelĀ® PRO/Wireless 3945ABG Network Connection adapter (iwl3945). Use “lspci” as root to find out what type of network card you have:

# lspci -nn | grep “Intel”
05:00.0 Network controller [0280]: Intel Corporation PRO/Wireless 3945ABG Network Connection [8086:4222] (rev 02)

Now we’re are good to go. You’ll need at least the 2.6.24 kernel, which is available on “lenny” onwards. If you’re using Etch (or even Sarge), tough luck. Significant upgrades to follow. Find out what kernel is loaded:

# uname -a
Linux woteba 2.6.26-1-686 #1 SMP Thu Aug 28 12:00:54 UTC 2008 i686 GNU/Linux

I’m using 2.6.26, which is recent. Otherwise add the following line to /etc/apt/source.list:

deb http://ftp.tw.debian.org/debian/ lenny main contrib non-free

Now use Synaptic Package Manager to download at least the following packages:

linux-image-2.6.26-1-686
firmware-iwlwifi

After everything is downloaded and set up successfully, you’ll need to restart, and choose 2.6.26 during the boot sequence. Once booted into the new kernel, try:

# modprobe iwl3945
# iwconfig
.
.
.
wlan0 IEEE 802.11 ESSID:”MakeTeaNotWar”
Mode:Managed Frequency:2.412 GHz Access Point: 00:1F:9E:CF:58:B0
Bit Rate=54 Mb/s Tx-Power=14 dBm
Retry min limit:7 RTS thr:off Fragment thr=2352 B
Encryption key:6565-1671-75
Link Quality=76/100 Signal level=-58 dBm Noise level=-87 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

If “iwconfig” fails, you might need to download “wireless-tools”, using Synaptic. Good. The wireless card has been detected as “wlan0″. Your entries may differ, of course. The output above shows a connection to the router with SSID “MakeTeaNotWar”.

I use this software called “wlassistant”. It is a QT-based program, and has several dependencies, but it’s really easy to use. You can get it via Synaptic, of course. Once Wireless Assistant is up and running, you should be able to connect to most wireless networks.

References: Debian Wiki.

Read the text comments here.

What is the output for the following 3 code snippets?


$x = 3;

if (4 < $x) {
print "The quick brown fox jumps over the lazy dog.";
} else {
print "She sells seashells on the seashore.";
}

$x = 1;
$x = ++$x * 2;
print $x;

$x = 1;
$x = $x++ * 2;
print $x;

I just read the lengthy comic, and then downloaded it. Check it out here.

As far as I am concerned, the UI is pretty, and it feels faster than even Firefox 3. Way to go! I hope a (Debian) Linux version comes out soon!

You may have noticed the new ‘blog’ suffix in this blog’s URL now.

I’ve setup a site where visitors can take a look at demos of my work.

Here you go

Instead of the (STILL much-loved) CodeIgniter PHP framework, it’s running a recent version of CakePHP. I’ve been using it for a recent project, and I must say, it has more functions but is harder to learn.

For client-side scripting, I am still using jQuery/jQuery UI, although I have been (re)learning Prototype/Scriptaculous of late.

Have fun!


# Set the auto_increment value (e.g. `id`) to one more the highest `id` value currently
alter table `foo` auto_increment=1

# Show how MySQL will parse this query, including key (indices) used and any additional parameters
explain select * from `foo`;

# Show indices for the given table
show keys from `foo`;

[sourcecode]
du -h –max-depth=1 | sort -n -r > du_log
[/sourcecode]

The following shell command runs the ‘du’ command to a max folder depth of 1, and then pipes the output to ’sort’, and the finally writes it ‘du_log’.