Bits of Simplicity

Sitemaps, slugs and pagination oh my!

09/20/2017 - b5866b

Last night I finally got around to doing something that I have been wanting to do for a while. I have added sitemaps, slug based pretty urls and pagination to this site. Since this site is a pet project and written from scratch it lacks a few key features that most modern blogging platforms have these days. I still need to add archive type listings as well as a page post type, RSS feeds and gpg post signing.

 

Archive pages are a bit tricky due to datetimes being stored as UTC in the database but converted to America/Los_Angeles when displayed. It means all of the urls are generated with America/Los_Angeles but data is queried with UTC. A work around for this is to create a new field that also stores the time in America/Los_Angeles inorder to query posts. This works because I am really only dealing with one time zone, and I don't want to convert all database timestamps away from UTC.

 A page post type should be a pretty easy one. Something simple with the ability to change templates similar to WordPress.

 RSS feeds should be the same as sitemaps. At least in theory. Only posts should have feeds.

 Post signing is a bit of a tricky one. I think the best way to go about this is have a downloadable payload that can be signed and uploaded. The payload would consist of the posts data. Once it is uploaded I can add a UI element to the frontend to signify that post has been signed. Maybe find away to verify the signature online, but also have a downloadable option. I want to stay away from doing any real gpg operations in the browser as this would not be as secure. That is unless I can find a js library that will interact with my Yubikey.

Ubuntu Touch Emulator inside a VM

09/15/2017 - c35333

I have had my eye on Ubuntu Touch as a possible Android replacement for a little while. Last night I finally sat down and tried to get the Ubuntu Touch emulator working inside a VM. I started by spinning up my Proxmox cluster and set to work provisioning a Ubuntu 17.04 Desktop VM. I haven't had a chance to check out 17.04 yet, so that was kinda neat, but after downloading the touch emulator with 

sudo apt install ubuntu-emulator
sudo ubuntu-emulator create testinstance
ubuntu-emulator run testinstance

I ran into a known bug where the emulator terminal session drops to the phones busybox session, so I delete the VM and began provisioning a Ubuntu 16.04.3 VM. I was able to get further along in the process, but still ended up with a blank screen.  After some digging I found a post referencing an issue with OpenGL, which makes sense on the Proxmox cluster, so I delete that VM, and began provisioning 16.04.3 on my desktop inside of Virtualbox. Unfortunately I ran into the same issue. At this point I think I am going to install 16.04.3 on an old laptop and see if that does the trick. I really want to try it before attempting to dual boot on my Nexus 6. I have really high hopes for Ubuntu touch to become an OSS alterntive mobile OS to Android and IOS.

Biking to work

09/08/2017 - 3504b6

I guess I got the idea to bike to work a few months back. The summer weather here in Reno is nice and spring/fall aren't half bad either. I only live about four miles away from work, so it's about 15 -20 minute commute which is actually about the same as when I drive. Then there are the health benefits. I can definitely be more active and lose a few pounds. So it just kind of made sense.

I decided bought an eBike (flx bike) due to the killer hill I have to go up to get home. The nice thing about a pedal assist eBike is I can dial it back if I want to get more of a work out, or dial it up if it's been a long day. It took about 4 weeks for the bike to arrive, which isn't too bad considering it came all the way from China.

This is the first week that I have been commuting, and so far loving it! At first it took a bit to get used to. The last time I rode a bike was going on 14 years. I am looking forward to a few more weeks (hopefully longer) before the winter weather starts to set in.

Elite Dangerous: The Long Trek Back to Federation Space

09/07/2017 - e73487

In my free time when I am not coding away I like to play a game called Elite Dangerous. By itself it is an excellent space sim, but when paired with a Vive and flight stick it becomes a portal to another universe. I have been playing it on and off since it came out in 2014, and it took me awhile to really "get it." I think it will be fun to blog about my Elite adventures every now and then.

When last I played I had just wrapped up a community goal, but along the way I decided I wanted a shinny new federal assault ship. Inorder to be able to fly a federal assault ship you have to be a certain rank in the federation. Which I am currently not. The community goal was in empire space, so I had to make the long trek back to federation space. I decided on the Sothis system. About 36 jumps out. I outfitted my ASP Scout for long distance and begain jumping.  It didn't take me too long, and once I got in system I begain running missing right away. Hopefuly with any luck I will be able to rank up pretty fast. Most missions are right next door in the CEOS system.

Thats all for now.

Blog Style Updates

08/25/2017 - d5d0d9

I have finally gotten around to updating some front-end styles on this thing. Nothing too fancy, but I think it helps with readability. I plan to do more design updates for the next few days.

keybase

08/15/2017 - adf4f0

