Skip to content

Leadership done right

Dear Reader,

I don’t get to blow the whistle,
I don’t get to ring the bell,
but let this sucker jump the track,
and see who catches hell.
— Author Unknown

Leadership is not about taking credit for the good; leadership is about shielding your team from the bad.

Next time your project goes off the rails, make sure you are standing out front.

Protect your team. That is one of the most important jobs of a leader.

Until next time,
I <3 |<

OpenHab Christmas Rule

Dear Reader,

Update: I posted the basic rules over on the OpenHab community site. The result was a much more elegant version of the rule determining if it’s time to turn on the Christmas Lights or not. Check it out and make sure you say thank you to Rich.

If you read my last post “OpenHab Notify Rule” then you know my latest hobby is home automation using OpenHab. it’s fun and while it still involves computers and programming, it helps me remember why I hate Java so much. :)

As I write this, we are in the midst of the Christmas Season and the Lovely and Talented Kathy lives for this time of year so that she can decorate the house. Since we just moved into a new house, this is a “rebuilding year” for us decoration wise, which is the perfect time to begin automating things. Thankfully, OpenHab makes that real easy. Below is my recipe for automating turning things on a dusk and off at 11:00 PM.

 

Items

I don’t have much in the way of Items yet. We just have the lights on the tree to turn on. So here is my single Item that I have to define.

1
2
3
4
5
6
7
Switch Plug_Christmas_Tree "Christmas Tree"  (christmasLights)
{
    channel="zwave:device:512:node29:switch_binary"
}
 
Group christmasLights
Switch sChristmasLights "Christmas Lights" <switch>  [ "Lighting" ]

All I do it turn on and off the plug. That last one, sChristmasLights, is so that I can expose it to Amazon’s Alexa. Don’t judge me! I don’t expose it directly to my network, it goes through a separate system that has a secure tunnel in to this one service. Trust me, I don’t trust Bezos any more than you do.

Rules

The items weren’t the hard part on this particular project, it was the logic behind turning things on and off and when. Here are the constraints:

  • Turn the lights on a Dusk
  • Turn the lights off at 11:00 PM
  • Regardless of what those liars marketers at Wall-Mart, or Target, or Amazon would have you believe, the Christmas season begins on the Friday after Thanksgiving and goes through the end of December. Don’t execute these actions if we are not ‘in season’.

So with those constraints in mind, here is what I came up with.

Imports

Since this is Java, you need to import a few things. These need to be at the top of whatever rules file you put the rules in.

1
2
3
4
5
6
import java.time.Year
import java.time.Month
import java.time.temporal.TemporalAdjusters
import java.time.temporal.ChronoUnit
import java.time.DayOfWeek
import java.time.LocalDate

Turn Lights on

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
rule "Christmas Lights ON"
when
  Channel "astro:sun:local:civilDusk#event" triggered START
then
  val String currentYear = String::format("%1$tY", new java.util.Date )
 
  val LocalDate thanksgiving = Year.of(Integer.parseInt(currentYear)).atMonth(Month.NOVEMBER).atDay(1)
    .with(TemporalAdjusters.firstInMonth(DayOfWeek.THURSDAY))
    .with(TemporalAdjusters.nextOrSame(DayOfWeek.THURSDAY))
    .with(TemporalAdjusters.next(DayOfWeek.THURSDAY))
    .with(TemporalAdjusters.next(DayOfWeek.THURSDAY))
    .with(TemporalAdjusters.next(DayOfWeek.THURSDAY))
 
  var LocalDate lastDayOfYear = Year.of(Integer.parseInt(currentYear)).atMonth(Month.DECEMBER).atDay(1)
    .with(TemporalAdjusters.lastDayOfYear)
 
  var LocalDate today = LocalDate.now()
 
  if (
    today.until(thanksgiving,ChronoUnit.DAYS)<=0 &&
    thanksgiving.until(lastDayOfYear, ChronoUnit.DAYS)>0
  ) {
    logInfo("LIGHTS","Light the Christmas tree")
    christmasLights.sendCommand(ON)
  } else {
    logInfo("LIGHTS",today.until(thanksgiving,ChronoUnit.DAYS).toString + " days until the Christmas tree is lit.")
  }
 
end

See, now you too can hate on Java. :)

Honestly, DateTime math sucks in any language and DTM is the heart of this problem. Thanksgiving is the 4th Thursday of the month of November in the US. That big ugly thing starting at line 7 computers the 4th Thursday of the month. On line 5, we computer the current year so that the ugly statement knows which Thanksgiving we want computed.

