Skip to content

Instantly share code, notes, and snippets.

View phochste's full-sized avatar

Patrick Hochstenbach phochste

View GitHub Profile
@phochste
phochste / gist:4169957
Created November 29, 2012 15:53
Store MARC records in a MongoDB database
use Catmandu::Importer::MARC;
my $importer = Catmandu::Importer::MARC->new(file => "/foo/bar.marc", type=> "USMARC");
my $store = Catmandu::Store::MongoDB->new(database_name => 'test');
$store->bag->add_many($importer);
Hello Gwen
How are you!! d sfkhushf s fksuhf ksuhfsalkufhusfkuhkhweuh fkudhauhf ahsdkufs f
slfsdif jslfijsfi jslfijsfijosjfs;ifsij s
@phochste
phochste / gist:9d4f2fea85b41de7f563
Created June 17, 2014 15:08
Catmandu ElasticSearch error handler
use Catmandu;
use Data::Dumper;
my $importer = Catmandu->importer('Mock');
# Create a store with a vey strict schema that always produces errors ...
my $store = Catmandu->store('ElasticSearch',
index_name => 'test2',
bags => { data => {
use Catmandu;
my $var = '';
my $exporter = Catmandu->exporter('JSON', file => \$var);
$exporter->add({ 'aaargh' => 'doedoedoe' });
$exporter->commit;
print $var;
#!/usr/bin/env node
/*
* Install: npm install n3
* Usage: cat gigantic.ttl | tutle2ntriples
* Usage: tutle2ntriples gigantic.ttl
*
* See also: https://github.com/RubenVerborgh/N3.js
*/
var file = undefined;
if (process.argv.length == 2) {
@phochste
phochste / import_viaf.pl
Created June 3, 2015 09:34
Match authors against VIAF using Catmandu and Linked Data Fragments
#!/usr/bin/env perl
#
# Match authors against VIAF
#
# License: http://dev.perl.org/licenses/artistic.html
#
# Author: Patrick Hochstenbach <[email protected]>
#
# Apr 2015
$|++;
{"coord":{"lon":3.72,"lat":51.05},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"cmc stations","main":{"temp":288.524,"pressure":1034.03,"humidity":87,"temp_min":288.524,"temp_max":288.524,"sea_level":1036.43,"grnd_level":1034.03},"wind":{"speed":6.93,"deg":242.008},"rain":{"3h":0.2025},"clouds":{"all":92},"dt":1447164399,"sys":{"message":0.0031,"country":"BE","sunrise":1447138397,"sunset":1447171449},"id":2797656,"name":"Gent","cod":200}
{"coord":{"lon":3.72,"lat":51.05},"sys":{"type":3,"id":4839,"message":0.0349,"country":"BE","sunrise":1417159365,"sunset":1417189422},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10d"}],"base":"cmc stations","main":{"temp":281.15,"pressure":1006,"humidity":87,"temp_min":281.15,"temp_max":281.15},"wind":{"speed":3.6,"deg":100},"rain":{"3h":0.5},"clouds":{"all":56},"dt":1417166878,"id":2797656,"name":"Gent","cod":200}
#
# Usage:
# marc_marc('852a',holding.$append)
# holding(-logfile => '/mnt/scratch/lludss/holding_error.txt')
#
package Catmandu::Fix::holding;
use strict;
use Catmandu::Util qw(:io is_string);
use POSIX qw(strftime);
use Data::Dumper;
{
"coord": {
"lon": 139.76,
"lat": 35.68
},
"weather": Array[1][
{
"id": 802,
"main": "Clouds",
"description": "scattered clouds",