Programming

Understand Magic Quotes in PHP

Have you ever heard about magic quotes? Today I have just realize why it must be called magic quotes. My objective was just to install phpMyAdmin on CentOS 4.2. I supposed it should be done in an hour. However, I stucked on generating the configuration file, config.inc.php. The symptom are as follows.

Krukle in beta

Krugle is going to start distributing beta account to all requesters one by one tomorrow. They also present a short demo preview the power of tag. Krugle is not just a common specific search engine mainly aimed to index only source codes, but also their specification, description, manual, and a lot more regarding the source codes.

Printing XML in Python

Once you have read an XML document or generated a new one, you might want to write them to a file, standard output, or even a string. Python provides many options to print out XML in string. Let me start from the very basic one.

print doc.toxml()

Easy! Now I will go to more advanced version of printing XML. Python offers good extension APIs and we should try them. First of all, don’t forget to import them and it’s rocking!

import sys  

Programmable FTP Client

FTP may not be as secure as SFTP but it is very fast. SFTP is best for personal usage. If you are sharing non-critical files among group of users, FTP seems to be better choice. Note that there is no shell access for those users. For example, a set of users are sharing a server space placed at a high-speed data center. Everyone placed requests to download new files everyday. In other words, all users download files to temporarily store in the server and then get them back home through FTP.

GeSHi - Generic Syntax Highlighter for Drupal

Since howforge.com has lots of contents related to programming techniques and source codes, I have been looking for a good syntax highlighter that supports all codes published in this site such as Python, HTML, XML, bash, C, Java, C#, CSS, JavaScript, SQL, Ruby, and PHP. Today, while editing XML code in DokuWiki, I found it has very powerful syntax highlighter provided by GeSHi. GeSHi is a generic syntax highlighter written in pure PHP. The advantage of GeSHi is its purity, in my opinion. You don’t have to deploy any additional software stacks like perl. Anyway, GeSHi is such a library for developer to call at run-time. To use it as a filter in Drupal, there must be a filter module that wraps GeSHi. Fortunately, vfilby has done geshifilter module for Drupal already. Actually, geshifilter covers all functions existing in codefilter module so you don’t need codefilter anymore.

Handle overflow in CSS

If you noticed some pages in howforge.com, they are containing

 tag to show code in monotype format. The side-effect of this tag is that all contents inside pre tag will never be wrapped if lines too long like usual cases. In other words, your layout may be extended the width for so long. Fortunately, I found a solution for this problem and just fixed in howforge.com. You could see the result of the solution in previous post. To fix this problem, just modify your CSS as follow.

pre {