Jeff Geerling's blog

Meet Phergie, an efficient PHP IRC bot

The Drupal community uses IRC extensively for collaboration and community building. A permanent and ever-helpful fixture of the official #drupal-* IRC channels, and in the Drupal community itself, is the humble Druplicon bot. Druplicon is a Drupal-based IRC bot that was created in 2005, and is still going strong as part of the Bot module for Drupal.

Bots like Druplicon do a lot of nice things—they can remind people of things after they were away for a while, they can store facts, track karma, throw people virtual beers, store and retrieve helpful facts, and relay important information. For example, when a build fails in Jenkins, a bot can post a message in IRC. Similarly, if a server goes down, or is under heavy load, the bot could post a message.

What if you want your own bot for a different IRC channel? Drupal's Bot requires an entire Drupal environment to run, and while the bot is not too heavy on resources, an always-connected, efficient and pluggable bot would be better off on its own. And in PHP-land, there's just such a bot. Meet Phergie, a PHP IRC Bot.

Phergie logo

Announcing DrupalCamp STL.2014 - April 26 in St. Louis, MO

DrupalCamp STL 2014 Logo

St. Louis is getting ready for its first-ever DrupalCamp! On April 26, 2014, DrupalCamp St. Louis will open up with a keynote by Brad Nowak, a Business Development Manager at Palantir. The Camp will have sessions covering a variety of topics, like Drupal 8 and how your business can benefit from Drupal's flexibility. It will be held at Washington University's West Campus in Clayton, MO, just a few blocks from a MetroLink station and only a few minutes away from Downtown St. Louis!

Online registration is open already, and for the next couple of weeks, earlybird registration is only $15! For that tiny fee you get:

  • A free lunch from Lywelyns
  • An snazzy t-shirt
  • A full day's worth of Drupal learning from some great Drupal users and developers in St. Louis and the midwest
  • A fun after party paid for by our excellent sponsors

Space is limited, so register early to guarantee a spot at the first DrupalCamp in the region!

Also, if you're interested in speaking at the Camp, please submit your session; we'd love to hear about sites you've built, new things in Drupal, business uses of Drupal, project management, site building, etc.!

Remove Tower's .git folder association in Mac OS X's Finder

I use Tower from time to time to do some git operations that require a little more attention or a better visual overview than what I can get via the CLI and built-in tools. However, I noticed that Tower likes to take over any folder with .git, and make Mac OS X's finder turn it into a 'Tower' package, so double-clicking the folder (which now behaves like a mini app or file) opens Tower.

I don't like that behavior, because I have some [example].git folders that I want to browse in the Finder or in other Mac apps without having to 'Show Package Contents'. Apparently GitX has the same issue, and I'm not the only one annoyed by this behavior.

The fix, for me, was simple:

  1. Get info on the .git folder (right-click and 'Get Info', or select the folder and hit Command-I).
  2. Select 'Terminal' under "Open with:"
  3. The "Open with:" menu should then change to Finder.app (because Terminal realizes this is actually a folder).

It seems like, after doing this and clicking 'Change All...', you can't switch back to the old behavior, but that's fine by me. I'll open .git folders in Tower when I want to, thankyouverymuch!

Multisite Apache Solr Search with Domain Access

Using one Apache Solr search core with more than one Drupal website isn't too difficult; you simply use a module like Apache Solr Multisite Search, or a technique like the one mentioned in Nick Veenhof's post, Let's talk Apache Solr Multisite. This kind of technique can save you time (and even money!) so you can use one Hosted Apache Solr subscription with multiple sites. The only caveat: any site using the solr core could see any other site's content (which shouldn't be a problem if you control all the sites and don't expose private data through solr).

There are two ways to make Apache Solr Search Integration work with Domain Access (one of which works similarly to the methods mentioned above for multisite), and which method you use depends on how your site's content is structured.

Solr Search with Domain Access - Siloed Content

If the content you are indexing and searching is unique per domain (just like it would be unique per multisite Drupal instance), then you can set up Domain Access to index content with a different Apache Solr hash per site, like so:

Ansible Playbooks for Drupal 8 Testing and Mac Dev

Lately, I've been working a lot with Ansible, a simple but powerful infrastructure management platform. I now use Ansible playbooks and ad-hoc commands to manage all of Midwestern Mac's infrastructure (this site, Hosted Apache Solr, Server Check.in, and many ancillary servers), and as a result, I've started using Ansible for pretty much any kind of work I need to do in development—including configuring my own Mac, and developing with Drupal 8.

Meet Ansible

Ansible Logo - Black transparent

For those who haven't heard of Ansible before, it's often described as being a little like Puppet or Chef, used for configuration management. You define the configuration of a server, and Ansible makes sure the server is configured as defined. But Ansible goes quite a bit further—it's also great for deploying applications (especially in tandem with tools like Jenkins), running commands on servers, and day-to-day management of a few, hundreds, or even thousands, of servers—it's an end-to-end configuration management tool. Ansible also has a great, and rapidly-growing community, building it up and making it markedly better every release.

Ansible uses YAML to define configuration (just like Drupal 8!), and is relatively easy to pick up, especially if you already have some experience on the command line. You can read more about it in a book I'm writing, Ansible for DevOps, and hopefully, I'll be able to tell you more about Ansible in person at DrupalCon Austin—I've submitted a session titled DevOps for Humans: Ansible for Drupal Deployment Victory! (please leave a comment and let me know what you want to hear!).

Drupal development VM (Vagrant + Ansible)

I used to use MAMP (a simple-to-install Apache + MySQL + PHP setup for Macs) for all my development, which made adding virtual hosts to Apache relatively simple. However, there are many downsides to developing with MAMP—I could never configure things like drush, APC, the version of PHP, MySQL, or auxiliary tools like XDebug and Solr, exactly how I wanted or needed them.

Dump an entire database with structure only for some tables with mysqldump

I typically use a MySQL GUI like Sequel Pro when I do database dumps and imports working from my Mac. GUI apps often give checkboxes that allow you to choose whether to include the structure/content/drop table command for each table in an export.

When using mysqldump on the command line, though, it's not as simple. You can either do a full dump and exclude a few tables entirely (using --ignore-table, or dump the structures of just one set of tables using the -d option. But you can't do both in one go with mysqldump.

However, you can use the power of redirection to do both commands at once to result in one dump file with all your tables, with structure only for the tables you specify:

mysqldump -u username -p -h hostname database \
--ignore-table=database.cache_form\
--ignore-table=database.cache_entity_node\
--ignore-table=database.cache_views_data\
--ignore-table=database.sessions\
--ignore-table=database.watchdog\
> ~/Desktop/database-dump.sql\
&& mysqldump -u username -p -h hostname -d database \
cache_form \
cache_entity_node \
cache_views_data \
sessions \
watchdog \
>> ~/Desktop/database-dump.sql

Pages

Subscribe to RSS - Jeff Geerling's blog