Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
@erochest
erochest / multiple_creators.php
Created July 31, 2012 18:15 — forked from jeremyboggs/multiple_creators.php
Changes how creators are listed depending on their numbers
<?php
/**
* One Creator: "Jane Doe"
* Two creators: "Jane Doe and John Doe"
* Three creators: "Jane Doe, John Doe, and Jim Doe"
* Four or more: "Jane Doe et al."
*/
if ($creators) {
switch (count($creators) {
@erochest
erochest / multiple_creators.php
Created July 31, 2012 18:15 — forked from jeremyboggs/multiple_creators.php
Changes how creators are listed depending on their numbers
<?php
/**
* One Creator: "Jane Doe"
* Two creators: "Jane Doe and John Doe"
* Three creators: "Jane Doe, John Doe, and Jim Doe"
* Four or more: "Jane Doe et al."
*/
if ($creators) {
@erochest
erochest / gist:3006751
Created June 27, 2012 20:42
What does this do?
SELECT `e`.*, `dt`.`name` AS `data_type_name`, `es`.`name` AS `set_name`, `rty`.`name` AS `record_type_name` FROM `hotchkiss_elements` AS `e`
LEFT JOIN `hotchkiss_data_types` AS `dt` ON dt.id = e.data_type_id
LEFT JOIN `hotchkiss_element_sets` AS `es` ON es.id = e.element_set_id
INNER JOIN `hotchkiss_record_types` AS `rty` ON rty.id = e.record_type_id WHERE (rty.name = 'Item' OR rty.name = "All") ORDER BY `e`.`order` ASC, `e`.`element_set_id` ASC
@erochest
erochest / insert-facet.sql
Created June 8, 2012 18:41
SQL to add a facet to Omeka Solr Search Plugin
SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
SET @set_name := 'Dublin Core';
SET @element_name := 'Coverage';
SET @label := 'Greeting';
SET @facet := 1;
SET @displayed := 1;
INSERT INTO omeka_solr_search_facets
@erochest
erochest / torefactor.php
Created June 6, 2012 13:58
Snippet to refactor
public static function createFacetSubForm($subform)
{
$output = '';
$facetId = $subform->getElement('facetid');
$label = $subform->getElement('label');
$options = $subform->getElement('options');
$id = preg_replace('/\W+/', '_', $label->getFullyQualifiedName());
$output .= '<tr>';
@erochest
erochest / original.clj
Created May 7, 2012 16:40
Versions of m
(defn m
"Measures the number of consonant sequences between
the start of word and position j. If c is a consonant
sequence and v a vowel sequence, and <...> indicates
arbitrary presence,
<c><v> -> 0
<c>vc<v> -> 1
<c>vcvc<v> -> 2
<c>vcvcvc<v> -> 3
...
user=> (defn test-m [stemmer] [stemmer (m stemmer) (m2 stemmer)])
#'user/test-m
user=> (-> (make-stemmer "ba") test-m)
[{:word [\b \a], :index 1} 0 0]
user=> (-> (make-stemmer "bava") test-m)
[{:word [\b \a \v \a], :index 3} 1 0]
user=> (-> (make-stemmer "baba") test-m)
[{:word [\b \a \b \a], :index 3} 1 0]
user=> (-> (make-stemmer "bababa") test-m)
[Exhibits]
id-column=eid
result-type=Exhibits
table={$prefix}_exhibits
flag=public
tagged=yes
[Exhibits.title]
[Exhibits.description]
@erochest
erochest / broken.php
Created April 12, 2012 15:57
What's wrong with this?
protected function _addFacetMappings()
{
$sql = <<<SQL
INSERT INTO `{$this->_db->prefix}solr_search_facets`
(element_id, name, element_set_id, is_facet, is_displayed, is_sortable)
VALUES (?, ?, ?, ?, ?, ?);
SQL;
$stmt = $this->_db->prepare($sql);
// These get inserted fine.
@erochest
erochest / reset-solr
Created April 12, 2012 15:11 — forked from waynegraham/gist:2355797
Delete solr index with curl
curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'