Skip to content

Instantly share code, notes, and snippets.

View ctfliblime's full-sized avatar

Clay Fouts ctfliblime

  • PTFS
  • Portland, Oregon
View GitHub Profile
BEGIN MESSAGE.
ecwGS6P3kqbIi0S tkhx2hxRAeRBjkc MX5qksUdOhJ2SiF uKD2147CcT4gZph
8VHPazkHf9EckSp pbEvD4StoSpTCKq 6Xr2MZHgg7H8hqg QeayyZE72JATKav
L8TyxC4geD8jF89 bh4hmGcAdMW2qWK ffzdqmJy2sle1L3 gsaQbg2SJXG4zdb
68jXA2RpbJMbFwJ i9AE9l2EOFVLPps 5KUz67tiSkCT.
END MESSAGE.
### Keybase proof
I hereby claim:
* I am ctfliblime on github.
* I am obelos (https://keybase.io/obelos) on keybase.
* I have a public key ASDHPNpyArqgJMtD5CcZvZsLqdjiC4sTb1yk0gpX9PR17Qo
To claim this, I am signing this object:
@ctfliblime
ctfliblime / gist:3997082
Created November 1, 2012 22:21
LibLime Koha Solr stats for 2012-10-31
LibLime Koha Solr stats for 2012-10-31
Searching:
- 37.4k total searches (average 1,558/hour)
- peak hour handled 3,660 (about 1/second)
- average request service time was 49ms
Index updates:
- 71.5k total document updates (average 3,578/hour)
- peak hour had 6,988 updates (just under 2/second)
@ctfliblime
ctfliblime / gist:2969326
Created June 21, 2012 23:58
Web API sketch
HTTP request headers indicate API version and representation format:
Accept: application/vnd.koha.liblime.com+json; version=0.01
Accept: application/vnd.koha.liblime.com+xml; version=0.01
Defaults to JSON and most recent API version.
POST /catsearch?query=asdf #Generates catalog search result set and returns HTTP 201 with Location set to search ID
GET /catsearch/12345 #Returns the result set, defaults e.g. start=0, count=20
@ctfliblime
ctfliblime / gist:2846252
Created May 31, 2012 21:01
Solr index schema
<?xml version="1.0" ?>
<schema name="VuFind Bibliographic Index" version="1.2">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="textFacet" class="solr.TextField" sortMissingLast="true" omitNorms="true">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<!-- strip trailing punctuation from facets: -->
<filter class="solr.PatternReplaceFilterFactory" pattern="(?&lt;!\b[A-Z])[.\s]*$" replacement="" replace="first"/>
</analyzer>
@ctfliblime
ctfliblime / gist:1314938
Created October 26, 2011 00:27
This is not the most efficient way, but it seems to work.
#!/usr/bin/env perl
use Koha;
use C4::Context;
use C4::Reserves;
use C4::Circulation;
use C4::Items;
my $dbh = C4::Context->dbh;
my $itemnumbers = $dbh->selectcol_arrayref(
@ctfliblime
ctfliblime / gist:1275289
Created October 10, 2011 13:14
This one will work on Perl 5.8 (and probably much earlier)
#!/usr/bin/env perl
use strict ;
use warnings;
use locale ;
my @table=(1,2,3,8,5,8,0,4) ;
my @places ;
# Max value
@ctfliblime
ctfliblime / gist:1274678
Created October 10, 2011 05:29
Writing Perl as Perl
#!/usr/bin/env perl
use 5.014;
my @table=(1,2,3,8,5,8,0,4);
my $max = pop [sort @table];
my @places;
while (my ($index, $value) = (each @table)) {
push @places, $index if $value == $max;
@ctfliblime
ctfliblime / gist:1235618
Created September 22, 2011 18:42
Why do these hashes have different contents?
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dumper;
sub return_void {
return;
}
@ctfliblime
ctfliblime / gist:1211547
Created September 12, 2011 15:28
How to get this exception to percolate all the way up to the Plack middleware?
sub reserve_GET : Args(1) {
my ($self, $c, @args) = @_;
try {
my $reserve = Koha::Model::Reserve->new(reservenumber => $args[0])->load;
$self->status_ok($c, entity=>as_tree($reserve));
}
catch {
if (/^No such Koha::/) {
HTTP::Exception::404->throw;