Spark Required

Pro tip: After running the gas tank dry, disconnecting the spark plug, removing the blade, changing the oil, installing a new blade, and filling the gas tank… you need to reconnect the spark plug if you want to start the engine.

For as bad as the air filter was that I replaced last week, the old oil was so much worse. Thick, black sludge and not much in the engine to drain. From now on I’ll try to perform these maintenance tasks more often than every 6 years.

The Defiant Ones

Adam Savage raved about The Defiant Ones on his podcast. I was subscribed to HBO for Game of Thrones, so I checked it out this weekend before cancelling.

“The Defiant Ones” examines the partnership between Jimmy Iovine and Dr. Dre – one the son of a Brooklyn longshoreman, the other straight out of Compton – and their leading roles in a chain of transformative events in contemporary culture.

The series is 4 parts and it was so good I couldn’t stop watching, so I watched all 4 hours in one sitting. I grew up listening to a lot of this music in the ’90s, but never knew most of the stories behind it all. I can’t even imagine the stories that will never be told.

Unboxing: HackerBoxes #0022 – BBC Micro:Bit

The latest HackerBox came in the mail yesterday. I managed to avoid any spoilers so thought I’d see how dumb I can sound as I figured out what was in the box.

I’m looking forward to checking out the Micro:Bit and its blocks editor. The 128×64 OLED and WiFi modules will definitely get used in projects at some point.

Knowing the Micro:bit sells for less than $20, this box seemed light on value, so I had a look. Like last time, all prices are from Amazon unless noted.

  • HackerBoxes #0022 Collectable Reference Card – $1 (estimate)
  • BBC Micro:Bit – $16.99
  • BBC Micro:Bit Connector Breakout Kit – $5.38 (
  • Twin AA Battery Holder – $2.79
  • OLED 128×64 pixel I2C Display – $6.99
  • Alligator Clip Jumper Wires – $1.50 (estimate)
  • Miniature Solderless Breadboard – $3.26
  • ESP-01 Wi-Fi Modules – $2.60
  • Six LED Indicator Module – $1.10 (2 for $2.21 on
  • Passive Piezo Buzzer – $1 (estimate)
  • AMS1117 3.3V Regulator Module – $1 (estimate)
  • Header Pins – $1 (estimate)
  • DuPont Jumpers – $1 (estimate)
  • Micro USB Cable – $5
  • Micro USB Breakout Module – $1.84
  • Exclusive Micro:Bit Decal – $1 (estimate)

Several of these items are extremely cheap and only sold in multiples so I gave generous estimates. Total comes to $53.45. Things in that $3-7 range really add up quickly. Still a good value for the $44 subscription.

If you’re interested in learning more about this particular box, check out the Instructables guide or leave a comment and I’ll try to answer.


5v Relay Module – Part 3

I had no plans for a part 3, but in part 2 of this series, I mentioned how I messed up the wiring several times when I was assembling the module. Instead of fixing it at the time, I started from scratch since I had extra parts. Well, I made some time to disassemble the non-working module and build a new one. I quickly set up a prototype on a breadboard to make sure I didn’t make the same mistakes and then I soldered it all together on a permanent board. Was smooth sailing, even with squeezing everything in as much as I could.

Now I have a two different spare relay modules, depending on power requirements, when I need one for a project.

Ant Bait

Occasionally during the summer months I get ants in my kitchen. I’ve always tried getting rid of them with Terro, without much success. I’m sure not leaving dirty dishes in the sink would help a lot, but that’s not going to change. 

I picked up a box of these Hot Shot ant bait stations and they really did take care of the problem in hours. I haven’t seen an ant since putting them out. I feel much better leaving them in a corner or by the sink, compared to pieces of cardboard with the Terro liquid.

Counting Types of Days in PHP

Since I work on our HR team at Automattic, sometimes I need to write code dealing with payroll. When someone starts or leaves we have to pay them for a partial period, which is based on the number of week days. Originally I wrote a simple function, but I set out to make it more useable. Here is what I came up with…

 * Counts the days (optionally limited by type of day) between (inclusive) two dates.
 * @param string $start_date First day (Y-m-d format).
 * @param string $end_date   Last day (Y-m-d format).
 * @param array  $types      Optional. Types of days to count. Default to all types
 * @return int Number of days matching the $types.
function get_days_between_dates( $start_date, $end_date, $types = array() ) {
	$count = 0;

	$included_day_type_indexes = array();
	if ( empty( $types ) ) {
		$included_day_type_indexes = range( 1, 7 );
	} else {
		foreach ( $types as $type ) {
			switch ( strtolower( $type ) ) {
				case 'weekday':
					$included_day_type_indexes = array_merge( $included_day_type_indexes, range( 1, 5 ) );
				case 'weekend':
					$included_day_type_indexes = array_merge( $included_day_type_indexes, range( 6, 7 ) );
				case 'monday':
				case 'mon':
					$included_day_type_indexes[] = 1;
				case 'tuesday':
				case 'tues':
				case 'tue':
				case 'tu':
					$included_day_type_indexes[] = 2;
				case 'wednesday':
				case 'wed':
					$included_day_type_indexes[] = 3;
				case 'thursday':
				case 'thurs':
				case 'thur':
				case 'thu':
				case 'th':
					$included_day_type_indexes[] = 4;
				case 'friday':
				case 'fri':
					$included_day_type_indexes[] = 5;
				case 'saturday':
				case 'caturday':
				case 'sat':
					$included_day_type_indexes[] = 6;
				case 'sunday':
				case 'sun':
					$included_day_type_indexes[] = 7;

		$included_day_type_indexes = array_unique( $included_day_type_indexes );

	$date = strtotime( $start_date );
	$end = strtotime( $end_date );
	while ( $date <= $end ) {
		if ( in_array( date( 'N', $date ), $included_day_type_indexes ) ) {

		$date = strtotime( '+1 day', $date );

	return $count;

/*** EXAMPLES ***/

echo get_days_between_dates( '2017-08-21', '2017-09-03' ) . "\n";
echo get_days_between_dates( '2017-08-21', '2017-09-03', array( 'weekday', 'weekend' ) ) . "\n";
echo get_days_between_dates( '2017-08-21', '2017-09-03', array( 'mon' ) ) . "\n";
echo get_days_between_dates( '2017-08-21', '2017-09-03', array( 'weekday' ) ) . "\n";
echo get_days_between_dates( '2017-08-21', '2017-09-03', array( 'mon', 'wednesday', 'fri' ) ) . "\n";

This is the output of the examples…


What do you think? What would you do different?

I put the function up on GitHub. Submit a pull request if you have improvements.

%d bloggers like this: