Skip to content

Instantly share code, notes, and snippets.

View dscape's full-sized avatar

Nuno Job dscape

View GitHub Profile
@dscape
dscape / coocurrence.xqy
Created March 23, 2011 14:29
Sample Co-occurence Index
for $c in cts:element-value-co-occurrences(
fn:QName("http://marklogic.com/MLU/top-songs", "genre"),
fn:QName("http://marklogic.com/MLU/top-songs", "artist")
, ("frequency-order",
"collation-1=http://marklogic.com/collation/en/S1/AS/T00BB",
"collation-2=http://marklogic.com/collation/en/S1/AS/T00BB"), cts:and-query(()))
return <i c="{cts:frequency($c)}">{
for $v in $c
return (attribute fst {fn:string($v//*:value[1])},
attribute snd {fn:string($v//*:value[2])})}</i>
@dscape
dscape / The-Innovators-Dilemma-Summary.md
Created February 22, 2011 21:02
Notes on The Innovator’s Dilemma: When New Technologies Cause Great Firms to Fail

Notes on The Innovator’s Dilemma: When New Technologies Cause Great Firms to Fail

  • Book by: Clayton M. Christensen, Cambridge, Massachusetts: Harvard Business School Press, 1997
  • Prepared by: B.B. McBreen. See [PDF][1] (more readable but it's not plain text)

Summary

  1. Market progress is separate from technology progress. Customers do not always know what they need.
  2. Innovation requires resource allocation which is extraordinarily difficult for disruptive technologies.
  3. Disruptive technology needs a new market. Old customers are less relevant. Disruptive technology is a marketing problem, not a technological one.

SAUCE

heat up a little bit of olive oil with chopped onions. (almost all portuguese recipes start like this). when onions are golden add tomatoes (many) add 2 bay leaves, beer, one chili pepper (chopped for extra spicyness), a little meat or sausage for meat flavour, a knorr thingy (either chicken or beef according to what your cooking in the sandwich), and a little smell of a strong drink like whiskey, brandy, port or one you would think would fit. all sauce recipes are a bit different, because some people like different flavours, stronger or less strong, spicy or not so spicy. some like to add a little bit of seafood sauce, wich gives a slightly different taste but works fine for some people (im one of them) :P you have to look out for it not to be to liquid. thats where you could add the cornstarsh to mke it thicker. This provides a quick fix for not getting it right i suppose in terms of thickness.

PER SANDWICH

<?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
@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
[user]
name = Nuno Job
email = [email protected]
[color]
ui = auto
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
(: 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 )
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 )

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

@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] };