DNS for Azure VM

I needed several VMs in Azure for testing purposes and I required a semi-stable HTTP server on each of them. Normally I give the VM a public IP, but since this was for testing purposes I did not want to waste any of my public IPs.

Azure VMs can still be accessed from the outside even without a public IP, but the IP changes during each reboot (at-least). Azure allows one to setup a DNS address for the dynamic IP to be used instead of the IP, which is awesome.

This can be done by:

  • Selecting the VM’s resource group under Resource Groups in the Azure portal.
  • Select the Public IP address associated with the VM.
  • Select Configuration and then specify the optionally DNS name.

Depending on the location of the VM, the DNS will look something like this:

xyz.westeurope.cloudapp.azure.com

Obviously, one must choose a name which does not conflict with another DNS in the Azure cloud.

HTML5 RDP Client

The Remote Desktop Protocol (RDP) is a protocol used for remote desktop connections primarily against PC’s running Windows, or VMs in the Azure cloud. The protocol is similar to VNC in many ways.

The HTML5 application I am currently building required the ability to seamless connect to a desktop computer using RDP. HTML5 however does not support RDP and cannot easily be implemented in the browser due to:

  • HTTP cannot be used for cross-domain connections.
  • WebSocket is not implemented by the remote PCs that I need to connect to.

The solution I found was to “tunnel” an RDP connection through the server hosting my HTML5 application. Several solutions exists, one being: Myrtille.

Myrtille is basically an ASPX application hosted in IIS, which provide a WebSocket interface and HTML5 remote desktop client (it also support HTML4 using HTTP which is slower). Myrtille, upon getting a connection request from a web client, tunnels the request back and forth through a Gateway service which comes with Myrtille.

The gateway utilizes a free implementation of RDP callsed FreeRDP, specifically wfreerdp.exe on Windows. The gateway service spawns a wfreerdp.exe process which does the actual RDP connection to the remote desktop computer.

When the connection is made, mouse and keyboard input is sent from the HTML5 client in the browser, through Myrtille to wfreerdp. Image data is transmitted from wfreerdp back to the HTML5 client.

rdp.png
The RDP client in action running inside my Chrome browser

MariaDB: Access from 0.0.0.0

I recently installed MariaDB, a MySQL fork, on a Linux VM in the cloud for testing and development purposes. I really struggled with getting proper access from my dev machine to the installation in the cloud.

Simply put, I just wanted a totally open SQL database for deving and testing, nothing production wise was needed.

MariaDB is by standard pretty secure: a good thing, and does not allow remote access: also a good thing.

