The Native American woman I met last week had an aneurysm and brain surgery last year. (She showed me the scar, and she’s fine now.) Before the aneurysm was discovered, she went to a shaman who’s well-known among Natives here. He lit something, made some smoke, did whatever else he does, then looked at her, put his finger on her forehead and said, “You are blocked here.”
Unfortunately she assumed he was referring to a mental blockage, and thought, “No, I’m an open person, he’s wrong.” Shortly after this, doctors discovered the aneurysm right where he pointed.
That moment where you’ve been working on something really hard at your desk, you solve it, then lean back, swivel your chair to the side, put your feet up on the desk in celebration, and then realize there’s a burning candle behind your head.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.17, “How to use filter to Filter a Scala Collection”
You want to filter the items in a collection to create a new collection that contains only the elements that match your filtering criteria.
I just saw this drawing on the Learn You a Haskell website, and I wish I had done something visual like it for the Scala Cookbook. It does a nice job of showing the
last functions (methods).
I’ve been working a lot on the next generation web server for the alvinalexander.com website lately, and as I’m looking at different HTTP accelerators, I keep wanting/needing to look at the headers returned by my web pages. A simple way to look at the HTTP headers from the command line is with the
curl command, like this:
curl -I http://example.com/
Running this command against the main Google website, I see output like this:
Linux head/tail FAQ: Can you share some examples of the Linux head and tail commands?
Sure. The Linux head and tail commands are very similar, so I've included them here together. The head command command prints lines from the beginning of a file (the head), and the tail command prints lines from the end of files. There's one very cool extra thing you can do with the tail command, and I'll show that in the tail example commands below.
A Perl program to extract lines from the middle of a file
I've always been a big fan of the Unix head and tail commands, but several times I have wanted to print a range of lines from the middle of a text file -- not just the beginning or end of a file. Not liking the available solutions, I wrote my own.
Here is the source code for a program named "
extract.pl", which prints lines from a text file beginning at the start line you specify and ending at the stop line.