Recent Notes
Displaying keyword search results 1 - 10
Created by voodoo on August 07, 2012 12:02:33
Last update: August 07, 2012 12:02:33
This code snippet:
#include <time.h>
#include <stdio.h>
int...
generates warning at line 6:
tt.c: In function ‘main’:
tt.c:6:15: warning: i...
The problem was that the prototype for strptime was not included from time.h . Define _GNU_SOURCE or _XOPEN_SOURCE to get rid of the warning:
$ gcc -D_XOPEN_SOURCE -o tt tt.c
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 James on February 02, 2012 09:31:03
Last update: February 02, 2012 09:31:03
This is an example that adds a validation rule to jQuery validation:
// add a custom method
$.validator.addMethod("m...
Created by Fang on November 02, 2011 16:40:10
Last update: November 02, 2011 16:40:10
Facelet taglib schema from JavaServer Faces Spec 2.0:
<xsd:schema targetNamespace="http://java.sun.com/x...
Created by jinx on April 26, 2011 11:58:33
Last update: April 26, 2011 12:00:40
The PHP function array_unique removes duplicate values from arrays. It takes an optional parameter $sort_flags , which can be one of:
SORT_REGULAR : compare items normally (don't change types)
SORT_NUMERIC : compare items numerically
SORT_STRING : compare items as strings
SORT_LOCALE_STRING : compare items as strings, based on the current locale.
Example:
<?php
$a = array(
'1' => 'Apple',
...
Output:
array_unique results:
array(3) {
[1]=>
...
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 20, 2011 08:59:07
Last update: April 20, 2011 08:59:30
You get this warning when timezone is not set (which is the default):
PHP Warning: mktime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in test.php on line 8
To get rid of the warning message, set timezone in php.ini :
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;...
Created by Dr. Xi on April 19, 2011 16:01:39
Last update: April 19, 2011 16:01:39
This note relates to Python 2.x. A Python class is old-style by default, unless it has another new style class or the "top level" class object as its parent. The sure way to tell that an object is an instance of a new style class is to use the function type , type(x) returns <type 'instance'> for an old-style class, but it returns <class 'ClassType.X'> for a new-style class.
Class definition:
class A: # old style class
def __init__(sel...
Test session:
>>> A
<class ClassType.A at 0x7f36ae442fb0>
...
Created by jinx on April 10, 2011 21:15:46
Last update: April 10, 2011 21:23:04
When developing in PHP, it's frustrating to have errors in the code but no error message displays. According to the PHP manual, the display_errors setting controls whether errors are displayed. You can either change it in php.ini :
; This directive controls whether or not and where...
or set it in your code:
<?php
ini_set('display_errors', 'On');
fsdlf...
But when you have syntax errors in your code, the ini_set function may not even get a chance to execute. So the only reliable way is to set it in php.ini :
<?php
// nothing gets displayed when display_er...
Created by James on March 13, 2011 13:44:37
Last update: March 21, 2011 11:30:55
This is a jQuery input control that lets you enter any number of input rows of name and value pairs.
<!DOCTYPE html>
<html>
<head>
<title>jQu...