Squirrel at the window

I’m sitting here working this morning when I start to hear that familiar scratching, crawling sound outside. In a few moments, the squirrel’s head appears from the right side of the window. He’s hanging sideways, three stories off the ground, and looking in, about twelve inches from my face. It’s cold outside so I had the window closed, but I slide it open.

“Dude, Cheerios,” he says.

“Oh shoot, I forgot,” I say.

By the time I walk to the kitchen, get the box of Cheerios, and open the door to the deck, he’s already there, waiting.

How to show an Android Snackbar message

To show an Android Snackbar message from an Activity or Fragment, use Java code like this:

Snackbar.make(view, "going to: " + url, Snackbar.LENGTH_LONG).show();

One key is to remember to call the show() method after make(). I have a tendency to forget to call show() and then wonder why my Snackbar message isn’t showing up. So maybe a better way to show that code is like this:

A terrific Model View Controller (MVC) diagram

Every once in a while when something hits you, you really remember it; it stands out in your mind as an “Aha” moment. One of those moments for me was when I saw a particular “Model/View/Controller” (MVC) diagram, and the light bulb went on. This diagram made the MVC pattern very simple, and I’ve never forgotten it.

Drupal 8: How to put a View or Block between the Content and Comments

I’m not going to discuss this code much, but in short, the source code below is for a Drupal 8 preprocess_node function that I use to set variables for (a) a custom view and (b) a custom block. I set the variables in this function, and then display them in my node.html.twig file like this:

{{ similar_by_terms }}

and this:

How to create a lazy view on a Scala collection

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.24, “How to Create a Lazy View on a Scala Collection”


You’re working with a large collection and want to create a “lazy” version of it so it will only compute and return results as they are actually needed.

An Android onTouchEvent method example (View class)

If you need to write an Android onTouchEvent method inside a View class, here’s some example source code (boilerplate/skeleton code) that shows how to implement this method, including how to use the MotionEvent in the method, and how to get the x and y location of the touch event: