<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
    
    <title> Rasmus' Toys Page</title>
    <link>http://toys.lerdorf.com/</link>
    <description></description>
    <dc:language>en</dc:language>
    <admin:errorReportsTo rdf:resource="mailto:" />
    <generator>Serendipity 1.6-alpha1 - http://www.s9y.org/</generator>
    <pubDate>Fri, 05 Feb 2010 01:10:31 GMT</pubDate>

    <image>
        <url>http://toys.lerdorf.com/templates/default/img/s9y_banner_small.png</url>
        <title>RSS:  Rasmus' Toys Page - </title>
        <link>http://toys.lerdorf.com/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>HipHop PHP - Nifty Trick?</title>
    <link>http://toys.lerdorf.com/archives/53-HipHop-PHP-Nifty-Trick.html</link>
    
    <comments>http://toys.lerdorf.com/archives/53-HipHop-PHP-Nifty-Trick.html#comments</comments>
    <wfw:comment>http://toys.lerdorf.com/wfwcomment.php?cid=53</wfw:comment>

    <slash:comments>6</slash:comments>
    <wfw:commentRss>http://toys.lerdorf.com/rss.php?version=2.0&amp;type=comments&amp;cid=53</wfw:commentRss>
    

    <author>rasmus@lerdorf.com (Rasmus)</author>
    <content:encoded>
    In a response to a question from ReadWriteWeb, among other things, I wrote:

&lt;blockquote&gt;
My main worry here is that people think this is some kind of magic
bullet that will solve their site performance problems.  Generating C++
code from PHP code is a nifty trick and people seem to have gotten quite
excited about it.  I&#039;d love to see those same people get excited about
basic profiling and identifying the most costly areas of an application.
Speeding up one of the faster parts of your system isn&#039;t going to give
you anywhere near as much of a benefit as speeding up, or eliminating,
one of the slower parts of your overall system.
&lt;/blockquote&gt;

The &quot;nifty trick&quot; part of that seems to have become the story, and them 
injecting a &quot;just&quot; in front it of it makes it sound more derogatory.  Anyone
who knows me knows that I am a big fan of nifty tricks that solve the problem.
When I first heard about the Facebook effort I was assuming they were writing
a JIT based on LLVM V8 or something along those lines.  Writing a good JIT is
hard.  Doing static code analysis and generating compilable C++ from it is
indeed a nifty trick.  It&#039;s not &quot;just&quot; a nifty trick, it is a cool trick that takes
advantage of a number of characteristics of PHP.  The main one being that
you can&#039;t overload PHP functions.  strlen() is always strlen, for example.  In
Python, this would be harder because you can overload everything.
&lt;br /&gt;&lt;br /&gt;
I also noted that most sites on the Web have a lot of lower hanging fruit that
would provide a much bigger performance improvement, if fixed, than doubling
the speed of the PHP execution phase.  The ReadWriteWeb site, for example, 
needs 160 separate HTTP requests and 41 distinct DNS lookups to load the
front page.  And once you get beyond the frontend inefficiencies you usually
find Database issues, inefficient system call issues and general architecture
problems that again aren&#039;t solved by speeding up PHP execution.
&lt;br /&gt;&lt;br /&gt;
If you have done your homework and find that your web servers are cpu-bound,
you are already using an opcode cache like &lt;a href=&quot;http://pecl.php.net/apc&quot;&gt;APC&lt;/a&gt; 
and your &lt;a href=&quot;http://valgrind.org/info/tools.html#callgrind&quot;&gt;Callgrind&lt;/a&gt; callgraph
shows you that the PHP executor is a significant bottleneck, then HipHop PHP is
definitely something you should be looking at. 
    </content:encoded>

    <pubDate>Thu, 04 Feb 2010 10:50:37 -0800</pubDate>
    <guid isPermaLink="false">http://toys.lerdorf.com/archives/53-guid.html</guid>
    
