Skip to content

Instantly share code, notes, and snippets.

View CliffordAnderson's full-sized avatar

Clifford Anderson CliffordAnderson

View GitHub Profile
@fordmadox
fordmadox / stage-directions.xq
Last active August 29, 2015 14:02
updated to output well-formed XML, rather than just an XML fragment; also, the return clause in the previous query output all of the stage elements, not the filtered list
declare namespace tei = "http://www.tei-c.org/ns/1.0";
(:
for each person, show stage directions involving that
person
:)
<people-plus-stage-directions>
{
for $person in //tei:person
(: using a map isn't required here, I don't think :)
xquery version "3.0";
declare namespace mdc = "http://mdc";
declare function mdc:add-check-digit-to-partial-barcode ($partial-barcode as xs:string) as xs:string {
(: the next two variables compute the Codabar barcode sum for 14-digit library barcodes according to the Luhn algorithm:)
let $barcode-sum :=
(: add up the even sequence :)
sum(string-to-codepoints($partial-barcode)[position() mod 2 eq 0] ! xs:integer(codepoints-to-string(.)))
+
(: add up the odd sequence :)
<!-- a schema for my postcard, with some commented-out stuff for other possibilities -->
<!-- ?. *, + act the same as quantiifers in regex -->
<!-- file extension has an extra .xml on the end to get github to color-code properly -->
element postcard {
<!-- attribute example
element date {
attribute iso-date { xsd:gYear }?,
text
},-->
element sender { text },
<postcard>
<unitdate>
<date type="single">Oct. 13</date>
</unitdate>
<location>Küsnacht</location>
<body>
<salutation>My dear Jelliffe,</salutation>
<p>It is nice to hear of you again after many years.</p>
<p>I just want to tell you that I see no point in sending my papers to your journal.
You surely know that I am a mystic according to American standards. So I think it will
@joewiz
joewiz / clean-excel-table.xq
Last active August 29, 2015 14:22 — forked from CliffordAnderson/build-ead.xqy
@CliffordAnderson's clean-excel-table.xqy, adapted for use with eXist 3.0 (develop branch)
xquery version "3.1";
declare namespace html="http://www.w3.org/TR/REC-html40"; (: the version of HTML used by the URL below :)
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; (: use XQuery 3.1's JSON serialization :)
import module namespace http="http://expath.org/ns/http-client"; (: @see http://expath.org/spec/http-client :)
declare option output:method "json";
declare option output:media-type "application/json";

October 28, 2014

  • Matt Perkins or maybe Calvin Bottoms: Word time
  • Josh Bush - show-and-tell: PewPew, a game written in Elm
  • Bryan Hunter - show-and-tell of Elixir's DocTest
  • Project Rosalind dojo

January 27, 2015

  • Dave Nolan - A first look at Nim and how to approach it functionally
= Network analysis with Neo4j
:neo4j-version: 2.1.0
:author: Suellen Stringer-Hye
:twitter: @suellenshye
:tags: domain:education, use-case:network analysis
@joewiz
joewiz / collection.xconf.xml
Created April 7, 2012 19:33
My XQuery snippets
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index>
<!-- Old full text index configuration. Deprecated. -->
<fulltext default="none" attributes="false"/>
<!-- New full text index based on Lucene -->
<lucene>
<text qname="SPEECH">
<ignore qname="SPEAKER"/>
</text>
@cpistrang
cpistrang / Charlottenburg_Project_1947.geojson
Last active March 1, 2017 22:29
Chris Pistrang and Ari Bradshaw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jnsprnw
jnsprnw / berlin.csv
Last active August 15, 2017 19:23
Wikidata
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 3 columns, instead of 2. in line 6.
attribute,identifier,value
"highest point",P610,"Arkenberge (Q19259618) ()"
"topic's main Wikimedia portal",P1151,"Portal:Berlin (Q3248436) ()"
"instance of",P31,"seat of government (Q1901835) ();metropolis (Q200250) ();federal capital (Q257391) (+1990-10-03T00:00:00Z);big city (Q1549591) ();state of Germany (Q1221156) ();municipality of Germany (Q262166) ();city with millions of inhabitants (Q1637706) ();city-state (Q133442) ();integrated municipality (Q1307779) ();city (Q515) ();Einheitsgemeinde of Germany (Q15974307) ()"
"contains administrative territorial entity",P150,"Mitte (Q163966) ();Friedrichshain-Kreuzberg (Q158893) ();Pankow (Q163012) ();Charlottenburg-Wilmersdorf (Q158095) ();Spandau (Q158083) ();Steglitz-Zehlendorf (Q158064) ();Tempelhof-Schöneberg (Q158106) ();Neukölln (Q4071168) ();Treptow-Köpenick (Q158089) ();Marzahn-Hellersdorf (Q119284) ();Lichtenberg (Q329609) ();Reinickendorf (Q158876) ()"
"legislative body",P194,"Abgeordnetenhaus of Berlin (Q640859) ()"
"highest judicial authority",P209