Notes by Dr. Xi

Displaying notes 11 - 20
Created by Dr. Xi on November 11, 2011 10:05:22    Last update: November 11, 2011 10:12:01
This is an HTML image tag filter using Java regex. It takes a string, finds the img tags, replaces the src attribute with one provided by the filter, then adds a class name to the class attribute. import java.util.regex.*; import java.io.*; ... Test file: <div id="HTML snippet"> <img src="img/big/txt-m...
Created by Dr. Xi on February 12, 2010 22:52:27    Last update: November 08, 2011 19:48:09
For Tomcat 6, there's no default manager username and password. You do have to set it up yourself, though it's pretty straightforward. The Tomcat manager webapp is restricted to users with a role named manager . So you'll need to create a user and assign the manager role to it. Edit $CATALINA_BASE/conf/tomcat-users.xml to read: <?xml version='1.0' encoding='utf-8'?> <!-- ... For tomcat 7: <tomcat-users> <role rolename="manager"/> ...
Created by Dr. Xi on October 22, 2011 14:34:17    Last update: October 22, 2011 14:34:33
JDK version and corresponding class version numbers: JDK Version Class Version 1.0 45.3 1.1 45.3 1.2 46.0 1.3 47.0 1.4 48.0 1.5 49.0 1.6 50.0
Created by Dr. Xi on September 30, 2011 15:34:47    Last update: September 30, 2011 15:34:47
A naive try would be something like this: $ nc -l 8082 | nc remote_host 80 Yes, it does forward the request from local port 8082 to remote_host:80 , but the response is dumped to stdout , not routed back to the client as expected. Using a named pipe makes it work: $ mkfifo backpipe $ nc -l 8082 0<backpipe | nc ... Use tee to get a glimpse of the response through the pipe (I wasn't able to find a way to dump the request): $ nc -k -l 8082 0<backpipe | nc localhost 80 | tee... The GNU netcat has a different syntax than the stock nc . It also supports different switches. To listen to port 1234: $ netcat -l -p 1234...
Created by Dr. Xi on September 24, 2011 20:59:16    Last update: September 24, 2011 21:00:20
To import source from my-project into the svn repository: $ svn import my-project/ file:///home/drxi/work/sv... List the contents of the repository: $ svn ls file:///home/drxi/work/svn-repository/ ... List the contents of the newly imported project: $ svn ls file:///home/drxi/work/svn-repository/my-...
Created by Dr. Xi on September 24, 2011 20:45:14    Last update: September 24, 2011 20:52:48
Use the svnadmin command to create a new svn repository: $ svnadmin create ~/work/svn-repository $ ls sv... There's no need to do " mkdir ~/work/svn-repository ", svnadmin will create it if it doesn't exist.
Created by Dr. Xi on September 19, 2011 16:15:19    Last update: September 19, 2011 16:15:19
By default, svn recursively adds new files into the repository: $ svn add * But you have to use " * ", using the dot (current directory) does not work (most likely the current directory is already versioned): $ svn add .
Created by Dr. Xi on September 19, 2011 11:56:42    Last update: September 19, 2011 11:57:26
It is well known that with the -D switch you can turn an ssh session into a socks proxy: ssh -D localhost:8080 remote_user@remote_host Now configure your browser to use " localhost:8080 " as a socks proxy and your web traffic is routed through remote_host via an ssh tunnel. But sometimes you encounter an error message like this: Disconnecting: Bad packet length - 1416586337 This is because sometimes, the ssh session outputs some "welcome" message into the tunnel, polluting the protocol stream between the client and the remote host. A safer way to establish an ssh socks proxy would be: ssh -N -D localhost:8080 remote_user@remote_host
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 Dr. Xi on August 25, 2011 08:41:36    Last update: August 25, 2011 08:41:36
There is no switch statement in Python. PEP 3103 is in rejected status. Use the " if..elif.. " struct instead: r = i % 5 if r == 0: print "V: ", l ...
Previous  1 2 3 4 5 6 7 8 9 10 Next