Skip to content

Instantly share code, notes, and snippets.

View erochest's full-sized avatar

Eric Rochester erochest

View GitHub Profile
@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
...
@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 / 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 / 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 / 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 / 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) {
#!/usr/bin/env python
import re
import sys
def fix_pre(match):
buffer = ['\n[sourcecode']
if match.group(1) and match.group(2):
buffer.append('{0}"{1}"'.format(match.group(1), match.group(2)))
@erochest
erochest / gist:3491062
Created August 27, 2012 18:21
The unnatural thing I did to get homebrew to compile MacVim (& vim) against Python 2.7 on Mac 10.6
cd /System/Library/Frameworks/Python.frameworks/Versions
sudo mv Current Current26
sudo ln -s /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7 Current
@erochest
erochest / fix.js
Created August 28, 2012 15:17
Wandering OL points
var _this = this;
var Map = OpenLayers.Map;
if (jQuery.browser.webkit) {
Map = OpenLayers.Class(OpenLayers.Map, {
updateSize: function() {
OpenLayers.Map.prototype.updateSize.apply(this, arguments);
var mapHeight = _this.element.height(),
mapWidth = _this.element.width();
_this.element.find('svg').each(function (i, el) {
jQuery(el).height(mapHeight).width(mapWidth);
@erochest
erochest / exitscript.bash
Created September 5, 2012 13:59
Combined exit codes
#!/bin/bash
./sub_exit.bash
ec1=$?
./sub_exit.bash
ec2=$?
[[ "$ec1" -eq "0" && "$ec2" -eq "0" ]]