Bits of Simplicity

Blog

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

 

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!

A need for speed (and security)

02/21/2017 - 9a82b3

Currently the site isn't much more than a glorified static site. I'm not really leveraging Laravel except to handle basic routing and html rendering. I have a plan to change that. In the mean time I have been playing around with cloudflare a bit on this project. I was pretty happy with the A rating on ssllabs. GTmetrix is also reporting a 0.8s load time and only 10 requests. Half of which are requests for google fonts. I might be able to cut that done by moving the import from css into html.

Thats really all for right now. Figure there will be a quite a few of these short updates until I get into the grove.

Ahoy world!

02/21/2017 - fe65dd

I've decided to build a new parsonal site and "Ahoy world" seemed like a fitting title for the first blog post. I'm not very good at blogging, but I figure it is great for personal & professional groth. I'm building this from "scratch" on my free time, so it might be a little slow going. The plan is to keep the design fairly minimal because I am a coder, and not a designer. A little bit about myself.

I'm a 25 year old developer named Bryan. I work for an amazing company called Noble Studios as a developer and work with some of the best talent in the industry. I get to work on a lot of cool stuff. In my free time I like to do the standard geek stuff. Video games, movies, anime. I own a vive and have been into VR games lately. I also like to do a lot of out door stuff like camping, hiking and sailing. I love to spend time in my hammock. I own two small sail boats and my dream is to sail around the world one day. I am also going to make a lot of nautical references. The primary reason for this blog is to write about tech stuff.

I want to try a few things and I have a few ideas for this site. I'v already setup some pretty sweet auto deployment using Gitlab CI. Staging & production environments. The server is pretty standard lamp stack. Ubuntu16, apache2, mysql5.7, php7.1. The backend of the site is built using the laravel framework. The frontend is built using HTML5, SCSS, Vue.js.

That's it for right now, but more to come.