<?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>Code Chewing</title>
	<atom:link href="http://www.codechewing.com/library/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codechewing.com/library</link>
	<description>Your library of really useful web development tips</description>
	<lastBuildDate>Sun, 19 May 2013 18:43:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>How to remove files and directories in Terminal</title>
		<link>http://www.codechewing.com/library/remove-file-directory-terminal/</link>
		<comments>http://www.codechewing.com/library/remove-file-directory-terminal/#comments</comments>
		<pubDate>Sat, 18 May 2013 20:06:25 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Commands]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2810</guid>
		<description><![CDATA[It&#8217;s too easy to remove a directory or file when using linux commands inside of the terminal. For removing files, you&#8217;d use rm: rm index.html To remove a directory in terminal, you need to add -r to the command: rm &#8230; <a href="http://www.codechewing.com/library/remove-file-directory-terminal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s <del>too</del> easy to remove a directory or file when using linux commands inside of the terminal.</p>
<p>For removing files, you&#8217;d use <kbd>rm</kbd>:</p>
<p><kbd>rm index.html</kbd></p>
<p>To remove a directory in terminal, you need to add -r to the command:</p>
<p><kbd>rm -r directory</kbd></p>
<p>You can also create conditions to be met for the removal. For example to remove all directories that start with 2013, we&#8217;d do this:</p>
<p><kbd>rm -r 2013*</kbd></p>
<p>And if you need to delete only files with a particular extension, say PHP files, you can use:</p>
<p><kbd>rm *.php</kbd></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/remove-file-directory-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create multiple incrementing directories in Terminal</title>
		<link>http://www.codechewing.com/library/incrementing-directories-terminal/</link>
		<comments>http://www.codechewing.com/library/incrementing-directories-terminal/#comments</comments>
		<pubDate>Sat, 18 May 2013 19:23:35 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Commands]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2803</guid>
		<description><![CDATA[Using some linux commands inside Terminal when you need to create many directories that increment by number is easy, such as a directory named after dates, e.g. 2013-01. This technique is very useful and efficient, read on! Let&#8217;s say we &#8230; <a href="http://www.codechewing.com/library/incrementing-directories-terminal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Using some linux commands inside Terminal when you need to create many directories that increment by number is easy, such as a directory named after dates, e.g. 2013-01. This technique is very useful and efficient, read on!</p>
<p>Let&#8217;s say we need directories 2012-01 to 2013-12. Now this is going to take some time manually through the GUI, so let&#8217;s do this via some linux commands inside of the Terminal.</p>
<p>First I&#8217;ll <kbd>cd</kbd> into my Pictures directory:</p>
<p><kbd>cd Pictures</kbd></p>
<p><a href="http://www.codechewing.com/library/incrementing-directories-with-bash/screen-shot-2013-05-18-at-20-06-06/" rel="attachment wp-att-2804"><img class="alignnone size-full wp-image-2804" alt="create directories with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-20.06.06.png" width="916" height="442" /></a></p>
<p>We&#8217;ll be using brace expressions to get this done. So we need directories 2012-01 to 2013-12. Here it is:</p>
<p><kbd>mkdir {2012..2013}-0{1..9} {2012..2013}-{10..12}</kbd></p>
<p><a href="http://www.codechewing.com/library/incrementing-directories-with-bash/screen-shot-2013-05-18-at-20-11-19/" rel="attachment wp-att-2805"><img class="alignnone size-full wp-image-2805" alt="mkdir with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-20.11.19.png" width="916" height="442" /></a></p>
<p>We split the brace expressions into two, as we&#8217;re padding out the months that are less than 10 with a leading zero. 10-12 can be left as is. Now let&#8217;s check out the result:</p>
<p><kbd>ls</kbd></p>
<p><a href="http://www.codechewing.com/library/incrementing-directories-with-bash/screen-shot-2013-05-18-at-20-13-50/" rel="attachment wp-att-2806"><img class="alignnone size-full wp-image-2806" alt="incremented directory names with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-20.13.50.png" width="916" height="442" /></a></p>
<p>And there they all are! This is a very powerful tool you should absolutely take advantage of when you need directory names with appended and/or prepended incremented digits. This is a great time saver with only a bit of linux command knowledge executed from within the terminal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/incrementing-directories-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create &amp; reuse a HTML template with Bash</title>
		<link>http://www.codechewing.com/library/reuse-html-template-bash/</link>
		<comments>http://www.codechewing.com/library/reuse-html-template-bash/#comments</comments>
		<pubDate>Sat, 18 May 2013 18:33:40 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2767</guid>
		<description><![CDATA[Situation: You&#8217;re a web developer and the pages within the project you&#8217;re working on require the same initial HTML or PHP template for every file, and you&#8217;re sick and tired of opening up an existing file and clicking the Save &#8230; <a href="http://www.codechewing.com/library/reuse-html-template-bash/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Situation:</p>
<p>You&#8217;re a web developer and the pages within the project you&#8217;re working on require the same initial HTML or PHP template for every file, and you&#8217;re sick and tired of opening up an existing file and clicking the Save As option from there. Maybe you have to delete some content as well before you can even get to your starting point? Pain.</p>
<p>Instead, let&#8217;s be smarter and utilise a neat Bash script to do the hard work for us. All it requires is a straight forward Bash script along with some linux commands from within the terminal. Then all you&#8217;ve have to do in the future is type this into the terminal and you&#8217;ve have a new custom file with the template contents inside of it:</p>
<p><kbd>./html_template &gt; new-file-with-template-.html</kbd></p>
<p><strong>But before you can do the above</strong>, here&#8217;s the instructions:</p>
<p>1) First, open your IDE of choice &#8211; for me, it&#8217;s Sublime Text, and we&#8217;re going to create the HTML template in Bash. It&#8217;s not scary, honest! Give it a try.</p>
<p>2) Here&#8217;s a very basic HTML template for this example, which we&#8217;ll type into the IDE (You can go nuts from here, but it&#8217;s just a basic example):</p>
<pre class="brush: bash; title: ; notranslate">#!/bin/bash

# Simple automated HTML template

cat &lt;&lt; _EOF_
&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;HTML Template example&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;/body&gt;

&lt;/html&gt;
_EOF_
</pre>
<p>Here&#8217;s the screenshot inside of my Sublime Text IDE:</p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-18-08-45/" rel="attachment wp-att-2771"><img class="alignnone size-full wp-image-2771" alt="html template using bash shell" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-18.08.45.png" width="755" height="563" /></a></p>
<p>We&#8217;ve just wrote a Bash script! Some bits explained:</p>
<p>- <kbd>#!/bin/bash</kbd> &#8211; This is <strong>not a comment</strong>, this tells the shell where Bash lives so it can successfully interpret the file.<br />
- As you may have expected, everything inside of <kbd>cat &lt;&lt; _EOF_</kbd> and <kbd>_EOF_</kbd> is outputted. It acts as an echo. You can actually name the <kbd>EOF</kbd> anything you want, but <kbd>EOF</kbd> (End Of File) is the convention.</p>
<p>3) Save this file inside your root website directory and name it <strong>html_template.sh</strong></p>
<p>4) Now it&#8217;s time for some cool linux commands inside the terminal! Open up terminal and cd into the same website directory as your new Bash script. For me, it&#8217;s here:</p>
<p><kbd>cd Documents/website</kbd></p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-05-26/" rel="attachment wp-att-2781"><img class="alignnone size-full wp-image-2781" alt="cd with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.05.26.png" width="916" height="442" /></a></p>
<p>5) Now we&#8217;re inside, check your file is there, using the list files with <kbd>-l</kbd> command to provide a detailed view:</p>
<p><kbd>ls -l</kbd></p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-06-18/" rel="attachment wp-att-2782"><img class="alignnone size-full wp-image-2782" alt="ls -l with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.06.18.png" width="916" height="442" /></a></p>
<p>Here you can see our Bash script &#8211; html_template.sh. The problem is, the file permissions do not allow for it to be executed; <code>-rw-r--r--</code>. We need <code>-rwx-r-x-r-x</code> for it to executable.</p>
<p>6) Let&#8217;s change this using the chmod command, where we pass <code>755</code> to get the permissions we require:</p>
<p><kbd>chmod 755 html_template.sh</kbd></p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-10-02/" rel="attachment wp-att-2784"><img class="alignnone size-full wp-image-2784" alt="chmod 755 with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.10.02.png" width="916" height="442" /></a></p>
<p>7) Check your file permissions have been updated by running the ls -l command for a detailed view again:</p>
<p><kbd>ls -l</kbd></p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-12-07/" rel="attachment wp-att-2786"><img class="alignnone size-full wp-image-2786" alt="check file permissions with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.12.07.png" width="916" height="442" /></a></p>
<p>As you can see &#8211; our file permissions have successfully been updated! Now the script can run! Excellent.</p>
<p>8) It&#8217;s time to run the script. We need to trigger the script and pass it a file name that it creates, or overwrites (with the HTML template) upon execution. It&#8217;s simple &#8211; my new file will be called example.php. So here goes:</p>
<p><kbd>./html_template.sh &gt; example.php</kbd></p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-16-12/" rel="attachment wp-att-2788"><img class="alignnone size-full wp-image-2788" alt="create new file with existing html template" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.16.12.png" width="916" height="442" /></a></p>
<p>Now let&#8217;s check example.php has been created:</p>
<p><kbd>ls</kbd></p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-18-22/" rel="attachment wp-att-2789"><img class="alignnone size-full wp-image-2789" alt="check html bash template" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.18.22.png" width="916" height="442" /></a></p>
<p>And there it is! Example.php just got created! And if I open it up in Sublime text:</p>
<p><a href="http://www.codechewing.com/library/reuse-html-template-bash/screen-shot-2013-05-18-at-19-19-52/" rel="attachment wp-att-2790"><img class="alignnone size-full wp-image-2790" alt="bash html template output" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-19.19.52.png" width="688" height="446" /></a></p>
<p>The new file has adopted our HTML template! Awesome! And that&#8217;s how you easily create HTML templates and trigger them with Bash! And if your template ever needs updating, you can just go into the bash script and update it there. Then any new files created via this method will include the updated template.</p>
<p>Lots of credit goes <a href="http://www.linuxcommand.org/" target="_blank">here</a> for this article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/reuse-html-template-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to open &amp; view a file inside terminal</title>
		<link>http://www.codechewing.com/library/how-to-open-view-file-in-terminal/</link>
		<comments>http://www.codechewing.com/library/how-to-open-view-file-in-terminal/#comments</comments>
		<pubDate>Sat, 18 May 2013 16:49:17 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Commands]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2759</guid>
		<description><![CDATA[You can open and view a text file from within the terminal with some simple linux commands to avoid changing windows, or incase you only need a quick preview without any syntax highlighting. To do this, we&#8217;ll be using a &#8230; <a href="http://www.codechewing.com/library/how-to-open-view-file-in-terminal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>You can open and view a text file from within the terminal with some simple linux commands to avoid changing windows, or incase you only need a quick preview without any syntax highlighting. To do this, we&#8217;ll be using a command called <kbd>less</kbd>.</p>
<p><kbd>cd</kbd> into a directory where you wish to preview a file, for me, it&#8217;s a JavaScript within here:</p>
<p><kbd>cd gallery-image</kbd></p>
<p>The file I want to preview inside this directory is called jquery.silkysmooth.1.0.js</p>
<p>So I&#8217;ll go ahead and type the folowing:</p>
<p><kbd>less jquery.silkysmooth.1.0.js</kbd></p>
<p><a href="http://www.codechewing.com/library/how-to-open-view-file-with-bash/screen-shot-2013-05-18-at-17-41-03/" rel="attachment wp-att-2760"><img class="alignnone size-full wp-image-2760" alt="view file contents inside of the terminal with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-17.41.03.png" width="889" height="304" /></a></p>
<p>After which, I&#8217;ll get the file contents outputted into the terminal window:</p>
<p><a href="http://www.codechewing.com/library/how-to-open-view-file-with-bash/screen-shot-2013-05-18-at-17-41-38/" rel="attachment wp-att-2762"><img class="alignnone size-full wp-image-2762" alt="view file inside bash using less command" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-17.41.38.png" width="889" height="511" /></a></p>
<p>You can scroll through this file and preview it right inside of the terminal!</p>
<p>To exit this view, press <kbd>q</kbd>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/how-to-open-view-file-in-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Curl a webpage in terminal</title>
		<link>http://www.codechewing.com/library/curl-webpage-in-terminal/</link>
		<comments>http://www.codechewing.com/library/curl-webpage-in-terminal/#comments</comments>
		<pubDate>Sat, 18 May 2013 16:31:22 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux Commands]]></category>
		<category><![CDATA[Other]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2750</guid>
		<description><![CDATA[It&#8217;s easy to download a website page straight onto your local hardrive with some simple linux commands inside of the terminal. We&#8217;ll be using the Curl command to achieve this. 1) Open up your terminal (or equivalent), and cd into &#8230; <a href="http://www.codechewing.com/library/curl-webpage-in-terminal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s easy to download a website page straight onto your local hardrive with some simple linux commands inside of the terminal. We&#8217;ll be using the Curl command to achieve this.</p>
<p>1) Open up your terminal (or equivalent), and cd into the directory you wish to save the webpage to:</p>
<p><kbd>cd Documents/bash</kbd></p>
<p><a href="http://www.codechewing.com/library/curl-webpage-with-bash/screen-shot-2013-05-18-at-17-25-10/" rel="attachment wp-att-2752"><img class="alignnone size-full wp-image-2752" alt="bash cd change directory" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-17.25.10.png" width="799" height="258" /></a></p>
<p>2) Now we can Curl the webpage off the internet and save it in our current directory:</p>
<p><kbd>curl -O http://www.codechewing.com/index.php</kbd></p>
<p><a href="http://www.codechewing.com/library/curl-webpage-with-bash/screen-shot-2013-05-18-at-17-25-51/" rel="attachment wp-att-2753"><img class="alignnone size-full wp-image-2753" alt="Curl website with bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-17.25.51.png" width="799" height="258" /></a></p>
<p>You&#8217;ll receive some confirmation details, telling you how long it took etc. You can now check your directory and find the webpage saved locally! It may look something like this:</p>
<p><a href="http://www.codechewing.com/library/curl-webpage-with-bash/screen-shot-2013-05-18-at-17-26-45/" rel="attachment wp-att-2754"><img class="alignnone size-full wp-image-2754" alt="curl webpage using bash" src="http://www.codechewing.com/library/wp-content/uploads/2013/05/Screen-Shot-2013-05-18-at-17.26.45.png" width="844" height="557" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/curl-webpage-in-terminal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add permanent comments to Sass compressed/minified CSS files</title>
		<link>http://www.codechewing.com/library/permanent-comments-to-sass-compressed-css/</link>
		<comments>http://www.codechewing.com/library/permanent-comments-to-sass-compressed-css/#comments</comments>
		<pubDate>Wed, 08 May 2013 16:40:00 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Sass]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2741</guid>
		<description><![CDATA[Inside of the Ruby file, config.rb, you can add some compile settings. One of these settings is called output_style, which gives you the option to compress/minify your stylesheet. Now I want to minify my CSS file, so I&#8217;ll update the &#8230; <a href="http://www.codechewing.com/library/permanent-comments-to-sass-compressed-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Inside of the Ruby file, <code>config.rb</code>, you can add some compile settings. One of these settings is called <code>output_style</code>, which gives you the option to compress/minify your stylesheet. Now I want to minify my CSS file, so I&#8217;ll update the <code>config.rb</code> file to contain the following line:</p>
<pre class="brush: ruby; title: ; notranslate">output_style = :compressed</pre>
<p>After restarting the Sass watch and forcing a re-compile, I find my CSS file has been compressed onto one line, great! That&#8217;s sorted for production.</p>
<p>But what if I intend to keep a comment block at the top, containing copyright notice, or author accreditation? This output style mode will strip those comments of mine.</p>
<p>To avoid your important comments from being removed, add a comment into your Sass file in the following way, with a leading exclamation mark:</p>
<pre class="brush: css; title: ; notranslate">/*! This will not be removed!! @author Codechewing */</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/permanent-comments-to-sass-compressed-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check for an AJAX request with PHP</title>
		<link>http://www.codechewing.com/library/check-for-ajax-request-with-php/</link>
		<comments>http://www.codechewing.com/library/check-for-ajax-request-with-php/#comments</comments>
		<pubDate>Tue, 07 May 2013 20:01:31 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2731</guid>
		<description><![CDATA[When you have a script waiting to receive an AJAX request to process, it&#8217;s sometimes a good idea to ensure that the request is a genuine AJAX call. This may strengthen the security of your website. Here&#8217;s a function you &#8230; <a href="http://www.codechewing.com/library/check-for-ajax-request-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When you have a script waiting to receive an AJAX request to process, it&#8217;s sometimes a good idea to ensure that the request is a genuine AJAX call. This may strengthen the security of your website.</p>
<p>Here&#8217;s a function you can use to check if the request was in fact from an AJAX call:</p>
<pre class="brush: php; title: ; notranslate">function is_ajax() {

  if( !empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) &amp;&amp;
  strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
  {
    return true;
  } else {
    return false;
  }

}</pre>
<p>If the function returns false, your PHP script could stop execution and do something else with this knowledge in hand. If the AJAX call is recognised then your PHP can get on with it&#8217;s normal PHP-like duties with the information from the AJAX request.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/check-for-ajax-request-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check for CSS transition support in the browser with JavaScript</title>
		<link>http://www.codechewing.com/library/check-for-css-transition-support-in-the-browser-with-javascript/</link>
		<comments>http://www.codechewing.com/library/check-for-css-transition-support-in-the-browser-with-javascript/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 13:04:02 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2724</guid>
		<description><![CDATA[Once you can determine if the browser supports CSS transitions, you can steer away from doing the animation through JavaScript, and instead use the more performance efficient CSS animations. Here&#8217;s the simple method of how to detect the CSS transitions: &#8230; <a href="http://www.codechewing.com/library/check-for-css-transition-support-in-the-browser-with-javascript/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Once you can determine if the browser supports CSS transitions, you can steer away from doing the animation through JavaScript, and instead use the more performance efficient CSS animations. Here&#8217;s the simple method of how to detect the CSS transitions:</p>
<pre class="brush: jscript; title: ; notranslate">if( 'WebkitTransition' in document.body.style ||
    'MozTransition' in document.body.style ||
    'OTransition' in document.body.style ||
    'transition' in document.body.style
) {
  // Do some CSS transitioning stuff
}</pre>
<p>You can build on this feature detection technique to use CSS animation instead &#8211; where it&#8217;s supported. You can even establish what prefixes to use if you want to go the extra mile.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/check-for-css-transition-support-in-the-browser-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatically add CSS vendor prefixes in Sublime Text using Emmet</title>
		<link>http://www.codechewing.com/library/automatically-add-css-vendor-prefixes-sublime-text-emmet/</link>
		<comments>http://www.codechewing.com/library/automatically-add-css-vendor-prefixes-sublime-text-emmet/#comments</comments>
		<pubDate>Fri, 29 Mar 2013 19:46:26 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Sublime Text]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2688</guid>
		<description><![CDATA[If you&#8217;re in need of an automatic way to add vendor prefixes to your CSS properties and values (such as -moz-, -webkit- etc.) , and you&#8217;re already using Sublime Text 2 with the Emmet plugin, you can generate the prefixes automatically &#8230; <a href="http://www.codechewing.com/library/automatically-add-css-vendor-prefixes-sublime-text-emmet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re in need of an automatic way to add vendor prefixes to your CSS properties and values (such as <code>-moz-</code>, <code>-webkit-</code> etc.) , and you&#8217;re already using Sublime Text 2 with the <a href="https://github.com/sergeche/emmet-sublime" target="_blank">Emmet plugin</a>, you can generate the prefixes automatically so you don&#8217;t have to worry about manually typing them out every time.</p>
<p>All we need to do is type a hyphen before our CSS property then press tab. See below for details:</p>
<pre class="brush: css; title: ; notranslate">-text-shadow /* then press tab */

/* Results in this */
-webkit-text-shadow: ;
-moz-text-shadow: ;
-ms-text-shadow: ;
-o-text-shadow: ;
text-shadow: ;
</pre>
<p>The cursor will automatically be at the end of each line before the semi-colon, where you can enter your desired values.</p>
<h2>Be vendor specific</h2>
<p>You can also choose the vendor prefixes you wish to support manually, rather than above, which just assumes all vendor prefixes are required.</p>
<pre class="brush: css; title: ; notranslate">-wm-text-shadow /* then press tab */

/* Results in this */
-webkit-text-shadow: ;
-moz-text-shadow: ;
text-shadow: ;
</pre>
<p>Be smart and download Emmet, use shortcuts like this and up your development speed and enjoy less of the boring stuff, like manually adding prefixes. Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/automatically-add-css-vendor-prefixes-sublime-text-emmet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple case conditions for one case inside a switch statement</title>
		<link>http://www.codechewing.com/library/multiple-case-conditions-for-one-case-inside-switch-statement/</link>
		<comments>http://www.codechewing.com/library/multiple-case-conditions-for-one-case-inside-switch-statement/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 21:07:56 +0000</pubDate>
		<dc:creator>Peter J Langley</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codechewing.com/library/?p=2679</guid>
		<description><![CDATA[Recently in JavaScript I needed the equivalent to an OR condition inside my switch statement for one of the cases. Without boring you about why I needed this OR condition, I&#8217;ll just share my recent snippet with you. It&#8217;s easy &#8230; <a href="http://www.codechewing.com/library/multiple-case-conditions-for-one-case-inside-switch-statement/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently in JavaScript I needed the equivalent to an OR condition inside my switch statement for one of the cases. Without boring you about why I needed this OR condition, I&#8217;ll just share my recent snippet with you. It&#8217;s easy enough to do:</p>
<pre class="brush: jscript; title: ; notranslate">switch( event.target.id ) {

  case 'meet-me-prev':
  case 'meet-me-prev-arrow':
  {
    GALLERY.slide('prev');
    break;
  }

  case 'meet-me-next':
  case 'meet-me-next-arrow':
  {
    GALLERY.slide('next');
    break;
  }

  default:
    return;

}</pre>
<p>As you can see, you just list the case conditions for the one case, and wrap the functionality inside curly braces.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codechewing.com/library/multiple-case-conditions-for-one-case-inside-switch-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
