Livefyre integration is a mess!

After spending a few hours integrating Livefyre into a project; I ran to Disqus!

My decision was solely based on their horrible integration story and dubious design.

HTTPS

First they give you a code snippet to paste on your page. The snippet worked perfectly; until I deployed the site and ran it against HTTPS.

They are serving their default scripts from an HTTP only source.

So I spend 30 minutes trying to figure out how to solve this problem; and it turns out they have a secondary library [possibly newer] that is served from a CDN and has both HTTP and HTTPS.

The problem is that new library has a very different interface.

RequireJS

I can tell from their initialization code that they are internally using RequireJS but they do not make it easy for you to actually integrate Livefyre with your own require; it was again, another 30 minutes of me trying to get it to work properly.

iFrame

Finally the thing that pushed me over the line; was when I saw a random iFrame popup at the bottom of my site!

I dug a bit and found that normally the iFrame was supposed to be set to display=’none’ but that somehow it was getting re-rendered on the page.

Disqus

In the end; I switched to Disqus. The experience was much better, simple integration with my RequireJS and no HTTPS problems.

Don’t cheat on phone interviews!

Don’t cheat on phone interviews; and if you are going to cheat, don’t be an idiot.

As of a few days ago, I didn’t know that cheating on phone interviews was a thing. It is so unthinkable and rather stupid that I just didn’t expect anyone to try to pull it off; especially not on a technical interview. My interviewee tried to pull a fast one on me, I got the drift and lead him straight to giving me the proof I needed that he was a cheat.

The Signs

My first hint that something was wrong came when I found that the candidate was taking too long to answer the questions. There was just too much dead silence on the phone. I initially attributed this to the candidate not really knowing the answers. However, within a few seconds he responded correctly.

Ok. Maybe it is just me. Let’s move on…

Again, silence, I am forced to check if he is still on the line.

Then the answer comes.

Ok. Maybe he is just nervous, or just awkward… Thats fine!

More silence, more correct answers. I increase the difficulty, and the answers keep coming. But some of the terms he is using are un-natural, somewhat textbookish…

I am getting suspicious!

The Test

I shift from testing his skills to testing his honesty. He said he wasn’t experience in Web UI development; So I kept asking him questions in this area; and he kept giving me textbook answers.

I wanted proof. I knew that with his 20 second pauses, he had enough time to paraphrase any technical explanation so I started asking him to write examples code or snippets for some of those topics.

What he didn’t realize is that I can google/bing just as fast as him!

It only took two written questions for me to catch him in the act! He writes an example with very peculiar and un-natural variable names; the kind of names that feel like they have more context to them…

5 seconds later I have his exact peculiar example, verbatim, on a question and answer site!

Irrationality

For the first time I found myself absolutely fuming in a middle of an interview! This guy was wasting my time. There was no way that he would ever get away with it!

There was something absolutely irrational about this individual’s behavior. He was obviously skilled enough as a coder, he had no reason to try to cheat his way into this specific job! How did he think he was going to get through the in-person interview? There was just no win out of this situation for him and yet he still tried to cheat his way through.

Why?

With some of the questions I gave him I would have gladly accepted an “I don’t know”. I gave him increasingly hard questions based on his readiness to answer the previous ones. Instead of focusing on his strength he pushed me to focus on his weakness.

The first lesson in cheating is: don’t go overboard! If you have the answer sheet to a final, you don’t ace the exam, you need to purposely make a few mistakes!

Don’t eagerly proclaim ‘I know this answer’ and then spend the next 20 seconds in silence!

He claimed to not be strong in Web UI and yet answered all the questions perfectly, with a textbook answer. I would never have been suspicious if it wasn’t for his idiocy!

In the end, I didn’t confront him. I was sufficiently frustrated that I deemed it more prudent to end that interview than to call him out on his dishonesty.

Don’t Cheat

Please don’t cheat on phone interviews! If the job is out of your technical reach, work hard on elevating yourself! Cheating might get you through a phone screen; but there is no way it will get you through an in person interview!

webapi – the elusive 406, AsyncEntitySetController

One of the most annoying things you will encounter while writing WebApi code [and there are many] is the 406 error.

‘Unacceptable!’

That’s all the server will tell you; ‘Unacceptable’…

Here is one of the harder bugs to find that causes this error;

If you are using an AsyncEntitySetController make sure you do not have ANY async functions in your controller that do not have an await in them; otherwise you will get a 406 without your controller ever being hit.

Forget HTML; Markdown is the way to go!

One of the most annoying things about creating websites is having to write large blocks of text in HTML. No matter how comfortable you are with HTML, it is an unnatural way of writing flowing texts. Having to worry about a hierarchy, a opening and closing tags, indenting, all things too distracting to writer.

This is where Markdown comes in, it is a simpler, text oriented syntax that is a lot simpler and cleaner than HTML for the purpose of constructing documents.

You can read more about markdown here: wikipedia

Node.JS

Install marked:

npm install marked

Include a markdown document into your jade view:

include path/to/document.md

Jade will automatically run document.md through marked and convert it to the proper HTML.

requirejs – load as module if possible

If you are writing a library that might or not be used with a module loader you can make your developers’ life easier by adding the following at the end of your module.

(function( window, undefined ) {
  __EXPORTED_OBJECT__ = {};
})(window);

if ( typeof module === "object" && module && typeof module.exports === "object" ) {
    module.exports = __EXPORTED_OBJECT__;
} else {
    if ( typeof define === "function" && define.amd ) {
        define( "__module_name__", [], function () { return __EXPORTED_OBJECT__; } );
    }
}

require.js – knockout templating plugin

update – this code should be modified to first look in the require.js registry before trying to load using ajax.

Here is a plugin I wrote to help me load and apply knockout templates using require.js.

This same pattern can be used with any other templating engine.

define(["libs/jquery", "libs/knockout"], function($, ko){
  function load(name, req, onload, config) {
    var url = req.toUrl(name + ".ko");

    function tmplr(err, text) {
      this.err  = err;
      this.text = text;

      this.apply = function(data, $el) {
        if (!this.err) {
          if ($el) {
            $el.html(text);
            ko.applyBindings(data, $el[0]);
          } else {
            ko.applyBindings(data);
          }
        } else {
          throw err;
        }
      };
    }

    $.get(url)
      .done(function (text) {
        onload(new tmplr(undefined, text));
      })
      .fail(function (jqXHR, textStatus, errorThrown){
        onload(new tmplr(errorThrown));
      });
  };

  return {
      load       : load
  };
});

usage:
“libs/require/plugin/ko” is the path to this plugin
“tmpl/app/contacts” is the path to the template; note that the plugin will add “.ko” to this path, the file would be called “contacts.ko”

require(["libs/require/plugin/ko!tmpl/app/contacts"], function(tmplr){
  if (!tmplr.err) {
    tmplr.apply($("#scope_element_id"), res);
  }
});

#Cordova – 2.7 – InAppBrowser Anonymous Event Handler Bug

If the callback passed to an InAppBrowser event is an anonymous method, said anonymous method will ONLY be called if it does not reference any other functions within the JS code.
ex:
[cc lang=”javascript”]
function foo(){console.log(‘hello from foo’);}
ref.addEventListener(‘loadstop’, function(e)
{
// this callback will not be called
console.log(‘hello from loadstop);
foo();
});
[/cc]

Bug Report