Categories
Uncategorized

Vote Like a Roman Emperor

Today my team launched our second WordPress block, the Vote block! The vote block lets your readers up or down vote content on your page that you’re looking for feedback on. You can already use it on your WordPress.com site or download the plugin for your self-hosted site here

What do you think?

Categories
Uncategorized

Either The Smartest or The Dumbest Thing I’ve Ever Done

That may be a bit of an exaggeration, but I’ve just imported the entire archive of my old blog at johncaruso.ca to this site. It was about 360 posts that date back to 2004 when I used to ramble on about mundane day to day things I was up to.

Its been fun to re-read some of those posts and reminisce, but at the same time, there are a bunch of formatting issues I now have to deal with since it was a completely custom site before and I had some weird css to make certain things (like code snippets) look just right. I’ll need to groom those posts and fix whatever needs fixing.

At the same time, it was a fun little exercise to generate a WordPress compatible XML file to export my old blog database to. Now I just need to generate the URL rewrites from my old site to point here so I can remove those posts from there and clean up that site a bit.

Categories
Uncategorized

Its A Poll Block!

My team over at Crowdsignal has been working on a cool new poll block plugin for WordPress called Crowdsignal Forms. We officially launched it this week for self-hosted WordPress sites and on WordPress.com! Please go check it out if you’ve got a WordPress blog or website.

Categories
Uncategorized

A New Beginning

I’ve had many web presences over the years. My first website (built with NetObjects Fusion and then Microsoft Front Page) was hosted on Geocities and it was a fan page for my heroes at the time: Patrick Roy, Saku Koivu and Jacques Villeneuve (if memory serves). After that I decided to learn HTML and build my first blog engine in java that would write out static files to be served. I then went on to learn PHP and mysql, built my own custom blog software and the rest is history. I’ve been building web apps ever since for fun and professionally.

And all that has lead up to where I am now, writing this first post on my newly minted WordPress.com site from the comfort of my sofa on the week and a half I have off between leaving my last job at Connected (which I thoroughly enjoyed but can’t speak too much about the super cool but secret projects I worked on there… damn NDA) and starting my next adventure with Automattic where I’ll be working on products for WordPress itself!

As I’ve said in the past, I’m going to try writing more. We’ll see how long it lasts this time around, but I think I’ll have quite a bit of content to go through before it starts to get tough. I’m going to try to write about my experience interviewing with and getting hired by Automattic as many have done before me, and also try to talk about what its like to work in a completely distributed company (oh yeah, I forgot to mention I get to work from home every single day).

I’m also going to try to import my existing blog’s content over here, but I’m not sure how that’s going to work with the existing links, so I may just leave things there and start fresh over here. I imagine JohnCaruso.ca becoming more of a portfolio site with links to all of my other stuff (including this blog). But we’ll see how that shapes up.

Categories
Uncategorized

Introducing: tiny nags.

Part of my self-re-education these last few months has been learning different web frameworks that I’ve been interested in but haven’t had the time to dive into. As you may have seen from my last post, one of those is ReactJS, and I’m proud to finally be able to make public the small project I put together while learning it… tinynags.com

tiny nags. is a web-based reminders app that uses HTML5 browser notifications to ‘nag’ you to do things that you need reminding. I created a few cute little robot characters to give the site a bit of character and not look as boring as it sounds. It supports all modern desktop web browsers (although some with limited support due to html5 notifications not being implemented the same across different browsers and operating systems) and Chrome on Android which was a nice little freebie I got for supporting HTML5 service workers. Safari on iOS doesn’t have support for HTML5 notifications so it has been left out in the cold. I may turn this into a mobile app at some point if I have the desire to, or if there is enough demand.

I’m currently trying to promote the site by contacting various productivity blogs and have posted it up on reddit here so if you have a Reddit account, please upvote it for me!

Categories
Uncategorized

Piggy Backing on ReactJS’s ServiceWorker for Notification Event Listeners

About a week ago I decided to start learning ReactJS because why not? just to get some exposure to yet another javascript framework that seems to be pretty popular right now. I had been in the middle of putting together a notification/reminder web app (more on that in a later post) and wasn’t particularly happy with the code I ended up putting together to populate the UI. Fast forward to yesterday, I gained some rudimentary knowledge on how to use React, converted my existing jquery based web app to React (along with my ServiceWorker code that was detecting when a notification was clicked or closed) and I was now ready to do a production build of the app. Upon doing the build and testing the resulting site, I found out that my service worker code was no longer firing.

