JavaFX Single Instance Application

This is based upon the solution in the blog post: Java Single Instance Application. The solution uses the “Socket Technique”: With this technique we start listening on a port, only one process can listen on a socket so after first instance of our application binds itself to the socket other instances will get BindException, which … Read more

Is there an platform independent equivalent of os.startfile()? [duplicate]

It appears that a cross-platform file opening module does not yet exist, but you can rely on existing infrastructure of the popular systems. This snippet covers Windows, MacOS and Unix-like systems (Linux, FreeBSD, Solaris…): import os, sys, subprocess def open_file(filename): if sys.platform == “win32”: os.startfile(filename) else: opener = “open” if sys.platform == “darwin” else “xdg-open” … Read more

How to call methods in Dart portion of the app, from the native platform using MethodChannel?

The signature is void setMethodCallHandler(Future<dynamic> handler(MethodCall call)), so we need to provide a function at the Dart end that returns Future<dynamic>, for example _channel.setMethodCallHandler(myUtilsHandler); Then implement the handler. This one handles two methods foo and bar returning respectively String and double. Future<dynamic> myUtilsHandler(MethodCall methodCall) async { switch (methodCall.method) { case ‘foo’: return ‘some string’; case … Read more

What common algorithms are used for C’s rand()?

See this article: http://en.wikipedia.org/wiki/List_of_random_number_generators This is the source code of glibc’s rand(): /* Reentrant random function from POSIX.1c. Copyright (C) 1996, 1999, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <[email protected]>, 1996. The GNU C Library is free software; you can redistribute it and/or modify … Read more

Application failed to start because it could not find or load the QT platform plugin “windows”

The error is caused because the program can’t find qwindows.dll qwindows.dll has to be in a folder named platforms so that the path from your executable to the dll is platforms/qwindows.dll Whereas this wasn’t enough in my case. I had also to add following line at the beginning of my main() QCoreApplication::addLibraryPath(“./”); Then everything worked.