In an effort to start tracking my daily word count, I wrote this script. It checks in a folder for changes to the word count of text files since it was last updated. I have the script update the word count nightly, using a cron job.
As my first experiment with the Python programming language, I made a script that helps me look at things in my todo.txt file.
Even if you don’t know Python, this should be pretty easy to follow. I’ll step through it with you!
#!/usr/bin/env python
#Filename: todo.py
# A script to do things with todo.txt
These lines are just housekeeping. We’re saying where Python is on the system and what we’re here to do.
import os
import sys
import re
Bringing in a few things to help us do things. os helps us get the location of the todo.txt file, sys allows us to read command line arguments, and re lets us do regular expressions.
One of these days I’ll make a write-up about my own personal backup solution, but today I came across an interesting command in the OS X terminal that should be of benefit to a lot of tech-savvy Mac users.
For my personal backups, I have a shell script I run daily to take care of everything. The script outputs text as it does its backup, so that once it’s done, I can see if it had any problems. This works great, until you start to use cron jobs.
Cron jobs are a powerful part of a UNIX system, similar to Tasks in Windows. The idea is that you can set a certain terminal command to run at a specific time, at certain intervals, in numeric ranges, and all sorts. To me, this seems like a great way to automate my backup system.
The problem is, cron jobs are part of the system’s background processing. You don’t see it. So, if I set up my backup script to run, say, at three in the morning, I have no clue if it ran or not without checking my log files. Ideally what I would want is to open up the Terminal.app, and have that run the script, rather than cron.
So how do you do this? With the open command.
open is useful for lots of jobs in the terminal. All it does is it opens the specified file in the default application, as chosen by Mac OS X. For example, a command like this:
> open ~/todo.txt
would open my todo.txt file in the default text editor, such as TextEdit or TextMate.
But here’s the ninja move: you can use the -a flag to specify the application. So, if I want to open up my backup script in the terminal, I tell cron to run this command:
> open -a /Applications/Utilities/Terminal.app ~/backup.sh
So now, rather than running silently in the background, an instance of Terminal.app pops open, and starts running backup.sh. Just what I wanted. Thanks OS X!
As part of my work photographing school concerts, I usually hang around the rehearsals taking “preliminary” photos. It’s the photographer’s equivalent of taking notes: seeing how the bands will be set up, where you can stand to get certain band members framed well, etc.
But during my visit to the 2009 Spring concert rehearsals, I ended up shooting not so many photos – but plenty of videos. Mostly influenced by the recent NIN video shot on a Canon 5D MkII, I tried the walkaround-video technique myself. It takes practice (and works better when you, say, have a NIN concert handy), but the results I got were pretty interesting. An exercise in manual focus if anything. Video is at the top of the article if you didn’t notice already!