After doing some digging I found out that React uses its own service worker to enable itself to run when your browser or device is offline. I was thrilled that I got that for free out of the box, but it also meant that my service worker was no longer running since you can only have 1 service worker running at a time for a single URL scope.

My solution for this was to merge my service worker code in with React’s service worker. Just a warning: This may not be recommended by React, and it might only work for my particular case because I just need to add some event listeners to the service worker. Your mileage may vary.

Since I was no longer able to run any code during the register phase of the service worker (since React is doing the registration), I needed to do the following in order to get a reference to the registration object whenever I want to call showNotification()



navigator.serviceWorker.ready.then(registration => {
    registration.showNotification("Notification Text",
    {
        data: {
            id: "recordid"
        }
    });
});

On the service worker side, I just need to paste in my event listeners into the service-worker.js file in the /build directory after building the React project. Keep in mind, you will need to do this every time you re-build your React project since that file will get replaced.



self.addEventListener("notificationclick", handleClickClose)
self.addEventListener("notificationclose", handleClickClose)

function handleClickClose(event) {
    const n = event.notification;
    sendMessage(n.data.id)
    n.close();
}

And thats all there is to it! You might notice that I’m calling a method sendMessage() in my event handler. I’m using this to let my application know which notification is being acted on. It isn’t required for the event handler to work, but it is part of the functionality for the web app I’m working on. sendMessage() is implemented as follows:



function sendMessage(pstrMessage)
{
    clients.matchAll({includeUncontrolled: true, type: 'window'}).then(clients => {
        clients.forEach(client => {
            client.postMessage(pstrMessage)
        })
    })
}

And I have an event listener that is registered during componentDidMount() in my React app’s root class that listens for messages from the service worker:


navigator.serviceWorker.addEventListener('message', function(event){
     // do some work here
     console.log("click notification for " + event.data)
});

Just one final note, I wrapped the registration of my original service worker in an if statement that checks if I’m in dev mode or not. This way it will still register during development (since the React service worker isn’t registered) and it is prevented from registering in production.



if (window.location.port === "3000")
{
     navigator.serviceWorker.register('/sw.js').then(...)
}

I imagine if I was better versed in React and building npm packages that there might be some way to bundle this up into a cleaner package that would make it more reusable and tie into the React build process in order to skip the manual step of copy/pasting the event listeners into the service-worker.js file. If anyone stumbles on this article and has knowledge of how to do that please let me know!

Categories
Uncategorized

New iOS App In The Works

My first foray into native (non Cordova) iOS apps has been in the works for the last couple of weeks. I read through Matt Neuburg’s iOS 10 Programming Fundamentals with Swift and Programming iOS 10 (although I cherry picked the parts I thought I’d need in this one) and then got started writing my first app, tentatively titled WallpaperCapture; A camera app that lets you take a photo for your iPhone lock screen and home screen with all of the labels and objects you’d normally see superimposed on the screen so you can frame the scene perfectly.

The goal with this app right now isn’t to get rich (I’m going to release it for free, possibly ad supported) but rather to practice what I’ve been learning, and experiment with interface objects and frameworks that I’ll likely need in the future on a much larger project. I’ve got a preliminary build that I’m testing right now that provides the time, date and other lock screen labels of an iPhone, along with the Perspective Zoom so that the photo that you take will look exactly as it does when you set it as a lock screen photo. The photos are currently stored into an app specific album in the Photos app, but I’m planning on having an in-app library to see all of the photos that have been taken. Eventually I will provide a way to upload the best images ‘to the cloud’ so that the photos can be shared with other users looking for interesting and unique wallpapers.

I’m in the process of implementing Fabric.io’s Crashlytics for app statistics prior to releasing the app to some users via TestFlight (email me if you are interested in being part of the beta test group). Once that is done and I’m ready to implement the ads and photo upload, I think I’m going to integrate with Firebase since it is an all in one SDK for ads, cloud storage and countless other features that I may need in the future.

Categories
Uncategorized

Experiment in SEO: CarKeyBatteryDepot.com

Over the last couple of weeks I have been getting up to speed with a few web development frameworks that I’ve been wanting to work on: NodeJS and bootstrap. I had experimented with both of them a little over the last few years, but I never had the chance to actually work on a project, until now.

