• Development

    Overriding Image Field Attribute Forms

    Another quick example for you…

    Here’s what the default image field form looks like, if you have enabled alt and title attributes:

    image_field_before

    One way to modify the titles and help text (descriptions) of the Alternate text and Title attributes here is to use hook_field_widget_form_alter. Here’s what your code might look like:

    Here’s the result:

    image_field_after

     

     

  • 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.