<?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>Things I Learned While Programming</title>
	<atom:link href="http://chrissilich.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://chrissilich.com/blog</link>
	<description>/* that might be helpful when you&#039;re programming too */</description>
	<lastBuildDate>Mon, 05 Mar 2012 22:35:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Stop Google from hijacking arrow key presses on Search Result pages</title>
		<link>http://chrissilich.com/blog/stop-google-from-hijacking-arrow-key-presses-on-search-result-pages/</link>
		<comments>http://chrissilich.com/blog/stop-google-from-hijacking-arrow-key-presses-on-search-result-pages/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 22:22:04 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[annoying]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[down]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[hijack]]></category>
		<category><![CDATA[keystrokes]]></category>
		<category><![CDATA[scroll]]></category>
		<category><![CDATA[up]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=317</guid>
		<description><![CDATA[If, like me, you use the arrow keys to scroll, or command key with an arrow key to scroll to the top or bottom of webpages on a daily basis, then you&#8217;ve been burned recently by google&#8217;s &#8220;helpful&#8221; new keyboard &#8230; <a href="http://chrissilich.com/blog/stop-google-from-hijacking-arrow-key-presses-on-search-result-pages/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If, like me, you use the arrow keys to scroll, or command key with an arrow key to scroll to the top or bottom of webpages on a daily basis, then you&#8217;ve been burned recently by google&#8217;s &#8220;helpful&#8221; new keyboard navigation on Search Result pages. </p>
<p>Yes, google thought it would be just a great idea to make their website the only one of the frickin internet that takes over our arrow keys and makes them much less useful.</p>
<p>Anyway, this guy <a href="http://zimzat.com/" target="_blank">ZimZat</a> hated it too, so he made a Chrome extension called <a href="http://userscripts.org./scripts/show/88447" target="_blank">Arrow Key Guard</a> to fix the problem. </p>
<p>If you&#8217;re not using Chrome, I don&#8217;t care, you have bigger problems anyway and you probably don&#8217;t use your keyboard for anything but typing shit about your cat into MS Powerpoint rainbow colored word-art objects anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/stop-google-from-hijacking-arrow-key-presses-on-search-result-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iTunes Match stuck on &#8220;Step 1: Gathering information about your iTunes Library&#8221;</title>
		<link>http://chrissilich.com/blog/stuck-on-gathering-information-about-your-itunes-library/</link>
		<comments>http://chrissilich.com/blog/stuck-on-gathering-information-about-your-itunes-library/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 21:16:10 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[itunes]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[match]]></category>
		<category><![CDATA[plus]]></category>
		<category><![CDATA[sync]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=316</guid>
		<description><![CDATA[I signed up for iTunes Match today, mostly just to upgrade all my music to un-DRM&#8217;d 256k (the iTunes Plus method would have cost about $100 at 30c a track). The jury is still out on whether I&#8217;ll renew the &#8230; <a href="http://chrissilich.com/blog/stuck-on-gathering-information-about-your-itunes-library/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I signed up for iTunes Match today, mostly just to upgrade all my music to un-DRM&#8217;d 256k (the iTunes Plus method would have cost about $100 at 30c a track). The jury is still out on whether I&#8217;ll renew the service next year.</p>
<p>Anyway, it got all the way 100% through Step 1: Gathering information about your iTunes library. and then stayed there for hours. Finally I noticed that a few songs in my library add a little cloud icon with a line through it. Closer inspection showed that those songs were DRM&#8217;d and were purchased on my ex-girlfriend&#8217;s iTunes account, which I am no longer authorized to use. Deleting, or removing them from the library (if you can foresee a need for DRM&#8217;d files you can&#8217;t open) will fix the problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/stuck-on-gathering-information-about-your-itunes-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Primal Screen&#8217;s Mic AS3 Output class</title>
		<link>http://chrissilich.com/blog/primal-screens-mic-as3-output-class/</link>
		<comments>http://chrissilich.com/blog/primal-screens-mic-as3-output-class/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 20:18:13 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[Actionscript/Flash]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[mic]]></category>
		<category><![CDATA[output]]></category>
		<category><![CDATA[primal]]></category>
		<category><![CDATA[primalscreen]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[trace]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=315</guid>
		<description><![CDATA[Today I committed the first version of my Mic AS3 class to Primal Screen&#8216;s Github repository. The purpose of this class is to organize your Output window into something much more usable. I wrote it in out typical relaxed Primal &#8230; <a href="http://chrissilich.com/blog/primal-screens-mic-as3-output-class/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I committed the first version of my Mic AS3 class to <a href="http://www.primalscreen.com" target="_blank">Primal Screen</a>&#8216;s <a href="https://github.com/primalscreen/as3/blob/master/com/primalscreen/utils/Mic.as" target="_blank">Github repository</a>.</p>
<p>The purpose of this class is to organize your Output window into something much more usable. I wrote it in out typical relaxed Primal Screen style&mdash; very human readable, very easy to figure out what function does what.</p>
<p>First, import the class:</p>
<pre class="brush:as3">
import com.primalscreen.utils.Mic;
</pre>
<p>Then say something into the Mic:</p>
<pre class="brush:as3">
Mic.say("This is a test", this);
</pre>
<p>And you should see this in your output window:</p>
<pre class="brush:text">
myClass says:  This is a test
</pre>
<p>The Mic class uses that reference to &#8220;this&#8221; to grab the name of the class that is &#8220;talking&#8221; to it, so you can see where the message is coming from, then it adds spaces where needed to line everything up. When you say things from a few different classes, you see the power in this:</p>
<pre class="brush:text">
       myClass says:  This is a test
  SoundManager says:  Playing sound "1.mp3"
       myModel says:  The button was pushed
  myController says:  Message recieved!
        myView says:  All your base are belong to us!
</pre>
<p>That&#8217;s a lot of &#8220;says: &#8221; isn&#8217;t it? Well that&#8217;s because we&#8217;re being calm, and well mannered. We&#8217;re saying things that ought to be said. Important things should be yelled!</p>
<pre class="brush:as3">
Mic.yell("This must be important!", this);
</pre>
<p>When the app starts to get big, with lots of traces, and you just want the big picture, turn off the normal speech, so you just hear the important stuff that you yelled (or screamed, we&#8217;ll get to that):</p>
<pre class="brush:as3">
Mic.ignoreSpeech();
</pre>
<p>Some things we don&#8217;t care about much, but on the off chance that we&#8217;re tearing our hair out in über-debug mode, and want every last bit of data, we should still whisper it:</p>
<pre class="brush:as3">
Mic.whisper("Nobody cares about what I'm saying right now", this);
</pre>
<p>Or if it&#8217;s super-duper important, we want to SCREAM it, and we can:</p>
<pre class="brush:as3">
Mic.scream("Something crazy is happening!", this);
</pre>
<p>In the hierarchy it goes whisper, say, yell, scream, and when you ignore a level, you ignore the ones below it too. What about ignoring a class:</p>
<pre class="brush:as3">
Mic.ignore(this);
Mic.ignore(SoundManager);
// this is a reference to the SoundManager class object
Mic.ignore("SoundManager");
// this works too, and we don't need an actual object reference
Mic.silence(this); // an alias for ignore

Mic.unignore(this);
Mic.unsilence(this); // an alias for unignore
</pre>
<p>What about the opposite, when we want to focus on the output of one particular class?</p>
<pre class="brush:as3">
Mic.spotlight(this);
Mic.spotlight(SoundManager); // class ref
Mic.spotlight("SoundManager"); // class name as string
Mic.focus(this); // an alias for spotlight

Mic.unspotlight();
Mic.unfocus(this); // an alias for unspotlight
</pre>
<p>And I didn&#8217;t cover it above, but here are the other ignore functions:</p>
<pre class="brush:as3">
Mic.ignoreWhispers();
Mic.ignoreSpeech();
Mic.ignoreSays(); // a grammatically incorrect alias
Mic.ignoreYells();
Mic.ignoreScreams();
Mic.ignoreAll(); // alias for ignore screams
</pre>
<p>Hope you like it!</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/primal-screens-mic-as3-output-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UPDATE: Fix: CSS Animation slow or choppy in mobile browsers</title>
		<link>http://chrissilich.com/blog/update-fix-css-animation-slow-or-choppy-in-mobile-browsers/</link>
		<comments>http://chrissilich.com/blog/update-fix-css-animation-slow-or-choppy-in-mobile-browsers/#comments</comments>
		<pubDate>Tue, 20 Sep 2011 12:07:57 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[-webkit-transform]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[choppy]]></category>
		<category><![CDATA[jumpy]]></category>
		<category><![CDATA[like butter]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[slow]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[translate]]></category>
		<category><![CDATA[translate3d]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=311</guid>
		<description><![CDATA[Original post: http://chrissilich.com/blog/fix-css-animation-slow-or-choppy-in-mobile-browsers/ Even better than just adding this code to all the elements you want sped up&#8230; -webkit-transform: translateZ(0); Use -webkit-transform: translate3d() to do all your animations, instead of left, right, top, bottom, margin, or padding properties. -webkit-transform: translate3d(50%, &#8230; <a href="http://chrissilich.com/blog/update-fix-css-animation-slow-or-choppy-in-mobile-browsers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Original post: http://chrissilich.com/blog/fix-css-animation-slow-or-choppy-in-mobile-browsers/</p>
<p>Even better than just adding this code to all the elements you want sped up&#8230;</p>
<pre class="brush:css">
-webkit-transform: translateZ(0);
</pre>
<p>Use -webkit-transform: translate3d() to do all your animations, instead of left, right, top, bottom, margin, or padding properties.</p>
<pre class="brush:css">
-webkit-transform: translate3d(50%, 0, 0);
</pre>
<p>Note that the values in the translate3d parentheses are x, y, z coordinates. Since -webkit-transform uses (yet another*) coordinate system, leaving a value as 0 will leave it unchanged (unless you used -webkit-transform somewhere else already).</p>
<p>Basically, the first example tells the browser to use the GPU to animate the element, which helps a fair bit, but the second code snippet uses the new CSS3 transform algorithms, which are WAY more efficient. The beautiful thing about it is all the modern smart phones use webkit, and therefore support -webkit-transform. My iPhone app now scrolls &#8220;<a href="http://www.cafepress.com/scrollbutter">like butter</a>&#8220;!</p>
<p>*<span style="font-size:10pt;">&#8220;Yet another&#8221; meaning you can move things relative to their point of origin with left/top, margin-left/margin-top, and now -webkit-transform;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/update-fix-css-animation-slow-or-choppy-in-mobile-browsers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Prevent Mobile Safari from zooming in when device rotates</title>
		<link>http://chrissilich.com/blog/prevent-mobile-safari-from-zooming-in-when-device-rotates/</link>
		<comments>http://chrissilich.com/blog/prevent-mobile-safari-from-zooming-in-when-device-rotates/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 18:57:34 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[device-width]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[landscape]]></category>
		<category><![CDATA[meta]]></category>
		<category><![CDATA[portrait]]></category>
		<category><![CDATA[rotate]]></category>
		<category><![CDATA[scale]]></category>
		<category><![CDATA[viewport]]></category>
		<category><![CDATA[zoom]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=309</guid>
		<description><![CDATA[So you&#8217;re making a mobile version of a website and you get it perfectly laid out for iOS handhelds in portrait mode. You&#8217;re using LiveView Screencaster to send your designs to you phone to see how they&#8217;ll look at actual &#8230; <a href="http://chrissilich.com/blog/prevent-mobile-safari-from-zooming-in-when-device-rotates/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;re making a mobile version of a website and you get it perfectly laid out for iOS handhelds in portrait mode. </p>
<p>You&#8217;re using <a href="http://www.zambetti.com/projects/liveview/">LiveView Screencaster</a> to send your designs to you phone to see how they&#8217;ll look at actual size, in your hand. </p>
<p>You&#8217;re using these media queries to make stylesheets for portrait and landscape on iPhone/iPod and iPad.</p>
<pre class="brush:css">
@media screen and (orientation:landscape) {/*landscape mode*/}
@media screen and (device-width: 768px) {/*iPad*/}
@media screen and (device-width: 768px) and (orientation:landscape){
	/*iPad, in landscape mode*/}
</pre>
<p>But you start to notice that your pixel perfect design gets scaled up every time you rotate the device to landscape. It zooms about 1.25x! The fix is in your meta tags, specifically the viewport one:</p>
<pre class="brush:html">
<meta name="viewport" content="width=device-width, initial-scale=1.0,
	maximum-scale=1.0, minimum-scale=1.0">
</pre>
<p>Some people will say, &#8220;why not just use &#8216;user-scalable=false&#8217;,&#8221; and the answer is that the user isn&#8217;t the only thing scaling the viewport. The rotation event does it too. That&#8217;s what we&#8217;re trying to prevent.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/prevent-mobile-safari-from-zooming-in-when-device-rotates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Primal Screen website launch</title>
		<link>http://chrissilich.com/blog/primal-screen-website-launch/</link>
		<comments>http://chrissilich.com/blog/primal-screen-website-launch/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 15:07:37 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[Actionscript/Flash]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[primal]]></category>
		<category><![CDATA[primalscreen]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=306</guid>
		<description><![CDATA[Did I mention that our new website launched? Primal Screen website (100% of code and 75% of design by yours truly). Oh, and I&#8217;ll never write another website in that bloated carcass of a useable PHP framework: Zend Framework. My &#8230; <a href="http://chrissilich.com/blog/primal-screen-website-launch/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Did I mention that our new website launched?</p>
<p><a href="http://www.primalscreen.com" title="Primal Screen website" target="_blank">Primal Screen website</a><br />
(100% of code and 75% of design by yours truly).</p>
<p>Oh, and I&#8217;ll never write another website in that bloated carcass of a useable PHP framework: Zend Framework. My advice: <a href="http://www.codeigniter.com" title="CodeIgniter" target="_blank">CodeIgniter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/primal-screen-website-launch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix: CSS Animation slow or choppy in mobile browsers</title>
		<link>http://chrissilich.com/blog/fix-css-animation-slow-or-choppy-in-mobile-browsers/</link>
		<comments>http://chrissilich.com/blog/fix-css-animation-slow-or-choppy-in-mobile-browsers/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 01:45:41 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[choppy]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jumpy]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[slow]]></category>
		<category><![CDATA[transition]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=304</guid>
		<description><![CDATA[I&#8217;m developing an iPhone app using the PhoneGap library, which lets you write your app as if it were a website. That means any UI transitions or animations have to be written the way you would for any modern website &#8230; <a href="http://chrissilich.com/blog/fix-css-animation-slow-or-choppy-in-mobile-browsers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m developing an iPhone app using the PhoneGap library, which lets you write your app as if it were a website. That means any UI transitions or animations have to be written the way you would for any modern website targeting Webkit: CSS3 transitions (mobile javascript is too slow for frame by frame calculations).</p>
<p>Unfortunately, CSS transitions can be a little slow, a little choppy, even on iPhone 4 and the faster Android based phones. The problem is that, by default, webkit doesn&#8217;t involve the GPU unless you&#8217;re doing 3D transforms. With desktop horsepower, thats fine. On a mobile device, that GPU could really help.</p>
<p>So how do you force webkit to share the processing load with the GPU?</p>
<p>Apply this style to the element you&#8217;re animating:</p>
<pre class="brush:css">
-webkit-transform: translateZ(0);
</pre>
<p>Simple, but effective.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/fix-css-animation-slow-or-choppy-in-mobile-browsers/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Socket.io 0.7 &#8211; Sending messages to individual clients</title>
		<link>http://chrissilich.com/blog/socket-io-0-7-sending-messages-to-individual-clients/</link>
		<comments>http://chrissilich.com/blog/socket-io-0-7-sending-messages-to-individual-clients/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 12:50:23 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Node]]></category>
		<category><![CDATA[PhoneGap]]></category>
		<category><![CDATA[socket.io]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[emit]]></category>
		<category><![CDATA[individual]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[message]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[nodejs]]></category>
		<category><![CDATA[one client]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[socketID]]></category>
		<category><![CDATA[socketio]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=301</guid>
		<description><![CDATA[Note that this is just for Socket.io version 0.7, and possibly higher if they don&#8217;t change the API again. I&#8217;m writing an iPhone app right now using PhoneGap and jQuery Mobile on the phone, and node.js and socket.io on an &#8230; <a href="http://chrissilich.com/blog/socket-io-0-7-sending-messages-to-individual-clients/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Note that this is just for Socket.io version 0.7, and possibly higher if they don&#8217;t change the API again.</p>
<p>I&#8217;m writing an iPhone app right now using PhoneGap and jQuery Mobile on the phone, and node.js and socket.io on an Amazon EC2 server, and I hit a wall when I started using Socket.io. The problem is that the documentation is sparse, disorganized, and hard to find. In addition to that, there are dozens of blog posts and community members who&#8217;ll teach you how to do things in older versions of socket, but the API has changed, so you just end up with <em>undefined</em> errors.</p>
<p>My exact problem was with sending messages to individual clients.</p>
<p>First, you need the client&#8217;s socket ID, so have the user &#8220;check in&#8221; when they connect, and have the server store their socket ID with whatever identifier we&#8217;ll be using to refer to users (in my case, phone number).</p>
<pre class="brush:javascript">
// on the server
var users = {};
io.sockets.on('connection', function (socket) {
	socket.emit('who are you');
	socket.on('check in', function (incoming) {
		users[incoming.phonenumber] = socket.id;
	});
});
</pre>
<pre class="brush:javascript">
// on the client
socket.on('who are you', function (incoming) {
	socket.emit('check in', {phonenumber: savedphonenumber});
});
</pre>
<p>To recap: The server is listening for connections. When a client connects, the server emits the custom message &#8220;who are you&#8221;. The client hears it and responds with it&#8217;s identifier (I&#8217;m using their phone number, which I verify and store earlier in the process). The server then stores the client&#8217;s socket ID in a users object, with their identifier as the key, and the socket ID as the value.</p>
<p>From then on, it&#8217;s a simple case of grabbing the user&#8217;s socket ID from the user&#8217;s table when you need to send them a message, and sending it like this:</p>
<pre class="brush:javascript">
var socketid = users[clientphonenumber];
io.sockets.socket(socketid).emit('for your eyes only');
</pre>
<p>One thing to consider is what happens to that users object if you have thousands of users. It&#8217;ll get pretty bloated, pretty quickly. You need to figure out a strategy for removing users from the users object if they disconnect AND if you don&#8217;t hear from them in a while (in case the disconnect event doesn&#8217;t fire).</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/socket-io-0-7-sending-messages-to-individual-clients/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>CSS z-index doesn&#8217;t do anything, inspector computed style says it&#8217;s z-index:auto</title>
		<link>http://chrissilich.com/blog/css-z-index-doesnt-do-anything-inspector-computed-style-says-its-z-indexauto/</link>
		<comments>http://chrissilich.com/blog/css-z-index-doesnt-do-anything-inspector-computed-style-says-its-z-indexauto/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 16:47:08 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[layers]]></category>
		<category><![CDATA[overlap]]></category>
		<category><![CDATA[positioning]]></category>
		<category><![CDATA[z-index]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=299</guid>
		<description><![CDATA[Today I fought with a stylesheet for a good 15 minutes, wondering why a content element was overlapping a nav element, and why I couldn&#8217;t just give the nav element a higher z-index number. Turns out, z-index is ignored on &#8230; <a href="http://chrissilich.com/blog/css-z-index-doesnt-do-anything-inspector-computed-style-says-its-z-indexauto/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I fought with a stylesheet for a good 15 minutes, wondering why a content element was overlapping a nav element, and why I couldn&#8217;t just give the nav element a higher z-index number. Turns out, z-index is ignored on elements that don&#8217;t have a position style attribute.</p>
<pre class="brush:css">
img {
	z-index: 10000000; /* ignored */
}

img {
	position: relative;
	z-index: 10000000; /* works! */
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/css-z-index-doesnt-do-anything-inspector-computed-style-says-its-z-indexauto/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TypeKit (@font-face) font&#8217;s look like crap in IE7 &amp; IE8 when animated with jQuery</title>
		<link>http://chrissilich.com/blog/typekit-an-font-face-fonts-look-like-crap-in-ie7-ie8-when-animated-with-jquery/</link>
		<comments>http://chrissilich.com/blog/typekit-an-font-face-fonts-look-like-crap-in-ie7-ie8-when-animated-with-jquery/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 15:01:53 +0000</pubDate>
		<dc:creator>Chris Silich</dc:creator>
				<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[@font-face]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[crappy]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[fade]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[opacity]]></category>
		<category><![CDATA[typekit]]></category>

		<guid isPermaLink="false">http://chrissilich.com/blog/?p=296</guid>
		<description><![CDATA[Internet Explorer does a pretty lousy job of displaying fonts anyway, especially fonts from all those new we font websites such as TypeKit (who I strongly recommend). But when you use, say, jQuery&#8217;s fadeIn() effect like this $(".fadeThisGuy").fadeIn(); &#8230; type &#8230; <a href="http://chrissilich.com/blog/typekit-an-font-face-fonts-look-like-crap-in-ie7-ie8-when-animated-with-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Internet Explorer does a pretty lousy job of displaying fonts anyway, especially fonts from all those new we font websites such as TypeKit (who I strongly recommend). But when you use, say, jQuery&#8217;s fadeIn() effect like this</p>
<pre class="brush:javascript">
$(".fadeThisGuy").fadeIn();
</pre>
<p>&#8230; type looks like crap all the way through the animation, and stays that way after.<br />
<a href="http://chrissilich.com/blog/wp-content/uploads/2011/07/Screen-shot-2011-07-16-at-10.41.33-AM.png"><img src="http://chrissilich.com/blog/wp-content/uploads/2011/07/Screen-shot-2011-07-16-at-10.41.33-AM.png" alt="Crappy type after animating" title="Crappy type after animating" width="321" height="48" class="aligncenter size-full wp-image-297" /></a></p>
<p>The reason for this is a bad implementation of &#8220;filters&#8221; in IE. &#8220;What are filters&#8221; you ask? Well while the rest of the web was being standardized to make our lives easier, Microsoft was ignoring the new standards and making up their own, worse looking and harder to write versions. jQuery hides all that from us by turning your fadeIn() into the appropriate filter code in IE, or opacity code in everything else.</p>
<p>There are 3 fixes.<br />
1) Avoid the problem. That means using a non-typekit font, or using an image of the type (which means it won&#8217;t be selectable, and google can&#8217;t see it).</p>
<p>2) Partial fix: At the end of your fadeIn() you can tell IE to drop all filters from the element. This isn&#8217;t great because it means that the type will still look like crap all the way through the animation, and then snap to normal looking (which is still not great in IE) at the end. Code for that below:</p>
<pre class="brush:javascript">
$(".fadeThisGuy").fadeIn(400, function() {
	$(this).css('filter', "");
});
</pre>
<p>3) &#8220;Graceful degradation&#8221;. The buzzword &#8220;graceful degradation,&#8221; refers to the act of checking the capabilities of your visitor&#8217;s browser, and scaling your awesomeness back to fit what their browser can do. They should still get the same website, just without the bells and whistles their browser can&#8217;t handle.</p>
<p>In this case, we&#8217;re checking for IE, and whether it&#8217;s version is < 9.</p>
<pre class="brush:javascript">
if ($.browser.msie &#038;&#038; parseInt($.browser.version) < 9) {
	// dumb it down for old IE 6, 7, and 8
} else {
	// regular awesomeness for people who know how to use Windows Update
}
</pre>
<p>As an alternative to a fadeIn() and fadeOut() I&#8217;d suggest either a simple show() and hide(), or any of the other jQuery Effects that don&#8217;t have to do with opacity/filters. You can find a list of jQuery effects <a href="http://www.jqapi.com" target="_blank">here</a> in the effects section.</p>
]]></content:encoded>
			<wfw:commentRss>http://chrissilich.com/blog/typekit-an-font-face-fonts-look-like-crap-in-ie7-ie8-when-animated-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

