Skip to content

Instantly share code, notes, and snippets.

View anarchivist's full-sized avatar
🐈‍⬛

María A. Matienzo anarchivist

🐈‍⬛
View GitHub Profile
@anarchivist
anarchivist / extract.sql
Created December 24, 2009 17:17
Match records in Horizon item/bib data and convert MARC to CSV
/* Use to extract records from SirsiDynix Horizon matching certain item/bib criteria */
SELECT DISTINCT item.bib#
FROM item, bib WHERE bib.bib# = item.item#
AND item.collection NOT IN ('oh', 'icos', 'mi')
AND item.location = 'icos'
AND (bib.text LIKE '%audio%' OR bib.text LIKE '%video%'
OR bib.text LIKE '%cassette%' OR bib.text LIKE '%tape%'
OR bib.text LIKE '%recording%' OR bib.text LIKE '%film%')
@anarchivist
anarchivist / gist:263275
Created December 24, 2009 17:23
UUID Computed Field for Drupal
<?php
/* Autopopulates a Drupal Computed Field [1] CCK field using the UUID module [2].
Requires the 6.x-1.x-dev version of the module UUID, with a specific patch [3].
It assumes that you only want to generate UUIDs once. It probably should be
abstracted into another CCK module, but I'm too lazy to do that at the moment.
[1] http://drupal.org/project/computed_field
[2] http://drupal.org/project/uuid
[3] http://drupal.org/node/502622#comment-1858190
*/
@anarchivist
anarchivist / gist:263276
Created December 24, 2009 17:27
Use Shrew with Computed Field module in Drupal to store/extract MARC data
<?php
/* Sample Computed Field/Shrew usage for Drupal. The Shrew module [1] uses the
Shrew [2] PHP library to interact with Innovative Interfaces online library
catalog systems.
[1] http://www.github.com/anarchivist/drupal-shrew
[2] http://www.github.com/anarchivist/shrew
*/
if (!$node->nid) {
@anarchivist
anarchivist / gist:263277
Created December 24, 2009 17:30
Programmatic file migration in Drupal for existing nodes over HTTP using CCK filefield and nodeapi
<?php
/* Similar to the CCK migration thing I posted before I found a peculiarity dealing with filefield and nodeapi - for some reason, it didn't actually update the filefield until I ran a separate node_save().. */
function archivalcollection_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
if ($op == 'presave') {
switch ($node->type) {
case 'archivalcollection':
if ((empty($node->field_arms_pdffile[0]['fid']) || $node->field_arms_pdffile[0]['fid'] == 0)
&& !empty($node->field_arms_amat_printfindingaid[0]['value'])) {
$pdfurl = $node->field_arms_amat_printfindingaid[0]['value'];
@anarchivist
anarchivist / gist:263279
Created December 24, 2009 17:36
Programmatic Drupal CCK node creation from CSV files using node_save()
<?php
/* The long and the short of it, for Drupal 6 - use content_insert(), which
should be fired anyway but isn't. See "node_save() with CCK fields" [1] for
more details. drupal_execute() is too robust for me - I just needed to import
a SQL Server table with 4500+ rows quickly. Requires parsecsv for PHP [2].
[1] http://drupal.org/node/218862#comment-726058
[2] http://code.google.com/p/parsecsv-for-php/
*/
@anarchivist
anarchivist / gist:263280
Created December 24, 2009 17:39
Autoassign default taxonomy terms in Drupal based on content type and CCK fields
<?php
/* This works similarly to the Taxonomy Defaults module [1] but has no UI.
This is for programmatic, backend stuff. It tests to see if somethings a
particular content type and then checks for the value of a given CCK field
to determine the appropriate term.
[1] http://drupal.org/project/taxonomy_defaults
*/
function custom_taxonomy_defaults_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
@anarchivist
anarchivist / gist:263281
Created December 24, 2009 17:44
Accessing Drupal's XMLRPC/Services API from Python
# probably ripped off from somewhere on drupal.org
# requires the services module
import xmlrpclib
s = xmlrpclib.ServerProxy('http://localhost/services/xmlrpc')
class DrupalNode:
def __init__(self, title, body, path, ntype='page', uid=1, username='mmatienzo'):
self.title = title
@anarchivist
anarchivist / mail2rss.pl
Created December 24, 2009 17:52
Modified mail2rss script, originally by ngerakines
#!/usr/pkg/bin/perl
# http://purl.org/net/matienzo/projects/mail2rss/
# based upon http://blog.socklabs.com/2006/03/07/email_feeds_with_procmail.html
# rewritten to create valid RSS 2.0
use strict;
use warnings;
use POSIX qw(strftime);
@anarchivist
anarchivist / gist-jquery.html
Created December 24, 2009 20:34
Add a list of recent Gists to any page using jQuery
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Gist/jQuery Demo</title>
<script src="http://www.google.com/jsapi"></script>
<script>
var ghusername = 'anarchivist';
function getgists(githubuser) {
@anarchivist
anarchivist / readme.md
Created December 25, 2009 07:17
Notes on installing Ubuntu Netbook Remix on a Samsung Go (N310)

Stuff done to/for netbook

  • install google chrome
  • install 3g card drivers in winxp
  • upgrade 3g card firmware
  • remove mcafee, msn
  • download ubuntu netbook remix ISO and pen drive utility
  • make bootable flash drive
  • change boot order - remove hard drive from boot list
  • test wifi, ethernet, camera (all work OK)