Trash – a safer and cross-platform `rm` #

Instead of permanently deleting files from the command line, this little tool moves them to the trash.

Like me, you might be thinking, “But I can do the same thing with mv.” To this Sindre writes:

Not really. The mv command isn’t cross-platform and moving to trash is not just about moving the file to a “trash” directory. On all OSes you’ll run into file conflicts. The user won’t easily be able to restore the file. It won’t work on an external drive. The trash directory location varies between Windows versions. For Linux there’s a whole spec you need to follow. On OS X you’ll loose the Put back feature.

Who knew?

A Hapi Ninja for Node.js #

Earlier this year we had Eran Hammer on the podcast to talk about the success of Node.js at Walmart for the infamous influx of traffic that Black Friday brings them. At the core of their success lies Hapi, the rich framework for building web applications and services with Node from Walmart Labs.

Hapi is a lot like Sinatra for Ruby in the fact that you start with a single server file and expand as needed from there to create a file and directory structure to organize and support your application code.

While hacking on Hapi recently, I found Hapi Ninja. If you’re just getting started like me, Hapi Ninja can serve as a boilerplate to learn from with Hapi, or even as the starting point for your Node web service.

It was also a pleasant surprise to see Saul Maddox was a native Houston Texan like myself. Sadly we’ve never met.

Metalsmith: a static site generator with lots of potential #

Segment.io’s Metalsmith doesn’t excite me because it’s a static site generator. It excites me because its everything-is-a-plugin philosophy turns it in to a potential swiss army knife for any project that manipulates a directory of files.

It could be a project scaffolder. It could be an e-book generator. It could be a build tool. It could be a documentation tool. It could be something I’ve never even heard of before.

Check out their examples to whet your imagination.

Quickly reduce the amount of data your node API returns #

When designing an API, it’s easy to forget that not everyone has a cable modem. What if a client could easily request exactly the data it needed. That is what JSON Mask aims to do.

This is a tiny language and an engine for selecting specific parts of a JS object, hiding/masking the rest.

A code example helps to demonstrate how this works.

var mask = require('json-mask')
mask({p: {a: 1, b: 2}, z: 1}, 'p/a,z')  // {p: {a: 1}, z: 1}

JSON Mask seems like an interesting way to reduce the amount of data we send down the pipes.

Node mock in-memory file system for testing #

In Node, the fs module provides file system access. Tim Schaub’s mock-fs module allows Node’s built-in fs module to be temporarily backed by an in-memory file system during testing.

From Tim’s post Mocking the file system:

When writing tests, it’s common to run up against code that relies on file system access. People often end up including a bunch of test fixtures along with their code. Tests might create some temporary space, copy fixtures in place, run code, make assertions about what was read or written, and then clean up. The result can be fragile when working across multiple operating systems and leads to long test run times. In cases like this, a mock file system provides an alternative.

Checkout the source on GitHub.

#113: Scale npm with Isaac Schlueter and Charlie Robbins

Adam talks with Isaac Schlueter and Charlie Robbins — Isaac is the creator of npm and maintainer of Node.js, and Charlie is the Co-Founder and CEO of Nodejitsu. We talk about the “crashyness” of npm recently and the community fundraiser they are starting to ask the community to support npm and to keep it running.

Scale npm. Keep it running. Keep it awesome. #

The npm Registry needs your help.

The npm Registry has had a 10x year. In November 2012 there were 13.5 million package downloads. In October 2013 there were 114.6 million package downloads. We’re honored to have been a part of sustaining this growth for the community and we want to see it continue to grow to a billion package downloads a month and beyond.

Recently the npm registry got “crashy.” Many were not able to install, publish, or otherwise write code on npm. That’s bad.

Nodejitsu is gracefully taking the blame, and have shared the technical details on the Node.js blog. Since May 2013, when they acquired IrisCouch, Nodejitsu has operated the npm registry for the community. They’ve also taken on considerable costs in the process.

We’re a startup. We run npm because we love node and we’re very well qualified for the job. But in the last year, npm has become a giant beast of a project. We run it lean, both from an engineering and hardware perspective, because it’s just too expensive to do otherwise.

We wondered, how could we possibly get the money for the hardware and engineers to do this the right way and keep it free for the community?

That’s where you come in.

Please show your supportDonate at scalenpm.org

#111: Hoodie, noBackend and offline-first with Caolan McMahon

Andrew and Adam talk with Caolan McMahon from Hoodie to talk about very fast web development where you can build complete web apps in days, without having to worry about backends, databases or servers (with Hoodie). We discuss noBackend and the idea behind offline first.

Prototype JSON APIs with Fortune.js #

If you hadn’t heard, JSON API is a format for building awesome APIs on top of JSON. You can see other posts tagged with JSON API here.

Recently, a new project related to JSON API was released: Fortune.js.

Fortune.js, a web framework for prototyping rich hypermedia APIs, allows you to rapidly prototype the server side of any JSON API api.

Check it out:

var fortune = require('fortune') 
  , app = fortune({ 
    db: 'petstore' 
  }) 
  .resource('person', { 
    name: String, 
    age: Number, 
    pets: ['pet'] // "has many" relationship to pets 
  }) 
  .resource('pet', { 
    name: String, 
    age: Number, 
    owner: 'person' // "belongs to" relationship to a person 
  })
  .listen(1337);

This will give you all the proper routes and format the responses in the right way to conform with the spec.

If you didn’t guess, fortune.js makes heavy use of Node, so you can get it from npm:

$ npm install fortune

I am super pumped about projects like this, because it shows off the great benefits of standardizing around a type like JSON API. Tooling that knows how to handle the type makes it really easy to get off the ground.

parallax.js: bringing real movement to the web #

parallax.js is a lightweight parallax engine that responds to the movements from your smartphone’s gyroscope and motion detection. The tool lets you specify depths and directions that determine how your webscape responds to physical movement.

Creating layers is super simple, as documented:

Simply create a list of elements giving each item that you want to move within your parallax scene a class of layer and a data-depth attribute specifying its depth within the scene. A depth of 0 will cause the layer to remain stationary, and a depth of 1 will cause the layer to move by the total effect of the calculated motion.

Parallax.js is useable in jQuery and Zepto as a plugin, too.

MIT Licensed. Browse the source code on Github.

#101: npm origins and Node.js with Isaac Schlueter

Andrew and Adam talk with Isaac Schlueter about the origins of npm, building an asynchronous web with Node.js, and how to get paid to open source. Mastering modern payments using Stripe with Rails. isaacs (Isaac Z. Schlueter) Foo Hack » Isaac Schlueter on Web Development isaacs (izs) on Twitter isaacs/npm Install Node.js and NPM using […]

Write a Date() like a human #

As a person who is constantly thinking about the user’s experience when interacting with my software, writing the date and time using real english such as “2 days from today”, or “tomorrow at 5pm” provides the, often needed, human touch I’m looking for.

Date, from Matthew Mueller, is an english language date parser for node.js and the browser that lets your users write dates like a normal human being using real english.

A few examples from the readme:

date('10 minutes from now')
date('in 5 hours')
date('at 5pm')
date('at 12:30')
date('at 23:35')
date('in 2 days')
date('tuesday at 9am')
date('monday at 1:00am')
date('last monday at 1:00am')
date('tomorrow at 3pm')
date('yesterday at 12:30am')
date('5pm tonight')
date('tomorrow at noon')

Check out the source on GitHub or the homepage for examples and demos.