Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am joemfb on github.
  • I am joemfb (https://keybase.io/joemfb) on keybase.
  • I have a public key whose fingerprint is CCB1 0C6E 555D 3645 8F4B 459B 1EE9 B9EF C7B4 350B

To claim this, I am signing this object:

@joemfb
joemfb / appservices-utils.xqy
Last active August 29, 2015 14:06
Utility functions for working with app-service APIs (Search, REST, etc.)
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
import module namespace ast = "http://marklogic.com/appservices/search-ast" at "/MarkLogic/appservices/search/ast.xqy";
import module namespace dbut = "http://marklogic.com/rest-api/lib/db-util" at "/MarkLogic/rest-api/lib/db-util.xqy";
import module namespace eput = "http://marklogic.com/rest-api/lib/endpoint-util" at "/MarkLogic/rest-api/lib/endpoint-util.xqy";
import module namespace sut = "http://marklogic.com/rest-api/lib/search-util" at "/MarkLogic/rest-api/lib/search-util.xqy";
import module namespace csu = "http://marklogic.com/rest-api/config-query-util" at "/MarkLogic/rest-api/lib/config-query-util.xqy";
import module namespace config-query = "http://marklogic.com/rest-api/models/config-query" at "/MarkLogic/rest-api/models/config-query-model.xqy";
@joemfb
joemfb / fn-info.xqy
Created September 11, 2014 18:58
XQuery function info in MarkLogic
xquery version "1.0-ml";
declare function local:fn-info($fn)
{
xdmp:function-name($fn),
xdmp:function-signature($fn),
xdmp:function-module($fn)
};
local:fn-info( cts:special#1 )
@joemfb
joemfb / mlpm_deploy.rb
Last active August 29, 2015 14:14
Roxy app_specific.rb module for deploying mlpm packages
require 'json'
class ServerConfig
alias_method :original_deploy_modules, :deploy_modules
def deploy_modules
# if @properties['ml.deploy-include-packages']
# deploy_packages
# end
@joemfb
joemfb / aggregates.xqy
Last active August 29, 2015 14:19
aggregate function metadata
xquery version "1.0-ml";
declare variable $numeric-scalar-types := ("int", "unsignedInt", "long", "unsignedLong", "float", "double", "decimal");
declare function local:scalar-types()
{
xdmp:read-cluster-config-file("database.xsd")/xs:schema
/xs:simpleType[@name eq "scalar-type"]/xs:restriction/xs:enumeration/@value/fn:string()
};
@joemfb
joemfb / structured-query-utils.xqy
Last active April 13, 2016 13:30
MarkLogic structured query conversion functions
xquery version "1.0-ml";
(:~
: Utility module from converting structured queries to/from JSON, XML, and cts:query
:)
module namespace sq = "http://marklogic.com/mlpm/structured-query";
import module namespace ast = "http://marklogic.com/appservices/search-ast"
at "/MarkLogic/appservices/search/ast.xqy";
import module namespace sut = "http://marklogic.com/rest-api/lib/search-util"
@joemfb
joemfb / search.peg
Created February 1, 2016 19:09
PEG.js search grammar
{
function joinNested(x) {
return x.map(function(y) {
return Array.isArray(y) ? joinNested(y) : y
}).join('')
}
}
// match all rules, consuming the entire input
root = a:all EOF { return a }
:- %say |= * :- %noun
::
:::: sets (http://urbit.org/docs/hoon/exercises/data-structures/)
::
=+ s=(silt `(list @t)`['urbit' 'arvo' 'hoon' 'arvo' ~])
~& 'original set'
~& s
::
:::: #1
::
@joemfb
joemfb / cartesian-product.hoon
Created June 14, 2016 04:40
produces the cartesian product of two sets-of-strings in Hoon
:- %say |= * :- %noun
=< (cartesian-product (sy ['a' 'b' 'c' ~]) (sy ['x' 'y' 'z' ~]))
::
|% ++ cartesian-product
|= {a/(set @t) b/(set @t)}
=+ r=*(set {@t @t})
|- ?~ a r
=+ b=b :: shadow b for inner loop walkthru
|- ?~ b
=+ ^= r
~novlen-hanweb@ grants that it's a little heavy-handed
--------------| for '=' /urbit-meta
--------------| --met ~tanpem-rolnul-danneb-hoslyt--socnyl-figteg-fotlev-datben
--------------| for '=' /urbit-meta
--------------| --met ~bolryl-niddem-poctyv-sapwep--fogsur-tornux-fotlev-datben
-------[12.955]
~lavbyr_datben* now anyone can be a _dotben!
~haclud_malfep= looks pretty good to me
~lavbyr_datben deploys an audience fix
~haptem-fopnys= why are people's audiences messed up