Recent Notes

Displaying keyword search results 1 - 9
Created by Dr. Xi on February 06, 2012 12:14:11    Last update: February 07, 2012 15:39:35
Oracle sqlplus command line tools does not support command line editing out-of-the-box. But on Linux there's a handy utility that enables command line editing with any command line tool: rlwrap - readline wrapper. Install rlwrap: $ sudo apt-get install rlwrap Create a keywords file .sql.dict (optional, but convenient): false null true access add as asc begin by chec... It would be nice to add the tables names also. Create an alias for sqlplus (put it in .bashrc ): alias sqlplus='rlwrap -f $HOME/.sql.dict sqlplus'
Created by jinx on May 18, 2011 20:09:05    Last update: May 18, 2011 20:09:05
The PHP function file_get_contents reads the entire contents of a file into a string, while the function file reads a file into an array. file_get_contents('filename') is equivalent to implode('', file('filename')) : <?php // reads entire file into array, one elem...
Created by jinx on May 04, 2011 19:39:44    Last update: May 04, 2011 19:42:51
The function include includes the specified file multiple times, while include_once only includes the file once. This is a test: Create file test.php with contents: <?php for ($i = 0; $i < 5; $i++) { inclu... Create file test.inc with contents: <?php echo __FILE__, " included: $i\n"; ?> ... Run test.php , the output is: E:\phpwork\test.inc included: 0 E:\phpwork\test... Change include to include_once , only one line is printed: E:\phpwork\test.inc included: 0 You must use include_once to avoid duplicate includes in the case A includes B and C , but B and C both includes D . The relationship between require and require_once is the same.
Created by jinx on April 28, 2011 21:09:08    Last update: April 28, 2011 21:09:08
PHP global variables are defined outside of functions and classes. They are visible both in the current file and in any included/required files. Also, any global variables defined in required/included files are visible in the current file. But they are not visible in any functions or classes, unless specifically declared global . Test: Create file test.php : <?php ini_set('display_errors', 'stderr'); i... Create file test.inc : <?php echo '[', __FILE__, '] $a . $b = ', $... Run the PHP script in command line: php test.php 2>C:\tmp\stderr.out The result is: [C:\work\test.inc] $a . $b = ab [C:\work\test.p... stderr messages: PHP Notice: Undefined variable: b in C:\work\scra...
Created by James on September 10, 2010 23:01:14    Last update: September 10, 2010 23:01:14
By default, heights for jQuery UI tab panels expand or contract depending on the height of each tab. The code snippet here sets the height of all tabs to be equal to that of the container. <!DOCTYPE html> <html> <head> <title>jQu...
Created by James on October 11, 2009 21:15:53    Last update: October 11, 2009 21:19:39
Many techniques for making rounded corners do not work well when the element being rounded is displayed on a background with a different color (or multiple colors). Example 1: Nifty Cube with JavaScript <html> <head> <base href="http://www.html.i... Example 2: modx Simple Rounded Corner Box <html> <head> <title>Round Corner</title> ... Example 3: CSS3 (does not work in IE) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ... Example 4: This is one that actually works ! The nifty corner technique can be tweaked to be background friendly, although the JavaScript version didn't work for some reason. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ...
Created by Dr. Xi on April 18, 2009 21:41:01    Last update: April 29, 2009 03:23:55
While Python is strongly typed and wouldn't allow you to concatenate string s with int s, it gladly compares strings to ints, with unexpected results: >>> '09' + 10 Traceback (most recent call last)... Use the int function to convert string to int and the str function to convert int to string: >>> int('10') 10 >>> str(10) '10' >>> ... To convert an array of strings: >>> map(lambda x: int(x), ['1', '2', '3']) [1, ...
Created by Dr. Xi on September 29, 2008 23:05:12    Last update: September 29, 2008 23:06:16
These variables are set or used by the Unix shell to modify its behavior. Variable Description ENV=file Name of script that gets executed at startup; Usually, ENV=$HOME/.kshrc FCEDIT=file Editor used by fc (fix command) command. If $FCEDIT is not defined, use $EDITOR, otherwise use the default (vi or ed). FPATH=dirs Directories to search for function definitions; undefined functions are set via typeset -fu . FPATH is searched when these functions are first referenced. HISTFILE=file File in which to store command history. Default is $HOME/.sh_history for Korn shell, $HOME/.bash_history for Bash. If not set, history is lost after logout. HISTSIZE=n Max number of commands to keep in history. HOME=dir Home directory; set by login from passwd file. IFS='chars' Internal field separators. Default is space, tab, and...
Created by Dr. Xi on December 12, 2007 20:30:01    Last update: December 12, 2007 20:32:23
This is a script to tail a log file through the web browser. It uses AJAX, apache web server, mod_python, UNIX utilities tail (requires the --lines switch) and wc . The log file may reside on the web server or any other host accessible from the web server through SSH. Although it's written in python, it should be easy to port to other languages such as Perl. Apache httpd.conf : LoadModule python_module modules/mod_python.so ... Python script: import time, os from os.path import basename ...