Recent Notes
Displaying keyword search results 1 - 10
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 Fang on January 16, 2012 19:32:20
Last update: January 16, 2012 19:32:54
You can submit a form via Ajax by the jQuery Form Plugin . There are two main methods:
ajaxForm : prepares a form for Ajax submit.
Example:
$('#myFormId').ajaxForm({
target: ...
When the form is submitted, it is sent via Ajax.
ajaxSubmit : submit a form via Ajax.
Example:
$('#myForm2').submit(function() {
// i...
jQuery Form Plugin is not in the core jQuery API, so you have to include an additional JS file:
<head>
<script type="text/javascript" ...
Created by jinx on May 03, 2011 11:43:26
Last update: May 03, 2011 11:43:26
The PHP function strval returns the string value of a variable. It does the same thing as casting a variable to string, or automatic conversion where string is expected.
Conversion rules:
Type String Value
Boolean TRUE '1'
Boolean FALSE '' (empty string)
integer of float string representing the number
Array The string 'Array'
Object Result of __toString() if defined, error otherwise
Resource 'Resource id #n' , where n is a number assigned to the resource.
NULL '' (empty string)
Example:
<?php
set_error_handler(function($errno, $errst...
Results:
bool(true)
---------------------
strval: '1'...
Created by jinx on April 29, 2011 13:43:13
Last update: April 29, 2011 13:44:34
List of functions testing variable type:
Function Description
is_bool Finds out whether a variable is a boolean
is_double Alias of is_float()
is_float Finds whether the type of a variable is float
is_int Find whether the type of a variable is integer
is_integer Alias of is_int()
is_long Alias of is_int()
is_null Finds whether a variable is NULL
is_numeric Finds whether a variable is a number or a numeric string
is_object Finds whether a variable is an object
is_real Alias of is_float()
is_scalar Finds whether a variable is a scalar
is_string Find whether the type of a variable is string
Test code:
<?php
class A {
}
$a = ar...
Output:
var_dump: int(1)
-------------------------
i...
Created by jinx on April 28, 2011 14:32:58
Last update: April 28, 2011 14:32:58
Use the is_array function to find out if a variable is array.
<?php
$a = array(
'1' => 'Apple',
...
Created by jinx on April 25, 2011 13:52:47
Last update: April 25, 2011 13:53:05
The PHP function isset determines if a variable is assigned a value. It returns TRUE if a variable is set and not NULL .
Example:
<?php
$a = "not empty";
$b = '';
// t...
A nice little function to assign a default value if a value is not given:
<?php
function isset_or(&$check, $alternate = N...
Created by jinx on April 25, 2011 12:43:40
Last update: April 25, 2011 12:43:40
Use the PHP function method_exists to check if the class or object has a certain method. It returns TRUE if the method exists (even when the value of the property is NULL), FALSE if the method does not exist.
Example:
<?php
class A {
var $p = 'A property';
...
Outputs:
Class A has method f1: bool(true)
Object $a has...
Also note that C++-like method overloading does not exist in PHP. Thus there's no ambiguity about which version of the method exists, i.e., with no argument, with one argument... etc. The following code generates Fatal error:
<?php
class A {
var $p = 'A property';
...
Created by jinx on April 25, 2011 11:50:09
Last update: April 25, 2011 11:51:53
Use the PHP function property_exists to check if the class or object has a certain property. It returns TRUE if the property exists (even when the value of the property is NULL), FALSE if the property does not exist, or NULL in case of an error.
Example:
<?php
class A {
var $p = 'A property';
...
Outputs:
Class A has property $p: bool(false)
Class A ha...
Created by jinx on April 10, 2011 14:14:29
Last update: April 10, 2011 14:14:46
The count function can be used to get the length of a PHP array. In PHP, there's no difference between an array with integer indexes and a map with string keys. Strings and integers are used interchangeably, '100' and 100 are the same when used as keys to an (associative) array.
sizeof is an alias of count .
<?php
$a[100] = '100';
echo "Length of \$a: ...
Outputs:
Length of $a: 1
Length of $a: 2
Length of $a...
Created by jinx on April 05, 2011 11:42:51
Last update: April 05, 2011 11:42:51
Use the ip2long function to check IP address range in PHP. The following code checks to see if an IP address falls in the private network ranges:
#!/usr/bin/php
<?php
function is_private_ip(...