• 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

  • 0

Interestingly, one of the first people to criticize these kind of “recommender systems” for their unintended effect on society was Patti Maes who had invented RINGO. She said that the inevitable effect is to narrow and simplify your experience - leading people to get stuck in a static, ever-narrowing version of themselves. Adam Curtis on NO FUTURE

All Watched Over by Machines of Loving Grace

All Watched Over by Machines of Loving Grace) (2011)

Someone uploaded this a while back and it's definately worth a watch. All of Adam Curtis's films are pretty amazing and worth checking out.

EDIT: Just noticing the video preview pics. Don't worry, its not about Ayn Rand in the way you would expect an online video to be about Ayn Rand ;)

All Watched Over by Machines of Loving Grace 1 from SACPOP on Vimeo.

All Watched Over By Machines of Loving Grace 2 from SACPOP on Vimeo.

All Watched Over by Machines of Loving Grace 3 from SACPOP on Vimeo.

  • 0

There are perhaps 30 developers worldwide who understand the autoconf tool chain. Andrew McCall on Freecode

Found on Ryan Dahl - Re: [nodejs] Re: Build nodejs with an alternative build system?

  • 0

few end of quarter projects:

A quick brain dump of project progress recently. Please forgive the grammar and spelling errors.

Tempy

This will add a live temperature sparkline of the apartment to the web. Temp data is coming from the Nest API using a display provided by one of the following libs:

Update

Working live at tempy.herokuapp.com.

Youtube-dl wrapper

This will easily spiral into a much larger project, but the idea is to make a small web wrapper around youtube-dl, which take video URLs, downloads them, converts them to an mp3 (via ffmpeg), then serves them up as a podcast feed. Obviously, this will be for personal use only, but it seems like the easiest way to cache a long conference talk or lecture for offline use on a phone.

Longer term project progress:

SEMterface

Totally missed the schedule on this. Looks like I will have to dump another quarter into this project. I have a ton more knowledge about how to make this project work now, so its a matter of finding time to do it and make enough progress early so that I am not forced to deviate to a much less interesting outcome.

base

Created a fresh new base site for a gh-pages hosted jekyll site. This has good initial progress made on it and a basic structure including dynamic javascript loading through require.js. Nest up is working on the CSS and flex box layout, which appears to be the next big hurdle.

gitpub

Recent Progress:

  • Switched from mocha to tape.
  • Syndication advertising in.
  • More tests... but apparently they suck because they are mocks.

Recent regression:

  • Posts error out.. but they still work
  • Lots of logic in routes. Bad!
  • Realizations of a Monolithic structure

Plans:

  • Rewrite the git wrapper
  • Get syndication working
  • Make more generic/app like?
  • But also reduce scope to a single website.