<?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>Radu Poenaru &#187; Others</title>
	<atom:link href="http://www.radupoenaru.com/category/my-work/others/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.radupoenaru.com</link>
	<description>Team leader and Software engineer</description>
	<lastBuildDate>Mon, 01 Aug 2011 20:47:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Adding new Social icons to the Mystique theme</title>
		<link>http://www.radupoenaru.com/adding-new-social-icons-to-mystique-theme/</link>
		<comments>http://www.radupoenaru.com/adding-new-social-icons-to-mystique-theme/#comments</comments>
		<pubDate>Sat, 08 Jan 2011 17:21:55 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1661</guid>
		<description><![CDATA[I use my blog to record and share my knowledge, but also to present to possible employers my skills. I use it like a marketing tool for my persona. For this, I need to make available not only the RSS and twitter account, but also resume profiles like Xing, LinkedIn and Facebook. <p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/adding-new-social-icons-to-mystique-theme/">Adding new Social icons to the Mystique theme</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadding-new-social-icons-to-mystique-theme%2F' data-shr_title='Adding+new+Social+icons+to+the+Mystique+theme'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadding-new-social-icons-to-mystique-theme%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadding-new-social-icons-to-mystique-theme%2F' data-shr_title='Adding+new+Social+icons+to+the+Mystique+theme'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadding-new-social-icons-to-mystique-theme%2F' data-shr_title='Adding+new+Social+icons+to+the+Mystique+theme'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2010/05/wordpress.png" rel="lightbox[1225]" title="WordPress, my favourite blogging system."><img align="left" alt="Adding child themes to WordPress, my favourite blogging system." border="0" height="150" src="http://www.radupoenaru.com/wp-content/uploads/2010/05/wordpress_thumb.png" style="border-width: 0px; margin: 10px; display: inline;" title="Adding child themes to WordPress, my favourite blogging system." width="150" /></a>I use my blog to record and share my knowledge, but also to present to possible employers my skills. I use it like a marketing tool for my persona. For this, I need to make available not only the <a href="http://www.radupoenaru.com/feed/">RSS</a> and <a href="http://twitter.com/radu_poenaru">Twitter</a> account, but also resume profiles like <a href="https://www.xing.com/profile/Radu_Poenaru">Xing</a>, <a href="http://www.linkedin.com/in/radupoe">LinkedIn</a> and <a href="http://www.facebook.com/radu.poenaru">Facebook</a>.</p>
<p>Since I am using <a href="http://www.radupoenaru.com/tag/wordpress/">WordPress </a>and I know a little bit of <a href="http://www.radupoenaru.com/tag/php/">PHP</a> and MySQL I wanted to customize my current theme.But some time ago I&rsquo;ve read that they <a href="http://codex.wordpress.org/Child_Themes" target="_blank">don&rsquo;t encourage</a> you to customize directly the chosen theme, but instead create your own child theme, with the desired customizations. This way, when the theme will be updated, you won&rsquo;t loose neither time nor brains trying to redo all the modifications.</p>
<p><span id="more-1661"></span></p>
<p>Creating a child theme, directly from the developers of WordPress</p>
<blockquote style="width: 90%;">
<p>Making a child theme is very simple. Create a directory, put a properly formatted <i>style.css</i> file in it, and you have a child theme! With a little understanding of HTML and <a href="http://codex.wordpress.org/CSS">CSS</a>, you can make that <i>very basic child theme</i> modify the styling and layout of a parent theme to any extent without editing the files of the parent theme itself. That way, when the parent theme is updated, your modifications are preserved.</p>
</blockquote>
<p>For some time ago, I started using child themes. At first, it seemed a useless time investment, but since then the theme was updated 3 or 4 times, so imagine each time creating a list of modifications to the original, implement them again and again in the new version!</p>
<p>Let&rsquo;s see some code!</p>
<p>The modification that I will present now is how to add new icons for job websites, up on the bar. The steps are:</p>
<p>1. Using your preffered image editing tool (I preffer using <a href="http://www.getpaint.net/">Paint .Net</a>, very smart and effective PNG producer) I modified the <strong>nav-icons.png </strong>file :</p>
<p>From :<img alt="The initial set of Social icons" border="0" height="64" src="http://www.radupoenaru.com/wp-content/uploads/2011/01/nav-icons_old.png" style="background-image: none; border-width: 0px; margin: 10px 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="Initial Social icons" width="128" /> To: <img alt="The final set of Social icons" border="0" height="64" src="http://www.radupoenaru.com/wp-content/uploads/2011/01/nav-icons.png" style="background-image: none; border-width: 0px; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px;" title="New set of Social icons" width="320" /></p>
<p>The extra icons are taken from a royality free icon pack. They are 64 by 64 pixels. You can modify their sizes, but you&rsquo;ll also have to update the javascript code that moves the images up and down.</p>
<p>Note: To make your life easier and keep the modifications to a minimum, keep the Twitter icon first and the RSS last, otherwise you&rsquo;ll have to override the entire $nav_extra underneath.</p>
<p>2.&nbsp; Add the icons in your child theme, by concatenating the script that shows new buttons with the one which is already present, containing the Twitter and RSS. If you want to change the order of the icons, you can change the lines order. If you want to make the RSS icon first, instead of adding strings to $nav_extra, you&rsquo;ll have to recreate also the RSS and Twitter strings and insert them in the string variable. Don&rsquo;t forget to add the action to WordPress queue, such that your function to be called:</p>
<pre class="brush: php" style="width: 90%;">function mystique_navbuttons_pics($nav_extra)
{
  $nav_extra .= &#39;&lt;a href=&quot;http://www.facebook.com/radu.poenaru&quot; class=&quot;nav-extra facebook&quot; target=&quot;_blank&quot; title=&quot;Contact me on Facebook!&quot;&gt;&lt;span&gt;Contact me on Facebook!&lt;/span&gt;&lt;/a&gt;&#39;;
  $nav_extra .= &#39;&lt;a href=&quot;http://www.linkedin.com/in/radupoe&quot; class=&quot;nav-extra linkedin&quot; target=&quot;_blank&quot; title=&quot;Contact me on LinkedIn!&quot;&gt;&lt;span&gt;Contact me on LinkedIn!&lt;/span&gt;&lt;/a&gt;&#39;;
  $nav_extra .= &#39;&lt;a href=&quot;https://www.xing.com/profile/Radu_Poenaru&quot; class=&quot;nav-extra xing&quot; target=&quot;_blank&quot; title=&quot;Contact me on Xing!&quot;&gt;&lt;span&gt;Contact me on LinkedIn!&lt;/span&gt;&lt;/a&gt;&#39;;

  $nav_extra = str_replace(&quot;title&quot;, &quot;target=&#39;_blank&#39; title&quot;, $nav_extra) ;

  return $nav_extra;
}
add_action(&#39;mystique_navigation_extra&#39;, mystique_navbuttons_pics&#39;);</pre>
<p>3. Add the CSS required by the icons. This requires each icon to know where to start cutting from main PNG file its own appearance. We will create and inject the CSS in the corresponding file.</p>
<pre class="brush: php" style="width: 90%;">function mystique_navbuttons_css(){
 $i = THEME_URL.&#39;/images&#39;; ?&gt;
/* Extra navigation icons */
#header a.xing{background: url(&lt;?php echo $i; ?&gt;/nav-icons.png) no-repeat scroll -192px top transparent}
#header a.linkedin{background: url(&lt;?php echo $i; ?&gt;/nav-icons.png) no-repeat scroll -64px top transparent}
#header a.facebook{background: url(&lt;?php echo $i; ?&gt;/nav-icons.png) no-repeat scroll -128px top transparent}

&lt;?php
}
add_action(&#39;mystique_css&#39;,&#39;mystique_navbuttons_css&#39;);</pre>
<p>That&rsquo;s all guys, now you have a child theme wit your customizations and never afraid that you&rsquo;ll have to spend time again when the theme will be updated!</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/adding-new-social-icons-to-mystique-theme/">Adding new Social icons to the Mystique theme</a></p>
<div class="shr-publisher-1661"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/adding-new-social-icons-to-mystique-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>7 easy steps to use Webmatrix and WordPress local development</title>
		<link>http://www.radupoenaru.com/7-easy-steps-to-use-webmatrix-and-wordpress-local-development/</link>
		<comments>http://www.radupoenaru.com/7-easy-steps-to-use-webmatrix-and-wordpress-local-development/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 09:14:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Webmatrix]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1656</guid>
		<description><![CDATA[Almost all good developers that I know have some kind of repository of their code. Mine is my blog, this blog. Stay with me and you’ll find out how to easily be able to create your local version of Wordpress, customize and test your plugins.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/7-easy-steps-to-use-webmatrix-and-wordpress-local-development/">7 easy steps to use Webmatrix and WordPress local development</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2F7-easy-steps-to-use-webmatrix-and-wordpress-local-development%2F' data-shr_title='7+easy+steps+to+use+Webmatrix+and+Wordpress+local+development'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2F7-easy-steps-to-use-webmatrix-and-wordpress-local-development%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2F7-easy-steps-to-use-webmatrix-and-wordpress-local-development%2F' data-shr_title='7+easy+steps+to+use+Webmatrix+and+Wordpress+local+development'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2F7-easy-steps-to-use-webmatrix-and-wordpress-local-development%2F' data-shr_title='7+easy+steps+to+use+Webmatrix+and+Wordpress+local+development'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2011/01/webmatrix.png"><img align="left" alt="Use Webmatrix to setup your local WordPress development environment." border="0" height="77" src="http://www.radupoenaru.com/wp-content/uploads/2011/01/webmatrix_thumb.png" style="background-image: none; border-width: 0px; margin: 10px; padding-left: 0px; padding-right: 0px; display: inline; float: left; padding-top: 0px;" title="Webmatrix" width="74" /></a>Almost all good developers that I know have some kind of repository of their code. Mine is my blog, this blog. Stay with me and you&rsquo;ll find out how to easily be able to create your local version of WordPress, customize and test your plugins.</p>
<p>For&acute;this you&rsquo;ll need to follow the next steps:</p>
<ol>
<li>Go to Webmatrix official website and download the Web Platform Installer which will install for you not only Webmatrix itself, but also a lot of useful tools like an integrated webserver, Internet Information Services Express, PHP interpretor and its connectors just to name a few. But you can also use it to add new features like ASP .Net MVC3!<span id="more-1656"></span></li>
<li>Because now the install of MySQL server is not any more supported, you&rsquo;ll have to install it by yourself &ndash; go to their <a href="http://dev.mysql.com/downloads/mysql/5.1.html" target="_blank">official website</a> and download it from there. Choose the MSI Installer essentials and the process will be very easy. I prefer to install it as a service and then, from Control Panel &ndash;&gt; Services, to set it to start manually. This way won&rsquo;t eat resources when it is not needed.</li>
<li>Next, we&rsquo;ll download a MySQL GUI called <a href="http://www.heidisql.com/" target="_blank">HeidiSQL</a> &ndash; free and smart product. One might say that command line is enough, but I would rather concentrate on development instead of memorizing all those commands.</li>
<li>Create an empty database and a user. I personally like to set the database name, user and its password to the ones that I use on my production WordPress website. This way, I only have to modify only the DBHost in the WordPress&rsquo; configuration file.</li>
<li>Create a production database backup using your prefered tool &ndash; I use for quite a while the <a href="http://wordpress.org/extend/plugins/wp-db-backup/" target="_blank">WP-DB-Backup</a> plugin for WordPress to generate my scheduled backups. Import&nbsp; the content of the backup (using HeidiSQL is very easy &ndash; just point it to a zip, gzip archive or a sql file).</li>
<li>Now that we setup our database, let&rsquo;s go to the code &ndash; download locally the sources of your website using FTP or other tools that your hosting provides, open Webmatrix and create a new website using local files. This way you will setup your development workspace wherever you like &ndash; I prefer to use D: drive. Otherwise, you&rsquo;ll be prompted to use your MyDocuments folder which will not be available any more in case of windows clean reinstall &ndash; the entire c: drive will be wiped-out.</li>
<li>Make the proper changes to the wp-config file (if you followed my advice you&rsquo;ll just have to replace in DBHost your production server with localhost). Hit Run (the small green arrow from the Webmatrix top ribbon) and you&rsquo;re good to go!</li>
</ol>
<p>If by any change you get a blank window in your prefered browser stating that &ldquo;</p>
<h3>Error establishing a database connection</h3>
<p>&rdquo; or something like this, go and check that in your hosts file (found in c:\Windows\System32\drivers\etc\) you have uncommented the line with localhost:</p>
<p>&nbsp;</p>
<p># For example: <br />
	# <br />
	#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 102.54.94.97&nbsp;&nbsp;&nbsp;&nbsp; rhino.acme.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # source server <br />
	#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 38.25.63.10&nbsp;&nbsp;&nbsp;&nbsp; x.acme.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # x client host</p>
<p># localhost name resolution is handled within DNS itself. <br />
	&nbsp;&nbsp;&nbsp; 127.0.0.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; localhost <br />
	#&nbsp;&nbsp;&nbsp; ::1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; localhost</p>
<p>Happy coding!</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/7-easy-steps-to-use-webmatrix-and-wordpress-local-development/">7 easy steps to use Webmatrix and WordPress local development</a></p>
<div class="shr-publisher-1656"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/7-easy-steps-to-use-webmatrix-and-wordpress-local-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add Syntax Highlight to WordPress</title>
		<link>http://www.radupoenaru.com/how-to-add-syntax-highlight-to-wordpress/</link>
		<comments>http://www.radupoenaru.com/how-to-add-syntax-highlight-to-wordpress/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 10:32:39 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Syntax Highlight]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1403</guid>
		<description><![CDATA[How to add SyntaxHilight in a child theme for the Wordpress blog. THis way you'll be able to update your theme without losing the additional scripts that customise it. Or move to another theme while keeping your favorite scripts attached to it.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/how-to-add-syntax-highlight-to-wordpress/">How to add Syntax Highlight to WordPress</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-add-syntax-highlight-to-wordpress%2F' data-shr_title='How+to+add+Syntax+Highlight+to+Wordpress'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-add-syntax-highlight-to-wordpress%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-add-syntax-highlight-to-wordpress%2F' data-shr_title='How+to+add+Syntax+Highlight+to+Wordpress'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-add-syntax-highlight-to-wordpress%2F' data-shr_title='How+to+add+Syntax+Highlight+to+Wordpress'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a title="WordPress, my favourite blogging system." href="http://www.radupoenaru.com/wp-content/uploads/2010/05/wordpress.png" rel="lightbox[1225]"><img style="border-right-width: 0px; margin: 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Adding child themes to WordPress, my favourite blogging system." border="0" alt="Adding child themes to WordPress, my favourite blogging system." align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/05/wordpress_thumb.png" width="150" height="150" /></a>I wrote quite a while ago about <a href="http://www.radupoenaru.com/implement-syntax-highlighting/" target="_blank">How to implement Syntax Highlight</a> in your WordPress blog. It used an forward, yet permanent approach: modify you’re theme’s <a href="http://www.radupoenaru.com/how-to-add-a-nice-jquery-slider/" target="_blank">header.php</a>. But is it enough?</p>
<p>Lately, I wanted to update my blog’s theme to the newest version. But hey! I had a lot of modifications such the one above that kept me from doing a smooth update: <a href="http://www.radupoenaru.com/bnr-exchange-rate/" target="_blank">BNR Slider,</a> custom images for RSS and Twitter, hints, Syntax Highlight and so on.</p>
<p>The newest solution that I come up with is using a child theme, feature provided by WordPress engine. Basically, you have a theme applied to you blog that you like. Instead of modifying it, you create a new folder in theme’s directory with a special name who’ll be applied OVER your base theme, customizing only the aspects you need. Assuming that your theme’s name is <strong>MyFavoriteTheme</strong>, you’ll have to create the child theme as <strong>MyFavoriteTheme-child</strong>. </p>
<p>In order to use your new theme, you’ll have to create in the<strong> MyFavoriteTheme-child</strong> folder two files:</p>
<ol>
<li>styles.css – required – who’ll mark your folder as a child theme </li>
<li>functions.php – optional – for our example is required, as we’ll write code inside of it </li>
</ol>
<p> <span id="more-1403"></span>
<p>First, you Really need to setup the styles. The content is simple and explained in <a href="http://codex.wordpress.org/Child_Themes" target="_blank">this straight-forward article</a>.</p>
<p>The most interesting part is the functions.php, where we’ll define code to add our Syntax Highlight classes. You’ll have to put all needed JavaScript files in the /scripts folder, in the root of the WordPress install, and the css files respectively in /styles folder. This is just for easy of migration from one theme to the other, if you get bored or want to change your current one.</p>
<p>Then, in the aforementioned functions.php from your <strong>MyFavoriteTheme-child</strong> folder you have to insert the following text:</p>
<pre class="brush: php">&lt;?php
$path_to_scripts = &quot;/scripts/&quot;;
$path_to_styles = &quot;/styles/&quot;;

function register_syntaxhighlight() {
  wp_enqueue_script('shcore',  $path_to_scripts.'shcore.js');

  wp_enqueue_script('shbrushcsharp', $path_to_scripts.'shBrushCSharp.js');
  wp_enqueue_script('shbrushcpp', $path_to_scripts.'shBrushCpp.js');
  wp_enqueue_script('shbrushcss', $path_to_scripts.'shBrushCss.js');
  wp_enqueue_script('shbrushobjc', $path_to_scripts.'shBrushObjC.js');
  wp_enqueue_script('shbrushjscript', $path_to_scripts.'shBrushJScript.js');
  wp_enqueue_script('shbrushphp', $path_to_scripts.'shBrushPhp.js');
  wp_enqueue_script('shbrushplain', $path_to_scripts.'shBrushPlain.js');
  wp_enqueue_script('shbrushruby', $path_to_scripts.'shBrushRuby.js');
  wp_enqueue_script('shbrushsql', $path_to_scripts.'shBrushSql.js');
  wp_enqueue_script('shbrushxml', $path_to_scripts.'shBrushXml.js');
  wp_enqueue_script('shbrushas3', $path_to_scripts.'shBrushAs3.js');
  wp_enqueue_script('shbrushjava', $path_to_scripts.'shBrushJava.js');
  wp_enqueue_script('shbrushSql', $path_to_scripts.'shBrushSql.js');

  wp_enqueue_script('shstarter', $path_to_scripts.'shstarter.js', array('shcore'));

  wp_enqueue_style('shcore',  $path_to_styles.'shcore.css');
  wp_enqueue_style('shThemeDefault', $path_to_styles.'shThemeDefault.css');
}

add_action('init', 'register_syntaxhighlight');

?&gt;</pre>
<p>The code explanation:</p>
<ol>
<li>First we set some global vars, to know where the directories are; </li>
<li>Then we create a new function in which we add one by one the scripts required for the site – you can add the ones that you use and when you’ll post some content that requires a new brush, the shCore will kindly alert you that one of the brushes is missing, specify also the name of it. This way you’ll load only the ones used and no more, keeping the webpage size low and quality high. </li>
<li>wp_enqueue_script assures that the script will be loaded once. So if it is already loaded by any other plugin or theme, you will not have it downloaded twice; </li>
<li>finally, we add an WordPress action, binding to the init hook and add there our code. </li>
</ol>
<p>After uploading your code to your WordPress install (be careful to names &#8211; Linux is case sensitive), you’ll have to select as theme the child theme, so your modification will be applied. Until you’ll select the child theme, you will not see any changes!</p>
<p>That’s it, folks! </p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/how-to-add-syntax-highlight-to-wordpress/">How to add Syntax Highlight to WordPress</a></p>
<div class="shr-publisher-1403"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/how-to-add-syntax-highlight-to-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Add Silverlight to WordPress</title>
		<link>http://www.radupoenaru.com/add-silverlight-to-wordpress-2/</link>
		<comments>http://www.radupoenaru.com/add-silverlight-to-wordpress-2/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 17:45:04 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1354</guid>
		<description><![CDATA[Few easy steps to add your Silverlight application to your favorite blogging system (mine is Wordpress).<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/add-silverlight-to-wordpress-2/">Add Silverlight to WordPress</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-silverlight-to-wordpress-2%2F' data-shr_title='Add+Silverlight+to+Wordpress'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-silverlight-to-wordpress-2%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-silverlight-to-wordpress-2%2F' data-shr_title='Add+Silverlight+to+Wordpress'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-silverlight-to-wordpress-2%2F' data-shr_title='Add+Silverlight+to+Wordpress'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a class="cboxElement" title="silverlight" href="http://www.radupoenaru.com/wp-content/uploads/2010/06/silverlight1.png" rel="lightbox[1338]"><img style="border-right-width: 0px; margin: 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Few easy steps to add your Silverlight application to your favorite blogging system (mine is WordPress)." border="0" alt="Few easy steps to add your Silverlight application to your favorite blogging system (mine is WordPress)." align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/06/silverlight_thumb1.png" width="91" height="89" /></a>
<p>As I presented earlier, you can easily create a <a href="http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/">Silverlight video player</a> and you can see it working <a href="http://www.radupoenaru.com/railscasts-silverlight-video-player/">pretty nice</a>. Not to mention that it can play&#160; a lot of formats and it is only 344 kb in size!&#160; Now let’s see how this is possible and how can one do it on his website.</p>
<p>From the start, <a href="http://www.radupoenaru.com/tag/silverlight-4/">Silverlight</a> was meant to be as easiest as possible to develop and deploy. Also, the cross browser (running on all major browsers) and cross platform (running on Linux, <a href="http://www.radupoenaru.com/tag/objective-c">Mac OSX</a> and Windows) was a requirement. But more than this, not to depend on the server side on .Net framework was also important. So you can deploy and run (only for running you’ll need the Silverlight Runtime installed) your app no matter the OS (Operating System).</p>
<p>This is why we discuss today on adding Silverlight to WordPress and not on How to deploy Silverlight on Linux. From the server’s OS point of view, Silverlight is just another file so you don’t need any plugin nor installs on the server side. It is on the client side where it is downloaded, setup with parameters and processed and here you need to install the Silverlight runtime – a mere of 4 Mb. If you’ve developed prior Adobe Flash application, you’ll feel very natural on the process. So let’s begin our ride to add your Silverlight application to WordPress.</p>
<h4>Step 1.</h4>
<p>Develop your Silverlight application. You should have a .xap file built in order to go further. </p>
</p>
<p> <span id="more-1354"></span><br />
<h4>Step 2.</h4>
<p>Upload to your WordPress blog your Silverlight application to a folder of your desire and then the Silverlight.js file that you find in your Visual Studio solution, in the web application project (I prefer to the root’s scripts folder). If you don’t find it, you can take it from <a href="http://www.radupoenaru.com/scripts/silverlight.js">here</a>, but beware that this might be outdated. Afterwards, create a new file, called silverlight_app.js ( I prefer lowercasing all my server side files so I won’t have problems with case-sensitive OS like Linux). In that file, paste the following script (the default way to handle Silverlight errors) and then upload it also:</p>
<pre class="brush: js">
function onSilverlightError(sender, args) {
    var appSource = &quot;&quot;;
    if (sender != null &amp;&amp; sender != 0) {
        appSource = sender.getHost().Source;
    }

    var errorType = args.ErrorType;
    var iErrorCode = args.ErrorCode;

    if (errorType == &quot;ImageError&quot; || errorType == &quot;MediaError&quot;) {
        return;
    }

    var errMsg = &quot;Unhandled Error in Silverlight Application &quot; +  appSource + &quot;\n&quot; ;

    errMsg += &quot;Code: &quot;+ iErrorCode + &quot;    \n&quot;;
    errMsg += &quot;Category: &quot; + errorType + &quot;       \n&quot;;
    errMsg += &quot;Message: &quot; + args.ErrorMessage + &quot;     \n&quot;;

    if (errorType == &quot;ParserError&quot;) {
        errMsg += &quot;File: &quot; + args.xamlFile + &quot;     \n&quot;;
        errMsg += &quot;Line: &quot; + args.lineNumber + &quot;     \n&quot;;
        errMsg += &quot;Position: &quot; + args.charPosition + &quot;     \n&quot;;
    }
    else if (errorType == &quot;RuntimeError&quot;) {
        if (args.lineNumber != 0) {
            errMsg += &quot;Line: &quot; + args.lineNumber + &quot;     \n&quot;;
            errMsg += &quot;Position: &quot; +  args.charPosition + &quot;     \n&quot;;
        }
        errMsg += &quot;MethodName: &quot; + args.methodName + &quot;     \n&quot;;
    }

    throw new Error(errMsg);
}</pre>
<p>Add references to both files in your WordPress theme&#8217;s header file, inside the &lt;head&gt;&lt;/head&gt; tag (you can edit the header.php).Note that even if the theme’s folder way deep from the root, the actual page processing is done in the root, where core web files are located. This is why we have added scripts with this path:</p>
<pre class="brush: html">&lt;script src=&quot;scripts/silverlight.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;scripts/silverlight_app.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<h4>Step 3. </h4>
<p>Create a new article in which you put the Silverlight object. Note that some blog editors (like Windows LiveWriter doesn’t like to have inside the article &lt; or &gt; so you’ll have to replace them with their HTML equivalents &amp;lt; and &amp;gt;). Also replace the PathTo with your actual path&#160; where you uploaded your Silverlight application ( can be a relative path or full http path – as long as you point to the application’s directory) and YourSilverlightApplicationName.xap with the actual name of your application :</p>
<pre class="brush: html">&lt;form id=&quot;form1&quot; style=&quot;height:100%&quot;&gt;
&lt;div id=&quot;silverlightControlHost&quot; style=&quot;width:400px; height:300px&quot; &gt;
    &lt;object data=&quot;data:application/x-silverlight-2,&quot; type=&quot;application/x-silverlight-2&quot; width=&quot;100%&quot; height=&quot;100%&quot;&gt;
	  &lt;param name=&quot;source&quot; value=&quot;PathTo/YourSilverlightApplicationName.xap&quot;/&gt;
	  &lt;param name=&quot;onError&quot; value=&quot;onSilverlightError&quot; /&gt;
	  &lt;param name=&quot;background&quot; value=&quot;white&quot; /&gt;
	  &lt;param name=&quot;minRuntimeVersion&quot; value=&quot;4.0.50401.0&quot; /&gt;
	  &lt;param name=&quot;autoUpgrade&quot; value=&quot;true&quot; /&gt;
	  &lt;a href=&quot;http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.50401.0&quot; style=&quot;text-decoration:none&quot;&gt;
			  &lt;img src=&quot;http://go.microsoft.com/fwlink/?LinkId=161376&quot; alt=&quot;Get Microsoft Silverlight&quot; style=&quot;border-style:none&quot;/&gt;
	  &lt;/a&gt;
    &lt;/object&gt;&lt;iframe id=&quot;_sl_historyFrame&quot; style=&quot;visibility:hidden;height:0px;width:0px;border:0px&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;/form&gt;</pre>
<h4>Step 4. </h4>
<p>Post the article and your hard worked Silverlight application!</p>
<p>That’s all! </p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/add-silverlight-to-wordpress-2/">Add Silverlight to WordPress</a></p>
<div class="shr-publisher-1354"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/add-silverlight-to-wordpress-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Silverlight VideoPlayer for RailsCasts</title>
		<link>http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/</link>
		<comments>http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 14:28:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1338</guid>
		<description><![CDATA[This is my second shot, this time in Silverlight 4, to develop a video player for RailsCasts. I learned a great bunch of stuff and used IValueConverter, RSS parsing with LINQtoXML, XAML, deep template customisation, dispatching.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/">Silverlight VideoPlayer for RailsCasts</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fsilverlight-videoplayer-for-railscasts%2F' data-shr_title='Silverlight+VideoPlayer+for+RailsCasts'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fsilverlight-videoplayer-for-railscasts%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fsilverlight-videoplayer-for-railscasts%2F' data-shr_title='Silverlight+VideoPlayer+for+RailsCasts'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fsilverlight-videoplayer-for-railscasts%2F' data-shr_title='Silverlight+VideoPlayer+for+RailsCasts'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2010/06/silverlight1.png"><img style="border-right-width: 0px; margin: 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="silverlight" border="0" alt="silverlight" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/06/silverlight_thumb1.png" width="91" height="89" /></a>
<p>I am and will be a Microsoft Developer. While working for convenience with other tools, I love strong type languages. I don’t want to ship products because I saved once and hit “s” one more time, so my product will be shipped with that small, human and yet unpardonable error in code. </p>
<p>How many times did you loose your time and effort with PHP in order to find a small mistake like this?</p>
<p>In my pursue on Microsoft tools path I started enjoying the Silverlight technology. Who might not know, Silverlight is a competitor to Flash. By now, on its 4th version, is way above Adobe Flash in almost all areas (I actually worked with Flex and Flash recently, so I really know what I’m talking about):</p>
<ul>
<li>Easy to develop : the C# language is a world class, easy to write in, with good compiler, a lot of resources and a VERY good IDE (try to write code and animations in same time in that Flash IDE and you’ll see what I mean) </li>
<li>Supports Full HD (there are examples on the net with 2 or 3 full HD movies playing), while Flash just tries to get HD with lots of CPU used. </li>
<li>The model of development is the same for in Browser and Out of Browser – you don’t need to change the tool from Flash to Flex in order to have same product for Desktop and Web. </li>
</ul>
<p> <span id="more-1338"></span>
<p>So I want to really learn, but what example shall I have? My <a href="http://www.radupoenaru.com/unibonn/">second job</a> as student is to work in Uni-Bonn, developing a <a href="http://www.radupoenaru.com/tag/ruby-on-rails/">Ruby on Rails</a> solution for them. While this is also an interpreted language, the RubyMine IDE makes it possible not to miss a variable or a mistyped string. It doesn’t provide types, but still, it’s a step forward. To improve my Rails skills I use a lot the website of a professional Ruby developer, <a href="http://railscasts.com/">Ryan Bates</a>. He has a lot of RailsCasts and he adds one each week. But unfortunately, being an Apple user, the movie is encoded as .mov file. I discovered that on the second link, with smaller font, provides also an .m4p link.</p>
<p>So I&#160; started developing a web Silverlight player for its movies. Yeah, I know, the web is full of them, but I wanted to lean this technology and also improve my access to Rails Casts.</p>
<p>I begun with a simple Silverlight project, adding a MediaElement on the canvas and set its Source property to a movie. It immediately started playing – was a nice experience by now. But you need controls for moving along the movie timeline, a list from which to choose your desired movie.</p>
<p>Thus, I started creating two User controls – one for MediaElement controls, and other for retrieving the guy’s rss feed, parse it and display it nicely. While the controls were quite fast to develop, the list took more time. Also because I wanted to learn a little bit of Expression Blend. So I used the Shawn Wildermuth’s <a href="http://wildermuth.com/dls/Dirty_Little_Secrets_Episode_2">Dirty Little Secret #2</a> and learn deep custom templating for a Listbox.</p>
<p>Putting all together was a breeze, the most time used was for testing the final product.</p>
<p>You can go directly to the Silverlight player and <a href="http://www.radupoenaru.com/railscasts-silverlight-video-player/">see the result</a>.</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/">Silverlight VideoPlayer for RailsCasts</a></p>
<div class="shr-publisher-1338"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Railscasts Silverlight video player</title>
		<link>http://www.radupoenaru.com/railscasts-silverlight-video-player/</link>
		<comments>http://www.radupoenaru.com/railscasts-silverlight-video-player/#comments</comments>
		<pubDate>Mon, 31 May 2010 10:46:36 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1328</guid>
		<description><![CDATA[Silverlight 4 player for RailsCasts. Created by Radu Poenaru using Silverlight 4, XAML, skining a ListBox completely,  deep control templates, IValueConverters, LinqToXml RSS feed parsing.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/railscasts-silverlight-video-player/">Railscasts Silverlight video player</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Frailscasts-silverlight-video-player%2F' data-shr_title='Railscasts+Silverlight+video+player'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Frailscasts-silverlight-video-player%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Frailscasts-silverlight-video-player%2F' data-shr_title='Railscasts+Silverlight+video+player'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Frailscasts-silverlight-video-player%2F' data-shr_title='Railscasts+Silverlight+video+player'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://www.radupoenaru.com/wp-content/uploads/2009/06/microsoft-silverlight.jpg"><img style="border-right-width: 0px; margin: 10px 20px 10px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="microsoft_silverlight" border="0" alt="microsoft_silverlight" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2009/06/microsoft-silverlight-thumb.jpg" width="134" height="150" /></a>
<p>This is my second shot to create a better player for Railcasts. As you can see, it goes better and better. Who knows what might be next?</p>
<div>If you want to know more about the process through&#160; which this player was designed you can read also:</div>
<ul>
<li><a href="http://www.radupoenaru.com/silverlight-videoplayer-for-railscasts/">How and why I choose the Silverlight platform</a> </li>
<li><a href="http://www.radupoenaru.com/add-silverlight-to-wordpress-2/">How to integrate your Silverlight content with your WordPress blog</a> (and presumable all blog systems who allow you to add JavaScript) </li>
</ul>
<form style="height: 100%" id="form1" runat="server">
<div style="width: 400px; height: 300px" id="silverlightControlHost"><object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"><param name="source" value="http://www.radupoenaru.com/ClientBin/RailsPlayer.xap" /><param name="onError" value="onSilverlightError" /><param name="background" value="white" /><param name="enableHtmlAccess" value="true"/><param name="minRuntimeVersion" value="4.0.50401.0" /><param name="autoUpgrade" value="true" /><a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.50401.0" style="text-decoration:none">  			  <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none" /> 		  </a> 	    </object><iframe style="border-right-width: 0px; width: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px; visibility: hidden; border-left-width: 0px" id="_sl_historyFrame"></iframe></div>
</p></form>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/railscasts-silverlight-video-player/">Railscasts Silverlight video player</a></p>
<div class="shr-publisher-1328"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/railscasts-silverlight-video-player/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Create a simple HTML .MOV player</title>
		<link>http://www.radupoenaru.com/create-a-simple-html-mov-player/</link>
		<comments>http://www.radupoenaru.com/create-a-simple-html-mov-player/#comments</comments>
		<pubDate>Wed, 26 May 2010 13:05:25 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1304</guid>
		<description><![CDATA[As a Ruby developer, I work quite a lot with their “special” plugins called gems. The nice fact about the gems is that they bring lots of functionality. By example, there’s a gem for paginating a collection who takes just few parameters and not only that finds out how many objects the collection has, but&#8230;<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/create-a-simple-html-mov-player/">Create a simple HTML .MOV player</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fcreate-a-simple-html-mov-player%2F' data-shr_title='Create+a+simple+HTML+.MOV+player'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fcreate-a-simple-html-mov-player%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fcreate-a-simple-html-mov-player%2F' data-shr_title='Create+a+simple+HTML+.MOV+player'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fcreate-a-simple-html-mov-player%2F' data-shr_title='Create+a+simple+HTML+.MOV+player'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img style="border-right-width: 0px; margin: 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="This is how I added ui-icon to JQuery tabs" border="0" alt="This is how I added ui-icon to JQuery tabs" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/05/jqueryui1.png" width="73" height="73" />
<p>As a <a href="http://www.radupoenaru.com/unibonn/" target="_blank">Ruby developer</a>, I work quite a lot with their “special” plugins called gems. The nice fact about the gems is that they bring lots of functionality. By example, there’s a gem for paginating a collection who takes just few parameters and not only that finds out how many objects the collection has, but also how to split them, generating the corresponding links and serving to the original container (that used to show the entire collection) only the collection part that is representative in the context of current page and items per page.</p>
<p>Before someone new to a specific gem starts thinking to implement it, usually searches on the net for examples. The most important gems are described and exemplified in <a href="http://railscasts.com" target="_blank">Railscasts.com</a>. The content is excelent, the quality is good, sound is nice but the format chosen for movies is Apple’s .MOV proprietary format. There are few plugins to install for playing the files with MediaPlayer, but frankly I wanted a quicker solution than go on some obscure websites and getting from there a creepy .exe installer.</p>
<p>So I’ve created a simple .mov player that will replace the <strong>33 MB </strong>of useless QuickTime Player (if you’re a Mac user, you have already this installed so you’ll not need my hack).</p>
<p><a href="http://www.radupoenaru.com/online-mov-player/">Go directly to the player &gt;</a></p>
<p>So let’s see some code!</p>
<p>First, I decided to use the Object method in order to play mov files. Apple provides a .cab file, who is able to play this files in browser. More documentation on its parameters you can find in their <a href="http://support.apple.com/kb/TA26486?viewlocale=en_US" target="_blank">Embedding</a> tutorial.</p>
<p>Don’t forget to add a link to JQuery library!</p>
<pre class="brush: html">&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;</pre>
<p>The html code is shown below and it is pretty straight forward:</p>
<pre class="brush: html">&lt;body&gt;
&lt;div class=&quot;media&quot;&gt;
  &lt;div class=&quot;navigationTabs&quot;&gt;
      &lt;input type=&quot;text&quot; id=&quot;txtURL&quot; style=&quot;width:75%&quot;/&gt;
      &lt;input type=&quot;button&quot; id=&quot;btnPlayMov&quot; value=&quot;Play&quot;/&gt;
      &lt;input type=&quot;button&quot; id=&quot;btnClearMov&quot; value=&quot;Clear&quot;/&gt;
      &lt;/div&gt;
      &lt;div id=&quot;divPlayer&quot;&gt;

http://media.railscasts.com/videos/188_declarative_authorization.mov

  &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;</pre>
<p>The JavaScript is a little bit trickier as it involves JQuery.&#160; For a newbie, it is pretty hard to debug, but after a while you’ll just feel it:</p>
<pre class="brush: js">$(function() {
  // bind an onClick event for this second Flash container
  $(&quot;#btnPlayMov&quot;).click(function() {
    var _height = &quot;306px&quot;;
    var _width = &quot;400px&quot;;
    var _movie =  $('#txtURL').val();

    var _html = '<object width="' + _width +
          '" height="' + _height +
          '" classid = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" >';
    _html += '<param name="src" value="' + _movie + ' ">';
    _html += '<param name="scale" value="tofit">';
    _html += '<embed width="' + _width + '" height="' + _height + '" src="' + _movie + '" scale="tofit" pluginspage="http://www.apple.com/quicktime/download/"></embed>';
    _html += '</object>';

    $(&quot;#divPlayer&quot;).html(_html);
  });

  $(&quot;#btnClearMov&quot;).click(function() {
    $(&quot;#divPlayer&quot;).html(&quot;http://media.railscasts.com/videos/188_declarative_authorization.mov&quot;);
  })
})</pre>
<p>Not to mention that it works in all major browsers (IE 8, FireFox 3.6 and Chrome) !</p>
<p><a href="http://www.radupoenaru.com/online-mov-player/">Go directly to the player &gt;</a></p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/create-a-simple-html-mov-player/">Create a simple HTML .MOV player</a></p>
<div class="shr-publisher-1304"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/create-a-simple-html-mov-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://media.railscasts.com/videos/188_declarative_authorization.mov" length="38117771" type="video/quicktime" />
		</item>
		<item>
		<title>How to generate image_src for Facebook links in WordPress theme</title>
		<link>http://www.radupoenaru.com/how-to-generate-image_src-for-facebook-links-in-wordpress-theme/</link>
		<comments>http://www.radupoenaru.com/how-to-generate-image_src-for-facebook-links-in-wordpress-theme/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 19:56:12 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=1203</guid>
		<description><![CDATA[In this article I present a script that sets the first image in a post as default image for sharing links in Facebook.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/how-to-generate-image_src-for-facebook-links-in-wordpress-theme/">How to generate image_src for Facebook links in WordPress theme</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-generate-image_src-for-facebook-links-in-wordpress-theme%2F' data-shr_title='How+to+generate+image_src+for+Facebook+links+in+Wordpress+theme'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-generate-image_src-for-facebook-links-in-wordpress-theme%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-generate-image_src-for-facebook-links-in-wordpress-theme%2F' data-shr_title='How+to+generate+image_src+for+Facebook+links+in+Wordpress+theme'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fhow-to-generate-image_src-for-facebook-links-in-wordpress-theme%2F' data-shr_title='How+to+generate+image_src+for+Facebook+links+in+Wordpress+theme'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img style="border-right-width: 0px; margin: 10px 20px 0px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Generate WordPress article to be attached when using Facebook links: image_src tag" border="0" alt="Generate WordPress article to be attached when using Facebook links: image_src tag" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/02/facebook2.png" width="124" height="155" />Sharing your article for free advertisement on Facebook is a fact. While using different Social Networks sharing tools I had a problem when sharing my articles on Facebook: sometimes the image that I intended to use to represent the article wouldn’t show in the list of the images who can be chosen. Why is that?</p>
<p>It bothered me some while I got the some free time to actually look into this, between <a href="http://www.radupoenaru.com/media-informatics-master/" target="_blank">exams</a>, <a href="http://www.radupoenaru.com/category/my-work/fit/" target="_blank">work</a> and <a href="http://www.radupoenaru.com/how-to-make-a-print-screen-on-microsoft-source-using-wpf/" target="_blank">master research</a>. After some wandering on the internet, I found <a href="http://wiki.developers.facebook.com/index.php/Facebook_Share/Specifying_Meta_Tags" rel="nofollow" target="_blank">here</a> the correct directions. What I learnt:<strong> <font color="#ff0000">Always search for the API! </font></strong></p>
<p>&#160;</p>
<blockquote style="width: 100%"><p>In order to make sure that the preview is always correctly populated, you should add the tags shown below to the &lt;head&gt; element in your HTML code. If you don&#8217;t tag your page, Facebook Share will grab the title of your page as specified in the &lt;title&gt; tag, and will create a summary description from the first text that appears in the body of your page. A list of thumbnails will all be selected from available images on your page. </p>
<p>You can control the exact title, description, and thumbnail that Facebook Share uses by adding the following meta tags to the &lt;head&gt; element in your page: </p>
<p>&lt;meta name=&quot;title&quot; content=&quot;title&quot; /&gt; &lt;meta name=&quot;description&quot; content=&quot;description &quot; /&gt; &lt;link rel=&quot;image_src&quot; href=&quot;thumbnail_image&quot; / &gt;</p>
</blockquote>
<p> <span id="more-1203"></span>
<p>Also, beware of this fact:</p>
<blockquote style="width: 100%"><p>The thumbnail_image is the URL to the image that appears in the Feed story. The thumbnail&#8217;s width or height must be at least 50 pixels, and cannot exceed 130&#215;110 pixels. The ratio of both height divided by width and width divided by height (w / h, h / w)<strong> cannot exceed 3.0</strong>. For example,<strong> an image of 126&#215;39 pixels will not be displayed</strong>, as the ratio of width divided by height is greater than 3.0 (126 / 39 = 3.23). Images will be resized proportionally. </p>
</blockquote>
<p>OK. so these are the Facebook requirements. How can we implement them?</p>
<p>So let’s get into some code.</p>
<p>First, I tried to modify the theme – adding the following code to the header.php file:</p>
<pre class="brush: php">$id =$post-&gt;ID;
$the_content =$wpdb-&gt;get_var(&quot;SELECT post_content FROM $wpdb-&gt;posts WHERE ID = $id&quot;);
$pattern = '!&lt;img.*?src=&quot;(.*?)&quot;!';
preg_match_all($pattern, $the_content, $matches);
echo '&lt;link $image_src=&quot;$matches['1'][0];&quot; $matches); $the_content, preg_match_all($pattern, /&gt;';</pre>
<p>While it is workable, from performace point of view isn&#8217;t very nice because you try to read at ANY page refresh the post and show the image. But what if you&#8217;re on the first page with lots of posts? Or in archive? The code that I settled in the final was placed in functions.php file in my current theme. It allows me to use triggers that output to the head of the page the desired content and also to do this only when a single post page is requested. The code is: </p>
<pre class="brush: php">function add_image_src(){

  global $post;
	// get the global variable post
  // if it exists and is only a single post
  if ($post){

    // pattern for recognizing first image in post
    $pattern = '!&lt;img.*?src=&quot;(.*?)&quot;!';
    preg_match_all($pattern, $post-&gt;post_content, $matches);

    //first image would be the representative image
    $image_src = $matches['1'][0];
    // extract it as Facebook wants it
    echo '&lt;link rel=&quot;image_src&quot; href=&quot;', $image_src,'&quot; /&gt;';
  }
}

// hooking to the head generation loop my function defined above
add_action('wp_head', 'add_image_src');</pre>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/how-to-generate-image_src-for-facebook-links-in-wordpress-theme/">How to generate image_src for Facebook links in WordPress theme</a></p>
<div class="shr-publisher-1203"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/how-to-generate-image_src-for-facebook-links-in-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Add SyntaxHighlight to Windows Live Writer in Preview mode</title>
		<link>http://www.radupoenaru.com/add-syntaxhiglight-to-windows-live-writer-in-preview-mode/</link>
		<comments>http://www.radupoenaru.com/add-syntaxhiglight-to-windows-live-writer-in-preview-mode/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 04:25:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[My work]]></category>
		<category><![CDATA[Others]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Syntax Highlight]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[User experience]]></category>
		<category><![CDATA[Windows Live Writer]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=993</guid>
		<description><![CDATA[Windows Live Writer is one of the most popular blog authoring tool that I also happen to like and use  because of its features – I especially enjoy the Preview tab. But it has a drawback - no Syntax Highlighting of my code! Let me tell you how I solved this issue.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/add-syntaxhiglight-to-windows-live-writer-in-preview-mode/">Add SyntaxHighlight to Windows Live Writer in Preview mode</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-syntaxhiglight-to-windows-live-writer-in-preview-mode%2F' data-shr_title='Add+SyntaxHighlight+to+Windows+Live+Writer+in+Preview+mode'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-syntaxhiglight-to-windows-live-writer-in-preview-mode%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-syntaxhiglight-to-windows-live-writer-in-preview-mode%2F' data-shr_title='Add+SyntaxHighlight+to+Windows+Live+Writer+in+Preview+mode'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fadd-syntaxhiglight-to-windows-live-writer-in-preview-mode%2F' data-shr_title='Add+SyntaxHighlight+to+Windows+Live+Writer+in+Preview+mode'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img style="border-right-width: 0px; margin: 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Add SyntaxHiglight to Windows Live Writer in Preview mode" border="0" alt="Add SyntaxHiglight to Windows Live Writer in Preview mode" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/02/WLWriter.png" width="100" height="100" /> <a href="http://windowslivewriter.spaces.live.com/blog/cns!D85741BB5E0BE8AA!174.entry" target="_blank">Windows Live Writer</a> (shorter: WLW) is one of the most popular blog authoring tool that I also happen to like and use. And I say this because of its features – I especially enjoy the Preview tab. But what it really lacks is previewing the ENTIRE page &#8211; it will get only the html and some css. So no <a href="http://www.radupoenaru.com/implement-syntax-highlighting/">Syntax Highlighting</a> of my code? Let me tell you how I solved this issue.</p>
<p>As a blog writer I searched for something that could allow me to write the articles offline and then upload them in WordPress. I also tried <a href="http://wordpress.org/" target="_blank">WordPress</a> built-in editor, but the editing box is so small that I couldn’t use it too much.</p>
<p>The most important feature for me is that it retrieves the blog theme and has a preview function that provide you the same look on editor window. So you will be able to write a post with a preview. But when having a more complex theme, using JQuery or Prototype, you will discover that you don’t get any more the same look and feel as in the blog. This is partially ok for editing, but sometimes it is really bad – especially if you’re a programmer and add a lot of code in your page. On blogs there is a solution to <a href="http://www.radupoenaru.com/syntaxhighlighter-how-to-use-it-and-brushes-available/">show the code with syntax color</a>, but in the Windows Live Writer I couldn’t find one suitable plug-in that does this.</p>
<p> <span id="more-993"></span>
</p>
<p>So it’s time for a simple and nice hack: while registering your blog in main menu entry Blogs – Edit blog settings, it will retrieve the page format for the preview feature. Searching in Windows 7 special directories, I found where it stores the blog template:</p>
<p>For Windows 7 and Vista users: <strong>C:\Users\YourUserName\AppData\Roaming\Windows Live Writer\blogtemplates\</strong></p>
<p>For Windows XP users: <strong>C:\Documents and Settings/YourUserName/Application data/Windows Live</strong></p>
<p>In this folder you’ll find as many folders as blogs you have registered in WLW – so it’s a matter of luck to find the right one. Basically, you have to navigate inside of each one and you’ll find there 2 HTML files:&#160; index.htm and index[1].htm and some not interesting folders containing associated images and css files. </p>
<p>First I tried to edit the index.htm file, who seems to be used by WLW to decorate the Edit view and inserted the following code right above the &lt;/HEAD&gt; tag:</p>
<pre class="brush:xml">&lt;link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/&gt;
&lt;link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'&gt;&lt;/script&gt;
&lt;script language='javascript'&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf';
SyntaxHighlighter.all();
&lt;/script&gt;</pre>
<p><strong>But surprise!</strong> Editing tab was changed, code nice highlighted , but it also modified&#160; the Source tab in the way that now contained also all the HTML generated by Syntax Highlighter. After undo, I was able to see again my page as it was before. So I modified in the same way index[1].htm file, which I found that is responsible for the Preview tab and it worked like a charm. So now I have the same Syntax highlight in WLW as on my blog!</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/add-syntaxhiglight-to-windows-live-writer-in-preview-mode/">Add SyntaxHighlight to Windows Live Writer in Preview mode</a></p>
<div class="shr-publisher-993"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/add-syntaxhiglight-to-windows-live-writer-in-preview-mode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Import CSV file and query it with LINQ</title>
		<link>http://www.radupoenaru.com/import-csv-file-and-query-it-with-linq/</link>
		<comments>http://www.radupoenaru.com/import-csv-file-and-query-it-with-linq/#comments</comments>
		<pubDate>Thu, 04 Feb 2010 19:02:00 +0000</pubDate>
		<dc:creator>Radu Poenaru</dc:creator>
				<category><![CDATA[2009 - Fraunhofer FIT]]></category>
		<category><![CDATA[Others]]></category>
		<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[CSV Parsing]]></category>
		<category><![CDATA[Import CSV]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[Microsoft]]></category>

		<guid isPermaLink="false">http://www.radupoenaru.com/?p=973</guid>
		<description><![CDATA[Assume that you have an plain text, old Comma Separated Values file filled with your precious export from a legacy system. How can you process it easily now? The first answer that is worth considering is parse it to LINQ, the language-integrated query, which is a collection of extensions to the .NET Framework that encompass language-integrated query, set, and transform operations.<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/import-csv-file-and-query-it-with-linq/">Import CSV file and query it with LINQ</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimport-csv-file-and-query-it-with-linq%2F' data-shr_title='Import+CSV+file+and+query+it+with+LINQ'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimport-csv-file-and-query-it-with-linq%2F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimport-csv-file-and-query-it-with-linq%2F' data-shr_title='Import+CSV+file+and+query+it+with+LINQ'></a><a class='shareaholic-tweetbutton' data-shr_count='none' data-shr_href='http%3A%2F%2Fwww.radupoenaru.com%2Fimport-csv-file-and-query-it-with-linq%2F' data-shr_title='Import+CSV+file+and+query+it+with+LINQ'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetTop Automatic --><p><img style="border-right-width: 0px; margin: 10px 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="How to easily import CSV file and query it with LINQ" border="0" alt="How to easily import CSV file and query it with LINQ" align="left" src="http://www.radupoenaru.com/wp-content/uploads/2010/02/CsvDelimited.png" width="100" height="100" /> Assume that you have an plain text, old Comma Separated Values file filled with your precious export from a legacy system. How can you process it easily now? The first answer that comes to mind is to parse it and load it into a datatable and later process it by using DataTable.Select() method. But this approach has some limitations – like splitting data into several tables and then join them.</p>
<p>One would imagine that parsing CSV files is a straightforward and boring task, given that it is quite a while since CSV is around. Some of them are correct &#8211; in the sense that many implementations merely use some splitting method like <code>String.Split()</code>. Some don’t even offer the specification of the values splitting character – so your file wouldn’t be parsed correctly if instead of <strong>,</strong> you have <strong>; </strong>as separator – yet another thing to modify if you’re lucky enough to have the sources. Others will not handle properly field values with commas because the simple split method of the String class. But there are better implementations that take care about escaped quotes, trimming spaces before and after fields and other small and useful details, but very few that I found did it all as I liked it &#8211; and at least as importantly, in a <strong>fast</strong> and <strong>efficient</strong> manner.</p>
<p> <span id="more-973"></span>
</p>
<p>After trying several methods to parse the csv file, I endup using <b><a href="http://www.codeproject.com/Members/Matt-Perdeck">Matt Perdeck</a>’</b>s LINQ to CSV library presented in its article on <a href="http://www.codeproject.com/KB/linq/LINQtoCSV.aspx">The Code Project</a> website.</p>
<p>Among the feature that I used and liked very much I would mention (from the article):</p>
<ul>
<li>Follows the <a href="http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm">most common rules for CSV files</a>. Correctly handles data fields that contain commas and line breaks. </li>
<li>In addition to comma, most delimiting characters can be used, including tab for tab delimited fields. </li>
<li>Can be used with an <code>IEnumerable</code> of an anonymous class &#8211; which is often returned by a LINQ query. </li>
<li>Supports deferred reading. </li>
<li>Supports processing files with international date and number formats. </li>
<li>Supports different character encodings if you need them. </li>
<li>Recognizes a wide variety of date and number formats when reading files. </li>
<li>Provides fine control of date and number formats when writing files. </li>
<li>Robust error handling, allowing you to quickly find and fix problems in large input files. </li>
</ul>
<p>Using the library is straight-forward: after downloading the zip file from the <a href="http://www.codeproject.com/KB/linq/LINQtoCSV.aspx">The Code Project</a> (this required that you have an account there) you can start using it by including it as a referenced library in your project.</p>
<p>Next step is to define the layout of your csv file, in a manner that CSVtoLINQ to be able to map the data from file (which is pure text) to correct data types :</p>
<pre class="brush: csharp">using LINQtoCSV;
using System;

class Product
{
    [CsvColumn(Name = &quot;ProductName&quot;, FieldIndex = 1)]
    public string Name { get; set; }

    [CsvColumn(FieldIndex = 2, OutputFormat = &quot;dd MMM HH:mm:ss&quot;)]
    public DateTime LaunchDate { get; set; }

    [CsvColumn(FieldIndex = 3, CanBeNull = false, OutputFormat = &quot;C&quot;)]
    public decimal Price { get; set; }

    [CsvColumn(FieldIndex = 4)]
    public string Country { get; set; }

    [CsvColumn(FieldIndex = 5)]
    public string Description { get; set; }
}</pre>
<p>As you can see, there are lots of types that you can apply to your class.</p>
<p>Then you have to declare the using clause in your source file, where you want to use it:</p>
<pre>using LINQtoCSV;</pre>
<p>Then, all you need is to start using the library by adding this code</p>
<pre class="brush: csharp">private void btnLoad_Click(object sender, EventArgs e) {
  openFile.Filter = &quot;CSV Files|*.csv&quot;;
  openFile.Title = &quot;Open CSV File&quot;;

  if (openFile.ShowDialog() == DialogResult.OK) {
    textBox1.Text = openFile.FileName;

    CsvFileDescription inputFileDescription = new CsvFileDescription {
      // cool - I can specify my own separator!
      SeparatorChar = ';',
      FirstLineHasColumnNames = true
    };

    CsvContext cc = new CsvContext();

    bEvents =
      cc.Read<beventtype>(openFile.FileName, inputFileDescription);

    // elegantly parse the LINQ outputed by the parser
    var bALLEvents =
      from p in bEvents
      orderby p.EventID
      select new { p.EventID, p.EventName, p.SourceName, p.TargetName };

    // binding to DataGridView
    // Notice the conversion to a List of the bALLEvents collection
    dataGridView1.DataSource = bALLEvents.ToList();
  }
}</pre>
<p>That’s it, folks – Enjoy and share!</p>
<p>Post from: <a href="http://www.radupoenaru.com">Radu Poenaru's Weblog</a><br/><br/><a href="http://www.radupoenaru.com/import-csv-file-and-query-it-with-linq/">Import CSV file and query it with LINQ</a></p>
<div class="shr-publisher-973"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.radupoenaru.com/import-csv-file-and-query-it-with-linq/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->

