Recent Notes

Displaying notes 31 - 40
Created by magnum on July 08, 2010 22:24:50    Last update: July 09, 2010 15:47:24
Start: [root@belo ~]# service sshd start Generating SSH2 RSA host key: [ OK ] Generating SSH1 RSA host key: [ OK ] Generating SSH2 DSA host key: [ OK ] Starting sshd: [ OK ] Stop: [root@belo ~]# service sshd stop Stopping sshd: [ OK ] Or: [root@belo ~]# /etc/init.d/sshd start Starting sshd: [ OK ] [root@belo ~]# /etc/init.d/sshd stop Stopping sshd: [ OK ] [root@belo ~]# Start sshd on boot: [root@belo ~]# chkconfig sshd on
Created by magnum on July 08, 2010 21:27:56
To redirect all HTTP traffic to HTTPS, add the Redirect directive to the HTTP VirtualHost: <VirtualHost _default_:80> Redirect permanent / https://www.example.com/ </VirtualHost> The general syntax is: Redirect [status] URL-path URL By the Apache httpd doc , any request beginning with URL-Path will return a redirect request to the client at the location of the target URL . However, the proxy directives does not seem to respect this rule. So it's best to place the proxy directives inside the HTTPS VirtualHost: <VirtualHost _default_:443> . . . ProxyRequests Off ProxyPass /tomcat http://127.0.0.1:8080/tomcat ProxyPassReverse /tomcat http://127.0.0.1:8080/tomcat . . . </VirtualHost>
Created by James on July 07, 2010 16:24:30
Select the last cell in a row for all rows: $('td:last', '#sessionsTable tr').each(function() { alert(this.innerHTML); }) Select the 3rd cell in a row for all rows: $('td:eq(3)', '#sessionsTable tr').each(function() { alert(this.innerHTML); })
Created by meiu on July 07, 2010 15:16:34    Last update: July 07, 2010 15:17:08
Example: <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <fmt:formatDate type="both" dateStyle="short" timeStyle="short" value="${notifyDateTime}"/> Full attributes: Attribute Meaning value Date object to be formatted type Format time only ('time'), date only ('date'), or both date and time ('both')? dateStyle Style to format date, e.g., default, short, long, full etc (c.f. JavaDoc for java.text.DateFormat) timeStyle Style for format time, e.g., default, short, long, full etc (c.f. JavaDoc for java.text.DateFormat) pattern User defined pattern, e.g., MM/dd/yyyy timeZone Which time zone to display the date for? var If the var attribute is specified, then a String value containing the formatted date is assigned to the named variable. Otherwise, the <fmt:formatDate> tag will write out the formatting results. scope When the var attribute is present, the scope attribute specifies the scope of the ...
Created by James on July 06, 2010 19:35:00
Java has built-in functions to get the basename and dirname for a given file path, but the function names are not so self-apparent. import java.io.File; public class JavaFileDirNameBaseName { public static void main(String[] args) { File theFile = new File("../foo/bar/baz.txt"); System.out.println("Dirname: " + theFile.getParent()); System.out.println("Basename: " + theFile.getName()); } } Results: C:\tmp>java JavaFileDirNameBaseName Dirname: ..\foo\bar Basename: baz.txt
Created by James on July 06, 2010 15:27:28
This example shows three jQuery icons with hover effects. <!DOCTYPE html> <html> <head> <title>jQuery UI Icons</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> <style type="text/css"> ul#icons li { cursor: pointer; float: left; list-style: none outside none; margin: 2px; padding: 4px; position: relative; } </style> <script type="text/javascript"> $(function() { $("#icons li") .mouseenter(function() { $(this).addClass('ui-state-hover'); }) .mouseleave(function() { $(this).removeClass("ui-state-hover"); }); }); </script> </head> <body> <div id="theContainer"> <ul id="icons"> <li class="ui-state-default ui-corner-all" title="Info"> <span class="ui-icon ui-icon-info"></span> </li> <li class="ui-state-default ui-corner-all" title="Upload"> <span class="ui-icon ui-icon-circle-arrow-n"></span> </li> <li class="ui-state-default ui-corner-all" title="Delete"> <span class="ui-icon ui-icon-circle-close"></span> </li> </ul> </div> </body> </html>
Created by voodoo on July 01, 2010 18:54:08
Problem: cannot connect to PostgreSQL server because of above error. Solution: add the host entries to the pg_hba.conf file: # TYPE DATABASE USER CIDR-ADDRESS METHOD # "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust # IPv4 remote connections: host all all 105.52.84.130/32 trust host all all 105.52.84.50/32 trust host all all 105.52.83.82/32 trust Reference for CIDR address: http://oav.net/mirrors/cidr.html
Created by voodoo on July 01, 2010 16:57:31
Use the pg_ctl command to start/stop/restart the PostgreSQL server: $ bin/pg_ctl -D /usr/local/pgsql/data -l logs/postgres.log start $ bin/pg_ctl -D /usr/local/pgsql/data stop $ bin/pg_ctl -D /usr/local/pgsql/data restart $ bin/pg_ctl -D /usr/local/pgsql/data status Environment variable PGDATA can be set in lieu of the -D switch.
Created by magnum on July 01, 2010 15:38:49    Last update: July 01, 2010 15:39:53
From Apache HTTPD docs: When acting in a reverse-proxy mode (using the ProxyPass directive, for example), mod_proxy_http adds several request headers in order to pass information to the origin server. These headers are: X-Forwarded-For The IP address of the client. X-Forwarded-Host The original host requested by the client in the Host HTTP request header. X-Forwarded-Server The hostname of the proxy server. Be careful when using these headers on the origin server, since they will contain more than one (comma-separated) value if the original request already contained one of these headers. For example, you can use %{X-Forwarded-For}i in the log format string of the origin server to log the original clients IP address, but you may get more than one address if the request passes through ...
Created by James on June 30, 2010 20:14:28    Last update: July 03, 2010 18:41:12
The HTML page <!DOCTYPE html> <html> <head> <title>jQuery File Upload without Flash</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> </head> <body> <form action="uploadFile.do" enctype="multipart/form-data" method="POST" onsubmit="startUpload();"> <input type="file" name="theUploadFile"> <input type="submit" name="submit" value="Upload"> </form> <div id="progress-bar"></div> </body> </html> Client Side Code // called before upload submit function startUpload() { $('#progress-bar') .progressbar() .data('uploadCompleted', false); window.setTimeout(uploadProgress, 1000); } // called every one second. Server side url uploadProgress.do returns // text: <bytes uploaded so far>/<file size>, e.g.: '1325/33387' function uploadProgress() { if ($('#progress-bar').data('uploadCompleted')) { $('#progress-bar').progressbar('destroy'); return; } $.ajax({ url: 'uploadProgress.do', cache: false, // this is important, otherwise there's no progress in IE! success: function(response) { var s = response.split('/'); $('#progress-bar').progressbar( 'option', 'value', 100*s[0]/s[1] ); } }); window.setTimeout(uploadProgress, 1000); } // called when ...
Previous  1 2 3 4 5 6 7 8 9 10 Next