Blog

Drupal development, project updates, occasional knee / head slappers

Jul 15, 2010

Go to settings

Select Music...

Set "Shake to shuffle" to off

Did that work for you, Mom?

Jun 16, 2011

Similar to RTFM (Read The F****ing Manual), CTFC is a headslapper that solves at a good number of the "I did everything right, but it's still not working" issues that come up with Drupal. Drupal caches theme functions, menu items, sometimes forms and entire pages. If you look at the database for any tables prefixed with cache_, you'll get an idea of just how insiduous the caching component of Drupal is.

So if you're having issues, take two CTFC's and call me in the morning.

To clear your caches, you have a few options:

1) You can go to your /admin/settings/performance page and click the Clear cached data button way down there on the bottom.

2) You can install Administration menu and hover over the icon in the top left corner (mine looks like the Acquia logo) and click the Flush all caches link (or a particular submenu item thereof).

3) I'm pretty sure you can clear the cache by manually truncating all of your database tables that start with cache_ plus the cache table. I use a program called Sequel Pro (which kicks serious butt, btw), and when I filter my tables to match cache_, here's what I get:

Note that there's a couple matching tables that shouldn't get truncated (hint: they start with imagecache...).

4) If you're really fancy, you can clear the cache using drush cc.

Jul 18, 2010