Now that we know the upper bounds of our window, we need to computer the lower bounds. The last day of the year. That one is easy.

From there it’s easy. Are there zero days or less left until Thanksgiving? If so, have we hit the end of the year? If we are between those two dates, LIGHT THE TREE!

This rule runs at dusk every night and depends on the Astro binding. The Astro was the second binding I installed, Z-Wave being the first. When I write my OpenHab book I think I’ll call it “OpenHab from Astro to Z-Wave” :)

Turn off the lights

Now, I could do all of those calculations every night at 11:00 to see if the Christmas lights need turning off. As it turns out, I’m lazy; that and I discovered the cron rule trigger. To turn the lights off I use the cron trigger to fire my rule every night at 11:00 in November and December. Yes, I cheated, deal with it.

Here’s my lights off rule.

1
2
3
4
5
6
7
rule "Christmas Lights OFF"
when
  Time cron "0 0 23 1/1 NOV,DEC ? *"
then
  christmasLights.sendCommand(OFF)
  logInfo("LIGHTS","Christmas, Lights Off")
end

Simple, huh?

That’s it. With those to rules and three items, I never ever have to worry about turning the tree of or on again. Next year, exterior illumination! :)

Hardware

To make the magic happen, I invested in a GE Z-Wave external plug. While I plan on wiring all my plugs in the house with Z-Wave, I’m not ready to do that just yet. With this, I just plug it in and plug the tree into it. Easy Peasy.

Wrapup

I hope that sharing what I know about seasonal illumination enhances your season. Remember, as much fun as it is to get together with family, that’s not the reason for the season.

Until next time,
I <3 K

=C=

The PHP Community is who *I* Say It Is

Dear Reader,

Yes, you read that correctly, the PHP Community is what and who I say it is. It is composed of the people that I say are a member, and I choose who are the leaders.

Here’s the thing, though, when I say “PHP Community”, in my mind, I see something different from you. My guess is that my friend Larry Garfield  sees something different too. (Larry has no idea that I am mentioning him in this post so don’t go all hatey on him)

In the US, when I say “House of Representatives”, all of us think of the same people. We know who they are, they are set aside and we give them power. However, when I say “PHP Community” there are more than five million different versions, each belonging to a different person because there are more than five million PHP developers out there. Who is in the community and who it’s leaders are are largely a matter of personal point of view.

You knew I had to make this about me

There has been a call for leaders to step up. The people that I consider leaders have stepped up. That having been said, the people I consider leaders may not be the people you consider leaders, and that’s fine. Let’s take me as an example. Many people consider me a leader in the PHP community. It may surprise you (and for some of you, it won’t) that there are a lot of people that do not consider me a leader.

  • There are people out there that dislike me because I created a for-pay PHP User Group.
  • There are people who will never consider me a leader in the community because I am a Christian and that entails beliefs that they cannot stomach.
  • There are people who do not consider me a leader in the community because they have seen my code and do not consider it good enough for me to be a leader.

Most importantly, I do not consider myself a leader because for the most part, I do not lead. I do try to educate, my goal is to build the next generation of PHP developers. I try to serve when I can, but I don’t always, I’ve let people down. In your version of the PHP Community, if I am a leader, I am very honored and hope that I don’t let you down. However, that is your particular version, others have different opinions.

In my version of the PHP community, I openly reject any leader who is actively seeking a position of power, regardless of how this manifests itself. In my version of the PHP Community, no leader has enough power to tell me that I need to reject someone else’s leadership or actively shun someone else. There are people I shun but to the best of my knowledge I have never encouraged others to do the same. Most of us are adults and can make up our own minds.

Make Up Your Own Mind. Make Up Your Own Community

Don’t look to leaders when you are trying to make a decision, decide for yourself. Please don’t look to me for leadership on what you should think about someone or some group. I am just as human and defective as you. All I know is what works for me. Be very wary of anyone trying to tell you how to feel about any member of the community. Look for yourself and decide for yourself. If you decide that someone is not worthy of your attention, then by all means, don’t give it. Don’t however, fall into the trap of deciding and then dogpiling on someone because you’ve decided you don’t like them.

:Conclusion

The PHP Community is who YOU decide it is.  Make it a community that works for you.

Until next time,
I <3 |<
=C=

p.s. next week, I am back to Public Speaking, I promise.

