Mycroft AI

Today I found out about Mycroft AI, which is an open-source answer to Alexa, Siri, Cortana, and OK Google. Like its proprietary competitors, Mycroft will listen to your commands and do stuff for you, such as setting an alarm, playing music, telling you the weather, getting stock quotes, and so on. Unlike its proprietary brethren, Mycroft won’t analyze this information to play targeted ads for you.

I haven’t installed it yet because I’m still looking into it. I have a lot of questions that I still have to find answers for. For example…

I have a Linux laptop that I use pretty frequently, plus an Android smartphone, a Linux PC in the home office, and another Linux PC being used as an entertainment center. My first question is whether I should us a different wake word for each device, or use the same one for all of them? Is it like the issue of password reuse, where it’s more secure to use different wake words?

It’s an interesting idea, so I hope they keep the development going.

Max Social

Reading this article about how the “short-term, dopamine driven feedback loops” created by social media giants are killing normal discourse, it makes me wonder how to fix it. Maybe if Facebook, Twitter, etc limited people to a maximum number of friends/followers, it would introduce a check in the system.

I normally use Twitter, so I’ll use their terminology for this. Let’s say everybody can only follow 500 people, and that they can only be followed by a maximum of 500 people. By limiting the number of people you follow, your diet of tweets is limited only to those Twitterers. That extra cute video of your kitten playing with a puppy can still go viral, but it’ll take longer to happen.

With a maximum limit on who we follow and who can follow us, we’re forced to do some picking and choosing. I think most people would follow close family members and allow the family members to follow them, and there would probably be something similar with coworkers (or maybe not). But for the rest, who would you follow? Politicians? Celebrities? Athletes? Artists? Conversely, who would you let follow you? Former classmates? Fellow hobbyists? Advertisers? Co-religionists?

Do you follow someone who seems to have gone off the rails and started relentlessly tweeting about pigeons? You can unfollow him. Do you follow an aunt who never tweets, ever? Unfollow her and follow someone more interesting.

Introducing maximum limits into social media would be an equalizer, since the cashier at the deli around the corner could have the same number of followers as the leader of the country.

Just a thought.

Move it on over

Today I’ve moved my website from Site5 to Dreamhost.

It’s not a decision I made lightly. because moving a site, with all the posts, media, etc is pretty complicated. But for roughly the same price, Dreamhost seems to offer better service and more amenities. The thing that really got me was that Dreamhost offers free SSL certificates from Let’s Encrypt, while Site5 seems to be dragging its heels on this. I suspect Site5 views SSL sales as a profit center. Regardless of whether that’s true, it’s hard to turn down free SSL certificates, thus the move to Dreamhost.

Review Haiku, again

Over the past year or so, I notice I haven’t been writing as many Review Haiku. There are a few reasons for this. One reason is that I wasn’t very satisfied with the most recent method of posting them, where I created a static PHP page for each review. While it’s good(-ish) if I want to compile them into an EPUB in the future, it’s also tedious.

Another reason is that I’ve been binge-watching TV series on Netflix and Amazon, and haven’t been watching as many movies. Very few TV series are worth creating a haiku for each episode, so I end up watching a lot of material for very few haiku.

There’s not much I can do about the latter issue, but I think I’ve fixed the former. Recently I took a class at Udemy on WordPress theme development and it was very informative. Since then I’ve created a custom theme, with a custom post type (review) and custom taxonomies for the post type. This past week I’ve been entering the older Review Haiku into WordPress and this page is the result. I hope you enjoy them.

JavaScript Coding Challenge 1

JavaScript Coding Challenge 1

For a long time, JavaScript was a programming language I tried to stay away from. It’s notorious for being insecure, but maybe a lot of that is due to sloppy coding by some of the people who use it. These days, however, it’s nearly everywhere, so it’s hard to escape. When creating websites, it’s considered as essential to know as HTML and CSS. Recently, I noticed Udemy had a sale on virtually all classes, so I signed up for The Complete JavaScript Course: Build a Real-World Project. I’ve only been doing it a few days, so I’ve got a long way to go. Of the 113 lectures, some of them are called “Coding Challenges”, where the student tries to write a project based on what has been taught already.

Lecture 14 is Coding Challenge 1. The challenge is a simple game between two players. Each player takes their height in centimeters and adds it to five times their age, and the winner is the one with the highest number. To make the game a bit more complex, a third player later joins the game. The code below is my solution.

// simple game
// highest value of height (in cm) and five times age wins

var playerOneHeight = 180;
var playerOneAge    = 26;
var playerTwoHeight = 190;
var playerTwoAge    = 22;

var p1Score = playerOneHeight + playerOneAge * 5;
var p2Score = playerTwoHeight + playerTwoAge * 5;

/*
if (p1Score > p2Score) {
    console.log('Player One wins');
} else if (p1Score < p2Score) {
    console.log('Player Two wins');
} else {
    console.log('Players One and Two are tied');
}
*/

// make it more complex
var playerThreeHeight   = 176;
var playerThreeAge      = 54;

var p3Score    = playerThreeHeight + playerThreeAge * 5;

if (p1Score > p2Score && p1Score > p3Score) {
    alert('Player 1 wins!');
} else if (p2Score > p1Score && p2Score > p3Score) {
    alert('Player 2 wins!');
} else if (p3Score > p1Score && p3Score > p2Score) {
    alert('Player 3 wins!');
} else if (p1Score === p2Score && p1Score > p3Score) {
    alert('Players 1 and 2 have tied!');
} else if (p1Score === p3Score && p1Score > p2Score) {
    alert('Players 1 and 3 have tied!');
} else if (p2Score === p3Score && p2Score > p1Score) {
    alert('Players 2 and 3 have tied!');
} else {
    alert('All players have tied');
}
    
 console.log('Player 1: ' + p1Score + ' Player 2: ' + p2Score + ' Player 3: ' + p3Score);

