Skip to content

Instantly share code, notes, and snippets.

View joewiz's full-sized avatar

Joe Wicentowski joewiz

  • Arlington, Virginia
View GitHub Profile
@lcahlander
lcahlander / xsd2json.xqy
Last active April 9, 2019 14:13
Translate an XML Schema into equivalent JSON Schema
xquery version "3.1";
(:~
This XQuery library module transforms an XML Schema to a JSON Schema equivalent.
NOTE: This is a work in progress. I would appreciate any comments to make it more robust.
To execute the transformation, place the followin in another XQuery module.
xquery version "3.1";
import module namespace xsd2json="http://easymetahub.com/ns/xsd2json" at "xsd2json.xqy";
@wsalesky
wsalesky / git-sync-v2.xql
Created November 30, 2017 18:57
Update git-sync XQuery to use eXistdb's native JSON parser.
xquery version "3.1";
(:~
: Webhook endpoint for tcadrt.com data repository, /master/ branch:
: XQuery endpoint to respond to Github webhook requests. Query responds only to push requests from the master branch.

: The EXPath Crypto library supplies the HMAC-SHA1 algorithm for matching Github secret. 

:
: Secret can be stored as environmental variable.
: Will need to be run with administrative privileges, suggest creating a git user with privileges only to relevant app.
:
@lcahlander
lcahlander / tsgen.xqm
Last active May 29, 2019 14:00
This library module walks an XML Schema and generates the stubs for a typeswitch transform to process a document from that schema.
(:
Copyright (c) 2017. EasyMetaHub, LLC
This work is licensed under a
<a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.
:)
xquery version "3.1";
(:~
This library module walks an XML Schema and generates the stubs for a typeswitch
@WaxCylinderRevival
WaxCylinderRevival / analyze-text-for-date-patterns.xq
Last active October 30, 2017 04:53
analyze-text-for-date-patterns.xq
(: declare namespace dp='https://history.state.gov/ns/xquery/date-processing' :)
declare variable $local:regexes :=
map {
"month-regex" : "(?:January|February|March|April|May|June|July|August|September|October|November|December)",
"month-regex-fr" : "(?:janvier|février|fevrier|mart|avril|mai|juin|juillet|août|aout|septembre|octobre|novembre|décembre|decembre)",
"month-regex-sp" : "(?:enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|setiembre|octubre|noviembre|diciembre)",
"day-regex" : "(?:\d{1,2})(?:st|d|nd|rd|th)?",
"day-range-regex" : "(?:\d{1,2})(?:st|d|nd|rd|th)?\s*[-–—]\s*(?:\d{1,2})(?:st|d|nd|rd|th)?",
"year-regex" : "(?:\d{4})",
@adamretter
adamretter / ant-show-deps.xqy
Created September 25, 2017 15:03
XQuery to display the dependencies tree of an Ant target
(:~
: XQuery to display the dependencies of an Ant target.
:
: There are two modes of operation:
: 1) Display all targets and immediate dependencies, specified by $project-file
: 2) Show a tree of a single targets dependencies, this happens when $target-name is set as well.
:
: External parameters:
: $project-file The initial Ant file to start parsing from (imports will be expanded)
: $target-name If specified we examine only a single target and produce a tree of all dependencies (recursively)

Technical details for https://stackoverflow.com/a/44169445/6730571

Details of investigation:

On a base system, /usr/bin/java is a symlink that points to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java, which is an Apple wrapper tool that locates and executes the actual java.

(Do not touch anything in those 2 system directories. It should actually be impossible due to "System Integrity Protection" anyway.)

If you don't have Java installed, attempting to execute java will open a dialog that invites you to install it.

@ismyrnow
ismyrnow / mac-clear-icon-cache.sh
Created May 5, 2017 19:28
Clear the icon cache on a Mac when you start seeing generic icons in Finder or the Dock
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
@CliffordAnderson
CliffordAnderson / anonymizer.xqy
Created March 10, 2017 21:01
Fold Left for Anonymizing Names
xquery version "3.1";
(: The credit for this idea goes to Joe Wicentowski :)
let $sentence := "The men attending the meeting were Mr. Anderson, Mr. Wicentowski, and Mr. Jones. The women attending were Ms. French, Ms. Ryder, and Ms. Callon."
let $names := ("Anderson", "Jones", "French")
let $replace := function($sentence as xs:string?, $name as xs:string) as xs:string? {fn:replace($sentence, $name, "Smith")}
return fn:fold-left($names, $sentence, $replace)
@jnovack
jnovack / bluetooth.sh
Created January 18, 2017 15:38
Control Bluetooth Daemon through Command Line OSX
#read the current pref, returns '0' for off and '1' for on.
defaults read /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState
#set bluetooth pref to off
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 0
#set bluetooth pref to on
sudo defaults write /Library/Preferences/com.apple.Bluetooth.plist ControllerPowerState 1
#kill the bluetooth server process
@CliffordAnderson
CliffordAnderson / 01-lookup-words
Last active January 19, 2017 16:00
Looking up words in the OED with XQuery
xquery version "3.1";
let $word := "person"
let $request :=
<http:request href="https://od-api.oxforddictionaries.com/api/v1/entries/en/{$word}" method="get">
<http:header name="app_key" value="###"/>
<http:header name="app_id" value="###"/>
</http:request>
return http:send-request($request)