Recent Notes
Displaying notes 41 - 50
Created by James on June 30, 2010 19:04:45
Last update: July 03, 2010 21:24:33
Technically, file upload cannot be handled by Ajax, because XMLHttpRequest (XHR) does not handle file inputs. All techniques not using Flash rely on an invisible iframe as the upload form submit target. JavaScript then grabs the response content from the iframe and present it, giving the same illusion as Ajax. webtoolkit AIM The technique by webtoolkit is very simple. It involves 3 simple steps: include the AIM script, implement the start/finish JavaScript functions, and add an onsubmit handler to the normal file upload form. The hooked up form looks like: <head> <script type="text/javascript" src="webtoolkit.aim.js"></script> <script type="text/javascript"> function startCallback() { // make something useful before submit (onStart) return true; } function completeCallback(response) { // make something useful after (onComplete) // response is the innerHTML of the ...
Created by James on June 29, 2010 19:11:54
Last update: July 23, 2010 21:23:24
import java.util.Random; public class GenerateRandomString { private static final int MIN_LENGTH = 5; private static final int MAX_LENGTH = 25; private static final String[] PARTS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz".split(""); public static void main(String[] args) { int length = 0; // random length string if (args.length > 0) { try { length = Integer.parseInt(args[0]); } catch (Exception e) { System.out.println("String length is not a number"); } } System.out.println(generateRandomString(length)); } private static String generateRandomString(int length) { Random generator = new Random(); if (length == 0) { length = MIN_LENGTH + generator.nextInt(MAX_LENGTH - MIN_LENGTH); } String s = ""; for (int i = 0; i < length; i++) { s += PARTS[generator.nextInt(PARTS.length - 1) + 1]; } return s; } }
Created by voodoo on June 29, 2010 15:08:16
ALTER TABLE PatchInfo ADD CONSTRAINT FileNameKey_UK UNIQUE (FileNameKey);
Created by voodoo on June 29, 2010 14:52:45
ALTER TABLE MyTable RENAME OldColumn TO NewColumn; -- or, with ONLY ALTER TABLE ONLY MyTable RENAME OldColumn TO NewColumn; If ONLY is not specified, the table and all its descendant tables (if any) are updated.
Created by voodoo on June 25, 2010 16:41:17
Last update: June 25, 2010 16:44:40
rdesktop is the Linux equivalent of mstsc on Widnows. To install rdesktop on Fedora, enter: yum install rdesktop To start rdesktop in full screen mode: rdesktop -f remote_host_name To toggle full screen mode, use key combination: Ctrl+Alt+Enter.
Created by James on June 24, 2010 22:04:19
Start with this page: <!DOCTYPE html> <html> <head> <title>jQuery UI Dialog</title> </head> <body> <form> <div id="dialog" title="Dialog Form Test"> <div class="input"> <label for="field1">Field 1</label> <input name="field1" type="text"> </div> <div class="input"> <label for="field2">Field 2</label> <input name="field2" type="text"> </div> <input type="submit" value="Submit"> </div> </form> </body> </html> When you click "Submit", the form submits fine. Now turn the form to a jQuery dialog: <head> <title>jQuery UI Dialog</title> <link rel="stylesheet" type="text/css" media="all" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/ui-darkness/jquery-ui.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"> </script> <script type="text/javascript"> $(function() { $("#dialog").dialog({ autoOpen: true, height: 220, width: 300 }); }); </script> </head> When you click "Submit", the form no longer submits! Why? When you convert the contents of the form into a dialog, the form becomes empty! The "Submit" button is no longer associated with ...
Created by magnum on June 23, 2010 22:24:01
Required: Apache web server mod_proxy_html proxy_html.conf: # Load mod_proxy_html required SOs LoadFile /usr/local/lib/libxml2.so LoadModule proxy_html_module modules/mod_proxy_html.so LoadModule xml2enc_module modules/mod_xml2enc.so # All knowledge of HTML links has been removed from the mod_proxy_html # code itself, and is instead read from httpd.conf (or included file) # at server startup. So you MUST declare it. This will normally be # at top level, but can also be used in a <Location>. # # Here's the declaration for W3C HTML 4.01 and XHTML 1.0 ProxyHTMLLinks a href ProxyHTMLLinks area href ProxyHTMLLinks link href ProxyHTMLLinks img src longdesc usemap ProxyHTMLLinks object classid codebase data usemap ProxyHTMLLinks q cite ProxyHTMLLinks blockquote cite ProxyHTMLLinks ins cite ProxyHTMLLinks del cite ProxyHTMLLinks form action ProxyHTMLLinks input src usemap ProxyHTMLLinks head profile ProxyHTMLLinks base href ...
Created by magnum on June 23, 2010 20:42:12
Last update: June 23, 2010 20:52:33
Compile mod_proxy_html from source code. Prerequisite: Apache httpd installed on system with header files. Command: # /usr/local/apache2/bin/apxs -i -c -I/usr/local/include/libxml2 -I. -L/usr/local/lib mod_proxy_html.c Output: /usr/local/apache2/build/libtool --silent --mode=compile gcc -prefer-pic -DSOLARIS2=10 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT -D_LARGEFILE64_SOURCE -g -O2 -I/usr/local/apache2/include -I/usr/local/apache2/include -I/usr/local /apache2/include -I/usr/local/include/libxml2 -I. -c -o mod_proxy_html.lo mod_proxy_html.c && touch mod_proxy_html.slo /usr/local/apache2/build/libtool --silent --mode=link gcc -o mod_proxy_html.la -L/usr/local/lib -rpath /usr/local/apache2/modules -module -avoid-version mod_proxy_html.lo /usr/local/apache2/build/instdso.sh SH_LIBTOOL='/usr/local/apache2/build/libtool' mod_proxy_html.la /usr/local/apache2/modules /usr/local/apache2/build/libtool --mode=install cp mod_proxy_html.la /usr/local/apache2/modules/ cp .libs/mod_proxy_html.so /usr/local/apache2/modules/mod_proxy_html.so chmod +x /usr/local/apache2/modules/mod_proxy_html.so cp .libs/mod_proxy_html.lai /usr/local/apache2/modules/mod_proxy_html.la cp .libs/mod_proxy_html.a /usr/local/apache2/modules/mod_proxy_html.a chmod 644 /usr/local/apache2/modules/mod_proxy_html.a ranlib /usr/local/apache2/modules/mod_proxy_html.a ---------------------------------------------------------------------- Libraries have been installed in: /usr/local/apache2/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the ...
Created by magnum on June 23, 2010 19:02:32
Last update: June 23, 2010 19:05:08
Get the public keys. The Apache HTTPD developer keys are available from: http://www.apache.org/dist/httpd/KEYS . Save the key file as KEYS . Import the keys into your keyring. The GPG ring is stored at $HOME/.gnupg/pubring.gpg . gpg --import KEYS Verify the signature. Using mod_proxy_html as example: C:\Downloads>gpg mod_proxy_html.zip.asc gpg: Signature made Fri Oct 30 10:26:26 2009 CDT using DSA key ID 40581837 gpg: Good signature from "Nick Kew <nick@webthing.com>" gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 4535 10BD A6C5 8556 24E0 0923 6D0B C73A 4058 1837 C:\Downloads>gpg --verify mod_proxy_html.zip.asc mod_proxy_html.zip gpg: Signature made Fri Oct 30 10:26:26 2009 CDT using DSA key ID 40581837 gpg: Good signature ...
Created by James on June 23, 2010 16:04:14
This is the page: <!doctype html> <html> <head> <title>UL Test</title> </head> <body> <div style="width:200px;margin:auto;clear:both;"> <ul style="list-style:disc outside none;padding:5px;margin-left:8px;"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> </div> </body> </html> When loaded in IE7, the bullets are not showing (they displayed fine in Firefox). It turned out that IE requires minimum left padding to display the bullets when the list-style is outside . Add 5px left padding: <ul style="list-style:disc outside none;padding:0px;padding-left:5px;margin-left:8px;"> IE displayed like this: Expand the left padding to 12px : <ul style="list-style:disc outside none;padding:0px;padding-left:12px;margin-left:8px;"> IE displays the bullets normally: