<?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>Ensellitis.com &#187; code</title>
	<atom:link href="http://ensellitis.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://ensellitis.com</link>
	<description>Coffee.  Tech.  The bizarre.  All nerd stuff.</description>
	<lastBuildDate>Fri, 28 May 2010 20:49:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>CSS Media Queries</title>
		<link>http://ensellitis.com/2010/05/28/css-media-queries/</link>
		<comments>http://ensellitis.com/2010/05/28/css-media-queries/#comments</comments>
		<pubDate>Fri, 28 May 2010 20:47:01 +0000</pubDate>
		<dc:creator>Devin Clark</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://ensellitis.com/?p=125</guid>
		<description><![CDATA[It is possible to load different styles on a page if certain factors exist. Now, I am not going to try to confuse you any more and I am just going to jump into some code. &#60;link src=&#34;some Styles.css&#34; media=&#34;screen&#34; /&#62; The important part of this is the media attribute. I am sure you all [...]]]></description>
			<content:encoded><![CDATA[<p>It is possible to load different styles on a page if certain factors exist. Now, I am not going to try to confuse you any more and I am just going to jump into some code.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link src=&quot;some Styles.css&quot; media=&quot;screen&quot; /&gt;</pre></div></div>

<p>The important part of this is the media attribute. I am sure you all use at least screen and print. We can add to those to change the layout of our page for different screen resolutions.</p>
<p>For Example, adding to our previous code:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link src=&quot;someStyles.css&quot; media=&quot;screen&quot; /&gt;
&lt;link src=&quot;someMediaStyles.css&quot; media=&quot;screen and (min-width: 480px)&quot; /&gt;</pre></div></div>

<p>All we added was &#8220;and (min-width: 480px)&#8221; after in our media attribute after screen. What that means is if the width of the browser is at least 480px then the stylesheet someMobileStyles will be loaded.<br />
That was a bad choice on my part to use min-width for iphone styles. There is another media query we can use, device-width, which does what I was trying to accomplish. (While writing the demo I discovered that min-width doesn&#8217;t work on the iPhone, device-width does)</p>
<p>From here on out I am going to reference using the @media declaration within a stylesheet. An example of the @media declaration:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media screen and (device-width: 480px) {</span>
<span style="color: #808080; font-style: italic;">/*css goes in here */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Pro Tip: I always use @media over the media attribute on the link tag because it saves an http request.</p>
<p>There are several media queries that we can use. The ones I can see myself using are min-width, device-width, orientation.<br />
Most of them allow you to add min- or max- as a prefix for greater or equal to or smaller or equal to.<br />
For a fill list, visit the <a href="http://www.w3.org/TR/css3-mediaqueries/#media1">W3 CSS Media Queries article</a>.</p>
<p>I wrote up a demo that shows a practical application of this technique. It shows 4 different layouts, one for 960px+, one for 600px to 959px, one for 480px to 599px and one for mobile devices with a width of 480px (like the iPhone).</p>
<p><a href="http://ensellitis.com/wp-content/uploads/2010/05/mediaQueriesDemo.html">Demo</a></p>
<h4>Further Reading</h4>
<p><a href="http://www.w3.org/TR/css3-mediaqueries/">http://www.w3.org/TR/css3-mediaqueries/</a><br />
<a href="http://css-tricks.com/resolution-specific-stylesheets/">Chris Coyer&#8217;s Excellent article on CSS Media Queries</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ensellitis.com/2010/05/28/css-media-queries/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Auto format HEX colors</title>
		<link>http://ensellitis.com/2010/05/20/auto-format-hex-colors/</link>
		<comments>http://ensellitis.com/2010/05/20/auto-format-hex-colors/#comments</comments>
		<pubDate>Thu, 20 May 2010 10:57:46 +0000</pubDate>
		<dc:creator>Chris Ensell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[HEX]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://ensellitis.com/?p=85</guid>
		<description><![CDATA[Another snippet from my library. This I have actually found useful several times in the past. It looks for HEX color values in a string and colorizes them. function format_hex_color&#40;$t&#41; &#123; $t = preg_replace&#40;&#34;#(\#[0-9A-Fa-f]{6})#si&#34;, &#34;&#60;span style='color:\\1'&#62;\\1&#60;/span&#62;&#34;, $t&#41;; return $t; &#125; Example usage $string = &#34;He wanted it in #ff0000 or #00FFAA.&#34;; $string = format_hex_color&#40;$string&#41;; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Another snippet from my library.  This I have actually found useful several times in the past.  It looks for HEX color values in a string and colorizes them.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> format_hex_color<span style="color: #009900;">&#40;</span><span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#(\#[0-9A-Fa-f]{6})#si&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;span style='color:<span style="color: #000099; font-weight: bold;">\\</span>1'&gt;<span style="color: #000099; font-weight: bold;">\\</span>1&lt;/span&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$t</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$t</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Example usage</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;He wanted it in #ff0000 or #00FFAA.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> format_hex_color<span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span></pre></div></div>

<p>Would output:<br />
He wanted it in <span style="color:#ff0000">#ff0000</span> or <span style="color:#00FFAA">#00FFAA</span></p>
<p>Works with both caps and lowercase.</p>
]]></content:encoded>
			<wfw:commentRss>http://ensellitis.com/2010/05/20/auto-format-hex-colors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP – Shorthand Echo</title>
		<link>http://ensellitis.com/2010/05/19/php-shorthand-echo/</link>
		<comments>http://ensellitis.com/2010/05/19/php-shorthand-echo/#comments</comments>
		<pubDate>Wed, 19 May 2010 15:26:39 +0000</pubDate>
		<dc:creator>Chris Ensell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://ensellitis.com/?p=55</guid>
		<description><![CDATA[To test out my new syntax highlighting plugin, I&#8217;m going to post a shorthand way of doing an echo in PHP. A typical echo is&#8230; &#60;?php echo $variable; ?&#62; And the shorthand method that I almost always use&#8230; &#60;?=$variable?&#62;]]></description>
			<content:encoded><![CDATA[<p>To test out my new syntax highlighting plugin, I&#8217;m going to post a shorthand way of doing an echo in PHP.</p>
<p>A typical echo is&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$variable</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And the shorthand method that I almost always use&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$variable</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://ensellitis.com/2010/05/19/php-shorthand-echo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

