How to write a bug report

You found some behavior you think isn’t right in a piece of software and you are thinking about reporting a bug.. Wait, stop, read this first as it will save you time in back/forth with the developer.

Is this actually a bug or desired behaviour?

Ask on the mailing list for the software first. Most developers do things for a reason.

Does a bug already exist for this?

Look through the bug tracker / issues for this software, it’s possible a bug already exists. If so you can throw a +1 at it, +1 is a universal “bump” to show your interest. You can also track issues on tools like Github.

Are you reporting the bug in the right place?

Etherpad, as an example doesn’t take plug-in bug reports on the core bug tracker. Plug-in bugs should be reported on the individual plug-in bug trackers.

Want it fixing quickly?

Create a bounty. You will be more likely to get a fix in a timely fashion. This is especially true for feature/enhancement requests.

Provide information

Bug reports like “I can’t click on anything” are completely useless. Include information such as:

  • Operating system (IE Windows)
  • Your browser (IE Firefox)
  • Your browser version (IE 24.2)
  • The page you are on (IE https://23to2.com/foo?241bar)
  • The version of software (IE Libre Office 9)

If you are running a server / client setup you should provide the details for both the server and the client.

Provide Steps to replicate.

Provide how you got the problem to happen.. IE

  • click on page X
  • click on element Y
  • do Z.

Don’t be a leech.

When you file a bug developers will look at your repository and if this is your first ever bug report and you don’t contribute anything back to any other projects it’s likely you will be ignored.

Provide Expected behavior

It’s useful for the developer to know what you actually expect to happen IE:
Expected behavior: Z element gets big.
Actual behavior: Z dissapears.

Be polite

Actually, I don’t care about this. I’d rather you were clear.

Other things to consider..

Is this a security issue? If so use the software packages responsible security disclosure. Can’t find it? Post to the mailing list or bump them on IRC.

Adding i18n to a Cordova App

i18n (Internationalization) in applications roughly means adding support for translations and other languages.  In this blog post I will talk you through a general approach to implementing i18n in Cordova Apps.  If your app isn’t open-source, move along, the 90s is on another website.

As Cordova apps are written in HTML/CSS/JS we can easily leverage existing web platforms and services to provide i18n at break-neck speeds.

TLDR Services/frameworks used:
* Translatewiki to provide translations
* Marcel’s html10n i18n implementation
* Handlebars for templating
* Etherpad implementation of detecting locale/language also written by Marcel

Implementation steps

* Ensure your app fulfills Translatewiki’s requirements (Open source etc)
* Talk to Translate / Internationalization team at Wikimedia foundation before creating Gerrit commit
* Gerrit commit to TranslateWiki adding support for your App.
* Include handlebars and html10n libraries in your app
* Modify your HTML putting markup in handlebar script tags
* Move your text strings into locales files.
* Include a handlebars html10n render helper
* Use the Etherpad implementation of detecting locale/language* Give someone at WMF access to commit to your Repo

Sit back and enjoy..

Once you have completed your implementation and it’s approved by the WMF the WMF translation team will translate all of your strings and commit them back to your repo. You might want to provide the WMF team with the ability to see each of your strings in situ in a browser, this means providing a mechanism to fake Cordova events..

Summary

This implementation is basically a straight copy of how we handle i18n in Etherpad, it’s pretty robust and clean to implement. All in all a complete refactor of the NFC Ring Control App while implementing i18n took about a week of full time commitment, well worth doing as now the larger community can provide translations which if I was to do hans solo would take months 🙂

Object measurement with webcam

Shut up and show me the demo.

I have been experimenting with using a webcam to measure an objects size, width and height.

It works by comparing the size of a user defined box to the size of a magnetic strip (which is also user defined). I tested it against a ruler and it seems accurate but obviously the larger the object the more accurate it becomes. Right now it’s setup to measure the size of a ring finger.

As this is a weekend project I published the source up on github. I haven’t decided on a license yet so for now don’t adopt it in any commercial applications but do feel free to contact me to chat about funding further development.

I use getUserMedia / Canvas to do most of the interaction between the webcam and the browser and I’m using PaperJS for drawing the boxes onto the canvas. The actual math is really simple

// Takes a scale value and tries to figure out the mm diameter of each ring
function scaleToRingSize(widthPx){
  return (85.72500 / stripWidth * widthPx).toFixed(2); // 85.72500 being the width of a magnetic strip in mm
}

The fingers.js also contains code for converting ring sizes in mm to the nearest smaller ring size. IE if your ring size is 22mm it will give you a ring size in US/EU that is 22.2mm instead of 20mm.

I’m researching using Tracking.Js with some custom OpenCV maps to do better object detection, I know this is possible but right now the algos are a bit buggy and I’d need a lot of positive images to create a good training set. If I could do some object tracking in theory I could auto detect the strip / target object size and automate / realtime the whole measurement process and in theory I could do ask a server to do real time object detection, but that’s for another day..

The measurement app might not quite fit on your page, this is because it’s 800px x 600px with absolute positioning, I guess I could make it use relative positioning but right now I’m not interested.

The tool will work in all browsers that support getUserMedia which is IE11, FF 17, Chjrome 21, Safari 7 and Opera 12, iOS Safari, BBB 10, Opera Mobile 12. For more browser support queries see getUserMedia browser support. Obviously if you are still using IE then you have probably made many other poor life decisions and you are beyond my help. Obviously because I’m using JS / CSS the app will work on a mobile and desktop webcam so you can in theory measure objects whilst on the move.

I had to worry about the overheads of the large javascript fabric.js library so I decided I didn’t want the additional overheads of jQuery. It’s entirely written in JS (with obv some CSS/HTML) throw into the mix. I could probably refactor it down to just JS without too much headache and this would give site admins the ability to do something like:

<script src="measurer.js"></script>
var measure = new Measurer();
measure.create("targetDiv"); // can do it like this because getUserMedia is limited to one instance of browser/OS.
measure.on('success', function(measurement){
  alert("Got a measurement of", measurement);
  measure.destroy();
});

You will need a card with a magnetic strip on the back, ideally a credit card as these are guaranteed to be a universal size.

Final thoughts: None of the images are saved to a server but as you know these images are being passed through the Internet which means your ISP is sending a copy of them to the NSA. I strongly recommend against using this tool to measure any part of your anatomy.

Script to get an email when a new property in your area is registered on Gumtree

This script will send you an email when a new property in your area comes up on twitter.. Replace shoreditch with the area you want and add in some email addresses. You will also want to modify the price.. at current it’s set to a minimum price of £150 per week.

It was written to solve a problem where we would be out looking for flats/apartments and we needed to be one of the first people to respond. This script gave us the edge that meant we could secure a good property in the limited window of time we had.

You need to be familiar with NodeJS to use this. Execute it as a cron job or however you want.. It will store results to a database called db.db

The code was written by @pitapoison – He is an awesome developer, you should follow him. We literally made this over a cup of tea and a bowl of pasta, it took 15 minutes and saved many hours.

I think it’s interesting to see the approach we used to solving a housing problem, something that affects everyone yet so few will take the time to create a piece of software that gives them the edge.

var request = require("request");
var parser = require("xml2json");
var db = require("dirty")("db.db");
var nodemailer = require("nodemailer");
var transport = nodemailer.createTransport("Sendmail");

db.on('load', function() {
  request('http://www.gumtree.com/rssfeed/single-room-flatshare/shoreditch', function (err, response, body) {
    if(err){
      throw err;
    }
    
    var json = JSON.parse(parser.toJson(body));
    
    var items = json.rss.channel.item;
    
    items.forEach(function(item){
      try {
        var title = item.title;
        var price = /([0-9]+)pw$/.exec(title)[1];
        var content = item["content:encoded"].replace(/\&\#[0-9]+;/g," ");
        var link = item.link;
      
        if(price < 150){
          return;
        }
      
        if(db.get(link) === true){
          return;
        }
        
        db.set(link, true);
      
        var emails = ["person1@example.com", "person2@example.com"];
        
        emails.forEach(function(email){
          var mailOptions = {
              from: "gumtreebot@example.com",
              to: email,
              subject: "GUMTREE: " + title,
              text: link + "\n\n\n" + content
          }
                    
          transport.sendMail(mailOptions);
        });
      
      } catch(e){
        console.error(e.stack || e);
      }
    });
  });
});