I have finally gotten around to setting up my keybase profile. I have been meaning to do it for some time. I added a link in the footer of the site and plan on keeping the gpg keys up todate.

Low level computing

05/01/2017 - b6ec0f

A few weeks back I ran accorss an intresting post on reddit about Ben Eater's YouTube channel. Ben is in the process of creating  a very well done series tutorials on building a breadboard of 8-bit computer. I have always been intrested in low level computing, but up until now haven't bothered to learn much about it. For most programmers & developers low level computing doesn't really matter, and these days use modern high level interpreted languages like JavaScript, PHP, Python, and even Java. Even when using mid level languages like .NET, C# and Objective C do developers rarely care about what is happning at the Opcode level. It's an area of computing my career hasn't really taken me to, so it is pretty fascinating.

I would love to create an Altair clone based off the computer Ben Eater's breadboard design. It would be a great learning experience. A nice mix of low level hardware and low level software. I would also love to create a very basic kernel and OS from scratch. One day when I finally have some time.

Been a bit busy

04/09/2017 - 95a5ee

I have been a bit busy as of late, so I have been a bit neglectful of the blog. However I do plan on getting back on track. Anyways more to come.

Time is hard

02/23/2017 - 4bba40

A common saying in the world of programming is "time is hard". You would think time would be easy, afterall we tell time everyday, but in reality time is very complex with many different variables. Here is an example I ran across recently.

If you work with WordPress for awhile there is a good chance you seen the Tribe Events plugin. It provides a events calender, and for the most part is a fantastic plugin, but it does have it's bugs. This particuler bug has to do with JSON-LD Schema data having the wrong date & time, which in turn means Goolge with display the wrong date. This is a reported bug, but Tribe doesn't seem to think it is a bug at all, but every site I have looked at all have the same issue. 

Before I can explain the issue lets talk a little bit about time. JSON-ld uses the ISO 8601 date format. Something like this: 2004-02-12T15:19:21+00:00

  • 2004-02-12 is the date (YYYY-DD-MM format)
  • T is a divider between date & time
  • 15:19:21 is the time (UTC/GMT)
  • +00:00 is the timezone offset

 

Using this format we can get a few things.

  1. Time in UTC - we can convert utc time to any timezone we want.
  2. Timezone offset - a "prefered" or originating time zone

 

So as an example:

2017-21-02T16:30:00-08:00

The UTC date time is 2/21/17 4:30 PM
The America Los Angeles time is 2/21/17 8:30 AM

If it was later in the day in America Los Angeles time, say 8:30 PM, it would be 4:30 AM the following day in UTC.

Alright now on to the issue.

Basically Tribe stores the UTC and originating timezone as different items in the database, and not as offsets.
When Tribe create the JSON-ld using ISO 8601 date format it uses the UTC value, but it doesn't apply the offset.

startDate: 2017-21-02T16:30:00-00:00

Just need to set the timezone to America Los Angeles. Sounds easy right? Well unfortunately not.
When you apply the offset using php it automatically converts the datetime object into the new timezone.

startDate: 2017-21-02T16:30:00+00:00

startDate: 2017-21-02T08:30:00-08:00

The UTC date time is 2/21/17 8:30 AM
The America Los Angeles time is 2/20/17 12:30 AM

But what we really want is

startDate: 2017-21-02T16:30:00-08:00

The UTC date time is 2/21/17 4:30 PM
The America Los Angeles time is 2/21/17 8:30 AM

Unfortanly there really isn't clean and easy way to do this in php, so this is what I came up with.

/* Tribe, modify json ld dates */
function tribe_modify_json_ld_event_dates ( $_data, $args, $event ) {

    $event_tz_string  = get_post_meta( $event->ID, '_EventTimezone', true );
    $tz_mode          = tribe_get_option( 'tribe_events_timezone_mode', 'event' );
    $tz_string        = $event_tz_string && $tz_mode === 'event' ? $event_tz_string : Tribe__Events__Timezones::wp_timezone_string();

    $offset = new DateTime();
    $offset = $offset->setTimezone( new DateTimeZone( $tz_string ) );
    $offset = $offset->format('P');

    $start = new DateTime($_data->startDate);
    if ($start->format('P') != $offset) {
        $_data->startDate = str_replace($start->format('P'), $offset, $_data->startDate);
    }

    $end = new DateTime($_data->endDate);
    if ($end->format('P') != $offset) {
        $_data->endDate = str_replace($end->format('P'), $offset, $_data->endDate);
    }
    return $_data;
}
add_filter( 'tribe_json_ld_event_object','tribe_modify_json_ld_event_dates', 10, 3 );

I am working on building a plugin that will fix the issue until Tribe creates a patch.

Short Blog Update

02/22/2017 - 7c099d

I finally got around to finishing up the basic admin. Posts are no longer static!