Punkstalgia

When writing I used to listen to music much of the time, but not so much anymore. But for some reason tonight I was inspired to put the pods in my ears and fire up some Stiff Little Fingers, starting with Suspect Device, one of the best Punk songs ever, then through Alternative Ulster and Can’t Say Crap on the Radio.

For a band with such an incendiary start, they have stayed together for a long time, and they produced memorable music for a couple of decades (it seems they are still making music together, which gladdens my heart). But those earliest, raw anthems that sing about “them” are my favorites. Stiff Little Fingers are punk, but the musicianship is there, always twisting, sometimes surprising, never dull.

Like all true punk bands, they were political. As a band in Belfast during the Time of Troubles, they were playing in a war zone. Those early concerts must have been damn near riots. I wish now I could have been at one, but I probably would have shit myself.

I haven’t got much writing done tonight, but I’m not sorry. It’s been a long time since I performed Suspect Device at Punk Rock karaoke down in San Diego (Yeah, I fronted a band with Greg Hetson (Circle Jerks) and Eric Melvin (NOFX) for one awesome and really loud three minutes. I’d like to believe Jennifer Finch (L7) was there too, but things are fuzzy), and it’s time to get back in touch.

Punk still lives today, but it’s not white guys with guitars who are making punk, it’s hip-hop and the countless variations I am not qualified to enumerate that carry that political torch of protest and disruption. But I like the guitars.

CODA: As I make my way through their catalog, I am reminded what pioneers that band could be on occasion. “This sounds like what <insert band here> did, only… [checks date] before them.”

1

In It to End It — With Your Help

Domestic abuse is a problem as old as humanity, but the last couple of years have been particularly bad for vulnerable people. The first step to recovering from abuse is often, “just get out of there,” and that’s never a simple calculus, but during a pandemic it gets ten times harder.

Several Bay-area organizations have banded together to make things less awful, and now that group is running a fundraiser. It’s a fitness-based endeavor, where participants set a mileage goal. Bikes are welcome, but it’s calibrated for running, so on a bike I can rack up a significant portion of their overall mileage goal.

And you can participate, too! You have two options: Sponsor me or put on miles yourself.

This is a local charity, so if you would rather support people closer to where you live, go for it. But please, please, support someone.

Top Golf

One of the awesome people who helped me get my shoulder working again was a friendly guy named Patrick. To succeed at a job like that, it takes more than a bunch of school and an internship and working one’s way up through the ranks. You have to be a people person. While Patrick was working on my soft tissues and testing my progress, there was also conversation. Physical therapy is like getting your hair done in that respect.

So while Patrick was exploring how far he could bend me before I yelped, we were also chatting about this and that. Since my presence there was due to a bicycle crash, naturally riding was part of the discussion. But Patrick also likes to swing a golf club, and eventually he told me about Top Golf.

I must confess I still don’t fully understand what this is, but I have grasped the most important part. Top golf is a place where you and your pals can go and have a beer or three and hit golf balls. But wait! There’s more! it seems that at Top golf there are computers and shit that analyze you shot and based on that you score points or kill monsters or ascend to primary breeder in your troupe. I glazed out at that part.

But the brilliance of all this is that someone asked the question, “What if we took the onerous task of hitting a golf ball, and turned it into a game?” Revolutionary!

Yep, someone has gamified golf. About time, too.

The Right Way to Build a Hotel on the Moon

There are three reasons to visit the moon:

  1. Low-gravity sex
  2. To say you did it
  3. It’s the fucking moon.

I have seen in my day more than one plan for a moon hotel. A few of those plans have some good ideas (really tall towers you can jump down the core of), but none of those designs understand a fundamental truth: Construction matters — every mark the construction crew makes on the landscape will outlive humanity.

On Earth, bulldozers level the property, the hotel goes up, and then the landscapers erase the scars of the machines used to create the hotel. On the moon, that won’t work.

Those footprints will still be there long after humanity is forgotten

When I’m looking out the window of Lunar Hotel 6, I don’t want to see the shattered remains of a landscape that will remember each footprint for tens of thousands of years. I want to see the moon, the way it is now. Every mark made during construction cannot be undone, so construction can make no marks near the hotel.

One of my best stories (note to self: submit story to next market) takes place in a hotel on the moon. Much of the story takes place in a dome that was raised from an underground tunnel and deployed like an umbrella, so that no human disturbance is evident on the other side.

I’ve got nothing against towers, either, but unless you want the tower dwellers to forever look out over wretched destruction, those towers have to be built from the inside. (Flashing to a 3D printer that turns material excavated from the tunnels below into the walls of the tower, lifted up one level at a time until the tower is two miles high and the horizon is curved. I might have a spiritual sequel.)

My note to any who might be considering building a hotel on the moon: It’s the moon. Respect that. Understand that. Hire me as a consultant. I’ve just given you good stuff for free, but I have more.

A Matter of Consistency

