<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><description>Front-end development minutiæ</description><title>dropshado.ws</title><generator>Tumblr (3.0; @dropshadows)</generator><link>http://dropshado.ws/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/dropshadows" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="dropshadows" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://tumblr.superfeedr.com/" /><item><title>Refresh button in IE developer tools</title><description>&lt;p&gt;Internet Explorer&amp;#8217;s HTML developer tool will not display changes to the DOM until you click the Refresh button. This goes for newly appended elements, changes to classes, and other changes.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/2cMTKQI.png" alt="Internet Explorer developer tool refresh button"/&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://cdpn.io/Jegfu"&gt;Try out this demo&lt;/a&gt;. New items won&amp;#8217;t appear in the inspector until you refresh.&lt;/p&gt;

&lt;p&gt;Thx to &lt;a href="https://github.com/desandro/masonry/issues/216#issuecomment-15504011"&gt;KillianJK on GitHub&lt;/a&gt; for putting in the due diligence to get to the bottom of this.&lt;/p&gt;</description><link>http://dropshado.ws/post/46430148565</link><guid>http://dropshado.ws/post/46430148565</guid><pubDate>Wed, 27 Mar 2013 13:10:09 -0400</pubDate><category>IE</category><category>hasexample</category></item><item><title>event.target on resize in Opera</title><description>&lt;p&gt;In Opera, on &lt;code&gt;resize&lt;/code&gt;, &lt;code&gt;event.target&lt;/code&gt; is &lt;code&gt;document&lt;/code&gt;, not &lt;code&gt;window&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/desandro/dCug7/"&gt;See fiddle&lt;/a&gt;.&lt;/p&gt;</description><link>http://dropshado.ws/post/46202492495</link><guid>http://dropshado.ws/post/46202492495</guid><pubDate>Sun, 24 Mar 2013 19:08:40 -0400</pubDate><category>Opera</category></item><item><title>touch.identifier = 0</title><description>&lt;p&gt;In the &lt;a href="http://www.w3.org/TR/touch-events/"&gt;touch event API&lt;/a&gt;, each touch object has a unique &lt;code&gt;identifier&lt;/code&gt; property. This allows you to keep track of which touch is which when listening to touch 
events. Try out &lt;a href="http://jsfiddle.net/desandro/WnnG9/8/"&gt;jsfiddle.net/desandro/WnnG9/8/show/light&lt;/a&gt; on a touch device.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;document.body.addEventListener( 'touchstart', function( event ) {
  // dismiss after-touches
  if ( isTouching ) {
    return;
  }
  event.preventDefault();
  // only care about the first touch
  var touch = event.changedTouches[0];
  identifier = touch.identifier;
  log('touch START; indentifer ' + touch.identifier );
  window.addEventListener( 'touchmove', onTouchMove, false );
  window.addEventListener( 'touchend', onTouchEnd, false );
  isTouching = true;
}, false );

function getTouch( event ) {
  // cycle through every change touch and get one that matches
  for ( var i=0, len = event.changedTouches.length; i &amp;lt; len; i++ ) {
    var touch = event.changedTouches[i];
    if ( touch.identifier === identifier ) {
      return touch;
    }
  }
}

