<?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>greenideas &#187; code</title>
	<atom:link href="http://mwhenry.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://mwhenry.com/blog</link>
	<description>A blog by Matt Henry</description>
	<lastBuildDate>Fri, 02 Jul 2010 23:26:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>The Rounded Corners of Tomorrow… Today!</title>
		<link>http://mwhenry.com/blog/2008/10/the-rounded-corners-of-tomorrow-today/</link>
		<comments>http://mwhenry.com/blog/2008/10/the-rounded-corners-of-tomorrow-today/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 04:46:12 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[standards]]></category>
		<category><![CDATA[svg]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=19</guid>
		<description><![CDATA[Hey, you know what can be a real pain in the tail? CSS rounded corners. Of course there are battle-tested, workhorse solutions out there, like sliding doors, or a handful of Javascript-based alternatives. But rounded corners are such a common element of web design and seem like a natural extension of the designer’s existing toolkit [...]]]></description>
			<content:encoded><![CDATA[<p>Hey, you know what can be a real pain in the tail? CSS rounded corners. Of course there are battle-tested, workhorse solutions out there, like <a href="http://www.alistapart.com/articles/slidingdoors/">sliding doors</a>, or a handful of <a href="http://www.curvycorners.net/">Javascript-based</a> alternatives. But rounded corners are such a common element of web design and seem like a natural extension of the designer’s existing toolkit that it only makes sense that there should be a way to implement them with pure CSS. The good news is that <code>border-radius</code> is indeed <a href="http://www.w3.org/TR/css3-background/#border-radius">coming in CSS3</a>. The better news is that you can start using it today, as long as you’re only targeting Gecko &amp; Webkit. Before we get to that though, let’s look at the way it’s supposed to work according to the spec.</p>
<p>As you might expect, the <code>border-radius</code> property is used a lot like <code>border</code>. That is, you can specify one value for each corner (<code>border-radius: 10px;</code>), one value per corner (<code>border-radius: 1px 2px 3px 4px;</code>), or values for opposite corners (<code>border-radius: 5px 10px</code>). It actually gets more complicated, since in addition to describing corners with one radius (i.e. those with semi-circular curves), you can make elliptically rounded corners by naming two radii. For more detail on this, take a look at the draft spec. Lastly, you can use a property for each corner, <code>border-top-left-radius: 2em;</code>, etc. So, assuming there aren’t any major changes in the spec, expect this to be what gets implemented as part of CSS3, and what you’ll ultimately using in your code.</p>
<p>But what about now? Here? Today? It happens that two of the standards-aware, forward-thinking rendering engines have developed proprietary extensions to CSS that should stand in for <code>border-radius</code> until certain <a href="http://www.css3.info/border-radius-apple-vs-mozilla/">ambiguities</a> in the spec can be resolved, and the property is implented according to the standard. So if you want to use <code>border-radius</code> in your code today, you’ll have to use both the Mozilla– and Webkit-specific CSS properties. Fortunately, both of the proprietary extensions work in the current major releases of their respective browsers.</p>
<p>If you’re making a box with four corners of the same radius, the syntax is the same in Mozilla and Webkit:</p>
<pre class="code">-moz-border-radius: 10px; /* 4 corners of radius = 4px*/
-webkit-border-radius: 10px; /* Same as Mozilla */</pre>
<p>To specify different radii for each corner, things diverge somewhat.</p>
<pre class="code">/* Mozilla: */
-moz-border-radius: 1px 2px 3px 4px;
/* Webkit:
    (The four declarations below amount to the
    same thing as the single rule above) */
-webkit-border-top-left-radius: 1px;
-webkit-border-top-right-radius: 2px;
-webkit-border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 4px;</pre>
<p>And that’s the guts of it. So to make a tabbed navigation list, you would use a declaration along the lines of the following (and <a href="examples/borderradius.html">see the below code in action.</a>):</p>
<pre class="code">li {
  border: 1px solid #587402;
  border-bottom: none;
  border-radius: 0 10px 0 10px;
  -moz-border-radius: 10px 10px 0 0;
  -webkit-border-top-left-radius: 10px;
  -webkit-border-top-right-radius: 10px;
  list-style-type: none;
  float: left;
  padding: .5em 1em 0 1em;
}</pre>
<p>There you have it. But there are just a couple of other things I want to point out. If the container you’re rounding the corners of has only text content and a background in it, the background will clip to the rounded corners. And indeed, according to the spec, <em>any</em> the contents of a block-level element on which a border-radius is set should clip do the same as long as you set <code>overflow: hidden</code> on those contents. However, the implementations just aren’t there yet. Instead, with anything over and above plain HTML text (for instance, an <code>img</code> or <code>iframe</code>) inside such a container, the square corners will peek outside of the rounded container. (<a href="examples/borderradius.html#pointy">Example</a>)</p>
<p>One solution would be to make the border thick enough that the corners of the inner element can’t poke through the outer border (<a href="examples/borderradius.html#bigBorder">like so</a>). Though inelegant, this will work just fine if you don’t need everything to round nicely. And this method should suffice for whatever kind of content you’re trying to stuff into your nicely rounded box.</p>
<p>However, if it’s an image you’re putting in the box and you need the inner corners to be rounded as well as the outer corners, then the only answer (for now) is to <a href="examples/borderradius.html#bigBorder">set the image as a background</a>. Still, if the language of the spec is any indication, it won’t always be this way.</p>
<p>For the poor soul who is trying to squeeze iframe content into a rounded corner box, you’re essentially out of luck at the moment. You can certainly use the thick border method I described above, but short of that, you’ll have to look to the bleeding edge. That is to say, you’ll need something which isn’t yet in any production-quality browser, but that is currently in the Webkit nightlies. I speak of the arcane methods of <code>-webkit-mask-image</code>. This property can take a png or an svg as its url, and pretty much anything you apply it to will play nice and clip to the shape of the image. <a href="examples/borderradius.html#map">See for yourself.</a> Still, this last bit is obviously not anything anybody will be using in production code for some time to come.</p>
<p>After reading all of this, if nothing else, I do hope that you’ve come away with a better idea of some of the great things that the CSS working group has in store for you, the developer. But even moreso, hopefully there’s something in all of this mess that you’ll be able to put to use today.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/10/the-rounded-corners-of-tomorrow-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What I’m Reading: 3/24</title>
		<link>http://mwhenry.com/blog/2008/03/what-im-reading-324/</link>
		<comments>http://mwhenry.com/blog/2008/03/what-im-reading-324/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 17:22:42 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[games]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=12</guid>
		<description><![CDATA[Nine Techniques for CSS Image Replacement: If you spend any time at all playing with CSS, you know that there are a full bajillion techniques for replacing text with an image. It’s a lot to remember, and I’ll fess up that I tend to use whatever one I happened to have read about most recently [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li><a href="http://css-tricks.com/nine-techniques-for-css-image-replacement/">Nine Techniques for CSS Image Replacement</a>: If you spend any time at all playing with CSS, you know that there are a full bajillion techniques for replacing text with an image. It’s a lot to remember, and I’ll fess up that I tend to use whatever one I happened to have read about most recently rather than taking a considered approach to which of them might be the best solution for a given situation. No more! The above-linked post does a great job of running through the pros and cons of the 9 (9!) major techniques, and from now on you (meaning “I”) no longer have any excuse to not use the best, semantic, most accessible one at every opportunity.</li>
<li><a href="http://meyerweb.com/eric/thoughts/2008/03/23/drugs-bugs-and-ie8/">Drugs, Bugs, and IE8</a>: A predictably good read from Eric Meyer, but I link to it mainly to have an excuse to echo the following point: There are a lot of beta browsers out there right now (one less, now that Safari 3 has shipped). If you’re testing your sites in them and something renders in any way other than what you were expecting, submit a bug report. <strong>Don’t</strong> change your code.</li>
<li><a href="http://webkit.org/blog/166/optimizing-page-loading-in-web-browser/">Optimizing Page Loading in the Web Browser</a>: For the browser builders, network latency is at least as big a problem as connection speed.</li>
<li><a href="http://www.gamasutra.com/view/feature/3581/a_japanese_rpg_primer_the_.php">A Japanese RPG Primer: The Essential 20</a>: Last week, <a href="http://www.gamasutra.com/" title="Gamasutra">Gamasutra</a> published this list of the best of the best in Japanese RPGs throughout the ages. It’s a top-20, so it’s not exhaustive, but it’s sure as hell exhaust<em>ing</em>–i’ve been chipping away at this beastie since last week. Anyway, if you’re at all into JRPGs, it’s a really fun read. It’s also neat to see some old favorites put into context alongside some seminal games that you may never have been exposed to.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/03/what-im-reading-324/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Front-end Development Link Roundup</title>
		<link>http://mwhenry.com/blog/2008/01/front-end-development-link-roundup/</link>
		<comments>http://mwhenry.com/blog/2008/01/front-end-development-link-roundup/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 15:20:16 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[css javascript]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=7</guid>
		<description><![CDATA[Here are just a few articles that have come out in the last couple of weeks that might be interesting and/or useful to some folks. What CSS Did We Learn in 2007 SEO site Search-This lists the CSS techniques they covered throughout last year. It’s a lot of useful, basic, meat-and-potatoes stuff. 101 CSS Techniques [...]]]></description>
			<content:encoded><![CDATA[<p>Here are just a few articles that have come out in the last couple of weeks that might be interesting and/or useful to some folks.</p>
<ol>
<li><a href="http://www.search-this.com/2008/01/09/what-css-did-we-learn-in-2007/">What CSS Did We Learn in 2007</a><br />
SEO site <a href="http://www.search-this.com/">Search-This</a> lists the CSS techniques they covered throughout last year. It’s a lot of useful, basic, meat-and-potatoes stuff.</li>
<li><a href="http://www.noupe.com/design/101-css-techniques-of-all-time-part-1.html">101 CSS Techniques Of All Time– Part 1</a><br />
Noupe begins a multi-part list of what they find to be the most useful CSS techniques. Again, a lot of great basic stuff for those who may be new to CSS, but it should also be pretty handy as a reference for the grizzled vets out there.</li>
<li><a href="http://ejohn.org/blog/acid3-tackles-ecmascript/">Acid 3 Tackles ECMAScript</a><br />
Resig lays out exactly what Acid 3 is testing. Very interesting, and some nice insight into some edge cases in Javascript</li>
<li><a href="http://www.oreillynet.com/xml/blog/2008/01/thoughts_on_firefox_30.html">Thoughts on Firefox 3.0</a><br />
Nice overview of some of the changes in Firefox 3. He mentions some improvements to the DOM implementation (and links to Mozilla’s more exhaustive list).</li>
<li><a href="http://meyerweb.com/eric/thoughts/2008/01/15/resetting-again/">Resetting Again</a><br />
Eric Meyer once again pushes the state-of-the-art in CSS resets.</li>
<li><a href="http://www.dave-woods.co.uk/?p=143">IE6 — CSS Bugs and Fixes Explained</a><br />
Another nice reference post. Dave Woods looks at a rogues gallery of cross-browser rendering issues.</li>
</ol>
<p>That’s it for now. Hopefully someone will find something useful in here.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/01/front-end-development-link-roundup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stupid Ruby Problem</title>
		<link>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/</link>
		<comments>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 13:44:39 +0000</pubDate>
		<dc:creator>Matt Henry</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mwhenry.com/?p=5</guid>
		<description><![CDATA[Like I said, I’m working on getting my Ruby chops up to snuff. I thought it might be fun to do that by porting all of the code in Joseph Adler’s fantastic Baseball Hacks from Perl to Ruby. I’m coming back to this project after letting it go for a while, and sure enough, the [...]]]></description>
			<content:encoded><![CDATA[<p>Like I said, I’m working on getting my Ruby chops up to snuff. I thought it might be fun to do that by porting all of the code in Joseph Adler’s fantastic <a href="http://books.google.com/books?id=51PS5G2Y2a4C&amp;dq=baseball+hacks&amp;pg=PP1&amp;ots=3YeuWSj5wn&amp;sig=J1V9kEnm1rtM1mD5_6sKtjFVRtQ&amp;hl=en&amp;prev=http://www.google.com/search?q=baseball+hacks&amp;ie=utf-8&amp;oe=utf-8&amp;rls=com.ubuntu:en-US:official&amp;client=firefox-a&amp;sa=X&amp;oi=print&amp;ct=title&amp;cad=one-book-with-thumbnail"><em>Baseball Hacks</em></a> from Perl to Ruby.</p>
<p>I’m coming back to this project after letting it go for a while, and sure enough, the problem I was having when I put it down is still vexing me.</p>
<p>One script is intended to grab all of the play-by-play data from <a href="http://retrosheet.org/">retrosheet.org</a>. The files all have urls like this:</p>
<pre class="code">

http://www.retrosheet.org/1957/1957al.zip

http://www.retrosheet.org/1957/1957nl.zip

http://www.retrosheet.org/1957/1957ml.zip</pre>
<p>The snippet below is a simplified version of the code I’m using to build the urls. It’s intended to print the urls of each zip file for each league from 1957 to  2006:</p>
<pre class="code">
year = 1957
leagues = ['al', 'nl', 'ml']leagues.each do |league|
  while year &lt;= 2006
    url = "http://www.retrosheet.org/#{year}/#{year}#{league}.zip"
    puts url
    year += 1
  end
end</pre>
<p>However, it doesn’t do that. It only generates the urls for the AL files, and I can’t get my brain around why.</p>
<p>I’ll be sure to add the solution when I figure it out, but for now I wanted to just document some of the struggles of a Ruby n00b.</p>
]]></content:encoded>
			<wfw:commentRss>http://mwhenry.com/blog/2008/01/stupid-ruby-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

