<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>HEAVYWORKS</title>
	
	<link>http://www.heavyworks.net</link>
	<description>Extreme Software Engineering</description>
	<lastBuildDate>Fri, 05 Mar 2010 16:58:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Heavyworks" /><feedburner:info uri="heavyworks" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Heavyworks</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/OHEAES-JcAQ/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin</link>
		<comments>http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:58:35 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Translation]]></category>
		<category><![CDATA[forum]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[l10n]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=435</guid>
		<description><![CDATA[We released today with the help of Bulli Castelo the internationalization file for this wonderful  forum plugin.
The language files can be found at the official Simple:Press Forum translations website.
Enjoy!

Related posts:Brazillian Portuguese (pt_BR) language file for WP-Filebase released
5 best practices on developing Wordpress plugins
Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences



Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-for-wp-filebase-released' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file for WP-Filebase released'>Brazillian Portuguese (pt_BR) language file for WP-Filebase released</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>We released today with the help of <a href="http://www.bullicastelo.com">Bulli Castelo</a> the internationalization file for this wonderful Wordpress<a title="Wordpress @ Wikipedia" href="http://en.wikipedia.org/wiki/Wordpress" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> forum plugin.</p>
<p>The language files can be found at the <a href="http://translate.simplepressforum.com/translations/brazilian/">official Simple:Press Forum translations website</a>.</p>
<p>Enjoy!</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-for-wp-filebase-released' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file for WP-Filebase released'>Brazillian Portuguese (pt_BR) language file for WP-Filebase released</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin</feedburner:origLink></item>
		<item>
		<title>Typing less with SSH</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/-RDufOPbF0U/typing-less-with-ssh</link>
		<comments>http://www.heavyworks.net/blog/posts/typing-less-with-ssh#comments</comments>
		<pubDate>Thu, 04 Mar 2010 21:17:41 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[aliases]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=419</guid>
		<description><![CDATA[
For me as a  user I always had to type long lines to start my  sessions. It&#8217;s no rocket science, you know, but for he who types thousands of characters each day, each character save is golden.
We usally start our SSH sessions by typing the following command string:

ssh user@domain.tld

I&#8217;ve tried to shorten this [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/ubuntu-is-going-windows-way' rel='bookmark' title='Permanent Link: Ubuntu is going Windows-way'>Ubuntu is going Windows-way</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/quick-tip-forcing-www-to-avoid-duplicate-content' rel='bookmark' title='Permanent Link: Quick Tip: Forcing www. to avoid duplicate content'>Quick Tip: Forcing www. to avoid duplicate content</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/221006_5456.jpg" alt="" title="" width="608" height="252" class="alignnone size-full wp-image-427" /></p>
<p>For me as a Linux<a title="Linux @ Wikipedia" href="http://en.wikipedia.org/wiki/Linux" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> user I always had to type long lines to start my <acronym title="Secure Shell">SSH</acronym><a title="SSH @ Wikipedia" href="http://en.wikipedia.org/wiki/Ssh" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> sessions. It&#8217;s no rocket science, you know, but for he who types thousands of characters each day, each character save is golden.</p>
<p>We usally start our <acronym title="Secure Shell">SSH</acronym> sessions by typing the following command string:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>domain.tld</pre></div></div>

<p>I&#8217;ve tried to shorten this by adding the domain and its <acronym title="Top Level Domain">TLD</acronym><a title="TLD @ Wikipedia" href="http://en.wikipedia.org/wiki/Tld" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> to my <code>hosts</code> file with a shorter alias like</p>
<pre>
hname hostname.tld
</pre>
<p>But obviously that crashed against Apache<a title="Apache @ Wikipedia" href="http://en.wikipedia.org/wiki/Apache" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> Vhost<a title="Vhost @ Wikipedia" href="http://en.wikipedia.org/wiki/Vhost" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> capability, the request never make it to the other end.</p>
<p>I personally have <acronym title="Secure Shell">SSH</acronym> keys on some of my servers to avoid typing passwords, that is good to prevent against MITM<a title="MITM @ Wikipedia" href="http://en.wikipedia.org/wiki/Mitm" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> attacks and keyloggers, but I still have to type the string mentioned lines above.</p>
<p>Then, with 3 lines in a <acronym title="Secure Shell">SSH</acronym>&#8217;s configuration file on my home directory (yes, you don&#8217;t need to alter the server&#8217;s <acronym title="Secure Shell">SSH</acronym> configuration file and yes, you can do that on your shared hosting&#8217;s shell account).<br />
<span id="more-419"></span><br />
It&#8217;s very simple. <acronym title="Secure Shell">SSH</acronym> allows some user-based configuration in your <code>~/.ssh</code> directory (note that <code>~</code> stands for your home directory (usually <code>/home/yourusername</code>) and it also provides Aliases<a title="Aliases @ Wikipedia" href="http://en.wikipedia.org/wiki/Aliases" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> capability.</p>
<p>The aliases can be configured in such a way that you won&#8217;t need to type neither the FQDN<a title="FQDN @ Wikipedia" href="http://en.wikipedia.org/wiki/Fqdn" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> nor even type a single username EVER MORE! </p>
<p>Your old</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>domain.tld</pre></div></div>

<p>will be shortened to</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> aliasname</pre></div></div>

<h2>Ok, talk is cheap, show me the code!</h2>
<h3>Creating the need files and directories</h2>
<p>All the magic occurs on the <code>config</code> in your already-mentioned <code>~/.ssh/</code> directory. If you don&#8217;t have one, create it and secure it, as the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">700</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>If the file does not exists, create it and secure it propperly, like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">touch</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>config
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">600</span> ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>config</pre></div></div>

<h3>Syntax model</h3>
<pre>
Host [alias name]
HostName [host's fqdn]
User [username to log-in as]
</pre>
<p><em>Without the braces, please!</em></p>
<p>For a user called <code>jdoe</code> on <code>mydomain.com</code> being shorted <code>md</code>, the code would be the following:</p>
<pre>
Host md
HostName mydomain.com
User jdoe
</pre>
<p>Save the file and you can start typing less with SSH:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ssh</span> md</pre></div></div>

<p>And that&#8217;s IT!</p>
<h2>Wow that&#8217;s great! What else this beauty can do?</h2>
<h3>Omnipresence</h3>
<p>Do you have the same username in a large number of machines, like in a local network? So you have to love the <code>*</code> wildcard.</p>
<pre>
Host *
User jdoe
</pre>
<h3>I have many names</h3>
<p>Want to follow a naming pattern but also wants to have shorter ones? Give multiple aliases!</p>
<pre>
Host gdf, gandalf
HostName gandalf.mydomain.com
User jdoe
</pre>
<h3>Avoid the front door</h3>
<p>Security through obscurity is always fun! Have your <acronym title="Secure Shell">SSH</acronym> aliases even in hosts with <code>sshd</code> running in a different port.</p>
<pre>
Host md
HostName mydomain.com
User jdoe
Port 11
</pre>
<h3>Be backwards compatible</h3>
<p>Have outdated <acronym title="Secure Shell">SSH</acronym> servers? I hope not! But if you do, you may also define a different protocol in a host-based manner.</p>
<pre>
Host md
HostName mydomain.com
User jdoe
Protocol 1
</pre>
<h3>Handle multiple keys</h3>
<p>You may specify the specific (what?) <acronym title="Secure Shell">SSH</acronym> key file for a host.</p>
<pre>
Host md
HostName mydomain.com
User jdoe
IdentityFile ~/mykey.pub
</pre>
<h2>And it also works on SCP!</h2>
<p>Oh yeah, file transfers are easier now!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">scp</span> somefile.txt md:<span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>upload</pre></div></div>

<p>More parameters can be found on <acronym title="Secure Shell">SSH</acronym> manual, page 5.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #000000;">5</span></pre></div></div>

<p>Phew! That&#8217;s all folks! Hope it helps someone as much as helped me! Anyone have any neat <acronym title="Secure Shell">SSH</acronym> trick?</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/ubuntu-is-going-windows-way' rel='bookmark' title='Permanent Link: Ubuntu is going Windows-way'>Ubuntu is going Windows-way</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/quick-tip-forcing-www-to-avoid-duplicate-content' rel='bookmark' title='Permanent Link: Quick Tip: Forcing www. to avoid duplicate content'>Quick Tip: Forcing www. to avoid duplicate content</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/typing-less-with-ssh/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/typing-less-with-ssh</feedburner:origLink></item>
		<item>
		<title>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/xRbxYPp2IIc/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences</link>
		<comments>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences#comments</comments>
		<pubDate>Tue, 23 Feb 2010 06:58:08 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[custom fields]]></category>
		<category><![CDATA[get_post_meta]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp_enqueue_script]]></category>
		<category><![CDATA[wp_enqueue_style]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=401</guid>
		<description><![CDATA[Sometimes you want to include page-specific  or  files and ended up in cluttered ifs and else ifs or even creating a creepy new page just for that.
&#8217;s excellent plugin infrastructure with their hooks and actions provides us a beautiful and clean form of including our JavaScript in specific pages.
In this tutorial, we will [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/wp-minifys-new-version-vanished-wordpress-http-requests-issue' rel='bookmark' title='Permanent Link: WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue'>WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin'>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to include page-specific JavaScript<a title="JavaScript @ Wikipedia" href="http://en.wikipedia.org/wiki/Javascript" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> or <acronym title="Cascading Style Sheets">CSS</acronym><a title="CSS @ Wikipedia" href="http://en.wikipedia.org/wiki/Css" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> files and ended up in cluttered <code>if</code>s and <code>else if</code>s or even creating a creepy new page just for that.</p>
<p>Wordpress<a title="Wordpress @ Wikipedia" href="http://en.wikipedia.org/wiki/Wordpress" class="wikipedia" rel="external wikipedia"><sup>w</sup></a>&#8217;s excellent plugin infrastructure with their hooks and actions provides us a beautiful and clean form of including our JavaScript in specific pages.</p>
<p>In this tutorial, we will be using three Wordpress functions: <code>get_post_meta()</code> and <code>wp_enqueue_script()</code> and <code>wp_enqueue_style()</code>.<br />
<span id="more-401"></span></p>
<h2>Custom Fields</h2>
<p>Well, you may have noticed that <code>get_post_meta()</code> is about the custom fields and you&#8217;re just right. </p>
<p>We&#8217;ll be using posts and pages custom field to add scripts and stylesheet files. I&#8217;m using the keys &#8216;js&#8217; and &#8216;css&#8217; to JavaScript and <acronym title="Cascading Style Sheets">CSS</acronym> files respectively.</p>
<p>If you don&#8217;t know how to use custom fields, please visit the <a href="http://codex.wordpress.org/Custom_Fields">Wordpress documentation on Custom Fields</a>.</p>
<p>The documentation on these functions are available at Wordpress documentation site:</p>
<dl>
<dt><code>get_post_meta</code></dt>
<dd><a href="http://codex.wordpress.org/Function_Reference/get_post_meta" title="get_post_meta documentation">http://codex.wordpress.org/Function_Reference/get_post_meta</a></dd>
<dt><code>wp_enqueue_style</code></dt>
<dd><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style" title="wp_enqueue_style documentation">http://codex.wordpress.org/Function_Reference/wp_enqueue_style</a></dd>
<dt><code>wp_enqueue_script</code></dt>
<dd><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" title="wp_enqueue_script documentation">http://codex.wordpress.org/Function_Reference/wp_enqueue_script</a></dd>
</dl>
<h2><code>get_post_meta</code></h2>
<p>This function is responsible by getting our custom field entries and returning them as an array.<br />
If one or more  entries are found, the array is returned with normal indexes (0..1&#8230;) and with the custom field values. If no entries are found, an empty array is returned.</p>
<p>Well, our return type will be always array so <code>foreach</code> will fit perfectly even on an empty set.</p>
<h2><code>header.php</code> file</h2>
<p>All code described in the following examples must be placed at least one line before the <code>wp_head()</code> function in your <code>header.php</code> file. if your <code>header.php</code> file is missing a <code>wp_head()</code> call, it shouldn&#8217;t. <code>wp_head()</code> function does lots of important things and many plugins use it. Please consider adding it to your code.</p>
<h2><code>wp_enqueue_script</code> and <code>wp_enqueue_style</code></h2>
<p>Some plugin developers may be not aware of these beautiful functions or even how scripts and stylesheets are managed by Wordpress.</p>
<p>All scripts and style, when properly set, are enqueued and inserted automatically when <code>wp_head()</code> is called. Enqueuing your scripts and style are a better way other than just hooking <code>wp_head()</code> and printing to the output buffer.</p>
<p>This assures that our scripts and styles will be included only at the <code>wp_head()</code> call and will not be printed out from nowhere messing out peoples templates and plugins.</p>
<p><em>NOTE: Due the printing menace of <code>script</code> tags and JavaScript code chunks, <a href="/blog/tag/wp-minify"><acronym title="WordPress">WP</acronym>-Minify</a> parses the ENTIRE site output in order to properly minify them.</em></p>
<p>This technique also prevents overlapping includes of twicely defined entries.</p>
<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/queue.gif" alt="CSS and JavaScript files happy in the queue" title="CSS and JavaScript files happy in the queue" width="600" height="417" class="aligncenter size-full wp-image-413" /><br />
Wordpress gives us respectively <code>wp_enqueue_script</code> and <code>wp_enqueue_style</code> for enqueueing scripts and stylesheets. Both functions receive a script or stylesheet unique identifier as the first parameter and the path as second (more parameters are available, please refer to the documentation for more understanding on this subject).</p>
<p>As this is an automated process, I&#8217;m using as unique identifier the md5 hash of the file&#8217;s path (the custom field value).</p>
<p><em>NOTE: This solution is made for JavaScript and <acronym title="Cascading Style Sheets">CSS</acronym> files that follows a unique parent directory. Please refer to the examples for more explanation.</em></p>
<p>So let&#8217;s get back to our <code>header.php</code> file just before the <code>wp_head()</code> call that we mentioned before. We also remember that the custom field key for JavaScript files that we&#8217;ll be using in this example is &#8216;js&#8217;.</p>
<h3>JavaScript files</h3>
<p>The following code will use <code>get_post_meta</code> to get the array (empty or not) of JavaScript files that have been set through custom fields under the <code>js</code> folder under our template directory.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$js</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'js'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$jscript</span><span style="color: #009900;">&#41;</span> wp_enqueue_script<span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$jscript</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/js/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$jscript</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3><acronym title="Cascading Style Sheets">CSS</acronym> files</h3>
<p>The following code will use <code>get_post_meta</code> to get the array (empty or not) of <acronym title="Cascading Style Sheets">CSS</acronym> files that have been set through custom fields under the <code>css</code> folder under our template directory.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$css</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'css'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$style</span><span style="color: #009900;">&#41;</span> wp_enqueue_style<span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$style</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>get_bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template_directory'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/css/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$style</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Simple huh? One line each and your problems are solved.</p>
<p>You may now call <code>wp_head()</code> and go drink your coffee!</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/wp-minifys-new-version-vanished-wordpress-http-requests-issue' rel='bookmark' title='Permanent Link: WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue'>WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin'>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences</feedburner:origLink></item>
		<item>
		<title>5 best practices on developing Wordpress plugins</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/o46k-HAjz0o/5-best-practices-on-developing-wordpress-plugins</link>
		<comments>http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins#comments</comments>
		<pubDate>Sun, 21 Feb 2010 19:34:20 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[cleanup]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=383</guid>
		<description><![CDATA[
Wordpress wonders me how it born as a Blogging platform and is growing a powerful CMS platform. Its plugin framework is full of hooks and actions and almost everything can be trapped and modified by plugins.
As Wordpress is a  oriented platform the function wrapped to the hooks and actions have no scope when called [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/wp-minifys-new-version-vanished-wordpress-http-requests-issue' rel='bookmark' title='Permanent Link: WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue'>WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin'>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/plugin.jpg" alt="Wordpress Plugins" title="Wordpress Plugins" width="484" height="296" class="aligncenter size-full wp-image-395" /><br />
Wordpress wonders me how it born as a Blogging platform and is growing a powerful <acronym title="Content Management System">CMS</acronym> platform. Its plugin framework is full of hooks and actions and almost everything can be trapped and modified by plugins.</p>
<p>As Wordpress is a Procedural Programming<a title="Procedural Programming @ Wikipedia" href="http://en.wikipedia.org/wiki/Procedural_programming" class="wikipedia" rel="external wikipedia"><sup>w</sup></a> oriented platform the function wrapped to the hooks and actions have no scope when called except global this can be hell when developing plugins. We must take extra-care to not compromise our plugin security and compatibility.</p>
<p>In our road developing plugins we learned some lessons, here is our share.<span id="more-383"></span></p>
<h2>1. Enable your WP_DEBUG</h2>
<p>This caused me some nightmares the first time I turned it on. Lots of plugin developers doesn&#8217;t have the habit of working with <acronym title="Pre-Hypertext Processing">PHP</acronym>&#8217;s <code>error_reporting</code> at the <code>E_ALL</code> level (Maximum Level, including notices of undefined variables) and I god SEVERAL notices on screen.</p>
<p><code>WP_DEBUG</code> can be enabled by simply adding the following line to your <code>wp-config.php</code> file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_DEBUG'</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><acronym title="Pre-Hypertext Processing">PHP</acronym> is a very friendly (if we can call this way) programming language that doesn&#8217;t cares very much to variable initialization but you should initialize all your variables and check if they are set with the language&#8217;s native <code>isset()</code> function.</p>
<p>If you have <code>WP_DEBUG</code> you will se NO errors at all so if your script breaks somewhere at the development, you&#8217;ll suffer lots of pain trying to blindly debug your code. Lots of experience had me finding unclosed brackets, parentheses and semicolons but, come on, I&#8217;m no masochist.</p>
<p>The best tip here is to have a development Wordpress installation. If this is not possible (or you are just too lazy), as lots of plugin developers (very popular ones) aren&#8217;t caring about notices showing up to your visitors if you have WP_DEBUG enabled you can always use the good and old <acronym title="Pre-Hypertext Processing">PHP</acronym> code to enable debug only if you are the visitor.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># 200.200.200.200 is an example IP and should be replaced by your own
</span><span style="color: #666666; font-style: italic;"># if you don't know your IP you can visit www.whatismyip.com
</span><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'200.200.200.200'</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WP_DEBUG'</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>2. Have a cleanup deactivation routine</h2>
<p>Had you ever took a look at your <code>wp_options</code> table after a long time activating and deactivating plugins? If you so you probably had seen the garbage left out there.</p>
<p>If you are going to write an option with <cod>add_option</code> or <code>update_option</code> please, please, please, be sure to remove your options upon plugin deactivation. I'm pretty sure no one wants your options leftovers as a souvenir.</p>
<p>To achieve such thing, you must register a deactivation hook by the <code>register_deactivation_hook</code> as following</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">register_deactivation_hook<span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'plugin_deactivate'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And obviously you will have to code an appropriate deactivation function, like <code>plugin_deactivate</code> in the example.</p>
<p><em>NOTE: Your deactivation function must be at the script's main <acronym title="Pre-Hypertext Processing">PHP</acronym> file.</em><br />
<em>NOTE: Your deactivation function may have any name.</em><br />
<em>NOTE: The <code>__FILE__</code> part specified at the deactivation hook is referencing your own script file.</em></p>
<p>I personally put all my options that goes to the <code>wp_options</code> database in a global associative array so if I add more options my cleanup function will still be compliant.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$aOptions</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$aOptions</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'myplugin-default-lang'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'en_US'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I also put my deactivation and cleanup functions apart so I can call the cleanup from within the deactivation function. This is made so if I want to add more deactivation functionalities else than cleanup I can do this without polluting my cleanup function with non-cleanup procedures.</p>
<p>The <code>plugin_deactivate</code> function will look like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> plugin_deactivate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Cleanup</span>
    plugin_cleanup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: function :: plugin_deactivate</span></pre></div></div>

<p>And the cleanup function as it follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> plugin_cleanup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$aOptions</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Delete our options</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$aOptions</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$sOptionKey</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$sOptionValue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
        delete_option<span style="color: #009900;">&#40;</span><span style="color: #000088;">$sOptionKey</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: function :: plugin_cleanup</span></pre></div></div>

<p>This should be enough to keep your options table tidy.</p>
<h2>3. Protect files that shouldn't be accessed directly</h2>
<p>Almost all your plugin files shouldn't be access directly. Exception goes to scripts that receives data from outside the Wordpress framework like thumbnail generators, image replacement techniques, <acronym title="Asynchronous JavaScript and XML">AJAX</acronym>, and such.</p>
<p>To disable direct access to your <acronym title="Pre-Hypertext Processing">PHP</acronym> files you must check if some Wordpress function is present and if not, shutdown the script if a good and old <code>exit();</code> call.</p>
<p>The example goes as:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_action'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> 
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Status: 403 Forbidden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HTTP/1.1 403 Forbidden'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></div></div>

<p>The example above also sends a 403 header in both formats (Internet Explorer and decent browsers, respectively).</p>
<h2>4. Use internationalization even if you aren't going to translate yet</h2>
<p>Even if you are not planning release you plugin with many languages I strongly recommend that you build yours i18n-ready by wrapping your texts on <code>gettext<a title="gettext @ Wikipedia" href="http://en.wikipedia.org/wiki/Gettext" class="wikipedia" rel="external wikipedia"><sup>w</sup></a></code> functions so other users can help (or even you in the future) to translate your plugin.</p>
<h3>The basics</h3>
<p>Internationalization basics in <acronym title="Pre-Hypertext Processing">PHP</acronym> is very simple. There are mainly two functions: <code>__()</code> and <code>_e()</code>. The difference is that <code>__()</code> returns the internationalized string <code>_e()</code> <code>echo</code>es it.</p>
<p>When text is within a variable or returned by a function you should use the <code>__()</code> function and if you want to <code>echo</code> it, <code>_e()</code> instead.</p>
<h4>Echoing internationalized text in a template file</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;h2&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My text goes here'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'My text domain goes here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h2&gt;</pre></div></div>

<h4>Returning internationalized text in a function</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> somefunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My text goes here'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'My text domain goes here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: function :: somefunction</span></pre></div></div>

<p>Internationalization is a wide subject and is covered greatly in the Wordpress "<a href="http://codex.wordpress.org/Writing_a_Plugin#Internationalizing_Your_Plugin">Writing a Plugin</a>" page.</p>
<p>Internationalizing your plugin is also a good marketing strategy since if someone releases a language file for your plugin, is also making it available in a wider market-share slice.</p>
<h2>5. Employ current coding best practices</h2>
<p>There are some wide best practices that are not exclusively to the Wordpress Plugin scope.</p>
<h3>Separate your code</h3>
<p>Applying this technique on Wordpress Plugin development is such as having the plugin's main php file just making the calls and registering the hooks and have your functions properly laid under a <code>lib/</code> function or such. Same things goes to <code>images/</code>, <code>js/</code> (JavaScript) and <code>css/</code>.</p>
<h3>Document your code</h3>
<p>Ok, this is like telling grown-ups to not touch the hot oven or putting the finger in a wall socket but many people still lacks in documenting code.</p>
<p>I suggest to keep your functions, classes and files documented in the <a href="http://www.phpdoc.org/">phpDocumentor</a> syntax.</p>
<p>This kind of syntax is inherited from Java and other languages apply it since is very readable and parse-able.</p>
<p>It goes like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * My loved function
 *
 * This function collects some data and process in this way to give the desired result.
 *
 * @param    string   $varname    Description of the variable
 * @param    int   $othervarname    Description of the variable
 * @return    void   This function returns nothing
 */</span></pre></div></div>

<h3>Stay DRY</h3>
<p>Try to avoid two functions that do basically the same thing. If you have two functions in separate classes that to the same thing (like string sanitization), consider having a utility class.</p>
<h2>Bonus Tip!</h2>
<p> Avoid kidnapping people's <code>wp_head()</code> and <code>wp_footer()</code> with your plugin propaganda. If you want to make such thing, do as <acronym title="HyperText Markup Language">HTML</acronym> code comment or make this branding stuff optional. </p>
<p>If you are going to make your plugin free, make it free, not AD dependant. If you think your plugin should be paid, then make it paid. Placing plugin ADs in the themplate may scare out some users. Your free plugin shall make your own propaganda by being useful and rich-featured, not by printing it out. </p>
<p>What's your tip?</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/wp-minifys-new-version-vanished-wordpress-http-requests-issue' rel='bookmark' title='Permanent Link: WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue'>WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin'>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins</feedburner:origLink></item>
		<item>
		<title>Brazillian Portuguese (pt_BR) language file for WP-Filebase released</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/vfCrV1bDiJo/brazillian-portuguese-pt_br-language-file-for-wp-filebase-released</link>
		<comments>http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-for-wp-filebase-released#comments</comments>
		<pubDate>Fri, 19 Feb 2010 18:42:30 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Translation]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[internationalization]]></category>
		<category><![CDATA[localization]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp-filebase]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=362</guid>
		<description><![CDATA[We have just baked the Brazillian Portuguese pt_BR.po (and .mo) internationalization language files for the great WP-Filebase Wordpress plugin from Fabian Schlieper.
This plugin is a great download / file manager that covered just all holes that we need in our clients&#8217; projects. It features a highly configurable theming, internationalization, categorization, download counter, traffic/bitrate limiter and [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin'>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>We have just baked the Brazillian Portuguese <code>pt_BR.po</code> (and <code>.mo</code>) internationalization language files for the great <a href="http://wordpress.org/extend/plugins/wp-filebase/"><acronym title="WordPress">WP</acronym>-Filebase</a> Wordpress plugin from <a href="http://fabi.me">Fabian Schlieper</a>.</p>
<p>This plugin is a great download / file manager that covered just all holes that we need in our clients&#8217; projects. It features a highly configurable theming, internationalization, categorization, download counter, traffic/bitrate limiter and more. </p>
<p>This is certainly a recommended Wordpress Plugin for all.<span id="more-362"></span></p>
<p>The language file was translated from the provided <code>template.po</code>. </p>
<p>Please submit any fixes for translation errors that you may find.</p>
<p><a href="/wordpress/wp-content/uploads/wpfb-pt_BR.mo">Download <code>pt_BR.mo</code> language file for <acronym title="WordPress">WP</acronym>-Filebase</a><br />
<a href="/wordpress/wp-content/uploads/wpfb-pt_BR.po">Optional download <code>pt_BR.po</code> language file for <acronym title="WordPress">WP</acronym>-Filebase</a></p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-released-for-simplepress-forum-wordpress-plugin' rel='bookmark' title='Permanent Link: Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin'>Brazillian Portuguese (pt_BR) language file released for Simple:Press Forum Wordpress plugin</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-for-wp-filebase-released/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/brazillian-portuguese-pt_br-language-file-for-wp-filebase-released</feedburner:origLink></item>
		<item>
		<title>Cisco binary games kills your productivity while enriching knowledge</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/vdKmJ4uPOdM/cisco-binary-games-kills-your-productivity-while-enriching-knowledge</link>
		<comments>http://www.heavyworks.net/blog/posts/cisco-binary-games-kills-your-productivity-while-enriching-knowledge#comments</comments>
		<pubDate>Tue, 12 Jan 2010 05:23:33 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Computer Science & Math]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=305</guid>
		<description><![CDATA[This is one of those Flash games that kills hours of productivity like Desktop Tower Defense, quite educative.


The game released by Cisco as part of its CCNA training has the objective of training your binary skills. You will be asked for the bits corresponding to a certain value or vice-versa.
Very interesting, can get really naughty [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>This is one of those Flash games that kills hours of productivity like <a href="http://www.handdrawngames.com/DesktopTD/Game.asp">Desktop Tower Defense</a>, quite educative.</p>
<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/binary_banner.jpg" alt="Cisco Binary Game" title="Cisco Binary Game" width="600" height="215" class="aligncenter size-full wp-image-308" /><br />
<span id="more-305"></span><br />
The game released by Cisco as part of its CCNA training has the objective of training your binary skills. You will be asked for the bits corresponding to a certain value or vice-versa.</p>
<p>Very interesting, can get really naughty sometimes.</p>
<p><a href="http://forums.cisco.com/CertCom/game/binary_game_page.htm" title="Cisco Binary Game">Play</a> at your own risk at Cisco&#8217;s website.</p>

<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/cisco-binary-games-kills-your-productivity-while-enriching-knowledge/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/cisco-binary-games-kills-your-productivity-while-enriching-knowledge</feedburner:origLink></item>
		<item>
		<title>Alternative syntax for PHP control structures</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/L6WuxwN3hYE/alternative-syntax-for-php-control-structures</link>
		<comments>http://www.heavyworks.net/blog/posts/alternative-syntax-for-php-control-structures#comments</comments>
		<pubDate>Sat, 02 Jan 2010 21:46:40 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[alternative]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=314</guid>
		<description><![CDATA[While it&#8217;s not a great secret, many people still not aware of the alternative syntax for control structures under PHP.
The C-like syntax for control structures are very intuitive but can deal lots of trouble when your code has lot of pages and lots of ifs, fors, while and therefore lots of opening and closing braces.
NOTE: [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/quick-tip-php-mail-header-misuse-vulnerability' rel='bookmark' title='Permanent Link: Quick-tip: PHP mail() header misuse &#8220;vulnerability&#8221;'>Quick-tip: PHP mail() header misuse &#8220;vulnerability&#8221;</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>While it&#8217;s not a great secret, many people still not aware of the alternative syntax for control structures under <acronym title="Pre-Hypertext Processing">PHP</acronym>.</p>
<p>The C-like syntax for control structures are very intuitive but can deal lots of trouble when your code has lot of pages and lots of <code>if</code>s, <code>for</code>s, <code>while</code> and therefore lots of opening and closing braces.</p>
<p><em>NOTE: As <a title="Alternative syntax for PHP control structures by Heavyworks @ DZone" href="http://www.dzone.com/links/alternative_syntax_for_php_control_structures.html#111906199">remembered by jakyra on DZone</a>, if you keep your code tidy you shouldn&#8217;t have functions that long and though not having this kind of problem, but this alternative syntax still have good benefits.</em></p>
<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/braces.jpg" alt="" title="No more losing in between braces" width="500" height="215" class="aligncenter size-full wp-image-328" /></p>
<h2>The alternative syntax</h2>
<p>The alternative syntax consists in changing the opening brace (<code>{</code>) to a colon (<code>:</code>) and each closing brace to its respective closing function: <code>endif;</code>, <code>endfor;</code>, <code>endforeach;</code>, <code>endwhile;</code> and <code>endswitch;</code>.<br />
<span id="more-314"></span></p>
<h2>Closing functions list</h2>
<dl>
<dt>opens <code>if ([parameters]):</code></dt>
<dd>closes <code>endif;</code></dd>
<dt>opens <code>for ([parameters]):</code></dt>
<dd>closes <code>endfor;</code></dd>
<dt>opens <code>foreach ([parameters]):</code></dt>
<dd>closes <code>endforeach;</code></dd>
<dt>opens <code>while ([parameters]):</code></dt>
<dd>closes <code>endwhile;</code></dd>
<dt>opens <code>switch ([value]):</code></dt>
<dd>closes <code>endswitch;</code></dd>
</dl>
<h2>Benefits of this alternative syntax</h2>
<p>The benefits of using this syntax are clear when put into practice. A far more readable code with no more commenting out braces like <code>} // end :: if</code>. You can instantly know which structural condition this closing brace belongs to and will no longer get confused between these and function braces.</p>
<h2>Disadvantages of the alternative syntax</h2>
<p>I personally do not consider this as a disadvantage but some people might consider since some text editors and IDEs have the ability to highlight the matching brace.</p>
<h2>Examples</h2>
<h3>If</h3>
<p><em>NOTE: <code>else</code> and <code>elseif</code> control structures follow the same structure.</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Standard syntax</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$otherVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$aThirdVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$otherVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$aThirdVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$otherVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$aThirdVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: if</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Alternative syntax</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$otherVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$aThirdVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$variable</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$otherVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$aThirdVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">else</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$otherVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$aThirdVariable</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Foreach</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Standard syntax</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: foreach</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Alternative syntax</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$key</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span></pre></div></div>

<h3>For</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Standard syntax</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">++</span>
<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">+</span><span style="color: #000088;">$bar</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: for</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Alternative syntax</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$i</span><span style="color: #339933;">++</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">+</span><span style="color: #000088;">$bar</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endfor</span><span style="color: #339933;">;</span></pre></div></div>

<h3>While</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Standard syntax</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">--;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: while</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Alternative syntax</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">--;</span>
	<span style="color: #b1b100;">print</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Switch</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Standard syntax</span>
<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$foo</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">:</span>
<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// end :: switch</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Alternative syntax</span>
<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$foo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">case</span> <span style="color: #0000ff;">&quot;bar&quot;</span><span style="color: #339933;">:</span>
<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
	<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endswitch</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>Photo: <a href="http://www.flickr.com/photos/andyfitz/3658091463/">Andy Fitz @ Flickr</a></em></p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/quick-tip-php-mail-header-misuse-vulnerability' rel='bookmark' title='Permanent Link: Quick-tip: PHP mail() header misuse &#8220;vulnerability&#8221;'>Quick-tip: PHP mail() header misuse &#8220;vulnerability&#8221;</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/5-best-practices-on-developing-wordpress-plugins' rel='bookmark' title='Permanent Link: 5 best practices on developing Wordpress plugins'>5 best practices on developing Wordpress plugins</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/alternative-syntax-for-php-control-structures/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/alternative-syntax-for-php-control-structures</feedburner:origLink></item>
		<item>
		<title>Sustainability application under Software Development</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/IzaBvlhh3mk/sustainability-application-under-software-development</link>
		<comments>http://www.heavyworks.net/blog/posts/sustainability-application-under-software-development#comments</comments>
		<pubDate>Tue, 08 Dec 2009 21:42:16 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[carbon footprint]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[global warming]]></category>
		<category><![CDATA[green]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=287</guid>
		<description><![CDATA[We are constantly trying to improve our web applications performance to gain speed, lower the load on the clusters and thus being able to attend to even more users but have you ever thought about how these improvements can aid Global Warming?
For years optimization techniques such as Caching in many levels (Disk/Memory), Compression, Clustering and [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/wp-minifys-new-version-vanished-wordpress-http-requests-issue' rel='bookmark' title='Permanent Link: WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue'>WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/ubuntu-is-going-windows-way' rel='bookmark' title='Permanent Link: Ubuntu is going Windows-way'>Ubuntu is going Windows-way</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>We are constantly trying to improve our web applications performance to gain speed, lower the load on the clusters and thus being able to attend to even more users but have you ever thought about how these improvements can aid <a href="http://en.wikipedia.org/wiki/Global_Warming">Global Warming</a>?</p>
<p>For years optimization techniques such as <a href="http://en.wikipedia.org/wiki/Caching">Caching</a> in many levels (Disk/Memory), <a href="http://en.wikipedia.org/wiki/HTTP_compression">Compression</a>, <a href="http://en.wikipedia.org/wiki/Cluster_(computing)">Clustering</a> and other were developed to acheive greater performance. </p>
<p>Global Warming is there for years and is getting worse every year but it seems that movements under IT has begun in order to create greener solutions. Many hosts such as <a href="http://www.dreamhost.com/aboutus-green.html">Dreamhost</a> (which we&#8217;re proud of being our hosting company) have already started their effort in reducing or even neutralizing their <a href="http://en.wikipedia.org/wiki/Carbon_Footprint">Carbon Footprint</a> and now developers can help on their side too.<br />
<span id="more-287"></span></p>
<h2>The Concept</h2>
<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/lamp-300x201.jpg" alt="Green Energy" title="Green Energy" width="300" height="201" class="alignright size-medium wp-image-298" /> Well, we don&#8217;t have to go too far to realize where optimization crosses paths with sustainability. It&#8217;s simple, it&#8217;s all about electricity (power) saving.</p>
<p>Again, it&#8217;s all about electricity. Every single bit minor instruction spends a very little piece of energy that goes through the processor and memory I/O operations and spends some little more sending data over the ethernet ports.</p>
<p>Let&#8217;s go from the beginning. The user has requested a website, the request goes through all the routers and switches in the way to the requisition. </p>
<p><em>NOTE: We are not considering this power consumption because it is not dependent on the application&#8217;s optimization.</em></p>
<p>Here is where optimization makes the difference: the way back. </p>
<p>Larger image or source files will take more CPU cycles to be processed, more Disk usage and more space allocated in memory. Then these big files have to be sent to the client and if you have many files this means more <acronym title="HyperText Transfer Protocol">HTTP</acronym> connections and headers being sent.</p>
<p>Techniques such <a href="http://www.alistapart.com/articles/sprites/"><acronym title="Cascading Style Sheets">CSS</acronym> Sprites</a> (heavily used by <a href="http://www.google.com">Google</a> and other big companies) aid to reduce the <acronym title="HyperText Transfer Protocol">HTTP</acronym> Connections between the server and the client.</p>
<p>Each <acronym title="HyperText Transfer Protocol">HTTP</acronym> connections contains not only the file&#8217;s data but it is preceded by header data with the file&#8217;s type, modified date and some other info so two square 20px images are bigger than one rectangular 40px per 20px image (the two 20px square images side by side).</p>
<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/routing_engine.jpg" alt="Routing" title="Routing" width="511" height="348" class="aligncenter size-full wp-image-295" /><br />
Then the requested files come from the server to the client by all the router and switches in-between them spending more power in transmission until it gets to its destiny where will consume more power to be rendered by client browser&#8217;s engine and window manager (Windows, Gnome, Kde etc).</p>
<h2>How to collaborate?</h2>
<p>Optimize your software. <a href="http://www.yahoo.com">Yahoo</a>&#8217;s <a href="http://developer.yahoo.com/yslow/">YSlow</a> and <a href="http://www.google.com">Google</a>&#8217;s <a href="http://code.google.com/speed/page-speed/">Page Speed</a> are great kickstarts. You can also check <a href="/blog/tag/caching">our articles on caching</a>.</p>
<p>As all great saving and recycling, results will only take place with everyone&#8217;s effort. These taken under huge proportions can result in great saving and thus more breathe to our planet.</p>
<p>Think green.</p>
<h2>Other considerations under power saving on software development</h2>
<p>In this <a title="Black Google would save 3000 megawatts @ EcoIron" href="http://ecoiron.blogspot.com/2007/08/history-in-january-2007-mark-ontkush.html">2007 article</a>, Mark Ontkush showed his study where dark-pallete-themed web applications required less energy from users&#8217; CRT monitors.</p>
<blockquote><p>&#8220;an all white web page uses about 74 watts to display, while an all black page uses only 59 watts. I thought I would do a little math and see what could be saved by moving a high volume site to the black format.&#8221;</p></blockquote>
<p><em>Mark Ontkush</em></p>
<p>And then the results came when he compared to traffic reports of huge websites such as Google:</p>
<blockquote><p>Take at look at Google, who gets about 200 million queries a day. Let&#8217;s assume each query is displayed for about 10 seconds; that means Google is running for about 550,000 hours every day on some desktop. Assuming that users run Google in full screen mode, the shift to a black background [on a CRT monitor! mjo] will save a total of 15 (74-59) watts. That turns into a global savings of 8.3 Megawatt-hours per day, or about 3000 Megawatt-hours a year. Now take into account that about 25 percent of the monitors in the world are CRTs, and at 10 cents a kilowatt-hour, that&#8217;s $75,000, a goodly amount of energy and dollars for changing a few color codes.</p></blockquote>
<p><em>Mark Ontkush</em></p>
<p>Black is the new black!</p>
<p>Unfortunately, dark-themed websites tend to be less accepted by the users, and some have even reported that white characters tend to blur by reading stress while reading an extensive text.</p>
<p>And you developer? What are you doing to save the world?</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/wp-minifys-new-version-vanished-wordpress-http-requests-issue' rel='bookmark' title='Permanent Link: WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue'>WP-Minify&#8217;s new version vanished Wordpress&#8217; HTTP requests issue</a></li>
<li><a href='http://www.heavyworks.net/blog/posts/ubuntu-is-going-windows-way' rel='bookmark' title='Permanent Link: Ubuntu is going Windows-way'>Ubuntu is going Windows-way</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/sustainability-application-under-software-development/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/sustainability-application-under-software-development</feedburner:origLink></item>
		<item>
		<title>Scytale, a greek cryptography system implemented in C++</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/Ez00Omk1eWE/scytale-a-greek-cryptography-implemented-in-c</link>
		<comments>http://www.heavyworks.net/blog/posts/scytale-a-greek-cryptography-implemented-in-c#comments</comments>
		<pubDate>Thu, 27 Aug 2009 04:39:30 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[scytale]]></category>
		<category><![CDATA[symmetric key]]></category>
		<category><![CDATA[transposition cypher]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=264</guid>
		<description><![CDATA[During TISafe&#8217;s Security Officer training this month, while talking about cryptography, the Scytale technique came up.
This was one of the first cryptography method with historical registry, used by the Greeks (Spartans, more specifically) to cypher messages during military campaigns thus not letting the enemy know their moves even if the message carrier gets caught, tortured [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.heavyworks.net/wordpress/wp-content/uploads/skytale.jpg" alt="Scytale" title="Scytale" width="250" height="143" class="alignright size-full wp-image-265" />During <a href="http://www.tisafe.com">TISafe</a>&#8217;s <a href="http://en.wikipedia.org/wiki/Chief_security_officer">Security Officer</a> training this month, while talking about cryptography, the <a href="http://en.wikipedia.org/wiki/Scytale">Scytale</a> technique came up.</p>
<p>This was one of the first cryptography method with historical registry, used by the Greeks (Spartans, more specifically) to cypher messages during military campaigns thus not letting the enemy know their moves even if the message carrier gets caught, tortured or killed.<br />
<span id="more-264"></span></p>
<h2>The cypher</h2>
<p>A very simple approach implements <a href="http://en.wikipedia.org/wiki/Transposition_cipher">transposition cypher</a> with a strip of leather, cloth or paper around a baton. Baton diameter inflicts directly in the encryption result so we can say that it is this algorithm&#8217;s <a href="http://en.wikipedia.org/wiki/Symmetric-key_algorithm">symmetric key</a></p>
<h2>Encryption process</h2>
<p>To encrypt the message, the sender rolls the strip of leather (or cloth, or paper, etc) around his baton and draw the message (vertically, character by character) across the strips, going back to the first strip on the next &#8220;line&#8221; when writing to the last strip, like <a href="http://en.wikipedia.org/wiki/Word_wrap">word-wrap</a>.</p>
<p>This example from Wikipedia ilustrates well the concept:</p>
<blockquote>
<pre>
_____________________________________________________________
       |   |   |   |   |   |  |
       | H | E | L | P | M |  |
     __| E | I | A | M | U |__|
    |  | N | D | E | R | A |
    |  | T | T | A | C | K |
    |  |   |   |   |   |   |
_____________________________________________________________
</pre>
</blockquote>
<h2>Decryption process</h2>
<p>As most symmetrical-key cypher systems, the decryption process is given by reversing the encryption process with the same key applied. The person with a baton with the same diameter (the same key) would be able to roll the strip over it and decrypt the message.</p>
<h2>Key value restrictions</h2>
<p>For a baton with 1cm diameter, the message will look just like the original, so we will discard key values of <code>1</code>. The same occurs if key value is equal to the message length.</p>
<h2>The algorithm</h2>
<p>The key represents the number of characters in each line of text:</p>
<dl>
<dt>key value: <code>2</code></dt>
<dd>2 characters per line</dd>
<dt>key value: <code>4</code></dt>
<dd>4 characters per line</dd>
</dl>
<p>For the explanation of this algorithm we&#8217;ll encrypt the following message: &#8220;<b>HEAVYWORKS</b>&#8221; (nice huh?)</p>
<h3>Chunk split</h3>
<p>The message is split into chunks of <code>N</code> characters, being <code>N</code> being the key value.</p>
<table class="dataTable">
<thead>
<th>Original</th>
<th>Key <code>2</code></th>
<th>Key <code>3</code></th>
<th>Key <code>4</code></th>
</thead>
<tfoot>
</tfoot>
<tbody>
<tr>
<td>HEAVYWORKS</td>
<td>
<pre>
HE
AV
YW
OR
KS
</pre>
</td>
<td>
<pre>
HEA
VYW
ORK
S
</pre>
</td>
<td>
<pre>
HEAV
YWOR
KS
</pre>
</td>
</tr>
</tbody>
</table>
<h3>Key relation</h3>
<p>All the character sequences are now ordered in columns after we splitted the message in chunks with the length of the key value. You should realized already that the number of columns will be equal to the chunk length and thus the key value. </p>
<h3>Transposition</h3>
<p>The transposition is made by creating new (encrypted) chunks with the characters from each column. These chunks will be of the same length of the corresponding column.<br />
At the end of the process, all cyphered chunks are put together.</p>
<table class="dataTable">
<thead>
<th>&nbsp;</th>
<th>Key <code>2</code></th>
<th>Key <code>3</code></th>
<th>Key <code>4</code></th>
</thead>
<tfoot>
</tfoot>
<tbody>
<tr>
<td>Cyphered chunks</td>
<td>
<pre>HAYOK EVWRS</pre>
</td>
<td>
<pre>HVOS EYR AWK</pre>
</td>
<td>
<pre>HYK EWS AO VR</pre>
</td>
</tr>
<tr>
<td>Cyphered message</td>
<td>
<pre>HAYOKEVWRS</pre>
</td>
<td>
<pre>HVOSEYRAWK</pre>
</td>
<td>
<pre>HYKEWSAOVR</pre>
</td>
</tr>
</tbody>
</table>
<h2>The C++ Way</h2>
<p>The Scytale class got very simple, as the algorithm is very simple. It uses only three libraries: <code>iostream</code>, <code>vector</code> (for variable-length arrays) and <code>cmath</code> (for some <code>ceil</code> calculation).</p>
<p>The binary is called from command-line with the <code>-k</code> keylenght and <code>-m</code> message (quote escaped).</p>
<h3>Under the hood</h3>
<p>The <code>main</code> function fetches the options using GNU <code>getopts</code> and thus does some early input checking and error handling. </p>
<p>All OK, the key is set by Scytale&#8217;s class&#8217; <code>setKey</code> method and message is passed as a parameter to the <code>encrypt</code> method. From this point <code>validate</code> method is called in order to validate if the key and messages are fit into the needs on <code>try/catch</code> statements.</p>
<p>Passing the validation, the <code>createStack</code> method creates the character chunk stack (oh, really!?) from the plain-text message with two nested <code>for</code> laces (first for rows, second for char position) that is handled over to <code>scrambleStack</code> in order to perform the transposition with another two netsted <code>for</code> laces (now the first for column and the second for row).</p>
<p>Finally, the encrypted message</p>
<p><em>NOTE: If validation fails, program exits with a <code>EXIT_FAILURE</code> error code and the error message is echoed to <code>stderr</code>.</em></p>
<h3>Source</h3>
<p>The source file is well documented using a kind of <a href="http://java.sun.com/j2se/javadoc/">Javadoc</a> syntax and can be downloaded <a href="/wordpress/wp-content/uploads/scripts/cryptography/algorithms/scytale/scytale.zip">here</a>.</p>
<h4>MD5 Sum</h4>
<p><code>a33edf6a4c4670380ce8c8e40edcb3d7  scytale.zip</code></p>
<h3>Compiling</h3>
<p>In order to compile with <code>g++</code> use the following line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">g++</span> <span style="color: #660033;">-Wall</span> <span style="color: #660033;">-ansi</span> <span style="color: #660033;">-pedantic</span> <span style="color: #660033;">-o</span> scytale scytale.cpp</pre></div></div>

<p><em>NOTE: I was not able to compile this under Windows XP with <a href="http://www.mingw.org/">MinGW</a>&#8217;s <code>g++</code>. Got compiling errors because of <code>getopts</code> and <code>vector</code>. If someone succeeds in compiling under Windows XP post a comment!</em></p>
<h2>Drawbacks</h2>
<p>This system cannot assure authenticity because it has no way to prove the author of the message so it can be crafted by the enemy that deduced, guessed or stolen the key.</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/smartly-resolving-your-wordpress-pages-and-posts-javascript-and-css-dependences' rel='bookmark' title='Permanent Link: Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences'>Smartly resolving your Wordpress pages and posts JavaScript and CSS dependences</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/scytale-a-greek-cryptography-implemented-in-c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/scytale-a-greek-cryptography-implemented-in-c</feedburner:origLink></item>
		<item>
		<title>Advanced SQL Injection</title>
		<link>http://feedproxy.google.com/~r/Heavyworks/~3/1pNtzA_YPrA/advanced-sql-injection</link>
		<comments>http://www.heavyworks.net/blog/posts/advanced-sql-injection#comments</comments>
		<pubDate>Mon, 17 Aug 2009 04:58:03 +0000</pubDate>
		<dc:creator>Jan Seidl</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://www.heavyworks.net/?p=259</guid>
		<description><![CDATA[Found that great video at LearnSecurityOnline.com of a presentation by one of its founders, Joseph McCray at Saecur&#8217;s DojoSec (monthly event hosted by Marcus Carey), earlier this year in February.
Joseph speaks in a very well-humorous way about &#8220;Advanced SQL Injection&#8221; covering from Error-based SQL Injection to Blind SQL Injection, pretty nasty and nice! Gives another [...]


Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/ordering-by-fields-that-contains-null-values' rel='bookmark' title='Permanent Link: Ordering by fields that contains null values'>Ordering by fields that contains null values</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Found that great video at <a href="http://www.learnsecurityonline.com/">LearnSecurityOnline.com</a> of a presentation by one of its founders, Joseph McCray at <a href="http://www.saecur.com/">Saecur</a>&#8217;s <a href="http://www.saecur.com/us/dojosec/">DojoSec</a> (monthly event hosted by Marcus Carey), earlier this year in February.</p>
<p>Joseph speaks in a very well-humorous way about &#8220;Advanced <acronym title="Structured Query Language">SQL</acronym> Injection&#8221; covering from Error-based <acronym title="Structured Query Language">SQL</acronym> Injection to Blind <acronym title="Structured Query Language">SQL</acronym> Injection, pretty nasty and nice! Gives another good overview under what we developers should look when protecting our code.</p>
<p>Here is the video:<br />
<object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3418947&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3418947&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/3418947">DojoSec Monthly Briefings &#8211; February 2009 &#8211; Joseph McCray</a> from <a href="http://vimeo.com/marcuscarey">Marcus Carey</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Don&#8217;t forget to check out other DojoSec videos at <a href="http://vimeo.com/marcuscarey">Marcus Carey</a>&#8217;s Vimeo channel and <a href="http://www.learnsecurityonline.com/">LearnSecurityOnline.com</a> to great security-related material!</p>

<p>Related posts:<ol><li><a href='http://www.heavyworks.net/blog/posts/ordering-by-fields-that-contains-null-values' rel='bookmark' title='Permanent Link: Ordering by fields that contains null values'>Ordering by fields that contains null values</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.heavyworks.net/blog/posts/advanced-sql-injection/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.heavyworks.net/blog/posts/advanced-sql-injection</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 7.473 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-03-08 19:35:28 -->