function onTouchMove( event ) {
  // get matched touch
  var touch = getTouch( event );
  if ( !touch ) {
    return;
  }
  log( 'touch move ' + touch.pageX + ' ' + touch.pageY );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I ran into a bug because I was short-cutting checking &lt;code&gt;touch.idenfitier&lt;/code&gt;. iOS uses a unique number for each every touch, like &lt;code&gt;166930777&lt;/code&gt;, &lt;code&gt;166930778&lt;/code&gt;, &lt;code&gt;166930779&lt;/code&gt;. It looks like Opera Mobile (and possibly Android) isn&amp;#8217;t as granular with these identifiers, instead using &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt; for each gesture event, then using &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;2&lt;/code&gt; for the next one. &lt;a href="https://github.com/desandro/draggabilly/commit/bd04a337#L1L240"&gt;I ran into a gotcha on that first touch&lt;/a&gt;, when it&amp;#8217;s a falsy value &lt;code&gt;touch.identifier = 0&lt;/code&gt;.&lt;/p&gt;</description><link>http://dropshado.ws/post/45694832906</link><guid>http://dropshado.ws/post/45694832906</guid><pubDate>Mon, 18 Mar 2013 16:33:13 -0400</pubDate><category>mobile</category><category>touch</category></item><item><title>Collapsing margins</title><description>&lt;p&gt;&lt;a href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins"&gt;Collapsing margins&lt;/a&gt; is an ancient property of the CSS Box Model, which I am just now comprehending. In short, with two block elements, will collapse the margins between them collapse to the greater margin. But this only applies to block elements. Floated and inline-block elements will keep margins un-collapsed.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://codepen.io/desandro/pen/rjiAc"&gt;See example on CodePen&lt;/a&gt;.&lt;/p&gt;

&lt;pre class="codepen" data-height="300" data-type="result" data-href="rjiAc" data-user="desandro" data-safe="true"&gt;&lt;code&gt; &lt;/code&gt;&lt;/pre&gt;

&lt;script async="async" src="http://codepen.io/assets/embed/ei.js"&gt; &lt;/script&gt;</description><link>http://dropshado.ws/post/39853759151</link><guid>http://dropshado.ws/post/39853759151</guid><pubDate>Sun, 06 Jan 2013 13:52:26 -0500</pubDate><category>CSS</category><category>hasfiddle</category></item><item><title>Gradient syntax helper</title><description>&lt;p&gt;Modernizr can detect general support for CSS3 gradients. But here&amp;#8217;s a little script to determine the vendor gradient syntax, i.e. &lt;code&gt;-webkit-linear-gradient&lt;/code&gt;, if supported by the browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/desandro/bxMgf/"&gt;jsfiddle.net/desandro/bxMgf/&lt;/a&gt;&lt;/p&gt;

&lt;iframe style="width: 100%; height: 400px" src="http://jsfiddle.net/desandro/bxMgf/embedded/js,result" allowfullscreen="allowfullscreen" frameborder="0"&gt; &lt;/iframe&gt;</description><link>http://dropshado.ws/post/35773506515</link><guid>http://dropshado.ws/post/35773506515</guid><pubDate>Thu, 15 Nov 2012 09:11:31 -0500</pubDate><category>JavaScript</category><category>CSS3</category><category>gradients</category><category>hasfiddle</category></item><item><title>js-beautify npm module</title><description>&lt;a href="https://npmjs.org/package/js-beautify"&gt;js-beautify npm module&lt;/a&gt;: &lt;blockquote&gt;
  &lt;p&gt;all of the code powering &lt;a href="http://jsbeautifier.org/"&gt;jsbeautifier.org&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Utility module for beautifying JS.&lt;/p&gt;</description><link>http://dropshado.ws/post/34703722501</link><guid>http://dropshado.ws/post/34703722501</guid><pubDate>Wed, 31 Oct 2012 11:23:40 -0400</pubDate><category>node</category><category>npm</category><category>JavaScript</category></item><item><title>Felix's Node.js Style Guide</title><description>&lt;a href="http://nodeguide.com/style.html"&gt;Felix's Node.js Style Guide&lt;/a&gt;: &lt;p&gt;via &lt;a href="http://jsforcats.com/"&gt;JavaScript for Cats&lt;/a&gt;&lt;/p&gt;</description><link>http://dropshado.ws/post/34119052034</link><guid>http://dropshado.ws/post/34119052034</guid><pubDate>Mon, 22 Oct 2012 17:27:32 -0400</pubDate><category>node</category><category>JavaScript</category><category>style guide</category></item><item><title>Get random letter</title><description>&lt;p&gt;Here&amp;#8217;s a helper function that uses &lt;a href="http://en.wikipedia.org/wiki/Base_36"&gt;base 36&lt;/a&gt; numeral system to return a random letter &lt;em&gt;a&lt;/em&gt; to &lt;em&gt;z&lt;/em&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function getRandomLetter() {
  var rand26 = Math.floor( Math.random() * 26 );
  return ( ( 10 + rand26 ) / 36 ).toString(36).substring(2);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/desandro/u2WgV/embedded/result,js" allowfullscreen="allowfullscreen" frameborder="0"&gt; &lt;/iframe&gt;</description><link>http://dropshado.ws/post/33612371490</link><guid>http://dropshado.ws/post/33612371490</guid><pubDate>Sun, 14 Oct 2012 21:47:08 -0400</pubDate><category>JavaScript</category><category>js</category><category>hasfiddle</category></item><item><title>Animating max-height to overcome height:auto limitation</title><description>&lt;a href="http://jsfiddle.net/leaverou/zwvNY/"&gt;Animating max-height to overcome height:auto limitation&lt;/a&gt;: &lt;blockquote class="twitter-tweet"&gt;&lt;p&gt;(this is probably not new, but just in case…) Q: How to transition to height:auto? A: Transition max-height instead! &lt;a href="http://t.co/48N05bg" title="http://jsfiddle.net/leaverou/zwvNY/"&gt;jsfiddle.net/leaverou/zwvNY/&lt;/a&gt;&lt;/p&gt;— Lea Verou (@LeaVerou) &lt;a href="https://twitter.com/LeaVerou/status/69776299685715970" data-datetime="2011-05-15T14:49:00+00:00"&gt;May 15, 2011&lt;/a&gt;&lt;/blockquote&gt;

&lt;script src="//platform.twitter.com/widgets.js"&gt; &lt;/script&gt;&lt;iframe style="width: 100%; height: 260px" src="http://jsfiddle.net/leaverou/zwvNY/embedded/result,css,html" allowfullscreen="allowfullscreen" frameborder="0"&gt; &lt;/iframe&gt;

&lt;p&gt;via &lt;a href="http://codepen.io/bradfrost/full/qwJvF"&gt;Brad Frost&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This technique is insanely badass. I use it for all my height-animating needs, including accordions.&lt;/p&gt;
&lt;/blockquote&gt;</description><link>http://dropshado.ws/post/32280391206</link><guid>http://dropshado.ws/post/32280391206</guid><pubDate>Tue, 25 Sep 2012 16:46:30 -0400</pubDate><category>CSS</category><category>transitions</category><category>Lea Verou</category><category>Brad Frost</category><category>hasfiddle</category></item><item><title>.command files can be double-clicked</title><description>&lt;p&gt;From Chris Page on &lt;a href="http://stackoverflow.com/a/9650209/182183"&gt;Stack Overflow: How do I make this file.sh executable via double click?&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;By default, *.sh files are opened in a text editor (Xcode or TextEdit). To create a shell script that will execute in Terminal when you open it, name it with the “command” extension, e.g., file.command. By default, these are sent to Terminal, which will execute the file as a shell script.&lt;/p&gt;
  
  &lt;p&gt;You will also need to ensure the file is executable, e.g.:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;chmod +x file.command
&lt;/code&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Works also for &lt;a href="http://apple.stackexchange.com/a/25261"&gt;&lt;code&gt;.tool&lt;/code&gt; files&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Combine this with &lt;a href="http://hints.macworld.com/article.php?story=20041217111834902"&gt;Allow .command files to determine working directory - Mac OS X Hints&lt;/a&gt; (from &amp;#8216;04) and you have a low-level interface to allow non-technical colleagues run command line scripts.&lt;/p&gt;

&lt;p&gt;The command line is a great and powerful tool for any capable developer, but to most non-technical users and colleagues, it is an uncomforting, alien black box. Ideally, any set of directions meant for everybody on your team should never include &amp;#8220;open up Terminal.&amp;#8221; &lt;code&gt;.command&lt;/code&gt; files provide a mechanism to bridge this gap.&lt;/p&gt;

&lt;hr&gt;&lt;p&gt;In the couple years that dropshado.ws has been dropping shadows, this is one of my favorite finds.&lt;/p&gt;

&lt;ol&gt;&lt;li&gt;It&amp;#8217;s way old.&lt;/li&gt;
&lt;li&gt;It&amp;#8217;s a bridge between the command line and the GUI.&lt;/li&gt;
&lt;/ol&gt;</description><link>http://dropshado.ws/post/31703650180</link><guid>http://dropshado.ws/post/31703650180</guid><pubDate>Sun, 16 Sep 2012 21:53:09 -0400</pubDate><category>bash</category><category>command line</category><category>OS X</category></item><item><title>GitHub Styleguide</title><description>&lt;a href="https://github.com/styleguide"&gt;GitHub Styleguide&lt;/a&gt;</description><link>http://dropshado.ws/post/27981455072</link><guid>http://dropshado.ws/post/27981455072</guid><pubDate>Wed, 25 Jul 2012 10:18:26 -0400</pubDate><category>github</category><category>style guide</category></item><item><title>Pretty git log</title><description>&lt;p&gt;&lt;a href="http://tjholowaychuk.com/post/26904939933/git-extras-introduction-screencast"&gt;TJ Holowaychuk featured a pretty git log alias&lt;/a&gt;, taking advantage of &lt;a href="http://git-scm.com/docs/git-log#_commit_formatting"&gt;&lt;code&gt;git log --pretty&lt;/code&gt;&lt;/a&gt;. I am now rocking:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias glog="git log --format='%Cgreen%h%Creset %C(cyan)%an%Creset - %s' --graph"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/SZyNd.png" alt="git log --pretty"/&gt;&lt;/p&gt;</description><link>http://dropshado.ws/post/27506212928</link><guid>http://dropshado.ws/post/27506212928</guid><pubDate>Wed, 18 Jul 2012 17:17:35 -0400</pubDate><category>git</category><category>TJ Holowaychuk</category></item><item><title>YAML Front Matter syntax highlighting in TextMate</title><description>&lt;p&gt;&lt;em&gt;Aside:&lt;/em&gt; Right now I&amp;#8217;m a train with spotty Wifi. Hence, lots of time for noodling rather than actual productivity.&lt;/p&gt;

&lt;p&gt;If you like that &lt;a href="https://github.com/mojombo/jekyll"&gt;Jekyll&lt;/a&gt; as much as I do, chances are you&amp;#8217;ve got lots and lots of wonderful Markdown files loaded with &lt;a href="https://github.com/mojombo/jekyll/wiki/YAML-Front-Matter"&gt;YAML Front Matter&lt;/a&gt;. I use Jekyll for everything, lo, even this very post! Let&amp;#8217;s get TextMate&amp;#8217;s Markdown Language Grammer to properly highlight the YAML up top.&lt;/p&gt;

&lt;p&gt;Crack open the Bundle Editor (Cmd + Opt + Ctrl + B) and select the Markdown Language Grammer. In TextMate 2, this is in  Markdown &amp;gt; Language Grammers &amp;gt; Markdown. You&amp;#8217;ll need to add two bits.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;block&lt;/code&gt;, er, block, add &lt;code&gt;{ include = '#yaml_front_matter'; },&lt;/code&gt; to the &lt;code&gt;patterns&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;block = {
  patterns = (
    { include = '#yaml_front_matter'; },
    { include = '#separator'; },
    { include = '#heading'; },
    ...
  );
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then add the following pattern for &lt;code&gt;yaml_front_matter&lt;/code&gt; under the &lt;code&gt;block&lt;/code&gt; repository. I just added it after &lt;code&gt;separator&lt;/code&gt; pattern.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;separator = {
  match = '(^|\G)[ ]{,3}([-*_])([ ]{,2}\2){2,}[ \t]*$\n?';
  name = 'meta.separator.markdown';
};
# add this next bit
yaml_front_matter = {
  patterns = (
    { begin = '\G---';
      end = '^---';
      name = 'source.yaml.embedded.markdown';
      patterns = ( { include = 'source.yaml'; } );
    },
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Boom. Now my Jekyll Markdown files look niiiiiiiiiice.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/vyYAK.png" alt="YAML Front Matter"/&gt;&lt;/p&gt;</description><link>http://dropshado.ws/post/27450570083</link><guid>http://dropshado.ws/post/27450570083</guid><pubDate>Tue, 17 Jul 2012 21:52:07 -0400</pubDate><category>YAML</category><category>Markdown</category><category>TextMate</category><category>syntax highlighting</category><category>Jekyll</category></item><item><title>GitHub code blocks in TextMate</title><description>&lt;p&gt;&lt;a href="https://github.com/blog/832-rolling-out-the-redcarpet"&gt;GitHub README&amp;#8217;s feature nice syntax highlighted code blocks&lt;/a&gt; with the triple tick notation.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;``` css
body { font-family: sans-serif; }
```
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But as this syntax is a part of &lt;a href="http://github.github.com/github-flavored-markdown/"&gt;GitHub Flavored Markdown&lt;/a&gt; and not the vanilla Markdown variety, TextMate does not recognize triple ticked code blocks, which can lead to ugly sections of the document. Take this example from &lt;a href="https://github.com/desandro/textmate-bundles/blob/master/README.mdown"&gt;desandro/textmate-bundle/README.mdown&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/8ykWk.png" alt="README with Redcarpet code block"/&gt;&lt;/p&gt;

&lt;p&gt;I resolved this by modifying TextMate&amp;#8217;s Markdown Language Grammer, adding in the triple tick pattern for &lt;code&gt;raw_block&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;raw_block = {
  patterns = (
    { begin = '(^|\G)([ ]{4}|\t)';
      name = 'markup.raw.block.markdown';
      while = '(^|\G)([ ]{4}|\t)';
    },
    { begin = '(^|\G)```';
      end = '(^|\G)```';
      name = 'markup.raw.block.markdown';
    },
  );
};
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Bingo.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/RWAGz.png" alt="README with Redcarpet code block syntax highlighted"/&gt;&lt;/p&gt;</description><link>http://dropshado.ws/post/27450475671</link><guid>http://dropshado.ws/post/27450475671</guid><pubDate>Tue, 17 Jul 2012 21:50:44 -0400</pubDate><category>Markdown</category><category>Textmate</category><category>syntax highlighting</category></item><item><title>TextMate commands with node</title><description>&lt;p&gt;&lt;a href="http://manual.macromates.com/en/commands"&gt;TextMate commands&lt;/a&gt; are the scripts that run every time you do some special key command, for example, Ctrl + Shift + W to wrap text in an HTML tag. Commands aren&amp;#8217;t just baked-in magic, each one is an editable script. This allows you to write your own. This is awesome.&lt;/p&gt;

&lt;p&gt;Personally, I&amp;#8217;m not familiar with bash or Ruby, which means the code behind any command is just as good as a magic spell. But through the wonder of node, I&amp;#8217;m able to develop my own TextMate commands that I actually comprehend.&lt;/p&gt;

&lt;p&gt;I had a project where I had to add links to any reference of a U.S. state, a perfect use-case for a custom command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# before
Pennsylvania and Rhode Island
# after
[Pennsylvania](../pennsylvania/) and [Rhode Island](../rhode-island/)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;node will need to be on your $PATH for TextMate.&lt;/p&gt;

&lt;p&gt;First check that node is in your $PATH. On my machine, I have in &lt;code&gt;~/.bash_profile&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;PATH=$PATH:~/bin:~/.gem/ruby/1.8/bin:/usr/local/bin/node
export PATH
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To check it&amp;#8217;s in there, from Terminal:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;echo $PATH
# /usr/bin:/bin: ... /usr/local/bin/node
# /usr/local/bin/node or something similiar should appear in there
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or you can just add it in Preferences &amp;gt; Advanced &amp;gt; Shell &lt;a href="https://twitter.com/rodneyrehm/status/212948905996980225"&gt;(thx @rodneyrehmm)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This will allow the script to be run in node. For this script, I am using &lt;a href="http://nodejs.org/api/process.html#process_process_stdin"&gt;process.stdin&lt;/a&gt;, which takes the selected in. Of course, node does this in chunks or something and there&amp;#8217;s a good reason for it, that &lt;a href="http://twitter/jfsiii"&gt;John&lt;/a&gt; could elaborate on. But what I do know is that this works.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env node

process.stdin.resume();

var str = '';

process.stdin.on( 'data', function ( chunk ) {
  str += chunk;
});

process.stdin.on( 'end', function () {
  // convert selected text to lowercase, then convert spaces to dashes
  var link = str.toLowerCase().replace( ' ', '-' );
  // format link
  var output = '[' + str + '](../' + link +'/)';
  process.stdout.write( output );
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My Bundle options for the command look something this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/S8MpM.png" alt="TextMate bundle options"/&gt;&lt;/p&gt;

&lt;p&gt;I hit Cmd + A around my selected text and it does the proper conversion. Nice! Now I can make TextMate commands at will.&lt;/p&gt;</description><link>http://dropshado.ws/post/25022667597</link><guid>http://dropshado.ws/post/25022667597</guid><pubDate>Wed, 13 Jun 2012 10:41:00 -0400</pubDate><category>node</category><category>Textmate</category></item><item><title>Iterate over hashes in liquid templates - Stack Overflow</title><description>&lt;a href="http://stackoverflow.com/a/8303885/182183"&gt;Iterate over hashes in liquid templates - Stack Overflow&lt;/a&gt;: &lt;blockquote&gt;&lt;p&gt;When you iterate over a hash using a variable called &lt;code&gt;hash&lt;/code&gt;, &lt;code&gt;hash[0]&lt;/code&gt; contains the key and &lt;code&gt;hash[1]&lt;/code&gt; contains the value on each iteration.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{% for link_hash in page.links %}
  {% for link in link_hash %}
    &lt;a href="http://%7B%7B%20link%5B1%5D%20%7D%7D"&gt;{{ link[0] }}&lt;/a&gt;
  {% endfor %}
{% endfor %}&lt;/code&gt;&lt;/pre&gt;&lt;/blockquote&gt;</description><link>http://dropshado.ws/post/24008029812</link><guid>http://dropshado.ws/post/24008029812</guid><pubDate>Tue, 29 May 2012 14:49:42 -0400</pubDate><category>Stack Overflow</category><category>Liquid</category></item><item><title>NaN messes with sorting</title><description>&lt;p&gt;I&amp;#8217;m building some dynamic table sorting. Looks like &lt;code&gt;NaN&lt;/code&gt; values are messing with the sorting. For the sake of the example, let&amp;#8217;s use an array of number-like strings. Try pasting this in your console.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(function() {
  var numbers = '19 26 63 twelve 83 106 hundred zero 12'.split(' ');
  return numbers.sort();
})();
// ["106", "12", "19", "26", "63", "83", "hundred", "twelve", "zero"]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The resulting array is as expected, since the values are still strings.&lt;/p&gt;

&lt;p&gt;Let&amp;#8217;s parse those values as integers, using a compare function in &lt;a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/sort"&gt;sort&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(function() {
  var numbers = '19 26 63 twelve 83 106 hundred zero 12'.split(' ');
  function parse( value ) {
    return parseInt( value );
  }
  return numbers.sort( function( a, b ) {
    return parse( a ) &amp;lt; parse( b );
  });
})();
// ["63", "26", "19", "twelve", "106", "83", "hundred", "zero", "12"]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This looks just random. I believe what&amp;#8217;s happening is how a &lt;code&gt;NaN&lt;/code&gt; value from &lt;code&gt;parseInt('foo')&lt;/code&gt; messes with the comparison. Comparing any number with &lt;code&gt;NaN&lt;/code&gt; will return &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;14 &amp;gt; NaN
// false
NaN &amp;gt; 14
// false
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Oh JavaScript, &lt;a href="http://wtfjs.com/"&gt;you so cray&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;My solution is to account for &lt;code&gt;NaN&lt;/code&gt; in the parser.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;(function() {
  var numbers = '19 26 63 twelve 83 106 hundred zero 12'.split(' ');
  function parse( value ) {
    value = parseInt( value );
    value = isNaN( value ) ? Infinity : value;
    return value;
  }
  return numbers.sort( function( a, b ) {
    return parse( a ) &amp;gt; parse( b );
  });
})();
// ["12", "19", "26", "63", "83", "106", "twelve", "hundred", "zero"]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You don&amp;#8217;t have to munge &lt;code&gt;NaN&lt;/code&gt; as &lt;code&gt;Infinity&lt;/code&gt;, but this at least treats the value as a number that can be properly compared.&lt;/p&gt;</description><link>http://dropshado.ws/post/23546185783</link><guid>http://dropshado.ws/post/23546185783</guid><pubDate>Tue, 22 May 2012 11:21:57 -0400</pubDate><category>javascript</category><category>js</category></item><item><title>Sequel Pro</title><description>&lt;a href="http://www.sequelpro.com/"&gt;Sequel Pro&lt;/a&gt;: &lt;p&gt;Nice SQL database management app.&lt;/p&gt;</description><link>http://dropshado.ws/post/20778512805</link><guid>http://dropshado.ws/post/20778512805</guid><pubDate>Mon, 09 Apr 2012 10:22:24 -0400</pubDate><category>SQL</category><category>app</category></item><item><title>Chrome Developer Tools settings</title><description>&lt;p&gt;Via &lt;a href="http://twitter.com/jfsiii"&gt;JFSIII&lt;/a&gt;, Chrome&amp;#8217;s Developer Tools has some useful options hidden in its settings panel. All this time, it has been hiding as that little cog icon in the bottom right.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/JOomh.png" alt="Chrome developer tools settings icon"/&gt;&lt;/p&gt;