I’ll post more of the coding challenges later.

Attic Insulation

As mentioned in the previous post, the attic of my house had virtually no insulation in it. Indianapolis is sort of in a weird place when it comes to weather. We don’t often get heavy snowfalls or bitter cold in the winter, however, they do happen every so often. Since heat rises, an uninsulated attic lets out a lot of heat. Adding insulation is like putting a thick quilt over the top of the house, trapping most of the heat underneath it, which is what you want in winter. By trapping the heat, the heating bills should be lower. So the theory goes, at least.

In fall of 2016, I started looking at insulation, hoping to install it before winter. My first choice was to get insulation made from recycled denim, but it isn’t carried by stores in my area and getting it shipped to my house would have been prohibitively expensive. Fiberglass insulation is also expensive, but it’s available almost everywhere. Reluctantly, I decided to go with fiberglass because it’s cheaper and more commonly available. The final product I chose was Owens-Corning kraft-faced R-38 batts. Each floor of the house is a little over 800 sq ft, so I planned on getting that much insulation. Since each pallet of insulation covers approximately 320 sq ft, I bought two pallets and planned on seeing how much I needed after going through it all.
Continue reading “Attic Insulation”

The House

Home Sweet Home
Home Sweet Home
Last spring, I bought a house in the Haughville neighborhood of Indianapolis. It’s a two story house in the American Craftsman style and was built in the 1920s. Though the house has been well-maintained and is very livable, with a house this old, it’s not surprising it needs some work. As I do new projects around the house, I’ll post about them, along with pictures. But before I do that I want to write a bit about the neighborhood, in general, and the house, in particular.

I moved to Indianapolis in March of 2000, and prior to the move I’d lived in Colorado for more than 20 years. I didn’t know anything about Indy, but I knew that if I wouldn’t be able to see mountains, I wanted to live in an urban area, where the tall buildings would block the mountainless view. Basically, I didn’t want to see that the mountains weren’t there. Weird logic, I know. Upon moving to Indy, I got a 500 sq. ft studio apartment in downtown Indy at the corner of 13th and Pennsylvania (around the corner from the President Benjamin Harrison home). It was a nice place, but rather basic. Rent when I first moved in was $325 per month. And life went on.
Continue reading “The House”

Messing around with code

Coding is something I do so rarely I often have to look online for tips and go through alot* of trial and error to get things done. On the current project, I wanted to do something differently.

Normally, in most database tables, it’s common to create an ID field to hold a number that serves as a unique identifier for that record (commonly known as a primary key). It’s easy to setup because the database does all the work, therefore it’s a very common form of primary key. However, primary keys don’t necessarily have to be numbers. The only requirement is that they be unique within the table.

For this project I wanted each primary key to be 10 characters long and consist of numbers and letters. Ten digits, plus 26 lowercase characters, plus 26 uppercase characters in a ten character string means 141 trillion possible unique keys (10+26+26)10 = 141,167,095,653,412 That should be enough for any database… that I’m working on.

In playing around with the code I realized there were a lot of other possibilities. I didn’t have to limit myself to numbers and the Latin alphabet. In fact, I didn’t need to use them at all. The code below is the same code I came up with, but the characters I used are different.


// generates a 10 character random ID
function id_gen($newid) {
$chars = "⩽⩾⩿⪀⪁⪂⪃⪄⪅⪆⪇⪈⪉⪊⪋⪌⪍⪎⪏⪐⪑⪒⪓⪔⪕⪖⪗⪘⪙⪚⪛⪜⪝⪞⪟⪠⪯⪰⪱⪲⪳⪴⪵⪶⪷⪸⪹⪺";
$tmp = preg_split("//u", $chars, -1, PREG_SPLIT_NO_EMPTY);
shuffle($tmp);
$tmp2 = join("", $tmp);
return mb_substr($tmp2,0,10,"UTF-8");
}

Calling id_gen in some PHP code would result in something like this ⩾⪺⪐⪒⪞⪠⪎⪉⪚⪷. Imagine a table full of those as their primary keys. The key to the function is PHP’s builtin mb_substr function. The normal substr function will take a string and cut it to a particular length, but it doesn’t do well with most UTF-8 characters. The mb_substr function can handle multibyte characters, which is why it’s used in this function.

* Fuck prescriptivist grammarians. “Alot” is a perfectly legitimate English word. If it gets used and is understood in context, it’s part of the language.

Another semester

Another semester, another Chinese class. This semester at IUPUI I’m taking EALC-C 301, Third Year Chinese 1. Classes started last week and I can already tell the class is going to be interesting. This is the first Chinese class I’ve had where I feel like I’m in the bottom-half of the class. Granted, it’s a small class, with only seven students, but some of the students have set a high bar. Two students are Chinese, so I’m not sure why they’re taking the class. Maybe they hope to test out of it. Another student taught English in China for a year. I’m under the impression he hasn’t been there for awhile, but he definitely has more practice.

Still, I’m resolved that the high bar isn’t insurmountable. I just have to work harder.

A Chinese coworker, who’s always good for telling me different chengyu (成语), told me about a saying of Mao that appears in classrooms over there:

好好学习,天天向上。
Hǎohāo xuéxí, tiāntiān xiàngshàng.
Study well, make progress everyday.

I take it to mean I should study everyday, including weekends, to make progress. To help me in my Chinese studies, I’ve also bought a year-long Chinese course from Transparent language. I’ll let you know how it goes.