fogbound.net




Mon, 6 Aug 2012

Sneaky, sneaky SELinux

— SjG @ 4:38 pm

I was getting a web site up and running on Centos 6.3, and PHP was refusing to talk to the SMTP server on the same box. This, in and of itself, is not unusual. There’s a checklist:

  • Verify SMTP’s running
  • Check that the SMTP server is configured to accept connections from localhost
  • Check the firewall rules
  • Really check the firewall rules by generating an email using telnet localhost 25 or nc localhost 25 from the command line
  • Check that PHP is trying to talk to the SMTP server you think it is
  • Look in the system log for SELinux being a bully and preventing communication

In this case, all of the above checked out cleanly. I was perplexed. But it turns out that, in what is as shocking and surprising as my cat wanting to be fed,
SELinux was indeed the culprit. It just wasn’t logging the problem anywhere.

A quick
setsebool -P httpd_can_network_connect=1

as root solved the problem.

Moral(s) of the Story: The cat is always hungry. SELinux is always fuckin’ shit up.


Tue, 17 Jan 2012

Sign of the Times

— SjG @ 2:58 pm

I think it’s a sad, sad sign of the times that most Linux distros not only omit figlet from their standard installations, but often don’t even offer it in their package managers.

       _           _                   _                      _ 
  __ _| | __ _ ___| |   __ _ _ __   __| | __      _____   ___| |
 / _` | |/ _` / __| |  / _` | '_ \ / _` | \ \ /\ / / _ \ / _ \ |
