Skip to content

Instantly share code, notes, and snippets.

$view = new view();
$view->name = 'test_solr';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'islandora_solr';
$view->human_name = 'test solr';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
@mjordan
mjordan / gist:9575829
Last active August 29, 2015 13:57
Number of items in FedoraCommons with average time to download a datastream, calculcated by downloading 100 random datastreams from all objects
Number of objects,average time to download datastream
9879,0.22425223655914
45096,0.079587544444444
77467,0.13624490322581
108640,0.088355711340206
133895,0.10383455102041
159749,0.091124947368421
185478,0.15220051546392
211806,0.14662007368421
235972,0.15356125773196
@mjordan
mjordan / gist:4513687555ac54ee4b10
Last active August 29, 2015 14:07
Walks a directory and generates checksums
import os
# Supports md5, sha1, sha256, and sha512
import hashlib
start_dir = '/home/mark/Pictures'
def generate_checksum_for_file(source_file_path, algorithm='md5'):
"""Generate and return a checksum for the file at source_file_path
using the specified algorithm.
"""
<html>
<body>
<head><title>The document’s title</title>
</head>
<h1>A heading</h1>
<table>
<tr><td>120</td><td>389</td></tr>
</table>
<p>Some text</p>
</body>
@mjordan
mjordan / gist:92e9eb263ee1071d8a23
Created March 26, 2015 22:42
Islandora content model to OBJ file extension map
$content_model_to_extension_map = array(
"islandora:sp-audioCModel" => array("mp3", "mp4a", "m4a", "oga", "ogg", "flac", "wav"),
"islandora:sp_basic_image" => array("jpeg", "jpe", "jpeg", "gif", "png"),
"islandora:sp_large_image_cmodel" => array("tiff", "tif", "jp2"),
"islandora:sp_pdf" => array("pdf"),
"islandora:sp_videoCModel" => array("mp4", "m4v", "mkv", "mpeg", "mpe","mpg", "qt", "mov", "ogv"),
"islandora:sp_web_archive" => array("warc"),
);
@mjordan
mjordan / foxml_archive.xml
Last active August 29, 2015 14:24
FOXML export in archive format for the standard Islandora Basic Image Collection
<?xml version="1.0" encoding="UTF-8"?>
<foxml:digitalObject VERSION="1.1" PID="islandora:sp_basic_image_collection"
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
<foxml:objectProperties>
<foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE="Basic Image Collection"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2015-06-30T22:02:43.975Z"/>
@mjordan
mjordan / foxml_migrate.xml
Created July 11, 2015 23:27
FOXML export in migrate format for the standard Islandora Basic Image Collection
<?xml version="1.0" encoding="UTF-8"?>
<foxml:digitalObject VERSION="1.1" PID="islandora:sp_basic_image_collection"
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
<foxml:objectProperties>
<foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE="Basic Image Collection"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2015-06-30T22:02:43.975Z"/>
@mjordan
mjordan / gist:4ae7724d5b3ffe38207f
Created July 19, 2015 14:39
Islandora Dev 101 Exercise 3: Two sample implementations
/**
* Implements hook_islandora_datastream_access().
*/
function islandora_dev101_islandora_datastream_access($op, $object, $user) {
if ($op == 'view fedora repository objects') {
foreach ($object as $ds) {
if ($ds->id == 'DC') {
// file_put_contents('/tmp/myfile.txt', $ds->content);
dd($ds->content);
}
@mjordan
mjordan / gist:99fac083970ea43528c6
Created July 19, 2015 14:49
Islandora Dev 101 Exercise 1: Sample implementation
/**
* Implements hook_islandora_object_modified().
*/
function islandora_dev101_islandora_object_modified(AbstractObject $islandora_object) {
drupal_set_message("Owner: " . $islandora_object->owner);
// Bonus answer.
// $message = variable_get('islandora_dev101_message', 'This just happened: ');
// drupal_set_message($message . ': ' . $islandora_object->owner);
}
@mjordan
mjordan / d6to7_cck_textfield_length_checker.php
Created August 7, 2013 16:49
Script to find Drupal 6 CCK text fields that are longer than 255 characters. Very useful in preparing to upgrade a site to Drupal 7.
<?php
/**
* d6to7_cck_textfield_length_checker.php, a script to find Drupal 6
* CCK text fields that are longer than 255 characters.
*
* Written by Mark Jordan, mjordan@sfu.ca and released into the
* public domain.
*
* Upgrading to Drupal 7 from Drupal 6 instances that use CCK can