• Development

    Applescript to Interact with iTerm2

    iTerm2 has decent support for Applescript. You can work with sessions, profiles, tabs, and more through Applescript. I only have one example, but it’s something I use in the real-world, so maybe it’ll help someone else.

    The following script will open a new tab for every server in the list, and execute a command on that server. Let’s say a new version of Drush is available. I’d use this script to log into every server (we have no less than 15 servers) and check which version of Drush the server is running. I could then quickly update if needed, and I’m already logged in to do so.

  • Development

    Sorting by Specific Fields with Apache Solr

    Recently I had to configure an Apache Solr search page to have the results sorted by a date field. We’re using the apachesolr module, which has a number of useful hooks, two of which we’ll use to accomplish this custom sort.

    If you browse to Administration » Reports » Apache Solr search index you will see a list of the indexed fields (example shown below). Most of the documentation I’ve seen out there regarding apachesolr sorting says you can use $query->setAvailableSort()  and $query->setSolrSort() within an implementation of  hook_apachesolr_query_prepare() , but there is at least one caveat: the field you want to sort on must be a single-value field! Here’s a look at the field list on the site I’m working on:

    apachesolr_fields

  • Development

    Userscript: Hulu Right-Click for Pop Out Video

    Hulu’s default rather large video player is usually too big for my needs. I prefer the “Pop Out” player. So, I often load the large video, click the cog wheel, move my mouse to the “popout” link, click it, then close the main window. It’s been a pain in the butt. So, I took some time to write a simple userscript that lets you right-click on any video thumbnail to open its video in the popout immediately. It’s working great for me but I have not tested it elsewhere, so I won’t be surprised if it doesn’t work for you… just let me know in the comments below…

    http://userscripts.org/scripts/show/311800

    UPDATE: I rewrote this as a Chrome Extension and published it. View the blog post.

  • Uncategorized

    Creating Field Groups in a Custom Module

    If you need your module to add a fieldgroup to your Drupal 7 site, follow this quick and easy process: Also, if you’re looking to create fields, see this related post.

    1. Build the fieldgroup through the “manage fields” UI.
    2. Modify the code below to include a proper $fieldgroup_name, $entity_type and $bundle_name. I needed to add a field to the user profile, so I set the $entity_type to “user” and the $bundle_name to “user”.
  • Development

    Creating Fields in a Custom Module

    I’m going to be very brief here, because Joel Stein covers this beautifully. Also, if you’re looking to create fieldgroups, see this related post.
    If you need your module to add a field to your Drupal 7 site, follow this quick and easy process:

    1. Build the field through the “manage fields” UI.
    2. Modify the code below to include a proper $field_name, $entity_type and $bundle_name. I needed to add a field to the user profile, so I set the $entity_type to “user” and the $bundle_name to “user”.
  • Development

    WordPress Plugin: Search Regex

    I wanted to quickly mention this plugin as it saved me a bit of time just now. While I worked on this new blog I set the development site up at wordpress.agileadam.com. When I switched the agileadam.com domain over to point to this new WordPress site all of my images stopped working (because the img tags pointed to wordpress.agileadam.com urls; shouldn’t they be relative anyway!? I’ll look into that later).

  • Development

    Add Links to Anchors Automatically

    The following snippet is something I used recently to add (below the current item in a menu) links to any anchors found in the content.

    Honestly I could probably create the <ul> outside of the each() loop and save having to check whether it exists with each iteration. Also, it’s probably not necessary to create the aname variable, but the overhead here is minimal.