Skip to content

Instantly share code, notes, and snippets.

View dscape's full-sized avatar

Nuno Job dscape

View GitHub Profile
function XHConn()
{
var xmlhttp, bComplete = false;
try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { xmlhttp = new XMLHttpRequest(); }
catch (e) { xmlhttp = false; }}}
if (!xmlhttp) return null;
this.connect = function(sURL, sMethod, sVars, fnDone)
{
@dscape
dscape / 01-cts:highlight.xq
Created March 24, 2010 23:42
Introduction to Alerting
let $doc :=
<root>
<a> It starts with hello and ends with goodbye. </a>
</root>
return
cts:highlight( $doc, cts:and-query(("hello", "goodbye")),
if (cts:word-query-text($cts:queries) eq "hello")
then (<font color="blue">{$cts:text}</font>)
else (<font color="red">{$cts:text}</font>))
@dscape
dscape / 01-refactoring-search.xq
Created March 25, 2010 13:06
Search, Updates and Range Indexes
declare namespace ts="http://marklogic.com/MLU/top-songs";
declare function local:build-query($text as xs:string) {
cts:or-query((
cts:word-query($text, (), 1),
cts:element-word-query(
xs:QName("ts:title"), $text, (), 2 ))) } ;
declare function local:search-rating($song) {
cts:score($song)
@dscape
dscape / create-xml-from-list-of-xpath-value-pairs.xqy
Created April 13, 2010 06:01
Generate XML out of XPath Expressions
import module namespace mem = "http://xqdev.com/in-mem-update"
at "/MarkLogic/appservices/utils/in-mem-update.xqy" ;
declare variable $DEBUG as xs:boolean := fn:true() ;
(: hack because the inmem update looses the right focus
: if you have an idea on a workaround, please let me know
:)
declare variable $redo as xs:string* := ();
(: functional ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::)
@dscape
dscape / 01-rewrite.xqy
Created April 14, 2010 23:22
Exploring rest in marklogic
(:
: start by pointing the url-rewriter to 'rewrite.xqy'
:)
xdmp:get-request-path()
@dscape
dscape / 01-install-redis.sh
Created April 21, 2010 19:23
Using Redis with MarkLogic Server
cd ~/Desktop
wget http://redis.googlecode.com/files/redis-1.2.6.tar.gz
tar -xvf redis-1.2.6.tar.gz
cd redis-1.2.6/
make
./redis-server
## you need port 6379 open. Possible to change.
@dscape
dscape / 00-readme.md
Created April 26, 2010 18:55
We will begin with a review of ApplicationBuilder and the SearchAPI. We will look at what functionality is provided out of the box with these tools, and how you can extend them to suit the needs of your project. In the class we will load sample documents,

Extending Application Builder

Abstract

We will begin with a review of ApplicationBuilder and the SearchAPI. We will look at what functionality is provided out of the box with these tools, and how you can extend them to suit the needs of your project. In the class we will load sample documents, build an application, then add features to the application by extending the code that is generated by ApplicationBuilder. By the end of the afternoon session you will have used our best practices for extending the functionality of this powerful tool.

Application Builder

Materials

  • Tutorial (Hard-copy)
@dscape
dscape / ubuntu-davfs-and-marklogic-server.sh
Created April 30, 2010 01:01
Using MarkLogic WebDAV Server in Ubuntu
## pre-requisite: working webdav server on port 9567
sudo apt-get install davfs2
sudo mkdir /media/mls-twitter
sudo mount -t davfs http://localhost:9567 /media/mls-twitter
@dscape
dscape / export-twitter-favorites-to-delicious.xqy
Created April 30, 2010 07:04
Export your twitter favorites links (includes redirects, page titles and suggested tags) to delicious with #MarkLogic
xquery version "1.0-ml";
declare variable $twitter-username as xs:string external;
declare variable $delicious-username as xs:string external;
declare variable $delicious-password as xs:string external;
declare function local:get-favorite-page($username,$page) {
xdmp:http-get(
fn:concat(
"http://api.twitter.com/1/favorites/",$username,".xml?page=",$page))[2] };

Lost in Recursion - Generate XML from name value pairs (HTML Form)

Meta

  • Pre-requisites

MarkLogic Server 4.2. Knowing your way around http://localhost:8001 or a working cq instalation

  • Difficulty: Medium
  • Keywords: XML, XForms, HTML, Forms, XQuery, Functional, Map, Fold, High Order Functions, Application Buider, Search, git, github, XQuery 1.1

Nuno Job