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.

Music and the Lollipop Lock Screen

Music and the Lollipop Lock Screen

After the battery started giving me trouble in my THL T6 Pro, I broke down and bought a slightly more upscale smartphone – an ASUS Zenfone 2. Both phones are about the same height and width, though the ASUS seems to be a bit thicker. One of the main differences in the phones is that the THL used KitKat (Android v. 4.4.x) and the ASUS uses Lollipop (Android v. 5.x). Anytime I get a new piece of technology, it takes awhile to figure it out and get it to work the way I want it to. I don’t plan on everything working right out-of-the-box.

Because it’s a good security practice, and because my employer requires it, I always set my mobile devices to require a PIN or password at the lock screen. This isn’t much of an issue, unless I’m listening to music. When I’m walking to or from work, I like to listen to music. The music app is set to shuffle, but it sometimes lands on a song that I don’t feel like listening to. With Android KitKat, I was able to go to the lock screen and fast-forward to another song, but I wasn’t to do this in Android Lollipop. Trying to figure it out, it looks like I’m not the only one with this problem.

Although I tried some of the online suggestions, they didn’t work for me. All of the suggestions I read had the same instructions: go to Settings -> Sound & Notification -> When device is locked -> Show all notification content. I did this but my lock screen was still only showing the time, the temp, and the number pad for the PIN.

To fix it, after doing the step above, I went into Settings -> Lock screen -> Skip the slide page -> Off. The Slide page is where the music widget shows up. Try it out.

Go to Music and start a song, then press the power button on the device to turn the screen off. Press the power button again to get the lock screen. Your song should still be playing, and you should be see the music widget, plus whatever other notifications you have enabled. If you want to unlock the device, you can swipe up from the bottom.

Live Below the Line

A year or so ago I read about a challenge where some people in the UK tried to live on £1 a day for five days. This is the level the World Bank sets as the level of extreme poverty. Nearly 1.2 billion people around the world live in conditions of extreme poverty. In the US it equates to about $1.50. I found out about the challenge too late to participate last year, but this year I’m going to give it a go.

Coincidentally, this morning I read that Gwenyth Paltrow will be taking the Food Stamp Challenge. The Food Stamp Challenge is similar, but it sets the bar at about $30 for seven days, which is what a family in the US would have to live on if they relied on food stamps. Both challenges are meant to draw attention of people living in poverty, though Live Below the Line is an organized attempt to raise money for charities fighting conditions of poverty.

While I’ve never lived in conditions of extreme poverty, I remember we used to be on food stamps when I was a kid, and as an adult, there have been times when I was unemployed and wondered where my next meal was coming from. This gives me reason enough to try and help. The challenge takes place from April 27th to May 1st.

It’s not going to be a true challenge. People who live in extreme poverty have to use that money to pay for food, shelter, clothes, healthcare, transportation, sanitation, and so on. For me, the challenge will just pay for food. I already have clothes and health insurance. I don’t have a car, so I don’t have to worry about that cost. My rent, which isn’t exorbitant, runs about $18.50 a day. Since I don’t plan on living on the streets those five days, it’s not a real challenge, in my opinion. However, I plan on blogging and showing what $1.50 a day buys in the US. The answer is not much.