Categories: Portfolio, Software Development

Node.js Search Engine for Github Wikis

I wrote an article on how to create a search engine using Node.js for Github Wikis. The Github wiki uses markdown formatted pages and is very easy to get started with. It isn’t as fully featured as other wikis but it is a good starting point for organizations looking to build a knowledge base.

Searching through a github wiki isn’t very easy to do, so in the article you will see how to index each wiki page and tag it for search queries.

Categories: Software Development

node-oauth-libre 0.9.15 ALPHA

I’m very excited. After starting a fork of node-oauth-libre a month ago, I have implemented a feature that many people have wanted for months: Promises instead of callbacks.

Promises are a way of escaping from Node’s callback hell.

node-oauth-libre now has support for promises thanks to the bluebird library. This support is optional and does not break compatibility with existing uses of node-oauth. To use it, you must explicitly import it.

Click here to check out the release notes for node-oauth-libre 0.9.15 ALPHA. The install and usage instructions are there and a link to some examples.

Here’s an example of using OAuth 1.0 promises:

Using Sequelize with Promises (with and without Q)

Using Sequelize with Promises (with and without Q)

Here is a basic example of using Sequelize with promises using the Q Promises library.

Q is basically a way for you to use Promises in Node.js. You can use it with Sequelize to make it easier to perform the SQL operations through the library.

Categories: Software Development

Dimming JavaScript curly braces and brackets in Emacs

When coding in Lisp or Scheme, some Emacs users prefer to have the parenthesis/brackets dimmed. The reason for this is that it makes it easier to see the things that matter like variable names.

If you are looking for a JavaScript mode for Emacs, please check out the following projects:

I’ve been coding more JavaScript lately and wondered if this would work for JS and indeed it does. While it doesn’t turn JS into CoffeeScript and you still have to type in in the brackets and curly braces and semi-colons, it does let you adjust the colour of them and let’s you dim them so that you can see the important parts.

Download parenface.el and then paste in the following snippet and you’re good to go. Don’t forget to customize the paren-face colour by doing this: M-x customize-group faces

Here’s a before and after shot (I’m using snow3 as the paren-face colour, the default provided by parenface.el is DimGray):

before and after enabling parenface for js-mode
before and after enabling parenface for js-mode

I’m not sure how useful it is to hide the ‘var’ and ‘function’ keywords. The cool thing is that all you have to do is alter the regex to suit your preferences.

If you like these kinds of snippets, check out Emacs-SOS, a StackOverflow search for emacs.

Categories: Software Development, Utilities

Restarting an Express web server using grunt-contrib-watch

I found some code for express livereload and for assets that change but I didn’t find anything that was good for restarting the Express webserver whenever a web server file changed. I’m very used to Django’s workflow where you can leave the dev web server running and it will reload whenever you change a Python file.
Continue reading “Restarting an Express web server using grunt-contrib-watch”

Categories: AngularJS, Portfolio, Software Development

Writing an AngularJS Tutorial, First Draft is up

The state of the AngularJS tutorials and API docs is not that great. I’ve had to look through two books and many tutorials just to understand the basics and instead of simply complaining, I decided to do something about it.

So here it is, my Learning AngularJS tutorial. It shows you how to setup an AngularJS project, what you need for testing, how to create a controller and how to use some of the more common directives, such as ng-repeat, ng-click, select, ng-bind, and ng-model.

The repo contains an HTML version and an ODT (OpenDocument text) version. There’s also the org-mode file used to create those versions. More importantly, all the code in the tutorial has been done in a literate programming fashion. Whatever you see in the tutorial has been assembled together and fully tested. All of the code is in the repo.

Update July 2017: You can check out the differences between Angular 2/4+ vs AngularJS 1.x here. I am planning on writing another tutorial using the latest version of Angular using the same literate programming style.