Recent Notes
Displaying keyword search results 1 - 10
Created by James on May 03, 2012 14:54:46
Last update: May 03, 2012 14:54:46
History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. For HTML4 browsers it will revert back to using the old onhashchange functionality. All major browsers are supported.
This is a simple test page to get started:
<html>
<head>
<title>Test History</title>
...
Note: state url must be provided for IE to generate a unique hash. YOu can prefix the state url with '?' ('#' does not work).
Created by Fang on November 12, 2011 21:03:03
Last update: November 12, 2011 21:03:03
Experts may disagree but I found it absolutely stunning that JSF EL does not provide an operator for string concatenation. The Java "+" operator is there for the take. Java, which is a strongly typed compiled language, overloads the "+" operator in such a way that any object can be concatenated with a string. But JSF EL, which definitely isn't as strongly typed as Java, restricts the "+" operator to numerical values only! Of course, experts may argue that the "+" operator overloading is a huge design flaw of the Java language. But even so, JSF EL is not the right place to fix it! In some cases, a concatenation operator isn't needed, for example:
<ui:repeat var="tab" value="#{tabs}"> <img ... But in case the concatenated...
Created by James on October 25, 2011 19:44:30
Last update: October 25, 2011 19:45:40
jQuery automatically maps HTML5 custom data attributes to data storage associated with the data() method. Here's an example:
<html>
<head>
<script type="text/javascript"...
Created by jinx on April 26, 2011 09:33:17
Last update: April 26, 2011 09:33:17
PHP arrays may be combined together with the array_merge function or the array union operator ' + '. But they give different results:
array_merge re-assigns index to numerical keys. It keeps both items when two values are indexed to the same numerical key in the original arrays.
The union operator does not change array indexes, numerical or not.
When same index appears in both original arrays, array_merge overwrites the value of the first array by the second array. The union operator ( + ) keeps the value in the first array.
Example:
<?php
$a1 = array(
'1' => 'Apple',
...
Output:
Using array_merge;
array(5) {
[0]=>
s...
Created by jinx on April 16, 2011 13:26:22
Last update: April 16, 2011 13:26:22
The function is uksort .
Example:
<?php
$a = array(
"a" => "Apple",
"O" ...
Outputs:
array(4) {
["a"]=>
string(5) "Apple"
...
Created by jinx on April 05, 2011 12:06:06
Last update: April 05, 2011 12:08:12
This is from Stackoverflow . It takes care of various possible headers set by proxies. Pretty neat!
<?php
function get_ip_address()
{
for...
Created by Dr. Xi on September 10, 2010 22:53:42
Last update: September 10, 2010 22:54:06
The sort operation for a Python list sorts a list in place . It takes three optional arguments to control the comparisons:
s.sort([cmp[, key[, reverse]]]) cmp specifies a custom comparison function of two arguments (list items) which should return a negative, zero or positive number depending on whether the first argument is considered smaller than, equal to, or larger than the second argument: cmp=lambda x,y: cmp(x.lower(), y.lower()) . The default value is None . key specifies a function of one argument that is used to extract a comparison key from each list element: key=str.lower . The default value is None . reverse is a boolean value. If set to True , then the list elements are sorted as if each comparison were reversed. Python 2.7 (r27:82525, Jul 4 2010, 09:01:59) [MSC...
Created by James on June 22, 2010 19:09:07
Last update: June 22, 2010 19:09:50
The first form iterates over a jQuery object and executes a function for each matched element. This is an example from jQuery documentation:
<!DOCTYPE html>
<html>
<head>
<style>
...
The second form iterates over a general collection (examples from jQuery documentation):
$.each([52, 97], function(index, value) {
al...
Created by Dr. Xi on May 02, 2009 21:25:35
Last update: May 02, 2009 22:07:40
Use the built-in dict function:
>>> dict([(1,2), (3,4), (5,6)])
{1: 2, 3: 4, 5:...
Or, if you have a list with even number of elements and want to use the odd numbered elements for key and even numbered elements for value:
>>> a = [ 'a', 1, 'b', 2, 'c', 3 ]
>>> dict([(a...
Created by Dr. Xi on March 24, 2009 23:40:51
Last update: March 24, 2009 23:41:34
The DECODE function is used to decode a key to a value , returning the default value if one is provided. It returns null if there's no match for keys and no default value is provided.
select DECODE(&quarter_id, '1', 'Spring', '2',...