<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.1" -->
<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/"
	>

<channel>
	<title>Maciej Zawadziński blog</title>
	<link>http://zawadzinski.com</link>
	<description>"Programmer - an organism that turns coffee into software"</description>
	<pubDate>Sat, 21 Jun 2008 16:08:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
	<language>en</language>
			<item>
		<title>How to use MySQL Views in Symfony?</title>
		<link>http://zawadzinski.com/2008/01/15/how-to-use-mysql-views-in-symfony/</link>
		<comments>http://zawadzinski.com/2008/01/15/how-to-use-mysql-views-in-symfony/#comments</comments>
		<pubDate>Tue, 15 Jan 2008 00:45:50 +0000</pubDate>
		<dc:creator>mauser</dc:creator>
		
		<category><![CDATA[english]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[technical]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[propel]]></category>

		<guid isPermaLink="false">http://zawadzinski.pl/2008/01/15/how-to-use-mysql-views-in-symfony/</guid>
		<description><![CDATA[Although MySQL views tend to be sometimes (ok, let&#8217;s be sincere - they usually are) ineffective, we can  face a situation where we want to use them. Neither Symfony, nor Propel support natively views, but I found recently a little workaround for it.
Let&#8217;s assume we&#8217;ve got in our schema.yml:

entry:
  id:
  title: varchar(255)
 [...]]]></description>
			<content:encoded><![CDATA[<p>Although MySQL views tend to be sometimes (ok, let&#8217;s be sincere - they usually are) ineffective, we can  face a situation where we want to use them. Neither Symfony, nor Propel support natively views, but I found recently a little workaround for it.</p>
<p>Let&#8217;s assume we&#8217;ve got in our <em>schema.yml</em>:</p>
<pre class="prettyprint">
entry:
  id:
  title: varchar(255)
  body: longvarchar
  pub_date: { type: timestamp, index: true }</pre>
<p>which, after running <em>propel-build-all</em>, will give us two following classes (files) in lib/model:</p>
<p>Entry.php<br />
EntryPeer.php</p>
<p>We want to use a view, that shows entries from recent week, we so run the query:</p>
<pre class="prettyprint">
CREATE VIEW entry_recent AS SELECT * FROM entry
WHERE pub_date > CURRENT_DATE - INTERVAL 7 DAY;</pre>
<p>The question is <strong>how to get objects of <em>Entry</em> type from <em>entry_recent</em> table</strong>?</p>
<h3>Solution.</h3>
<p>Add an aditional table in <em>schema.yml</em> with <em>skipSql=true</em> attribute – it will result in generating php classes, but propel won&#8217;t generate any SQL code.</p>
<pre class="prettyprint">
entry_recent:
  _attributes: { skipSql: true, readOnly: true }
  id:
  title: varchar(255)
  body: longvarchar
  pub_date: { type: timestamp, index: true }</pre>
<p>It&#8217;s important that <em>entry_recent</em> has always the same columns as entry.<br />
After <em>propel-build-all</em> we have two additional classes:</p>
<p>EntryRecent.php<br />
EntryRecentPeer.php</p>
<p>Now we open EntryRecent.php and change the base class from <em>BaseEntryRecent</em> to <em>Entry</em>.</p>
<pre class="prettyprint">
class EntryRecent extends <strike>BaseEntryRecent</strike> Entry
{
}</pre>
<p>And that&#8217;s it.</p>
<p>When we want to use our view, we simply use <em>EntryRecentPeer</em> methods to retrieve objects – <em>doSelect()</em>, <em>doSelectOne()</em> methods will return us <em>EntryRecent</em> objects, but their superclass is <em>Entry</em>, so we can use all methods that we had previously wrtiten in <em>Entry.php</em>.</p>
<p>What&#8217;s more we can update our objects (normally we are not able to update views), because they will use <em>BaseEntry</em> class instead of <em>BaseEntryRecent</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://zawadzinski.com/2008/01/15/how-to-use-mysql-views-in-symfony/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to get video thumbnails from dailymotion?</title>
		<link>http://zawadzinski.com/2008/01/06/how-to-get-video-thumbnails-from-dailymotion/</link>
		<comments>http://zawadzinski.com/2008/01/06/how-to-get-video-thumbnails-from-dailymotion/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 11:37:53 +0000</pubDate>
		<dc:creator>mauser</dc:creator>
		
		<category><![CDATA[english]]></category>

		<category><![CDATA[technical]]></category>

		<category><![CDATA[api]]></category>

		<category><![CDATA[dailymotion]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://zawadzinski.pl/2008/01/06/how-to-get-video-thumbnails-from-dailymotion/</guid>
		<description><![CDATA[You can get thumbnails from YouTube easily using their API, but Dailymotion does not have API or any other intuitive way to download jpeg from specific video.  I made a little research and found a solution, that at least work for me.  When you are scanning webpages for videos you find embed tags [...]]]></description>
			<content:encoded><![CDATA[<p>You can get thumbnails from <a href="http://youtube.com">YouTube</a> easily using their <a href="http://code.google.com/apis/youtube/overview.html">API</a>, but <a href="http://dailymotion.com">Dailymotion</a> does not have API or any other intuitive way to download jpeg from specific video.  I made a little research and found a solution, that at least work for me.  When you are scanning webpages for videos you find embed tags with videos similiar to the one below:</p>
<blockquote><p><code class="prettyprint"> &lt;embed src="http://www.dailymotion.com/swf/IHnP80wxWqFSlg4ms" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" height="363" width="425"&gt;&lt;/embed&gt;</code></p></blockquote>
<p>At first I thought that I can get thumbnail using swf parameter <em>IHnP80wxWqFSlg4ms</em>. But it was wrong. We need first get the effective URL (after HTTP 302, or HTTP Location header forwarding). We can do it using <a href="http://curl.haxx.se/libcurl/">libcurl</a>:</p>
<pre class="prettyprint">
function getEffectiveUrl($url) {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_exec($ch);>

  $newurl = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
  curl_close($ch);

  return urldecode($newurl);
}</pre>
<p>Our effective URL looks like this:</p>
<blockquote><p>http://www.dailymotion.com/flash/flvplayer.swf?rev=1198003823&amp;<br />
statEnabled=1&amp;selfURL=http://www.dailymotion.com/Gregouze7<br />
/video/x2a39c_just-jack-starz-in-their-eyes_music&amp;<br />
&#8230; <em>(it is really long!)</em></p></blockquote>
<p>Now we can get from the effective URL two important information - <em>key</em> and <em>title</em> using the following simple regular expression:</p>
<blockquote><p><code class="prettyprint">#video/([a-z0-9]+)_([a-z0-9-]+)#i"</code></p></blockquote>
<p>So our <em>key</em> is <em>x2a39c</em>. We fetch the thumbnail from:</p>
<blockquote><p> http://www.dailymotion.com/thumbnail/320&#215;240/video/[<em>key</em>]</p></blockquote>
<p>And that&#8217;s it. There also other sizes available like 160&#215;120.</p>
]]></content:encoded>
			<wfw:commentRss>http://zawadzinski.com/2008/01/06/how-to-get-video-thumbnails-from-dailymotion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>(In)dependent woman or (in)dependent man.</title>
		<link>http://zawadzinski.com/2008/01/05/independent-woman-or-independent-man/</link>
		<comments>http://zawadzinski.com/2008/01/05/independent-woman-or-independent-man/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 21:10:43 +0000</pubDate>
		<dc:creator>mauser</dc:creator>
		
		<category><![CDATA[english]]></category>

		<category><![CDATA[personal]]></category>

		<category><![CDATA[independance]]></category>

		<category><![CDATA[woman]]></category>

		<guid isPermaLink="false">http://zawadzinski.pl/2008/01/05/independent-woman-or-independent-man/</guid>
		<description><![CDATA[Todays women wants more rights, become more independent. Sincerely I don&#8217;t care much about it, even think that they do the right thing, but this is a little bit too much:
&#8220;I don&#8217;t do any housework. No I don&#8217;t have a housekeeper who does it all for me, but I have a boyfriend, which is much [...]]]></description>
			<content:encoded><![CDATA[<p>Todays women wants more rights, become more independent. Sincerely I don&#8217;t care much about it, even think that they do the right thing, but this is a little bit too much:</p>
<p><em>&#8220;I don&#8217;t do any housework. No I don&#8217;t have a housekeeper who does it all for me, but I have a boyfriend, which is much cheaper&#8221;</em></p>
<p><a href="http://zawadzinski.pl/wp-content/uploads/2008/01/blogasek.png" title="Another side of independence"><img src="http://zawadzinski.pl/wp-content/uploads/2008/01/blogasek.jpg" alt="Another side of independence" border="0" /></a></p>
<p>So I prepared an answer:</p>
<p><em>&#8220;When your woman wants you to work in the kitchen&#8230; remember never give up your real work and passion. Be yourself!&#8221;</em></p>
<p><a href="http://zawadzinski.pl/wp-content/uploads/2008/01/blogasek2.png" title="Be yourself!"><img src="http://zawadzinski.pl/wp-content/uploads/2008/01/blogasek2.jpg" alt="Be yourself!" border="0" /></a></p>
<p>PS. I received the first picture from my girlfriend - think it means no good for me?</p>
]]></content:encoded>
			<wfw:commentRss>http://zawadzinski.com/2008/01/05/independent-woman-or-independent-man/feed/</wfw:commentRss>
		</item>
		<item>
		<title>sfFeed2Plugin patch</title>
		<link>http://zawadzinski.com/2008/01/05/sffeed2plugin-patch/</link>
		<comments>http://zawadzinski.com/2008/01/05/sffeed2plugin-patch/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 17:32:50 +0000</pubDate>
		<dc:creator>mauser</dc:creator>
		
		<category><![CDATA[english]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[technical]]></category>

		<category><![CDATA[atom]]></category>

		<category><![CDATA[feed]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://zawadzinski.pl/2008/01/05/sffeed2plugin-patch/</guid>
		<description><![CDATA[I wrote a small patch for sfFeed2Plugin (verson 0.9.4) to get feed&#8217;s generator field and comment feeds for each post.
The generator is an identificator of software that generated feed. It is quite obvious and both RSS and Atom formats support it.
However, comment feeds are a little bit more tricky.
In Atom you get something like that:
 [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a small patch for <a href="http://trac.symfony-project.com/wiki/sfFeed2Plugin">sfFeed2Plugin</a> (verson 0.9.4) to get feed&#8217;s <em>generator</em> field and comment feeds for each post.</p>
<p>The <em>generator</em> is an identificator of software that generated feed. It is quite obvious and both RSS and Atom formats support it.</p>
<p>However, comment feeds are a little bit more tricky.</p>
<p>In Atom you get something like that:</p>
<blockquote><p> <code>&lt;entry&gt;</code><br />
<code>...</code><br />
<code>&lt;link rel='replies' type='text/html' </code><br />
<code> href='http://blog.example.com/post-title/#comments'</code><br />
<code> title='Comments'/&gt;</code><br />
<code>&lt;link rel='replies' type='application/atom+xml' </code><br />
<code> href='http://blog.example.com/post-title/feed/' </code><br />
<code> title='Comment feed'/&gt;</code><br />
<code>...</code><br />
<code>&lt;/entry&gt;</code></p></blockquote>
<p>So we need <em>replies</em> link which has a mime type <em>application/atom+xml.</em></p>
<p>In RSS it is more straighforward:</p>
<blockquote><p> <code>&lt;item&gt;</code><br />
<code>...</code><br />
<code>   &lt;wfw:commentRss&gt;</code><br />
<code>   http://blog.example.com/post-title/feed/</code><br />
<code>   &lt;/wfw:commentRss&gt;</code><br />
<code>...</code><br />
<code>&lt;/item&gt;</code></p></blockquote>
<p>We simply get the <em>wfw:commentRss</em> field.</p>
<p>So how to use patched sfFeed2Plugin?</p>
<p>It is really easy, there is one additional method in <em>sfFeed</em> class called <em>getGenerator()</em>, and one in <em>sfFeedItem</em> class called <em>getCommentFeed()</em>:</p>
<blockquote><p><code> &lt;?php<br />
$feed = sfFeedPeer::createFromWeb($url);<br />
echo $feed-&gt;getGenerator()."\n";<br />
foreach($feed-&gt;getItems() as $item) {<br />
echo $item-&gt;getCommentFeed()."\n";<br />
}<br />
?&gt;<br />
</code></p></blockquote>
<p>How to apply the patch?</p>
<blockquote><p><code> $ cd sfFeed2Plugin/<br />
$ patch -p1 &lt; sfFeed2Plugin-094-mauser.patch<br />
</code></p></blockquote>
<p><a href="http://zawadzinski.pl/wp-content/uploads/2008/01/sffeed2plugin-094-mauser.patch" title="sfFeed2Plugin patch">Download patch</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zawadzinski.com/2008/01/05/sffeed2plugin-patch/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