| (_| | | (_| \__ \_| | (_| | | | | (_| |  \ V  V / (_) |  __/_|
 \__,_|_|\__,_|___(_)  \__,_|_| |_|\__,_|   \_/\_/ \___/ \___(_)

Fri, 11 Nov 2011

Imaginary Tech Conversation

— SjG @ 3:14 pm

Coder #1: Man, revision control sucks.
Coder #2: What? Are you insane?
Coder #1: Insane? I don’t think so.
Coder #2: How can you say revision control sucks, then?
Coder #1: Well, I’m stuck using SVN.
Coder #2: Subversion isn’t so bad. Especially with the new merge tracking stuff from version 1.5. It’s pretty easy to use.
Coder #1: Yeah, well, I stand by my assertion. It sucks.
Coder #2: Can you be more specific?
Coder #1: Have you tried using SVN in a mixed environment? Say Windows, Linux, and Mac OS?
Coder #2: It’s not going to be line-ending issues. Oh, I see. You’re talking about case-sensitive versus case-insensitive filesystems.
Coder #1: I wish it was that easy. That’s crappy, but you can work around it.
Coder #2: Then?
Coder #1: A riddle for you. When is UTF-8 not UTF-8?
Coder #2: Huh?
Coder #1: When it’s in a filename.
Coder #2: [clicks, reads]
Coder #1: But I guess if you don’t have any Macs or ZFS around, you’re fine.
Coder #2: Holy Linus on a unicycle! Well, I guess it’s back to dated tar files…
Coder #3: Use GIT, you IDIOT!


Sat, 24 Sep 2011

Ffun ffmpeg ffunctionality

— SjG @ 2:59 pm

I’ve been processing a collection of product videos which came to me in a huge variety of sizes, aspect ratios, and qualities. I need to re-encode them to work in HTML 5, but, more importantly, I need to make them fit into a common player space on the web page.

It turns out that newer versions of ffmpeg support not only cropping, but also padding, and you can even do both operations at once!

For example, I had a source video that was originally 16:9, but had been letterboxed to 4:3, and then had two different sets of labels added. I needed to crop out the letterboxed portion and the top set of labels, and make the result fit nicely into 16:9. So I used VLC, a screen capture utility, and Photoshop to get the measurements. Then I used ffmpeg to crop the relevant section and pad it out to fit into my space (in this case, I’m left aligning the video in the padded output):


ffmpeg -i original/converted.wmv -vf crop=394:295:6:0,pad=524:295:0:0:0xFFFF00 -sameq converted.mov

That’s cropping a 394 x 295 piece out of the original video (with the origin at 6 pixels from the left, and 0 pixels from the top), and then padding it out to 524 x 295 filling the padded area with bright yellow. The 524 x 295 is really close to 16:9 — and in a later process, it gets resized to the more standard 480 x 2721.

You can string together the padding and cropping in either order, depending on the effect you’re trying to achieve.

1I’m sure some educated person out there could tell me why video standards are so confused/confusing, down to the non-square pixels. While a true 16:9 would dictate 480 x 270 pixels, everybody seems to use 480 x 272. Why? The only thing I can figure out is that 272 is evenly divisible by a power of 2, which probably made display hardware cheaper to manufacture. As you can see, my resizing adds a bit of distortion, but at these resolutions, it doesn’t really matter.


Fri, 19 Aug 2011

Timelapse Photography and the Evolution of Hardware

— SjG @ 10:29 pm

We’ve had some new hatches in the Butterfly Fort, and there are at least six chrysalids which will be eclosing in the next couple of days1. This reawakens my interest in time-lapse photography.

I used to have a setup with a Harbortronics D2000 which I hooked up to my Nikon Coolpix 950 (and, later, Coolpix 995). It was good for a lot of things, but I succeeded in burning a nice streak across the sensor of the camera when the sun passed directly through the scene — the Coolpix line didn’t have a physical shutter, so the lens focused the sun onto the delicate sensor for the full time it was in view.

I’ve been using the Brinno Gardenwatch Cam that I received as a gift
a few years ago. It’s a dedicated, all-in-one time-lapse device. Once I learned a few things, I was able to use it successfully. First off, it really needs to be run on Nickel-metal hydride batteries. Next, you have to listen carefully when turning it on, because it’s not always obvious when you’ve powered it on and then off again by holding down the button a bit too long.

The Gardenwatch Cam does a decent job. It creates AVI format movies. It has 7 interval settings ranging from 1 minute to 24 hours. It has two focus settings, one for close up, and one for landscape.

With the monarchs, though, I want to be able to get in closer, and have sharper images than the Gardenwatch cam will give me. I still have a Nikon D70 which served me well for many years, but has been supplanted by the D90 in recent years. I also have a small assortment of lenses that I’ve accumulated over the past fifteen years. I’m thinking that the six megapixels of the D70 should be far more than adequate for doing some nice macro time-lapse work.

So the only problem is intervalometry — how do I trigger the camera to take pictures? Nikon sells intervalometers for most cameras, but the D70 is notably excluded from that list. There are a number of people making kits (or generously giving away their designs). I thought I might be able to rig something together.

I was successful. Taking an ancient Gateway Solo 9300 notebook that I’d bought for a king’s ransom back in 1998 or 1999, I installed Ubuntu 11.4 desktop on it. This was a mistake. The machine has a 366MHz Pentium II processor, and 128 MB of memory — lesser specs than your iPhone2. It got part way through the boot sequence, and locked up (terminal swapping? driver issues? I don’t know). I then installed a version of Ubuntu 8 Server for which I happened to have a CD. After installation, I booted into Matrix-esque screen garbage, but after some fighting with boot parameters was able to get running cleanly. Next, I installed gPhoto2. Putting the D70 into PPT mode, I hooked it up to the notebook with a USB cable.

Voilà! Now, all it took was a few commands:

Find the camera:

gphoto2 --auto-detect

Store pictures on the camera’s compact flash card:

gphoto2 --set-config capturetarget=1

And take pictures at a 30-second interval:

gphoto2 --capture-image --interval 30

If I get any worthy results, I’ll post ’em on Archie’s Garden.

1 There sure are a lot of great insect words. “Eclose” and “chrysalid” are just two among many.
2 The two generations of iPhone had 128 MB of memory, and a 412 MHz ARM processor.