Upgrading WordPress blogs

Software Development
Once in a while you must do this and, if you end up lazy for years like me, may even feel nightmares about upgrading from version 2.x to version 4.x, luckily upgrading Wordpress is one of the easiest things you can do: Making a backup It's always wise to backup your site before you make such a change. Don't worry, you don't need to backup absolutely everything, but check which things you need to backup depending on your needs: 1. Your posts and comments: which is as easy as going to admin > Tools > Export and save an XML (maybe JSON in future?) file with all the relevant content. Whatever happens now, any wordpress version should be able to recover your most relevant data. 2. Your wp-content: usually you…
Read More

Quick introduction to SVN

Software Development
SVN or Subversion is a source control repository technology that allows to save code statuses on a centralized server from which the developers can save the current status of their project, merge with what others devs have been doing, create branches of a project to develop new features or solve bugs in an isolated space and finally merge back to the trunk to include the changes into the next release. SVN also has some clients that connect to the centralized repository and help you committing changes into it or getting the latest changes from it: one of them is Tortoise. Getting a Repository You can use Windows explorer to handle everything, so getting a project from the repository is as easy as creating a new folder anywhere in your computer,…
Read More

AngularConnect 2015 London

Software Development
So I’ve been at the AngularConnect Conference these two days and these are some of the things I got from it: TypeScript You know something has become popular when all the speakers using javascript (and in this conf that was around 95% of them) use it. TypeScript is a language made by Microsoft that allows you to use classes and interfaces in javascript (and some other things) and then can be compiled into plain javascript. The reason for it to become that popular is that being able to create interfaces or classes is crucial when developing big apps, I have been finding it increasingly difficult to deal with the codes complexity as my company's project has grown and was starting to worry as it is to grow more, definitely, I…
Read More

First steps with Protractor

Software Development
Once installed in your computer, it's time to start messing with it :) First of all, we will use their websites tutorial test. Create this spec.js file: [sourcecode language="js" wraplines="false"] // spec.js describe('Protractor Demo App', function() { it('should have a title', function() { browser.get('http://juliemr.github.io/protractor-demo/'); expect(browser.getTitle()).toEqual('Super Calculator'); }); });[/sourcecode] That's just a basic test. Then create this config file to set up Protractor: [sourcecode language="js" wraplines="false"] // conf.js exports.config = { framework: 'jasmine2', seleniumAddress: 'http://localhost:4444/wd/hub', specs: ['spec.js'] }[/sourcecode] Starting the webdriver manager To make it run you need to open the console and run the webdriver manager, so open it and exec: webdriver-manager start Executing the tests Now that the webdriver manager is running, open another console window, move to the folder where you created those two files and exec this:…
Read More

Installing Protractor

Software Development
First of all, make sure you have Node.js installed in a newer version than 0.10. Open cmd, exec: node -v If it's not the right one, go to node.js page and get the latest .msi for Windows. Install Python You are going to need to install Python 2.7, just get the installer from Python's download page and follow the steps. To make your life easier, you will need to add python as an environment variable, you can do this manually or check the option "Add python.exe to path" at the "Customize install" screen during the installation: select "Will be installed on local harddrive". Restart your cmd command window (close and open, changes on environment variables may not be effective if not). Note: You may need to restart your computer at…
Read More

Using Google Tag Manager with AngularJS

Software Development, Web programming, Web statistics
One would expect that being Angular a Google product and Google Tag Manager another of their products combining them would be quite simple and straightforward, but I personally had my doubts and not much documentation on how are we supposed to make them work. Should I just paste the code as usual or will that get into conflict with Angular? Is it going to register "page views" whenever I change the routing or not as it's not a standard page view? I checked some things and here are some of my results: Adding Google Tag Manager snippet into the page First of all, I didn't find any problem with just copy-pasting the code before the /body closing tag, but I wanted to angularize it and have everything in one piece…
Read More

Spying with Mocha and Sinon.js

