As you drive from Española east to Chimayó --
in non-COVID-19 times, you might be heading to Rancho de Chimayó,
the area's best New Mexican restaurant -- many of the street names,
of course, are Spanish.
That's no surprise: this area is one of the oldest white-settled parts
of the United States (of course, the Puebloans had been living in the
area for centuries), starting in 1598 when Don Juan de Oñate
declared it the capital of Santa Fe de Nuevo México, though the
capital moved to La Villa Real de la Santa Fe de San Francisco de Asís
(modern-day Santa Fe) twelve years later. The area remained under
Spanish, and then Mexican, rule until 1848 when it was ceded to the
United States.
So you're driving along, moving from the little village of Santa Cruz
into the equally small Cuartalez,
passing street names like Avenida Fernandez, Calle de la Capilla,
Fresquez Ln, Je Martinez Ln, Calle de Esquibel -- and then right
after Calle de Esquibel, there's another street sign:
Eh Ski Vel Ln.
Read more ...
Tags: humor
[
12:25 Apr 03, 2020
More humor |
permalink to this entry |
]
Every time the media invents a new moon term -- super blood black wolf
moon, or whatever -- I roll my eyes.
First, this ridiculous "supermoon" thing is basically undetectable to
the human eye. Here's an image showing the relative sizes of the absolute
closest and farthest moons. It's easy enough to tell when you see the
biggest and smallest moons side by side, but when it's half a degree
in the sky, there's no way you'd notice that one was bigger or smaller
than average.
Even better, here's a link to an
animation
of how the moon changes size and "librates" -- tilts so that we can
see a little bit over onto the moon's far side -- during the course of
a month.
Anyway, the media seem to lap this stuff up and every month there's a
new stupid moon term. I'm sure nearly every astronomer was relieved
to see the thoroughly sensible Gizmodo article yesterday,
Oh My God Stop It With the Fake Moon Names What the Hell Is a 'Black Moon' That Isn't Anything.
Not that that will stop the insanity.
If You Can't Beat 'Em, Join 'Em
And then, talking about the ridiculous moon name phenom with some
friends, I realized I could play this game too.
So I spent twenty minutes whipping up my own
Silly Moon Name Generator.
It's super simple -- it just uses Linux' built-in dictionary, with no sense
of which words are common, or adjectives or nouns or what.
Of course it would be funnier with a hand-picked set of words,
but there's a limit to how much time I want to waste on this.
You can add a parameter ?nwords=5
(or whatever number)
if you want more or fewer words than four.
How Does It Work?
Random phrase generators like this are a great project for someone
just getting started with Python.
Python is so good at string manipulation that it makes this sort
of thing easy: it only takes half a page of code to do something fun.
So it's a great beginner project that most people would probably find
more rewarding than cranking out Fibonacci numbers (assuming you're not a
Fibonacci
geek like I am).
For more advanced programmers, random phrase generation can still be a
fun and educational project -- skip to the end of this article for ideas.
For the basics, this is all you need: I've added comments explaining
the code.
import random
def hypermoon(filename, nwords=4):
'''Return a silly moon name with nwords words,
each taken from a word list in the given filename.
'''
fp = open(filename)
lines = fp.readlines()
# A list to store the words to describe the moon:
words = []
for i in range(nwords): # This will be run nwords times
# Pick a random number between 0 and the number of lines in the file:
whichline = random.randint(0, len(lines))
# readlines() includes whitespace like newline characters.
# Use whichline to pull one line from the file, and use
# strip() to remove any extra whitespace:
word = lines[whichline].strip()
# Append it to our word list:
words.append(word)
# The last word in the phrase will be "moon", e.g.
# super blood wolf black pancreas moon
words.append("moon")
# ' '.join(list) combines all the words with spaces between them
return ' '.join(words)
# This is called when the program runs:
if __name__ == '__main__':
random.seed()
print(hypermoon('/usr/share/dict/words', 4))
A More Compact Format
In that code example,
I expanded everything to try to make it clear for beginning programmers.
In practice, Python lets you be a lot more terse, so the way
I actually wrote it was more like:
def hypermoon(filename, nwords=4):
with open(filename, encoding='utf-8') as fp:
lines = fp.readlines()
words = [ lines[random.randint(0, len(lines))].strip()
for i in range(nwords) ]
words.append('moon')
return ' '.join(words)
There are three important differences (in bold):
Opening a file using "with" ensures the file will be closed properly
when you're done with it. That's not important in this tiny example, but
it's a good habit to get into.
I specify the 'utf-8' encoding when I open the file because when I
ran it as a web app, it turned out the web server used the ASCII
encoding and I got Python errors because there are accented characters
in the dictionary somewhere. That's one of those Python annoyances
you get used to when going beyond the beginner level.
The way I define words all in one line (well, it's conceptually
one long line, though I split it into two so each line stays under 72
characters) is called a list comprehension. It's a nice compact
alternative to defining an empty list []
and then
calling append()
a bunch of times, like I did in the
first example.
Initially they might seem harder to read, but list comprehensions can
actually make code clearer once you get used to them.
A Python Driven Web Page
Finally, to make it work as a web page, I added the CGI module.
That isn't really a beginner thing so I won't paste it here,
but you can see the CGI version at
hypermoon.py
on GitHub.
I should mention that there's some debate over CGI in Python.
The movers and shakers in the Python community don't approve of CGI,
and there's a plan to remove it from upcoming Python versions.
The alternative is to use technologies like Flask or Django.
while I'm a fan of Flask and have used it for several projects,
it's way overkill for something like this, mostly because of all
the special web server configuration it requires (and Django is
far more heavyweight than Flask). In any case,
be aware that the CGI module may be removed from Python's standard
library in the near future. With any luck, python-cgi will still be
available via pip install
or as Linux distro packages.
More Advanced Programmers: Making it Funnier
I mentioned earlier that I thought the app would be a lot funnier with
a handpicked set of words. I did that long, long ago with my
Star Party
Observing Report Generator (written in Perl; I hadn't yet
started using Python back in 2001). That's easy and fun if you
have the time to spare, or a lot of friends contributing.
You could instead use words taken from a set of input documents.
For instance, only use words that appear in Shakespeare's plays, or
in company mission statements, or in Wikipedia articles about dog breeds
(this involves some web scraping, but Python is good at that too;
I like
BeautifulSoup).
Or you could let users contribute their own ideas for good words to use,
storing the user suggestions in a database.
Another way to make the words seem more appropriate and less random
might be to use one of the many natural language packages for Python,
such as NLTK, the Natural Language Toolkit. That way, you could
control how often you used adjectives vs. nouns, and avoid using verbs
or articles at all.
Random word generators seem like a silly and trivial programming
exercise -- because they are! But they're also a fun starting
point for more advanced explorations with Python.
Tags: humor, astronomy, programming, python
[
14:24 Aug 01, 2019
More humor |
permalink to this entry |
]
Dave was reading New Mexico laws regarding a voter guide issue we're
researching, and he came across this gem in
Section
29-1-14 G of the "Law Enforcement: Peace Officers in General:
Unclaimed Property" laws:
Any alcoholic beverage that has been unclaimed by the true owner, is
no longer necessary for use in obtaining a conviction, is not needed
for any other public purpose and has been in the possession of a
state, county or municipal law enforcement agency for more than ninety
days may be destroyed or may be utilized by the scientific laboratory
division of the department of health for educational or scientific
purposes.
We can't decide which part is more fun: contemplating what the
"other public purposes" might be, or musing on the various
"educational or scientific purposes" one might come up with for
a month-old beverage that's been sitting in the storage locker ...
I'm envisioning a room surrounded by locked chain-link containing
dusty shelves containing rows of half-full martini and highball glasses.
Tags: humor, law
[
11:04 Sep 26, 2016
More humor |
permalink to this entry |
]
On a hike a few weeks ago, we encountered an unusual, and amusing, stile
across the trail.
It isn't uncommon to see stiles along trails. There are lots of
different designs, but their purpose is to allow humans, on foot,
an easy way to cross a fence, while making it difficult for vehicles
and livestock like cattle to pass through.
A common design looks like this, with a break in the fence and "wings"
so that anything small enough to make the sharp turn can pass through.
On a recent hike starting near Buckman, on the Rio Grande,
we passed a few stiles with the "wings" design; but one of the
stiles we came to had a rather less common design:
It was set up so that nothing could pass without climbing over the
fence -- and one of the posts which was supposed to hold fence rails
was just sitting by itself, with nothing attached to it.
I suspect someone gave a diagram to a welder, and the welder, not
being an outdoor person and having no idea of the purpose of a stile,
welded it up without giving it much thought. Not very functional ...
and not very stilish, either!
I'm curious whether the error was in the spec, or in the
welder's interpretation of it. But alas, I suspect I'll never learn
the story behind the stile.
Giggling, we climbed over the fence and proceeded on our hike up to
the very scenic Otowi Peak.
Tags: humor, stile
[
11:38 Apr 30, 2015
More humor |
permalink to this entry |
]
I've always loved small-town newspapers. Now I have one as a local
paper (though more often, I read the online
Los Alamos Daily Post.
The front page of the Los Alamos Monitor yesterday particularly
caught my eye:
I'm not sure how they decide when to include national news along with
the local news; often there are no national stories, but yesterday I
guess this story was important enough to make the cut. And judging by
font sizes, it was considered more important than the high school
debate team's bake sale, but of the same importance as the Youth
Leadership group's day for kids to meet fire and police reps and do
arts and crafts. (Why this is called "Wild Day" is not explained in
the article.)
Meanwhile, here are a few images from a hike at Bandelier National Monument:
first, a view of the Tyuonyi Pueblo ruins from above (click for a larger
version):
Some petroglyphs on the wall of Alamo Canyon.
We initially called them spirals but they're actually all concentric
circles, plus one handprint.
And finally, a cairn guarding the bottom of Lummis Canyon.
All the cairns along this trail were fairly elaborate and artistic,
but this one was definitely the winner.
Tags: humor, los alamos, bandelier, ruins, cairn, art
[
14:01 Apr 16, 2015
More humor |
permalink to this entry |
]