• 0

Keeping an eye on the research servers

  • 0

Replied to a post on sandeep.io:

Nice research links!

Have you tried something like mosh?

  • 0

Boards of Canada-Audiotrack 01A

  • 0

Shell Art

  • 0

Goal to get photo hosting to S3 via micropub working by this years end.

More to come.

  • 0

  • 0

  • 0

Pulled from felixge/node-style-guide and written down as to not forget.

Return early from functions

To avoid deep nesting of if-statements, always return a function's value as early as possible.

Right:

function isPercentage(val) {
  if (val < 0) {
    return false;
  }

  if (val > 100) {
    return false;
  }

  return true;
}

Wrong:

function isPercentage(val) {
  if (val >= 0) {
    if (val < 100) {
      return true;
    } else {
      return false;
    }
  } else {
    return false;
  }
}

Or for this particular example it may also be fine to shorten things even further:

function isPercentage(val) {
  var isInRange = (val >= 0 && val <= 100);
  return isInRange;
}

Name your closures

Feel free to give your closures a name. It shows that you care about them, and will produce better stack traces, heap and cpu profiles.

Right:

req.on('end', function onEnd() {
  console.log('winning');
});

Wrong:

req.on('end', function() {
  console.log('losing');
});

No nested closures

Use closures, but don't nest them. Otherwise your code will become a mess.

Right:

setTimeout(function() {
  client.connect(afterConnect);
}, 1000);

function afterConnect() {
  console.log('winning');
}

Wrong:

setTimeout(function() {
  client.connect(function() {
    console.log('losing');
  });
}, 1000);

December Reading List

Catching up on a bunch of stuff by substack and ogd and learning some things when developing tempy, plus a few other tangents.

Browserify all the things!

  • Browserify-handbook - Read all of it!

    Browserify didn't really make sense until I was able to understand require.

    People used to think that exporting a bunch of handy utility-style things would be the main way that programmers would consume code because that is the primary way of exporting and importing code on most other platforms and indeed still persists even on npm.

  • Rails is omakase - More on why small modules are nice.

  • Node Packaged Modules A nice dose of sanity to the insanity that is front-end JS library management.

    There is only one problem: browsers don't have a good way to load modules. The state of the art is to have a ton of script tags that either leak globals e.g. how jQuery plugins all use $ or use RequireJS to manage loading code into the correct scopes.

  • ES6 Modules: The End of Civilization As We Know It? - dlmanning pointed this article out regarding the future of module loading. Excellent read.

  • Browserify-middlware - A connect style middleware for generating your browserified bundles.

  • wzrd.in - CDN for common.js packages.
  • multi-shim-example-including-dependencies - Adapting global JS libs for browserify.

Streams and Promises

  • Streams Handbook

    Streams can help to separate your concerns because they restrict the implementation surface area into a consistent interface that can be reused.

    Streams have always been more confusing than callbacks, and after reading this, they are much easier to understand. That being said, its concerning to see how different APIs are of the various stream versions.

  • Speaking of streams, promises seem weirder the more I hear about them:

    23:51:54 <rvagg> Promises are a huge pollution to interoperability, an abstraction on top of an abstraction

    23:52:51 <rvagg> Domenic: they are an hack on top of synchronous languages that haven't grown up with first-class functions and they are an uncomfortable fit in JS because of this

    23:53:18 <rvagg> they allow you to defer your learning of what "asynchronous programing" means, further delaying your ability to write more performance and parallel code

    23:54:44 <rvagg> callbacks are the very definition of a representation of "stuff that happens in the background", we have that mechanism already

    23:55:23 <rvagg> helping people adapt to full CPS is a more worthy goal than allowing them to defer that for even longer (and they do have to get there in the end no matter what route they take) rvagg on #io.js

  • node aesthetic

  • many things

Testing and Tasking

io.js/node stuff

Node.js is forked. Here is all that you need to know.

Misc

Books

want/reading/read:

  • 0

Tempy is up and running smoothy so far:

tempy