Angular, EventSource, Go and wasted lifetime

If you have ever used EventSource and Angular and have read all the other blog posts and github issues and Stackoverflow posts and nothing worked, then you’ve probably come here and will happily leave knowing you solved your problem.

First of all I use cobra, I know, get to the point. As part of cobra I add the serve command, so I can go run main.go serve

This is the serve.go file

I set up the route, cors and run it

The server/handler/handler.go file

Here is the important part. I wasted the last 6 hours and previous to that 2 days on this issue.
If you’re serving this via nginx, you have to set this header X-Accel-Buffering = no.
If you don’t send this header responses will get buffered by nginx until the timeout it met then flushed to the client.
The above code has a ticker that ticks every second and sends a new “Server Sent Event”.

Why it didn’t work for me was, as you see above Event: "message". I had that set to “darko”.

The Angular service

eventSource.onmessage expects a message with the Event: "message" content. Since I had it set to “darko”,
the onmessage event never fired. If you for whatever reason need to send an event that is not a message type,
the eventSource.addEventListener is how you listen for that event.
As you might have seen in other blog posts or github issues, zonejs and EventSource aren’t the best of friends.
So you have to wrap it all in so you can have real time updates, and not just when you unsubscribe from the Observable.

Finally, the component

and the component html

Finally, the nginx configuration for the development server. To serve it all.
Here I’m using on the local network.

Things I wish I knew before using CentOS (7)

This is an ongoing, updated post of things I wish I knew beforehand.
CentOS is a solid base for any server, as it requires minimum maintenance and is very conservative when it comes to updated versions.
This post will be a mess at first, but continue to grow and evolve.

Current systemd for CentOS7

Up to date and legacy PHP versions

Current LTS or mainline kernel

More up to date qemu

libvirt manual migration

Following scenario:

You have 2 servers. No shared storage.
You would like to move VMs from Server A to Server B.

If you want a clean filesystem there will be downtime.
Downtime will take as long as it needs to copy the image from one server to the other.

Step 1:

Shutdown the instance running on the source server.

Step 2:

Copy the image, usually located in /var/lib/libvirt/images/ , from source to destination.

Step 3:

Dumo the configuration xml of your vm and copy it to the destination server

This will copy to the home directory of the destination server, in this case /root/ (implied by the : after the server name)

Step 4:

Import the copied xml domain configuration on the destination server.
The MAC address probably changed, depending on your data center’s setup you’d need to edit the xml file accordingly.
The domain import command is

Step 5:
Finish it up.
Change network configuration from inside the guest.
You will need to login via spice console.
It’s best to use the great tool “Virtual Machine Manager” for this job.
Remember to keep your VM’s root password ready.

Widevine’s “NO FEES” claim is a lie

If you browse over to widevine dot com you’ll see a

No Fees

Widevine supports the use of standards-based royalty-free solutions for encryption, adaptive streaming, transport and player software without licensing fees or required participation in the CWIP training program.

This is now the 3rd time I wrote them, and received no response.

Thanks to piracy we’ve lost over 50% ad revenue. Widevine, a Google/Alphabet company doesn’t care that people steal our work and put in on Youtube, where we have to spend unnecessary time to go through their annoying copyright claim process and deal with the negative fallout, including the reputation hit when you take down a video.
The amount of email spam when you file a copyright complaint is exceeds all limits. It’s not only annoying but also time-consuming. And sometimes people claim they have the right of “fair use” when they take 100% of our content and add it to their video. No it’s not fair use if you take 100% of our content and put it in your video. That is called theft.

Idee zur Stromgewinnung

Ich habe heute zum ersten mal sowas gesehen:

Ein Wasserhahnaufsatz mit verschiedenen LED Lichtern. Auf sowas muss man erstmal kommen.
Das funktioniert so das dadurch das Wasser durchfliesst Strom erzeugt wird und mit diesem Strom wird eine LED betrieben.
Was wäre wenn jeder Wasserhahn verbunden wäre mit einem Akku der diesen Strom speichert. Nehmen wir ein 6 Familien Haus, oder mehr. Da würde schon was zusammenkommen.