Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View leftclickben's full-sized avatar

Ben New leftclickben

View GitHub Profile
@leftclickben
leftclickben / strip-referer
Created December 7, 2015 07:05
strip-referer
#!/bin/bash
# http://nigel.mcnie.name/blog/removing-the-referer-part-of-php-error-messagse-from-apache-logs
perl -pe 's/\s+\[\:error\]\s+\[pid\s+\d+\]\s+\[client\s+.*?\]//; s/, referer:.*//'
@leftclickben
leftclickben / describeScreen.php
Last active August 29, 2015 14:24
(CollectiveAccess) Retrieve CSV of placements for a given screen, with labels
#!/usr/bin/env php
<?php
$screen = 35; // modify as required
$locale = 'en_AU';
$pdo = new PDO('mysql:host=wamcmisdb01-staging;dbname=cmis', 'cmis', 'uhkdv5Uwhkk7pmv');
$placements = $pdo->query('select * from ca_editor_ui_bundle_placements where screen_id = ' . $screen . ' order by rank asc')->fetchAll();
foreach ($placements as $placement) {
$settings = unserialize(base64_decode($placement['settings']));
@leftclickben
leftclickben / nestedRenameSpacesToUnderscores
Last active August 29, 2015 14:09
Rename whitespace in files to underscores, with any level of nesting
maxdepth=`find . -printf '%d\\n' | sort -n | tail -1` && for depth in `seq 1 $maxdepth`; do find -mindepth 1 -maxdepth $depth -exec bash -c 'f=`echo "{}" | sed -r s:\\\s+:_:g` ; if [ "$f" != "{}" ]; then mv "{}" "$f"; fi' \; ; done
@leftclickben
leftclickben / cleanup-providence-database-after-relationship-generator-integration-test.sql
Created May 14, 2014 04:17
cleanup-providence-database-after-relationship-generator-integration-test.sql
-- Cleans up any data that might be remnant after a run of the RelationshipGeneratorPluginIntegrationTest,
-- particularly if the run fails for some reason, it might not execute its tearDown() and can leave remnant
-- data in the database.
-- NOTE YOU WILL NEED TO MODIFY SOME OF THE HARDCODED VALUES IN HERE TO SUIT YOUR CURRENT DATABASE
-- Alternatively this could probably be improved to use more of the "code like '%...%'" and less of the "id > X" style
delete from ca.ca_attribute_values where value_id > 14;
delete from ca.ca_attributes where table_num = 57 and element_id = 70 and row_id > 46;