Rik's Ramblings

Friday, April 24, 2015

Googling for Stuff

If you're having a problem with something, It's great to Google the error message and find the solution to your problem.

However, it's weird when you Google something and get the answer, and the person who answered the question is you, from two years back.

Thanks me!  I love you, you're awesome.

Monday, April 20, 2015

EventSource, for server side push to the browser

How did I not know about this spec before now!?

...in some scenarios data doesn't need to be sent from the client. You simply need updates from some server action. A few examples would be friends' status updates, stock tickers, news feeds, or other automated data push mechanisms ...

I tried it out on my own server, with a little perl test script and sure enough it works!

Server Test Code in Perl

print "content-type: text/event-stream\n\n";
$| = 1;  # Forces flush after every line

local $count = 10;

while (0 != $count){
   print "data: something".$count."\n\n";
   $count -= 1;

Browser Test Code in JavaScript

var eventurl = "http://server.dom/cgi-bin/server_side_events/test";
var foo = new window.EventSource(eventurl);
var bar = function(evt){ 
   console.log("BAR: "+JSON.stringify(evt.data)); 
foo.addEventListener("message", bar);

Try it now!

Tuesday, April 14, 2015

Night at the Museum 3

Hey, maybe my mistake was watching this movie in the first place, but let's put that aside for now!

In the scenes where Ben Kingsley is present, I get a distinct impression that the video was shot mainly with body doubled.  I don't think Ben Kingsley and Ben Stiller we ever actually in the room together.


Monday, April 13, 2015

Floating Point Accuracy

Here's a warning if you're attempting to do any serious math using a web browser:

var foo = 0.1;
foo += 0.2;
console.log("0.1 + 0.2 = "+foo);

>>> 0.1 + 0.2 = 0.30000000000000004

Close enough right? Unless you're a bank, or rocket scientist that is!

But you already know this right?!

Don't blame JavaScript though, this is due to the IEEE floating point standard!
- IEEE Floating Point Standard

Wednesday, April 01, 2015

MiniLock, simple effective file encyption in the browser

This looks good: https://minilock.io/

Unfortunately only available as a Chrome browser add-on right now, I'd really like Firefox support.