Image for post
Image for post

one Promise to .find(them). One Promise to bring them all and in the darkness .bind(them)

Today I was introduced to what might be regarded as the most powerful piece of JavaScript Promise syntax in the best way possible: right in the thick of a live coding interview puzzle for which the method was critical.

That piece of syntax is Promise.all.

First, a bit on Promises

Before JavaScript could Promise, asyncronous code was written in what many JS developers would call callback hell. Others call it the Hadouken effect:

Image for post
Image for post
Hadouken!

Because this is so clumsy, Promises were created and made available through various libraries (Q, when, WinJS, RSVP.js, bluebird.js) before being made native to JavaScript:

Image for post
Image for post

Promises encapsulate asynchronous code and create an easy way of starting and resolving streams of code out of direct sequence. Whereas event listeners are instantiated and then respond to external events asynchronously — which can create issues where an event that occurs before the listener is instantiated goes overlooked — a Promise begins and ends all within defined code blocks, and resolves once. …


Image for post
Image for post
Sourced from an excellent visual guide to the Solar System of JS by Shaun Lebron

I recently gave a presentation on JavaScript Transpilers at the Flatiron School with Dison Ruan, and I believe it’s such an important and compelling topic for just about anybody who uses software that it makes a lot of sense to write this accompanying article. I’ll split it into the same four sections that we did the presentation:

  • Why JavaScript
  • The Babel Transpiler
  • The World of Transpilers
  • The Future of JavaScript

So for a little background:

Why JavaScript?

JavaScript is a language created in ten days by Brendan Eich (who later ascended to hacker-God status and founded Mozilla) while he was at Netscape Navigator in 1995. …


It’s Native?!

Image for post
Image for post

Audio synthesis is an art and a science, with infinite breadth and depth. So needless to say, when I started in on my first JavaScript project working with the API I was ready to get knee-deep in JSON and parse every object and function out of a giant nested data structure.

But alas, we pulled up the Web Audio API documentation in the Mozilla Developer Network documentation and there was not a single mention of AJAX requests, JSON — there wasn’t even a single mention of Promises!

Instead:

Image for post
Image for post

~20 lines of code yields a deep bass sound on the page (in this case a 50Hz sine wave; put on some headphones, ‘cause your tinny laptop speakers won’t cut it). With the same lines of code an a few edits, I could just as well render any frequency in a number of waveforms (see lines 11–13…


Proactively protect your sensitive data from running off the Rails

Figaro is a very nifty tool for proactively protecting your rails project, so that you don’t ever have to use BFG, which I wrote about last week.

While BFG is for cleaning out your GIT repository tree, e.g. when you have accidentally uploaded sensitive data, Figaro is just the tool to prevent this from happening in the first place.

First in your rails app, add Figaro to your Gemfile and bundle install:

gem "figaro"

Next, execute the gem:

$ bundle exec figaro install

This creates a commented config/application.yml


For when your repository has been compromised

Image for post
Image for post

Although it was among my most cherished stories of my early childhood, this article is not about the Big Friendly Giant or his eponymous novel by Roald Dahl — no Fleshlumpeaters, Snozzcumbers, or Whizzpopping. Sorry!

BFG is a tool I encountered recently because of a pretty awful mistake I made in one of my git repositories. Designing my first API-leveraging program, I was juggling enough new structural and syntactical concepts that I didn’t think twice before throwing my API key right into a constant in the class that used it make a rest-client request.

Of course, I was lucky only to have made this beginner’s mistake with a New York Times API key — they aren’t hard to acquire, don’t provide access to personal and or account information, and won’t allow other users who have access to it to ring up an array of charges. So in that regard I was certainly lucky. This is not an uncommon mistake among developers, and it could be much worse — I’ve heard stories of amazon bills in the hundreds as the cost of an API key compromised in a public repository on Github. …


Week four of Flatiron School’s web dev bootcamp is on the threshold, and the last few weeks have borne a rapid ascent from the basics of Ruby to the implementation of complete dynamic web servers. Of all of the ideological traversals that we have made, the most startling for me has been the understanding of the distinction between dynamic and static web hosting and details of the broader workings of the internet that come with that distinction.

Image for post
Image for post
a map of the transoceanic fiber optic internet cables

First, it should be noted that the internet is actually connected by giant transoceanic cables.

I always thought that was just an extended joke on Ted…


I’m learning to program.

Learning to program at its very beginnings requires a shift in the way that I imagine: it permutes the very definition of action and the very action of definition, and blurs the line between the two.

This is because of the semantic nature of code. In the physical realm, I might think of an action — to snap a portrait — as an abstract concept, or as a plan that is distinct from the action that I actually take to snap the portrait. …

About

Charles Samuels

{ type: [‘Designer’, ‘Programmer’, ‘Artist’], location: ‘NYC’ }

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store