npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

colour-challenge

v1.1.0

Published

A Node.js response to the colour code challenge

Downloads

2

Readme

Colour Code Challenge

The aim of the colour challenge is to create a script to randomly generate an RGB colour every hour and programmatically name it with an adjective + noun.

The challenge was created as a way to compare the syntax between languages with a commonly themed application.

Demo

View a demonstration.

Node.js Colour Code Challenge

This version is written in Node.js and available as a package to download from NPM.

Methodology

The application follows MVC principles:

  • All data is read and written through functions within the util module ./lib/util.js. The data is stored within a JSON file.
  • The view is located at ./views/log.mst written in HTML5 using mustache templating
  • Three controllers provide the operations, these are ./lib/add.js, ./lib/server.js and ./lib/clear.js

Each operation is accessed through ./lib/cli.js which acts as the command line interface. They can also be accessed through ./bin/cli which NPM adds to the users path as colour-challenge when installed.

To log the data hourly colour-challenge add should be defined as a cron job.

Installation

The application requires Node.js and npm to be installed, instructions can be found at nodejs.org.

With Node installed use the following to install the application globally.

npm install -g colour-challenge

Alternatively install direct from the repository.

npm install -g https://github.com/StudioLE/node-colour-challenge.git

Configuration

The app uses node-config so it's highly configurable. I recommend copying the ./config/default.json file to ./config/local.json and editing that so that your changes are not overwritten by future updates.

cd /usr/lib/node_modules/colour-challenge
cp config/default.json config/local.json
nano config/local.json

Usage

Add a single colour to the log

colour-challenge add

Add multiple colours to the log

colour-challenge add 10

Clear all previous logs

colour-challenge clear

Spin up a server to view the logs

colour-challenge server

Cron Setup

To run the script on the hour every hour you will want to configure a cron job similar to the following:

0 * * * * colour-challenge add

Participate

Now you've seen how it's done why don't you take a shot in the language of your own choice? Or perhaps there's a framework you've been dying to try out? Give it a go and send us a link to your repository. The challenge is great for participants of all levels of experience.