</item>
<item>
    <title>SQLi Detection - Duh Moment</title>
    <link>http://toys.lerdorf.com/archives/52-SQLi-Detection-Duh-Moment.html</link>
            <category>Software</category>
    
    <comments>http://toys.lerdorf.com/archives/52-SQLi-Detection-Duh-Moment.html#comments</comments>
    <wfw:comment>http://toys.lerdorf.com/wfwcomment.php?cid=52</wfw:comment>

    <slash:comments>8</slash:comments>
    <wfw:commentRss>http://toys.lerdorf.com/rss.php?version=2.0&amp;type=comments&amp;cid=52</wfw:commentRss>
    

    <author>rasmus@lerdorf.com (Rasmus)</author>
    <content:encoded>
    Not sure why it took me so long to figure out what I am sure is obvious to most other people who have thought about this, but it never clicked for me how to get anywhere near useful SQL Injection detection.  The injection itself is trivial, of course, but determining whether it actually worked and weeding out false positives in an automated manner was something that seemed too hard.  &lt;br /&gt;
&lt;br /&gt;
During my run on Friday I had a Duh! moment on it.  Annoyingly simple.  Do it in 3 requests.  Request #1 is a normal request.  For example, &amp;quot;&lt;strong&gt;?id=1&lt;/strong&gt;&amp;quot; in the URL.  If the id is being passed to an SQL request it will return a single record or perhaps no record, it doesn&#039;t really matter.  Now on request #2 do &amp;quot;&lt;strong&gt;?id=1 or 3=4&lt;/strong&gt;&amp;quot;, that is, inject a false &#039;OR&#039; condition.  If the output changes, we are done.  Nothing to see here.  However, if the output does not change we send request #3 with &amp;quot;&lt;strong&gt;?id=1 or 3=3&lt;/strong&gt;&amp;quot; and if that output differs from request #2 then we have a potential SQLi situation.  There are of course still chances of false positives (and negatives) with page stamps and such, but filtering out the response headers and html comments cuts down on that a bit.  Add different combinations of single and double-quotes, like &amp;quot;&lt;strong&gt;?id=1&#039;or&#039;3&#039;=&#039;3&lt;/strong&gt;&amp;quot; (without the double-quotes, of course) and it might be able to catch something.&lt;br /&gt;
&lt;br /&gt;
The best thing about it is that it can slide into an existing scanner framework quite easily.  If you have a base reference request, then it just adds a single request to the common case where the false &#039;OR&#039; condition output does not match the base reference.  You only need to do the true &#039;OR&#039; condition request in case it does match.&lt;br /&gt;
&lt;br /&gt;
Anybody have any other approaches? 
    </content:encoded>

    <pubDate>Sun, 10 Jan 2010 18:44:09 -0800</pubDate>
    <guid isPermaLink="false">http://toys.lerdorf.com/archives/52-guid.html</guid>
    
</item>
<item>
    <title>Playing with Gearman</title>
    <link>http://toys.lerdorf.com/archives/51-Playing-with-Gearman.html</link>
    
    <comments>http://toys.lerdorf.com/archives/51-Playing-with-Gearman.html#comments</comments>
    <wfw:comment>http://toys.lerdorf.com/wfwcomment.php?cid=51</wfw:comment>

    <slash:comments>9</slash:comments>
    <wfw:commentRss>http://toys.lerdorf.com/rss.php?version=2.0&amp;type=comments&amp;cid=51</wfw:commentRss>
    

    <author>rasmus@lerdorf.com (Rasmus)</author>
    <content:encoded>
    This was written in September 2009 when the current version of Gearman was 0.9.  
Thanks to Eric Day for answering my dumb questions along the way.
&lt;br /&gt;&lt;br /&gt;
To get started, install Gearman.  I am on Debian, so this is what I installed:
&lt;pre style=&quot;background: #ddd; border: 1px solid #000; padding: 5px; line-height:1em;&quot;&gt;
% apt-get install gearman gearman-job-server gearman-tools libgearman1 libgearman-dev libdrizzle-dev
&lt;/pre&gt;

Enable Gearman in &lt;strong&gt;/etc/default/gearman-server&lt;/strong&gt;
&lt;br /&gt;
Set up Gearman to use MySQL for its persistent queue store in &lt;strong&gt;/etc/default/gearman-job-server&lt;/strong&gt;
&lt;pre style=&quot;background: #ddd; border: 1px solid #000; padding: 5px; line-height:1em;&quot;&gt;
 PARAMS=&quot;-q libdrizzle --libdrizzle-host=127.0.0.1 --libdrizzle-user=gearman \
                       --libdrizzle-password=your_pw --libdrizzle-db=gearman \
                       --libdrizzle-table=gearman_queue --libdrizzle-mysql&quot;

