Linux tip – regular expression find and replace in all files in a directory

As you may have seen me tweet, I’ve been looking for a way to do this. I didn’t want to manually change my Apache configuration to reflect my new internal IP address. After some Internet searching, I stumbled across this gem: http://www.linuxquestions.org/questions/linux-software-2/find-and-replace-text-in-multiple-file-203801/#post1742045

find . -name '[^.]*' | xargs perl -pi -e 's/192\.168\.1\.3/192\.168\.0\.3/g'

I adapted it to this for my task of replacing IP addresses. The first set of numbers is the old one (don’t delete the backslashes) and the second set is the new one.

This command assumes all files in the directory are configuration files and do not start with a dot.

Enjoy!

Update: According to a commenter, sed -i 's/thisip/thatip/g' * should also work. I didn’t try that since I thought it wouldn’t work with multiple input files.

Cloning Content Types in D7 – Errata

Update: You may also want to check out the Bundle Copy module. I haven’t tried it yet, so let me know in the comments if it works!

Recently, I read the Stanford Tech Commons article on Cloning a Content Type in D7 at https://techcommons.stanford.edu/topics/drupal-7x/cloning-content-type-d7. It proposes a simple but (mostly) effective way  to wind up with cloned content types in Drupal 7. Summarized:

How-to: Create Drupal development sites in Quickstart

Yesterday, I felt like reviewing some patches, so I fired up my Quickstart-based virtual machine and set about creating some Drupal development sites. I realized I first had to create Drush Make files to get the proper development versions installed. So I did that. However, I also realized that, despite cloning the code via Git and checking out a particular branch, the Git clone was not actually a Git repository. This is because Drush Make requires the –working-copy switch in order to do this. I’ve posted a workaround on the Quickstart issue queues. This post mostly serves as pointers to a couple things:

Feeds CSV Importer Sources: Caveat Amplificator

I had an interesting experience with Feeds and Feeds Tamper today. I wasn’t able to get a comma-separated set of words to turn into multiple tags no matter what I tried. I was using the Explode plugin that comes with Feeds Tamper and set the delimiter as a comma and the limit to 1. My research indicated this should work, but it didn’t.

There were two problems that were so counterintuitive, the urge to blog about them came over me. Disclaimer: I admit I’ve never properly read the Feeds documentation; I figured setting up a node importer based off a CSV parser would be pretty easy.

The solution is extremely simple:

When setting up your CSV importer and specifying Source column names, do not use spaces or uppercase letters. This means you need to avoid it in your CSV file as well.

That’s all! Instead of Body Text, call it body_text. What happens is that by the time Feeds Tamper receives your Feeds field, the data structure it uses to store them contains lowercase (and probably space-free) versions of whatever you had as the Source column names back in your updater. Using my tip ensures that these will be the same, and Feeds Tamper will be happy.

Have fun tampering.

P.S. The Latin in the title hopefully means, “Developer beware.”

wiz1.us back, Fill PDF Service still a bit slow

wiz1.us seems to be back (I think it’s generally been working anyway, since it uses hook_boot() and doesn’t have to bootstrap much).

Fill PDF Service is still somewhat slow but does seem to be loading now. The host mentioned that some packet loss is occurring, so I guess that’s what it is.

Hold out a bit longer. Thanks.

Meetup API Tools Seek Co-Maintainer, Further Developments Possible

Always wanted to entitle something like that. Anyway, I’m certainly not getting anywhere fast on PHP Meetup API Client or Meetup API on drupal.org.

There are issues on both expressing this. Reply to them or contact me.

Meetup API on drupal.org issue: http://drupal.org/node/1194532
GitHub issue: https://github.com/wizonesolutions/meetup_api/issues/4

Code Sprint Report: San Diego, Conference Organizing Distribution (COD)

On May 7, I attended a code sprint in San Diego. Fortunately, Jerad Bitner has already blogged about this. Given that, I’ll share my experience and impressions rather than the event breakdown.

My previous code sprint was at SANDCamp 2011. That one was different in that the goals were planned out in advance and most of the time was spent writing code. In contrast, most of the time in this first COD sprint was spent planning, tweaking make files, and re-building feature modules. Porting an installation profile is a bigger job than writing a module, that’s for sure!

I mostly worked on researching the state of COD’s dependencies and updating the make file and groups.drupal.org wiki page accordingly.

The sprint was fun, and I’d do it again. It’s even better that the sprint helped move it forward.

I’ll be sprinting again at DrupalCon London, so look for me!