Photo Credit: Day 18 by Emily Neef
Used under Creative Commons
(Read the title tag)

MailChimp, Secure Forms, and owning mistakes

mc_freddie_color_webDear Reader,

 

Screen Shot 2016-03-30 at 9.25.34 AM

So yesterday (March 29th, 2016) I started a small crap-storm on twitter directed at one of my favorite SaaS vendors, MailChimp. I didn’t mean to, I really do like MailChimp. I’ve been using them since ~2009 and find their service to be awesome. However, As you can see from my tweet, I couldn’t figure out how to make the signup form for Nomad PHP secure.

At first, do no harm

The problem arose when the person running @mailchimp answered and informed me that even though the URL wasn’t secure, the information was securely transmitted the server. I would show a picture of that tweet as well but @mailchimp has removed it. The information passed was of course, wrong.  If the URL is not secure, the information being sent is being transmitted across the wire in clear text. If at this point, you are not sure what the difference between HTTP:// and HTTPS:// is, read “How does HTTPS provide security?”.

The problem is, not only did I know it was wrong, those people who follow me and @mailchimp also knew it was wrong. What followed was a dogpile on @mailchimp, which was not my intent, but then again, I didn’t ask them to give false info either. Honestly, I just wanted to know how to get an encrypted URL to the form for people to join the list.

The answer

Later in the day – I’m not sure if no technical people noticed, or if they just wanted to let things die down – @mailchimp did eventually give me the answer I needed. To their credit, they owned the mistake that was made earlier in the day as well.  If you don’t use MailChimp to manage your mailing lists, this section won’t be of much interest to you.

First, I am talking about a specific type of form, MailChimp’s “General Forms”. These are the forms that are hosted on MailChimp’s servers and they just give us a URL to pass out.

To get there, log into your account and select a list.

screenshot_001

From there select “Signup Forms” to get to this screen.

screenshot_002

And from there, select “General Forms”. You’ll get a screen that among other things shows you the “Signup form URL”. This is what all the fuss is about.

screenshot_003

 

Notice, it’s not secure. When they finally did answer, @mailchimp told me to replace the domain with “list-manage.com” and then I could use https://.

Screen Shot 2016-03-30 at 9.54.29 AM

So I took them at their word, using the info from the screen above, I tried:

https://list-manage.com/bxaPaD

This did not. I simply replaced eepurl.com with list-manage.com and added the s to https://. The instructions were as clear as they could make them in 140 chrs, which is to say, they left out a step.  eepurl.com is MailChimp’s URL shortener. It will not – and apparently never will – handle encrypted URLs. However, Nomad PHP’s eepurl resolves to http://nomadphp.us1.list-manage.com/subscribe?u=b39a511bbe71aa74d27241bb6&id=193666c7d7 and that page is encrypted. A sad note, not all of the elements on the page are encrypted, so even thouhg the data being sent back to the server is encrypted, the page won’t get a “Green Lock”. MailChimp, can we do something about this?

tl;dr

If you use Mailchimp and want to pass around a secure URL so that people can join your mailing list, take the eepurl, paste it into a browser and let the page load, then take that URL and add https:// . Since in Nomad PHP’s case, the form is actually hosted at list-manage.com, I didn’t need to make any changes. It is my understanding that this is not always the case. So make sure that if your forms doesn’t resolve to list-manage, that you change the domain as well.

 

fClose()

Ok, back to the crap storm. MailChimp did not shy away from their mistake, unlike a lot of companies I deal with, they owned it.

Screen Shot 2016-03-30 at 10.07.34 AM

They could have “Clarified” the response, they could have ignored it totally and just kept going. MailChimp did the right thing. While I am bummed that I didn’t get a screenshot of the offending tweet, I actually do appreciate the fact that they deleted it instead of just leaving bad info out there for unsuspecting muggles to run across.

I deal with MailChimp not because they are flawless in their execution – far from it, they pissed me and a bunch of others off recently with their changes to Mandrill – but because when they are wrong, they own it. I respect that, I aspire to that.

I aspire to treat my customers with the same candor. With Nomad PHP, Day Camp 4 Developers, and all my other endeavors, I try to be honest with my customers and own my mistakes.Whether this takes the form of a public apology or a refund to someone who wasn’t 100% satisfied that I delivered what I promised, I would rather take the hit financially or ego-wise than have someone think I wronged them.

Thank you MailChimp for leading the way.

Until next time,
I <3 |<
=C=