While I was attempting (and failing) to write an episode thirty days in a row here at Muddled Ramblings and Half-Baked Ideas, a kid named James, known as the Iron Cowboy, today wrapped doing 100 full-length triathlons in 100 days.

Yep, 2.4-mile swim, 112-mile bike ride, followed by a full-ass 26.2-mile marathon.

100 times. In 100 days.

He did it to raise funds and awareness to rescue children from sex trafficking and sexual exploitation, so maybe he’s crazy, but it’s the right kind of crazy. My pals at Fezzari Bikes are proud sponsors, and I love them for that as well.

I can only imagine how it will feel for the Iron Cowboy to take a day off tomorrow. Congratulations, James!

Measuring Myself Against the Mountain

Plan A today was to head south on the lovely Coyote Creek trail, and depending how I felt when I got there, try attacking a new hill. The trail was blocked by a fire truck, however, as the crew sprayed water over a still-smoldering brush fire. I turned around and decided instead to test my progress toward my long-term goal of summiting Mt. Hamilton. I wouldn’t try to break my record, I decided, but there’s a nice loop that goes up the main highway and then descends on a smaller road that sees almost no traffic.

About a mile after I turned around I thought, “I should have taken a picture — fire trucks are exciting!”

It was even more annoying than usual getting to the base of the mountain, catching almost every single red light as I rode through the city. Grrr. Then it was time to climb. I have gotten better at riding very, very slowly, and I’m strong enough that I can almost sustain that snail’s pace for a decent period of time. The grade of the road is very consistent, but occasionally there’s a short stretch that’s a wee bit steeper, a difference you wouldn’t even notice while driving, but for me it’s the difference between sustainable and deficit. A little less down force on the seat post would put me over the top, I think.

I got to the turn-off for the descent, and after a short breather I decided instead to try to push up the mountain a little farther before going back down. Which is when my legs delivered their big, fat NOPE! I’d hardly gone any distance at all before I turned back and rolled on down the mountain. I added a couple of easy miles at the end for nothing more than pride.

Twenty miles to get to and from the actual ride, and six miles for the climb and descent.

1

The Chosen One

The archives of the True Disciples of the World-Changer were burned to the ground, and it turned out the data backup service they used was owned by their enemies. It is only by the most outside of chances that the content of the email the Disciples sent me was saved by their email provider for marketing purposes.

I did not read the email at the time, and even if I had, it would not have changed anything. When you read the excerpt below, you can see that it comes off a bit… Nigerian.

It began thus:

Blessings upon you, chosen one! You have been “randomly” selected to usher humanity into a new era! What will this new era be like? We all wait with great anticipation to learn the answer to that question from you! As the chosen one, you will leave a permanent imprint on the course of humanity forevermore.

How you exercise this great responsibility is of course entirely up to you, but we True Disciples of the World-Changer are eager to help you come to terms with your responsibility.

Alas, please note that the True Disciples of the World-Changer only invoke the “random-chance” protocol when humanity is under dire threat, and this time is no exception. Should those forces that wish to end humanity learn that you are the chosen one, they will stop at nothing to end you. For that reason, please do not share this email with anyone, no matter how trusted.

In retrospect, that explains a lot of what’s happening now. Especially when you consider that email is not remotely secure, and the Band of Destruction had long since put their tentacles in every email provider. There was more in the email, about contacting them, and giving them info, and thwarting an existential threat, but how many of those do you get every day?

Live and learn, I guess. Sorry, human race. My bad.

php’s missing array_usearch

Pure geekery today, kids.

php has a bunch of functions that work on arrays. (In most modern languages arrays are defined by classes or prototypes and have methods built-in. php is not a modern language.) There are functions like array_sort that takes an array and puts the elements of that array in order. That’s fine if you have an array of numbers or strings, but for more complex things, how does the code decide which comes first?

For that use, there is another function, array_usort that takes an array, and you tell it what code to use to compare the two items.

php also has a method called array_search which finds whether an array has a particular item in it. As before this works fine for simple items, but becomes less useful as the items in the array grow in complexity, or you want to find something that you don’t already have a full example of. What if you have a list of books and you want to find the one titled Huckleberry Finn?

It seems logical that there would be a search function where, as for array_usort, you tell the code what defines a “match”, and then off it goes to see what comes up. Logical, but it’s not there (unless it’s tucked away with a terrible name that makes no sense, which is entirely possible in php).

So after about the eleventy-hundredth time writing a little loop to find something in an array I said, “dangit, I’m writing array_usearch.”

function array_usearch(array $array, Closure $test) {
    $found = false;
    $iterator = new ArrayIterator($array);
 
    while ($found === false && $iterator->valid()) {
        if ($test($iterator->current())) {
            $found = $iterator->key();
        }
        $iterator->next();
    }
 
    return $found;
}

