Knick Labs

Adventures in Ruby, JavaScript and Other Things

Lorem Ipsum and Concat NodeJS Packages Updated

I have published minor updates to the Lorem-Ipsum and Concat packages for NodeJS. You can get the updates through NPM. An issue in Lorem-Ipsum that saw ‘undefined’ appear in program output has been closed. An issue in Concat in which files could be included multiple times under certain circumstances has also been closed.

To install the latest version of Lorem-Ipsum (0.0.9):

1
npm install lorem-ipsum -g

To install the latest version of Concat (0.2.4):

1
npm install concat -g

Note that you can install both of these packages locally in your projects and require them as well. They are however, most useful as command line utilities and so benefit from doing a global install.

Node.js Platform on Ubuntu

I can’t stay away from Node.js. It’s just too much fun. So the first thing I did tonight upon finally settling on Linux Mint/Cinnamon on my laptop was install RVM and Ruby. But then I installed Node.js!

Getting a recent version of Node.js installed on Ubuntu or Ubuntu-derivatives is no walk in the park. The version in the official repositories is out of date. So you’ve got to add an unofficial (and untrusted) source or compile it yourself.

It turns out there is another, much easier way. Some nice chap has posted a script that will set-up a Rock Solid Node.js Platform on Ubuntu. As an added bonus, you can configure the script to install Mongo and/or Redis too.

Silence ROR App Logs

I think the asset pipeline in Ruby on Rails is great. I enjoy being able to create a bunch of tiny stylesheets and javascripts and having Rails put them back together into monolithic documents for me. It even minifies the assets in production. The asset pipeline offers a lot for free.

What I don’t like about the asset pipeline is how noisy it is. It logs every single asset request in the app log. I usually wind up with several pages of console output, most of which is full of notices of GET requests for assets. All of this data gets in the way of the information. There is very good information in the app logs, such as passed parameters and executed queries – that’s the stuff I want to see.

Fortunately, there is a very easy fix for this problem. There is a Ruby Gem called Quiet Assets that supresses most of the log output from the asset pipeline. Just add

1
gem 'quiet_assets', group: :development

to your gemfile and then run bundle install.

After installing Quiet Assets and restarting your server, you’ll probably be a happier Ruby on Rails coder.

The Problem with Webrick

All the noise from the asset pipeline is gone now that we have installed Quiet Assets. However, you might notice another problem if you are using Webrick and Ruby 1.9.3. You may have a series of warnings in your app log about unknown content-length of the response body. This is an issue with Webrick and it is solved easy enough if you are willing to use another development server.

Just add

1
gem thin

to your gemfile and then run bundle install.

Now your rails app will run on the Thin web server and your app logs will be clean.

Announcing Niagara Beaches CLI

As part of a larger project I am working on, I created a Node.js module to get beach reports for Niagara Region beaches, including the somewhat famous, Lakeside Park.

The module can be used as a library in any node project. You can also install Niagara Beaches globally, by running npm install niagara-beaches --global. This will allow you to run niagara-beaches from your command line to receive an up-to-date list of beaches and their latest status updates.

Here’s an example of how to use the module in a Node.js script.

1
2
3
4
5
6
7
8
9
10
11
var beaches = require('niagara-beaches');

beaches.get(function(err, data) {
  if (err) {
    return console.log(err);
  }

  for (var i = 0, max = data.length; i < max; i++) {
    console.log(data[i]);
  }
});

Visit the Official Niagara Beaches Web Page for more information.

Preliminary Version of Node Lorem Ipsum Module Released

I made a simple Node module tonight that generates passages of Lorem Ipsum, which is great placeholder text. This is a preliminary version so it does not have many options yet, but it is nonetheless useful.

How to Use the Module

Install the module through npm.

1
npm install lorem-ipsum

Require the module in your script. It returns a function which you can call. When invoked, the function will return a string of lorem ipsum text.

1
2
var g = require('lorem-ipsum')
  , s = g();

You can also pass options to the function. You can pass a count and specify if you want words or sentences.

1
s = g({count: 5, units: 'words'});

How to Use the Command Line Interface

Install the module globally through npm.

1
npm install lorem-ipsum -g

Running the command lorem-ipsum will output a paragraph of lorem ipsum text. You can also specify a count and whether you want words or sentences.

1
lorem-ipsum 5 --sentences

NodeConcat Updated - Now Works on Windows

NodeConcat - a simple file concatenation tool I wrote - did not support Windows. Since I built this tool for myself and I don’t use Windows, I wasn’t upset.

I received a pull request from ricknpc that added support for Windows by accounting for the differences in the Windows file system. That patch has been merged into master and the package has been updated on the NPM Registry.

So, if you need to use NodeConcat on Windows, make sure you update to version 0.2.3.

Coming Soon… Software Niagara

I have started a grassroots initiative called Software Niagara to help foster a stronger software community in the Niagara Region. In hacker parlance, it is a fork of Software Hamilton - a group that has done a great job building a strong software community in Hamilton through events such as Demo Camps and Start-Up Drinks.

I want to thank Software Hamilton for their help and encouragement in starting Software Niagara. I’ll be happy if we experience a fraction of their success.

Read on for more information on Software Niagara.

What is Software Niagara?

Software Niagara is an indepentent grassroots initiative focused on building a stronger software community in the Niagara Region. We strive to connect local people with an interest in software - that includes professional developers, computing students, hackers, entrepreneurs, and so many others. We do this primarily by organizing events such as Demo Camps.

Are There Groups That Do This Already?

Yes!

If there are any other groups we’ve missed, please email me us info@softwareniagara.com or send us a message on Twitter to let us know.

Why Do This?

We believe that for communities to get stronger, they need to interact more. We want to provide even more ways for software folk in Niagara to connect and find each other. We also hope that other software-related groups in Niagara use Software Niagara as a platform to promote their groups.

What Are You Planning?

We are currently planning a demo camp event for this summer. Demo Camps are a great way to meet others in the local tech community and see what they are working on.

And that’s all. We don’t want to get ahead of ourselves. We want to see how demo camp goes and get feedback from the community on where this should go long term.

How Can I Help?

Here’s what we need:

  • People to demo cool things they have developed
  • Someone to give a keynote at our first demo camp
  • People to come to our first demo camp

If you can help with any of this, please contact us at info@softwareniagara.com or send us a message on Twitter.

Where Can I Find Out More?

We’re finishing our website and setting a date for demo camp. We jumped the gun a bit with putting up this FAQ because we were adding a bunch of people to our Twitter account and thought we owed you an explanation.