Skip to content

Instantly share code, notes, and snippets.

Avatar

Eric Bloch eedeebee

  • Hillsborough, CA
View GitHub Profile
View tampermonkey_trello_list_num_cards_show
// ==UserScript==
// @name Trello Lists Show Num Cards
// @namespace http://use.i.E.your.homepage/
// @version 0.1
// @description enter something useful
// @match https://trello.com/b/*
// @copyright 2012+, You
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
// ==/UserScript==
setTimeout(function() {
@eedeebee
eedeebee / qbe-json-ex.java
Created Feb 1, 2014
MarkLogic Java API QBE for JSON
View qbe-json-ex.java
// create a search definition
StringHandle handle = new StringHandle(
"{ \"$query\": { \"plenary\": true } }"
).withFormat(Format.JSON);
RawQueryByExampleDefinition query = queryMgr.newRawQueryByExampleDefinition(handle);
// create a handle for the search results
StringHandle resultsHandle = new StringHandle().withFormat(Format.JSON);
@eedeebee
eedeebee / ex001.java
Created Feb 1, 2014
MarkLogic Java Tutorial Examples as of V7
View ex001.java
// Create a search definition
StringHandle handle = new StringHandle(
"<q:qbe xmlns:q=\"http://marklogic.com/appservices/querybyexample\">\n" +
" <q:query>\n" +
" <PLAY>\n" +
" <PERSONAE>\n" +
" <PERSONA><q:word>brother</q:word></PERSONA>\n" +
" </PERSONAE>\n" +
" </PLAY>\n" +
" </q:query>\n" +
View gist:8551357
for $speech in (doc()//SPEECH)[1 to 100]
let $speaker := $speech/SPEAKER
let $lines := $speech/LINE
return (
<h2>{$speaker/text()}</h2>,
<p>{for $line in $lines return $line/text()}</p>
)
View Search Options.json
{
"options": {
"debug": false,
"transform-results": {
"apply": "raw"
},
"constraint": [{
"name": "stars",
"range": {
"type": "xs:int",
@eedeebee
eedeebee / grouping.xqy
Created Jan 7, 2014
Grouping the values from a range index
View grouping.xqy
xquery version "1.0-ml";
declare namespace sample = "http://marklogic.com/sample";
let $groupsize := 1000
let $values := cts:element-values(xs:QName("sample:value"))
let $count := fn:count($values)
let $groups :=
for $i in (0 to (xs:int($count div $groupsize) + 1))
let $group := $values[(($i * $groupsize) + 1) to (($i + 1) * $groupsize)]
return fn:string-join($group, "|")
@eedeebee
eedeebee / tweet_options.xml
Created Jan 3, 2014
Search options for tweet and telephone fields, with suggestion source
View tweet_options.xml
<options xmlns="http://marklogic.com/appservices/search">
<search-option>unfiltered</search-option>
<quality-weight>0</quality-weight>
<return-plan>true</return-plan>
<debug>true</debug>
<constraint name="tweet">
<word>
<field name="tweet"/>
</word>
</constraint>
@eedeebee
eedeebee / tweet_options.xml
Last active Jan 2, 2016
Search options for fields with tweet and telephone #s
View tweet_options.xml
<options xmlns="http://marklogic.com/appservices/search">
<search-option>unfiltered</search-option>
<quality-weight>0</quality-weight>
<return-plan>true</return-plan>
<debug>true</debug>
<constraint name="tweet">
<word>
<field name="tweet"/>
</word>
</constraint>
@eedeebee
eedeebee / tweet_options.xml
Created Jan 3, 2014
Search options with word field constraint
View tweet_options.xml
<options xmlns="http://marklogic.com/appservices/search">
<search-option>unfiltered</search-option>
<quality-weight>0</quality-weight>
<return-plan>true</return-plan>
<debug>true</debug>
<constraint name="tweet">
<word>
<field name="tweet"/>
</word>
</constraint>
@eedeebee
eedeebee / setup1.xqy
Last active Jan 2, 2016
Setup scripts for MarkLogic custom tokenization tutorial at http://developer.marklogic.com/learn/custom-tokenization
View setup1.xqy
xquery version "1.0-ml";
(: Create the database and forest on current host :)
import module namespace admin="http://marklogic.com/xdmp/admin"
at "/MarkLogic/admin.xqy";
let $config := admin:get-configuration()
let $config :=
admin:database-create($config, "tweets",
xdmp:database("Security"), xdmp:database("Schemas"))
let $config := admin:forest-create($config, "tweetsF1", xdmp:host(), ())