Recent Notes

Displaying keyword search results 1 - 10
Created by James on September 18, 2012 20:46:12    Last update: September 18, 2012 20:46:12
There's no easy way in jQuery (like one or two lines) to copy all CSS properties (inline, inherited, native, etc.) from one element to another. Such as, create a <p> element that has the same CSS as an existing <div> element. Upshots provides a simple jQuery plugin that seemed to work. I copy the code below. $.fn.copyCSS = function(source){ var dom = ...
Created by Dr. Xi on October 01, 2007 03:26:46    Last update: August 25, 2011 08:57:40
Use the sub function in the re module to do global replacement: import re re.sub(pattern, replacement, inpu...
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 James on March 03, 2011 20:50:51    Last update: March 03, 2011 20:51:54
This function parses the querystring and returns the query parameters as a map. It calls the string replace function with a function replacement and uses the side effects of the replacement function call to populate the parameter map. function getQueryParameters() { var result ...
Created by James on March 03, 2011 20:29:52    Last update: March 03, 2011 20:30:36
The general syntax for JavaScript string replace is: str.replace(regexp|substr, newSubStr|function[, |n... i.e., The substring to be replaced can be either a string or a regular expression (regex) The replacement string can be a string, or a function which returns the replacement. If the second parameter is a function, the function will be invoked after the match has been performed. The parameters passed to the function are: the matched (to be replaced) substring, the parenthesized submatch strings, offset of the match, and the whole string on which replace is being called. It can take an optional flags argument, but that's not standard . Examples: // replace apples with oranges // only the ...
Created by Dr. Xi on October 26, 2010 04:47:37    Last update: January 11, 2011 20:00:36
The code presented here is a simple implementation of a tab set. It is used to demo how a tab set could be implemented. The code is stand alone and does not depend on any JavaScript libraries. Multiple tab sets within the same page is supported. The HTML markup is fairly simple: Tabs sets are contained within a DIV element with class name "tabsContainer". Define a UL list for the tabs. Follow the UL list with equal number of DIVs for the tab contents. The Nifty Corners Cube technique is used to draw the rounded corners (original form, not the enhanced JavaScript form). HTML, CSS and JavaScript: <!doctype html> <html> <head> <style typ...
Created by Dr. Xi on September 11, 2008 22:55:01    Last update: January 11, 2011 19:48:19
<html> <head> <script language="JavaScript">...
Created by Dr. Xi on November 18, 2010 22:13:36    Last update: November 18, 2010 22:13:36
You can use the eval function to substitute a value defined by a variable. Suppose you have a string literal $a = 'a $string' and you want Perl to substitute $string with the value of the $string variable. This is normally not a problem. Because if you use double quote, Perl does the interpretation automatically: $string = 'theactual'; $a = "a $string"; pri... But this doesn't work if the value of $string isn't available when you define the template $a . In this case, you have to use single quote to preserve the template definition. But you can use eval to do the replacement when the value of $string becomes available: #!/usr/bin/perl $a = 'a $string'; $string = ...
Created by Dr. Xi on September 11, 2008 23:06:18    Last update: October 06, 2010 03:16:13
Firefox and Google chrome has native support for the trim function for a String. IE (as of IE 8.0) does not provide a trim function for String. Using the JavaScript Executor , if you execute: 'abcd '.trim you get: function trim() { [native code] } in Firefox and Google Chrome. But you get nothing in IE. If you try to execute the trim method on a String: 'abcd '.trim() you get this in IE: TypeError: Object doesn't support this property or... In order to have the trim function across all browsers, define this function: if(typeof String.prototype.trim !== 'function') { ... Or, if you use jQuery, you can use $.trim()
Created by Fang on August 17, 2010 21:08:13    Last update: August 17, 2010 21:08:13
JSTL string manipulation functions String manipulation functions are simple and self-evident. You just need to know that they exist. Test it Make these additions to the expanded test application : Create a new Java class StringManipulation : package jstl.demo.handler; import java.... Create a new JSP ( stringmanipulation.jsp ) under webapp : <%@ taglib uri="http://java.sun.com/jsp/jstl/c... Compile and package the WAR with: mvn package Deploy the WAR to a servlet container of your choice (for example, Tomcat or JBoss). Test the page with this URL (Tomcat/JBoss running on port 8080): http://localhost:8080/jstl-demo/demo/StringManipulation You may adjust the URL if your servlet container runs on a different port or the web app is bound to a different context root.
Previous  1 2 Next