Skip to main content

· 3 min read
Richard Haar

There are a huge amount of datasets available online, you can find many on https://dataportals.org/ including data for the city of New York. They provide a dataset containing details on over 1.8 million crashes.

Plotting the data#

Now each crash contains a Latitude and Longitude value for where the collision occurred. And with 1.8 million collisions, it should be possible to map New York roads using this data.

· 8 min read
Richard Haar

NPM#

NPM hosts over 1.7 million packages at the time of writing, with over 35 billion downloaded packages in the last week alone. Originally the package manager for Node.js, but taking over as the package manager for all of JavaScript. The cool thing with Node.js is that you can compile some C++ to a node addon, making it available for use in JavaScript, so you get the benefit of native code.

So for my first publicly uploaded NPM module, I wanted to create a Cyclic Redundancy Check (CRC) module that conformed to the AUTOSAR (AUTomotive Open System ARchitecture) spec but written in C++.

· 5 min read
Richard Haar

Browsing without a GUI#

Puppeteer allows you to control a Chrome or Chromium instance using NodeJs. The real benefit is running Puppeteer as a headless browser, meaning you don't have any GUI to interact with but you can navigate pages, interact with buttons and take screenshots all from your node script. For example:

 const puppeteer = require('puppeteer');  async function screenshot() {     const browser = await puppeteer.launch({});     const page = await browser.newPage();     await page.goto('https://www.google.com');     await page.screenshot({path: 'GoogleOn' + new Date().toDateString() + '.png'});     browser.close(); }  screenshot();

· 6 min read
Richard Haar

JavaScript lets you mix and match types quite happily, and in most cases the result might be exactly what you expect:

> 'Total : ' + 100'Total : 100'> '12' * 336

However you might not get what you expect:

> '15' + 1'151'> '15' - 114
> if([]) {... console.log('hello')... }helloundefined> [] == truefalse

· 12 min read
Richard Haar

Multivariable linear regression is all about taking in a set of data points (x0, x1, …,xn, y) and to be able to predict y values for some other data points (x0',x1',…,xn'). I'm giving an example here on how to do so in Python as well as computing the coefficient of determination (R2) to see how well the predictor variables model y.

All the following code is available with an MIT licence here.

· 4 min read
Richard Haar

In C++17, the std::variant was introduced alongside the std::visit function which allows you to implement the Visitor pattern rather easily. To begin with I'll explain how to use the std::variant and how it fit's into the Visitor pattern.

· 3 min read
Richard Haar

As we all know StackOverflow can be an intimidating place for new users, as any mistakes are quickly picked up, critcised and questions are closed. You also see the same group of people quick to answer questions (See here for a user answering over 85,000 questions in SQL.) But what if I told you it's possible to hit the front page of StackOverflow within a month.