Quick stats:

  • The treadmill is a Pro-Form 770 EKG. I bought it on Cragslist for $150 (my last treadmill was $50)
  • I walk from 1-2 MPH (no, I don't run, in spite of the picture you see below). 
  • I'm on the treadmill for 4-6 hours a day

People ask me if I run on this thing. I don't. Partially because it would make working impossible, and partially because I work upstairs in an older home and fear for its integrity.

The white part is kind of a 'floating' surface. It's not screwed down so that I can shift it from time to time - mostly depending on how big my lunch is.

Here's what I did to attach the desk surface to the handles:

  • First, I removed the rubber handles, exposing the metal bar you see above
  • Then, I took a drill and trilled two holes in each handle.
  • I took the two screws from other parts of the treadmill that didn't really need them (I hope) and screwed in the bookshelf braces. I got the braces as True Value for a couple bucks apiece.
  • Once these were stable, I laid a bit of spare plywood board on the braces and marked out where the screw holes were.
  • I created some pilot holes and screwed the braces to the plywood.

The bright red item you see to the right is a fly gun.

Jul 14, 2010

// $Id:$

Bible Field

Bible Field is sponsored by Calvary Chapel (http://www.ccboise.org/) and written by Chris Shattuck (http://drupal.org/user/166383). A live version of this README file can be found at 

Introduction

The idea behind the Bible Field module is to provide a CCK field that can reference a body of work by book, chapter and verse. Below are some features:

  • The ability to reference a range or single point
  • A special Views 'range filter' that allows for search within a ranged entry (like chapters 2 to 10)
  • A compound Views filter that allows you to specify the granularity of the filter to book, chapter or verse
  • Books are pulled from a CVS file, so you can reference arbitrary bodies of work (not just Bibles)
  • Chapter selectors are automatically adjusted to the number of chapters in the currently selected book

Installation

See http://drupal.org/getting-started/install-contrib for instructions on how to install or update Drupal modules.

Usage

The Bible Field module adds two features: a new CCK field type, and additional filters for views. For a guide with screenshots, see http://chrisshattuck.com/node/119.

To add the CCK field:

1. Click the "Manage Fields" link next to your content type in /admin/content/types and scroll down to the bottom. 
2. Select the "Bible reference" type and fill in the rest of the form.
3. Next, choose your settings. There are two settings specific to Bible Field, the Version and the alphabetical sorting. If set to sort alphabetically, any book fields will be sorted from 1-9 and A-Z, otherwise the sorting will follow the default, which is likely the real order.

Now, you can add references in that node type.

To add a chapter range filter:

  1. Click the plus button next to the Filters section of a view to add a new filter, and select the Content category. 
  2. Scroll down until you see the fields ending in "Ending chapter" or "Starting chapter"check the 'Ending chapter' or 'Starting chapter'.
  3. Click the Add button.
  4. Under the 'Operator' select field, select 'Within start and end range'.
  5. Optionally, expose the filter

This will add a select input with a chapter select input. Searching for a particular chapter will allow you to search for nodes that match a particular chapter range. For example, if I have a node that references Genesis chapter 5-12, and I filter for chapter 7, it will be a match.

If you add a filter for the book as well, the numbers in the chapter select input will be auto-loaded with each change to match the number of chapters in the book.

To add a granular filter (filter by book, by book and chapter or by book,chapter and verse)

  1. Click the plus button next to the Filters section of a view to add a new filter, and select the Content category. 
  2. Scroll down until you see the "Bible field composite" option.
  3. Select this and click the Add button.
  4. Select the granularity (book, chapter or verse)
  5. Expose the filter

This filter is like a ranged search for chapter and verse with the book filter as well.

To add other books or bibles

Bible Field doesn't work for just bibles - it can function to reference any body of work, and even co-releate references across multiple works. You can have multiple reference fields in the same content type that reference different bodies of work.

To add a new reference list, you can look in the module directory under /optional_csv/hitchhikers_guide_to_the_galaxy.txt. In this file, you can see the structure required to feed Bible Field the correct information. On each new line there is the name of the book, a comma, and the number of chapters in the book.

If you copy this file over to bible_csv, you will see a new option when you add a CCK field for referencing the Hitchhiker's Guide to the Galaxy. Using this as an example, you can add any body of work you'd like.

Jul 14, 2010

This is a quick guide to getting started with the Bible Field Drupal module.

Adding the field to your content type

Click the "Manage Fields" link next to your content type in /admin/content/types and scroll down to the bottom. Select the "Bible reference" type and fill in the rest of the form.

Next, choose your settings. There are two settings specific to Bible Field, the Version and the alphabetical sorting. If set to sort alphabetically, any book fields will be sorted from 1-9 and A-Z, otherwise the sorting will follow the default, which is likely the real order.

The version allows you to select from multiple Bible versions. As an example of using a different source file, I've added a file called hitchhikers_guide_to_the_galaxy.txt in the optional_csv folder to demonstrate how Bible Field can be used for any book reference. If you drag this file over to the bible_csv folder, you'll be able to choose from the default King James Bible or the Hitchhiker's Guide to the Galaxy.

Using the field

Now that you've added the field, you can add references in your nodes. Go to the node add page for the content type you added the field to, and you should see the following:

Here you can select as many references as you need to. When you select a book, the chapter input will automatically be populated with the number of chapters in that book. Choose a starting chapter will automatically set the ending chapter to the same number.

Setting up filters in Views

Once you have content with references, you can set up a View. You can use the book, starting chapter, ending chapter, starting verse and ending verse fields, but there are two special filters as well.

The first is a range selector, to allow searching through a range of chapters and verses.

First, click the plus button next to the Filters section of the view to add a new filter, and select the Content category. Scroll down until you see the following, check the 'Ending chapter' or 'Starting chapter' and click the Add button.

Now you'll see the settings form for the filter. The special one available here is called "Within start and end range, as you see below:

If you select that, and expose the filter, you'll see a select input with a list of chapters. To make this most useful, also add a filter for the book as well and expose it. The resulting form might look something like this when you preview it in Views:

If you do this, the chapter select input should auto-fill with the number of chapters in the selected book. So if someone is doing a search for Genesis, chapter 5, and a piece of content matches a range of Genesis chapters 3-10, it will match.

The second special filter is simple and granular. Add a new filter, select to show only Content filters, and select the "Bible field composite" item, as seen below:

This will open up an options form to allow you to select the granularity of the input. You can choose to display just the book, the book and chapter, or the book, chapter and verse inputs, as you see below:

This filter works only as an exposed filter, so make sure to expose it. When you do, it should look something like this if you selected 'verse' for the granularity:

That's it, enjoy!

Jul 15, 2010

I kept banging my head against this one because the PHP function array_merge() will act strangely if all of the keys in an associate array are integers. So doing the following DOES NOT WORK:

'#options' => array_merge(array('' => ''), drupal_map_assoc(range(1, 100))),

But, doing the following DOES:

'#options' => array('' => '') + drupal_map_assoc(range(1, 100)),

Another solution that works, but is not as concise:

'#options' => drupal_map_assoc(array_merge(array('' => ''), range(1, 100)));
Oct 22, 2010

Whenever it's time to add a module to the drupal.org contrib repository, I flounder a bit. Here's a little documentation on the steps I took when recently adding the Evernote module.

From the command line...

First, you need to login using your CVS account username (replace cvs_username below):

export CVSROOT=:pserver:cvs_username@cvs.drupal.org:/cvs/drupal-contrib

cvs login

Next, check out the drupal contrib repository. From the command line, do:

cvs checkout -l contributions/modules

Copy the module folder over to the modules/ directory and add it with the following commands:

cvs add example

cvs add example/*

Commit it with the following:

cvs commit -m "Super helpful commit message here"

Create a project on drupal.org: http://drupal.org/node/add/project-project. As Boris points out below, some people like to do this before adding the project to CVS. I prefer doing it this way so that when any 'new project' alerts go out on RSS, there's something for people to download and play with right away.

To create a development branch, cd to the module directory

cvscalvar tag -b DRUPAL-6--1

To create an official release, cd to the module directory

cvs tag DRUPAL-6--1-0-BETA1

To update your current checkout to use the development version:

cvs update -dP -r DRUPAL-6--1

Now, you need to add any releases to the module project page by clicking the "Add new release" link on the project page.

In order to get the development release showing on the project page, you need to click on the "Administer releases" link (see image above). Then, check the "Show snapshot release" checkbox (see below)

Useful links:

Jul 20, 2010

// $Id:$

CONTENTS OF THIS FILE

  • Introduction
  • Installation
  • Usage

INTRODUCTION

Creator: ChrisShattuck <http://drupal.org/user/166383>

The original idea behind the Evernote module was to integrate the pulling of content from Evernote for rapid blogging purposes. My hope is to further abstract out some of the tools used to do this so that the module can be used as an API for open-ended integration with Evernote.

This module will do the following:

  • Establish a connection with an Evernote account
  • Allow an administrator to set up a 'feed' that will perform a one-way sync from Evernote to Drupal based on multiple criteria. For example, you can set up a feed to pull content with a particular tag.
  • Allow 2-way syncing of 'tags' as taxonomy terms
  • Downloading images and other resources from Evernote notes into image or file fields
  • And a bunch more

INSTALLATION

See http://drupal.org/getting-started/install-contrib for instructions on how to install or update Drupal modules.

You will also need to add the Evernote API library to Drupal. Right now the API isn't quite set up for web applications like this, so you'll need to do some finagling. You can use the instructions below to build the library yourself, or you can go to this URL to read about how to download a ZIP file with this already done: http://chrisshattuck.com/blog/instructions-setting-evernote-library-evernote-drupal-module

  1. Download the Evernote API (labeled "Evernote API") - http://www.evernote.com/about/developer/api/
    2. Expand the zip
    3. Copy the folder /sample/php/EDAMWebTest/lib/HTTP to /lib/php
    4. Copy the folder /sample/php/EDAMWebTest/lib/OAuth to /lib/php
  2. Next we need a few PEAR libraries that might not be installed on your server, so...
  3. Download the HTTP_Request PEAR script and add to /lib/php/HTTP - http://pear.php.net/package/HTTP_Request/
  4. Download the Net_URL PEAR script and add to /lib/php/HTTP - http://pear.php.net/package/Net_URL/
  5. Download the Net_Socket PEAR script and add to /lib/php/HTTP -http://pear.php.net/package/Net_Socket/
  6. Rename the folder /lib/php to evernoteand move it to your /sites/all/libraries/folder

USAGE

  1. Go to /admin/build/module and click the 'create a new account' link
  2. If you don't mind saving your Evernote username and password on the server, fill in the username and password at the bottom of the form. To receive a temporary authentication from Evernote, fill in the widget.
  3. Once the account as been added, you can click on 'Add feed' next to the account to create a feed.
  4. Fill out the form to create the criteria for the feed. When cron runs, it will import any new matches and update any changed notes.
Jul 20, 2010

Below are instructions for putting together a PHP-based API library for Evernote, particularly for the Evernote Drupal module. I've attached a ZIP file to this post (see the bottom) which can be used temporarily until the brilliant Evernote folks have the time to compile a distribution.

If you use the ZIP file included below the following instructions (evernote-api.zip), just unzip it and add it to your /sites/all/libraries folder. To put it together yourself, use the following instructions.

  1. Download the file here (labeled "Evernote API) 
  2. Expand the zip
  3. Copy the folder /sample/php/EDAMWebTest/lib/HTTP to /lib/php
  4. Copy the folder /sample/php/EDAMWebTest/lib/OAuth to /lib/php
  5. Next we need a few PEAR libraries that might not be installed on your server, so...
  6. Download the HTTP_Request PEAR script and add to /lib/php/HTTP
  7. Download the Net_URL PEAR script and add to /lib/php/HTTP
  8. Download the Net_Socket PEAR script and add to /lib/php/HTTP
  9. Rename the folder /lib/php to evernote and move it to your /sites/all/libraries/folder
Jul 18, 2010

As mentioned here, today I've been evaluating some speech-to-text services. As a practical test of Google's transcription service, I called my Voice account and started playing one of my training videos from buildamodule.com. The idea being that it would be great to be able to search text in videos without doing an actual transcription, which would kill me.

The result was pretty poor and very funny. Here we go:

"Hi. This is Chris Shattuck google model, dot, com and in the studio. We're gonna be talking about working with function. Hoople. So what the video that came before this where we talked about a rate is. We're gearing this lesson more towards people. They don't have a backrest P H P Felt it, but they need to work with cooking, kuple for somebody. Hey, here's what we're gonna cover. First of all look at how to identify function. And then we'll talk about what the fuck's actually his, and while we were just want we'll go over some handy conventions for or preheating a function some. Technical, conventions as user scruples based in particular, hoarded using references, which is an important concept understand or is choosing Cox in. Kuple. Speaking folks will talk about how to identify hook function and you just want we won't go into a death in this lesson, but there is some other videos on the site they do. Thanks, we'll take a look at creating private function. Sir basically functions that we don't want other modules access. It's a look at using variables that are outside of the scooper function or they're basically to find somewhere else at triple. If I will look at storing of permanent dribble inside of function, so we can. We use it Let's go ahead and get started by looking at how to write that 5 Hi Chris, this to make it bigger we're creating a function We're gonna start off with the function. If you were followed by space next is the name of the function in this case it's demo underscore me following the our print this. He's an inside of those parentheses, or any parameters we wanna add to the function. So, the user is variable."

Some of my favorite parts:

  • Various transcriptions of Drupal: "Hoople", "kuple", 
  • "We're gearing this lesson more towards people" - as opposed to....
  • "First of all look at how to identify function. And then we'll talk about what the fuck's actually his"
  • "Speaking folks will talk about how to identify hook function"
  • "If I will look at storing of permanent dribble inside of function, so we can."
  • "So, the user is variable."

Okay, so using Google voice for legitimate transcription services is out. But, great for a party.

Syndicate content Syndicate content Syndicate content Syndicate content Syndicate content