<?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>Marc Neuwirth&#039;s Blog</title> <atom:link href="http://marcneuwirth.com/feed/" rel="self" type="application/rss+xml" /><link>http://marcneuwirth.com</link> <description>Random crumbs of programming knowledge</description> <lastBuildDate>Tue, 02 Oct 2012 03:02:41 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item><title>Creating the Earth with D3.js</title><link>http://marcneuwirth.com/blog/2012/06/24/creating-the-earth-with-d3-js/</link> <comments>http://marcneuwirth.com/blog/2012/06/24/creating-the-earth-with-d3-js/#comments</comments> <pubDate>Sun, 24 Jun 2012 15:41:21 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[D3.js]]></category> <category><![CDATA[JavaScript]]></category> <category><![CDATA[SVG]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=477</guid> <description><![CDATA[There is no way around it, creating data visualizations with D3 is just plain fun. Lately, I have especially enjoyed building map visualizations, but I hadn&#8217;t figured out an excuse to use the azimuthal projection on a project. I still haven&#8217;t, but &#8230; <a
href="http://marcneuwirth.com/blog/2012/06/24/creating-the-earth-with-d3-js/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>There is no way around it, creating data visualizations with <a
title="D3.js" href="http://d3js.org">D3</a> is just plain fun. Lately, I have especially enjoyed building map visualizations, but I hadn&#8217;t figured out an excuse to use the azimuthal projection on a project.<br
/> <span
id="more-477"></span><br
/> I still haven&#8217;t, but this Earth is pretty cool looking:</p><div
class="wp-caption experiment-caption"><iframe
marginwidth="0" marginheight="0" scrolling="no" class="experiment-frame" src="http://marcneuwirth.com/experiments/globe/" width="960" height="500"></iframe><p
class="wp-caption-text">Click and drag to pan, use scroll wheel to zoom <a
href="http://marcneuwirth.com/experiments/globe/" target="_blank">Fullscreen</a></p></div><p>There are really three parts working here:</p><ol><li>The actual map, which is an orthographic azimuthal projection of the countries of the world onto the outside of a sphere.</li><li>The stars and outer space, which is a equidistant azimuthal projection onto the inside of a larger sphere</li><li>A giant circle with the same diameter as the map sphere for background gradient and a Gaussian blur (SVG Filter)</li></ol><p><strong>Map</strong></p><p>The map itself is pretty simple, each country is a <a
href="http://www.geojson.org/geojson-spec.html">GeoJSON</a> &#8216;feature&#8217; polygon which is just a list of lat/lon points that form the borders of the country:</p><pre class="brush: jscript; title: ; notranslate">
{
  &quot;type&quot;:&quot;Feature&quot;,
  &quot;properties&quot;:{
    &quot;name&quot;:&quot;Cyprus&quot;
  },
  &quot;geometry&quot;:{
    &quot;type&quot;:&quot;Polygon&quot;,
    &quot;coordinates&quot;:[
      [
        [33.973617,35.058506],
        [34.004881,34.978098],
        [32.979827,34.571869],
        [32.490296,34.701655],
        [32.256667,35.103232],
        [32.73178,35.140026],
        [32.919572,35.087833],
        [33.190977,35.173125],
        [33.383833,35.162712],
        [33.455922,35.101424],
        [33.475817,35.000345],
        [33.525685,35.038688],
        [33.675392,35.017863],
        [33.86644,35.093595],
        [33.973617,35.058506]
      ]
    ]
  },
  &quot;id&quot;:&quot;CYP&quot;
}
</pre><p>Each country is mapped to a spot on the page according to the projection, and the paths are clipped so that only the ones on the visible side of the sphere are shown.</p><p><strong>Stars</strong></p><p>Outer space is the inside of a sphere that is three times the size of the Earth itself. It is also another map projection, but instead of countries, there are 300 randomly placed points of varying sizes. These points are supposed to look like stars and create the backdrop for the Earth.</p><p><strong>Polish</strong></p><p>In order to make this look more like the Earth, there is a single SVG circle element behind all of the map data. The circle uses a SVG linearGradient and filter for a little bit of a 3D spherical look and the fuzzily defined edge caused by the atmosphere.</p><pre class="brush: xml; title: ; notranslate">
&lt;svg id=&quot;defs&quot;&gt;
    &lt;defs&gt;
        &lt;linearGradient id=&quot;gradBlue&quot; x1=&quot;0%&quot; y1=&quot;0%&quot; x2=&quot;100%&quot; y2=&quot;0%&quot;&gt;
            &lt;stop offset=&quot;0%&quot; style=&quot;stop-color:#005C99;stop-opacity:1&quot; /&gt;
            &lt;stop offset=&quot;100%&quot; style=&quot;stop-color:#0099FF;stop-opacity:1&quot; /&gt;
        &lt;/linearGradient&gt;
        &lt;filter id=&quot;glow&quot;&gt;
            &lt;feColorMatrix type=&quot;matrix&quot;
                values=
                &quot;0 0 0 0   0
                 0 0 0 0.9 0
                 0 0 0 0.9 0
                 0 0 0 1   0&quot;/&gt;
            &lt;feGaussianBlur stdDeviation=&quot;5.5&quot; result=&quot;coloredBlur&quot;/&gt;
            &lt;feMerge&gt;
                &lt;feMergeNode in=&quot;coloredBlur&quot;/&gt;
                &lt;feMergeNode in=&quot;SourceGraphic&quot;/&gt;
            &lt;/feMerge&gt;
        &lt;/filter&gt;
    &lt;/defs&gt;
