W14Y18 – MQTT Client for OSX, Fingerprint & HTTPS, Consola and full width embedded Youtube video

MQTT Client for OSX

For those working with OSX, I suggest you to use the most powerful MQTT client I’ve found: MQTTfx. This soft is complete. You will find all the basic features (like unsecured connection, already available on most light tools) and some very useful:

  • User/password authentication
  • SSL/TLS
  • Proxy settings

You have a large choice of certificates, which covers a lot of scenarios and platforms (SAP IoT 4.0 Platform included)

View/download MQTTfx

Fingerprint Check to verify HTTPS certificates

Sometimes, it can be useful to check if you are sending data or connected to the right website (for security purposes). In my case, when I’m connecting Arduino boards or something like this with network I’m not the owner, I’m using the fingerprint check.

Let’s see how it works.

First, you need to retrieve the fingerprint for the target website/API. For this, go to the website and click on the little “lock” icon in the address bar and click on the Certificate section.

Now, scroll down while you find the Fingerprints section and copy these two values (see below the example with Github).

The last step is to check when you establish the connection, if the fingerprint is the same or not. Below, an example in Arduino

// Check HTTPS
WiFiClientSecure client;
Serial.print("Connecting to ");
Serial.println(host);
if (!client.connect(host, httpsPort)) {
  Serial.println("Connection failed");
  return;
}

if (client.verify(fingerprint, host)) {
  Serial.println("Certificate matches");
} else {
  Serial.println("Certificate doesn't match");
}
// The rest of your code...

Consola

Logs are important when you code – If you pass your day, switching between terminal windows, it’s time to get them sexy! For this, I found Consola and I fall in love with this elegant consoler logger.

npm install consola --save

And now in your code, you can log info like this:

const consola = require('consola')

// See types section for all available types
consola.start('Starting build');
consola.success('Built!');
consola.info('Reporter: Some info');
consola.error(new Error('Foo'));

Give a try here: https://github.com/nuxt/consola

Full width embedded Youtube video

If you want to embed your Youtube video on your blog (WordPress or other), it’s possible with some custom CSS.

First go to the video link you want to embed and click on Share > Embed and get the whole iframe tag.

For example: <iframe width="560" height="349" src="http://www.youtube.com/embed/<YOUR_VIDEO_ID>" frameborder="0"></iframe>

Now, wrap the iframe tag inside a div and add the css.

<div class="youtubeVideoContainer">
    // the iframe tag here
</div>

.youtubeVideoContainer {
    position: relative;
    padding-bottom: 56.25%;
    padding-top: 25px;
    height: 0;
}
.youtubeVideoContainer iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

That’s it. Your video will use the full width of your post.

W04Y17 – Git, create a new repository from a current branch, disable HTTP logs in Express, Android mass storage and kill process on specific port

Create a new repo from an existing branch

As you know, it’s strongly recommended to create a new repository if a branch depends to another branch in your project… Basically, if you need to clone a repo twice and checkout each to a different branch to launch your project, it’es very bad!

So, the simplest method in three steps to create a new repo from a current branch is to:

> create your **new_repo** in GitHub
> cd to your local branch 
> git push git@github.com:youraccountname/new_repo +old_branch:master

Now, your new GitHub repository is up to date. The master branch corresponds to the branch in your old repo with all history preserved which is a very good point!

How to disable HTTP request logs in Node/Express.js

When you launch your application built on Node/Express, you’ll probably see a lot of logs for each resources (css, images, js, etc…)

GET /resources/styles.css 200 0ms
GET /js/lib/jmyawesomelib.js 200 0ms
etc...

The solution is to move the logging plugin below the resource plugin in the app init! or comment your morgan module (works on Express.js 4)

//app.use(morgan('dev'));

No more logs!

Mass storage troubleshooting

I figured some problems lorsque je branchais my Google Nexus 5X to my Macbook (also on a Windows machine too). It was impossible to do a mass storage to retrieve the phone content (photos, videos, downloaded files, etc…). I tried all the solutions found on forums and the only software that saved my life is Android File Transfer by Google for OSX.

Download Android File Transfer

Kill process running on a specific port

To kill a port that is running on a specific port, you need to execute the following commands. First, get the list of process running with corresponding ports and info:

netstat -a -o -n

Now, you get a list of process running on your machine, you only have to pick the PID corresponding the port you are looking to kill and replace 8080 below.

taskkill /F /PID 8080

Successfully killed, bye bye 🙂