<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>the echothis blog &#187; Uncategorized</title>
	<atom:link href="http://blog.echothis.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.echothis.com</link>
	<description>HelloWorld() shouldn't be so hard</description>
	<lastBuildDate>Mon, 06 Sep 2010 15:35:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Startup errors with Plesk 9.5 on CentOS 5</title>
		<link>http://blog.echothis.com/2010/09/06/startup-errors-with-plesk-9-5-on-centos-5/</link>
		<comments>http://blog.echothis.com/2010/09/06/startup-errors-with-plesk-9-5-on-centos-5/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 13:19:51 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=403</guid>
		<description><![CDATA[When ordering a new VPS box from my hosting provider, I was pleased to see they had upgraded to Plesk 9.5.  However, I was disappointed to find out it wasn&#8217;t running automatically on https://MYIPADDRESS:8443/ (which obviously makes it impossible to log in and configure the first time).  So I rolled up my sleeves, SSH&#8217;ed in [...]]]></description>
			<content:encoded><![CDATA[<p>When ordering a new VPS box from my <a href="http://www.webkeepers.com">hosting provider</a>, I was pleased to see they had upgraded to Plesk 9.5.  However, I was disappointed to find out it wasn&#8217;t running automatically on <a href="https://MYIPADDRESS:8443/">https://MYIPADDRESS:8443/</a> (which obviously makes it impossible to log in and configure the first time).  So I rolled up my sleeves, SSH&#8217;ed in and got to work.</p>
<p>The first hint of  a problem was the Apache error I got when I tried to bounce plesk:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>root<span style="color: #000000; font-weight: bold;">@</span>tisailing ~<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #666666; font-style: italic;"># /usr/local/psa/admin/bin/websrvmng -a</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>httpd: error <span style="color: #000000; font-weight: bold;">while</span> loading shared libraries: libldap-2.3.so.0: cannot open shared object <span style="color: #c20cb9; font-weight: bold;">file</span>: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
websrvmng: get_apache_path: <span style="color: #ff0000;">'/usr/sbin/httpd -V'</span> failed
websrvmng: get_apache_path: <span style="color: #ff0000;">'/usr/sbin/httpd -V'</span> failed</pre></div></div>

<p>This was odd, but easy enough to fix:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum update</span>
<span style="color: #666666; font-style: italic;"># service psa restart</span></pre></div></div>

<p>Then at the link you get:<br />
<tt><br />
ERROR: PleskFatalException StatInfo-&gt;getProductVersion failed: file_get_contents() failed: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead 0: common_func.php3:146 psaerror(string 'StatInfo-&gt;getProductVersion failed: file_get_contents() failed: mktime() [function.mktime]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PDT/-7.0/DST' instead') 1: common_func.php3:66 getProductLoginVersion() 2: SP.php:101 ssoGetSpName() 3: SP.php:393 SsoSpConfig-&gt;load() 4: SP.php:215 SsoSpConfig-&gt;__construct() 5: SP.php:223 SsoSpConfig::getInstance() 6: SP.php:447 SsoSpConfig() 7: RelyingParty.php:19 isSsoEnabled() 8: auth.php3:185<br />
</tt></p>
<p>Uh, OK.  A bit of Googling yields <a href="http://sogoth.com/?p=135">this blog posting</a>, so add the proper OS and Plesk version strings to <tt>/usr/local/psa/version</tt> and restart Plesk via <tt>service psa restart</tt>.</p>
<p>Then the Plesk login screen at least comes up.  I ran into a number of non-blocking error messages (all related to the DNS configuration) as I created my administrator account so we&#8217;ll see if any of those come back to bite me later, but so far it seems to be behaving normally.</p>
<p>One thing I did notice, was that <tt>/etc/httpd/conf.d/php.conf</tt> was not properly set up to handle PHP scripts.  If you get a &#8220;download file&#8221; dialog, then change</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mime_module<span style="color: #000000; font-weight: bold;">&gt;</span>
    AddType application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php .php
    AddType text<span style="color: #000000; font-weight: bold;">/</span>html .php
    AddHandler application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php php
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>to</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_php<span style="color: #000000; font-weight: bold;">&gt;</span>
AddType application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php .php
AddHandler application<span style="color: #000000; font-weight: bold;">/</span>x-httpd-php .php
AddHandler application<span style="color: #000000; font-weight: bold;">/</span>php5-script .php
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/09/06/startup-errors-with-plesk-9-5-on-centos-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A simpler NamespaceFile engine for CakePHP 1.2</title>
		<link>http://blog.echothis.com/2010/09/04/a-simpler-namespacefile-engine-for-cakephp-1-2/</link>
		<comments>http://blog.echothis.com/2010/09/04/a-simpler-namespacefile-engine-for-cakephp-1-2/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 22:18:15 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=399</guid>
		<description><![CDATA[Using Cake, once you start working with a large number of data cache files, you see the limitation of storing them all in a single directory (which is the default FileEngine behavior). In my case I have a hierarchical Tree behavior on a model and rather than traverse the tree to find its path each [...]]]></description>
			<content:encoded><![CDATA[<p>Using Cake, once you start working with a large number of data cache files, you see the limitation of storing them all in a single directory (which is the default FileEngine behavior).  In my case I have a hierarchical Tree behavior on a model and rather than traverse the tree to find its path each time (which incurs a bunch of DB queries), I simply cache the array of its &#8220;branch&#8221; to save the work.  But this means I have a cache file for each node in the tree, and rapidly that gets to be a big number of files in app/tmp.</p>
<p>Frank de Graaf wrote<a href="http://bakery.cakephp.org/articles/view/efficient-caching-with-namespacefileengine"> an excellent drop-in upgrade of FileEngine</a> that lets you name the cache keys as namespaces, which get stored in different directories.  So you can, for example, delete a group of keys at once by deleting their directory.  He doesn&#8217;t recommend it for replacing your default FileEngine cache, but for specialized instances (like mine) it works great.  One change I did make to his class was to make it extend FileEngine rather than reimplement it like he does &#8211; this results in a very compact class that seems to work just as well, as far as I can tell.</p>
<p>To use it, I chose to activate it at runtime, just where I needed it, then switch back to the default.  E.g.,</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">...</span>
	<span style="color: #000000; font-weight: bold;">function</span> function_that_needs_this_cache_engine<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Use NamespaceFile cache engine, only for this</span>
		App<span style="color: #339933;">::</span><span style="color: #004000;">import</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Vendor'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'NamespaceFile'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		Cache<span style="color: #339933;">::</span><span style="color: #004000;">config</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> 
			<span style="color: #0000ff;">'engine'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'NamespaceFile'</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'duration'</span><span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'+1 year'</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'prefix'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'data.'</span> 
			<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
		Cache<span style="color: #339933;">::</span><span style="color: #004000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'namespace.cachename'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cache_value'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;+1 year&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">echo</span> Cache<span style="color: #339933;">::</span><span style="color: #004000;">read</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'namespace.cachename'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// revert to the normal cache engine</span>
		Cache<span style="color: #339933;">::</span><span style="color: #004000;">config</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'default'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'engine'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'File'</span><span style="color: #339933;">,</span> 
			<span style="color: #0000ff;">'path'</span>	<span style="color: #339933;">=&gt;</span>	ROOT <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> APP_DIR <span style="color: #339933;">.</span>  DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'tmp'</span>
			<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The class is here; put it in app/vendors/namespace_file.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #009933; font-style: italic;">/** 
 * Partial reimplementation of Cake's original FileEngine. This 
 * engine supports namespaces similar to: 
 * 
 * Cache::write('app.pictures.recent', $recentPictures, 'app'); 
 * Cache::write('app.pictures.top', $topPictures, 'app'); 
 * 
 * This namespacing allows deletion of parent namespaces like: 
 * 
 * Cache::delete('app.pictures', 'app'); 
 * 
 * The settings for this cache should be 
 * defined at the bottom of /config/bootstrap.php like the following: 
 * 
 * App::import('Vendor', 'NamespaceFile'); 
 * Cache::config('app', array('engine' =&gt; 'NamespaceFile', 'duration'=&gt; '+1 hour', 'prefix' =&gt; 'cake.'));
 * 
 * Place this file in APP/vendors/. 
 * 
 * WARNING: DO NOT USE AS YOUR APP'S DEFAULT CACHE! 
 * 
 * @author Frank de Graaf (Phally) 
 * @link http://www.frankdegraaf.net 
 * @license MIT license 
 * 
 * // Modified 9/4/10 by echothis - Changed to extend FileEngine, resulting in a much simpler class
 */</span> 
<span style="color: #000000; font-weight: bold;">class</span> NamespaceFileEngine <span style="color: #000000; font-weight: bold;">extends</span> FileEngine <span style="color: #009900;">&#123;</span> 
&nbsp;
	<span style="color: #009933; font-style: italic;">/** 
	 * Write data for key into cache 
	 * 
	 * @param string $key Identifier for the data 
	 * @param mixed $data Data to be cached 
	 * @param mixed $duration How long to cache the data, in seconds 
	 * @return boolean True if the data was succesfully cached, false on failure 
	 * @access public 
	 */</span> 
	<span style="color: #000000; font-weight: bold;">function</span> write<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$duration</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #000088;">$writable</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__setKey<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_a</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$writable</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'File'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__init <span style="color: #339933;">||</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">===</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span> 
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$writable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">exists</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #000088;">$writable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Folder</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__getFolderPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			<span style="color: #000088;">$writable</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span> 
		parent<span style="color: #339933;">::</span><span style="color: #004000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$duration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #009933; font-style: italic;">/** 
	 * Get absolute file for a given key 
	 * 
	 * @param string $key The key 
	 * @return mixed Absolute cache file for the given key or false if erroneous 
	 * @access private 
	 */</span> 
	<span style="color: #000000; font-weight: bold;">function</span> __getPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">settings</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> DS<span style="color: #339933;">,</span> <span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #009933; font-style: italic;">/** 
	 * Get absolute folder for a given key 
	 * 
	 * @param string $key The key 
	 * @return mixed Absolute cache file for the given key or false if erroneous 
	 * @access private 
	 */</span>     
	<span style="color: #000000; font-weight: bold;">function</span> __getFolderPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__getPath<span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #009933; font-style: italic;">/** 
	 * Return the class (File/Folder) for a key. 
	 * 
	 * @param string $key The key 
	 * @return mixed File or Folder class for a key. 
	 * @access private 
	 */</span>     
	<span style="color: #000000; font-weight: bold;">function</span> __setKey<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__setPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__getPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #009933; font-style: italic;">/** 
	 * Return the class (File/Folder) for a path. 
	 * 
	 * @param string $path The path 
	 * @return mixed File or Folder class for a path. 
	 * @access private 
	 */</span>         
	<span style="color: #000000; font-weight: bold;">function</span> __setPath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__File<span style="color: #339933;">-&gt;</span><span style="color: #004000;">Folder</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cd</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #000088;">$object</span>  <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__File<span style="color: #339933;">-&gt;</span><span style="color: #004000;">Folder</span><span style="color: #339933;">;</span> 
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$object</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span> 
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__File<span style="color: #339933;">-&gt;</span><span style="color: #004000;">path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$path</span><span style="color: #339933;">;</span> 
		<span style="color: #000088;">$object</span>  <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__File<span style="color: #339933;">;</span> 
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$object</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> 
&nbsp;
	<span style="color: #009933; font-style: italic;">/** 
	 * Override the parents key method, so the keys don't get transformed 
	 * 
	 * @param string $key The key 
	 * @return mixed The key if one is passed else return false 
	 * @access public 
	 */</span> 
	<span style="color: #000000; font-weight: bold;">function</span> <span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span> 
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/09/04/a-simpler-namespacefile-engine-for-cakephp-1-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Chrome doesn&#8217;t like to stream</title>
		<link>http://blog.echothis.com/2010/08/10/google-chrome-doesnt-like-to-stream/</link>
		<comments>http://blog.echothis.com/2010/08/10/google-chrome-doesnt-like-to-stream/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 22:03:23 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=387</guid>
		<description><![CDATA[Often if you have a long-loading page,  you&#8217;ll want to stream the content as it arrives.  Firefox does a great job of aggressively rendering content, but other browsers like Google Chrome and IE don&#8217;t. A typical workaround for this is to first &#8220;wake up&#8221; the browser, then periodically flush the output buffer &#8211; this has [...]]]></description>
			<content:encoded><![CDATA[<p>Often if you have a long-loading page,  you&#8217;ll want to stream the content as it arrives.  Firefox does a great job of aggressively rendering content, but other browsers like Google Chrome and IE don&#8217;t.</p>
<p>A typical workaround for this is to first &#8220;wake up&#8221; the browser, then periodically flush the output buffer &#8211; this has been known for awhile.  What&#8217;s less known, is that the textual content you&#8217;re sending actually matters as well (at least to Chrome and thus likely Safari).  E.g., a standard <a href="http://www.joeyrivera.com/2008/ob_start-ob_flush-flush-set_time_limit-give-user-feedback-during-execution">workaround</a> is this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// start output buffer</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">ob_get_level</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;printing...&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #990000;">str_pad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">ob_flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">usleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">30000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But what&#8217;s interesting is that this slight modification breaks it on Chrome:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// start output buffer</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">ob_get_level</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;printing...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">print</span> <span style="color: #990000;">str_pad</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">ob_flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">usleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">30000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Apparently Google engineers think &lt;br&gt;&#8217;s are important, but newline characters, not so much.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/08/10/google-chrome-doesnt-like-to-stream/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What to do if your ISP decides to block outgoing SSH requests</title>
		<link>http://blog.echothis.com/2010/08/03/what-to-do-if-your-isp-decides-to-block-outgoing-ssh-requests/</link>
		<comments>http://blog.echothis.com/2010/08/03/what-to-do-if-your-isp-decides-to-block-outgoing-ssh-requests/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 20:55:36 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=385</guid>
		<description><![CDATA[I run several websites on a leased VPS box and use WinSCP to SSH in. Suddenly a few days ago I got locked out, and got only “Connection Timeouts” when I tried to log in. First I figured this was due to my Norton Internet Security firewall suddenly getting confused. But disabling it, and the [...]]]></description>
			<content:encoded><![CDATA[<p>I run several websites on a leased VPS box and use WinSCP to SSH in.  Suddenly a few days ago I got locked out, and got only “Connection Timeouts” when I tried to log in.</p>
<ol>
<li>First I figured this was due to my Norton Internet Security firewall suddenly getting confused.  But disabling it, and the Windows Firewall, had no effect.</li>
<li>Then I tried resetting my router and flushing my DNS cache, which I knew was a long shot but worth a try.  Still no luck.</li>
<li>I tried SSH’ing in from another box on the internet and sure enough, got in right away (as did a friend of mine elsewhere and the VPS support people).  So this told me that Comcast (my ISP) had decided that traffic shaping was in my best interest (or at least theirs), and was thus blocking port 22 traffic to this particular box.  I should note that this server has no objectionable content on it (it’s actually for a few nonprofits I work with), I don’t transfer large files back and forth, or anything like that.  And also, this is an <strong>outgoing </strong>connection, <a href="http://nexus172.wordpress.com/2009/04/21/how-i-got-around-comcasts-blockade-of-ssh/">not an incoming one</a>, so it’s 100% within the Comcast terms of use anyway.</li>
</ol>
<p>This in mind, I logged into the server (via the other internet box) and set up sshd to run on a second, higher-number port by editing /etc/ssh/sshd_config:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
Port <span style="color: #000000;">22</span>
Port <span style="color: #7a0874; font-weight: bold;">&#91;</span>HIGH_NUMBER<span style="color: #7a0874; font-weight: bold;">&#93;</span>
...</pre></div></div>

<p>Then I bounced the sshd service and was able to log in on the new port.</p>
<p>This of course begs the question of what exactly Comcast is doing snooping on my network traffic and blocking connections without warning.  If I have a spare few hours to sit on the phone with their tech support, I intend to find out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/08/03/what-to-do-if-your-isp-decides-to-block-outgoing-ssh-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to restore a SQL Server database from a backup file</title>
		<link>http://blog.echothis.com/2010/07/15/how-to-restore-a-sql-server-database-from-a-backup-file/</link>
		<comments>http://blog.echothis.com/2010/07/15/how-to-restore-a-sql-server-database-from-a-backup-file/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 17:42:20 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=380</guid>
		<description><![CDATA[Recently I volunteered to port a website from ColdFusion/SQL Server to PHP and MySql.  But rather than getting the database snapshot as a SQL script, which would have been easy to migrate, I was given the database in the form of a SQL Server backup, which has two parts: an LDF log fie and an [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I volunteered to port a website from ColdFusion/SQL Server to PHP and MySql.  But rather than getting the database snapshot as a SQL script, which would have been easy to migrate, I was given the database in the form of a SQL Server backup, which has two parts: an LDF log fie and an MDF data file.</p>
<p>Now not being particularly skilled in SQL Server, I had to hunt around for what to do with this.  It turned out to be ultimately pretty easy.  Just install SQL Server 2008 via the Web Installer, reboot, and then launch the administration interface and run this SQL statement to import the backup file as a database:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">RESTORE <span style="color: #993333; font-weight: bold;">DATABASE</span> mydb <span style="color: #993333; font-weight: bold;">FROM</span> disk <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'C:<span style="color: #000099; font-weight: bold;">\\</span>path<span style="color: #000099; font-weight: bold;">\\</span>to<span style="color: #000099; font-weight: bold;">\\</span>mydb.bak'</span>
<span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #993333; font-weight: bold;">REPLACE</span><span style="color: #66cc66;">,</span> MOVE <span style="color: #ff0000;">'mydb_Dat'</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'C:<span style="color: #000099; font-weight: bold;">\\</span>Program Files<span style="color: #000099; font-weight: bold;">\\</span>Microsoft SQL Server<span style="color: #000099; font-weight: bold;">\\</span>MSSQL10.SQLEXPRESS<span style="color: #000099; font-weight: bold;">\M</span>SSQL<span style="color: #000099; font-weight: bold;">\\</span>DATA<span style="color: #000099; font-weight: bold;">\\</span>mydbdat.mdf'</span><span style="color: #66cc66;">,</span>
MOVE <span style="color: #ff0000;">'mydb_log'</span> <span style="color: #993333; font-weight: bold;">TO</span> <span style="color: #ff0000;">'C:<span style="color: #000099; font-weight: bold;">\\</span>Program Files<span style="color: #000099; font-weight: bold;">\\</span>Microsoft SQL Server<span style="color: #000099; font-weight: bold;">\\</span>MSSQL10.SQLEXPRESS<span style="color: #000099; font-weight: bold;">\\</span>MSSQL<span style="color: #000099; font-weight: bold;">\\</span>DATA<span style="color: #000099; font-weight: bold;">\\</span>mydblog.ldf'</span></pre></div></div>

<p>Then choose &#8220;Script to File&#8221; to output the database to an ordinary SQL script, which then can be imported into MySQL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/07/15/how-to-restore-a-sql-server-database-from-a-backup-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick steps to configure SSL encryption on a WAMP server</title>
		<link>http://blog.echothis.com/2010/07/10/quick-steps-to-configure-ssl-encryption-on-a-wamp-server/</link>
		<comments>http://blog.echothis.com/2010/07/10/quick-steps-to-configure-ssl-encryption-on-a-wamp-server/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 19:02:41 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=373</guid>
		<description><![CDATA[There are a number of guides for this on the web, all of varying accuracy.  These are the minimal steps I followed to get it working for development on a stock WAMP server installation: Enable ssl_module in the Apache module list Create the self-signed certificate keys as per Section 3 of http://tud.at/programm/apache-ssl-win32-howto.php3: cd c:\path\to\wamp\bin\apache\Apache2.2.11\conf &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>There are a number of guides for this on the web, all of varying accuracy.  These are the minimal steps I followed to get it working for development on a stock WAMP server installation:</p>
<ol>
<li>Enable ssl_module in the Apache module list</li>
<li>Create the self-signed certificate keys as per Section 3 of <a href="http://tud.at/programm/apache-ssl-win32-howto.php3">http://tud.at/programm/apache-ssl-win32-howto.php3</a>:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> c:\path\to\wamp\bin\apache\Apache2.2.11\conf
&nbsp;
<span style="color: #666666; font-style: italic;"># Set a PEM passphrase of 4 characters or more.  You can leave the challenge password blank.</span>
openssl req <span style="color: #660033;">-config</span> openssl.cnf <span style="color: #660033;">-new</span> <span style="color: #660033;">-out</span> my-server.csr
&nbsp;
<span style="color: #666666; font-style: italic;"># Set the &quot;Common Name&quot; to localhost, accepting the rest of the defaults.</span>
openssl rsa <span style="color: #660033;">-in</span> privkey.pem <span style="color: #660033;">-out</span> my-server.key
&nbsp;
openssl x509 <span style="color: #660033;">-in</span> my-server.csr <span style="color: #660033;">-out</span> my-server.cert <span style="color: #660033;">-req</span> <span style="color: #660033;">-signkey</span> my-server.key <span style="color: #660033;">-days</span> <span style="color: #000000;">365</span></pre></div></div>

</li>
<li>In your conf/extra/httpd-vhosts.conf, add this:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">### SSL</span>
<span style="color: #666666; font-style: italic;"># see http://www.modssl.org/docs/2.8/ssl_reference.html for more info</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># change this from &quot;sem&quot; to avoid startup errors</span>
SSLMutex default
&nbsp;
SSLRandomSeed startup <span style="color: #7a0874; font-weight: bold;">builtin</span>
SSLSessionCache none
&nbsp;
Listen <span style="color: #000000;">443</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">443</span><span style="color: #000000; font-weight: bold;">&gt;</span>
ErrorLog logs<span style="color: #000000; font-weight: bold;">/</span>ssl.log
LogLevel info
<span style="color: #666666; font-style: italic;"># You can later change &quot;info&quot; to &quot;warn&quot; if everything is OK</span>
&nbsp;
SSLEngine On
SSLCertificateFile conf<span style="color: #000000; font-weight: bold;">/</span>my-server.cert
SSLCertificateKeyFile conf<span style="color: #000000; font-weight: bold;">/</span>my-server.key
&nbsp;
<span style="color: #666666; font-style: italic;"># copy the &lt;Directory&gt; information from the appropriate HTTP virtual host</span>
DocumentRoot <span style="color: #ff0000;">&quot;C:/path/to/docroot&quot;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #000000; font-weight: bold;">/&gt;</span>
    ...
<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

</li>
<li>Restart Apache.</li>
</ol>
<p>That should do it, then just navigate to <strong>http://localhost:443</strong>.  You&#8217;ll get browser warnings complaining that the certificate is self-signed and thus probably bogus, but it will work otherwise.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/07/10/quick-steps-to-configure-ssl-encryption-on-a-wamp-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Subversion on CentOS &#8211; be careful what you read</title>
		<link>http://blog.echothis.com/2010/07/06/installing-subversion-on-centos-be-careful-what-you-read/</link>
		<comments>http://blog.echothis.com/2010/07/06/installing-subversion-on-centos-be-careful-what-you-read/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 21:06:50 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=358</guid>
		<description><![CDATA[The CentOS directions are pretty good &#8211; follow them to the letter.  The directions in the installed /etc/httpd/conf.d/subversion.conf &#8211; less so.  In particular, your &#60;Location&#62; node should look something like this, in order to work (ignore the rest): &#60;Location /repos&#62; DAV svn # path to your repo here SVNPath /var/www/svn/repos &#160; AuthType Basic AuthName &#34;Subversion [...]]]></description>
			<content:encoded><![CDATA[<p>The<a href="http://wiki.centos.org/HowTos/Subversion"> CentOS directions</a> are pretty good &#8211; follow them to the letter.  The directions in the installed /etc/httpd/conf.d/subversion.conf &#8211; less so.  In particular, your &lt;Location&gt; node should look something like this, in order to work (ignore the rest):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>Location <span style="color: #000000; font-weight: bold;">/</span>repos<span style="color: #000000; font-weight: bold;">&gt;</span>
  DAV <span style="color: #c20cb9; font-weight: bold;">svn</span>
  <span style="color: #666666; font-style: italic;"># path to your repo here</span>
  SVNPath <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>repos
&nbsp;
  AuthType Basic
  AuthName <span style="color: #ff0000;">&quot;Subversion repos&quot;</span>
  AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>svn-auth-conf
  Require valid-user
<span style="color: #000000; font-weight: bold;">&lt;/</span>Location<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/07/06/installing-subversion-on-centos-be-careful-what-you-read/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving out a playlist to share it</title>
		<link>http://blog.echothis.com/2010/07/05/saving-out-a-playlist-to-share-it/</link>
		<comments>http://blog.echothis.com/2010/07/05/saving-out-a-playlist-to-share-it/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 16:44:20 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=353</guid>
		<description><![CDATA[Apple, and to a lesser extent, Microsoft, go out of their way to make sharing music painful &#8211; even in the simple case of sharing a playlist of songs with your buddy (which clearly falls under Fair Use!).  For example, suppose you made a playlist for yourself (of music you own), put it on an [...]]]></description>
			<content:encoded><![CDATA[<p>Apple, and to a lesser extent, Microsoft, go out of their way to make sharing music painful &#8211; even in the simple case of sharing a playlist of songs with your buddy (which clearly falls under Fair Use!).  For example, suppose you made a playlist for yourself (of music you own), put it on an iPod, and then played it for a friend.  If they liked it and wanted it on their iPod as well, how would you share it with them?  You can&#8217;t &#8220;send&#8221; them a playlist &#8211; you&#8217;d have to copy the songs one by one to a hard drive or DVD, then hand it to your friend, he plugs it into his computer, he copies over the songs, then he takes the time to recreate your playlist manually in iTunes.  It would be funny if the state of the art wasn&#8217;t so sad!</p>
<p>In just this situation, I ended up writing a short PHP console script to do this semi-automatically.  It parses a playlist file in PLS format, then copies the files to a central directory, which can then be copied to an external hard drive.  This would then be plugged into your friend&#8217;s PC, and the music copied to the destination of choice.  Finally, it outputs a modified PLS file with all the paths changed.</p>
<p>No magic here, just a few lines of code to make the tedious task of sharing music you like, somewhat less so.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// saveplaylist.php</span>
<span style="color: #000088;">$copy_folder</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'H:\\temp\\'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// path to a central directory</span>
<span style="color: #000088;">$destination_folder</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'C:\\My Music\\'</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// the destination on your friend's PC</span>
<span style="color: #000088;">$playlist_file</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'C:\Users\JohnDoe\Music\Playlists\myplaylist.pls'</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// the playlist file</span>
<span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$playlist_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$newplaylist</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$contents</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$matches</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match_all</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/File(.*)=(.*)$/msU'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$contents</span><span style="color: #339933;">,</span> <span style="color: #000088;">$matches</span><span style="color: #339933;">,</span> PREG_SET_ORDER<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$matches</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pathinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> PATHINFO_BASENAME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Copying <span style="color: #006699; font-weight: bold;">{$file}</span>...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$copy_file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$copy_folder</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$destination_file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$destination_folder</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$name</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$copy_file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$escaped_filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'\\'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\\\'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$escaped_filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$escaped_filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$escaped_filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'['</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\['</span><span style="color: #339933;">,</span> <span style="color: #000088;">$escaped_filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$escaped_filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">']'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\]'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$escaped_filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$escaped_filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'('</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\('</span><span style="color: #339933;">,</span> <span style="color: #000088;">$escaped_filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$escaped_filename</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">')'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'\\)'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$escaped_filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$newplaylist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/File'</span><span style="color: #339933;">.</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'='</span><span style="color: #339933;">.</span><span style="color: #000088;">$escaped_filename</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'File'</span><span style="color: #339933;">.</span><span style="color: #000088;">$match</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'='</span><span style="color: #339933;">.</span><span style="color: #000088;">$destination_file</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newplaylist</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;hr&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$newplaylist</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/07/05/saving-out-a-playlist-to-share-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The best way to get a playlist onto an iPod or iPhone</title>
		<link>http://blog.echothis.com/2010/05/28/the-best-way-to-get-a-playlist-onto-an-ipod-or-iphone/</link>
		<comments>http://blog.echothis.com/2010/05/28/the-best-way-to-get-a-playlist-onto-an-ipod-or-iphone/#comments</comments>
		<pubDate>Fri, 28 May 2010 20:27:14 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=351</guid>
		<description><![CDATA[It’s my firm belief that the bloated, horrible software that is iTunes will ultimately be the downfall of Apple’s music business. It’s really, really awful on a variety of fronts (performance, openness to outside developers, etc.), but is sadly the most reliable way I can get music onto my iPhone and iPod. Beyond that, I [...]]]></description>
			<content:encoded><![CDATA[<p>It’s my firm belief that the bloated, horrible software that is iTunes will ultimately be the downfall of Apple’s music business.   It’s really, really awful on a variety of fronts (performance, openness to outside developers, etc.), but is sadly the most reliable way I can get music onto my iPhone and iPod.  Beyond that, I try to stay out of iTunes as much as possible.</p>
<p>While the Windows Media Player 12 (part of Windows 7) has improved significantly over the previous version, particularly in terms of performance and streaming more video formats out of the box, as a simple jukebox it still leaves a lot to be desired.  The best media player app I’ve found is Songbird, due to several factors such as a) it’s open-source, b) it has a number of great community-built plugins for things like lyrics, and c) it allows you to manage your music in ways the other apps simply cannot.</p>
<p>A simple example is “What is the best way to get a playlist onto my iPod/iPhone”?  This is much more complicated than it should be if you have a large library (i.e., too large to handle in iTunes, which isn’t much).  So the best way is to create it in <a href="http://getsongbird.com">Songbird</a>, then export it into a PLS file that can be read by iTunes.  So the steps are</p>
<ol>
<li>Install <a href="http://getsongbird.com">Songbird</a>.</li>
<li>Install the “<a href="http://addons.songbirdnest.com/addon/51">Playlist Export Tool</a>” add-in.  I suggest also installing the <a href="http://addons.songbirdnest.com/addon/24">Windows Media Playback</a> and <a href="http://addons.songbirdnest.com/addon/1230">LyricMaster</a> add-ins while you’re at it.</li>
<li>Import your library into Songbird by following the directions.</li>
<li>Make the playlist you want. The search box in the upper right can be really useful in this.</li>
<li>When done go to File-&gt;Export Playlist(s)</li>
<li>Check the playlist, then click “Done” to save it as a PLS to the specified location.</li>
<li>Close Songbird and open iTunes.  You can now drag the PLS file into iTunes, which will then import the songs it needs.  You can then sync it with your device.</li>
</ol>
<p>This way you can actual spend time listening to your music, not fighting with iTunes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/05/28/the-best-way-to-get-a-playlist-onto-an-ipod-or-iphone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Index PDF files with Windows 7 64-bit</title>
		<link>http://blog.echothis.com/2010/03/18/index-pdf-files-with-windows-7-64-bit/</link>
		<comments>http://blog.echothis.com/2010/03/18/index-pdf-files-with-windows-7-64-bit/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 22:56:10 +0000</pubDate>
		<dc:creator>Rolf</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.echothis.com/?p=347</guid>
		<description><![CDATA[In a previous post I offered some hints for getting Windows Search to work better.  Here&#8217;s another one. Adobe PDF files are ubiquitous, so you&#8217;d expect to be able to index them.  But Windows doesn&#8217;t ship with a &#8220;filter&#8221; for this format, so you have to download your own.  According to Adobe: Adobe currently bundles [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://blog.echothis.com/2010/02/10/making-windows-7-search-a-little-less-dysfunctional/">previous post</a> I offered some hints for getting Windows Search to work better.  Here&#8217;s another one.</p>
<p>Adobe PDF files are ubiquitous, so you&#8217;d expect to be able to index them.  But Windows doesn&#8217;t ship with a &#8220;filter&#8221; for this format, so you have to download your own.  According to <a href="http://www.adobe.com/support/downloads/detail.jsp?ftpID=4025">Adobe</a>:</p>
<blockquote><p>Adobe currently bundles a 32-bit PDF iFilter with Adobe Acrobat® 9 as well as free Adobe Reader® 9 software. It uses the Microsoft iFilter interface and allows third-party indexing tools to extract text from Adobe PDF files.</p>
<p>In response to customer requests, Adobe is releasing Adobe PDF iFilter 9 for 64-bit platforms, which will allow searching PDF files on Microsoft® Windows® 64-bit platforms for applications such as Microsoft Office SharePoint Server 2007, Microsoft Exchange Server 2007, and Microsoft SQL Server 2005.</p></blockquote>
<p>At least for me, the 32-bit filter version that got installed with Adobe Reader 9 apparently doesn&#8217;t work on Windows 7 64-bit, and worst of all, fails silently so you would never know there&#8217;s a problem.  So install the download at the link above.  After that you probably need to rebuild your index, but should get your PDF files indexed from that point forward.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.echothis.com/2010/03/18/index-pdf-files-with-windows-7-64-bit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
