This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| // See comments below. | |
| // This code sample and justification brought to you by | |
| // Isaac Z. Schlueter, aka isaacs | |
| // standard style | |
| var a = "ape", | |
| b = "bat", | |
| c = "cat", | |
| d = "dog", |
| var flattenObject = function(ob) { | |
| var toReturn = {}; | |
| for (var i in ob) { | |
| if (!ob.hasOwnProperty(i)) continue; | |
| if ((typeof ob[i]) == 'object') { | |
| var flatObject = flattenObject(ob[i]); | |
| for (var x in flatObject) { | |
| if (!flatObject.hasOwnProperty(x)) continue; |
| # Two things are important to note: | |
| # | |
| # 1) The code is fugly, because it was a JavaScript/iPad experiment. | |
| # I know that it is ugly, so pretty please don't comment on that part. | |
| # 2) I tried to use as many CoffeeScript features as possible, | |
| # including but not limited to list comprehensions, | |
| # heredocs, destructuring assignment and also the "do" operator | |
| # | |
| # I welcome comments about stuff that is not CoffeeScripty enough, or what I should | |
| # write differently. |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| /* vim:set ts=2 sw=2 sts=2 expandtab */ | |
| /*jshint asi: true undef: true es5: true node: true devel: true | |
| forin: false latedef: false */ | |
| /*global define: true */ | |
| if (typeof(WeakMap) === 'undefined') WeakMap = (function(global) { | |
| "use strict"; | |
| function defineNamespace(object, namespace) { |
| // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
| // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
| // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
| // MIT license | |
| (function() { | |
| var lastTime = 0; | |
| var vendors = ['ms', 'moz', 'webkit', 'o']; |
| { | |
| "Version": "2008-10-17", | |
| "Id": "b2cc31d0-cc91-4285-a658-473099d2c867", | |
| "Statement": [ | |
| { | |
| "Sid": "AllowPublicRead", | |
| "Effect": "Allow", | |
| "Principal": { | |
| "AWS": "*" | |
| }, |
| var p1 = { | |
| x: 20, | |
| y: 20 | |
| }; | |
| var p2 = { | |
| x: 40, | |
| y: 40 | |
| }; |
| # Two things are important to note: | |
| # | |
| # 1) The code is fugly, because it was a JavaScript/iPad experiment. | |
| # I know that it is ugly, so pretty please don't comment on that part. | |
| # 2) I tried to use as many CoffeeScript features as possible, | |
| # including but not limited to list comprehensions, | |
| # heredocs, destructuring assignment and also the "do" operator | |
| # | |
| # I welcome comments about stuff that is not CoffeeScripty enough, or what I should | |
| # write differently. |