Initialize a Typescript Interface with JSON

Posted by in Software

TL;DR: You can initialise a typescript interface using JSON objects. On my quest to load and save objects as JSON, I found that you can convert a JSON object to an interface via something called type assertion. Basically, if you have an interface:

you can load a JSON object via JSON.parse(json) straight to an instantiation of the interface. Then, you can use the said instantiation in e.g. a component. Now, all is nice, but what if you want to initialise an instance of the PathInterface interface? That’s simple. You…read more

Check Duplicated Paths with LoDash (and Angular 2)

Posted by in Uncategorized

One of the things I’m looking at is to be able to create a list of paths I’d want to scan. The first iteration had blind addition to the list. However, this would make the user’s responsibility to manage the duplicated paths, which is not really nice. Therefore, I think it’s a good thing to add some sort of path duplication detection in the code. The pseudo-code would be something like:

In this case, if we have a non-null item, then we already have something in the list. Otherwise,…read more

Angular 2
Refresh Bound Variables from Callback

Posted by in Software

TL;DR: Use ChangeDetectorRef‘s detectChanges() at the end of your callback code. While developing my electron.js app, I’ve had the following workflow: I have an input element and a button The input element is capable of editing a path The button triggers a File Open dialog

The problem I had was the showOpenDialog() accepts a callback and I couldn’t get the input field to update once the user has picked a file. Fortunately, the smart angular developers have thought of this situation too and the solution is quite simple. You…read more

Applications for EPSO/AD/331/16

Posted by in EPSO

The number of applications are: No. Section Places Candidates AC 1 Data Analysis and IT Service 30 852 9.5x 2 Digital Workplace, Office Automation and Mobile Computing 25 258 3.4x 3 Enterprise Resource Planning (ERP) 14 208 5.0x 4 ICT Security 49 418 2.9x 5 IT Infrastructure 38 595 5.2x 6 IT Portfolio/Programme Management and Enterprise Architecture 24 626 8.7x AC: How many people compete for one place to the AC (which, in turn, is 3 times higher than the reserve list) HTH,

WordPress with HTTPS on Dreamhost and CloudFlare

Posted by in IT, Tutorial

Today I’ve got my blog work over HTTPS, including admin. Woo-hoo! Below are the steps I used to do it. Prerequisites My configuration is as follows: Hosting on Use CloudFlare free account WordPress 4.7.1 at the time of writing Initialisation From the Dreamhost Panel, select Domains > Secure Hosting: You’ll be presented with a panel to select the type of certificate. I chose to use Let’s Encrypt because it’s free: Once you select Let’s Enctypt SSL, you’ll have to select the domain, accept the T&C and click Add Now:…read more

Load FontAwesome Fonts with Webpack 2

Posted by in Software

TL;DR:: Add the (s)css dependency to your main (s)css file and specify where to find the fonts too. Then use the proper loaders in your webpack.config.js file. The past few days I had trouble loading the font-awesome fonts with webpack. I tried quite a few solutions: Using the font-awesome-sass-loader Manual solution webpack + font-awesome test Looking at SO (How to configure font file output directory …) and so on… Nothing seemed to work propoerly. I either had the fonts ignored or got errors of files not found. Finally, I have…read more

Copy File from Local Desktop to Remote Resktop Connection

Posted by in IT

TL;DR: Drag-and-drop doesn’t work. Copy&paste does! Before yesterday, my way of moving files between my local desktop and a remote one using MS Remote Desktop Connection involved a 3rd party service like Dropbox or email. Then, a kind soul took pity on me and showed me the proper way. In his words: Drag and drop doesn’t work but copy/paste does. Simple, but veeerrryyy effective! Note I’ve only tried this so far between 2 MS Windows machines, with some large-ish (30M) files.

Multiline Regex in Visual Studio Code

Posted by in IT

Setting up a multi-line regular expression in VS code is done by explicitly matching the CR/LF characters using \r?\n. For example, if I want to find all lines starting with a [, including subsequent blank lines, I can do:


Scan Decorated Classes in Typescript

Posted by in Software, Tutorial

TL;DR: Make the decorator set a property in the class and look for it. While trying my hand at writing an ORM, I had a problem of initialising the database through a dummy instantiation of some models, without running an explicit command. In java, I can use code generation to provide a list of objects following a pattern (e.g. implementing an interface). Here, the concepts are somewhat different and I found out I can use decorators. My model looks like this:

where the @table() and @field are decorators. Ideally,…read more

Make Electron Work with Sqlite3

Posted by in Software, Tutorial

The other day I tried to integrate knex with a SQLITE3 back-end. Unfortunately, the instant I’ve tried to instantiate knex, I’ve got a lot of errors. After getting rid of them, I found that I can’t get sqlite3 to work at all, even though I’ve checked the installation and it was OK (got the binary downloaded and even rebuilt it). Uncaught Error: Cannot find module ‘/…/node_modules/sqlite3/lib/binding/node-v51-darwin-x64/node_sqlite3.node’ So, here are the steps that I did to make it work: install electron-rebuild

install sqlite3 using npm

rebuild electron with sqlite3….read more