&lt;p&gt;Personal favorites include &lt;strong&gt;Disable cache&lt;/strong&gt;, &lt;strong&gt;Text Editor indent&lt;/strong&gt;, &lt;strong&gt;Dock to right&lt;/strong&gt; which is ideal for mobile-sized media-query development.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://i.imgur.com/yLSRE.png" alt="Chrome developer tools settings"/&gt;&lt;/p&gt;</description><link>http://dropshado.ws/post/20349545288</link><guid>http://dropshado.ws/post/20349545288</guid><pubDate>Mon, 02 Apr 2012 10:40:07 -0400</pubDate><category>Chrome</category><category>John Schulz</category></item><item><title>Git submodules</title><description>&lt;p&gt;I think I&amp;#8217;m ready to discuss &lt;a href="http://book.git-scm.com/5_submodules.html"&gt;Git submodules&lt;/a&gt;. My chronic problem with submodules is that I don&amp;#8217;t use them often enough to understand how they work. From what I gather, you can do a lot more than what I&amp;#8217;ll cover, but I&amp;#8217;m only interested in just placing a repo in a repo.&lt;/p&gt;

&lt;p&gt;The benefit of submodules is that you can reduce duplicate code. Instead of copying files from one repo into another, Git can manage this for you. nclud.com v3 currently has 6 submodules. These are helpful for pulling changes to external repos &amp;#8212; in our case &lt;a href="https://github.com/louisremi/jquery-smartresize"&gt;jquery-smartresize&lt;/a&gt; and &lt;a href="https://github.com/malsup/form"&gt;jquery.form.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been breaking out re-useable bits of code into smaller repos and gists. So I&amp;#8217;ve got this &lt;a href="https://gist.github.com/1866474"&gt;requestAnimationFrame polyfill&lt;/a&gt;, and I want to include it in another project, &lt;a href="https://github.com/nclud/inflickity"&gt;Inflickity&lt;/a&gt;. This can be done with two &lt;code&gt;git submodule&lt;/code&gt; commands:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git submodule add git://gist.github.com/1866474.git request-animation-frame
git submodule update --init
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will add the submodule, then pull in the appropriate commit. I&amp;#8217;ll be able to use &lt;code&gt;request-animation-frame/requestanimationframe.js&lt;/code&gt; in the &lt;a href="http://nclud.github.com/inflickity/"&gt;Inflickity demo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Both those commands trigger a change in the repo, changing &lt;code&gt;.gitmodules&lt;/code&gt; and reference to the submodule repository.  This change will require a commit.&lt;/p&gt;

