Skip to content

Instantly share code, notes, and snippets.

require 'rom-repository'
require 'rom-sql'
db = ROM.container(:sql, 'sqlite::///tmp/foo.sqlite') do |c|
c.default.create_table(:users) do
primary_key :id
column :name, String, null: false
end
end
@gioele
gioele / odd2odd.xsl
Last active July 22, 2016 18:51
additional remarks in odd2odd
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:s="http://www.ascc.net/xml/schematron"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
xmlns:rng="http://relaxng.org/ns/structure/1.0"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:teix="http://www.tei-c.org/ns/Examples"
@gioele
gioele / backup-exist.sh
Last active July 21, 2016 14:00
Backup script for eXist-db
#!/usr/bin/env bash
set -e
set -u
#USER="" # set username
#PASS="" # set password
#HOST="" # set host, eg. localhost:8080
COLLECTION_BASE_URL="http://$USER:$PASS@$HOST/exist/rest/db"
@gioele
gioele / mom-diff-steps.md
Last active August 29, 2015 14:20
Diff for MOM

First approximation

Preparatory steps

  1. serialize the base document (version 0) in the variable String ver0_string;
  2. serialize the modified document (version 1) in the variable String ver1_string;
  3. create a ByteArrayOutputStream diff_result object.

The call

@gioele
gioele / add_child_ns.rb
Created November 25, 2014 18:42
Nokogiri `add_child` does not copy namespaces
#!/usr/bin/env ruby
require 'nokogiri'
src =<<EOD
<wrapper xmlns="ns" xmlns:extra="extra">
<record xml:id="r1">
<field>aaa</field>
<field extra:type="second">bbb</field>
</record>
@gioele
gioele / match-var.rs
Created August 18, 2014 13:57
matches in rust with variable values
impl<'a> FromBase64 for &'a [u8] {
fn from_base64(&self, config: Config) -> Result<Vec<u8>, FromBase64Error> {
let mut r = Vec::new();
let mut buf: u32 = 0;
let mut modulus = 0i;
let chars = match config.char_set {
Standard => STANDARD_CHARS,
UrlSafe => URLSAFE_CHARS,
XmlNmtoken => XML_NMTOKEN_CHARS,
@gioele
gioele / TEST-Archiv-EAD.xml
Created August 12, 2014 11:43
TEST-Archiv in EAD format
<!DOCTYPE ead PUBLIC "+//ISBN 1-931666-00-8//DTD ead.dtd (Encoded Archival Description (EAD) Version 2002)//EN" "http://lcweb2.loc.gov/xmlcommon/dtds/ead2002/ead.dtd">
<ead>
<eadheader langencoding="iso639-2b"
countryencoding="iso3166-1"
dateencoding="iso8601"
repositoryencoding="iso15511"
scriptencoding="iso15924"
relatedencoding="DC">
<eadid identifier="TEST-EAD; erste Akzession"
url="http://localhost:2234/atom-testing/index.php/somethinglikethis"
@gioele
gioele / annex-direct.log
Last active August 29, 2015 14:04
git-annex whereis does not work in direct mode
+ set -e
+ set -u
+ export LC_ALL=C
+ direct=true
+ h=localhost
+ dr=/tmp/annex
+ sync=sync -c annex.alwayscommit=true
+ chmod a+rwx -R pc1 pc2
+ rm -Rf pc1 pc2
+ ssh localhost chmod a+rwx -R /tmp/annex/Docs.git
@gioele
gioele / sync-doesnot-push.sh
Created July 11, 2014 09:09
git-annex sync does not push
#!/bin/sh -x
set -e ; set -u
export LC_ALL=C
d=$(pwd)
# cleanup
chmod a+rwx -R REPO pc1 || true
rm -Rf REPO pc1
@gioele
gioele / central-git-annex.sh
Last active August 29, 2015 14:03
git-annex repositories not seen when using sync without alwayscommit
#!/bin/sh -x
set -e ; set -u
export LC_ALL=C
h=${h:-localhost}
dr="/tmp/annex"
chmod a+rwx -R pc1 pc2 || true
rm -Rf pc1 pc2