I ran a script this afternoon that died mysteriously without any output.
It was using SQLAlchemy to query all the rows from a large table
so that they could be transformed into JSON Lines to be loaded into Elasticsearch.
When I reran my script,
I noticed this time that something had printed Killed at the very end.
A little research convinced me that the OOM Killer was the likely assassin.
I looked in /var/log/kern.log
and I found that my process had used up almost all of the 8GB on this system
before being killed.
The query had to be the problem.
A little more research led me to augment my query with …continue.
I’ve had to figure this out twice in recent months,
and it was no easier the second time than the first.
If you reinstall the Facebook app on Android,
you will be plagued by the phone buzzing every few minutes
to notify you that someone posted something.
The relevant setting is buried deeply.
- Open the Facebook app
- Click the gray-on-white hamburger icon. Top right, second row.
- Scroll all the way down to App Settings. Click.
- Click Notifications. It’s not obvious that it’s clickable.
- Change the Vibrate setting to OFF
- Curse Facebook.
On Mac/Linux, os.path.join is an alias for posixpath.join,
which always joins path segments with /.
On Windows, os.path.join is an alias for ntpath.join,
which always uses \.
When dealing with URLs, we always want forward slashes,
regardless of platform, so posixpath.join should be used to build URL paths.
Running:
from __future__ import print_function
from six.moves.urllib_parse import urljoin as abs_urljoin
from posixpath import join as path_urljoin
def urljoin(site, path):
return abs_urljoin(site, path)
def test_join(site, path):
result = urljoin(site, path)
print("'{0}' + '{1}'\n\t-> '{2}'".format(site, path, result))
return result
local_path = path_urljoin('2016', '07', '12', 'release', 'index.html')
test_join('https://www.example.com', 'foo/bar/quux.js')
test_join('https://www.example.com', local_path)
test_join('https://www.example.com/', local_path)
test_join('https://www.example.com/prefix', local_path)
Yields:
'https://www.example.com' + 'foo/bar/quux.js'
…continue.
Python 2.6 introduced the format method to strings.
In general, format is now the preferred way to build strings
instead of the old % formatting operator.
One exception is with the logging module,
where the best practice is to use %s and %d.
Why?
First, %s is the idiomatic way to use logging,
which was built years before format was introduced.
Second, if there’s a literal % in the interpolated values,
logging will be unhappy,
since there won’t be corresponding arguments in the call.
It won’t fall over, since
“The logging package is designed to swallow exceptions which occur while logging in production.
This is so that errors which occur while handling logging events
- …continue.
Title: Flashman and the Mountain of Light
Author: George MacDonald Fraser
Rating: ★ ★ ★ ★
Publisher: Plume
Copyright: 1990
Pages: 368
Keywords: historical fiction, humor
Reading period: 29 June–10 July, 2016
Flashman and the Mountain of Light takes place just after Flashman’s Lady,
and it also falls between the two parts of Royal Flash,
making it the fourth book chronologically of the Flashman Papers
and the ninth book published.
In the prologue,
our hero finds himself telling Queen Victoria
a much-edited version of how he came to acquire the Koh-i-Noor diamond
on the crown’s behalf forty years earlier during the
First Anglo-Sikh War.
The actual story—at least according to Flashman and Fraser—is that …continue.
What an awful week for race relations in the United States of America.
On Monday night, Alton Sterling was shot and killed by Baton Rouge police.
One night later, Philando Castile was shot and killed by police in Minnesota.
Both men were black and neither was resisting arrest.
Both shootings were caught on video, which inflamed passions.
On Thursday night at a peaceful rally in Dallas protesting police violence,
two snipers killed five police officers and wounded seven others.
Micah Johnson was later killed by police in a standoff;
three others were arrested.
The police should not have killed Alton Sterling or Philando Castile—or Tamir Rice or Freddie Gray or …continue.
Teatro Zinzanni is a long-running circus dinner theater in Seattle.
Six of us went tonight and enjoyed
a blend of cabaret, circus arts, fine dining, and vaudeville.
The current show, Hotel L’Amour, is ostensibly set in a fine hotel,
where the octogenarian Madame reminisces about her career,
while Caesar the lounge lizard hams it up,
Maestro Voronin brings a puppet girl to life,
one aerialist cavorts around an enormous martini glass,
a juggler dazzles with his versatility,
another aerialist works the straps,
and the soprano trills.
All this while the audience eats a fairly decent meal spread out over three hours.
‘Twas enjoyable to be sure and the acts were good
but it was hard …continue.
Title: The Tailor of Panama
Director: John Boorman
Rating: ★ ★ ★ ★
Released: 2001
Keywords: spy thriller, satire
Watched: 7 July, 2016
Andy Osnard (Pierce Brosnan) is a disgraced MI6 officer, packed off to Panama,
where he recruits Harry Pendel (Geoffrey Rush), the eponymous tailor.
Osnard is an unscrupulous dirtbag;
Pendel is a fabulist in need of money;
they’re made for each other.
Panama is “Casablanca without the heroes”
and Pendel spins tall tales that make their way back to London.
Eventually, he outdoes himself, claiming that the Canal is to be sold to the Chinese.
Osnard manages to procure $15 million to fund a revolution,
which he plans to abscond with.
Brosnan plays against type …continue.
I had to rename several hundred thousand files today.
Thanks to a botched invocation of ImageMagick,
they all looked like unique_prefix.png.jpg,
whereas we simply wanted unique_prefix.jpg.
I found a suitable answer at the Unix StackExchange.
As one of the many variants of parameter substitution,
Bash supports ${var/Pattern/Replacement}:
“first match of Pattern within var replaced with Replacement.”
for f in *.png.jpg;
do
mv $f "${f/.png}"
done
The target expression could also have been written as "${f/.png.jpg/.jpg}"
Title: Flashman’s Lady
Author: George MacDonald Fraser
Rating: ★ ★ ★ ★
Publisher: Plume
Copyright: 1977
Pages: 330
Keywords: historical fiction, humor
Reading period: 24–29 June, 2016
Flashman’s Lady takes place between the two parts of Royal Flash,
making it the third book chronologically of the Flashman Papers
and the sixth book published.
Flashman and his wife, Elspeth, become friendly with Don Solomon Haslam,
a rich merchant from the East Indies.
Losing a wager to Haslam, who is smitten with Elspeth,
Flashy has to let Haslam take Elspeth and her father on a trip to Singapore.
As things have become hot for him in England, he sails east with them.
Haslam’s feelings for …continue.
Previous »
« Next