Recent Notes

Displaying keyword search results 1 - 10
Created by woolf on December 11, 2011 13:38:58    Last update: December 11, 2011 13:38:58
Install usb.essentials . Package usbutils is optional. # opkg update # opkg install kmod-usb2 # opk... Install usb printer support: # opkg install kmod-usb-printer Install p910nd print server: # opkg install p910nd Edit /etc/config/p910nd : config p910nd option device /dev... Configure firewall to allow port 9100 ( /etc/config/firewall ): # Allow printer con... If clients are connecting from wan then the first line should be: option src wan Enable automatic start of print server when router boots: #/etc/init.d/p910nd enable Restart router: # reboot
Created by magnum on June 20, 2011 20:32:38    Last update: June 20, 2011 20:32:38
Here, = prints line number followed by new line, N appends the next line of input into the pattern space . Print line number at beginning of line, followed by a space: sed = test.txt | sed 'N;s/\n/ /' Print line number at beginning of line, followed by a tab: sed = test.txt | sed 'N;s/\n/\t/' Print line number right adjusted with 6 leading spaces: sed = test.txt | sed 'N; s/^/ /; s/\(.\{6,\}\...
Created by Dr. Xi on April 20, 2011 21:44:15    Last update: May 02, 2011 20:56:58
The String.format() method provides versatile formatting capabilities. This tutorial tries to present these capabilities in a accessible manner. The format string A format string can contain zero, one, or more format specifiers . The general form of a format specifier is: %[argument_index$] [flags] [width] [.precision]co... where things in square brackets are optional, and conversion is a character indicating the conversion to be applied to the corresponding variable value. The only required characters in the format specifier is the percent sign % and the conversion character. A simple example: public static void simpleFormat() { System.out... The Argument index The argument index is specified by a number, terminated by the dollar sign $ . The same argument may be repeated multiple times in a format string. Unindexed...
Created by jinx on April 19, 2011 20:30:20    Last update: April 19, 2011 20:30:20
The PHP constant __FILE__ is the current file name, __LINE__ is the current line number. These can be helpful writing error logs. <?php // __LINE__ is the current line numbe... Outputs: Current file is C:\scrap\test2.php, current line n...
Created by jk34 on April 19, 2011 15:42:24    Last update: April 19, 2011 15:42:24
Check the __name__ variable to see if the Python module was invoked from the command line. The line prints when the Python script is called from the command line, but doesn't print when it is imported by another Python module with import MyModule . if __name__ == '__main__': print 'Invoked f...
Created by Dr. Xi on October 16, 2008 20:45:40    Last update: March 28, 2011 20:23:22
Java's built-in classes are way too complex/flexible for a simple protocol like HTTP. This is a wrapper to simplify HTTP GET and POST. import java.io.*; import java.net.*; imp... A simple test: import java.io.*; import java.util.*; ...
Created by Dr. Xi on March 28, 2011 11:11:33    Last update: March 28, 2011 11:13:21
grep is a versatile command with many variations (grep, egrep, fgrep, then various implementations). It uses a regula expression (regex) pattern to filter input. But then there are basic and extended flavors of regex - leading to even more confusion. And, beware that there are lots of bad examples of regex in the wild... There are two critical questions to ask when you use grep: which grep implementation are you using? what is the flavor of the regex? Here are some examples for gnu grep v2.7: # Find all numbers (no decimal point), basic regex... Use the -o flag to show only the matching part instead of the whole matching line: grep -o -E '\b[0-9]{2}\b' The good thing about the gnu grep is that it...
Created by Dr. Xi on February 28, 2011 12:29:19    Last update: February 28, 2011 12:30:40
The Unix shell passes these parameters to the shell script: Variable Meaning $* A single string representing all command line arguments separated by $IFS (internal field separator, usually a space) $@ A sequence of strings representing the command line arguments. $1,$2...$n $1 is the first argument, $2 is the second argument, and so on... $0 The name of the script itself. $# The number of arguments. Example shell script ( sharg.sh ): #!/bin/sh echo $# arguments passed to $0: $@ ... Output for ./sharg.sh "a b c d" : 1 arguments passed to ./sharg.sh: a b c d here ... Output for ./sharg.sh a "b c" d : 3 arguments passed to ./sharg.sh: a b c d here ...
Created by Dr. Xi on February 09, 2011 13:27:51    Last update: February 09, 2011 13:27:51
By the perldoc , use Module LIST; is exactly equivalent to: BEGIN { require Module; Module->import( LIST); } Because of the BEGIN block, use is executed immediately. Therefore, it is not suitable for lazy loading of modules at runtime. use does not work with a runtime variable: C:\>perl $cgi = "CGI"; require $cgi; prin... require works: C:\>perl $cgi = 'CGI'; require "${cgi}.pm"; ... Also, file extension is required if require is not passed a bareword: // this works require CGI; // so does th...
Created by Dr. Xi on September 10, 2010 20:52:32    Last update: September 10, 2010 20:52:32
Unlike PHP, in Python an array index must be integer (string is an array of characters): >>> s 'abcd12345' >>> s[1] 'b' >>> s['...
Previous  1 2 Next