Categories: Portfolio, Software Development

node-oauth-libre

Update: node-oauth-libre 0.9.15 ALPHA is out, please download and test and report any issues with the new promises support.

In the last month I was looking for a Node.js library for¬†authenticating with APIs that use OAuth 1.0a or OAuth 2.0, and found a pretty good library: node-oauth. It was great but it would have been nicer if it had promises instead of callbacks, and maybe if the OAuth 2 class implemented more methods. I started to worry that the library didn’t seem maintained, there were lots of issues and pull requests that are still waiting for a response or to be merged into the code.

I’ve also been reading Free as in Freedom and The Cathedral and The Bazaar and the hackers of each book, Richard M. Stallman and Eric S. Raymond, both took other projects and improved them and contributed back their changes and improvements to the community. With their maintenance, the projects (Emacs and fetchmail) had vibrant developer and user communities.

So I have decided to basically adopt the node-oauth project under the new name node-oauth-libre. This blog post is the announcement that I’m doing this and yes that means I’ve really forked the code. The node-oauth-libre project uses the GPL version 3, with the original code and patches to the original project licensed under the MIT license.

Continue reading “node-oauth-libre”

Categories: Software Development

grunt2gulp 0.0.2 is out

There’s some fixes in there and I spent some of the weekend improving the linter to catch the case where custom tasks are being loaded using loadTasks when converting Grunt files to Gulp.

View the release notes.

Download it here: npm install grunt2gulp

Remember if you’re reporting an issue,¬† please include your Gruntfile and any messages displayed by Grunt or the grunt2gulp program such as an error or stack trace. This makes it much faster for me to track down the issue and to test it with grunt2gulp and Grunt.

Categories: Software Development

Lessons from “Producing Open Source Software”

The free book, Producing OSS / Producing Open Source Software, is one I’ve referred to now and again when thinking about how free/open source projects should be run and lately I’ve been thinking about how a big company like Red Hat works when they’re based around free/open source projects.

Here are some choice quotes that I think can serve as useful lessons for open organizations.

Continue reading “Lessons from “Producing Open Source Software””

Categories: Software Development

VirtualBox Helpful Links

I was setting up some virtual machines with VirtualBox in the last few weeks and stumbled upon problems that I’ve encountered before.

Here are some helpful links for when you’re setting up a virtual machine in VirtualBox:

Continue reading “VirtualBox Helpful Links”

Categories: Software Development

grunt2gulp.js: JavaScript to CoffeeScript?

grunt2gulp-logoSo I don’t know if anyone is actively following the development of grunt2gulp.js but I decided to be a little more active in working on it. A week ago at work someone mentioned CoffeeScript and it’s a good time to check it out. I initially used it a long time ago when it first became available and I liked the result but it didn’t offer a huge improvement on the little JavaScript that we were writing at the time (under 200 lines of code).

However, grunt2gulp.js is starting to get…hairy. It’s about 400 lines (or more?) now and it’s time to split things up into separate files at the least.

I created a new branch called zesty-coffee and it’ll be using CoffeeScript. I’m using the npm preinstall script to compile the files into the bin/ script. Next step is making sure the conversion is complete and works correctly and after that I’m going to create a Gruntfile.js for linting the generated grunt2gulp.js file and for generating the JSDocs from it. After that we’ll have a good working example of a Gruntfile that can be converted to gulp within the repo so it’s easier to dog-food grunt2gulp.

The generated JavaScript from CoffeeScript is very nice and readable so debugging isn’t a chore. The list comprehensions in CoffeeScript do encourage a slightly different coding style and the lighter syntax for creating anonymous functions (a.k.a. blocks a.k.a. lambdas) encourages an almost functional style.

Check out the zesty-coffee branch on github.

Check out grunt2gulp on NPM.

Check out grunt2gulp on GitHub.

UPDATE: I manually converted the code from JavaScript to CoffeeScript. If you’re looking to automate your conversion from javascript to coffee, you can check out js2coffee.

Categories: AngularJS, Software Development

Screenshots with Selenium WebDriver

Here we learn to use Protractor with Selenium WebDriver providing the functionality to take screenshots.

Update: Andrew Batz has kindly put together an NPM-installable package with the code in this article. Click here to check it out or download it using npm install screenshot-protractor

As I work with SPAs (Single Page Applications) it becomes more obvious that some parts of a web app can only be inspected visually. As part of an end2end test or user acceptance testing, manually checking screenshots is still faster than manual testing. Screenshots at different steps of a process can be put together into a presentation or PDF and presented to clients or other stakeholders to show them that not only is the backend code working, but the frontend looks and feels right.

So here’s a snippet for taking a screenshot with Protractor, which is designed for AngularJS, and an end2end test that uses Jasmine and Protractor:

https://gist.github.com/rudolfolah/60b03873977551bcf68b

When to take screenshots during an end2end test:

  • to inspect the layout/styling
  • to inspect how the site looks across multiple browsers
  • to verify with client/stakeholders that we’re building the right thing
  • to share with other developers when debugging an issue