Software Development
Sinon spies Spies on sinon are redirected functions that will notify of any call to them. Let's see an example: [sourcecode language="js" wraplines="false"] var myGreatObject = { myAwesomeMethod: function () { console.log(1); //do something } }; it('test spies', function () { myGreatObject.myAwesomeMethod(); // 1 //Now let's reconvert it into an spy: myGreatObject.myAwesomeMethod = sinon.spy(); console.log(myGreatObject.myAwesomeMethod.called); // false myGreatObject.myAwesomeMethod(); console.log(myGreatObject.myAwesomeMethod.called); // true console.log(myGreatObject.myAwesomeMethod.callCount); // 1 myGreatObject.myAwesomeMethod(); myGreatObject.myAwesomeMethod(); console.log(myGreatObject.myAwesomeMethod.callCount); // 3 }); [/sourcecode] I think that's a good example of how spies work in Mocha+Sinon. We have an object and we can make use of it, as usual. We then redirect the object's method to an spy, this is, the method "myAwesomeMethod" is actually a pointer, so we point to a different function, that's all. If we check if the spy has…
Read More

Configuring Karma to test Angular apps using RequireJS

Software Development
Installing and configuring a testing environment for an Angular application hasn't been very straightforward for me but here are the steps I took (the right ones, at least). Configuring Karma First of all, we need to have installed and working: Node.js + Karma + Mocha + Chai + Sinon + Karma-RequireJs (the plugin for Karma, not the standard library). Once that works, we still need to configure it all to test our app, which is a big angular app and uses RequireJS to load its modules. First of all, we can configure Karma by executing "karma init" on the console (make sure you do that on the main folder of your project!!). That will give us a config file with the basic config done. We wanted to use Mocha, Chai…
Read More

Node.js

Software Development
Node is a javascript based server that allows to run javascript based applications in your computer without having to open or use any browser. This means that javascript applications can be run as desktop apps. You may now wonder why would anyone want to do that, but in any case, I'm not saying you have to build any JS app, actually, there are plenty of them already developed that you can benefit from, you only need to install node.js and start installing and running them. Those tools by the way, are mainly helpers to build your websites... in javascript. Which has a lot of sense, as many applications are now going into Knockout, Ember or AngularJS, which means client-side presentation apps made in javascript. So we are going to have…
Read More

Installing Node.js with Karma and Mocha for Visual Studio

Software Development
Node.js Please download the installer (.msi) from their downloads page. There's also an .exe but it didn't work very well to me. You need to install it as an admin, so open cmd as admin then go to the folder where the msi is downloaded and exec it (just write its name). That should install node. Testing that it worked Before going forward we can check that the install was successful, to test node, on the same cmd just type "node -v" and press enter, that should display its current version. You can also write just "node" to open the program. Now write "1+2" and press enter, that should output a 3. Ctrl+C to close node. (more…)
Read More

Configuring local website domain and SSL using IIS7

Software Development
Creating your website This tutorial is not really about how to add your website to IIS, but just as a quick reminder: Open IIS, expand your Computer icon, right click on "sites", click on "Add new site..." and select the folder where it's placed. Remember that if it's a .Net website you may have to set the right Framework at the App Pool. Setting a website's domain Now that we have our website running but that we need to access it using localhost or 127.0.0.1, maybe using some port to have multiple websites like :8080 or :9999, you may prefer to set a domain and get rid of the port. Select your website on the left panel, now look for the "Bindings" option on the right panel and click it,…
Read More

How to build .Net projects manually

Software Development
We can build .Net projects manually by making a call to the Microsoft's builder engine called MSBuilder.exe, which comes with Visual Studio so it should be placed around some folder there depending on the version of Visual Studio that you have. It is already integrated into Visual Studio, but if you want to call it manually you can make a call to it using a command line and sending which project to build and its options. As writing that each time we want to build would be hazardous and time-consuming it is better to create a script to do all the stuff just on executing it. This way, also, we can prepare different scripts with different types of builds: dev, staging, production, ... Here you have an example of what…
Read More

Continuous Integration Summary

Software Development
Every time that somebody commits any change, the entire application is built and a comprehensive set of automated tests is run against it. If build or tests fail, the development team stops and fixes it immediately. The goal is that the software is in a working state all the time. Check In regularly so that changes keep small and less likely to break the build. Use proper log descriptions on check ins. Never Check In a Broken Build as that breaks the continuous integration. Always run all Commit Tests Locally before Committing or get your CI (Continuous Integration) Server to do it for you. Wait for Commit Tests to pass before moving on. If commits are done frequently any crash should be a small piece to fix, if left unbroken,…
Read More