Recent Notes

Displaying notes 71 - 80
Created by Dr. Xi on December 25, 2009 00:13:19
Use the in operator to find out if a Python array contains an object: >>> a = [1, 2, 3] >>> 1 in a True >>> 3 in a True >>> 5 in a False >>> '1' in a False >>>
Created by Dr. Xi on December 24, 2009 22:25:38    Last update: December 24, 2009 22:26:11
Use the urlparse [/url] module to parse a URL into parts. The urlparse function parses a URL into six components, returning a 6-tuple. This corresponds to the general structure of a URL: scheme://netloc/path;parameters?query#fragment >>> from urlparse import urlparse >>> parts = urlparse('http://www.google.com/search?hl=en&source=hp&q=python') >>> parts ('http', 'www.google.com', '/search', '', 'hl=en&source=hp&q=python', '') >>>
Created by voodoo on December 20, 2009 04:46:36    Last update: February 08, 2010 03:49:21
Cygwin comes with openssh and X Windows. You need to select these packages from the cygwin installation screen: openssh (Net) X-start-menu-icons (X11, optional) xinit (X11) xorg-server (X11 server) To start an X-enabled remote SSH session, you need to start the X server on the cygwin side first: startxwin then enter: ssh -Y user@network-address This allows you run X apps on cygwin, but you won't see your normal Linux desktop (gnome, KDE etc.). In order to see remote desktop, you need to run XDMCP (Display Manager Control Protocol, which isn't secure). It's a bit tricky to set up XDMCP over ssh.
Created by Dr. Xi on December 05, 2009 20:12:16    Last update: December 05, 2009 20:46:45
It's quite easy for Perl to open a pipe and read from it: $file = "nospace.txt"; open(IN, "cat $file |") or die "Can't open pipe: $!"; while (<IN>) { # read line into default varieble $_ print; # print defaut variable $_ } close IN; But the code breaks when the file name contains a space: # This does not work! $file = "yes space.txt"; open(IN, "cat $file |") or die "Can't open pipe: $!"; while (<IN>) { # read line into default varieble $_ print; # print defaut variable $_ } close IN; On Windows, these don't work either: # This does not work! $file = "yes space.txt"; open(IN, "cat \"$file\" |") or die "Can't open pipe: $!"; open(IN, "cat '$file' |") or die ...
Created by Dr. Xi on December 04, 2009 05:29:11
From Perldoc : The exec function executes a system command and never returns - use system instead of exec if you want it to return. It fails and returns false only if the command does not exist and it is executed directly instead of via your system's command shell. Since it's a common mistake to use exec instead of system , Perl warns you (if -w is set - but you always do that) if there is a following statement which isn't die , warn , or exit .
Created by Dr. Xi on December 04, 2009 04:44:40
From Perldoc : The special literals __FILE__, __LINE__, and __PACKAGE__ represent the current filename, line number, and package name at that point in your program. They may be used only as separate tokens; they will not be interpolated into strings. If there is no current package (due to an empty package; directive), __PACKAGE__ is the undefined value. The two control characters ^D and ^Z, and the tokens __END__ and __DATA__ may be used to indicate the logical end of the script before the actual end of file. Any following text is ignored. Text after __DATA__ may be read via the filehandle PACKNAME::DATA , where PACKNAME is the package that was current when the __DATA__ token was encountered. The filehandle is left open pointing to the ...
Created by Dr. Xi on December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after ...
Created by voodoo on November 28, 2009 17:27:16    Last update: January 26, 2010 03:46:20
Nothing describes this utility better than the utility's authors: This utility, which has the most comprehensive knowledge of auto-starting locations of any startup monitor, shows you what programs are configured to run during system bootup or login, and shows you the entries in the order Windows processes them. These programs include ones in your startup folder, Run, RunOnce, and other Registry keys. You can configure Autoruns to show other locations, including Explorer shell extensions, toolbars, browser helper objects, Winlogon notifications, auto-start services, and much more. Autoruns goes way beyond the MSConfig utility bundled with Windows Me and XP. http://technet.microsoft.com/en-us/sysinternals/bb963902.aspx
Created by voodoo on November 28, 2009 17:19:08
Windows XP Automatic Update automatically downloads WGA and tries to install it. You either let it install or click cancel every time you boot up. Fortunately it's pretty easy to stop the installation since it's a scheduled task: simply enter tasks into the Run box, then uncheck the Enabled checkbox for the WGASetup task.
Created by Dr. Xi on November 23, 2009 23:37:55    Last update: November 24, 2009 04:04:20
IE can be started from JScript as an ActiveX control. Create a file named start_ie.js with the following contents and run (from command line or Run box): var browser = new ActiveXObject("InternetExplorer.Application"); // the following two lines are not necessary. They are here just to show that you can associate // properties to the browser object. browser.putProperty("question", "123uiotuer4"); var q = browser.getProperty("question"); browser.visible = true; // default is false browser.navigate('http://www.google.com/search?q=' + q);
Previous  3 4 5 6 7 8 9 10 11 12 Next