<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Paul Straw]]></title>
		<description>Paul Straw writes code and talks about things on his personal weblog.</description>
		<lastBuildDate>Wed, 11 Feb 2015 12:45:00 -0800</lastBuildDate>
		<link>http://paulstraw.com</link>
		<atom:link href="http://paulstraw.comfeed" rel="self" type="application/rss+xml" />
		<copyright>Copyright 2015</copyright>

					<item>
				<title><![CDATA[Simple JavaScript Parallax]]></title>
				<author></author>
				<description><![CDATA[<p>While working on Knight Foundation&#8217;s <a href="http://www.knightfoundation.org/features/livable-cities/">Livable Cities</a> project, I needed to apply a parallax-style effect to certain elements on the page. There are a lot of great JavaScript libraries to handle this sort of thing, but I&#8217;m a big fan of keeping file size and script processing time down whenever possible. It took about 30 minutes and less than 50 lines of code, and performs as well or better than most libraries.</p>
<p>In development, there&#8217;s a delicate balance between <a href="http://en.wikipedia.org/wiki/Not_invented_here">Not Invented Here</a>, and making sure you&#8217;re using the right tool for the job.</p>
<pre><code class="language-coffeescript"># We'll need these variables later
win = $(window)
curScrollPos = 0
winHeight = win.height()

# Cache all the elements we want to parallaxify
parallaxElements = $('.parallax')

# Figure out if we need to add a browser prefix for CSS transforms
styles = window.getComputedStyle(document.documentElement, '')
stylePrefix = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || (styles.OLink == '' &amp;&amp; ['', 'o']))[1]

# This function gets called whenever a user scrolls (or `touchmove`s) the page
scrollHandler = -&gt;
  for parallaxElement in parallaxElements
    # Re-jQueryify the element
    # This could be sped up by not using jQuery, but it's already quite performant on desktop and mobile
    parallaxElement = $(parallaxElement)
    pOffset = plaxable.offset()
    pRand = plaxable.data('rand')

    # Add a `bottom` property to the element's offset
    pOffset.bottom = pOffset.top + plaxable.outerHeight()

    # If this element hasn't already been assigned a parallax randomizer, create one for it
    # This makes sure elements scroll at slightly different speeds to enhance the "layered" effect
    if !pRand
      pRand = Math.random() * (1.3 - 0.7) + 0.7
      plaxable.data('rand', pRand)

    #  We only want to adjust elements that are currently on screen
    if pOffset.bottom &gt;= curScrollPos &amp;&amp; pOffset.top &lt;= curScrollPos + winHeight + 100
      # Actually calculate and set the transform
      newYOff = Math.min -((curScrollPos + winHeight - pOffset.top) * 0.1) * pRand, 0
      # Directly accessing an element's `style` property is significantly faster than using `jqObject.css(…)`
      plaxable[0].style["#{stylePrefix}Transform"] = "translate3d(0, #{newYOff}px, 0)"

# Kick everything off!
$(document).on 'ready', -&gt;
  win.on 'resize', -&gt; winHeight = win.height()
  win.on 'scroll touchmove touchend', scrollHandler
  scrollHandler()</code></pre>]]></description>
				<pubDate>Wed, 11 Feb 2015 12:45:00 -0800</pubDate>
				<link>http://paulstraw.com/weblog/simple-javascript-parallax</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/simple-javascript-parallax</guid>
			</item>
					<item>
				<title><![CDATA[Rails User-Editable Configuration]]></title>
				<author></author>
				<description><![CDATA[<p>When building out a Rails site with a large admin interface, you&#8217;ll eventually need to add some system settings that don&#8217;t relate specifically to any model. This is an Interesting Problem™, because ActiveRecord ties everything in the database to a model. I&#8217;ve recently started using the pattern of a GlobalConfig model to get around this.</p>
<pre><code>rails g model global_config singleton_guard:integer</code></pre>
<pre><code class="language-ruby">class GlobalConfig &lt; ActiveRecord::Base
  validates :singleton_guard, presence: true, uniqueness: true, numericality: {equal_to: 1}
  before_validation :set_singleton_guard

private
  def set_singleton_guard
    self.singleton_guard = 1
  end
end</code></pre>
<p>Once you&#8217;ve got this base, you need a nice way to actually access the config model from your controllers and views. I added this bit to my ApplicationController:</p>
<pre><code class="language-ruby">class ApplicationController &lt; ActionController::Base
  …

private
  def global_config
    @global_config ||= GlobalConfig.first || GlobalConfig.new

    return @global_config
  end
  helper_method :global_config
end</code></pre>
<p>From there, you can simply call <code>global_config</code> from any controller or view. By using an instance variable, we ensure that no matter how many times you access the GlobalConfig this way, it will only make one database call per request cycle.</p>
<p>Now that you&#8217;ve got the configuration model all set up, you can add whatever you need (e.g., <code>rails g migration add_newsletter_signup_cta_to_global_config newsletter_signup_cta:string</code>). Since it&#8217;s just a normal Rails model, you can set up forms and validation the same way you would for anything else. Using this pattern, clients can easily swap text, images, toggle site features, and more.</p>]]></description>
				<pubDate>Fri, 06 Feb 2015 01:47:00 -0800</pubDate>
				<link>http://paulstraw.com/weblog/rails-user-editable-configuration</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/rails-user-editable-configuration</guid>
			</item>
					<item>
				<title><![CDATA[nvALT and the Outboard Brain]]></title>
				<author></author>
				<description><![CDATA[<p>I have to remember a lot of stuff. If you work with computers, you probably do too. Cory Doctorow popularized the concept of the &quot;<a href="http://archive.oreilly.com/pub/a/javascript/2002/01/01/cory.html">Outboard Brain</a>&quot; a long time ago, and it&#8217;s still a valid concept. While Cory&#8217;s approach was based around blogging, mine has used a simple program called <a href="http://brettterpstra.com/projects/nvalt/">nvALT</a> for the last several years.</p>
<p>nvALT is a beautifully simple application that lets you write plain text notes about anything. Its main trick is letting you create or search for notes without having to manually manage creating or saving files; everything happens directly from the search bar at the top. If I need to take down contact information, I can just type &quot;James Hobbs&quot;, hit enter, and immediately start typing phone numbers, company names, or any other relevant information.</p>
<p>Since all files are saved as plain text, they can easily be synced via your service of choice, and edited on any platform (right now, I&#8217;m using <a href="http://omz-software.com/editorial/">Editorial</a> on iOS). By writing my notes using <a href="http://daringfireball.net/projects/markdown/">Markdown</a> syntax, I can also instantly convert them to beautiful HTML or PDF documents using <a href="http://marked2app.com/">Marked</a>. This gives me an incredible workflow that scales from one-liner code snippets to documentation for clients; all with no barrier to <em>just start writing</em>.</p>]]></description>
				<pubDate>Fri, 06 Feb 2015 00:59:00 -0800</pubDate>
				<link>http://paulstraw.com/weblog/nvalt-and-the-outboard-brain</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/nvalt-and-the-outboard-brain</guid>
			</item>
					<item>
				<title><![CDATA[ViewMaster]]></title>
				<author></author>
				<description><![CDATA[<p>I&#8217;m happy to announce that my first Mac App Store app has been approved and released to the public! It&#8217;s a simple menu bar app that shows you the current status and viewer count of a Twitch stream. I created it over the course of a couple days using <a href="http://rubymotion.com">RubyMotion</a>, and far too much time tweaking the icon.</p>
<p>If you&#8217;re a Mac user streaming with Twitch, you should check it out: <a href="https://itunes.apple.com/us/app/viewmaster-for-twitch/id913092374">ViewMaster for Twitch</a>.</p>]]></description>
				<pubDate>Sat, 30 Aug 2014 01:19:00 -0700</pubDate>
				<link>http://paulstraw.com/weblog/viewmaster</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/viewmaster</guid>
			</item>
					<item>
				<title><![CDATA[Tydlig]]></title>
				<author></author>
				<description><![CDATA[<p>A beautiful calculator app that throws away the &quot;normal&quot; calculator interface for something that makes much more sense on a touchscreen device. There&#8217;s no reason modern calculator applications should constrain themselves to the same layout and feature set that&#8217;s been used since the 1970s.</p>]]></description>
				<pubDate>Sun, 15 Dec 2013 05:00:00 -0800</pubDate>
				<link>http://tydligapp.com/</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/tydlig</guid>
			</item>
					<item>
				<title><![CDATA[Asset Management with Grind]]></title>
				<author></author>
				<description><![CDATA[<p>When you&#8217;re creating a website without the aid of something like Rails&#8217; <a href="http://guides.rubyonrails.org/asset_pipeline.html">Asset Pipeline</a>, it can be tempting to drop all your CSS and JavaScript into giant files that contain all the logic for every page in the site. This feels easy at first, but almost always becomes cumbersome as the project grows.</p>
<p>Splitting your assets up into smaller page- or module-based files makes for more reusable and maintainable code. <a href="https://github.com/paulstraw/grind">Grind</a> is a tool I made to help combine these files before serving them to the browser.</p>
<p>Automatically combining these files saves you work. You don&#8217;t have to manually include every file in your HTML, and if you&#8217;re dealing with SCSS or CoffeeScript, you don&#8217;t have to have another build step to compile them. It&#8217;s also beneficial for your users, since fewer HTTP requests means the site will load faster.</p>
<p>Assume you&#8217;re building a site with the following directory structure:</p>
<pre><code>index.html
about.html
src/
    js/
        home.js
        about.coffee
    css/
        global.scss
        mixins.scss
        home.scss
        about.scss</code></pre>
<p>You can use a <code>Grindfile</code> something like this (placed in your project root, or anywhere relative to the files you want it to process) to process your assets and get them ready for the browser:</p>
<pre><code class="language-json">{
    "paths": [
        "src/js"
    ],
    "hint": true,
    "uglify": true,
    "out": "site.js",
    "before": "sass src/css/global.scss:css/site.css"
}</code></pre>
<p>This will combine, <a href="http://www.jshint.com/">hint</a>, and <a href="https://github.com/mishoo/UglifyJS2">uglify</a> all JavaScript and CoffeeScript files inside <code>src/js</code>, and use the <code>sass</code> command line utility to process and output <code>src/css/global.scss</code> as standard CSS.</p>
<p>Inside <code>global.scss</code>, you can simply <code>@import</code> the other files, and easily get a single CSS file to serve to browsers:</p>
<pre><code class="language-scss">@import "mixins.scss";
@import "home.scss";
@import "about.scss";</code></pre>
<p>If you&#8217;ve got <a href="http://nodejs.org/">Node.js</a> installed, you can easily install Grind with NPM: <code>sudo npm install grind -g</code>. Once that&#8217;s done, just create a <code>Grindfile</code> in your project and run <code>grind</code> from the command line in that directory.</p>]]></description>
				<pubDate>Sun, 15 Dec 2013 01:00:00 -0800</pubDate>
				<link>http://paulstraw.com/weblog/asset-management-with-grind</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/asset-management-with-grind</guid>
			</item>
					<item>
				<title><![CDATA[Look at the Photo, Not the Frame]]></title>
				<author></author>
				<description><![CDATA[<p>I work with an extremely talented design team, all of whom are unhappy with iOS 7&#8217;s new design direction. While I agree there are some rough edges, overall I think the changes will ultimately be for the best, as designers and developers (including Apple&#8217;s own) learn to work with the new concepts and design language.</p>
<p>Good &quot;pixel design&quot; is, of course, very important; it has been one of the main ways to provide the &quot;user delight&quot; that designers strive for ever since the first GUI. Very few companies outside of tired examples like Google and Craigslist can even attract users without good design to help sell the product. But computers are now powerful enough to provide that same sense of delight in other ways, one of which is the use of motion, which provides visual interest and context without drawing attention away from the content. iOS 7 utilizes motion in almost every interaction; the parallax effects throughout the system, elastic trays, and home screen icon zooming just scratch the surface.</p>
<p>As I type this into <a href="http://vesperapp.co">Vesper</a>, I&#8217;m struck by just how much care has gone into what is truly &quot;as little design as possible&quot;. Subtle, well-considered animation and gorgeous typography help create the same sense of wonder that the most ornamental apps inspire on first load, but instead of just being nice to look at, they also improve the actual usage of the application. Every decision that the Q Branch team made serves to make writing more enjoyable; all the design is in service of helping me actually write words on the page. The true soul of every application is its user experience.</p>
<p>Until iOS 7, app design on iOS had been becoming progressively more complex and ornamental; nearly fetishistic. The sudden turnaround isn&#8217;t a rejection of beautiful design, it&#8217;s a return to caring more about the photograph than the frame.</p>]]></description>
				<pubDate>Fri, 04 Oct 2013 00:00:00 -0700</pubDate>
				<link>http://paulstraw.com/weblog/look-at-the-photo-not-the-frame</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/look-at-the-photo-not-the-frame</guid>
			</item>
					<item>
				<title><![CDATA[The Flaticons Collection]]></title>
				<author></author>
				<description><![CDATA[<p>Zach Roszczewski just launched his Flaticons icon collection (development courtesy yours truly). It has over 1000 icons, and includes fonts, PNGs, PSDs, and more. There&#8217;s also a great search tool that lets you drag and drop the PSDs directly into Photoshop from the browser, or copy the CSS class names and unicode values for use with the fonts.</p>]]></description>
				<pubDate>Tue, 30 Apr 2013 00:00:00 -0700</pubDate>
				<link>http://flaticons.co</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/the-flaticons-collection</guid>
			</item>
					<item>
				<title><![CDATA[One Laptop Per Child Gets Results in Ethiopia]]></title>
				<author></author>
				<description><![CDATA[<p>A pretty neat article on the OLPC project&#8217;s distribution of 1000 Android tablets to an Ethiopian village. The children there had apparently never seen written words before, but still managed to use (and eventually &quot;hack&quot;) the tablets. After a few months, they figured out how to unlock the devices&#8217; cameras (which were disabled by the manufacturer or distributor, apparently).</p>
<blockquote>
<p>Within four minutes, one kid … found the on/off switch. He&#8217;d never seen an on/off switch. He powered it up. Within five days, they were using 47 apps per child per day. Within two weeks, they were singing ABC songs [in English] in the village.</p>
</blockquote>]]></description>
				<pubDate>Sat, 27 Apr 2013 00:00:00 -0700</pubDate>
				<link>http://www.dvice.com/archives/2012/10/ethiopian-kids.php</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/olpc-ethiopia</guid>
			</item>
					<item>
				<title><![CDATA[Why You Should Jailbreak Your iPhone]]></title>
				<author></author>
				<description><![CDATA[<p>I haven&#8217;t been into jailbreaking since the iPhone 3G days, but Sam Sheffer has convinced me to give it another go. Some great, native-looking stuff; not to mention the awesome Nexus S-style &quot;Old TV&quot; lock animation.</p>]]></description>
				<pubDate>Mon, 18 Mar 2013 00:00:00 -0700</pubDate>
				<link>http://www.theverge.com/2013/3/4/4062792/top-15-reasons-to-jailbreak-your-iphone</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/the-verge-ios-jailbreak</guid>
			</item>
					<item>
				<title><![CDATA[stacksort]]></title>
				<author></author>
				<description><![CDATA[<p>Gregory Koberger&#8217;s hilarious implementation of an idea from <a href="http://xkcd.com/1185/">xkcd #1185</a> (check the alt text). Surprisingly, it works quite well.</p>
<p><em>h/t <a href="https://twitter.com/dalmaer">Dion Almaer</a></em></p>]]></description>
				<pubDate>Mon, 18 Mar 2013 00:00:00 -0700</pubDate>
				<link>http://gkoberger.github.com/stacksort/</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/stacksort</guid>
			</item>
					<item>
				<title><![CDATA[Don't Run a Shitty Company]]></title>
				<author></author>
				<description><![CDATA[<p>Dan Benjamin, David Heinemeier Hansson, Shlok Vaidya, and Haddie Cooke talk about Yahoo&#8217;s recent telecommuting ban.</p>
<p>Shlok:</p>
<blockquote>
<p>They want you to come in, they want you to put on a suit while you do it. … [Because] they don&#8217;t have real jobs. … Those guys are in there, they&#8217;re in their suits, and they want you in there, in your suit, doing Suit Things that they can make sure you&#8217;re doing.</p>
<p>&quot;What, you wrote 40 lines of code today? I don&#8217;t care what it does, you wrote forty; I need fifty&quot;.</p>
</blockquote>]]></description>
				<pubDate>Tue, 05 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://5by5.tv/quit/14</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/dont-run-a-shitty-company</guid>
			</item>
					<item>
				<title><![CDATA[‘Join Me, and Together We Can Rule the Galaxy’]]></title>
				<author></author>
				<description><![CDATA[<p>Octopus Creative is bringing on another front-end developer. We spend our time helping awesome companies create great products, and need someone to help us pull all the front-end parts together.</p>
<p>Interested? You should know HTML, CSS, and JavaScript like the back of your hand. Being deeply familiar with things like templating languages, CSS preprocessors, and CoffeeScript is also critical, as is a constant drive to always be improving yourself. If you think you&#8217;ve got what it takes, you should <a href="http://www.authenticjobs.com/jobs/16190/front-end-developer">get in touch</a>.</p>]]></description>
				<pubDate>Tue, 05 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://www.authenticjobs.com/jobs/16190/front-end-developer</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/join-me-and-together-we-can-rule-the-galaxy</guid>
			</item>
					<item>
				<title><![CDATA[Fear of a WebKit Planet]]></title>
				<author></author>
				<description><![CDATA[<p>After the <a href="http://robert.ocallahan.org/2013/02/and-then-there-were-three.html">recent controversy</a> over Opera&#8217;s switch from their in-house rendering engine Presto to WebKit, John Siracusa argues that WebKit&#8217;s ubiquity is more analogous to Linux than Internet Explorer.</p>
<blockquote>
<p>Linux is the canonical open source success story. It succeeded for reasons that are now so boring they’re accepted as common sense. There’s still plenty of room for variation and innovation, but now all the significant achievements are shared with the world. If a company improves Linux, it’s not just improving its own products; it’s making Linux better for everyone.</p>
</blockquote>]]></description>
				<pubDate>Mon, 04 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://hypercritical.co/2013/03/04/fear-of-a-webkit-planet</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/fear-of-a-webkit-planet</guid>
			</item>
					<item>
				<title><![CDATA[‘Just Give Me the Money, and I'll Send You a Show’]]></title>
				<author></author>
				<description><![CDATA[<p>Louis C.K. talks about the origins of his FX series.</p>]]></description>
				<pubDate>Mon, 04 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://www.youtube.com/watch?v=ssfEzWn3Mbk</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/just-give-me-the-money</guid>
			</item>
					<item>
				<title><![CDATA[Replacing the Minimum Wage]]></title>
				<author></author>
				<description><![CDATA[<p>Interesting idea from <a href="http://moorewr.tumblr.com/">moorewr</a>:</p>
<blockquote>
<p>Everyone gets money equal to what the Government claims is the minimum income for subsistence. No questions asked. Want to sit on your ass? The Government [will] cut you a check for $14.5k  per year. After that you’re on your own - no WIC, no subsidized rents, and so on.</p>
</blockquote>
<p>I have no idea what kind of social and economic effects this would have, but it would be fascinating to compare against the cost of all the social programs and subsidies it would replace.</p>]]></description>
				<pubDate>Sun, 03 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://moorewr.tumblr.com/post/44477647331/replacing-the-minimum-wage-a-modest-proposal</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/replacing-the-minimum-wage</guid>
			</item>
					<item>
				<title><![CDATA[The Google Glass Feature No One is Talking About]]></title>
				<author></author>
				<description><![CDATA[<p>Mark Hurst:</p>
<blockquote>
<p>It’s not a stretch to imagine that you could immediately be identified by [a] Google Glass user who gets on the bus and turns the camera toward you. Anything you say within earshot could be recorded, associated with the text, and tagged to your online identity. And stored in Google’s search index. Permanently.</p>
</blockquote>
<p>Interesting thoughts on a possible dystopian future, starting with Google Glass. This isn&#8217;t something that concerns me personally (at least not at the moment), but it&#8217;s definitely important to keep in mind as wearable computing becomes more prevalent.</p>]]></description>
				<pubDate>Fri, 01 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://creativegood.com/blog/the-google-glass-feature-no-one-is-talking-about/</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/google-glass-feature</guid>
			</item>
					<item>
				<title><![CDATA[Our Solar System from a Non-fixed Perspective]]></title>
				<author></author>
				<description><![CDATA[<p>Fantastic.</p>
<p><em>h/t <a href="https://twitter.com/shanselman">Scott Hanselman</a></em></p>]]></description>
				<pubDate>Fri, 01 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://i.imgur.com/Z7FpC.gif</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/solar-system</guid>
			</item>
					<item>
				<title><![CDATA[Flaticons]]></title>
				<author></author>
				<description><![CDATA[<p>A great new icon set from my friend and coworker, <a href="http://dribbble.com/zachroszczewski">Zach Roszczewski</a>. He&#8217;s giving away a free starter kit to everyone who joins the mailing list.</p>
<p>I&#8217;ve seen the still-in-progress full set; you&#8217;ll definitely want to keep your eye on these.</p>]]></description>
				<pubDate>Fri, 01 Mar 2013 00:00:00 -0800</pubDate>
				<link>http://flaticons.co/</link>
				<guid isPermaLink="true">http://paulstraw.com/weblog/flaticons-teaser-site</guid>
			</item>
		
	</channel>
</rss>