% mysqladmin create gearman

% mysql 
mysql&gt; create USER gearman@localhost identified by &#039;your_pw&#039;;
mysql&gt; GRANT ALL on gearman.* to gearman@localhost;
&lt;/pre&gt;

** &lt;strong&gt;Careful&lt;/strong&gt;, if you are running MySQL using &lt;strong&gt;--old-passwords&lt;/strong&gt; this won&#039;t work with libdrizzle.
You will need to get the 41-char password hash with a little snippet of PHP that does
the double sha1 encoding:
&lt;pre style=&quot;background: #ddd; border: 1px solid #000; padding: 5px; line-height:1em;&quot;&gt;
% php -r &quot;echo &#039;*&#039;.strtoupper(sha1(sha1(&#039;your_pw&#039;,true)));&quot;

% mysql
mysql&gt; UPDATE mysql.user set Password=&#039;above_output&#039; where User=&#039;gearman&#039;;

% mysqladmin flush-privileges
&lt;/pre&gt;
 &lt;br /&gt;&lt;a href=&quot;http://toys.lerdorf.com/archives/51-Playing-with-Gearman.html#extended&quot;&gt;Continue reading &quot;Playing with Gearman&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Thu, 24 Sep 2009 14:57:32 -0700</pubDate>
    <guid isPermaLink="false">http://toys.lerdorf.com/archives/51-guid.html</guid>
    
</item>
<item>
    <title>Using pecl/oauth to post to Twitter</title>
    <link>http://toys.lerdorf.com/archives/50-Using-pecloauth-to-post-to-Twitter.html</link>
            <category>PHP</category>
    
    <comments>http://toys.lerdorf.com/archives/50-Using-pecloauth-to-post-to-Twitter.html#comments</comments>
    <wfw:comment>http://toys.lerdorf.com/wfwcomment.php?cid=50</wfw:comment>

    <slash:comments>5</slash:comments>
    <wfw:commentRss>http://toys.lerdorf.com/rss.php?version=2.0&amp;type=comments&amp;cid=50</wfw:commentRss>
    

    <author>rasmus@lerdorf.com (Rasmus)</author>
    <content:encoded>
    I have seen a lot of questions about &lt;a href=&quot; http://wiki.oauth.net/f/iiw-one-pager.pdf&quot;&gt;OAuth&lt;/a&gt; and specifically how to do OAuth from PHP.  We have a new &lt;a href=&quot;http://pecl.php.net/oauth&quot;&gt;pecl oauth extension&lt;/a&gt; written by &lt;a href=&quot;http://jawed.name/&quot;&gt;John Jawed&lt;/a&gt; which does a really good job simplifying OAuth.  
&lt;br /&gt;&lt;br /&gt;
I added Twitter support to &lt;a href=&quot;http://slowgeek.com&quot;&gt;Slowgeek.com&lt;/a&gt; the other day and it was extremely painless.  The goal was to let users have a way to have Slowgeek send a tweet on their behalf when they have completed a &lt;a href=&quot;http://nikeplus.nike.com&quot;&gt;Nike+&lt;/a&gt; run.  Here is a simplified description of what I did.
&lt;br /&gt;&lt;br /&gt;
First, I needed to get the user to authorize Slowgeek to tweet on their behalf.  This is done by asking Twitter for an access token and secret which will be stored on Slowgeek.  This access token and secret will allow us to act on behalf of the user.  This is made a bit easier by the fact that &lt;a href=&quot;http://apiwiki.twitter.com/OAuth-FAQ#Howlongdoesanaccesstokenlast&quot;&gt;Twitter does not expire access tokens&lt;/a&gt; at this point, so I didn&#039;t need to worry about an access token refresh workflow.
&lt;br /&gt;&lt;br /&gt;



 &lt;br /&gt;&lt;a href=&quot;http://toys.lerdorf.com/archives/50-Using-pecloauth-to-post-to-Twitter.html#extended&quot;&gt;Continue reading &quot;Using pecl/oauth to post to Twitter&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 27 Apr 2009 15:20:08 -0700</pubDate>
    <guid isPermaLink="false">http://toys.lerdorf.com/archives/50-guid.html</guid>
    
</item>

</channel>
</rss>