&lt;/svg&gt;
</pre><p><strong>Moving Around</strong></p><p>D3 makes panning and zooming pretty easy to figure out with maps, however it is mostly tuned for the more often used projections like Albers and Mercator, which use the translate property instead of the origin to control the focal point. That works great for those projections because it allows the scrollwheel to zoom in on the mouse pointer as it does in Google Maps.</p><p>Unfortunately, that paradigm doesn&#8217;t work as well for this azimuthal projection, so we need to detach the pan and zoom events from affecting each other. This isn&#8217;t currently an option in D3, so I have a <a
href="https://github.com/mbostock/d3/pull/616" title="GitHub Pull Request">pull request</a> with a fix that will hopefully be merged soon. Until then, I am using a <a
href="/experiments/globe/d3.custom.js/">custom version</a> with my change already merged.</p><p>Now that panning and zooming are separated, the <code>move</code> function will calculate the origin and scale based on the mouse event and change the projections for the map and outer space accordingly. Then, the map will be redrawn using the new projections. This creates a smooth experience that allows your to pan and zoom around the Earth.</p><p>Feel free to play with the demo above and look through the code below or fork it on <a
href="https://gist.github.com/2865882" title="GitHub">GitHub</a>.</p> <script src="https://gist.github.com/2865882.js"></script> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2012/06/24/creating-the-earth-with-d3-js/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>Solving Problems Subscribing to Facebook Real-time Updates</title><link>http://marcneuwirth.com/blog/2011/12/08/facebook-real-time-updates/</link> <comments>http://marcneuwirth.com/blog/2011/12/08/facebook-real-time-updates/#comments</comments> <pubDate>Thu, 08 Dec 2011 06:11:43 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[Facebook]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=407</guid> <description><![CDATA[Facebook&#8217;s Real-time Updates documentation is not very explicit on how to subscribe to a feed, especially when all I am looking for is an example. So after figuring out what OAuthException (#15) "This method must be called with an app &#8230; <a
href="http://marcneuwirth.com/blog/2011/12/08/facebook-real-time-updates/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><img
class="alignright size-medium wp-image-413" title="facebook_platform" src="http://marcneuwirth.com/wp-content/uploads/2011/12/facebook_platform-300x300.jpg" alt="" width="300" height="300" />Facebook&#8217;s Real-time Updates <a
title="Real-time Updates documentation" href="https://developers.facebook.com/docs/reference/api/realtime/">documentation</a> is not very explicit on how to subscribe to a feed, especially when all I am looking for is an example. So after figuring out what <code>OAuthException (#15) "This method must be called with an app access_token"</code> was trying to tell me and fixing the problem, I figured I would share my PHP example here. Hopefully, it will be helpful to you.<strong>*</strong> There are two parts that you need to set up:</p><ol><li><a
href="#bullet-1">Setup an endpoint for the subscription</a></li><li><a
href="#bullet-2">Post to Facebook and tell them you are subscribing</a></li><ol><li><a
href="#bullet-2A">Get an <code>access_token</code></a></li><li><a
href="#bullet-2B">POST to Facebook with cURL</a></li></ol></ol><p><span
id="more-407"></span></p><h1 id="bullet-1">1. Setup an Endpoint</h1><p>This part is actually pretty easy because Facebook actually gives you <a
title="sample subscription endpoint" href="https://github.com/facebook/real-time/blob/master/samples/php/callback.php">example</a> code (yay!). Put that file on a web server somewhere with an external ip so that Facebook can reach it. Replace <code>'abc'</code> in <code>define('VERIFY_TOKEN', 'abc');</code>. Save this value for later.</p><h1 id="bullet-2">2. Post to Facebook</h1><p>Now comes the part that is not well documented. In order to subscribe you need to first specifically get an <code>access_token</code>, then POST to Facebook.</p><h2 id="bullet-2A" style="padding-left: 30px;">A. Get an <code>access_token</code></h2><pre>$app_id = APP_ID;
$secret = APPLICATION_SECRET;
$token_url =    "https://graph.facebook.com/oauth/access_token?" .
        "client_id=" . $app_id .
        "&amp;client_secret=" . $secret .
        "&amp;grant_type=client_credentials";
$response = @file_get_contents($token_url);
$params = null;
parse_str($response, $params);</pre><h2 id="bullet-2B" style="padding-left: 30px;">B. POST to Facebook with cURL</h2><p>Remember when we defined the <code>VERIFY_TOKEN</code> earlier? Replace <code>VERIFY_TOKEN</code> with that value in this code, and <code>ENDPOINT_URL</code>with the url of the file from part 1.</p><pre>$base_url = "https://graph.facebook.com/$app_id/subscriptions";
$url = $base_url . "?access_token=" . $params['access_token'];
$fields_string = '';
$fields = array(
            'callback_url=ENDPOINT_URL',
            'object=user',
            'verify_token=VERIFY_TOKEN',
            'fields=feed'
        );
$fields_string = implode("&amp;", $fields);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
//execute post
$result = curl_exec($ch);
//close connection
curl_close($ch);</pre><p>Once you visit this page successfully, Facebook will call the callback_url defined, verify that the <code>VERIFY_TOKEN</code> in both parts match, and then start sending Real-time Updates to your endpoint.</p><p>That was easy.</p><p><em><strong>*</strong>By the time you find this post and need help, you can either learn from my example code or, more likely, bang your head against a wall once you realize Facebook has changed its API once again.</em></p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/12/08/facebook-real-time-updates/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Building the Hancock Tower in CSS</title><link>http://marcneuwirth.com/blog/2011/07/25/building-the-hancock-tower-in-css/</link> <comments>http://marcneuwirth.com/blog/2011/07/25/building-the-hancock-tower-in-css/#comments</comments> <pubDate>Mon, 25 Jul 2011 14:14:41 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[CSS3]]></category> <category><![CDATA[3D Transforms]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=378</guid> <description><![CDATA[Still feeling inspired by Building a CSS City, I recreated another Boston building using CSS transforms this weekend: the Hancock Tower. This one was a bit tougher than building the Prudential Tower because it is more than just a few different size boxes &#8230; <a
href="http://marcneuwirth.com/blog/2011/07/25/building-the-hancock-tower-in-css/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<div
id="attachment_380" class="wp-caption alignright" style="width: 186px"><a
href="http://marcneuwirth.com/wp-content/experiments/hancock"><img
class="size-medium wp-image-380" title="CSS Hancock Tower Demo" src="http://marcneuwirth.com/wp-content/uploads/2011/07/hancock-176x300.jpg" alt="Hancock Tower built using CCS3 transforms" width="176" height="300" /></a><p
class="wp-caption-text">CSS Hancock Tower Demo</p></div><p>Still feeling inspired by <a
title="Building a pure CSS 3D City" href="http://cubiq.org/building-a-pure-css-3d-city">Building a CSS City</a>, I recreated another Boston building using CSS transforms this weekend: the Hancock Tower. This one was a bit tougher than building the <a
title="Building the Prudential Tower in CSS" href="http://marcneuwirth.com/blog/2011/07/19/building-the-prudential-tower-in-css/">Prudential Tower</a> because it is more than just a few different size boxes stacked on top of each other.</p><p>Creating the main body of the building wasn&#8217;t too hard, except for the inset parts on the thin sides. The base, on the other hand, was a pretty big pain. Fitting the sides together and sizing a top was a bit of a struggle (and probably mostly unnecessary because no one really notices that part of the building), but I think it turned out pretty well. The roof of the base flickers when spinning around the back of the building in Chrome for some reason, but appears perfectly in Safari.</p><p>After getting the building shape together I added the glass window texture and the darker row on the top of the building. Also, I think the coolest part of the Hancock Tower is how it reflects whatever is around it, so I added a cloud photo that rotates as the building moves around.</p><p>Originally I though there would be way less DOM elements on this model, but it turned out to be around the same as the Prudential Tower because of all the details:</p><pre>&lt;div class="wrapper"&gt;
            &lt;div class="block floors"&gt;
                &lt;div class="side1"&gt;
                    &lt;div class="inset left"&gt;&lt;/div&gt;
                    &lt;div class="inset left-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="side2"&gt;
                    &lt;div class="inset left"&gt;&lt;/div&gt;
                    &lt;div class="inset left-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="side3"&gt;
                    &lt;div class="windows"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="side4"&gt;
                    &lt;div class="windows"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="top"&gt;&lt;/div&gt;
            &lt;/div&gt;
            &lt;div class="block base"&gt;
                &lt;div class="side1"&gt;
                    &lt;div class="inset left"&gt;&lt;/div&gt;
                    &lt;div class="inset left-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="side2"&gt;
                    &lt;div class="inset left"&gt;&lt;/div&gt;
                    &lt;div class="inset left-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right-center"&gt;&lt;/div&gt;
                    &lt;div class="inset right"&gt;&lt;/div&gt;
                &lt;/div&gt;
                &lt;div class="side3"&gt;&lt;/div&gt;
                &lt;div class="side4"&gt;&lt;/div&gt;
                &lt;div class="top"&gt;&lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;</pre><p>Take a look at the <a
title="3D Hancock Tower Experiment Demo" href="http://marcneuwirth.com/wp-content/experiments/hancock/">Hancock Tower demo</a> in a webkit browser (Safari looks better than Chrome if you have the option).</p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/07/25/building-the-hancock-tower-in-css/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Building the Prudential Tower in CSS</title><link>http://marcneuwirth.com/blog/2011/07/19/building-the-prudential-tower-in-css/</link> <comments>http://marcneuwirth.com/blog/2011/07/19/building-the-prudential-tower-in-css/#comments</comments> <pubDate>Tue, 19 Jul 2011 13:45:13 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[CSS3]]></category> <category><![CDATA[3D Transforms]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=356</guid> <description><![CDATA[Last week I saw an awesome post by Matteo Spinelli on Building a CSS City and loved the idea. Since I am somewhat obsessed with trying to build things with 3D transforms (even though they are very impractical at this point), I decided &#8230; <a
href="http://marcneuwirth.com/blog/2011/07/19/building-the-prudential-tower-in-css/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<div
id="attachment_357" class="wp-caption alignright" style="width: 213px"><a
href="http://marcneuwirth.com/wp-content/experiments/prudential/"><img
class="size-medium wp-image-357" title="prudential" src="http://marcneuwirth.com/wp-content/uploads/2011/07/prudential-203x300.jpg" alt="" width="203" height="300" /></a><p
class="wp-caption-text">CSS Prudential Tower Demo</p></div><p>Last week I saw an awesome post by <a
title="Website of Matteo Spinelli" href="http://cubiq.org">Matteo Spinelli</a> on <a
title="Building a pure CSS 3D City" href="http://cubiq.org/building-a-pure-css-3d-city">Building a CSS City</a> and loved the idea. Since I am somewhat obsessed with <a
title="Slideshow with CSS 3D Transforms Part 2: Playing with Shapes" href="http://marcneuwirth.com/blog/2011/04/08/slideshow-with-css-3d-transforms-part-2-playing-with-shapes/">trying to build things with 3D transforms</a> (even though they are very impractical at this point), I decided to attempt the <a
title="Prudential Tower wikipedia page" href="http://en.wikipedia.org/wiki/Prudential_Tower">Prudential Center</a>. The concept was basically the same as his, except instead of building out I am building up.</p><p>The tower is built of 4 blocks stacked on top of each other: the spire, hub, neck and floors. Each block is essentially a cube of a certain size positioned using CSS Transforms and skinned with a texture. The proportions of the building are not quite right, but I couldn&#8217;t find them anywhere easily enough.</p><p>The markup is pretty simple:</p><pre>&lt;div class="block spire"&gt;
    &lt;div class="side1"&gt;&lt;/div&gt;
    &lt;div class="side2"&gt;&lt;/div&gt;
    &lt;div class="side3"&gt;&lt;/div&gt;
    &lt;div class="side4"&gt;&lt;/div&gt;
    &lt;div class="top"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="block hub"&gt;
    &lt;div class="side1"&gt;&lt;/div&gt;
    &lt;div class="side2"&gt;&lt;/div&gt;
    &lt;div class="side3"&gt;&lt;/div&gt;
    &lt;div class="side4"&gt;&lt;/div&gt;
    &lt;div class="top"&gt;&lt;/div&gt;
    &lt;div class="bottom"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="block neck"&gt;
    &lt;div class="side1"&gt;&lt;/div&gt;
    &lt;div class="side2"&gt;&lt;/div&gt;
    &lt;div class="side3"&gt;&lt;/div&gt;
    &lt;div class="side4"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="block floors"&gt;
    &lt;div class="side1"&gt;&lt;/div&gt;
    &lt;div class="side2"&gt;&lt;/div&gt;
    &lt;div class="side3"&gt;&lt;/div&gt;
    &lt;div class="side4"&gt;&lt;/div&gt;
    &lt;div class="top"&gt;&lt;/div&gt;
&lt;/div&gt;</pre><p>And CSS for the main section of the building:</p><pre>.block {
    margin: 0 auto;
    width:100px;
    height:500px;
    -webkit-transform-style:preserve-3d;
}
.block div {
    position:absolute;
    width:100px;
    height:500px;
    background: url('images/pru-side.jpg');
}
.floors .top {
    height: 100px;
}
.side1 {
    -webkit-transform:rotateY(90deg) translate3d(-100px,0,100px);
    -webkit-transform-origin:0 100% 0;
}
.side2 {
    -webkit-transform:rotateY(-90deg);
    -webkit-transform-origin:0 0 0;
}
.side3 {
    -webkit-transform:translate3d(0,0,100px);
}
.side4 {
    -webkit-transform: rotateY(180deg);
}
.top {
    -webkit-transform:rotateX(90deg) ;
    -webkit-transform-origin:100% 0;
}
.bottom {
    -webkit-transform: rotateX(90deg) rotateZ(90deg);
    -webkit-transform-origin:0 100%;
}</pre><p>The other sections use similar transforms, just with different sizes and offsets to align them in the center. Take a look at the <a
title="3D Prudiential Tower Experiment Demo" href="http://marcneuwirth.com/wp-content/experiments/prudential/">Final Demo</a> in any <a
title="Can I use 3d transforms" href="http://caniuse.com/transforms3d">webkit browser</a>.</p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/07/19/building-the-prudential-tower-in-css/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Revisiting the jQuery UI Time Slider</title><link>http://marcneuwirth.com/blog/2011/05/22/revisiting-the-jquery-ui-time-slider/</link> <comments>http://marcneuwirth.com/blog/2011/05/22/revisiting-the-jquery-ui-time-slider/#comments</comments> <pubDate>Mon, 23 May 2011 01:44:31 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[jQuery]]></category> <category><![CDATA[jQuery UI]]></category> <category><![CDATA[Slider]]></category> <category><![CDATA[time]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=304</guid> <description><![CDATA[Last year I wrote a post on how to use the jQuery UI slider widget for time ranges. I got emailed a question about it two weeks ago and looking back at the code, I realized there were many things &#8230; <a
href="http://marcneuwirth.com/blog/2011/05/22/revisiting-the-jquery-ui-time-slider/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Last year I wrote a <a
title="Using a jQuery UI Slider to Select  a Time Range" href="http://marcneuwirth.com/blog/2010/02/21/using-a-jquery-ui-slider-to-select-a-time-range/">post</a> on how to use the jQuery UI slider widget for time ranges. I got emailed a question about it two weeks ago and looking back at the code, I realized there were many things that could be done much better. So I decided to rewrite the code as a jQuery UI plugin wrapping the slider widget and put it on <a
title="jQuery UI Time Slider on GitHub" href="https://github.com/marcneuwirth/jquery-ui-timeslider">GitHub</a>.</p><p>Hopefully the code is now cleaner, more efficient, and easier to understand. You can see the demo <a
title="Time Slider Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/05/timeslider.html">here</a></p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/05/22/revisiting-the-jquery-ui-time-slider/feed/</wfw:commentRss> <slash:comments>11</slash:comments> </item> <item><title>Slideshow with CSS 3D Transforms Part 2: Playing with Shapes</title><link>http://marcneuwirth.com/blog/2011/04/08/slideshow-with-css-3d-transforms-part-2-playing-with-shapes/</link> <comments>http://marcneuwirth.com/blog/2011/04/08/slideshow-with-css-3d-transforms-part-2-playing-with-shapes/#comments</comments> <pubDate>Fri, 08 Apr 2011 15:19:21 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[CSS3]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[3D Transforms]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=271</guid> <description><![CDATA[So there were a couple of issues in Part 1: 1) I was using &#8216;class&#8217; as an element in the options object and threw an error in Safari. 2) The rest of the page besides the gallery looked really uninteresting. &#8230; <a
href="http://marcneuwirth.com/blog/2011/04/08/slideshow-with-css-3d-transforms-part-2-playing-with-shapes/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a
title="3D Transforms Slideshow Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d.html" target="_blank"><br
/> <img
class="aligncenter size-full wp-image-277" title="slideshow3d-cylinder" src="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d-cylinder.jpg" alt="Cylinder Shaped 3D transform" width="700" height="322" /></a></p><p>So there were a couple of issues in <a
title="Creating a Slideshow using CSS3 3D Transforms" href="http://marcneuwirth.com/blog/2011/04/05/creating-a-slideshow-using-css3-3d-transforms/">Part 1</a>:</p><p>1) I was using &#8216;class&#8217; as an element in the options object and threw an error in Safari.</p><p>2) The rest of the page besides the gallery looked really uninteresting.</p><p>3) A ring is the only shape that we could make.</p><p>Luckily, since then I have fixed all of those things plus added a couple more improvements. Obviously it is nice that this will work for people with Safari and the page is not as terrible looking, but the most interesting part is the new shapes.</p><p><span
id="more-271"></span></p><p>While a ring was cool, I figured that now that we had the framework for generating a 3d slideshow gallery, it should be pretty simple to extend this to include a bunch of different shapes: Vertical, Cylinder, Ribbon, Double Helix, Coil and, of course, Ring.</p><p>I was able to create these 8 different shapes using 4 parameters. Flat controls whether each slide will be a different height or even with its neighbors. Vertical controls if the rotation is on the x-axis or y-axis. Rows creates multiple smaller circles based on the number. Helix controls how many streams there are. So the default ring woud be flat, 1 row, 1 helix and not vertical.</p><pre class="brush: jscript; title: ; notranslate">
getShape: function (type) {
    switch (type) {
    case 'Vertical':
        return {
            flat: true,
            rows: 1,
            helix: 1,
            vertical: true
        };
    case 'Cylinder':
        return {
            flat: true,
            rows: 3,
            helix: 1,
            vertical: false
        };
    case 'Tall Cylinder':
        return {
            flat: true,
            rows: 6,
            helix: 1,
            vertical: false
        };
    case 'Ribbon':
        return {
            flat: false,
            rows: 2,
            helix: 1,
            vertical: false
        };
    case 'Double Helix':
        return {
            flat: false,
            rows: 1,
            helix: 2,
            vertical: false
        };
    case 'Coil':
        return {
            flat: false,
            rows: 2,
            helix: 0,
            vertical: false
        };
    case 'Big Coil':
        return {
            flat: false,
            rows: 1,
            helix: 0,
            vertical: false
        };
    case 'Ring':
        return {
            flat: true,
            row: 1,
            helix: 1,
            vertical: false
        };
    default:
        return {};
    }
}
</pre><p>For each of those settings, some work is happening in the transform function to change the rotation value or the amount the picture is translated in either the Z or Y direction:</p><pre class="brush: jscript; title: ; notranslate">
var rotate = ((length / rows) - count) * 360 / (length / rows),
    translateZ = length / rows * width,
    translateY = 0;