&lt;p&gt;If anyone else clones the repo, they&amp;#8217;ll have to update and init the submodules as well.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone &lt;a href="https://github.com/nclud/inflickity.git"&gt;https://github.com/nclud/inflickity.git&lt;/a&gt;
cd inflickity
git submodule update --init
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;EDIT&lt;/strong&gt; Or better yet, &lt;a href="http://stackoverflow.com/questions/3796927/git-clone-submodule/4438292#4438292"&gt;clone the repo and pull in submodules with &lt;code&gt;git clone --recursive&lt;/code&gt;&lt;/a&gt; (thx &lt;a href="https://twitter.com/mathias/status/184969937364844544"&gt;Mathias&lt;/a&gt;):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone --recursive &lt;a href="https://github.com/nclud/inflickity.git"&gt;https://github.com/nclud/inflickity.git&lt;/a&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, the crazy-pants part. Per the &lt;a href="http://schacon.github.com/git/git-submodule.html"&gt;Git reference&lt;/a&gt;, &lt;code&gt;git submodule update&lt;/code&gt;&amp;#8230;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;will make the submodules HEAD be detached&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I think this is where I usually lose control of what was happening with my submodules. The submodule&amp;#8217;s repository has checked out the specific commit, and is not on the master branch as I would have expected. For example, let&amp;#8217;s try cloning the Inflickity repo and getting that submodule working.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/projects $ git clone &lt;a href="https://github.com/nclud/inflickity.git"&gt;https://github.com/nclud/inflickity.git&lt;/a&gt;
Cloning into inflickity...
...
Unpacking objects: 100% (87/87), done.
~/projects $ cd inflickity
~/projects/inflickity $ git submodule update --init
Submodule 'request-animation-frame' (git://gist.github.com/1866474.git) registered for path 'request-animation-frame'
Cloning into request-animation-frame...
...
Submodule path 'request-animation-frame': checked out 'db50266cd98d2d46277fd54d24cfd37766476a00'
~/projects/inflickity $ ls request-animation-frame/
requestanimationframe.js
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Great, so the contents of the submodule are there. But what happens if we check the status of that submodule repository:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/projects/inflickity $ cd request-animation-frame/
~/projects/inflickity/request-animation-frame $ git status
# Not currently on any branch.
nothing to commit (working directory clean)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Not on any branch. Darnit. This will prevent the basic &lt;code&gt;git pull&lt;/code&gt; from working, so you&amp;#8217;ll have to specify remote and branch.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/projects/inflickity/request-animation-frame $ git pull origin master
From git://gist.github.com/1866474
 * branch            master     -&amp;gt; FETCH_HEAD
Already up-to-date.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;code&gt;git submodule foreach&lt;/code&gt; allows you to run a shell command for each submodule, which is ideal for pulling all submodules.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/projects/inflickity $ git submodule foreach 'git pull origin master'
Entering 'request-animation-frame'
From git://gist.github.com/1866474
 * branch            master     -&amp;gt; FETCH_HEAD
Already up-to-date.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Just like when adding submodules, if there are any new commits that were pulled for a submodule, you&amp;#8217;ll need to track that change in a commit for the parent repository.&lt;/p&gt;

&lt;p&gt;In review, my three go-to git submodule commands are:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# starts it off
git submodule update --init
# for anyone else cloning
git clone --recursive my-repo.git
# pull in any fresh commits
git submodule foreach 'git pull origin master'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This keeps me in the parent repo, and I don&amp;#8217;t get confused popping in and out of submodules repo.&lt;/p&gt;</description><link>http://dropshado.ws/post/20058825150</link><guid>http://dropshado.ws/post/20058825150</guid><pubDate>Wed, 28 Mar 2012 07:36:00 -0400</pubDate><category>git</category><category>Mathias Bynens</category></item></channel></rss>
