Gutenberg Youtube Embed

The Gutenberg Youtube embed lacks a few things. The alignment doesn’t seem to be working, at least in the theme I’m using. I’m using Generate-Pro, a Genesis child theme. By default, it’s left-aligned. I have to add this div to make it centered.

<div style="text-align:center">
</div>

If you want right aligned, use this div.

<div style="text-align:right">
</div>

TLK.IO Embed

tlk.io is a simple chat page that you can embed on your site. If all you are seeing is a blank screen, I may have a fix for it. I don’t think it’s documented anywhere. I did not see it on tlk.io’s website. Here’s the code that they want you to embed. Of course, you have to use your own data-channel instead of the default “hey.”

<div id="tlkio" data-channel="hey" style="width:100%;height:400px;"></div>
<script async="" src="http://tlk.io/embed.js" type="text/javascript"></script>

The above code will not work if your site is secured via SSL. You’ll need to change the embed.js reference to https. In this case, it would be something like this. 

<div id="tlkio" data-channel="hey" style="width:100%;height:400px;"></div>
<script async="" src="https://tlk.io/embed.js" type="text/javascript"></script>

The code will work in WordPress as well.

URL Encode

If you need to special characters encoded in a URL, these sites really come handy. Why is there a need to encode? URLs accepts only alphanumeric characters and a limited number of special characters. For example, : and / are common characters you’ll find in URLs. Meanwhile spaces are not allowed, but instead are represented as %20 when encoded. There are other special characters that will need to be encoded.

Here are a couple of sites to help you encode:

https://www.urlencoder.org/
https://www.url-encode-decode.com/

Implementing Surfcali.com

I have a website called Surfcali.com. It’s a website that provides tide table information for select California beaches. The tide information on the website is auto-generated by the xtide program which is available on most Linux distributions.

You can install xtide on Ubuntu by typing this command from the Terminal.

sudo apt-get install xtide

Instead of explaining how the website is implemented using lots of words, it’s probably much easier to explain it via video.

So, here’s a short video of how Surfcali.com was put together.

Video

How to Zebra Stripe a Table

A HTML table can be difficult to read, especially if there are hundreds of rows. Reading across a row can sometimes be a challenge. One way of making the table more legible is to alternate the background color of each row. By the way, the plugin used on this blog to display code uses zebra stripes. Zebra stripping can be done by toggling a variable and alternately displaying an odd or even CSS class as it goes through the loop.

The Code:

// set variable initially to "odd."
// loop 4 times for demo purposes.
// toggle CSS classes while in a loop.
$c = "odd";
$count = 0;
echo "<table>";
while ($count < 4) :
  if ($c == "even") : echo "<tr class='even'>"; $c="odd"; else : echo "<tr class='odd'>"; $c="even"; endif;
  echo "<td>Data</td>";
  echo "</tr>";
  $count++;
endwhile;
echo "</table>";

The Result:

<table>
<tr class='odd'><td>Data</td></tr>
<tr class='even'><td>Data</td></tr>
<tr class='odd'><td>Data</td></tr>
<tr class='even'><td>Data</td></tr>
</table>

The Style:

.odd { background-color: #fff; }
.even { background-color: #eee; }

To see it in action, visit CodePad.