Laur IVAN

Make Electron work with Knex.js

Posted by in Software, Tutorial

To make my life easier (and because I hate writing SQL statements), I thought of installing an ORM. After some search, I’ve decided to use knex. Unfortunately, the moment I integrated it into my app, webpack started generating errors like: ERROR in ./~/knex/lib/dialects/maria/index.js Module not found: Error: Can’t resolve ‘mariasql’ in ‘/…/node_modules/knex/lib/dialects/maria’ @ ./~/knex/lib/dialects/maria/index.js 59:11-30 @ ./~/knex/lib/dialects ^\.\/.*\/index\.js$ @ ./~/knex/lib/index.js @ ./~/knex/knex.js @ ./src/main.ts and warnings like: WARNING in ./~/knex/lib/seed/index.js 150:11 Critical dependency: the request of a dependency is an expression Not nice! To get rid of the errors I…read more

Electron App
Send Menu Command to Angular App

Posted by in Software, Tutorial

TL;DR: In the main process use mainWindow.webContents.send(‘cmd’) and in your Angular component (renderer process) bind it to a method with ipcRenderer.on(‘cmd’, this.open.bind(this)) (where open() is a method). I need to make my angular app work when a menu item is clicked (think: I click on “Open” and my angular app needs to perform the actual operation). The problem I’ve encountered is the menu actions happen in the main process while my angular code lives in the renderer process. Thus, I need to make the two communicate :) In my main…read more

List Columns in a ResultSet

Posted by in Software, Tutorial

In order to list all columns in a JDBC ResultSet (e.g. for debug purposes), you need to iterate through its metadata:

Note: Column numbers start from 1, not 0 (hence the md.getColumnName(i + 1) above). I usually wrap this in a if(logger.isTraceEnabled()) so it doesn’t get triggered all the time. HTH, A little experiment: If you find this post and ad below useful, please check the ad out :-)

Skip the EPSO Online Test

Posted by in EPSO, Tutorial

TL;DR:: Replace the end of the application URL from e.g. 1947_en to 1947/apply_en. These days, EPSO is in the habit of launching calls with multiple fields with a twist: each field has its own application page. So, if you just want to browse the fields for more details (e.g. Talent Screener in specialist competitions), you’d have to go through the test each time. Quite time consuming… The URL for a field is:

where [field_id] is the identifier of the call and [lang] is the language. E.g. for Enterprise Resource…read more

Electron App
Use SCSS, Luke!

Posted by in Project Management, Software

Traditionally, I’ve been a LESS supporter. The way it does mixins for example seems to me more intuitive. However, I noticed that my go-to framework (bootstrap) is now doing SASS-first and then LESS. So, one adapts… and the option in angular-cli makes things less painful. What was painful was to convert a bunch of LESS code to SCSS :/ Here are some findings relative to using SCSS in my application: Webpack does it nicely via the sass-loader You can use relative, absolute and ~ paths to refer to other resources….read more

Electron and WebPack – Live Reloads

Posted by in Software, Tutorial

I wanted to create a skeleton with Electron, Angular 2, capable of live reload while in development. I’ve settled on the following framework: Electron (d’oh!) Angular 2 Angular CLI (because it makes it easy to generate boilerplate code) SASS (SCSS in fact) Webpack 2 and Babel After a lot of trial and error (and also scouring the internet for solutions), I think I reached a nice-ish solution. Following articles outline the steps and functionalities I implemented. Why angular-cli Is it alive? Use SCSS, Luke! Adding Webpack Electron-ize Send Menu Command…read more

Electron App
Is It Alive?

Posted by in Software, Tutorial

TL;DR: Yes, but it’s limping badly. Now that I’ve created the angular app, I wanted to find out if I could develop an Electron app without actually adding the Electron dependency yet. My naive findings are: You can develop any ui-related bit I could not implement actual business logic. This is due to the fat that browsers don’t have access to some things like fs. If you want to add more functionality (e.g. debug vs release options), you need webpack. A little experiment: If you find this post and ad…read more

Electron App
. Why angular-cli?

Posted by in Software, Tutorial

The decision has been made for me since I’m new to Angular in general and the CLI offers a package deal particularly where code generation and initial package management is concerned. There’s also the boon of webpack, which is used as engine. Although the balance tilts heavily in favour of using angular-cli, this package also has a bunch of flaws, apparent to me also because of the end target: No multiple webpack configs. Angular CLI only has an optimised configuration and doesn’t expose hooks to be able to alter it…read more

Debug Electron in VS Code

Posted by in Software

TL;DR: You need to follow the server (electron) client (VS code debugger) approach. Be aware of OS specifics! So far, my approach towards development/debugging would be to write some code, test it, rewrite, test… all with a bunch of console.log() statements. That’s not efficient at all and since VS code has debugging capabilities, I’ve decided to find out how. First, when you enter the debug mode, you’re presented with a default configuration containing of two parts: A launch part – designed to launch your application An attach part – designed…read more