Tuesday, December 15, 2009

Books: My Reading List

what am i reading at the moment? i guess everyone's got some kind of a list of books one currently reads or is interested in reading; the same goes for music, which albums to listen to or crave for, and also what movies one has seen and which ones one might consider to collect as DVD issues. here's my recent reading list:

Thomas Pynchon: Inherent Vice

Alex Halberstadt: Lonely Avenue: The Unlikely Life and Times of Doc Pomus
this title reminded my of the song i first heard on a Van Morrison record and only later on a Ray Charles album. touchingly written!

Mark Twain: The Complete Interviews (Studies in American Literary Realism and Naturalism)
very interesting reading; i didn't know that Mark Twain at his own time was popularly known as a humorist. in my youth i'd never consider his Adventures of Tom Sawyer and Huckleberry Finn as humorous literature.

Mark Twain: Bummel durch Deutschland
Mark Twain: Bummel durch Europe
i'm considering getting these about Mark Twain's travels through Germany and Europe. they will certainly make facinating reading about Europe at the time.

Mark Twain: Die Schreckliche Deutsche Sprache (the awful german language)
i haven't seen this one at local bookstores, but it definitely sounds like an inviting title after what i've read so far about Mark Twain.

J. R. Moehringer: The Tender Bar: A Memoir (Audio Book)
i'm not a big fan of audiobooks, i'd rather read; but this one i find interesting since it's being read by the author 'n' i guess he'd put the pronounciations appropriately there where he'd 've wished to highlight or obscure in this tender memoir.

tom.paine


PHP: list all files of a local directory

... i haven't written an article since march ... here's a short script.

the issue: i wanted to save a list of a music albums i'd converted from CD to mp3 format. to avoid typing it all out i got myself a little script to do the work for me at mouse click:

<pre>
<?php
define('DEFAULT_DIR','D(rive):\\MyFolder\\');
$dir = (isset($_GET['dir'])) ? $_GET['dir'] : DEFAULT_DIR;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo $file . "\n";
}
closedir($dh);
}
}
?>
</pre>


this code simply lists all files and folders of the MyFolder directory.

there was another code snippet i worked on: i wanted a list of the songtitles of a particular album without the .mp3 file extension; the code looks like this:

<?php
define('DEFAULT_DIR','D(rive):/MyFolder');
$dir = (isset($_GET['dir'])) ? $_GET['dir'] : DEFAULT_DIR;
?>
<html>
<head>
<title>List-All-Files : <?=$dir;?></title>
<script language="JavaScript" type="text/javascript">
<!--
function copyit(theField) {
var tempval=eval("document.linktable.list_table");
tempval.focus();
tempval.select();
therange=tempval.createTextRange();
therange.execCommand("Copy");
}
//-->
</script>
<style type="text/css">
<!--
body {font-family:'Trebuchet MS'; color:#AB0000;}
form {font-family:'Courier New', Courier; font-size: 12px;}
.button {font-family: Verdana, Helvetica, sans-serif; font-size: 11px; font-weight: bold; cursor: hand; color: #AB0000; margin-top: 3mm; border: 2px; border-color: #DDDDDD; border-style: outset; background-color: #FFFFFF; width: 150;}
.button1 {font-family: Verdana, Helvetica, sans-serif; font-size: 11px; font-weight: bold; cursor: hand; color: #AB0000; margin-top: 3mm; border: 2px; border-color: #DDDDDD; border-style: outset; background-color: #FFFFFF; width: 150;}
.button2 {font-family: Verdana, Helvetica, sans-serif; font-size: 11px; font-weight: bold; cursor: hand; color: #FFFFFF; margin-top: 3mm; border: 2px; border-color: #DDDDDD; border-style: outset; background-color: #AB0000; width: 150;}
-->
</style>
</head>
<body topmargin="0">
<center><h3><u><i>List-All-Files</i></u> : <?=$dir?></h3></center>
<form name="linktable">
<div><input class="button" type="button" value="COPY & PASTE" onclick="copyit();" onmouseover="this.className='button2'" onmouseout="this.className='button1'"></div><br>
<textarea style="width:875px; height:1000px; color:#FFFFFF; background-color:#AB0000;" name="list_table" readonly="readonly">
<?php
filesInDir($dir);
function filesInDir($tdir)
{
$dirs = scandir($tdir);
foreach($dirs as $file) {
if (($file == '.') || ($file == '..')) { }
elseif (is_dir($tdir.'/'.$file)) { filesInDir($tdir.'/'.$file); }
else { echo substr($file,0,strlen($file)-4)."\n"; } }
}
?>
</textarea>
</form>
</body>
</html>


this will list all files of the directory MyFolder minus the last 4 digits of the complete filename. of course if the file-extension would be .html it would still include the . (dot) in the filename; furthermore, this code displays the list in an easy to use copy and paste form field.

well, at least it's something, isn't it?

tom.paine