Skip to content

Instantly share code, notes, and snippets.

View kurtcagle's full-sized avatar

Kurt Cagle kurtcagle

  • Semantical LLC
  • Bellevue, WA 98006
  • 07:42 (UTC -07:00)
View GitHub Profile
@kurtcagle
kurtcagle / x
Created October 22, 2008 21:18
var $ = jQuery;
CmdUtils.CreateCommand({
name:"macro",
author: { name: "Kurt Cagle", email: "kurt@oreilly.com"},
contributors: ["Kurt Cagle"],
license: "Apache License, v.2",
homepage: "http://www.xforms.org/xrx/?q=ubiquity",
description: "Performs regular expression replacements of web page content.",
help: "The macro verb takes the URL of a dictionary file (which can be set up as a default using the defaultURL property) and uses it to replace each regex term with its corresponding replacement value in either a web page (if no content is selected) or within a given selection (if one has been).",
var $ = jQuery;
CmdUtils.CreateCommand({
name:"macro",
author: { name: "Kurt Cagle", email: "kurt@oreilly.com"},
contributors: ["Kurt Cagle"],
license: "Apache License, v.2",
homepage: "http://www.xforms.org/xrx/?q=ubiquity",
description: "Performs regular expression replacements of web page content.",
help: "The macro verb takes the URL of a dictionary file (which can be set up as a default using the defaultURL property) and uses it to replace each regex term with its corresponding replacement value in either a web page (if no content is selected) or within a given selection (if one has been).",
for $item in $items/foo/bar where $item return
<foo>{$item}</foo>
select * where {
?s owl:sameAs ?subject.
?s ?p ?o
} order by ?p ?o limit 1000
@kurtcagle
kurtcagle / Annotations.js
Created June 9, 2015 05:10
Annotations.js (or Annotations.sjs for MarkLogic) is a script for providing basic annotation services.
var Annotations = {
set: function (fn,key,expr){
if (fn.annotation == null){
fn.annotation = {};
}
fn.annotation[key]=expr;
return this;
},
get: function(fn,key){
if (fn.annotation != null){
@prefix person: <http://semantical.co/ns/person/>
@prefix class: <http://semantical.co/ns/class/>
@prefix rdf: <http://semantical.co/ns/person/>
person:JaneDoe
rdf:type class:Person.
Yea
@kurtcagle
kurtcagle / cards.xqy
Last active August 29, 2015 14:24
Creating a deck of Cards in MarkLogic XQuery
declare module namespace cards = "http://semantical.co/ns/cards/";
import module namespace stack = "http://semantical.co/ns/stack/" at "stack.xqy";
declare function cards:new() as item() {
let $deck :=
for $suit in ("&hearts;","&clubs;","&spades;","&diams;")
for $spot in ("A",(2 to 10),"J","Q","K") return
$spot || $suit
let $shuffled-deck :=
for $item in $deck order by
@kurtcagle
kurtcagle / stack.xqy
Created July 12, 2015 21:43
A stack is an XQuery map-based structure.
module namespace stack = "http://optum.com/ns/stack/";
declare function stack:new($seq as item()*) as map:map {
map:new((map:entry("stack",$seq)))
};
declare function stack:push($stack as map:map,$item as item()) {
map:put($stack,"stack",($item,map:get($stack,"stack")))
};
@kurtcagle
kurtcagle / gist:55c223243cc42fd6c645
Last active August 29, 2015 14:25
Metaprogramming Gist 1
prefix person: <http: //semantic.co/ns/person></http:>
prefix personName: <http: //semantic.co/ns/personName></http:>
person:jane_doe
rdf:type class:Person;
rdfs:label "Jane Doe"^^xs:string;
.
@kurtcagle
kurtcagle / Cluster1.ttl
Last active November 24, 2015 05:38
Model of Simple Book Recommendation Engine
user:JaneDoe
rdf:type class:User;
rdfs:label "Jane Doe";
.
book:BooksOfFae
rdf:type class:Book;
rdfs:label "Books of Fae";
book:author author:KurtCagle;
.