Categories: Software Development

Django Unit Testing with Mocks

Here I’m going to talk about how to use mocks when writing unit tests for Django, the Python-based web framework. Using Django test mocks has really opened my eyes on how to write much better unit tests. Previously, and in some cases still do when using 3rd party services, I would use fake API servers to serve fake data for testing end to end. With the mock library, I can easily mock out server responses in Django tests.
Continue reading “Django Unit Testing with Mocks”

Categories: Software Development

Emacs angularjs-mode v1.0 release!

I’ve finally had some time to upgrade Emacs angularjs-mode with some expandable code snippets (thanks to YA Snippets) and added auto-complete mode dictionaries.

What I’ve found a pain when coding AngularJS is that you really need your environment setup well for it before you can get a lot done with it. Having angularjs’s javascript files installed, a basic index.html, a Gruntfile, a Karma and Protractor configuration saves a lot of time. But even with a basic project structure, you still need to be faster when writing new controllers, directives and services. Auto-complete-mode and snippets can help with that.

All of the top-level definitions in the AngularJS API are included in the auto-complete dictionaries. The dictionary for angular-html-mode contains all the common directives.

Use Emacs angularjs-mode for faster angularjs coding! Now with 100% more auto-complete and snippets!

Categories: Software Development

Three Reasons Why Your Software Is So Far Behind Schedule

Reading this article on TechCrunch listing a few reasons why software development falls behind schedule.

Yes. Many times yes.

However, to give a more detailed answer and one issue…

The first reason is true. Technical debt can be measured in onboarding time. If you don’t have an up-to-date set of documentation describing how to get up and running and your system requires lots of extra twiddling and fiddling around, then you have a lot of technical debt. When you do onboard a new developer, make sure they fix some of that and simplify the process further. By the time you get to onboard employee M + N you should have less onboarding time and less technical debt.

As the article points out, if Facebook with so many complex systems and many projects can allow for real useful code to be deployed within a day, your less complex system with 1/100th of the servers and complexity should take a few hours to be setup and allow you to deploy useful code.

With respect to the second reason I agree that you should know what you’re testing and why, elaborate test suites indicate that you’re testing the wrong thing or your tests are brittle. For example, I had to write unit tests that mocked out 3 dependencies and had methods called “add” and “remove”. Guess what I was testing? That’s right, whether the class would add or remove the object to an array/list/some other data structure. It didn’t require any special business logic or require elaborate rules and conditionals, it was a straight addition or removal. My test was essential the same as a unit test for a linked list or array data structure’s insert/push/append/delete methods. Those kinds of tests can be safely removed.

The third reason I’m iffy on. On the one hand, yes it makes sense to use AWS or Google App Engine or some other cloud service. On the other hand, those can be expensive and sometimes there are laws in your country that require keeping data within the country. That leaves three options: expensive local cloud server, private servers (VPS or co-located), private cloud. In Canada our web hosting services are always more expensive, same with our domain registration. Both private co-located servers and a private cloud require maintenance and/or lots of cash. Some Canadian companies aren’t limited and can use AWS or Google App Engine…but they end up not using it to the maximum ability because the company introduces some other limitations that defeat the purpose of using cloud-based hosting such as not designing the architecture to be scalable to take advantage of the cloud. You can see this in consulting and contracting firms where every single project requires a separate server as if the client you’re working for can’t envision their website growing exponentially…how depressing.

Categories: Portfolio, Software Development

grunt2gulp: a tool for converting Grunt task-runner files to Gulp.js

grunt2gulp is a tool for converting Gruntfiles to Gulp.js files.

There’s a new task runner around, Gulp.js, and it’s supposedly very good (haven’t had a chance to try it yet) but there are still many projects using Grunt. If you want to try out Gulp on an existing Grunt-based project, it can be tedious to start rewriting things because Gulp is imperative and based on the idea of streams while Grunt is more declarative.

grunt2gulp a tool for converting Grunt to Gulp.js files
Click here to check out the source code for grunt2gulp on Github.

grunt2gulp.js helps make the transition from Grunt to Gulp. I used the files on this blog post as a test case, and I also used a Gruntfile from a strongloop project as a test case. Both test cases are included in the examples directory.

What I like about gulp from what I saw is that it’s a wrapper around orchestrator and vinyl-fs and it’s straight-forward. Grunt is monolithic from what I’ve seen and I think moving to Gulp will be a good move over the long-term. However, I think there is still a place for a declarative sort of task configuration file.

grunt2gulp

In any case, if you’re trying to move to Gulp from Grunt, check out grunt2gulp! Feedback would be great, and patches would be awesome.

Into Frontend Web Dev? Check out some of these articles

2017 Update: grunt2gulp is still being used but it seems now that people are moving from Grunt and Gulp to webpack (or Rollup.js). Gulp is still a very cool build tool to use. However, I recommend that people move away from Grunt as soon as possible on to more modern tools like Gulp and Webpack and Rollup.js.

2019 Update: it looks like webpack is the winner as the most popular JavaScript frameworks, Angular and React, are using it.