parent

Sometimes dreams teach us things alvin February 12, 2020 - 11:21am

It seems like sometimes dreams exist to teach us things. Last night there was a very long dream sequence in which a deceased relative was a raging alcoholic. At one point I had to help him off the floor, and when I touched him I instantly saw what he had seen, and felt what he was feeling. It was like 100% empathy for that person. I immediately felt, “Wow, if I had been through these things I might be in the same shape myself,” so rather than feeling pity for him I felt empathy. I got him up into a chair and said, “Talk to me.” He tried to brush me off, but when I told him what I had seen and felt he began weeping and I hugged him for a while.

Ram Dass on being a parent, and a soul alvin May 16, 2018 - 8:47am

Ram Dass on being a parent, and a soul (and attachment).

Children Learn What They Live (poem)

If a child lives with criticism,
he learns to condemn.

If a child lives with fear,
he learns to be apprehensive.

If a child lives with ridicule,
he learns to be shy.

If a child lives with shame,
he learns to feel guilty.

If a child lives with encouragement,
he learns to be confident.

If a child lives with praise,
he learns to be appreciative.

If a child lives with acceptance,
he learns to love.

If a child lives with approval,
he learns to like himself.

If a child lives with honesty and fairness,
he learns what truth and justice are.

If a child lives with friendliness,
he learns that the world is a nice place in which to live.

With what is your child living?

~part of a "Children Learn What They Live" poem by Dorothy Law Nolte

How to define a collection whose element are all of some base type (inheritance)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 19.6, “How to define a collection whose element are all of some base type.”

Back to top

Problem

You want to specify that a class or method takes a type parameter, and that parameter is limited so it can only be a base type, or a subtype of that base type.

Back to top

Solution

Define the class or method by specifying the type parameter with an upper bound. To demonstrate this, create a simple type hierarchy:

Table of Contents

  1. Problem
  2. Solution
Back to top

Akka/Scala: How to monitor the death of an Actor with “watch”

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 13.8, “Monitoring the death of an Akka Actor with ‘watch’”.

Back to top

Problem

You want an actor to be notified when another actor dies.

Back to top

Solution

Use the watch method of an actor’s context object to declare that the actor should be notified when an actor it’s monitoring is stopped.

Table of Contents

  1. Problem
  2. Solution
Back to top

How to call a Scala superclass constructor

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 4.11, “How to call a Scala superclass constructor.”

Problem

You want to control a Scala superclass constructor that’s called when you create constructors in a subclass.

Java ‘instanceof’ inheritance examples alvin September 3, 2009 - 6:42pm

In other tutorials I've written about the Java "instanceof null" behavior, and the Java "instanceof interface" behavior, and it occurred to me that I've never written anything about how the instanceof operator works with Java class inheritance.