Create PDF's in Angular / Typescript

Posting an example of how to create PDFs directly in the browser with no server involved using Angular, Typescript and

The demo is here:

The PDF creation is initiated in the createPDF() method of this source:

The pdfmake library is made available to Angular and Typescript by creating a script element inside an rxjs/Observable that is notified on the script element onload. You can see how it's done in here:

Simple Firebase service for Angular 2

If you want a very simple alternative to Angularfire you may create a firebase service very easily. I made this to avoid extra configuration when it comes to adding npm packages and configuring for bundling. This is done by downloading the scripts from Firebase CDN directly by using a dynamically created script tag.

Once the service is initialized you'll find the database in the public database property, and you just use the regular Firebase API. (Example: this.fbservice.database.ref('someproperty').set(somevalue) - and remember to have fbservice : FireBaseService in your component constructor to inject the service. )

And here's the code for the service:
import{Injectable}from'@angular/core';import{Observable}from'rxjs/Observable';declareconstfirebase : any;constconfig={apiKey:"",authDomain:"",databaseURL:"",storageBucket:"",messagingSenderId:"",};@Injectable() exportclassFireB…

My VNC based development environment with Visual Studio Code running on Ubuntu

I've used this setup for my development environment for several years - giving me a developer desktop I can access anywhere. Even from my mobile phone. I've been fixing bugs, writing code and deployed emergency fixes from the bus, train and mountain tops.

The setup is based on a lightweight desktop environment. There are lot of alternatives, but I've chosen fluxbox. From a plain AWS Amazon Ubuntu 16.04 ec2 instance I've started like this:

sudo apt-get update
sudo apt-get install fluxbox

Download and extract tigervnc from (I downloaded the binary file from named tigervnc-1.7.0.x86_64.tar.gz )

then extract:
tar -xvzf tigervnc-1.7.0.x86_64.tar.gz
You need to install:
sudo apt-get install x11-xkb-utils
You need to edit .vnc/xstartup:
nano .vnc/xstartup
last line replace "twm &" with:
fluxbox &
Then you can start the vnc server:

Glassfish - Exception in creating message-driven bean container (NullPointerException)

This may happen every now and then if you killed the appserver and JMS was left in locked state. You can try to resolve it by deleting the file glassfish4/glassfish/domains/domain1/imq/instances/imqbroker/lock.

Secure file transfer with Java and Versile

Just made an example of how to transfer a file over a secure and authenticated connection in pure Java - without having to use additional technology like ssh/scp. Versile has all you need for creating a secure and authenticated connection, and you'll decide what files you want to expose - nothing more - nothing less.This is the file server (include versile.jar in your classpath - and create a file called "personregister.txt" in the working directory): package versileexample; import; import; import; import; import java.util.logging.Level; import java.util.logging.Logger; import org.versile.Versile; import org.versile.common.auth.VAuth; import org.versile.common.auth.VCredentials; import org.versile.common.auth.VPrivateCredentials; import org.versile.common.peer.VInetSocketPeer; import org.versile.common.peer.VPeer; import org.ver…

Converting from linear to logarithmic scale

A simple function useful to plot a logarithmic scale. Just provide it with the min and max values of the scale and the value you want to convert - and you'll get in return a value as it should be positioned on a logarithmic scale in the given range.
public double toLogScale(double min, double max,double val) { double logmin = Math.log(min); double logmax = Math.log(max); double logscale = (Math.log(val)-logmin) / (logmax-logmin); return min+(max-min)*logscale; }

Ubuntu desktop in the cloud accessible with VNC

To create a Ubuntu desktop on Amazon EC2 that can be accessed by VNC I did the following steps:

1. Create 64-bit Ubuntu server instance
2. Install ubuntu desktop:

sudo apt-get install ubuntu-desktop

3. Install x11vnc

sudo apt-get install x11vnc

4. Install xvfb

sudo apt-get install xvfb

5. Configure x11vnc

sudo nano /etc/init/x11vnc.conf
start on login-session-start script /usr/bin/x11vnc -xkb -auth /var/run/lightdm/root/:0 -noxrecord -noxfixes -noxdamage -rfbauth /etc/x11vnc.pass -forever -bg -rfbport 5900 -o /var/log/x11vnc.log end script
And you should also set a password for your vnc sessions:

sudo x11vnc -storepasswd /etc/x11vnc.pass
6. Configure X server to use xvfb:

(Add the xserver-command line)

sudo nano /etc/lightdm/lightdm.conf
[SeatDefaults] greeter-session=unity-greeter user-session=ubuntu xserver-command=/etc/X11/xinit/xserverrc
(Replace the exec line)

sudo nano /etc/X11/xinit/xserverrc #!/bin/sh #exec /usr/bin/X -nolisten tcp "$@" exec Xv…