Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

Printing columns of information from Unix text files is easy, especially using commands like awk, perl, and more recently, ruby. This short tutorial shows my old-school awk way of doing this.

awk column printing examples

Suppose you have a file named foo with contents like this:

1 2 3
a b c

You can easily use awk to print columns of information from this file. Here are a few examples that show how to print the data columns from the file:

I started an “autoimmune” diet a few weeks ago, and one thing it has done is to make my problems more consistent. This is one of my current problems: at rest my blood pressure is usually low and my heart rate is often in the 95-110 beats per minute range.

Here’s a link to five more chapters from my book, Functional Programming, Simplified.

Today’s work: Review at least four more lessons of my new book, Functional Programming, Simplified.

When I was younger I didn’t really like The Beatles, though I did like individual songs by John Lennon and Paul McCartney. Lately I’ve been listening to a lot of McCartney and The Beatles, and this quote from the Wikipedia’s A Day in the Life discussion is good:

“Paul and I were definitely working together, especially on ‘A Day in the Life’ that was a real ... The way we wrote a lot of the time: you’d write the good bit, the part that was easy, ‘I read the news today’ or whatever it was, then when you got stuck or whenever it got hard, instead of carrying on, you just drop it; then we would meet each other, and I would sing half, and he would be inspired to write the next bit and vice versa. He was a bit shy about it because I think he thought it’s already a good song. Sometimes we wouldn’t let each other interfere with a song either, because you tend to be a bit lax with someone else’s stuff, you experiment a bit. So we were doing it in his room with the piano. He said ‘Should we do this?’; ‘Yeah, let’s do that.’”

(Here’s a link to A Day in the Life on YouTube.)

There was a time when I had the misconception that yoga is about exercising the body.

Then one day my wise teacher (who studied directly under Iyengar) told me, “If you aren’t paying attention to your actions, all you’re doing is stretching.”

Android 7 comes with a cool new “split screen” feature where you can look at two apps running at the same time. This little pictorial/tutorial shows how to use this split-screen feature.

Back to top

How to use Android’s split-screen feature

Step 1: Open two or more apps

The easiest way to get started with this feature is to have two or more Android apps open. You may want to open more than two apps, because some apps won’t support the split-screen feature. For instance, at the time of this writing, Kindle and Netflix don’t support it. I recommend starting a browser like Chrome, and another app like Twitter or an email app.

Tip: When you’re first getting started, open a few Google apps. They are more likely to work in split-screen mode than other apps.

Step 2: Tap the Android “recent apps” icon

What started off as an accidental finding resulted in me performing a test on myself the last few weeks. The results are in, and I think they’re pretty conclusive: right before going to bed, if I turn off the tv (or put down the book I’m reading) and meditate for a little while, I remember my dreams more, sleep less, and wake up more refreshed.

“A state of being is an experience. A description of a state of being is a symbol. Symbols and experience do not follow the same rules.”

~ The Dancing Wu Li Masters: An Overview of the New Physics

This is a little RxScala example from the RxScala/RxJava Github docs:

object Transforming extends App
{
    /**
     * Asynchronously calls 'customObservableNonBlocking'
     * and defines a chain of operators to apply to the 
     * callback sequence.
     */
    def simpleComposition()
    {
        AsyncObservable.customObservableNonBlocking()
            .drop(10)
            .take(5)
            .map(stringValue => stringValue + "_xform")
            .subscribe(s => println("onNext => " + s))
    }

    simpleComposition()
}

If you like visual diagrams, this source code goes along with this marble diagram.

I’ll be including examples like this in my book, Functional Programming, Simplified.

This is a nice example of a marble diagram. I found it on this RxJava documentation page. In a related note, RxMarbles.com is a fun website. If it’s not obvious how they work, this rxwiki.wikidot.com page provides a formal description of how marble diagrams are drawn.

Example marble diagram

A friend was in Talkeetna recently, and sent me a picture of what this cabin looks like these days. Skipping over that, this is what it looked like in mid-September when I lived there.

The old cabin in Talkeetna

A long time ago I wrote about how to improve your iTunes song quality, but that article was about how to make the songs you already have in iTunes sound their best through a couple of tweaks.

This morning I was again listening to a song on YouTube, and then I checked it against the same song I have in iTunes, and the YouTube song quality sounded better than my song, which I purchased through Amazon.com. In short, that led me to find this amazon page where they discuss the (poor) quality of their MP3s, part of which is shown in this image. IMHO, I don’t think people are that concerned about 5 MB file sizes and 56k dialup connections in most places. (They could make this an option.)

Poor Amazon MP3 quality

This image of “lessons learned” comes from an article titled, “Learning FP the hard way: Experiences on the Elm language.” (Elm is incredibly similar to Haskell.)

FP the hard way

“That’s someone’s opinion,” he said. “There are certain things in this world you can’t control. You’ve got to keep living without them.”

~ Jimmy Garoppolo, in this article

The song of the day is a fun little song called Goodnight Tonight, by Wings (Paul McCartney):

The next chapter of my new book, “Functional Programming, Simplied” is now online. It’s titled, “Benefits of Functional Programming.”

“On Venus it snows metal.” This image comes from the Google search results, with the story contents coming from smithsonianmag.com.

On Venus it snows metal

“I’m such a liar.”

Here’s a photo of the building I grew up in, in Chicago, Illinois. (Thanks, Google Maps.)

My old Chicago home