Skip to content

Instantly share code, notes, and snippets.

View eedeebee's full-sized avatar

Eric Bloch eedeebee

  • Hillsborough, CA
View GitHub Profile
xquery version "1.0-ml";
declare variable $deck-counter := map:map();
declare variable $deck := map:map();
declare function local:get-card($num) {
let $card := map:get($deck-counter, xs:string($num))
let $_ := xdmp:log(fn:concat("card: ", $card, " $num: ", $num), "debug")
return
(: call recursively with another rand number, if the
@eedeebee
eedeebee / gist:778998
Created January 14, 2011 01:42
Snippet #1 in Adding Maps to an AppBuilder application
declare function app:get-content()
{
let $view := $config:CONTEXT/*:view
return
if ($view eq "search")
then (
xdmp:apply($config:toolbar),
if (data($config:RESPONSE/@total) eq 0)
then xdmp:apply($config:error-message,
concat("Your search for ",$config:CONTEXT/*:q,
@eedeebee
eedeebee / get-points.xqy
Created January 14, 2011 01:44
Snippet #3 from Adding Maps to an AppBuilder application
xquery version "1.0-ml";
<locations>
{
let $pins := cts:search(/pin, cts:element-query(xs:QName("location"), cts:and-query(())))
for $pin in $pins
where fn:exists($pin/location/lat)
return
<location>
<url>/detail{fn:base-uri($pin)}</url>
<name>{$pin/name/text()}</name>
@eedeebee
eedeebee / maps.js
Created January 14, 2011 01:45
Snippet #3 from Adding Maps to an AppBuilder application
function initialize() {
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
myOptions);
@eedeebee
eedeebee / gist:779005
Created January 14, 2011 01:47
Snippet #4 from Adding Maps to an AppBuilder application
We couldn’t find that file to show.
<dev:lounge>
<beverages>
<coffee brew="strong" />
<soda flavor="orange"/>
</beverages>
<lab code="xquery" speed="awesome"/>
</dev:lounge>
@eedeebee
eedeebee / sample-function-decl.xqy
Created July 1, 2011 22:01
XQuery Coding Guidlines: Rule 1
declare function my:function(
$a as xs:string,
$b as element(my:options)
) as empty-sequence()
{
(: body of function :)
};
@eedeebee
eedeebee / 4a-one-line-if-then-else.xqy
Created July 1, 2011 22:14
XQuery Coding Guidelines: Rule 4
(: one line if/then/else :)
if ($condition) then $action else ()
@eedeebee
eedeebee / vis-widgets-1-.js
Created August 27, 2012 16:56
MarkLogic Visualization Widgets Snippets
$(document).ready(function() {
var config = {
searchEndpoint: "search.php",
valueEndpoint: "values.php"
}
ML.controller.init(config);
var options = {
constraint: "decade",
title: "Awards by decade",
@eedeebee
eedeebee / mlcp-example-1.sh
Last active September 20, 2016 08:11
MarkLogic Content Pump Examples
mlcp.sh import \
-host localhost \
-port 8006 \
-username user \
-password ******* \ 
-input_file_path /data/latest