<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>&#60;SourceBench/&#62; Your place to share code stuff &#187; Languages</title>
	<atom:link href="http://sourcebench.com/category/languages/feed/" rel="self" type="application/rss+xml" />
	<link>http://sourcebench.com</link>
	<description></description>
	<lastBuildDate>Tue, 04 May 2010 07:57:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Easy Post Meta fields class set &#8211; easy custom fields for WordPress</title>
		<link>http://sourcebench.com/languages/wordpress/easy-post-meta-fields-class-set-easy-custom-fields-for-wordpress/</link>
		<comments>http://sourcebench.com/languages/wordpress/easy-post-meta-fields-class-set-easy-custom-fields-for-wordpress/#comments</comments>
		<pubDate>Tue, 04 May 2010 07:56:40 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[custom post fields]]></category>
		<category><![CDATA[easy custom fields]]></category>
		<category><![CDATA[post meta]]></category>
		<category><![CDATA[post meta fields]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/wordpress/easy-post-meta-fields-class-set-easy-custom-fields-for-wordpress/</guid>
		<description><![CDATA[If you ever needed to work with post meta fields and did not want to mess around with validation and all this stuff around it check out http://wordpress.org/extend/plugins/easy-custom-fields/ for a simple set of classes to build on.]]></description>
			<content:encoded><![CDATA[<p>If you ever needed to work with post meta fields and did not want to mess around with validation and all this stuff around it check out <a href="http://wordpress.org/extend/plugins/easy-custom-fields/" rel="nofollow">http://wordpress.org/extend/plugins/easy-custom-fields/</a> for a simple set of classes to build on.</p>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/wordpress/easy-post-meta-fields-class-set-easy-custom-fields-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple parallel processing with Bash using &#8220;wait&#8221; and &#8220;jobs&#8221;</title>
		<link>http://sourcebench.com/languages/bash/simple-parallel-processing-with-bash-using-wait-and-jobs/</link>
		<comments>http://sourcebench.com/languages/bash/simple-parallel-processing-with-bash-using-wait-and-jobs/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 13:53:14 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[Bash/shell]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[threading]]></category>
		<category><![CDATA[wait]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/bash/simple-parallel-processing-with-bash-using-wait-and-jobs/</guid>
		<description><![CDATA[#!/bin/bash
# this is a simple helper script that can be used when you are in need of running multiple processes at once
# simply run your command with an ampersand at the end and after this
# execute forky with the number of parallel processes as argument.

function forky() {
	local num_par_procs
	if [[ -z $1 ]] ; then
		num_par_procs=3
	else
		num_par_procs=$1
	fi

	while [[ [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">#!/bin/bash
# this is a simple helper script that can be used when you are in need of running multiple processes at once
# simply run your command with an ampersand at the end and after this
# execute forky with the number of parallel processes as argument.

function forky() {
	local num_par_procs
	if [[ -z $1 ]] ; then
		num_par_procs=3
	else
		num_par_procs=$1
	fi

	while [[ $(jobs | wc -l) -ge $num_par_procs ]] ; do
		sleep 1
	done
}

# below is an example - make sure to change this to your needs
for fname in `ls -1`; do
	echo &quot;`jobs | wc -l` jobs in spool&quot;
	echo -e &quot;processing $fname\n&quot;
	# below should be the command you like to execute. in this example it's a php script that would do something with a file.
	# important is the &amp; at the end of the command which sends the command to the background
	php ~/a_script_that_does_something_with_the_file --file=$fname &amp;
	# after this call the forky function with the amount of parallel processes as parameter
	forky 5
done

wait</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/bash/simple-parallel-processing-with-bash-using-wait-and-jobs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Test if a nameserver change is done right</title>
		<link>http://sourcebench.com/languages/bash/test-if-a-nameserver-change-is-done-right/</link>
		<comments>http://sourcebench.com/languages/bash/test-if-a-nameserver-change-is-done-right/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 23:52:28 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[Bash/shell]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[domains]]></category>
		<category><![CDATA[nameserver]]></category>
		<category><![CDATA[ns]]></category>
		<category><![CDATA[whois]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/bash/test-if-a-nameserver-change-is-done-right/</guid>
		<description><![CDATA[# imagine you just updated your whois data so it will point your domain to an other nameserver and you want to know if that worked out
# this little command lets you know on *nix based machines
for i in a b c d e f g h i j k l; do dig +short ns [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;"># imagine you just updated your whois data so it will point your domain to an other nameserver and you want to know if that worked out
# this little command lets you know on *nix based machines
for i in a b c d e f g h i j k l; do dig +short ns domainname.com @$i.GTLD-SERVERS.NET; done</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/bash/test-if-a-nameserver-change-is-done-right/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disable right click context menus with jQuery</title>
		<link>http://sourcebench.com/languages/javascript/disable-right-click-context-menus-with-jquery/</link>
		<comments>http://sourcebench.com/languages/javascript/disable-right-click-context-menus-with-jquery/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 14:47:34 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[context menu]]></category>
		<category><![CDATA[disable]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[right click]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/javascript/disable-right-click-context-menus-with-jquery/</guid>
		<description><![CDATA[$(document).ready(function(){
  $(document).bind(&#34;contextmenu&#34;,function(e){
    return false;
  });
});]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript;">$(document).ready(function(){
  $(document).bind(&quot;contextmenu&quot;,function(e){
    return false;
  });
});</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/javascript/disable-right-click-context-menus-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>command line real-time view of what files Time Machine is copying</title>
		<link>http://sourcebench.com/languages/bash/command-line-real-time-view-of-what-files-time-machine-is-copying/</link>
		<comments>http://sourcebench.com/languages/bash/command-line-real-time-view-of-what-files-time-machine-is-copying/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 09:15:51 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[Bash/shell]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[time machine]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/bash/command-line-real-time-view-of-what-files-time-machine-is-copying/</guid>
		<description><![CDATA[sudo fs_usage -w -f filesys backupd &#124; grep open]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">sudo fs_usage -w -f filesys backupd | grep open</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/bash/command-line-real-time-view-of-what-files-time-machine-is-copying/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Print the number of established and listening connections to your server on port 80 per each IP address</title>
		<link>http://sourcebench.com/languages/bash/print-the-number-of-established-and-listening-connections-to-your-server-on-port-80-per-each-ip-address/</link>
		<comments>http://sourcebench.com/languages/bash/print-the-number-of-established-and-listening-connections-to-your-server-on-port-80-per-each-ip-address/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 23:49:27 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[Bash/shell]]></category>
		<category><![CDATA[connections]]></category>
		<category><![CDATA[listening]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[ports]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/bash/print-the-number-of-established-and-listening-connections-to-your-server-on-port-80-per-each-ip-address/</guid>
		<description><![CDATA[netstat -plan&#124;grep :80&#124;grep -E &#34;(EST&#124;LIST)&#34;&#124;awk {'print $5'}&#124;cut -d: -f 1&#124;sort&#124;uniq -c&#124;sort -nk 1]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">netstat -plan|grep :80|grep -E &quot;(EST|LIST)&quot;|awk {'print $5'}|cut -d: -f 1|sort|uniq -c|sort -nk 1</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/bash/print-the-number-of-established-and-listening-connections-to-your-server-on-port-80-per-each-ip-address/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automatically insert meta description tag into posts/pages.</title>
		<link>http://sourcebench.com/languages/wordpress/automatically-insert-meta-description-tag-into-postspages/</link>
		<comments>http://sourcebench.com/languages/wordpress/automatically-insert-meta-description-tag-into-postspages/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 09:49:04 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[description]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[meta description]]></category>
		<category><![CDATA[wp_head]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/wordpress/automatically-insert-meta-description-tag-into-postspages/</guid>
		<description><![CDATA[&#60;?php
/**
 * Automatically insert meta description tag into posts/pages.
 * - can be configured to use either first X chars/words of the post content or post excerpt if available
 * - can use category description for category archive pages if available
 * - can use tag description for tag archive pages if available
 * - [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: php;">&lt;?php
/**
 * Automatically insert meta description tag into posts/pages.
 * - can be configured to use either first X chars/words of the post content or post excerpt if available
 * - can use category description for category archive pages if available
 * - can use tag description for tag archive pages if available
 * - can use blog description for everything else
 * - can use a default description if no suitable value is found
 * - can use the value of a custom field as description
 *
 * @usage
 * // add a custom configuration via filter
 * function set_meta_desc_settings( $settings ) {
 * 		return array( 'length' =&gt; 10, 'length_unit' =&gt; 'char|word', 'use_excerpt' =&gt; true, 'add_category_desc' =&gt; true, 'add_tag_desc' =&gt; true, 'add_other_desc' =&gt; true, 'default_description' =&gt; '', 'custom_field_key' =&gt; '' );
 * }
 * add_filter( 'meta_desc_settings', 'set_meta_desc_settings' );
 * add_action( 'wp_head', 'meta_desc' );
 *
 * @author Thorsten Ott
 */
function meta_desc() {
	$default_settings = array(
								'length' =&gt; 25, // amount of length units to use for the meta description
								'length_unit' =&gt; 'word', // the length unit can be either &quot;word&quot; or &quot;char&quot;
								'use_excerpt' =&gt; true, // if the post/page has an excerpt it will overwrite the generated description if this is set to true
								'add_category_desc' =&gt; true, // add the category description to category views if this value is true
								'add_tag_desc' =&gt; true, // add the category description to category views if this value is true
								'add_other_desc' =&gt; true, // add the blog description/tagline to all other pages if this value is true
								'default_description' =&gt; '', // in case no description is defined use this as a default description
								'custom_field_key' =&gt; '', // if a custom field key is set we try to use the value of this field as description
								);

	$settings = apply_filters( 'meta_desc_settings', $default_settings );

	extract( shortcode_atts( $default_settings, $settings ) );

	global $wp_query;

	if( is_single() || is_page() ) {
		$post = $wp_query-&gt;post;

		// check for a custom field holding a description
		if ( !empty( $custom_field_key ) ) {
			$post_custom = get_post_custom_values( $custom_field_key, $post-&gt;ID );
			if ( !empty( $post_custom ) )
				$text = $post_custom[0];
		}
		// check for an excerpt we can use
		else if( $use_excerpt &amp;&amp; !empty( $post-&gt;post_excerpt ) ) {
			$text = $post-&gt;post_excerpt;
		}
		// otherwise use the content
		else {
			$text = $post-&gt;post_content;
		}

		$text = str_replace( array( &quot;\r\n&quot;, &quot;\r&quot;, &quot;\n&quot;, &quot;  &quot; ), &quot; &quot;, $text ); // get rid of all line breaks
		$text = strip_shortcodes( $text ); // make sure to get rid of shortcodes
		$text = apply_filters( 'the_content', $text ); // make sure it's save
		$text = trim( strip_tags( $text ) ); // get rid of tags and html fragments
		if ( empty( $text ) &amp;&amp; !empty( $default_description ) )
			$text = $default_description;	

	} else if( is_category() &amp;&amp; true == $add_category_desc ) {
		$category = $wp_query-&gt;get_queried_object();
		$text = trim( strip_tags( $category-&gt;category_description ) );
		if ( empty( $text ) &amp;&amp; !empty( $default_description ) )
			$text = $default_description;

	} else if( is_tag() &amp;&amp; true == $add_tag_desc ) {
		$tag = $wp_query-&gt;get_queried_object();
		$text = trim( strip_tags( $tag-&gt;description ) );
		if ( empty( $text ) &amp;&amp; !empty( $default_description ) )
			$text = $default_description;

	} else if ( true == $add_other_desc ) {
		$text = trim( strip_tags( get_bloginfo('description') ) );
		if ( empty( $text ) &amp;&amp; !empty( $default_description ) )
			$text = $default_description;
	}

	if ( empty( $text ) )
		return;

	if ( 'word' == $length_unit ) {
		$words = explode(' ', $text, $length + 1);
		if ( count( $words ) &gt; $length ) {
			array_pop( $words );
			array_push( $words, '...' );
			$text = implode( ' ', $words );
		}
	} else {
		if ( strlen( $text ) &gt; $length ) {
			$text = mb_strimwidth( $text, 0, $length, '...' );
		}
	}

	if ( !empty( $text ) ) {
		echo &quot;\n&lt;meta name=\&quot;description\&quot; content=\&quot;$text\&quot; /&gt;\n&quot;;
	}
}
?&gt;</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/wordpress/automatically-insert-meta-description-tag-into-postspages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>parse a urls from text file and split their components with named labels</title>
		<link>http://sourcebench.com/languages/php/parse-a-urls-from-text-file-and-split-their-components-with-named-labels/</link>
		<comments>http://sourcebench.com/languages/php/parse-a-urls-from-text-file-and-split-their-components-with-named-labels/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 23:08:28 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[extract]]></category>
		<category><![CDATA[preg_match_all]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[urls]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/php/parse-a-urls-from-text-file-and-split-their-components-with-named-labels/</guid>
		<description><![CDATA[preg_match_all('/(?P&#60;protocol&#62;(?:(?:f&#124;ht)tp&#124;https):\/\/)?(?P&#60;domain&#62;(?:(?!-)(?P&#60;sld&#62;[a-zA-Z\d\-]+)(?&#60;!-)[\.]){1,2}(?P&#60;tld&#62;(?:[a-zA-Z]{2,}\.?){1,}){1,}&#124;(?P&#60;ip&#62;(?:(?(?&#60;!\/)\.)(?:25[0-5]&#124;2[0-4]\d&#124;[01]?\d?\d)){4}))(?::(?P&#60;port&#62;\d{2,5}))?(?:\/(?P&#60;script&#62;[~a-zA-Z\/.0-9-_]*)?(?:\?(?P&#60;parameters&#62;[=a-zA-Z+%&#38;\&#38;amp;\'\(\)0-9,.\/_ -]*))?)?(?:\#(?P&#60;anchor&#62;[=a-zA-Z+%&#38;0-9._]*))?/x',$text,$data)]]></description>
			<content:encoded><![CDATA[<pre class="brush: php;">preg_match_all('/(?P&lt;protocol&gt;(?:(?:f|ht)tp|https):\/\/)?(?P&lt;domain&gt;(?:(?!-)(?P&lt;sld&gt;[a-zA-Z\d\-]+)(?&lt;!-)[\.]){1,2}(?P&lt;tld&gt;(?:[a-zA-Z]{2,}\.?){1,}){1,}|(?P&lt;ip&gt;(?:(?(?&lt;!\/)\.)(?:25[0-5]|2[0-4]\d|[01]?\d?\d)){4}))(?::(?P&lt;port&gt;\d{2,5}))?(?:\/(?P&lt;script&gt;[~a-zA-Z\/.0-9-_]*)?(?:\?(?P&lt;parameters&gt;[=a-zA-Z+%&amp;\&amp;amp;\'\(\)0-9,.\/_ -]*))?)?(?:\#(?P&lt;anchor&gt;[=a-zA-Z+%&amp;0-9._]*))?/x',$text,$data)</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/php/parse-a-urls-from-text-file-and-split-their-components-with-named-labels/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Get a list of urls/domains from a text file</title>
		<link>http://sourcebench.com/languages/bash/get-a-list-of-urlsdomains-from-a-text-file/</link>
		<comments>http://sourcebench.com/languages/bash/get-a-list-of-urlsdomains-from-a-text-file/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 23:05:54 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[Bash/shell]]></category>
		<category><![CDATA[domains]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[urls]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/bash/get-a-list-of-urlsdomains-from-a-text-file/</guid>
		<description><![CDATA[sed 's/http/\^http/g' FILENAME &#124; tr -s &#34;^&#34; &#34;\n&#34; &#124; grep http&#124; sed 's/[\ &#124;\\\&#124;\&#34;].*//g' &#124; sed &#34;s/['].*//g&#34; &#124; sort &#124; uniq]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">sed 's/http/\^http/g' FILENAME | tr -s &quot;^&quot; &quot;\n&quot; | grep http| sed 's/[\ |\\\|\&quot;].*//g' | sed &quot;s/['].*//g&quot; | sort | uniq</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/bash/get-a-list-of-urlsdomains-from-a-text-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Start an application from the command line in OSX</title>
		<link>http://sourcebench.com/languages/bash/start-an-application-from-the-command-line-in-osx/</link>
		<comments>http://sourcebench.com/languages/bash/start-an-application-from-the-command-line-in-osx/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 22:03:57 +0000</pubDate>
		<dc:creator>The SourceBench</dc:creator>
				<category><![CDATA[Bash/shell]]></category>
		<category><![CDATA[launch application]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://sourcebench.com/languages/bash/start-an-application-from-the-command-line-in-osx/</guid>
		<description><![CDATA[# use open -a followed by the program name and optionally a file name for an output log file
open -a /Applications/TextEdit.app logfile.txt]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;"># use open -a followed by the program name and optionally a file name for an output log file
open -a /Applications/TextEdit.app logfile.txt</pre>]]></content:encoded>
			<wfw:commentRss>http://sourcebench.com/languages/bash/start-an-application-from-the-command-line-in-osx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
