« November 2012 | Main | January 2013 »

December 19, 2012

Add timeline view of datasets

The goal of this to do is to establish a graphical view of the span of various datasets.

1. Add Datetime field to Dataset:
Collection Dates|field_dataset_sample_dates|Datetime|Select List

- This field type is required by timeline. You could also modify the module itself which is probably better.

- Set Permissions for the new field (view Anonymous, edit colleague)

- Must be 1 value only (not unlimited)

2. Install Timeline

$ cd ~/sites/all/modules
$ wget http://ftp.drupal.org/files/projects/timeline-6.x-2.1.tar.gz
$ tar -xzf timeline-6.x-2.1.tar.gz
$ rm timeline-6.x-2.1.tar.gz

- Enable timeline and VBO, run update.php

3. Build VBO view (Unnecessary, Timeline is compatible with field type Date.

Fields
Content: Collected - From date Default
Content: Collected - To date Default
Content: Collection - From date Default
Content: Collection - To date Default
Node: Title Title

Filter
Content: Collected (field_beg_end_date) - From date not empty


Style
Bulk Operations (php execute)
Default sort by node title
Uncheck preserve across pages

Access
Administrator

4. Copy dates to new field (Unnecessary, Timeline is compatible with field type Date.

$object -> field_dataset_sample_dates[0]['value'] = str_replace("T", " ", $object->field_beg_end_date[0]['value']);
$object -> field_dataset_sample_dates[0]['value2'] = str_replace("T", " ", $object->field_beg_end_date[0]['value2']);
node_save($object);

5. Delete VBO view and module

6. Add Timeline view
Type
Node

Style
Timeline


Items to display
Unlimited

Fields
Node: Title
Content: Collection - From date Default
Content: Collection - To date Default

Filters
Node: Type = Data Set
Node: Published Yes

Page Display
Path
datasets/timeline


7. After realizing that Timeline only works with date fields of 1 value (From/To) I am aborting this mission because that is incompatible with our data model.

Posted by kkwaiser at 09:45 AM | Comments (0)

December 18, 2012

Recurring Updates to Drupal Modules

*Highjacking my own blog post*

Patch Drupal Core
Drupal 6 doesn't like empty, required radio buttons and this causes problems when using the Conditional Fields module. The patch here, allows the form validation to ignore required, hidden and empty radio-button fields. Patch at line 700. Referencing post is here.


WYSIWYG:
If, after updating WYSIWYG, the biography field when adding a new Person (/node/add/person) is autopopulated with a break tag apply this patch (at least until the editor is finally patched) to avoid the addition of
tags into blank paragraphs.
- Create a text file containing the patch (para_fix.diff)
- SFTP it into the wysiwyg root directory
- Apply it $ patch -p0 < para_fix.diff


Marinelli:
I've heavily customized this theme so any updates should be done very carefully. Unfortunately, I haven't thought about this much and don't know what the best approach to updating it will be. Right now, I just hope no updates come out.

Print
When new versions of this module come out the print/lib/dompdf/ folder needs to be replaced. This library allows for pages to be printed as PDF.

SMTP
Another module with a library that needs to be replaced. I recommend copying the original library into the new module folder. smtp/phpmailer/

Biblio:
There are two changes that need to be made to biblio files everytime the module is updated:

1. Change the appears of the export links:

"Tagged to Endnote"
biblio_theme.inc
line 922 954
function _build_biblio_tagged_link($base, $nid) {

"RTF to RichText"
line 912 943
function _build_biblio_rtf_link($base, $nid) {


Posted by kkwaiser at 04:42 PM | Comments (0)

Copy date field values with Drupal VBO

Ugly PHP snippet follows:

dpm($context);

$date1 = str_replace("T", " ", $object->field_beg_end_date[0]['value']);
dpm($date1);

$object -> field_dataset_sample_dates[0]['value'] = strtotime(str_replace("T", " ", $object->field_beg_end_date[0]['value']));
$object -> field_dataset_sample_dates[0]['value2'] = strtotime(str_replace("T", " ", $object->field_beg_end_date[0]['value2']));
node_save($object);

dpm($object);

This video gave led me to the strtotime function which shouldn't actually be used for copying to datetime fields.

VBO documentation node

Posted by kkwaiser at 04:20 PM | Comments (0)

December 07, 2012

Connect to the LSA DFS

$ sudo mkdir /dev/umbs

$ sudo /sbin/mount.cifs //lsa.m.storage.umich.edu/lsa-umbs /dev/umbs -o user=UMROOT/kkwaiser sec=krb5i

See the Mainstream Storage docs for more.

Posted by kkwaiser at 02:01 PM | Comments (0)

Convert ogv to mp4 or flv Ubuntu

This was serially annoying to figure out. However, in the process I found probably the best Ubuntu tutorial ever. I mean, thorough installation instructions are great but they even guide you through uninstalling your first failed attempt AND tell you how to undo the tutorial you just followed!

Compile FFmpeg on Ubuntu

and then it is

$ ffmpeg -i /tmp/input-2.ogv /tmp/output.mp4
$ ffmpeg -i /tmp/input-2.ogv /tmp/output.flv

Note, I also got PiTiVi to convert ogv to flv but ogv to mp4 failed.

I did get one error

dpkg-deb: error: parsing file '/var/tmp/tmp.wbpjpldtdB/package/DEBIAN/control' near line 7 package 'ffmpeg':
error in Version string '5:git-2012-12-07-1f46722-1': version number does not start with digit


dpkg-deb: error: parsing file '/var/tmp/tmp.wbpjpldtdB/package/DEBIAN/control' near line 7 package 'ffmpeg':
error in Version string '5:git-2012-12-07-1f46722-1': version number does not start with digit
(END)
/var/tmp/tmp.wbpjpldtdB/dpkgbuild.log

and don't know what it means or how to fix it but that doesn't matter because things appear to work.

Posted by kkwaiser at 01:44 PM | Comments (0)

December 06, 2012

Tweaking Ubuntu mic volumes

Somehow my mic settings got messed up and sound very, very quiet with a lot of background static. There are probably better ways to fix this problem but here is a way to improve it, at least.

In my Sound Preferences (System > Preferences > Sound) I am using Hardware:Analog Stereo Duplex and Input: Microphone 2 (Front Mic)

In a terminal:

$ alsamixer

Press F4 to get to the Capture portion of the mixer.

Arrow Left or Right to Front Mic Boost and take to 100
Arrow Left or Right to Capture and set at ~85

Test and repeat

Posted by kkwaiser at 04:26 PM | Comments (0)

Block user accounts via database operation

I've had problems where I want to block a 100 or more user accounts at once. This leads to a Drupal memory error. To avoid the error you need to block accounts 5 or so at-a-time (working off the admin/user/user page).

This SQL can be used to block a lot of accounts at once based on role.

UPDATE drupal_users
LEFT JOIN drupal_users_roles ON drupal_users.uid = drupal_users_roles.uid
SET drupal_users.status = 0
WHERE drupal_users_roles.rid = 8

Posted by kkwaiser at 10:06 AM | Comments (0)

Unexpected 404 Page Not Found errors Drupal 6

PROBLEM:

I was in the process of locking some old user accounts and had just logged into the database via phpMyAdmin when the site started showing 404 Errors everywhere. The menus were not populating but there were signs that the site was still able to connect to the database. I remember I hit the users table but didn't (shouldn't have) made any changes when things went awry. I'm pretty certain nothing changed on the backend but that should be considered.


SOLUTION

FYI, I figured this out. Well, kind of. Via this page I had to run update.php. The problem was potentially related to the menu system or, prior to the freeze, I was trying to lock accounts. Operating on too many accounts at once leads to a WSOD. Possible memory error?

Posted by kkwaiser at 09:07 AM | Comments (0)