Recent Notes
Displaying keyword search results 51 - 60
Created by Dr. Xi on January 07, 2010 23:40:28
Last update: February 09, 2010 03:24:35
This is a utility to generate SQL insert statements for Oracle for one table, or a set of tables. It doesn't cover all possibilities but should be good enough for most cases.
import java.io.*;
import java.sql.*;
import ...
To generate insert statements for multiple tables, simply put the table names in a file, one per line, and use the -f switch.
Created by Dr. Xi on January 29, 2010 21:08:43
Last update: January 29, 2010 21:08:43
This class reads a text file line by line and echos the contents to standard out.
import java.io.*;
public class ReadTextFile...
Created by woolf on December 28, 2009 00:11:20
Last update: January 15, 2010 04:01:46
From http://www.videohelp.com/tools/MJPEG_Tools :
A sample command line to deinterlace dv footage, give a slight film look, pass it through a Spatial-Pre-Filter, Temporal-Noise-Filter, and a Spatial-Post-Filter, then encode to DVD complient mpeg2 video looks like this -
lav2yuv capture.dv | yuvdeinterlace -f | yuvdenois...
From http://www.linux.com/archive/feature/40069 , the actual video file can be used in place of edit list (eli) file:
# de-noice the video and scale for DVD output
l...
Created by Dr. Xi on January 08, 2010 03:53:37
Last update: January 08, 2010 03:54:56
This is an Ant custom task to merge Properties files I lifted from http://marc.info/?l=ant-user&m=106442688632164&w=2 , with some minor bug fixes.
Example usage:
<taskdef name="mergeProperty" classname="ant.task....
Implementation:
package ant.task.addon;
import java.io.Buff...
Created by Dr. Xi on November 19, 2008 00:22:27
Last update: January 07, 2010 23:00:36
There is a open source project named [ini4j] for processing Windows .ini configuration files. However, I found it an overkill for my purposes. So here is my simple implementation of a .ini parser. It mimics the standard java.util.Properties class with enhancements to get and set properties by section name. There are only a few simple rules: Leading and trailing spaces are trimmed from section names, property names and property values. Section names are enclosed between [ and ] . Properties following a section header belong to that section Properties defined before the appearance of any section headers are considered global properties and should be set and get with no section names. You can use either equal sign ( = ) or colon ( : )...
Created by Dr. Xi on January 04, 2010 05:04:10
Last update: January 07, 2010 15:59:25
This is the error:
>>> import urllib2
>>> f = urllib2.urlopen('htt...
Reason: SSL is not supported in Python installation.
>>> import httplib
>>> hasattr(httplib, 'HTTPS'...
Solution: recompile Python with SSL on
Steps:
Download and install OpenSSL , if you don't have it already.
Download Python source and rebuild Python (the usual steps of configure, make and make install). Python's configure script should be able to pick up your existing SSL libraries automatically and build a shared library _ssl.so.
Some web sites suggest editing the file Modules/setup.dist , uncomment the lines starting with _ssl , and making changes to the SSL path. This would link the SSL library statically to Python.
# Socket module helper for socket(2)
#_socket s...
Created by Dr. Xi on January 02, 2010 16:37:13
Last update: January 02, 2010 16:37:57
Use the del operator to delete one key, or clear method to delete all keys:
>>> d = { 'a': 1, 'b': 2, 'c' : 3 }
>>> del d['...
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 |") ...
But the code breaks when the file name contains a space:
# This does not work!
$file = "yes space.txt";
...
On Windows, these don't work either:
# This does not work!
$file = "yes space.txt";
...
You need to use a technique called Safe Pipe Opens :
$file = "yes space.txt";
$prog = "cat";
...
Created by Dr. Xi on December 04, 2009 04:44:40
Last update: 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
Last update: 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...