Stuff I'm Up To

Technical Ramblings

jQuery in Node.js — November 30, 2016

jQuery in Node.js

Using jQuery in Node.js gave me something to think about. Especially as there seems to be so many ways to do it.

If you’re using it in a renderer you can pretty much use it like you would in a plain old html page and use a script src. A couple of things I tried cause bootstrap to start complaining about jQuery not being defined. I eventually decided on this approach to get things working together.

In your html head you’ll need to include the css. You could get creative with Gulp and sass if you really want, but I’m just going for out of the box.

<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css">    

Then in your script tags:

    <!-- Insert this line above script imports  -->

        if (typeof module === 'object') {
            window.module = module;
            module = undefined;

        global.jQuery = require('jquery/dist/jquery.min.js');
        global.$ = jQuery;
        var jQueryUI = require('jqueryui');
        var jQueryMousewheel = require('jquery-mousewheel/jquery.mousewheel.js')($); // jQuery plugin handling
        var bootstrap = require('bootstrap');
        var tinysort = require('tinysort/dist/tinysort.js').tinysort;

    <!-- Insert this line after script imports -->

        if (window.module) module = window.module;

Notice the special handling ($) on the jQueryMousewheel plugin and the .tinysort to make these work as the should.

Slick.js – another carousel — November 29, 2016
Learning Electron & Node.js —

Learning Electron & Node.js

Many years ago in a galaxy far, far away I developed an application to manage and read my comic books. I developed it in a Windows environment and used C# Dot Net to build it. It worked just great and I still use it today.

It’s actually one of the things I use that prevents me from going full Linux on my home desktop. So I decided I’d see if I could remedy that by replacing it with a cross platform solution using Electron.

If nothing else it would provide me with an opportunity to learn how to use Electron & Node.js

Continue reading

Owl Carousel v2 —
Electron, 7-zip & Images — November 25, 2016

Electron, 7-zip & Images

The app I’m trying to create reads image files from a compressed file. either a zip, a rar or 7-zip format. The aim is to then extract the first image from the file and use that to make a thumbnail that can be displayed in an electron browser page.

Sounds easy? But I’ve been through lot’s of different uncompress/decompress libraries from the npm package manager and none of them have really fitted the bill. In fact the current choice I see as a bit of a compromise.

To make the app truly cross platform I was hoping for a self contained library that ran the decompression algorithms natively within Node.js/Javascript. There are a few out there, many for handling zip files, but when it comes to rar the perfomance and capabilities are really lacking.

Continue reading

Windows DKIM DNS Entry — November 24, 2016

Windows DKIM DNS Entry

Windows always gives me a bit of grief when trying anything a little out of the ordinary. I always find doing the same thing on Linux way simpler. This time it was relating to a DNS TXT entry for DKIM that is longer than 255 characters.

As we have a split DNS system out external DNS entries need to be manually mirrored internally. This is because often the DNS reply is different if you’re from an internal network to that of an external one.

The 255 character limit was no problem for the external system. It parsed the string and split it into the required elements automatically. Internally you MUST split it yourself and enter it into the Windows DNS server as separate lines, delimited with a carriage return.

Using DIG I could see the response from outside being returned correctly. But from inside it took me a few attempts to get Windows to leave it alone and make the entry the same.

Continue reading

DKIM Signature Testing —

DKIM Signature Testing

After setting up a DKIM DNS entry and then sending email we were seeing one of authorised 3rd parties failing to pass the DKIM checks. The DNS record looked OK but the mail systems like Google and Yahoo were saying it was failing. So how do I go about testing a message I received so I can see for myself what’s going on?

Looks like the answer is to use a Perl module “Mail::DKIM::Verifier”

Continue reading

Electron, JQuery & Bootstrap 3 — November 19, 2016
gulp.js — November 18, 2016
Atom – an Electron IDE — November 17, 2016

Atom – an Electron IDE

I figured this was pretty cool. An editor created using Electron, that you can use to create Electron apps.

What’s fun about this is that after using the Brackets editor for some time, and it is pretty good, I realised that Brackets was written in JavaScript. I had no clue how though. Now I realise it’s done in a similar manner. A JavaScript engine, powering a browser style interface.

Also Microsoft have just released Visual Studio Code, which is actually made using Electron!

I’ll certainly be trying our Atom in place of Brackets for a while.

SPF Testing —
Node.js & Electron — November 16, 2016

Node.js & Electron

I’ve run into Node.js a few times and kinda struggled with just what it’s all about. I’ve decided to have a bit of a poke at trying to develop an application that is cross platform and runs locally on either Windows or Linux, maybe even the fruit stuff and ran into Electron.

I’ll confess to being completely lost as to how to even begin. Setting it up seemed confusing in the documentation. In reality it pretty much fell onto my Windows machine once I figured it out.

Electron is a product delivering Node.js and the Chromium browser as a package. So put simply you write HTML, JavaScript & CSS that get delivered into a locally run browser. Node.js provides the scripting engine that has access to local resources that are accessed through the Chromium browser.

Continue reading