Recently I had to convert about 250 RAW image files to PNGs. For neatness, I wanted to convert the upper-case filenames the camera assigned with a lower-case name.
A little bash script-fu is all it took:
clean_pics.sh
#!/bin/bash
# Extract from SD Card
for i in /Volumes/SDCARD/DCIM/100ND40X/DSC_0*; do
filename=$(basename "$i")
lower_file="$(echo $filename | tr '[A-Z]' '[a-z]')"
# verify it doesn't already exist
newfile="${lower_file%.*}.png"
echo -e "Processingnt$i tont$newfile"
if [[ -e $newfile ]]; then
echo "****SKIPPING"
else
convert "$i" "$newfile"
fi
done
echo -e "Detoxing..."
find . -iname "*.png" -exec detox "{}" ;
echo "Procedure complete."
(“SDCARD”, etc is the path to the source files)
Once the script was up and running, it took about 1/2 hour to process all the files. Meanwhile, I was off doing something else!
Note: the post “I don’t hire unlucky people” was written by Raganwald on posterous.com, which unfortunately went belly-up April 2013. It is too important a lesson to let disappear, so I’m posting it here. For all you fellow unlucky people, I hope you get hired soon. 🙂
Bertram Wooster and Ernestine Anderson were staffing up their teams. Bertram was hiring trainees to work in the company’s retail stores, Ernestine was hiring software developers to build a new supply chain system for the company’s operations. “Bert,” Ernestine asked, “I have hundreds of resumés, how do I whittle them down to a handful of calls and a few interviews?”
Bertram smiled. He grabbed a pile of resumés from his desk, then started dealing the resumés out, first one back onto his desk, second into the recycle bin, third onto his desk, fourth into the recycle bin. When he was finished, he had thrown half of the resumés away. “It’s simple.” Bertram told Ernestine. “Just don’t hire anybody who’s unlucky.”
Ernestine tried that for a few weeks, throwing half the resumes out and the combing through the remainder looking for qualified applicants. She got nowhere, even if the people looked good on paper, when she talked to them on the phone it was quickly apparent that they weren’t capable of writing FizzBuzz. Meanwhile, Bertram was staffing up nicely.
Ernestine decided that the needed a new approach, so she went for coffee with Mark Fidrych to get his advice. Mark was the company’s CFO, and she worked closely with him on the company’s supply chain. Mark was also an angel investor on the side and he knew a little about the software industry. He nodded sympathetically when she explained that what was working for Bertram wasn’t working for her.
“Look,” he explained, “The essential difference between your situation and Bert’s is that Bert has a lot more qualified people applying for his positions. Sure, there are klunkers. But let’s say that half of the resumes he gets are decent. If he gets a hundred resumes and throws fifty away blindly, he’s still left with twenty-five decent ones on average. Essentially, Bert’s problem is how to organize his time, not how to find good people. When you asked for his advice, you described your problem in the same terms, so naturally he told you how he does it.”
“But you don’t really have a how-to-organize-your-time problem, you have a finding a needle in a haystack problem. There are way fewer qualified people applying for programming jobs. If you get one hundred resumes, you might have no qualified people, you might get one, if you get two or three in a hundred you’re doing well. If you have one good person in a hundred and you throw fifty away randomly, you now only have fifty resumés to sift through, but there’s a fifty-fifty chance you won’t find anyone worth interviewing, much less hiring.”
Ernestine nodded. “So,” she essayed, “I need to be a lot more selective about the resumés I discard because I have a much lower signal-to-noise ratio?” Mark stared at her blankly, then laughed as he caught her meaning. “Right!”
Ernestine stopped throwing half the resumés away and started treating her job as one of finding that elusive one good person in a hundred. It took time, and she found herself making a lot of adjustments.
two years later
Ernestine and Mark left to found a supply chain management company. Their startup grew quickly, and Ernestine found herself in a meeting with Oscar, an unkempt but talented team lead she had just promoted. Oscar was holding a stack of resumés and he wanted advice about hiring. Ernestine smiled and told him about her experience trying to implement Bertram’s advice, and how Mark’s advice turned things around for her.
Oscar seemed a little grouchy. “That’s a nice story,” he said, “but what specifically did you do?” Ernestine smiled, Oscar could be brusque. “Well,” she began.
“First, I stopped caring so much about little things like how ‘professionally’ a resume was formatted or whether the cover email had spelling mistakes. I realized that throwing people away because of a spelling mistakes was really another way of discarding half the resumés because you don’t want to work with unlucky people.”
“Wait,” said Oscar, “but surely all things being equal, the person who takes the time to get the email right is better than the person who doesn’t?”
“Sure,” agreed Ernestine, “But all other things aren’t equal. What if the email with the spelling mistake came from someone who’s really busy because they’re talented and have a lot to do in their current position?”
“No way,” argued Oscar, “If they want to work here, they’ll take the time to check their spelling.”
“That’s true,” agreed Ernestine, “And if I had fifty great people, I want to speak to the twenty-five who want to work here before I speak to the twenty-five who aren’t sure. But if I have a pile with ninety-nine duds and one good person, I’m more interested in finding that one good person first and deciding whether they want to work here second.”
“The problem with filtering people by spelling mistake is that we’re making up a little theory about whether a spelling mistake tells us something important about the candidate’s abilities. Which would be fine if we didn’t have anything else to go by, but we do have something else to go by, we have their resumé and their code samples and we can call them on the phone and talk to them. So I gnore the little theories and go with what really matters.”
Oscar considered this. “Ok,” he continued, “What else?”
“Well,” continued Ernestine, “I took the same thinking to everything I did when hiring. Every way of selecting or rejecting a person is either a direct measurement of their ability to do the job or an indirect measurement. Indirect measurements are things like computer science degrees. They—“
Oscar interrupted her. “Look,” he said, “University teaches you important things, things that are essential to doing your job. A degree is a requirement, and I don’t mean as a test of conformity.” Ernestine nodded. “Well, it’s true that nearly everyone we’ve hired has had a degree. But all the same, I didn’t sort resumes by degree or by school, I simply looked for relevant experience and reviewed the candidate’s code samples or portfolios when they had them to share. It turns out that almost everyone with the experience we wanted also had a University Degree.”
“But it’s dangerous to confuse correlation with causation. And especially dangerous to confuse correlation with necessity. If University is a great idea for a programmer, it will sort itself out when you look at their experience, look at their code, and interview them. I take the same approach to stuff like whether they blog or have hip hobbies like rock climbing. Most of our folks climb, mountain bike, or paddle, but I ignore that when looking at resumés.”
“After all, having the wrong hobby would be very unlucky. And I don’t throw unlucky resumés away.”
hiring programmers, not ascetics or rock stars
Oscar thought about that for a while. Ernestine continued. “Obviously, we don’t ask people to share their social media with us. But I try to resist the temptation to read anything personal about a candidate, even if it’s public. I don’t want to be subconsciously prejudiced for or against them. It’s a disaster if I miss the one in a hundred because they’re a friend-of-a-friend and I can see on their Facebook that they espouse political views I abhor. That’s not only illegal, it’s bad for business.”
“I also don’t want to be prejudiced in their favour because they seem to be a like-minded soul. If there’s only one in two hundred resumes worth considering, quite a few people are going to be really nice people that nevertheless aren’t right for us. The best thing is to avoid reviewing anything that isn’t pertinent to the task at hand, which means code or words about code.”
“They can spout all they want about politics and Freedom Zero on their blog, but if I’m considering them for a job, I don’t want to know what they think about stuff like that, and I stopped myself from reading anything off-topic when researching candidates. As far as hiring is concerned, having compatible opinions is a question of luck, not qualifications.”
Ernestine was warming to the subject. “Another thing I did was start advertising in plain English. We tried placing ads for ninjas, rock stars, and so on, but I discovered this was the cultural equivalent of advertising for white males who drink dry martinis. Not that white males who drink dry martinis can’t do the job, but there’s no real difference between advertising for a Ninja and throwing half your resumés away because you don’t like unlucky people. Either way, you end up with fewer resumés.”
Oscar spoke again. “But what if the Ninja ad attracts more qualified respondents than the plain ad?” Ernestine smiled. “When you’re programming, how do you know which code to optimize?”
Oscar smiled. “I measure. Premature optimization is the—Oh, I get it!”
“Right,” Ernestine continued, “I measure too. And you ought to. Advertising for people is no different than selling things online. You track everything and measure everything. You A/B test. You run analytics. And you don’t throw half of your market away.”
“But,” Oscar protested, “You say our problem is finding that one person in a hundred or one in two hundred. How does being so damn inclusive help? We still need to reject ninety-nine people.”
“Ah,” explained Ernestine, “What I do is raise the actual talent bar higher to make up for removing all the other hurdles between a candidate and an interview. You shouldn’t reject people because they don’t look or sound like the last good person you hired, but you can and should reject people who can’t do the job. I don’t give anyone a free pass. I don’t care if they say they have Lisp experience and I heard them speak at RubyFringe and they let it drop that they were talking to Brendan Eich at Christian Jaekl’s wedding. I grill them, hard, on actual programming and actual software development.”
Oscar nodded. “Thanks,” he said, then hesitated. “Hey,” he said, “I think I just realized why you hired me when so many other places wouldn’t even give me a phone screen. Thanks a lot.”
“No thanks necessary,” said Ernestine, “You’re a great programmer and you’re going to be an even better team lead. You belong here. We’ll do great things together.”
The path is set via a myriad of config files. It is very easy to accidentally add the same directory to the path, and there is no built-in mechanism from preventing this situation.
While it has no impact on performance, it does make reading the path more difficult (for example, when trying to see if a particular directory is in the path).
Easy Fix
When you find your path cluttered up with duplicate directories, it is relatively easy to correct this. Simply use pathmunge to add directories instead of the typical
export PATH=/fizz/buzz:$PATH
Procedure
First, edit your /etc/bashrc (or equivalent) and add the following function:
pathmunge () {
if ! [[ $PATH =~ (^|:)$1($|:) ]] ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
Now you can call this function in your ~/.bashrc, ~/.bash_profile, or wherever you need to add a directory to the path. There are two ways to do this.
Insert at the beginning of the path
Using
pathmunge /path/to/dir
is the functional equivalent of
export PATH=/path/to/dir:$PATH
Append to the end of the path
pathmunge /path/to/dir after
is the functional equivalent of
export PATH=$PATH:/path/to/dir
In either case, the directory won’t be added if it already is in the path, preventing duplicates.
Note: this was written by Raganwald on posterous.com, which unfortunately went belly-up April 2013. It is too important a lesson to let disappear, so I’m posting it here.
Bertram Wooster and Ernestine Anderson were staffing up their teams. Bertram was hiring trainees to work in the company’s retail stores, Ernestine was hiring software developers to build a new supply chain system for the company’s operations. “Bert,” Ernestine asked, “I have hundreds of resumés, how do I whittle them down to a handful of calls and a few interviews?”
Bertram smiled. He grabbed a pile of resumés from his desk, then started dealing the resumés out, first one back onto his desk, second into the recycle bin, third onto his desk, fourth into the recycle bin. When he was finished, he had thrown half of the resumés away. “It’s simple.” Bertram told Ernestine. “Just don’t hire anybody who’s unlucky.”
Ernestine tried that for a few weeks, throwing half the resumes out and the combing through the remainder looking for qualified applicants. She got nowhere, even if the people looked good on paper, when she talked to them on the phone it was quickly apparent that they weren’t capable of writing FizzBuzz. Meanwhile, Bertram was staffing up nicely.
Ernestine decided that the needed a new approach, so she went for coffee with Mark Fidrych to get his advice. Mark was the company’s CFO, and she worked closely with him on the company’s supply chain. Mark was also an angel investor on the side and he knew a little about the software industry. He nodded sympathetically when she explained that what was working for Bertram wasn’t working for her.
“Look,” he explained, “The essential difference between your situation and Bert’s is that Bert has a lot more qualified people applying for his positions. Sure, there are klunkers. But let’s say that half of the resumes he gets are decent. If he gets a hundred resumes and throws fifty away blindly, he’s still left with twenty-five decent ones on average. Essentially, Bert’s problem is how to organize his time, not how to find good people. When you asked for his advice, you described your problem in the same terms, so naturally he told you how he does it.”
“But you don’t really have a how-to-organize-your-time problem, you have a finding a needle in a haystack problem. There are way fewer qualified people applying for programming jobs. If you get one hundred resumes, you might have no qualified people, you might get one, if you get two or three in a hundred you’re doing well. If you have one good person in a hundred and you throw fifty away randomly, you now only have fifty resumés to sift through, but there’s a fifty-fifty chance you won’t find anyone worth interviewing, much less hiring.”
Ernestine nodded. “So,” she essayed, “I need to be a lot more selective about the resumés I discard because I have a much lower signal-to-noise ratio?” Mark stared at her blankly, then laughed as he caught her meaning. “Right!”
Ernestine stopped throwing half the resumés away and started treating her job as one of finding that elusive one good person in a hundred. It took time, and she found herself making a lot of adjustments.
two years later
Ernestine and Mark left to found a supply chain management company. Their startup grew quickly, and Ernestine found herself in a meeting with Oscar, an unkempt but talented team lead she had just promoted. Oscar was holding a stack of resumés and he wanted advice about hiring. Ernestine smiled and told him about her experience trying to implement Bertram’s advice, and how Mark’s advice turned things around for her.
Oscar seemed a little grouchy. “That’s a nice story,” he said, “but what specifically did you do?” Ernestine smiled, Oscar could be brusque. “Well,” she began.
“First, I stopped caring so much about little things like how ‘professionally’ a resume was formatted or whether the cover email had spelling mistakes. I realized that throwing people away because of a spelling mistakes was really another way of discarding half the resumés because you don’t want to work with unlucky people.”
“Wait,” said Oscar, “but surely all things being equal, the person who takes the time to get the email right is better than the person who doesn’t?”
“Sure,” agreed Ernestine, “But all other things aren’t equal. What if the email with the spelling mistake came from someone who’s really busy because they’re talented and have a lot to do in their current position?”
“No way,” argued Oscar, “If they want to work here, they’ll take the time to check their spelling.”
“That’s true,” agreed Ernestine, “And if I had fifty great people, I want to speak to the twenty-five who want to work here before I speak to the twenty-five who aren’t sure. But if I have a pile with ninety-nine duds and one good person, I’m more interested in finding that one good person first and deciding whether they want to work here second.”
“The problem with filtering people by spelling mistake is that we’re making up a little theory about whether a spelling mistake tells us something important about the candidate’s abilities. Which would be fine if we didn’t have anything else to go by, but we do have something else to go by, we have their resumé and their code samples and we can call them on the phone and talk to them. So I gnore the little theories and go with what really matters.”
Oscar considered this. “Ok,” he continued, “What else?”
“Well,” continued Ernestine, “I took the same thinking to everything I did when hiring. Every way of selecting or rejecting a person is either a direct measurement of their ability to do the job or an indirect measurement. Indirect measurements are things like computer science degrees. They—“
Oscar interrupted her. “Look,” he said, “University teaches you important things, things that are essential to doing your job. A degree is a requirement, and I don’t mean as a test of conformity.” Ernestine nodded. “Well, it’s true that nearly everyone we’ve hired has had a degree. But all the same, I didn’t sort resumes by degree or by school, I simply looked for relevant experience and reviewed the candidate’s code samples or portfolios when they had them to share. It turns out that almost everyone with the experience we wanted also had a University Degree.”
“But it’s dangerous to confuse correlation with causation. And especially dangerous to confuse correlation with necessity. If University is a great idea for a programmer, it will sort itself out when you look at their experience, look at their code, and interview them. I take the same approach to stuff like whether they blog or have hip hobbies like rock climbing. Most of our folks climb, mountain bike, or paddle, but I ignore that when looking at resumés.”
“After all, having the wrong hobby would be very unlucky. And I don’t throw unlucky resumés away.”
hiring programmers, not ascetics or rock stars
Oscar thought about that for a while. Ernestine continued. “Obviously, we don’t ask people to share their social media with us. But I try to resist the temptation to read anything personal about a candidate, even if it’s public. I don’t want to be subconsciously prejudiced for or against them. It’s a disaster if I miss the one in a hundred because they’re a friend-of-a-friend and I can see on their Facebook that they espouse political views I abhor. That’s not only illegal, it’s bad for business.”
“I also don’t want to be prejudiced in their favour because they seem to be a like-minded soul. If there’s only one in two hundred resumes worth considering, quite a few people are going to be really nice people that nevertheless aren’t right for us. The best thing is to avoid reviewing anything that isn’t pertinent to the task at hand, which means code or words about code.”
“They can spout all they want about politics and Freedom Zero on their blog, but if I’m considering them for a job, I don’t want to know what they think about stuff like that, and I stopped myself from reading anything off-topic when researching candidates. As far as hiring is concerned, having compatible opinions is a question of luck, not qualifications.”
Ernestine was warming to the subject. “Another thing I did was start advertising in plain English. We tried placing ads for ninjas, rock stars, and so on, but I discovered this was the cultural equivalent of advertising for white males who drink dry martinis. Not that white males who drink dry martinis can’t do the job, but there’s no real difference between advertising for a Ninja and throwing half your resumés away because you don’t like unlucky people. Either way, you end up with fewer resumés.”
Oscar spoke again. “But what if the Ninja ad attracts more qualified respondents than the plain ad?” Ernestine smiled. “When you’re programming, how do you know which code to optimize?”
Oscar smiled. “I measure. Premature optimization is the—Oh, I get it!”
“Right,” Ernestine continued, “I measure too. And you ought to. Advertising for people is no different than selling things online. You track everything and measure everything. You A/B test. You run analytics. And you don’t throw half of your market away.”
“But,” Oscar protested, “You say our problem is finding that one person in a hundred or one in two hundred. How does being so damn inclusive help? We still need to reject ninety-nine people.”
“Ah,” explained Ernestine, “What I do is raise the actual talent bar higher to make up for removing all the other hurdles between a candidate and an interview. You shouldn’t reject people because they don’t look or sound like the last good person you hired, but you can and should reject people who can’t do the job. I don’t give anyone a free pass. I don’t care if they say they have Lisp experience and I heard them speak at RubyFringe and they let it drop that they were talking to Brendan Eich at Christian Jaekl’s wedding. I grill them, hard, on actual programming and actual software development.”
Oscar nodded. “Thanks,” he said, then hesitated. “Hey,” he said, “I think I just realized why you hired me when so many other places wouldn’t even give me a phone screen. Thanks a lot.”
“No thanks necessary,” said Ernestine, “You’re a great programmer and you’re going to be an even better team lead. You belong here. We’ll do great things together.”
The path is set via a myriad of config files. It is very easy to accidentally add the same directory to the path, and there is no built-in mechanism from preventing this situation.
While it has no impact on performance, it does make reading the path more difficult (for example, when trying to see if a particular directory is in the path).
Easy Fix
When you find your path cluttered up with duplicate directories, it is relatively easy to correct this. Simply use pathmunge to add directories instead of the typical
export PATH=/fizz/buzz:$PATH
Procedure
First, edit your /etc/bashrc (or equivalent) and add the following function:
pathmunge () {
if ! [[ $PATH =~ (^|:)$1($|:) ]] ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
Now you can call this function in your ~/.bashrc, ~/.bash_profile, or wherever you need to add a directory to the path. There are two ways to do this.
Insert at the beginning of the path
Using
pathmunge /path/to/dir
is the functional equivalent of
export PATH=/path/to/dir:$PATH
Append to the end of the path
pathmunge /path/to/dir after
is the functional equivalent of
export PATH=$PATH:/path/to/dir
In either case, the directory won’t be added if it already is in the path, preventing duplicates.
“I need a time and cost estimate to develop a fizzbuzz mobile app on all minor mobile platforms (Windows/Blackberry/Symbian), and I need that estimate in 15 minutes.”
When you need to develop/design a solution for the majority of corporate users, you will need to test it on Internet Explorer. If you have a Mac, setting this up on your machine is easy.
The original source for this information was OSXDaily. I cleaned it up and added additional information.
Intended Audience
If you’re unfamiliar with using the terminal, these instructions will not help you. The point is to allow you to install Internet Explorer on Mac for the purposes of testing and developing web applications and sites. Ideally, you are one of the following:
Web Developer
Web Designer
QA Tester
If you plan on running Internet Explorer for other purposes (such as working with an IE-only site), then this is probably not the best solution for your needs.
Once you have the virtual machines installed, fire them up, set up the Windows instance (install drivers, etc.), then take a snapshot. This is the one you will always use.
When you get a ‘you must activate’ notice, open a Windows cmd line and run
slmgr –rearm
You can rearm two times before it won’t work anymore. At that point, roll back to your snapshot and you can rearm again when you get the message. Obviously, when you roll back to your snapshot all changes will be discarded (that’s the point), so make sure you save any data on your host’s drive.
FAQ
Q. Where is the command line on my Mac? A. It is not recommended that you use these instructions; instead try another solution such as Apple Boot Camp.
Q. How do I install/uninstall Oracle Virtual Box? A. You can try looking for information on the Oracle Virtual Box website or contact the Genius Bar at your local Apple Store for assistance.
Q. Where are the windows snapshots stored? A. In ~/.ievms/
Q. The download stalls or crashes. A. If it stalls, check your internet connection; you may have to restart the install. In the event of a crash, examine the error message to determine the cause of the problem.
Q. Can you just install it for me? A. Sorry, no.
Won Word
To rearm XP, use: rundll32.exe syssetup,SetupOobeBnk
I don’t have the exact errors to post because I deleted my compile log, but they are the same errors you get if you don’t have the bzip2 development libraries installed, which of course I do in /www
[snip]
Then someone helpful asks for more information.
Please recompile so that you can tell us te exact errors.
Derick
And then, GOLD:
The php developer who added/maintains bzip2 support will know what I am talking about. I am not going to compile when I know this! It would be a waste of my time.
Wow.
Now, not to worry; a few minutes later the submitter saw the error of his ways, compiled his code, posted the exact error message and got help.
Learning how to ask questions is a skill. Mastering this skill can only help, because everyone (even the Super-cool techno guru) has to ask for help at some point, so why not be as effective as possible?
I recently ran across the anti-pattern of what I see as a common problem amongst designers and developers: coupled presentation and content. I’ve found that decoupling the presentation from the content makes things much easier to write, maintain and expand.
Take a look at what is going on here: we’re adding a 10px margin to the top of the div. DON’T DO THIS. You want your class names to be contextual, not descriptive of the style.
Rule of thumb
To change the layout, you should only have to edit the CSS, not the HTML.
Here’s where our anti-pattern falls down and will cause grief.
You decide to adjust the positioning of the section. You can:
Edit the CSS, changing the class’s margin value and breaking every other element that uses that class.
Edit the HTML create a new class, then edit its CSS class definition. If you have to experiment with different margin values, you’ll need a LOT of classes. “Will 14px work or 15px? What about .25em? Argh!”
You can’t have too many attributes in each class, because they will have unintended consequences for the other elements that are using them. Add a red border to one class because you need a border for a specific element, now you have red borders on ALL the elements that share that class. So, you’ll have to have many single- (or few-) attribute values, and include all of the necessary ones on the required HTML elements.
<div style="margin:5px;border:3px blue outset;float:left;width:75%" ...
for no good reason.
The Cure
Think about the element in terms of content or a functional space. What is it and what does it do? In our example above, let’s assume it is the lede section of an article. Then we would do:
By decoupling the content (div) from the presentation (style-dependent class), we are free to adjust the style of that element by making whatever changes to the CSS and leaving the HTML alone.
“But,” you shriek, “I have common elements for everything! Rounded corners! Gradients! (except IE…) Et cetera!”
For this, we will turn to our trusty companions Less and/or Sass in a future post.
Won Word