<?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>Alexey Zakhlestins blog</title>
	<atom:link href="http://blog.milkfarmsoft.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.milkfarmsoft.com</link>
	<description>Programming for Mac and Web</description>
	<lastBuildDate>Sun, 13 Jun 2010 15:42:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
			<item>
		<title>Node.js 0.1.98</title>
		<link>http://blog.milkfarmsoft.com/2010/06/node-js-0-1-98/</link>
		<comments>http://blog.milkfarmsoft.com/2010/06/node-js-0-1-98/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 15:42:32 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript node.js]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/2010/06/node-js-0-1-98/</guid>
		<description><![CDATA[<p>Node.js 0.1.98 was released recently. It has bundled &#8220;readline&#8221; library now, so REPL-mode just got much <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2010/06/node-js-0-1-98/">Node.js 0.1.98</a></span>]]></description>
			<content:encoded><![CDATA[<p><a href="http://nodejs.org/">Node.js</a> 0.1.98 was released recently. It has bundled &#8220;readline&#8221; library now, so REPL-mode just got much more usable</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2010/06/node-js-0-1-98/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pake 1.4.0 is released</title>
		<link>http://blog.milkfarmsoft.com/2010/03/pake-1-4-0-is-released/</link>
		<comments>http://blog.milkfarmsoft.com/2010/03/pake-1-4-0-is-released/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 08:16:18 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[pake]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=156</guid>
		<description><![CDATA[<p>I just released new version of Pake.</p>
<p></p>
<p>Pake is a command line utility for executing predefined tasks, inspired by make. It is written in PHP and the tasks are also described in PHP. Pake can be used for compiling projects from different pieces, generating code, preprocessing templates and deploying projects.</p>
<p>If you know Phing, then Pake is a <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2010/03/pake-1-4-0-is-released/">Pake 1.4.0 is released</a></span>]]></description>
			<content:encoded><![CDATA[<p>I just released new version of <a href="http://wiki.github.com/indeyets/pake/">Pake</a>.</p>
<p></p>
<p>Pake is a command line utility for executing predefined tasks, inspired by make. It is written in PHP and the tasks are also described in PHP. Pake can be used for compiling projects from different pieces, generating code, preprocessing templates and deploying projects.</p>
<p>If you know Phing, then Pake is a similar thing, but doesn&#8217;t use XML, is easier to use and faster.</p>
<p></p>
<p>Here&#8217;s the brief Changelog:</p>
<ul>
<li>added &#8220;interactive mode&#8221; (pake -i)</li>
<li>new helper: pakeMercurial (in addition to pakeSubversion and pakeGit we already had)</li>
<li>updated sfYaml library</li>
<li>use copy+unlink instead of rename in pake_rename() to workaround problem of moving files between volumes</li>
<li>&#8220;pake compact&#8221; (developers-only) command works again</li>
<li>added explicit pakePearTask::package_pear_package($file, $target) method</li>
<li>fixed output-formatting (long texts in exceptions, etc.)</li>
<li>various packaging fixes</li>
</ul>
<p>All Pake 1.x versions are compatible with php-5.2. Earlier versions might work, but those are not tested.</p>
<p>If you need automation tool for your project, then Pake might be exactly what you need.</p>
<p></p>
<p>Useful links:</p>
<ul>
<li><a href="http://wiki.github.com/indeyets/pake/" title="Pake">Pake&#8217;s homepage</a> (including documentation)</li>
<li><a href="http://wiki.github.com/indeyets/pake/installing-pake" title="Installing Pake">Installation instructions</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2010/03/pake-1-4-0-is-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ode to mb_ereg functions</title>
		<link>http://blog.milkfarmsoft.com/2009/11/ode-to-mb_ereg-functions/</link>
		<comments>http://blog.milkfarmsoft.com/2009/11/ode-to-mb_ereg-functions/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 00:28:20 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=151</guid>
		<description><![CDATA[There is a common misunderstanding, that mb_ereg_* functions are just unicode counterparts of ereg_* functions: slow and non-powerful. That's as far from truth as it can be. <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/11/ode-to-mb_ereg-functions/">ode to mb_ereg functions</a></span>]]></description>
			<content:encoded><![CDATA[<p>PHP has some sets of functions, which are not known to the wide audience. One of those is mb_ereg_* family of functions.</p>
<p>There is a common misunderstanding, that mb_ereg_* functions are just unicode counterparts of ereg_* functions: slow and non-powerful. That&#8217;s as far from truth as it can be.</p>
<p>mb_ereg_* functions are based on <a href="http://www.geocities.jp/kosako3/oniguruma/" title="Oniguruma">oniguruma</a> regular expressions library. And oniguruma is one of the fastest and most capable regular expression libraries out there. Couple of years ago I made <a href="http://blog.milkfarmsoft.com/2006/12/regexps-in-php-again/" title="Alexey Zakhlestins blog  &raquo; regexps in PHP, again">a little speed-test</a>.</p>
<p>Anyway, this time, I was going to tell about it&#8217;s usage. PHP-documentation isn&#8217;t telling much.</p>
<p>Let&#8217;s start with the basic fact: you don&#8217;t need to put additional delimeters around your regular exprsssions, when you use mb_ereg_* funcitons. For example:</p>
<pre>// find first substring consisting of letters from 'a' to 'c' in 'abcdabc' string.
<a href="http://docs.php.net/mb_ereg" title="PHP: mb_ereg - Manual">mb_ereg</a>('[a-c]+', 'abcdabc', $res);</pre>
<p>To execute same search, but in case-insensitive fashion, you should use <a href="http://docs.php.net/mb_eregi" title="PHP: mb_eregi - Manual">mb_eregi</a>()</p>
<p>mb_ereg(), mb_eregi() and mb_split() functions use pre-set options in their work. You can check current options and set the new ones using <a href="http://docs.php.net/mb_regex_set_options" title="PHP: mb_regex_set_options - Manual">mb_regex_set_options</a>() function. This function is parametrized by string, each letter of which means something.</p>
<p>There are parameters (you can specify several of these at the same time):</p>
<ul>
<li>&#8216;i&#8217;: ONIG_OPTION_IGNORECASE;</li>
<li>&#8216;x&#8217;: ONIG_OPTION_EXTEND;</li>
<li>&#8216;m&#8217;: ONIG_OPTION_MULTILINE;</li>
<li>&#8216;s&#8217;: ONIG_OPTION_SINGLELINE;</li>
<li>&#8216;p&#8217;: ONIG_OPTION_MULTILINE | ONIG_OPTION_SINGLELINE;</li>
<li>&#8216;l&#8217;: ONIG_OPTION_FIND_LONGEST;</li>
<li>&#8216;n&#8217;: ONIG_OPTION_FIND_NOT_EMPTY;</li>
<li>&#8216;e&#8217;: eval() resulting code</li>
</ul>
<p>And there are &#8220;modes&#8221; (if you specify several of these, the LAST one will be used):</p>
<ul>
<li>&#8216;j&#8217;: ONIG_SYNTAX_JAVA;</li>
<li>&#8216;u&#8217;: ONIG_SYNTAX_GNU_REGEX;</li>
<li>&#8216;g&#8217;: ONIG_SYNTAX_GREP;</li>
<li>&#8216;c&#8217;: ONIG_SYNTAX_EMACS;</li>
<li>&#8216;r&#8217;: ONIG_SYNTAX_RUBY;</li>
<li>&#8216;z&#8217;: ONIG_SYNTAX_PERL;</li>
<li>&#8216;b&#8217;: ONIG_SYNTAX_POSIX_BASIC;</li>
<li>&#8216;d&#8217;: ONIG_SYNTAX_POSIX_EXTENDED;</li>
</ul>
<p>Descriptions of these constants are available in this document: <a href="http://www.geocities.jp/kosako3/oniguruma/doc/API.txt">API.txt</a></p>
<p>So, for example, mb_regex_set_options(&#8216;pr&#8217;) is equivalent to mb_regex_set_options(&#8216;msr&#8217;) and means:</p>
<ul>
<li>. should include \n (aka &#8220;multiline-match&#8221;)</li>
<li>^ is equivalent to \A, $ is equivalent to \Z (aka &#8220;strings are single-lined&#8221;)</li>
<li>using RUBY-mode</li>
</ul>
<p>By the way, that is the default setting for mb_ereg_* functions. And, mb_ereg_match and mb_ereg_search families of functions take options-parameter explicitly.</p>
<p>So, back to functions:</p>
<pre>// make sure, that the whole string matches the regexp:
<a href="http://docs.php.net/mb_ereg_match" title="PHP: mb_ereg_match - Manual">mb_ereg_match</a>('[a-c]+', $user_string, 'pz'); // 'pz' specifies options for this operation
                                             // (multiline perl-mode in this case)

// replace any of letters from 'a' to 'c' range with 'Z'
$output = <a href="http://docs.php.net/mb_ereg_replace" title="PHP: mb_ereg_replace - Manual">mb_ereg_replace</a>('[a-c]', 'Z', $user_string, 'b'); // use basic POSIX mode</pre>
<p>Ok, these were easy and similar to what you&#8217;ve seen in preg_* functions. Now, to something more powerful. The real strength lies in mb_ereg_search_* functions. The idea is, that you can let oniguruma preparse and cache text and/or regexp in its internal buffers. If you do, matching will work a lot faster.</p>
<pre><a href="http://docs.php.net/mb_ereg_search_init" title="PHP: mb_ereg_search_init - Manual">mb_ereg_search_init</a>($some_long_text); // preparse text
<a href="http://docs.php.net/mb_ereg_search" title="PHP: mb_ereg_search - Manual">mb_ereg_search</a>('[a-c]'); // execute search
while ($r = <a href="http://docs.php.net/mb_ereg_search_getregs" title="PHP: mb_ereg_search_getregs - Manual">mb_ereg_search_getregs</a>()) { // get next result
    // work with matched result
}

mb_ereg_search('[d-e]'); // execute different search on the same text

mb_ereg_search_init($some_other_text); // preparse another text
mb_ereg_search(); // execute search using previous (already preparsed) regexp</pre>
<p>This is the fastest way of parsing large documents in php, as far as I know.</p>
<p>Notes on charsets. Though, it is often mentioned, that mb_ereg_* functions are &#8220;unicode&#8221;, it would be more practical to say, that they are encoding-aware. It is a good idea to specify, which encoding you use beore calling oniguruma.</p>
<p>Some options:</p>
<pre><a href="http://docs.php.net/mb_regex_encoding" title="PHP: mb_regex_encoding - Manual">mb_regex_encoding</a>('UTF-8');
mb_regex_encoding('CP1251'); // windows cyrillic encoding
mb_regex_encoding('Shift_JIS'); // japanese</pre>
<p>Check the <a href="http://docs.php.net/manual/en/mbstring.encodings.php" title="PHP: Summaries of supported encodings - Manual">full list of supported encodings</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/11/ode-to-mb_ereg-functions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DNS SRV-records support in HTTP-browsers</title>
		<link>http://blog.milkfarmsoft.com/2009/09/dns-srv-records-support-in-http-browsers/</link>
		<comments>http://blog.milkfarmsoft.com/2009/09/dns-srv-records-support-in-http-browsers/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 13:34:11 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=141</guid>
		<description><![CDATA[Ten years ago, today, on september 20, 1999 bug titled "DNS: RFC 2782 not supported (SRV records)" was submitted to Mozilla. Today, in 2009, bug has patch attached, but it is not committed and waits for approval. I doubt, that is the longest-living bug in mozilla, but, still, 10 years is a great age for a bug. Let's party! :)
 <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/09/dns-srv-records-support-in-http-browsers/">DNS SRV-records support in HTTP-browsers</a></span>]]></description>
			<content:encoded><![CDATA[<p>Ten years ago, today, on september 20, 1999 bug titled &#8220;DNS: RFC 2782 not supported (SRV records)&#8221; was submitted to Mozilla. Today, in 2009, bug has patch attached, but it is not committed and waits for approval. I doubt, that is the longest-living bug in mozilla, but, still, 10 years is a great age for a bug. Let&#8217;s party! <img src='http://blog.milkfarmsoft.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, some of my readers, are probably asking themselves: what is it all about? why is this bug important? Ok. Let&#8217;s find out!</p>
<p>How does browser usually find which server to ask, when you enter URL?  Well, at first, it parses out protocol and domain name from URL. For example, if URL is <strong>http://www.example.com/page.html</strong> then protocol is <strong>http</strong> and domain name is <strong>www.example.com</strong>. After that, browser sends request for &#8220;A&#8221; type record to DNS server and server replies with IP address (or several IP addresses). After that, browser tries to open connection with these addresses one by one, until it finds one which really works. Hopefully, first one will work, but sometimes each one will fail; In this case, browser will show us an error.</p>
<p>&#8220;A&#8221; records have the following format:</p>
<pre>
    hostname    IN  A   ip-address  time-to-live
</pre>
<p>For basic cases, this scheme seems to work just fine, but it has some inherent flaws, when you start to think about scalability.</p>
<ol>
<li>It is impossible to map different services on the same domain-name to different servers. For example: I can&#8217;t have FTP and HTTP servers responding on example.com and, at the same time, located on different physical machines. My only option would be some kind of router, which would forward requests on different ports to different IP&#8217;s.</li>
<li>It is impossible to map service to specific port of server. Browsers just looks for TCP-connection on port 80 while using HTTP, for example.</li>
<li>It is impossible to implement sophisticated load-balancing rules in DNS. Having several A-records in DNS just gives possibility to have equal-load of several machines, nothing fancy.</li>
</ol>
<p>It is an interesting fact, that all this problems are solved long time ago for one specific protocol called SMTP (yes, the one which delivers emails all around the globe). SMTP uses special kind of DNS-records called &#8220;MX&#8221; which allow to specify which machine(s) are waiting for SMTP-connections targeted to domain name and allow to specify priority of these machines, so, at first, clients will try to access machines with high priority and in case of problems will fallback to low-priority ones. So, MX records make email-infrastructure seriously more robust and scalable then anything else. Why such special treatment?</p>
<p><a href="http://en.wikipedia.org/wiki/MX_record" title="MX record - Wikipedia, the free encyclopedia">&#8220;MX&#8221; records</a> have the following format:</p>
<pre>
    domainname  IN  MX  priority    hostname  time-to-live
</pre>
<p>Here, <a href="http://tools.ietf.org/html/rfc2782" title="RFC 2782 - A DNS RR for specifying the location of services (DNS SRV)">RFC 2782</a> comes on scene. Idea of this standard is to achieve similiar flexibility for any protocol used on internet.</p>
<p>&#8220;SRV&#8221; records allow to specify that specific application protocol, used over specific transport protocol of this domainname is handled by several servers on specific ports with various priority. That is as flexible as it can be. Let me throw some examples:</p>
<pre>
    _http._tcp.example.com. 86400 IN SRV 0 5 81 www1.example.com.
    _http._tcp.example.com. 86400 IN SRV 0 5 80 www2.example.com.
    _http._tcp.example.com. 86400 IN SRV 1 9 81 www-backup.example.com.
    _http._tcp.example.com. 86400 IN SRV 1 1 8000 www-weak-backup.example.com.
</pre>
<p>These four records tell browser, that:</p>
<ul>
<li>HTTP-over-TCP connections for &#8220;example.com&#8221; domain are handled by 4 servers: www1.example.com on port 81, www2.example.com on port 80, www-backup.example.com on port 81 and www-weak-backup.example.com on port 8000.</li>
<li>www1.example.com and www2.example.com have priority &#8220;0&#8243; (highest), so should be first to try. Both have weight &#8220;5&#8243;, which means, that they have 50% chance to be selected by client (equal load)</li>
<li>In case both of these are not reachable, browser should check lower-priority servers www-backup.example.com and www-weak-backup.example.com, but www-backup.example com should be preferred in 9 out of 10 cases (it has weight=9, while another one has weight=1).</li>
</ul>
<p>Sounds pretty cool, but, unfortunately, this technology is still not implemented in any of the browsers. Mozilla(Firefox) has <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=14328">this bug</a> for 10 years, WebKit has <a href="https://bugs.webkit.org/show_bug.cgi?id=6872">this bug</a> for 3+ years and Chromium has <a href="http://code.google.com/p/chromium/issues/detail?id=22423" title="Issue 22423 - chromium - DNS: RFC 2782 not supported (SRV records) - Project Hosting on Google Code">this bug</a> since today.</p>
<p>There is no need for special support on webserver-side — that&#8217;s a good side of this technology too. Just add relevant records to DNS-server and all compliant clients will see it.</p>
<p>At the moment, SRV-records are widely used by XMPP/Jabber, SIP, LDAP software and Kerberos. I believe, any protocol in use can benefit.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/09/dns-srv-records-support-in-http-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XSLCache in PECL</title>
		<link>http://blog.milkfarmsoft.com/2009/08/xslcache-in-pecl/</link>
		<comments>http://blog.milkfarmsoft.com/2009/08/xslcache-in-pecl/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 15:50:42 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=136</guid>
		<description><![CDATA[<p>XSLCache extension for PHP, originally developed by NYTimes started its second life in PECL&#8217;s repository and I am proud to announce first PECL-release.</p>
<p>The XSL Cache extension is a modification of PHP&#8217;s standard XSL extension that caches the parsed XSL stylesheet representation between sessions for 2.5x boost in performance for sites that repeatedly apply the same transform. <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/08/xslcache-in-pecl/">XSLCache in PECL</a></span>]]></description>
			<content:encoded><![CDATA[<p>XSLCache extension for PHP, originally developed by NYTimes started its second life in PECL&#8217;s repository and I am proud to announce <a href="http://pecl.php.net/package/xslcache">first PECL-release</a>.</p>
<p>The XSL Cache extension is a modification of PHP&#8217;s standard XSL extension that caches the parsed XSL stylesheet representation between sessions for 2.5x boost in performance for sites that repeatedly apply the same transform. API-wise it is compatible with usual <a href="http://docs.php.net/manual/en/book.xsl.php">XSL extension</a> with two small exceptions:</p>
<ol>
<li>instead of XSLTProcessor class you should use <strong>XSLTCache</strong> class.</li>
<li>importStyleshet method has another &#8220;signature&#8221;: <strong>void importStylesheet(string $path, bool $cachesheet=true);</strong></li>
</ol>
<p>Installation, from now on, should be as simple as &#8220;<strong>pecl install xslcache</strong>&#8220;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/08/xslcache-in-pecl/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Pake: PHP project build system</title>
		<link>http://blog.milkfarmsoft.com/2009/08/pake-php5-project-build-system/</link>
		<comments>http://blog.milkfarmsoft.com/2009/08/pake-php5-project-build-system/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 14:03:33 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=127</guid>
		<description><![CDATA[Pake project wasn't maintained for a while, so I decided to give it a spin (as there is a good chance, that I will be able to use it for my current projects). I imported it's version history to GitHub. My plan is to add some generally usable helpers to current branch, write some documentation and then to start work on Pake2 which would use all new features of PHP-5.3 (namespaces, closures, rich SPL). <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/08/pake-php5-project-build-system/">Pake: PHP project build system</a></span>]]></description>
			<content:encoded><![CDATA[<p>Sometimes, there are pieces of software, which are unfairly forgotten. Let&#8217;s talk about one these.</p>
<p>Often, while working on software projects, one finds, that there are repetitive tasks, which would be much easier to deal with, if automated. In the C/Unix world, this task is often solved by <a href="http://en.wikipedia.org/wiki/Make_(software)">Make</a>, Java programmers prefer <a href="http://en.wikipedia.org/wiki/Ant_(software)">Apache Ant</a>, Ruby programmers use <a href="http://en.wikipedia.org/wiki/Rake_(software)">Rake</a>. The fact, which is not commonly known, is, that PHP also has such instrument, and it is called <strong>Pake</strong>. It was originally created by authors of <a href="http://www.symfony-project.org/">Symfony framework</a>. Unfortunately, they never wrote any documentation, which killed adoption rates.</p>
<p>To start automating something, you need to create Pakefile.php in the root-directory of your project, define some tasks inside and run them with &#8220;pake taskname&#8221; from command-line. The good news is, that tasks are defined in PHP language and syntax is quite simple:</p>
<div class="php" style="font-family: monospace; color: #000000;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></p>
<p>pake_desc<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;FOO task&#8217;</span><span style="color: #66cc66;">&#41;</span>;<br />pake_task<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;foo&#8217;</span>, <span style="color: #ff0000;">&#8216;bar&#8217;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>pake_desc<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;BAR task&#8217;</span><span style="color: #66cc66;">&#41;</span>;<br />pake_task<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;bar&#8217;</span>, <span style="color: #ff0000;">&#8216;baz&#8217;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>pake_desc<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;BAZ task&#8217;</span><span style="color: #66cc66;">&#41;</span>;<br />pake_task<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;baz&#8217;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>pake_alias<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;default&#8217;</span>, <span style="color: #ff0000;">&#8216;foo&#8217;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// marking foo as default task</span></p>
<p><span style="color: #000000; font-weight: bold;">function</span> run_foo<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$task</span>, <span style="color: #0000ff;">$args</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; <a style="text-decoration: none;" href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;foo<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br /><span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #000000; font-weight: bold;">function</span> run_bar<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$task</span>, <span style="color: #0000ff;">$args</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; <a style="text-decoration: none;" href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;bar<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br /><span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #000000; font-weight: bold;">function</span> run_baz<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$task</span>, <span style="color: #0000ff;">$args</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; <a style="text-decoration: none;" href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;baz<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;<br /><span style="color: #66cc66;">&#125;</span></div>
<p>I defined 3 rules, gave them descriptions and specified dependencies. Additionally, I specifed default rule. Now, we can play with this a bit. Create file with this contents, save it somewhere, and point your terminal to the same directory.</p>
<p><code><br />
> pake<br />
baz<br />
bar<br />
foo<br />
</code></p>
<p>What happened? Pake looks for &#8220;default&#8221; task in the pakefile. We defined &#8220;foo&#8221; as default. Pake found out, that foo depends on bar, and bar depends on baz. So, Pake runs &#8220;baz&#8221;, then &#8220;bar&#8221; and then, finally, &#8220;foo&#8221;. That is as simple as it can be.</p>
<p>Pake has builtin support for basic file-operations (pake_mkdirs(), pake_copy(), pake_rename(), pake_remove()), which are the powered-up versions of php&#8217;s filesystem-functions, templating (pake_replace_tokens()), directory-mirroring (pake_mirror()) and runners for creating PEAR-packages, <a href="http://phing.info/trac/">Phing</a>-commands and <a href="http://www.simpletest.org/">Simpletest</a>.</p>
<p>Pake project wasn&#8217;t maintained for a while, so I decided to give it a spin (as there is a good chance, that I will be able to use it for my current projects). I imported it&#8217;s version history to GitHub. You can find latest version here: <a href="http://github.com/indeyets/pake">http://github.com/indeyets/pake</a></p>
<p>My plan is to add some generally usable helpers to current branch, write some documentation and then to start work on Pake2 which would use all new features of PHP-5.3 (namespaces, closures, rich SPL).</p>
<p>Git-project is a source for creating pear-package. To build one use the following command:</p>
<p><code><br />
> php bin/pake.php release 1.1.0a1<br />
</code></p>
<p>it will create &#8220;pake-1.1.0a1.tgz&#8221; file in the same directory. You can install it with the following command:</p>
<p><code><br />
> pear install -f pake-1.1.0a1.tgz<br />
</code></p>
<p>If you want to grab a prebuild pear-package of pake, you can do it <a href="http://github.com/indeyets/pake/downloads">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/08/pake-php5-project-build-system/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>work with TwitterData in PHP</title>
		<link>http://blog.milkfarmsoft.com/2009/08/work-with-twitterdata-in-php/</link>
		<comments>http://blog.milkfarmsoft.com/2009/08/work-with-twitterdata-in-php/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 19:36:35 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=106</guid>
		<description><![CDATA[I recently created a small library for working with twitterdata in PHP. Sources are available from GitHub. Twitter Data is a simple, open, semi-structured format for embedding machine-readable, yet human-friendly, data in Twitter messages. <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/08/work-with-twitterdata-in-php/">work with TwitterData in PHP</a></span>]]></description>
			<content:encoded><![CDATA[<p>I recently created a small library for working with <a href="http://twitterdata.org/" target="_blank">twitterdata</a> in PHP. Sources are available from GitHub: <a href="http://github.com/indeyets/php-twitterdata/tree/master">php-twitterdata</a></p>
<p>Here&#8217;s the description from Twitter Data site:</p>
<blockquote><p>
Twitter Data is a simple, open, semi-structured format for embedding machine-readable, yet human-friendly, data in <a href="http://twitter.com/">Twitter</a> messages. This data can then be transmitted, received, and interpreted in real time by powerful new kinds of applications built on the Twitter platform. Here is an example Twitter Data message:</p>
<p><code>I love the #twitterdata proposal! $vote +1</code></p>
<p>The part with the dollar sign, $vote +1, is a piece of data embedded using the Twitter Data format.
</p></blockquote>
<p>To use php-twitterdata library, <a href="http://github.com/indeyets/php-twitterdata/downloads">download</a> it into the sub-direcory in your project&#8217;s directory (or any other place you like) and init the autoloader:</p>
<div class="php" style="font-family: monospace; color: #000000;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br /><span style="color: #2500B9; font-weight: bold;">require</span> <span style="color: #ff0000;">&#8216;php-twitterdata/autoload.php&#8217;</span>;<br /><span style="color: #000000; font-weight: bold;">?&gt;</span></div>
<p>PHP API provided by php-twitterdata has 2 layers. On lower level, there are 3 classes: <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData_Message.php#L12" target="_blank">TwitterData_Message</a>, <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData_Frame.php#L12" target="_blank">TwitterData_Frame</a> and <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData_Tuple.php#L12" target="_blank">TwitterData_Tuple</a> which correspond to parts of data-enabled twitter-message. Message can consist of several Frames, Frame can consist of several Tuples and a &#8220;subject&#8221;. Objects of each of these classes can be created programmatically and combined in hierarchy. Each of them has &#8220;magic&#8221; <a href="http://docs.php.net/manual/en/language.oop5.magic.php#language.oop5.magic.tostring" target="_blank">__toString()</a> method, so, to export them as a valid twitter-message, you just need to put objects in string context. Something like this:</p>
<div class="php" style="font-family: monospace; color: #000000;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br /><span style="color: #0000ff;">$tuple</span> = <span style="color: #000000; font-weight: bold;">new</span> TwitterData_Tuple<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;foo&#8217;</span>, <span style="color: #ff0000;">&#8216;bar&#8217;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #0000ff;">$frame</span> = <span style="color: #000000; font-weight: bold;">new</span> TwitterData_Frame<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;Hello, world!&#8217;</span>, <a style="text-decoration: none;" href="http://docs.php.net/array" target="_blank"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$tuple</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><a style="text-decoration: none;" href="http://docs.php.net/echo" target="_blank"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$frame</span>;<br /><span style="color: #000000; font-weight: bold;">?&gt;</span></div>
<p>and the result will be:<br />
<code><br />
Hello, world! $foo bar<br />
</code></p>
<p>If you need to parse Twitter Data messages you should use <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData_Parser.php#L29" target="_blank">TwitterData_Parser</a> class. It is a SAX-style parser, with DOM-style export. If all you need is a hierarchy of objects, use it like this:</p>
<div class="php" style="font-family: monospace; color: #000000;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br /><span style="color: #0000ff;">$parser</span> = <span style="color: #000000; font-weight: bold;">new</span> TwitterData_Parser<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$text_from_twitter</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #0000ff;">$message</span> = <span style="color: #0000ff;">$parser</span>-&gt;<span style="color: #006600;">export</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// $message is object of TwitterData_Message class</span><br /><span style="color: #000000; font-weight: bold;">?&gt;</span></div>
<p>Otherwise, you can specify another handler-class as a second parameter of constructor. Such class has to implement <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData_Parser.php#L12" target="_blank">TwitterData_Parser_CallbackInterface</a>.</p>
<p>Does it all sound too complex? No problem!</p>
<p>php-twitterdata library also includes high-level interface, which consists of 2 simple functions: <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData.php#L14" target="_blank">TwitterData::array_to_TwitterData()</a> and <a href="http://github.com/indeyets/php-twitterdata/blob/e59c94763f60deb9701a380101047d9cb6586245/TwitterData.php#L19" target="_blank">TwitterData::TwitterData_to_array()</a>. First one converts associative array into the string, which can be inserted into twitter-message, and second one takes message-string received from twitter and returns associative array parsed out of tuples from the first frame of message (If you need to get all possible data from message, you will still need to use low-level API).</p>
<p>Example of high-level API:</p>
<div class="php" style="font-family: monospace; color: #000000;"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />TwitterData::<span style="color: #006600;">TwitterData_to_array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;Hello, world! $foo bar&#8217;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #808080; font-style: italic;">// array(&#8216;foo&#8217; =&gt; &#8216;bar&#8217;);</span></p>
<p><span style="color: #0000ff;">$message</span> = <span style="color: #ff0000;">&#8216;Hello, world! &#8216;</span>.TwitterData::<span style="color: #006600;">array_to_TwitterData</span><span style="color: #66cc66;">&#40;</span><a style="text-decoration: none;" href="http://docs.php.net/array" target="_blank"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&#8216;foo&#8217;</span> =&gt; <span style="color: #ff0000;">&#8216;bar&#8217;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #808080; font-style: italic;">// Hello, world! $foo bar</span><br /><span style="color: #000000; font-weight: bold;">?&gt;</span></div>
<p>Library has <a href="http://github.com/indeyets/php-twitterdata/tree/e5f7ae14a65ed00368e23750de1addaac20f5684/tests" target="_blank">unit-tests</a>, which cover all examples provided on Twitter Data site both on <a href="http://twitterdata.org/" target="_blank">Introduction</a> page and on <a href="http://twitterdata.org/examples/" target="_blank">Examples</a> page and is licensed under <a href="http://github.com/indeyets/php-twitterdata/blob/e5f7ae14a65ed00368e23750de1addaac20f5684/LICENSE#L1" target="_blank">MIT-style license</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/08/work-with-twitterdata-in-php/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Move to GitHub</title>
		<link>http://blog.milkfarmsoft.com/2009/08/move-to-github/</link>
		<comments>http://blog.milkfarmsoft.com/2009/08/move-to-github/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 18:05:16 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql query builder]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=101</guid>
		<description><![CDATA[<p>Just notifying all interested parties, that my &#8220;Application Server in PHP&#8221; and &#8220;MySQL Query Builder&#8221; projects are moved to GitHub.</p>
<p>Their new homes are:</p>

Application Server in PHP
MySQL Query Builder

<p>p.s. newest release of MySQL Query Builder has support for subqueries in <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/08/move-to-github/">Move to GitHub</a></span>]]></description>
			<content:encoded><![CDATA[<p>Just notifying all interested parties, that my &#8220;<a href="http://blog.milkfarmsoft.com/?p=51">Application Server in PHP</a>&#8221; and &#8220;<a href="http://blog.milkfarmsoft.com/?p=55">MySQL Query Builder</a>&#8221; projects are moved to GitHub.</p>
<p>Their new homes are:</p>
<ul>
<li><a href="http://github.com/indeyets/appserver-in-php/tree/master">Application Server in PHP</a></li>
<li><a href="http://github.com/indeyets/MySQL-Query-Builder/tree/master">MySQL Query Builder</a></li>
</ul>
<p>p.s. newest <a href="http://github.com/indeyets/MySQL-Query-Builder/downloads">release of MySQL Query Builder </a>has support for subqueries in <strong>IN(…)</strong> statements</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/08/move-to-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chronograph at MacZOT. $12.95 only!</title>
		<link>http://blog.milkfarmsoft.com/2009/06/chronograph-at-maczot-12-95-only/</link>
		<comments>http://blog.milkfarmsoft.com/2009/06/chronograph-at-maczot-12-95-only/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 06:53:14 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[milkfarmsoft]]></category>
		<category><![CDATA[chronograph]]></category>
		<category><![CDATA[sale]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=92</guid>
		<description><![CDATA[<p></p>
<p>Just wanted to let you know, that our time-tracking app Chronograph is available for $12.95 from MacZOT today. That&#8217;s 50% of our usual price. Please note, that it is a time-limited offer: you can buy Chronograph at this price only on June 30, 2009. Additionally, MacZOT will be giving several free licenses to their subscribers — <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/06/chronograph-at-maczot-12-95-only/">Chronograph at MacZOT. $12.95 only!</a></span>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.milkfarmsoft.com/images/chronograph.png" alt="Chronograph" align="left" style="margin-right:1.5em" /></p>
<p>Just wanted to let you know, that our time-tracking app <a href="http://www.milkfarmsoft.com/chronograph.php" title="Milk Farm Software: Chronograph, Time Tracker for Mac">Chronograph</a> is available for $12.95 from <a href="http://www.maczot.com/" title="MacZOT | One Great Mac Software. Daily. |">MacZOT</a> today. That&#8217;s 50% of our usual price. Please note, that it is a time-limited offer: you can buy Chronograph at this price only on June 30, 2009. Additionally, MacZOT will be giving several free licenses to their subscribers — take your chance.</p>
<p>By the way, we recently released Chronograph 1.3 which has one of the most requested features: iCal integration. Just click one button in preferences and watch how all your tracked time-data appears in iCal-calendar. Add a simple AppleScript and you can integrate Chronograph data into your workflow. With each release Chronograph becomes more mature, but, still, is an extremely easy to use piece of software.</p>
<p>If you were waiting for some special occasion to buy Chronograph license — this is exactly such occasion. Don&#8217;t miss it. <a href="http://www.maczot.com/" title="MacZOT | One Great Mac Software. Daily. |">It is HERE</a>.</p>
<p>relevant links:</p>
<ul>
    <a href="http://www.milkfarmsoft.com/" title="Milk Farm Software: Products">Milk Farm Software, ltd.</a><br />
    <a href="http://www.milkfarmsoft.com/chronograph.php" title="Milk Farm Software: Chronograph, Time Tracker for Mac">Chronograph&#8217;s home-page</a><br />
    <a href="http://s3.amazonaws.com/milkfarmsoft/Chronograph%201.3.0.dmg">Download Chronograph 1.3</a>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/06/chronograph-at-maczot-12-95-only/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP-FPM is BSD-licensed now</title>
		<link>http://blog.milkfarmsoft.com/2009/06/php-fpm-is-bsd-licensed-now/</link>
		<comments>http://blog.milkfarmsoft.com/2009/06/php-fpm-is-bsd-licensed-now/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 06:25:16 +0000</pubDate>
		<dc:creator>indeyets</dc:creator>
				<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.milkfarmsoft.com/?p=88</guid>
		<description><![CDATA[It took several years of waiting, but, it finally happened. PHP-FPM project is officially BSD-licensed now and has good chances to become a part of official PHP distribution. <span style="color:#777"> . . . &#8594; Read More: <a href="http://blog.milkfarmsoft.com/2009/06/php-fpm-is-bsd-licensed-now/">PHP-FPM is BSD-licensed now</a></span>]]></description>
			<content:encoded><![CDATA[<p>Some seriously good news here. It took several years of waiting, but, it finally happened. <a href="http://php-fpm.anight.org/" title="php-fpm: PHP FastCGI Process Manager">PHP-FPM</a> project is <a href="http://groups.google.com/group/highload-php-en/browse_thread/thread/974eaff4ad094391">officially BSD-licensed</a> now, which means, that it has good chances to become a part of official PHP distribution.</p>
<p>PHP-FPM is &#8220;deciphered&#8221; as &#8220;PHP FastCGI Process Manager&#8221; and is a patch for php to greatly improve FastCGI SAPI usage in production. It adds a bunch of additional features to php&#8217;s fastcgi such as: easy php-process daemonization (with ability to specify uid/gid/chroot/log-file), safe php-processes restart (without losing requests), custom error-handling and accelerated file-upload support (requires additional support from web-server).</p>
<p>There&#8217;s not much documentation in english, currently, but, again, there is a good chance that it will be added really soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.milkfarmsoft.com/2009/06/php-fpm-is-bsd-licensed-now/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
