Skip to content

Instantly share code, notes, and snippets.

View dscape's full-sized avatar

Nuno Job dscape

View GitHub Profile
@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] };
let $l := ('a','b','c','d','e','f','g','h')
let $c := count($l)
let $n := 4
let $m := if ($n > $c) then $c else $n
let $step := ceiling( $c div $m )
return (
concat("l=", string-join($l, ", "), " c=", $c, " n=", $n, " step=", $step),
for $i in (1 to $m)
let $s := xs:integer( 1 + ( ( $i - 1 ) * $step ) )
let $f := xs:integer( $s + $step - 1 )
(: better approach as allows you to use xdmp:estimate :)
declare function local:partition-range($list-size, $nr-partitions) {
let $m := if ($nr-partitions > $list-size)
then $list-size
else $nr-partitions,
$step := ceiling( $list-size div $m )
return
for $i in (1 to $m)
let $s := xs:integer( 1 + ( ( $i - 1 ) * $step ) )
let $f := xs:integer( $s + $step - 1 )
[user]
name = Nuno Job
email = nunojobpinto@gmail.com
[color]
ui = auto
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
@dscape
dscape / .bashrc
Created September 16, 2010 01:03
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
<?xml version="1.0" encoding="UTF-8"?><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book><?xml version="1.0" encoding="UTF-8"?><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book><?xml version="1.0" encoding="UTF-8"?><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Computer</genre><price>44.95</price><publish_date>2000-10-01</publish_date><description>An in-depth look at creating applications with XML.</description></book><?xml version="1.0" encoding="UTF-8"?><book id="bk101"><author>Gambardella, Matthew</author><title>XML Developer's Guide</title><genre>Comp