Load File into String
11
Convert an irregular name=value pair string into a formatted array.
3
Given a string, you can return an Enum value
Originally found at http://codeproject.com/dotnet/EnumTips.asp?df=100&forumid=38264&exp=0&select=797671
Originally found at http://codeproject.com/dotnet/EnumTips.asp?df=100&forumid=38264&exp=0&select=797671
9
Fixed the regular expression to check for more strict requirements.
7
Need to GZip a file using Perl?
Use Compress::Zlib.
This is a simple perl script which creates a GZip file.
Use Compress::Zlib.
This is a simple perl script which creates a GZip file.
8
Is this file the same as that file? The files may or may not be binary. We could compare the modify dates, or the sizes. But, those are not very accurate to know if a file has really changed.
Introducing MD5 Checksum. We can feed the files into Digest::MD5 in binary mode.
This is a great way to do Incremental Backups.
This is also an easy way to verify checksums when downloading files from the internet which list their MD5 Checksums.
You'll need the Digest::MD5 Perl Module.
Introducing MD5 Checksum. We can feed the files into Digest::MD5 in binary mode.
This is a great way to do Incremental Backups.
This is also an easy way to verify checksums when downloading files from the internet which list their MD5 Checksums.
You'll need the Digest::MD5 Perl Module.
14
This function calculates how many lines will text occupy.
Example (simple):
$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus tincidunt posuere dolor";
$num_lines = how_many_lines(10, $string);
It accepts a third, optional, parameter $options, that allows you to change behaviour. $options should be array. Following configuration options are available:
'white_spaces' - default: array(' ', "\t") - array of chars, that should be treated as whitespace.
'new_lines' - default: array("\r\n", "\n") - array of strings, that should be treated as newlines. For example, for HTML you can set 'new_lines' => array('');
'force_line_breaks' - default: true - force wrapping, when the token is longer than width, or not. If set to false, and token cannot be fitted into $width, function will return false;
'callback' - default: null - callback function for determining character width. Must accept at least one parameter - $char
'callback_params' - default: array() - optional additional callback parameters
'char_widths' - default: null - associative array in a form $char => $width, which contains char width. If $char is not found in the array, it's width is defaulted to 0.
Example (simple):
$string = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus tincidunt posuere dolor";
$num_lines = how_many_lines(10, $string);
It accepts a third, optional, parameter $options, that allows you to change behaviour. $options should be array. Following configuration options are available:
'white_spaces' - default: array(' ', "\t") - array of chars, that should be treated as whitespace.
'new_lines' - default: array("\r\n", "\n") - array of strings, that should be treated as newlines. For example, for HTML you can set 'new_lines' => array('');
'force_line_breaks' - default: true - force wrapping, when the token is longer than width, or not. If set to false, and token cannot be fitted into $width, function will return false;
'callback' - default: null - callback function for determining character width. Must accept at least one parameter - $char
'callback_params' - default: array() - optional additional callback parameters
'char_widths' - default: null - associative array in a form $char => $width, which contains char width. If $char is not found in the array, it's width is defaulted to 0.
8
Copies files from nested folders into one source, flat directory.
13
Deletes all files of a certain extention from a folder.
7
Move a file quickly in java.
13
mattrmiller
in the normal GZIPOutputStream you can not et the compression level. I came across this little script tonight that allows you to set the compression level for GZIPOutputStream.









