Apr 302013

I’ve mentioned to a few people in passing (and some can tell just by looking): this site switched from Drupal version 6 to WordPress version 3 in December 2012. I’d been on Drupal since November 2010; on ANHosting since December 2010. I didn’t rush to a decision. There had been months of consideration and several factors which led to the switch.

Continue reading »

Mar 212013

find is a very useful utility, but has so many capabilities that you end up hitting the man page every time you come back to it.

I occasionally need to remove old/cached files based on age, which is perfect for find. It’s able to search based on file access times, file status change times and file modification times. Not all systems even track access times (look at your mount options and/or /etc/fstab) so I try to search by modification time when possible. The *time options specify days (24 hours). The *min options specify minutes.

For example, I don’t usually need a copy of any temp files from more than a week ago:
find /tmp -mtime +7 -exec rm -f {} \;

In some cases, you’ll want to search for recent files rather than older files. In this case, you simply switch the sign in front of the number of days. To see a list of this last week’s temp files:
find /tmp -mtime -7

In one case, I needed to restrict to the last day’s FTP uploads, excluding any files that were currently being written (to inspect and remove unauthorized uploads). Here, I assumed that anything which hadn’t been touched for 30 minutes was no longer being uploaded:
find /var/ftp/pub -mmin +30 -mtime -1 -exec parse_script.sh {} \;

Feb 242013

Writing shell scripts is easy, but they’re often ugly. Writing Python is clean, but getting it to accomplish the same tasks isn’t always as easy.

I’ve been kicking around the pros and cons for a while. Many people choose simply based on what they already know, which only gives them that one option.

After reading A Clean Python Shell Script the conclusion started to form in my head:

  • If there aren’t any arguments to pass in, it’s probably a shell script.
  • If there isn’t much for control logic (besides a single loop or if/else) it’s probably a shell script.
  • If the task is automation of command-line instructions it’s almost definitely a shell script.

Python is great for projects with complicated logic or utilities that take many different arguments. Similarly the logging capabilities are excellent if the project could fail in many different ways.

I suspect that if I have a project mixing this set of requirements, I might try calling the shell from Python rather than trying to shoehorn pipes and I/O redirection into Python.

Jan 302013

I’ve used the /proc and /sys filesystems for a variety of tasks, but it’s always interesting to discover a new use. For example, if you want to completely remove an ethernet device from the system (not just disable the ethernet link) it can be done from /sys. In almost all cases, you simply want to use ifconfig down or ifdown to de-activate the port (allowing you to reactivate later). But there are instances where you want to remove the eth device. In this case, you can use /sys to remove a single device.

In my case, it worked even though there are two ethernet devices on the same Intel gigabit ethernet chip and are both served by the same Linux kernel module.
Continue reading »

Jan 022013

Health researchers have long been studying the effects of sitting at work. The reports I’ve seen are negative: sitting all day at work is detrimental to your health. Circulation is cut off to portions of your body, your organs are squeezed and your joints/muscles are forced to remain in static positions all day. Even more disturbing is the finding that exercise cannot offset the negative effects of sitting. If you’re sitting all day, you are harming your health.

Standing desks are nothing new, so I’ve been thinking about it for a number of years. After seeing a post describing very cost-effective standing desks, I decided it was time to try. It depends upon your height, but most people need nothing more than a coffee table and a shelf from Ikea (about $20 total). In my case, I’m tall enough that I don’t even need the shelf. The only item I purchased was a 35″ x 21″ LACK coffee table (p/n 101.042.95). You will probably also want an anti-fatigue floor mat to protect your feet, knees and back.

Continue reading »

Dec 272012

I’ve been using Pulseaudio to easily switch audio output between my digital amplifier and analog headphones (this prevents my headphones from blaring when I’m not actually wearing them). Recent updates to Pulseaudio required a number of changes in my configuration. At this point, I’m not even sure I could use the digital and analog outputs without going through this process. The process is not incredibly complex, but requires the use of new utilities and a bit of experimentation.

Continue reading »

Dec 232012

I don’t always listen to music with lyrics, but when I do, I listen to Flux Pavilion.

Screenshot of my Pandora music feed with Flux Pavilion lyrics

As I’ve said before, I really enjoy listening to Pandora. I frequently discover new artists. I also run across little amusements such as this!

Dec 142012

Earth is just too small and fragile a basket for mankind to keep all its eggs in.
–Robert A. Heinlein

This brief century of ours is arguably the most significant one in the history of our universe. We’ll have the technology either to self-destruct, or [to] seed our cosmos with life. The situation is so unstable that I doubt we can dwell at this fork in the road for more than another hundred years. But if we end up going the life route instead of the death route, then in a distant future our cosmos will be teaming with life, all of which can be traced back to what we do—here and now. I don’t know how we’ll be thought of, but I’m sure that we won’t be remembered as insignificant.
— Max Tegmark, MIT professor

The dinosaurs became extinct because they didn’t have a space program. And if we become extinct because we don’t have a space program, it’ll serve us right!
— Larry Niven

Continue reading »

Nov 242012

I’ve been with T-Mobile since the release of the original G1 android phone. Overall, I am a happy customer, but the quantity of bloatware on their phones does seem to be increasing. The G2 shipped with a few odds and ends you couldn’t install, such as Twitter and Facebook. This wasn’t extremely annoying, as they were popular 3rd party apps. I’ve now upgraded to a “flagship” Samsung device that arrived with a fairly large quantity of lousy Samsung and T-Mobile apps. I’m stripping out much of this, but rooting the device and returning to stock Android is not attractive, because this device has specialized apps for a stylus (Samsung Galaxy Note II).

Continue reading »

Aug 082012

I’ve been dabbling in game development for at least 7 years. A lot of knowledge and experience have been absorbed, but there’s not a lot to show for it. My primary project was originally a barely-playable prototype, but has been a technology demo ever since.

A year and a half ago, I wrote that you have to complete simple game projects before building larger games successfully. I’m sure it’s not a universal rule, but I have no doubt a more experienced developer designs better games. I failed to follow my own advice and continued dabbling with my existing project. There’s not a lot of free time in my schedule, but I’m now certain I have enough to get things done.

Screenshot of N-Snakes game

At the end of July I attended a Boston Python Meetup focusing on simple projects. Based on a Pygame template they built, I was able to quickly build a playable game. I’m not about to win any speed-coding competitions, but I have an interesting game after one month of dabbling.

Continue reading »