Coffee and laptops

About 3 weeks ago, I tried to share a cup of coffee with my laptop. It wasn’t happy.

We have a bunch of coffee mugs from a set of dishes made by Pfaltzgraff. They are probably close to 10 years old now and the handles keep breaking off. Literally, the handle detaches from the mug. The set started with 8 mugs and I’ve superglued 4 of them back on now.

So, 3 weeks ago, I sat down at my desk with a cup of coffee, opened up my laptop, lifted the mug to take a drink and about 6 inches above the desk the handle detached and the mug dropped back to the desk. I was poised with only the handle in my hand as coffee flooded the keyboard (Murphy’s law).
Continue reading “Coffee and laptops”

Refugees

One of my coworkers is a refugee from one of Trump’s shithole countries. He is college educated with a degree in business economics, speaks 5 languages fluently and was an instructor in one of them. He currently holds down a full time job and a part time job and is starting his own business. All while sending 3 daughters to college.

I can certainly see why we wouldn’t want his kind here.

Python: unexpected behavior with static initializer

I’ve been working on an IOT project using a Raspberry PI Zero W. I fully intend to document it here in a future post, so I won’t go into details about it now.

This post came about because I was troubleshooting a problem and the root cause surprised me.

I come from the world of C#/Java/Swift and part of the reason for taking on this project was learning a new language. The code for this device is written in Python.

Python has OOP structures like the aforementioned languages and I expected similar behavior. The OOP mantra, of course is, Encapsulation, Inheritance, Polymorphism.

From my reading it seems that Python doesn’t have the same idea of private/public as other languages making the first principle a bit fuzzy.

I have a class with quite a few class variables. This class is instantiated multiple times and I fully expected that the variables from each instantiation would be distinct. However, in this case, one of them was not.

I have code that looks like this:

class myClass:
    myData = [0] * 100

Later I fill the array with data.

What I discovered was that apparently all of the arrays were mapped to the same address space. I only had one copy of the data and was overwriting it in each class instance. As I was expecting each to be unique, this was not the desired behavior.

The solution was simple, I moved the initialization into the class __init:

def __init(self, vars...):
    self.myData = [0] * 100

It now works as expected, but it took quite a while to drill down to the root cause.

StackOverflow question here.

Reflections of a Domino’s Delivery Driver

Right upfront I would be remiss if I didn’t say that I do enjoy this job despite everything below.  Except for the hours, it’s an easy gig that pays quite well.

About the pay:
I get minimum wage. In my state, that’s about $10.50/hour. Well, that’s my base pay.  I also work for tips.  In the current economic environment, tips are about $3.50 per delivery.  So if I can manage 3 deliveries/hour, that’s usually an additional $12.  Making my take home around $20/hour.
Continue reading “Reflections of a Domino’s Delivery Driver”

Calendar file generation

I had a need to create ics files for a PHP project I was working on. I found a existing class that had most of what I needed and it was simple to modify it for the additional features I needed.

Giving credit where it is due: ICS.php (https://gist.github.com/jakebellacera/635416)

Then I discovered that I had more than an occasional need to generate ics files outside of that project, so I decided to deploy a web service that I could call and a form that utilized that service.
Continue reading “Calendar file generation”