<?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>sbramley - coding life</title>
	<atom:link href="http://sbramley.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://sbramley.com</link>
	<description>A random view of all things in the world wide web</description>
	<lastBuildDate>Wed, 21 Dec 2011 18:19:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to use Split with jQuery?</title>
		<link>http://sbramley.com/2011/12/how-to-use-split-with-jquery/</link>
		<comments>http://sbramley.com/2011/12/how-to-use-split-with-jquery/#comments</comments>
		<pubDate>Wed, 21 Dec 2011 18:19:34 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[javascript snippets]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=157</guid>
		<description><![CDATA[var str = 'something -- something_else'; var substr = str.split(' -- '); // substr[0] contains &#34;something&#34; // substr[1] contains &#34;something_else&#038;quot]]></description>
			<content:encoded><![CDATA[<pre class="wp-code-highlight prettyprint">
var str = 'something -- something_else';
var substr = str.split(' -- ');
// substr[0] contains &quot;something&quot;
// substr[1] contains &quot;something_else&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/how-to-use-split-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB + power outage = downtime</title>
		<link>http://sbramley.com/2011/12/mongodb-power-outage-downtime/</link>
		<comments>http://sbramley.com/2011/12/mongodb-power-outage-downtime/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 13:35:28 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[server stuff]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=147</guid>
		<description><![CDATA[MongoDB handles unexpected shutdowns quite appallingly, one thing that I always forget is the general server language for speaking with the server and getting the info I need to get her back up and running. $ sudo status mongodb $ sudo stop mongodb $ sudo start mongodb $ sudo restart mongodb To see whats going on&#8230; If you see &#8220;Error: couldn’t connect to server 127.0.0.1} (anon):1137&#8243; This condition is largely ]]></description>
			<content:encoded><![CDATA[<p>MongoDB handles unexpected shutdowns quite appallingly, one thing that I always forget is the general server language for speaking with the server and getting the info I need to get her back up and running. </p>
<pre class="wp-code-highlight prettyprint">
$ sudo status mongodb
$ sudo stop mongodb
$ sudo start mongodb
$ sudo restart mongodb
</pre>
<p>To see whats going on&#8230;</p>
<p>If you see &#8220;Error: couldn’t connect to server 127.0.0.1} (anon):1137&#8243;<br />
This condition is largely due to an unclean shutdown, and results in the creation of a lockfile /var/lib/mongodb/mongod.lock.</p>
<pre class="wp-code-highlight prettyprint">
$ sudo rm /var/lib/mongodb/mongod.lock
$ sudo -u mongodb mongod -f /etc/mongodb.conf --repair
</pre>
<p>Then start the process again, all should be peachy in the world again</p>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/mongodb-power-outage-downtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache Address already in use: make_sock: could not bind to port 80 error and solution</title>
		<link>http://sbramley.com/2011/12/apache-address-already-in-use-make_sock-could-not-bind-to-port-80-error-and-solution/</link>
		<comments>http://sbramley.com/2011/12/apache-address-already-in-use-make_sock-could-not-bind-to-port-80-error-and-solution/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 04:01:56 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[server stuff]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=88</guid>
		<description><![CDATA[Just had this delightful problem tonight, fix: First make sure port 80/443 is not used by any other service or application with netstat command: # netstat -tulpn&#124; grep :80 If port 80 is bind to httpd, kill all process: # killall -9 httpd Now start the httpd: # /etc/init.d/httpd start Make sure it&#8217;s a user capable of sudo]]></description>
			<content:encoded><![CDATA[<p>Just had this delightful problem tonight, fix:<br />
First make sure port 80/443 is not used by any other service or application with netstat command:</p>
<pre class="wp-code-highlight prettyprint">
# netstat -tulpn| grep :80
</pre>
<p>If port 80 is bind to httpd, kill all process:</p>
<pre class="wp-code-highlight prettyprint">
# killall -9 httpd
</pre>
<p>Now start the httpd:</p>
<pre class="wp-code-highlight prettyprint">
# /etc/init.d/httpd start
</pre>
<p>Make sure it&#8217;s a user capable of sudo</p>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/apache-address-already-in-use-make_sock-could-not-bind-to-port-80-error-and-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a soft or symbolic link in ubuntu</title>
		<link>http://sbramley.com/2011/12/creating-a-soft-or-symbolic-link-in-ubuntu/</link>
		<comments>http://sbramley.com/2011/12/creating-a-soft-or-symbolic-link-in-ubuntu/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 01:11:23 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[server stuff]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=140</guid>
		<description><![CDATA[Sometimes you want to link to a directory that isn&#8217;t necessarily within the web root for the particular site you are on. Simple enough solution for it though. ln -s /webroot/home/httpd/test.com/index.php /home/sbramley/index.php or ln -s /webroot/home/httpd/test /home/sbramley/ So you can link to a directory of file easyyyyy]]></description>
			<content:encoded><![CDATA[<p>Sometimes you want to link to a directory that isn&#8217;t necessarily within the web root for the particular site you are on. </p>
<p>Simple enough solution for it though.</p>
<pre class="wp-code-highlight prettyprint">
ln -s /webroot/home/httpd/test.com/index.php /home/sbramley/index.php
</pre>
<p>or</p>
<pre class="wp-code-highlight prettyprint">
ln -s /webroot/home/httpd/test /home/sbramley/
</pre>
<p>So you can link to a directory of file easyyyyy</p>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/creating-a-soft-or-symbolic-link-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twisted Knickers &#8211; Change is good</title>
		<link>http://sbramley.com/2011/12/twisted-knickers-change-is-good/</link>
		<comments>http://sbramley.com/2011/12/twisted-knickers-change-is-good/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 01:54:49 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[featured]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=125</guid>
		<description><![CDATA[Twisted knickers is a site I built when I first started building sites, unfortunately web standards were pretty shocking back then and my skill set wasn&#8217;t up to par. The entire site was built using a table (yes, before I knew how to float divs). So when I got the opportunity to fix it up this year I jumped at the opportunity, who likes having their name against something that ]]></description>
			<content:encoded><![CDATA[<p>Twisted knickers is a site I built when I first started building sites, unfortunately web standards were pretty shocking back then and my skill set wasn&#8217;t up to par. The entire site was built using a table (yes, before I knew how to float divs). </p>
<p>So when I got the opportunity to fix it up this year I jumped at the opportunity, who likes having their name against something that doesn&#8217;t really match their skill sets.</p>
<p>For the first time I&#8217;ve used @font-face for embedding fonts, I&#8217;d always use transparent pngs before but of course, when you don&#8217;t have much content to start with, the more you can use, the better it be. It worked awesome as well. I allowed the client to choose the font they had most preference to on <a href="http://fontsquirrel.com" title="Font Squirrel" target="_blank">http://fontsquirrel.com</a>. </p>
<p>Something that narks me a lot is the myth of flash, why do people think that only flash can look really good? I found a slideshow which I like a lot for the optional transitional elements. <a href="http://aviathemes.com/aviaslider/" title="AviaSlider" target="_blank">http://aviathemes.com/aviaslider/</a> has to be one of the nicest jquery based slideshow system I&#8217;ve used.</p>
<p>Throw it all together with a stock photo for a background and boom. <a href="http://twistedknickers.ca" title="Twisted Knickers" target="_blank">http://twistedknickers.ca</a>. Clean, inviting and delivers the content required.</p>
<p>Happy with the result in the end and something I&#8217;m more than happy putting my name by.</p>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/twisted-knickers-change-is-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Matching a string</title>
		<link>http://sbramley.com/2011/12/matching-a-string/</link>
		<comments>http://sbramley.com/2011/12/matching-a-string/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:36:25 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[php snippets]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=122</guid>
		<description><![CDATA[I just posted on splitting a string, might as well add my match as they can often come hand in hand. preg_match(&#34;your search item&#34;, &#34;your_string&#34;) Boom, done]]></description>
			<content:encoded><![CDATA[<p>I just posted on splitting a string, might as well add my match as they can often come hand in hand.</p>
<pre class="wp-code-highlight prettyprint">
preg_match(&quot;your search item&quot;, &quot;your_string&quot;)
</pre>
<p>Boom, done</p>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/matching-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Splitting a string</title>
		<link>http://sbramley.com/2011/12/splitting-a-string/</link>
		<comments>http://sbramley.com/2011/12/splitting-a-string/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:28:16 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[php snippets]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=120</guid>
		<description><![CDATA[I&#8217;ve just spent 15 minutes looking for this darn function, never again! Here is how to split a string to get the information you require: Edit: A wise PHP guru just gave me an alternative option as well. $chars = explode('-', &#34;your-string-here&#34;); Is the same as: $chars = preg_split('/-/', &#34;your-string-here&#34;, -1, PREG_SPLIT_NO_EMPTY); $your = $chars[0]; $string = $chars[1]; $here = $chars[2]; Works just peachy]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just spent 15 minutes looking for this darn function, never again!<br />
Here is how to split a string to get the information you require:</p>
<p><em>Edit: A wise PHP guru just gave me an alternative option as well.</em></p>
<pre class="wp-code-highlight prettyprint">
$chars = explode('-', &quot;your-string-here&quot;);
</pre>
<p>Is the same as:</p>
<pre class="wp-code-highlight prettyprint">
$chars = preg_split('/-/', &quot;your-string-here&quot;, -1, PREG_SPLIT_NO_EMPTY);
                           $your = $chars[0];
                           $string = $chars[1];
                           $here = $chars[2];
</pre>
<p>Works just peachy</p>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/splitting-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update table with join function &#8211; MYSQL</title>
		<link>http://sbramley.com/2011/12/update-table-with-join-function-mysql/</link>
		<comments>http://sbramley.com/2011/12/update-table-with-join-function-mysql/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 16:46:29 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[mysql snippets]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=116</guid>
		<description><![CDATA[True story, I always forget where each value should be positioned for a left join on an update statement. This is always useful for a reference guide for me: UPDATE t1 LEFT JOIN t2 ON t2.id = t1.id SET t1.col1 = newvalue WHERE t2.id IS ]]></description>
			<content:encoded><![CDATA[<p>True story, I always forget where each value should be positioned for a left join on an update statement. This is always useful for a reference guide for me:</p>
<pre class="wp-code-highlight prettyprint">
UPDATE  t1
LEFT JOIN
        t2
ON      t2.id = t1.id
SET     t1.col1 = newvalue
WHERE   t2.id IS NULL
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/update-table-with-join-function-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP shorthand IF statements</title>
		<link>http://sbramley.com/2011/12/php-shorthand-if-statements/</link>
		<comments>http://sbramley.com/2011/12/php-shorthand-if-statements/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 03:42:44 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[php snippets]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=105</guid>
		<description><![CDATA[Easy to forget the correct syntax but darn it&#8217;s useful, a recap on shorthand php if statements. Basic True / False Declaration $is_admin = ($user['permissions'] == 'admin' ? true : false); Conditional Welcome Message echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!'; Conditional Items Message echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.'; Conditional Error Reporting Level error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT); Conditional Basepath echo '&#60;base href=&#34;http'.($PAGE_IS_SECURE ]]></description>
			<content:encoded><![CDATA[<p>Easy to forget the correct syntax but darn it&#8217;s useful, a recap on shorthand php if statements.</p>
<p>Basic True / False Declaration</p>
<pre class="wp-code-highlight prettyprint">
$is_admin = ($user['permissions'] == 'admin' ? true : false);
</pre>
<p>Conditional Welcome Message</p>
<pre class="wp-code-highlight prettyprint">
echo 'Welcome '.($user['is_logged_in'] ? $user['first_name'] : 'Guest').'!';
</pre>
<p>Conditional Items Message</p>
<pre class="wp-code-highlight prettyprint">
echo 'Your cart contains '.$num_items.' item'.($num_items != 1 ? 's' : '').'.';
</pre>
<p>Conditional Error Reporting Level</p>
<pre class="wp-code-highlight prettyprint">
error_reporting($WEBSITE_IS_LIVE ? 0 : E_STRICT);
</pre>
<p>Conditional Basepath</p>
<pre class="wp-code-highlight prettyprint">
echo '&lt;base href=&quot;http'.($PAGE_IS_SECURE ? 's' : '').'://mydomain.com&quot; /&gt;';
</pre>
<p>Nested PHP Shorthand</p>
<pre class="wp-code-highlight prettyprint">
echo 'Your score is:  '.($score &gt; 10 ? ($age &gt; 10 ? 'Average' : 'Exceptional') : ($age &gt; 10 ? 'Horrible' : 'Average') );
</pre>
<p>Leap Year Check</p>
<pre class="wp-code-highlight prettyprint">
$is_leap_year = ((($year % 4) == 0) &amp;&amp; ((($year % 100) != 0) || (($year %400) == 0)));
</pre>
<p>Conditional PHP Redirect</p>
<pre class="wp-code-highlight prettyprint">
header('Location: '.($valid_login ? '/members/index.php' : 'login.php?errors=1')); exit();
</pre>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/php-shorthand-if-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clickable elements</title>
		<link>http://sbramley.com/2011/12/clickable-elements/</link>
		<comments>http://sbramley.com/2011/12/clickable-elements/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 03:35:16 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[html snippets]]></category>
		<category><![CDATA[javascript snippets]]></category>

		<guid isPermaLink="false">http://sbramley.com/?p=98</guid>
		<description><![CDATA[&#60;a&#62; tags are great for text and images, but what about divs? or list elements? not so much. With most of my images, I set them as background images of a div, when it comes to positioning divs on a page it&#8217;s just easier than having to mess with the images within them as well. Here&#8217;s a tidy way of making your div clickable. &#60;div onclick=&#34;location.href='http://sbramley.com/';&#34; style=&#34;cursor: pointer;&#34;&#62; &#60;/div&#038;gt]]></description>
			<content:encoded><![CDATA[<p><img src='http://sbramley.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/98.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>&lt;a&gt; tags are great for text and images, but what about divs? or list elements? not so much. With most of my images, I set them as background images of a div, when it comes to positioning divs on a page it&#8217;s just easier than having to mess with the images within them as well.<br />
Here&#8217;s a tidy way of making your div clickable.</p>
<pre class="wp-code-highlight prettyprint">&lt;div onclick=&quot;location.href='http://sbramley.com/';&quot; style=&quot;cursor: pointer;&quot;&gt;
&lt;/div&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://sbramley.com/2011/12/clickable-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