Firstly, one has to edit the proper .cnf file under /etc/mysql/* and set the bind-address from 127.0.0.1 to 0.0.0.0. MariaDB by default listens only on the loopback interface, thus making it impossible to reach it from outside either LAN or WAN.

Next up, one needs to restart the service: service mysql restart which will apply the changed bind-address.

Now it is possible to connect from outside, TCP/IP wise, however, the MariaDB user (such as root) needs to be granted access from outside to be able to actually make a logical connection to the DBMS.

This can be done by issuing the following SQL query (in this case, for root with password xyzw):

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xyzw' WITH GRANT OPTION;

Which will grant root access level from anywhere.

To fire off this SQL, I suggest to simply login to the box using SSH and connect to the mysql CLI using:

sudo mysql -u root

and then fire off the query.

 

Method of loci

I stumbled upon the method of loci in my quest to improve my memory. Although I have an OK ability to recall information, I struggle with names of places and especially things.

The method of loci is an ancient technique invented by the Greeks I believe, where one mentally attach images, sounds, etc to known location, be it real or fictional, in ones memory. This method is also known as the memory palace technique.

The important part is to use locations which are well known for ones loci, for me this could be:

  • Left lamp-stand in my bedroom.
  • The bedroom door.
  • The dashboard of my car.
  • The desk of my work.
  • The first part of the first level of super Mario bros (where you get the mushroom for the first time).

To remember stuff, one breaks the subject into images/words/sounds that can be mentally attached to a loci. For instance, to remember the license plate number of AV28011 of a white van, I would place the following mental images in three locis:

  1. Looking to the left laying in my bed, I see a VHS recorder with an AV out connector laying on my lamp-stand.
  2. From the lamp-stand, I take the VHS through the door, where the number 28 is itched into the white paint.
  3. Grabbing the handle, I notice the number 011 hanging on a waving sign under the handle.

When trying to remember the license plate of the white van, I just need to focus on the first loci: the lamp-stand in my bedroom. I will quickly see the VHS and from there know that I have to take it through the door, thus notice the 28 itched into the white paint, and finally see the number 011 hanging from the door handle.

I just tried this technique the other day, and I was impressed by how easily I remember the license plate of the white van.

If you struggle with memory recall, try this technique.

Node on Raspberry PI

I recently re-installed a PI with NodeJS support and MariaDB support.

NodeJS is not known by apt-get (a strange beta/alpha version is present, version 0.10 or something, not what we want).

I found this guide for the job: http://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/

More or less, execute the script located at deb.nodesources using:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -

and then proceed with apt-get install

sudo apt-get install nodejs

Simply as that!

Chart.js

In the past I have used D3.js and even Highchart.js for my charting needs. Today, I decided to tryout yet another Open Source alternative: Chart.js.

Chart.js is available through npm and @typings also exists for TypeScript fans such as myself:

npm install chart.js --save

npm install @typings/chart.js --save

Chart.js can be included with the script tag, CommonJs, ES6 and RequireJS. Although for HTML5 programming I always do the legacy route using script tag (I know.. I need to move with the tech).

Chart rendering happens in a canvas, nothing fancy DOM manipulation which I really like, especially when working with ReactJS. The chart look and feel is very generic, nothing fancy here.

I really like the tool-tips though:

chartjs.png

Chart.js is also responsive, thus scaling to different screen sizes. I have yet to tryout this feature though. Apart from this, it supports animation, multiple axis, mixed chart types, and more.

8 chart types are provided out of the box. Definitely recommended.

TurboGrafx-16/PCEngine CD Emulation

Lakka supports TurboGrafx/PCEngine emulation out of the box atleast for ROMs, but the CD roms (cue/bin) requires that one find the correct bios: syscard3.bin and uploads this into the system directory on the Lakka box. No issues with this if one can find the correct syscard3.bin file.

However, I still struggled getting PCE CD emulation to work since Retroarch crashed whenever I tried to load Castlevania: Rondo of Blood.

drac_x1
Rondo of Blood for PCEngine/TurboGrafx

It took me some time to figure out what the problem was and no resources online was helpful. I finally pinpointed the issue to the .cue file of the release. Even though the .cue file was 100% correct, i.e. all .wav and .bin files were correctly referenced by the cue file with no apparent pathing issues, I had to change the cue file manually to get it to work:

  1. I removed all spaces from the filenames, e.g. “rondo of blood(j).bin” -> “rondoofblood(j).bin”.
  2. I removed all *special characters*, e.g. “rondoofblood(j).bin” -> “rondoofblood.bin”.
  3. I changed all Tracks to be of BINARY Type, i.e. WAVE -> BINARY.

I believe step 3 was what did the trick for me. Example of an WAVE entry converted to BINARY:

Before:

FILE Track01.wav WAVE
 TRACK 01 AUDIO
 INDEX 01 00:00:00

After:

FILE Track01.wav BINARY
 TRACK 01 AUDIO
 INDEX 01 00:00:00

Not sure why this works, but it does atleast on the latest Lakka x86 build.

After booting the game, no sound would play of any kind. I wrongly believe this to be due to my hack above, but no, this was simply because the emulator defaults to 0% music, ambient and effects volume, but why?!?!

Increasing the volume to 100% fixed the issue.

BTW – Rondo of Blood for PCE is better than Castlavania X for the SNES even though they share alot of gameplay elements…

Just my two cents.