Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on March 30, 2012 10:07:25    Last update: March 08, 2013 13:41:57
After a user resets a password, I want to force the user to change the password before she gets access to secured content. This is usually done with a servlet filter. But with Spring MVC, you can also use a HandlerInterceptor . According to Spring JavaDoc: HandlerInterceptor is basically similar to a Servlet 2.3 Filter, but in contrast to the latter it just allows custom pre-processing with the option of prohibiting the execution of the handler itself, and custom post-processing. Filters are more powerful, for example they allow for exchanging the request and response objects that are handed down the chain. Note that a filter gets configured in web.xml, a HandlerInterceptor in the application context. As a basic guideline, fine-grained handler-related preprocessing tasks are candidates...
Created by voodoo on February 02, 2013 12:29:56    Last update: February 02, 2013 12:29:56
I got this error while compiling ucspi-tcp . The solution was to move #include <errno.h> from error.c to error.h . The following also works: echo gcc -O2 -include /usr/include/errno.h > conf-... The reason was explained in http://cr.yp.to/docs/unixport.html#errno
Created by voodoo on January 11, 2013 09:36:27    Last update: January 11, 2013 09:39:03
Redsocks is a transparent socks/proxy redirector. You use iptables to redirect TCP traffic to redsocks, redsocks will forward to upstream SOCKS4, SOCKS5 or HTTPS proxy server. Once set up, the redirection is system wide, so you don't have to set up proxy for each individual application. It is useful when you have to use a SOCKS or proxy server to make the connection but the application does not support proxy settings (for example, the Android browser). Linux/iptables, OpenBSD/pf and FreeBSD/ipfw are supported. Sample configuration file : base { log_debug = off; log_info = off; ... According to the project home page , redsocks is used by ProxyDroid to provide system-wide proxy on rooted Android devices.
Created by Fang on January 04, 2013 14:35:14    Last update: January 04, 2013 14:35:41
You can use the runOrder parameter to control the test execution order for Maven surefire tests: <build> <plugins> <plugin> ... Other options are: Option Meaning alphabetical Alphabetical reversealphabetical Reverse Alphabetical random Randomized hourly alphabetical on even hours, reverse alphabetical on odd hours failedfirst Failed first will run tests that failed on previous run first, as well as new tests for this run. balanced Balanced is only relevant with parallel=classes, and will try to optimize the run-order of the tests to make all tests complete at the same time, reducing the overall execution time. filesystem This is the default. I guess this is the order returned by the file system: uncontrolled but deterministic.
Created by voodoo on September 25, 2012 19:33:02    Last update: September 25, 2012 19:33:02
This a step-by-step example of how to create the files for GNU automake. Put the C source file in directory src ( cat src/hello.c ): #include <config.h> #include <stdio.h> ... Run autoscan to generate configure.scan . Rename configure.scan : mv configure.scan configure.ac Edit autoscan.ac . Update this line: AC_INIT([FULL-PACKAGE-NAME], [VERSION] , [BUG-REP... Add this line after AC_INIT : AM_INIT_AUTOMAKE([foreign -Wall -Werror]) Add this line before AC_OUTPUT : AC_CONFIG_FILES([Makefile src/Makefile]) Create file Makefile.am ( cat Makefile.am ): SUBDIRS = src Create file src/Makefile.am ( cat src/Makefile.am ): bin_PROGRAMS = hello hello_SOURCES = hello.c Run these commands: $ aclocal $ autoheader $ automake --add-miss... The file configure is generated after autoconf is run. Build with: $ ./configure $ make Create tarball for distribution with: $ make dist...
Created by voodoo on September 25, 2012 19:10:19    Last update: September 25, 2012 19:10:19
Here is a list of the most useful targets that the GNU Coding Standards specify (from automake manual ). make all Build programs, libraries, documentation, etc. (same as make). make install Install what needs to be installed, copying the files from the package's tree to system-wide directories. make install-strip Same as make install, then strip debugging symbols. Some users like to trade space for useful bug reports... make uninstall The opposite of make install: erase the installed files. (This needs to be run from the same build tree that was installed.) make clean Erase from the build tree the files built by make all. make distclean Additionally erase anything ./configure created. make check Run the test suite, if any. make installcheck Check the installed programs...
Created by voodoo on August 15, 2012 11:23:44    Last update: August 15, 2012 11:23:44
By default Linux pipe output is buffered. For example, you can't see the most recent stdout on screen with tee : $ ./mycommand | tee /tmp/mycommand.log Here are two ways to make the pipe unbuffered. Method 1: use the unbuffer command from expect $ sudo apt-get install expect-dev $ unbuffer ./... Method 2: use stdbuf # Make output line buffered: $ stdbuf -oL ./myc...
Created by Dr. Xi on May 25, 2012 15:47:34    Last update: May 25, 2012 15:49:33
Steps to configure SSL for Apache HTTPD server on Windows: In Apache2.2/conf/httpd.conf , load mod_ssl and include httpd-ssl.conf : LoadModule ssl_module modules/mod_ssl.so ... In Apache2.2/conf/extra/httpd-ssl.conf , make sure the paths for the cert files point to the cert and key you want to use: # Server Certificate: # Point SSLCertificat... Start up Apache. If it fails, use the command line to see what the error is. There won't be any log in error.log if there are errors in the conf files: C:\Program Files (x86)\Apache Software Foundation\... I corrected the previous error by using the alternative line for SSLSessionCache : # Inter-Process Session Cache: # Configure ...
Created by Fang on March 05, 2012 20:32:37    Last update: March 05, 2012 20:32:37
In this simple example, I create a simple validating bean and create a JUnit test to test the validation. The bean ( src/main/java/com/example/Person.java ): package com.example; import javax.validatio... The test ( src/test/java/com/example/TestPerson.java ): package com.example; import java.util.Set; ... Run the test: mvn clean test You'll notice that one test passed and the other failed. The tests require that a person must have a name and the name cannot be empty, so @NotNull is not the right rule to use here. To make sure that the name is not empty, we need to use @Pattern . But since a null String matches any pattern, @NotNull is also needed: package com.example; import javax.validatio...
Created by voodoo on September 30, 2011 08:22:39    Last update: February 18, 2012 16:17:36
This iptables rule redirects all port 80 traffic from subnet 192.168.0.0/24 to 192.168.0.1 running HTTP proxy (say squid): /usr/sbin/iptables -t nat -A PREROUTING -s 192.168... Make any packets destined to port 3256 on firewall be NAT'ed to internal system server on port 80: iptables -t nat -I PREROUTING -s ! 192.168.2.0/24 ... To make internal web server work for clients from the internet, LAN and the firewall itself: Make all packets from the Internet going to port 80 on the firewall ( $INET_IP ) to be redirected (or DNAT'ed) to the internal HTTP server ( $HTTP_IP ): iptables -t nat -A PREROUTING --dst $INET_IP -p tc... SNAT the packets entering the firewall that are destined for $HTTP_IP (internal HTTP server) port 80 so that they...
Previous  1 2 3 4 5 6 7 8 9 10 Next