I had the idea to put together a little website to search for car key replacement batteries when my Mazda 3’s car key was starting to get a little weak. Doing a google search returned some results but nothing definitive, other than a few youtube videos on how to replace the battery. Nothing outright stated that a 2014 Mazda 3 uses a CR2025 type coin battery, so it didn’t give me the confidence that I was actually getting the right battery without confirming it with the car manual. And further more, those youtube videos didn’t give me an option to buy an actual replacement battery.

So I set out to build a new site that would both definitively tell you what kind of battery your car key needs, and give you some cheap options to purchase a replacement battery and I called it CarKeyBatteryDepot.com. The website lets you specify your car’s year, make and model and key fob type (if there is more than one for your car) and it displays the type of replacement battery you need and provides you a list of vendors to purchase the battery from for cheap. The battery database was built by going through hundreds of car manuals (so far only Mazda and Toyota from 1999-2019 is supported) using a Python program I wrote to read the PDFs and extract the battery data. The purchasing options are pulled from Amazon’s Product Advertising API.

The site was built using NodeJS and NGINX with a LokiJS backend for fast searching and Bootstrap to provide a responsive UI. I followed Mozilla’s Beginner’s Guide to SEO to get the basics of SEO to give the site the best chance of being the top Google search result. Specifically, I’m using the following techniques:

  • ‘Meta Description’ tag in header, and all keywords in both the ‘title’ tag and at the top of the page
  • URLs for every possible battery response with the car’s year, make and model in the path. Ex: carkeybattery.com/2014/Mazda/3
  • sitemap.xml with a list of every possible URL so Google knows what to index
  • support SSL, with a free certificate obtained from LetsEncrypt.org

I’ve been waiting to see how well this works, but Google hasn’t indexed the site as of yet. This blog post is meant to both give me a way to introduce the site to anyone who is following my website, and to give Google another link to the site in the hopes that they consider this as me vouching for the site which should help its site rank. I’m hoping this little experiment works and that I can generate a few bucks off of Amazon referrals, as well as use it as an example when attempting SEO for other people. I’ll post a follow up once I have some definitive results.

Categories
Uncategorized

Programming Language Potpourri

At one point this morning I was thinking about what subject to tackle next and I started thinking about all of the different programming languages that I’m currently, actively, writing in at the moment between all of my contract and personal projects. It was getting a little scary when I realized there were about 6 different languages that I write in on an almost daily basis at my contract job, and another 2 that I kind of hack around with at home.

Contract #1

HTML5 Apps
– Javascript using the Sencha Touch and EXTJS framework
– Java for custom native Cordova plugins on Android
– Objective-C and Swift for custom native Cordova plugins on iOS

Main Web app and Webservices
– C# for latest main application and mobile REST services
– VB for previous main application still supported by the client
– Java for a custom web service for solving routing problems using jsprit
– TSQL for database stored procedures

Contract #2

50BookPledge.ca
– PHP for dynamic web pages
– Javacript for the usual cool site interaction stuff

84 North Studios Projects

SilverBeak.com
– Python using bottlepy for the site

And a bunch of other things using a combination of all of the languages already mentioned

That list ended up being bigger than I thought it was going to be when I first started writing this post. I had to go back and update the language count in the first paragraph a couple of times.

Listing all those out has started to worry me a bit about how well I actually know those languages. The doubt started creeping in yesterday when I stumbled on Standard JS Style and read through a couple of links. Mainly the part about not using semicolons to terminate a line. I knew they weren’t required, but I didn’t know why or in what situations you’d need to either make exceptions or handle the fact that the js interpreter might get confused (like starting a line with [ ( and some other chars). I’ve since done the requisite reading and now have the knowledge, but that just leads me to think what else don’t I know that I DON’T KNOW? I think I need to start trying to just buckle down and specialize in one or two of these areas that I use a lot and just learn all there is to know. I’m leaning towards javascript, and maybe even dumping PHP in favour of nodejs since I’ve been wanting to use it for a project lately but don’t know for what yet.

Categories
Uncategorized

Ok Seriously, I’m Back For REAL This Time…

So my last post was well over a month ago, not quite fulfilling the promise of having an active blog. But life has been busy since my fiancĂ©e and I bought a house. And now between trying to find ‘stuff’ to fill it with and getting all our paperwork in order, there just hasn’t been much free time to just sit and write.

So I’ve learned over the last month that adulting is hard, but I’m getting used to it and now I’ll have one more thing to write about here. Maybe this development-leaning blog will turn into a home improvement blog at some point?