if (!flat) {
    if (helix &gt; 1) {
        translateY = count % helix * 2;
        translateZ /= 2;
    } else {
        translateY = count / 4;
    }
} else {
    if (rows &gt; 1) {
        translateY = parseInt((count - 1) / (length / rows), 10) * 1.5;
    }
}
translateY *= height;
rotate = rotate % 360;
if (rotate &gt; 180) {
    rotate -= 360;
}
</pre><p>Go over to the <a
title="3D Transform Slideshow Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d.html" target="_blank">demo</a> page and try out some of the different shapes with different numbers of pictures. It is interesting to see which handle many pictures really well. The Double Helix, Ring and Vertical are pretty unwieldy at around 100 pictures, but look cool with fewer. The Cylinder looks ok with less than 30 pictures, but I think it really shines with more. Try the Cylinder or Tall Cylinder with 120+ pictures and it looks awesome, everything is still easy to see and navigate. I like the Coil and Big Coil also, they look pretty good no matter how many pictures, but they take up a ton of room for the amount of pictures they show at one time. Ribbon isn&#8217;t all that exciting, but it looks nice enough and it doesn&#8217;t take up too much room.</p><p><a
title="3D Transforms Slideshow Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d.html" target="_blank"><img
class="aligncenter size-full wp-image-276" title="slideshow3d-coil" src="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d-coil.jpg" alt="Coil Shaped 3D Transform" width="700" height="377" /></a></p><p>One nice little addition I added in was the left and right arrow keys should now function to move you through the photos as you would expect. This makes navigation a little bit easier and is also a nice way to move through some of these new shapes in a way that wasn&#8217;t really necessary with just the Ring.</p><p>Make sure you take a look at the <a
title="3D Transform Slideshow Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d.html" target="_blank">finished demo</a> (or the <a
title="Original 3D Transform Slideshow Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d-original.html" target="_blank">original demo</a>) and get the source on <a
title="Get the Source on GitHub" href="http://github.com/marcneuwirth/slideshow3d" target="_blank">github</a>. Which shapes do you like the best?</p><p>Enabling 3d transforms in Chrome:<br
/> Type in about:flags in your address bar, enable GPU Accelerated Compositing and restart your browser.<br
/> If it is still not working, navigate to about:gpu. It appears that this won&#8217;t work on some Windows XP machines saying: &#8220;Hardware Acceleration Unavailable NVIDIA drivers older than 257.21 on Windows XP are assumed to be buggy&#8221;</p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/04/08/slideshow-with-css-3d-transforms-part-2-playing-with-shapes/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Creating a Slideshow using CSS3 3D Transforms</title><link>http://marcneuwirth.com/blog/2011/04/05/creating-a-slideshow-using-css3-3d-transforms/</link> <comments>http://marcneuwirth.com/blog/2011/04/05/creating-a-slideshow-using-css3-3d-transforms/#comments</comments> <pubDate>Tue, 05 Apr 2011 13:41:40 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[CSS3]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[3D Transforms]]></category> <guid
isPermaLink="false">http://marcneuwirth.com/?p=238</guid> <description><![CDATA[This weekend I was creating a couple fun ideas with Zoomooz.js, an awesome jQuery plugin for zooming to elements on a page, and was bummed to see that it couldn&#8217;t handle 3D transforms yet. After seeing Paul Hayes  3D Sphere and the Morphing &#8230; <a
href="http://marcneuwirth.com/blog/2011/04/05/creating-a-slideshow-using-css3-3d-transforms/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a
title="3D Slideshow using CSS3 Transforms Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d-original.html" target="_blank"><img
class="aligncenter size-full wp-image-246" title="slideshow3d" src="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d.jpg" alt="3D Slideshow using CSS3 Transforms" width="600" height="215" /></a></p><p>This weekend I was creating a couple fun ideas with <a
title="Zoomooz.js" href="http://janne.aukia.com/zoomooz/" target="_blank">Zoomooz.js</a>, an awesome jQuery plugin for zooming to elements on a page, and was bummed to see that it couldn&#8217;t handle 3D transforms yet. After seeing Paul Hayes  <a
title="Creating a sphere with 3D CSS" href="http://www.paulrhayes.com/2011-02/creating-a-sphere-with-3d-css/" target="_blank">3D Sphere</a> and the <a
title="Morphing Power Cubes" href="http://www.webkit.org/blog-files/3d-transforms/morphing-cubes.html" target="_blank">Morphing Power Cubes</a>, I spent a bunch of time playing around with 3D CSS transforms without coming up with anything too practical. But, after some of my Zoomooz experiments, I thought it would be interesting to see if it would be possible to create a scalable 3D slideshow in the model of the Morphing Power Cubes’ ring setup. Unfortunately this only works in webkit browsers because that is the only one that has 3D transform support as of this moment, so I am using <a
title="Modernizr" href="http://www.modernizr.com/" target="_blank">Modernizr</a> to test if your browser can preform the 3D Transforms.</p><p><span
id="more-238"></span></p><p>So starting with the Power Cube&#8217;s ring CSS, I stripped out all of the styles I wasn’t going to need and started creating the JavaScript function that would create the ring dynamically based on how many elements were in the list:</p><p>Main CSS:</p><pre class="brush: css; title: ; notranslate">
#container {
	-webkit-perspective: 1000;
	-webkit-perspective-origin: 50% 40%;
	-webkit-transform-style: preserve-3d;
}
#stage {
	width: 100%;
	margin-top: 200px;
	padding-bottom: 100px;
	-webkit-transform-style: preserve-3d;
}
#shape {
	margin: 0 auto;
	height: 240px;
	width: 240px;
	list-style: none;
	-webkit-transform-style: preserve-3d;
	-webkit-transition-duration: 1s;
}
</pre><p>Transform JavaScript:</p><pre class="brush: jscript; title: ; notranslate">
transform: function () {
    var length = children.length,
        count = length;
    while (count) {
        var child = $(children[length - count]),
			ratio = count / length,
			width = child.width() / 6.3,
			rotate = (length - count) * 360 / length,
			translate = length * width;
        if (rotate &gt; 180) {
			rotate -= 360;
        }
        child
		.css(transformClass + 'transform', 'rotateY( ' + rotate + 'deg ) translateZ(' + translate + 'px)')
		.attr('data-angle', rotate)
		.attr('data-original-angle', rotate)
		.attr('data-translate', translate)
		.addClass(addClass);
        count--;
    }
}
</pre><p>I calculated the angle at which each side should be rotated between -180 and 180 degrees, so that the ring will rotate towards the shortest path on the initial load. Next I estimated the radius of the circle by multiplying the length of the side by the number of sides and divide by approximately 2pi ~= 6.3. I set the angle and translation in the z direction (radius) so that the ring will be created given sides of equal widths. I also saved the original angle, current relative angle, and radius as data attributes for later use.</p><p>Now I have the ring and it is looking pretty good, but I want to be able to select pictures and have the ring spin to the selected picture. Instead of changing the angles of the actual sides and rotating that way, it is actually easier to just rotate the outer unordered list element to make it appear that the ring is rotating. Using a jQuery click event handler, I am going to rotate the outer element to the opposite angle of the side I want to see facing forward.</p><pre class="brush: jscript; title: ; notranslate">
setElementTransform: function (elem, clicked) {
	var	deg = -1 * setup.getElementTransform(clicked),
		value = 'RotateY(' + deg + 'deg)';
	$(elem).css(transformClass + 'transform', value);
}
</pre><p>Next, I needed to recalculate the relative angles for each side so that the ring will always take the shortest path when spinning to the next selected side. So I adjusted the relative angle by +360 or -360 if the difference between the current angle and the slide angle is more than 180 degrees.</p><pre class="brush: jscript; title: ; notranslate">
setAngles: function (current) {
	var length = children.length,
		currentAngle = parseInt(current.attr('data-angle'), 10),
		count = length;
	while (count) {
		var child = $(children[length - count]),
			rotate = parseInt(child.attr('data-angle'), 10),
			origRotate = parseInt(child.attr('data-original-angle'), 10),
			translate = parseInt(child.attr('data-translate'), 10);
		if (rotate - currentAngle &gt; 180) {
			rotate -= 360;
		} else if (rotate - currentAngle &lt; -180) {
			rotate += 360;
		}
		child
			.css(transformClass + 'transform', 'rotateY( ' + origRotate + 'deg ) translateZ(' + translate + 'px)')
			.attr('data-angle', rotate);
		count--;
	}
}
</pre><p>Last, I changed the translation in the z direction on the selected slide to be 1.6 times normal so that it comes closer to screen and stands out from the rest of the sides. That seems to be about as big as you can make it, without having the picture go past the screen.</p><p>I am using the flickr api to get the pictures used for the slideshow. This *should* work for any number of slides (besides 1 I guess), however I think it looks best with less than 50. My browser really starts choking after around 400 slides, but that seems to be pretty impractical anyway.</p><p>Again, at this time, 3D transforms only work in webkit browsers, although hopefully they will become more standard soon. In Chrome you may need to update and/or enable ‘GPU Accelerated Compositing’ on the about:flags page for this to work. If it is still not working check the about:gpu for more information.  I am currently on Google Chrome 11.0.696.34 beta on Windows 7 and I think it looks pretty awesome, so hopefully it does for you too. My girlfriend was not as thrilled about it as I was until I changed the search term to be puppies; now she loves it.</p><p>Take a look at the finished <a
title="CSS3 3D Transforms Slideshow Demo" href="http://marcneuwirth.com/wp-content/uploads/2011/04/slideshow3d-original.html" target="_blank">demo</a> or get the source on <a
title="Source" href="https://github.com/marcneuwirth/slideshow3d" target="_blank">github</a></p><p><a
title="Slideshow with CSS 3D Transforms Part 2: Playing with Shapes" href="http://marcneuwirth.com/blog/2011/04/08/slideshow-with-css-3d-transforms-part-2-playing-with-shapes/">Continued in Part 2</a></p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/04/05/creating-a-slideshow-using-css3-3d-transforms/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Anything you can do, Google does better</title><link>http://marcneuwirth.com/blog/2011/01/12/anything-you-can-do-google-does-better/</link> <comments>http://marcneuwirth.com/blog/2011/01/12/anything-you-can-do-google-does-better/#comments</comments> <pubDate>Thu, 13 Jan 2011 00:11:05 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[Uncategorized]]></category> <category><![CDATA[Google Goggles]]></category> <guid
isPermaLink="false">http://blog.marcneuwirth.com/?p=150</guid> <description><![CDATA[Google does a lot of things better than I can. It always knows the best way between two points while I often get lost, it can do unit conversions on the fly while I’m stuck looking for the other side &#8230; <a
href="http://marcneuwirth.com/blog/2011/01/12/anything-you-can-do-google-does-better/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<div><p>Google does a lot of things better than I can. It always knows the best way between two points while I often get lost, it can do unit conversions on the fly while I’m stuck looking for the other side of the measuring cup, and of course it can find pretty much anything as long as you know how to ask. One of the last things I have going for me is the ability to see and process information on the fly. Luckily I can sit on the bus, look at a newspaper and figure out this Sudoku puzzle using just my eyes, my brain and a pen. Oh, Google does that better than I do now too? Great.</p><p><span
id="more-150"></span></p><p><a
href="http://www.google.com/mobile/goggles/#text">Google Goggles</a> is an image recognition app that is used to search based on a picture taken on your phone. It is used to take a picture of a landmark, barcode, print ads or many other things and figure out what exactly it is that is staring you in the face. Ideally it would be useful if you have no idea what something is, but more often we have some idea and just type it in and search the old fashion way.</p><p>So what does that have to do with my Sudoku puzzle? Well, now with Google Goggles you can just take a picture of a Sudoku board with your phone and <a
href="http://googlemobile.blogspot.com/2011/01/google-goggles-gets-faster-smarter-and.html">Google will actually solve it for you</a>. Fast.</p><p>Since Sudoku is essentially a logic puzzle with very strict parameters, they are well suited to be solved by computer algorithms. Programs to solve Sudoku’s have been around for a while, so actually solving the puzzle isn’t terribly impressive; it’s the way that it happens that is fantastic. It takes about 30 seconds total for Goggles to take the picture, scan it in, figure out it is a Sudoku puzzle and solve for the answer. There is something just mind blowing about holding your phone’s camera up to a puzzle, taking a picture and watching the answer appear. And it is not just the easy newspaper Sudoku that it can handle; I decided to give it a real test with a couple of the<a
href="http://en.wikipedia.org/wiki/Sudoku_algorithms#Exceptionally_difficult_Sudokus_.28hardest_Sudokus.29">Hardest Sudoku’s</a> according to Wikipedia, and Goggles sliced through them like butter.</p><p>I guess the next time I hit a snag in my morning Sudoku I can get help from Google in 30 seconds instead of glaring jealously at the guy across from me who just finished it. At least I still have crossword puzzles to do while Skynet puts the finishing touches on becoming self-aware…</p></div> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2011/01/12/anything-you-can-do-google-does-better/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>A Free and Open Internet?</title><link>http://marcneuwirth.com/blog/2010/12/22/a-free-and-open-internet/</link> <comments>http://marcneuwirth.com/blog/2010/12/22/a-free-and-open-internet/#comments</comments> <pubDate>Wed, 22 Dec 2010 04:46:18 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[Capstone]]></category> <category><![CDATA[Isobar NA]]></category> <category><![CDATA[Net Neutrality]]></category> <guid
isPermaLink="false">http://blog.marcneuwirth.com/?p=145</guid> <description><![CDATA[This is the moment we have all been waiting for —well, those of us who like the internet the way it is— Congress is going to enact Net Neutrality regulations. Wait, what is Net Neutrality again? Net Neutrality has two &#8230; <a
href="http://marcneuwirth.com/blog/2010/12/22/a-free-and-open-internet/">Continue reading <span
class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a
href="http://marcneuwirth.com/wp-content/uploads/2010/12/net-neutrality.jpg"><img
class="alignright size-full wp-image-146" title="net-neutrality" src="http://marcneuwirth.com/wp-content/uploads/2010/12/net-neutrality.jpg" alt="" width="236" height="236" /></a>This is the moment we have all been waiting for —well, those of us who like the internet the way it is— Congress is going to enact Net Neutrality regulations.</p><p><em>Wait, what is Net Neutrality again?</em></p><p><span
id="more-145"></span></p><p>Net Neutrality has two main principles:</p><p>1)      Web information is distributed in an unbiased manner</p><p>2)      Accordingly, it is accessible to everyone (with a computer) in a designated area <em>for the same cost</em></p><p>Sounds like a great American idea, right? The new regulations would not allow Internet Service Providers to block Websites that offer competing services to their own nor speed up or slow down certain types or sources of Internet traffic. That’s great, because I’m way behind on my <a
href="http://www.hulu.com/">Hulu</a> queue and if Comcast started slowing down their traffic I would never get through it.</p><p>However, according to the <a
href="http://www.nytimes.com/2010/12/21/business/media/21fcc.html">New York Times</a>, these rules are more lenient for wireless carriers. Even though they cannot block Websites, they can still block or limit access to applications or services that directly compete with their own. Wait, what? That isn’t really Net Neutrality…</p><p>“Maybe you like Google Maps. Well, tough,” said Senator Al Franken on Saturday “If the F.C.C. passes this weak rule, Verizon will be able to cut off access to the Google Maps app on your phone and force you to use their own mapping program, Verizon Navigator, even if it is not as good. And even if they charge money, when Google Maps is free. If corporations are allowed to prioritize content on the Internet, or they are allowed to block applications you access on your iPhone, there is nothing to prevent those same corporations from censoring political speech.”</p><p>This is a nightmarish scenario for those of you who have ever used and paid for VZ Navigator; you can imagine how (literally) lost this world could be without our free Google Maps. But most importantly, telecom companies don’t have the people’s interest at heart; it’s their wallets they are thinking about. I think <a
href="http://www.theatlantic.com/technology/archive/2010/12/steve-wozniak-to-the-fcc-keep-the-internet-free/68294/">Steve Wozniak</a> said it best: “Every time and in every way that the telecommunications careers have had power or control, we the people wind up getting screwed.”</p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2010/12/22/a-free-and-open-internet/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>More Capstone News</title><link>http://marcneuwirth.com/blog/2010/05/04/more-capstone-news/</link> <comments>http://marcneuwirth.com/blog/2010/05/04/more-capstone-news/#comments</comments> <pubDate>Tue, 04 May 2010 18:49:00 +0000</pubDate> <dc:creator>Marc</dc:creator> <category><![CDATA[Capstone]]></category> <category><![CDATA[News]]></category> <category><![CDATA[Northeastern]]></category> <guid
isPermaLink="false">http://blog.marcneuwirth.com/?p=135</guid> <description><![CDATA[Yesterday&#8217;s Globe had a nice write up about Numbers Empower: http://www.boston.com/business/technology/articles/2010/05/03/app_can_help_fine_tune_your_electricity_usage/ Site redesign and some more posts coming soon.]]></description> <content:encoded><![CDATA[<p>Yesterday&#8217;s Globe had a nice write up about Numbers Empower:<a
href="http://www.boston.com/business/technology/articles/2010/05/03/app_can_help_fine_tune_your_electricity_usage/" title="Globe Write-up"> http://www.boston.com/business/technology/articles/2010/05/03/app_can_help_fine_tune_your_electricity_usage/</a></p><p>Site redesign and some more posts coming soon.</p> ]]></content:encoded> <wfw:commentRss>http://marcneuwirth.com/blog/2010/05/04/more-capstone-news/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Dynamic page generated in 0.632 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-05-23 10:44:39 -->