All this does is try each element in the array against a function you provide until the function returns true, then it returns the key for that item in the array. If no match is found, it returns false, the same way array_search does. Simple! Using it would look something like this:

// define a type to put into a list
class Thing  {
    public $id;
    public $name;
 
    public function __construct($id, $name, $category) {
        $this->id = $id;
        $this->name = $name;
    }
}
 
// make a list of them, mixed up a bit
$listOfThings = [
    new Thing(1, 'one'),
    new Thing(2, 'two'),
    new Thing(4, 'four'),
    new Thing(3, 'three'),
];
 
// find the index of the item with id = 4
$id4Index = array_usearch($listOfThings, function($thing) {
    return $thing->id === 4;
});
// $id4Index will now be 2

The function will work on all php array types, whether with numeric indices or strings.

php purists might object to using the name array_usearch because all the other array_u* functions take a callable for defining the function, while this version uses a Closure. There are a couple of reasons: 1) Closures didn’t exist in php when the array_u* functions were defined, 2) it’s the 21st century now and other languages use closures in this manner for a reason, and 3) closures allow the function that gets passed to array_usearch to be reused with different values. With a little extra setup we can make searching super-clean:

// function that returns an anonymous function that captures the id to search for
$idClosure = function($id) {
    return function($item) use ($id) {
        return $item->id = $id;
    }
}
 
$id4Index = array_usearch($idClosure(4)); // value will be 2
$id2Index = array_usearch($idClosure(2)); // value will be 1

Now we can write code compactly that can search for matches of arbitrary complexity, and we can create little factories to produce the search functions themselves, so the complexity is tucked away out of sight. This variation takes an array of key/value pairs and searches for items that match all of those values:

function firstIndexMatching(array $array, array $criteria, bool $useStrict = true) {
 
    if (count($criteria) < 1) {
        return false;
    }
 
    // create a closure that has captured the search criteria
    $testWithCriteria = function($criteria, $useStrict) {
 
        return function($item) use ($criteria, $useStrict) {
 
            foreach($criteria as $key => $value) {
                if (!isset($item->$key)) {
                    return false;
                } else if ($useStrict && $item->$key !== $value) {
                    return false;
                } else if (!$useStrict && $item->$key != $value) {
                    return false;
                }
            }
 
            return true;
        };
    };
 
    return array_usearch($array, $testWithCriteria($criteria, $useStrict));
}

Now if you have an array of people, for instance, you can search for the first match with a given name:

$joeCoolIndex = firstIndexMatching($people, [
    'firstName' => 'Joe',
    'lastName' => 'Cool'
]);

The loop and the comparisons are moved out of the way and all the main part of your code need to do is supply the criteria for the search.

Ultimately after a search like this, you will want to have the item, not just its index. That’s easy enough, but don’t forget that if no match is found, array_usearch will return false, which php will often conflate with 0, so extra care has to be taken when using the returned index.

$joeCool = $joeCoolIndex !== false ? $people[$joeCoolIndex] ?? null : null;

Obviously this could be added to the firstIndexMatching function if one is never interested in the index itself.

And there you have it! A simple callback-based search function, ready to keep your main code clean and clear.

Gettin’ the Lingo

The official Sweetie of Muddled Ramblings and Half-Baked Ideas recently acted on an long-term resolution to become better at speaking the language of many of our neighbors. After all, our city of residence is not Saint Joseph.

To pursue this goal, she has subscribed to Duolingo, an online language-learning application. She has been sure to put in a little time on the project every day, often combining it with time on our exercise machine. Buffing up brain and body at the same time!

When she went to the payment section of the portal, she discovered that a family pack didn’t cost that much more than an individual license, and she knew full-well that there were several family members who have been wanting to learn one language or another.

So now I’m signed up, too. I will be learning Spanish too, but first I wanted to get a start on remembering what little Czech I once knew. I have family members who speak Czech, so it makes sense. I figure a month to show progress with the Czech before I add in Spanish sessions as well.

It’s pretty exciting, but when the program tested my current level of Czech proficiency, it politely said, “let’s start at the beginning.” So I’m starting at the beginning, but when they throw a new word at me, there’s a pretty good chance I already know it.

Is Duolingo better than other language-learning software? Honestly I don’t know, and I’m not sure how much that even matters. What matters is devoting a little time each day to add a new phrase or two. Beyond the actual lessons, Duolingo devotes enormous energy to rewarding consistency, and bestowing worthless cartoon trinkets for taking an extra lesson in a session. I got my five-day-straight pat on the back today.

Big June

It’s been June for about two hours now, Pacific Daylight Time. It’s going to be a big month. I have mede some commitments.

I will exercise. I have joined a team health habit challenge with some coworkers and I will not let them down.

I will blog. Every day this month I will post some half-assed shit. Welcome to the first installment of that.

I will write. Every damn day I will add to Munchies. Or subtract from Munchies. Whatever’s right at the time.

Addendum: I will remember to hit “Publish” after I write a blog episode.