New CLI For FitBit!

Yesterday, FitBit released a brand new CLI for developers. This is huge news that brings development to the local machine, and doesn't rely on the use of their web-based studio.
Don't get me wrong, the studio is a great tool! However, it is very nice to be able to run local editors such as VSCode.

When I was testing the new CLI, I ran into an issue that is simple to solve, but I couldn't find anything online telling me what was wrong. Here is the error when trying to install my app to the simulator:

Install failed: App was built for meson, but connected device only supports higgs applications.

The Solution

Silly me... My app is only built to work on Versa devices. The simulator first launched as an Ionic device. So naturally, the app will not install to Ionic. You can change this from within your package.json file.

"buildTargets": [
    "meson",
    "higgs"
],

meson is for the Versa, and higgs is for Ionic. If you weren't aware of this before, then the error wouldn't mean anything to you. But, now you know, so go out there and make some amazing apps for FitBit!

Last week I attended the ESRI User Conference in San Diego, CA. I had a blast learning about all of their amazing geo-analytics services! We have a plan to build an app at Windstream that will require highly accurate GPS tracking on an iPad.

At the conference, I threw together a quick app that plotted where the user was each time the ESRI Track module received a GPS update. Being inside a gigantic conference center with 17,000 users caused a lot of interference, so testing at the venue was impossible. I tested a bit throughout downtown, and the accuracy was quite bad.

I did ask one of the developers that works on the GPS Track module at the conference about increasing the accuracy. He had said that the 'enableHighAccuracy' was turned on by default, and it was up to the device (more on this below).


Testing in Decatur

After getting back to Decatur, I decided to do some more testing. I don't live near skyscrapers or large venues, so I thought maybe the GPS would be much more consistent.

FieldTest

Field Testing ESRI Geolocation Services

As you can see (click the image for a better view), the dots tracking my location were still a bit all over the place, but it wasn't terrible.

We noticed when using a native app such as Google Maps, the accuracy was much better. Even after using Google Maps and switching back to our web app, the accuracy was great for a little bit, then went back to jumping all over the place.


Progressive Web App

I then decided to try to package up the tracker as a PWA. I had little hopes that this would affect the accuracy, but wanted to rule out every possibility. It was as I expected. The PWA did not perform any better compared to running the app within a web browser. At this point, I was thinking of making a separate native app to track the location, and built the rest of this app as the separate PWA. Not ideal, but a possible plan B.


Faster Polling

What the developers at ESRI did not mention was the polling time of the default Track module. The way the GPS works on the device, is that it polls nearby cell towers and WiFi hotspots to try to triangulate your location. If you move a little, and poll again, it will get a more accurate reading.

What I found digging in the ESRI JS API docs, is that the default time for the polling is 15 SECONDS! Even on foot, you can cover quite a bit of distance in this time.
This is what was causing the location to bounce all over the place on the map.

You can adjust the timeout of the polling in the geolocationOptions of the Track module.

    // Create an instance of the Track widget
    // and add it to the view's UI
    let track = new Track({
        view,
        geolocationOptions: {
            maximumAge: 0,
            timeout: 500,
            enableHighAccuracy: true
        },
    });
    view.ui.add(track, "top-left");

DO NOT set the timeout to 0. There are a lot of Javascript examples using 0 for the timeout. Doing so will make the ESRI map not work, without even throwing console errors.

Setting the timeout to 500ms has greatly increased the GPS accuracy on my demo app. I now feel that it is just as accurate as using Google Maps with these settings.

The demo code I used for this can be found on GitHub

I have been planning a custom theme for my personal site here at ChrisPerko.NET. Currently, the site is running a child theme of Hestia, developed by ThemeIsle.com. It's a great theme, and I've had it for over a year, but I want something custom! I had a choice to make; which starter theme to use? It is very useful to create a theme completely from scratch in order to understand what all is being done behind the scenes. Alecaddd has a great YouTube series called Create a Premium WordPress Theme, and it is a great place to start if you've never built a theme from scratch.


_Underscores

_Underscores is a great starter theme. It was created by the same folks that created and maintain WordPress itself. I am currently using this as part of the TailwindCSS Theming Series on YouTube. _Underscores gets rid of all the annoying parts of developing a theme, such as setting up the header.php and footer.php files, javascript and stylesheet enqueues, and even setting up a simple mobile navigation menu! If you are fairly new to WordPress theme development, it is a great place to start. Honestly, a simple theme could be built by just working the CSS of the _Underscores theme.

The WordPress CLI (Command Line Interface) comes baked with a command to generate a brand new _Underscores theme for you in an existing WordPress installation. This feature allows a rapid setup of your environment; in minutes you can have a fresh install of WordPress running locally, with a brand new theme ready for styling!


Sage

I have been working in Laravel development for that past year, and really love the framework. One thing I really like about it, is how fast you can get an application running using Blade templates. If you don't know, Blade allows you to write very clean front-end code with access to all the PHP goodness. Instead of having to break into PHP to do something such as a for loop, you can simply do this in Blade: @foreach(users as user):.

Using Blade templates in WordPress seemed like it would be a great way to write cleaner, more readable code. This is where Sage by Roots comes in. Sage is a starter theme that comes with a bunch of goodies out of the box just like _Underscores. It has all of the fun things that Blade has to offer, such as extending layout files, and you can start it by using Bootstrap 4, Foundation, Bulma, or even nothing if you really want to control everything.

My main concern with Sage is how drastically different it is to a regular theme. The file structure closely resembles an application source structure than a theme. This may work for you if you are building a complicated application on top of WordPress, but for a standard theme this will seem very daunting. The Blade files are nice and neat, but you must have a separate file acting like a controller to get the data you need to that Blade template. Controllers make a lot of sense when building an app, but to just display a post on a page seems like overkill to me.

My last gripe with Sage really just comes down to this: What if I build a theme for a client and later on they decide to hire another developer to make some changes? That developer will most likely have never used Sage, and the huge difference in file structure alone versus a standard theme will probably completely confuse that developer. Using Sage would also be a huge learning curve for an inexperienced developer, so if you are new to the world of web development, I highly suggest using either of the other two starter themes on this post.


AWPS

The last starter theme for this post is AWPS, or the Alecaddd WordPress Starter Theme. AWPS is based on _Underscores, so if you like what _Underscores has to offer, I highly recommend at least taking a look at this theme.

This theme has an advantage in my book over _Underscores in that the back-end is all object-oriented. This leads to much cleaner code, and is very easy to extend to add in any feature you can think of. It utilizes the PSR-4 autoloader, so no more require() lines scattered about in your PHP code.

Want a fast setup? No worries, there is a CLI for that! A new feature of the CLI allows you to even give the theme a custom namespace for all of the class files. Want a more in-depth look at it in a video format? Alessandro has even created a YouTube series on AWPS to get you familiar with it quickly.


Conclusion

In conclusion, for my new theme, I have decided to go with AWPS. Although it doesn't use Blade templates, which I originally wanted, it is very easy to use. Packed with all the features I loved about _Underscores, AWPS really brings the starter theme up to modern day coding standards.

For beginner developers, I recommend either starting with _Underscores, or if you have an understanding of OOP, go with AWPS. You will be up and running in no time!

KISS Weekend Project

San Antonio has a lack of rock stations to listen to on the radio. The only one that exists in the area is 99.5 KISS. Over the years living here, I have noticed that the same songs are always playing, and always by the same artists. I can't tell you how many times I have heard Metallica's Enter Sandman. The artists and songs they play are not bad, they are just over played.

One weekend in January, I set out to build a small Laravel app to analyze the songs that KISS plays. Luckily, the KISS website has a little widget showing what is currently playing. Inspecting the code on the site revealed that is uses data from a REST API, that is fully open to the public to use, no CORS or anything protecting it.

Building a service to fetch data from this API was super easy to use, and the source code for this project can be found on my GitHub account. Next I wanted to analyze the release dates of the songs that are played on the site, which is where Discogs comes into play. Discogs has an API that can be used to get information on a given song, including the release date. I still have some work to do on analyzing the dates, as some of the dates my app has retrieved show release dates very recent, as some of the songs have been remastered and re-released.

More Analytics

Currently, the KISS Sucks app shows the most recently played songs and the most played artists. I recently posted the site on the 99.5 Kiss Sucks San Antonio Facebook page as a comment to a post and had great feedback from the community. Some feedback gave me ideas on more metrics to show on the page, and I have an idea of making a searchable section where users can see how often a particular song or artist was played over the course of a week, month, quarter, etc.

As for styling, the site was put together in a short period of time, and styling was more of an after thought. I plan to completely redesign the site from the ground up, and possibly pull in posts from the community Facebook page. This project is completely open-source, so if anyone has any ideas or a design they would like to implement, feel free to create a pull request!

Copyright © 2018 Chris Perko

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram