Skip to content

Instantly share code, notes, and snippets.

View dmccreary's full-sized avatar

Dan McCreary dmccreary

View GitHub Profile
@dmccreary
dmccreary / tigergraph-schema-json-to-gsql.js
Created May 1, 2020 13:28
Node.js script that will convert a TigerGraph schema archive JSON file into GSQL.
#!/usr/local/bin/node
# written by Josh Meekhof
var fs = require("fs");
var content = fs.readFileSync("schema.json");
var schema = JSON.parse(content);
var vertextT = [];
var edgeT = [];
const joiner = (acc, val) => acc + (val + "\n");
@dmccreary
dmccreary / find-big-images-in-ppt-file.sh
Last active December 13, 2025 00:00
Find big images in PowerPoint
#!/bin/sh
# this program has been updated to list both the images and the largest images and the slide numbers together
# get the parameter
echo "working on" "$1"
rm -r /tmp/big-images 2> /dev/null
mkdir /tmp/big-images
# copy the ppt file to /tmp
cp "$1" /tmp/big-images
# rename it to be .zip
mv "/tmp/big-images/$1" "/tmp/big-images/$1.zip"
@dmccreary
dmccreary / skos-prefLabel-with-opt-alt.sparql
Created July 14, 2017 20:32
SKOS prefLabels with optional altLabels.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?s ?p ?o
WHERE
{
?s skosxl:prefLabel ?o .
OPTIONAL {?s skosxl:altLabel ?o}
}
@dmccreary
dmccreary / list-all-SPARQL-Prefixes.xqy
Created July 14, 2017 20:12
List all the SPARQL prefixes
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
declare namespace map="http://marklogic.com/xdmp/map";
let $prefixes-map := <map>{sem:prefixes("skosxl: http://www.w3.org/2008/05/skos-xl#")}</map>
return $prefixes-map/map:map/map:entry/map:value/text()
@dmccreary
dmccreary / list-all-SPARQL-Prefixes.xqy
Created July 14, 2017 20:12
List all the SPARQL prefixes
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
declare namespace map="http://marklogic.com/xdmp/map";
let $prefixes-map := <map>{sem:prefixes("skosxl: http://www.w3.org/2008/05/skos-xl#")}</map>
return $prefixes-map/map:map/map:entry/map:value/text()
@dmccreary
dmccreary / expand-keywords.sparql
Last active July 14, 2017 18:28
Sample Keyword Expansion SPARQL Query
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT (str(?prefTerm) AS ?pTerm) (str(?altTerm) AS ?aTerm)
FROM <urn:x-evn-master:BenefitSectionDetails0>
FROM <urn:x-evn-master:BenefitSection>
WHERE {
?s (skosxl:prefLabel | skosxl:altLabel) / skosxl:literalForm ?allTerms .
FILTER (LCASE(str(?allTerms)) = LCASE('IUD'))
@dmccreary
dmccreary / element-range-values-to-skos.xqy
Created January 21, 2017 14:57
MarkLogic Element Range Index to SKOS-XL
xquery version "1.0-ml";
import module namespace admin = "http://marklogic.com/xdmp/admin" at "/MarkLogic/admin.xqy";
import module namespace style = "http://danmccreary.com/style" at "/modules/style.xqy";
let $nl := "&#10;"
let $namespace := xdmp:get-request-field('namespace')
let $localname := xdmp:get-request-field('localname')
@dmccreary
dmccreary / roter-encoder.cpp
Created July 28, 2015 02:48
Sample Arduino Rotery Encoder Example from Budd Churchward demo.
/* rotery encoder demo by Budd Churchward.
See: https://www.youtube.com/watch?v=FGxLXqzPe3Q
*/
const byte pinA = 2; // encoder pin A to Arduino pin 2 which is also interrupt pin 0 which we will use
const byte pinB = 3; // encoder pin B to Arduino pin 3 which is also interrupt pin 1 but we won't use it
byte state = 0; // will store two bits for pins A & B on the encoder which we will get from the pins above
int level = 0; // a value bumped up or down by the encoder
int haveNewInterrupt = 0; // 1 if we have a new interrupt to show, 0 otherwise
@dmccreary
dmccreary / rainbow_controller.cpp
Created October 18, 2014 18:50
NeoPixel Controller for Spark
// This #include statement was automatically added by the Spark IDE.
#include "lib1.h"
// This #include statement was automatically added by the Spark IDE.
#include "neopixel/neopixel.h"
#include "application.h"
//#include "spark_disable_wlan.h" // For faster local debugging only
#include "neopixel/neopixel.h"
@dmccreary
dmccreary / rotary-encoder-led-strip.c
Created October 2, 2014 20:06
Arduino program to drive a 12 pixel LED strip with a rotary encoder.
#include <Adafruit_NeoPixel.h>
/* Rotary encoder read example
http://www.circuitsathome.com/mcu/programming/reading-rotary-encoder-on-arduino
connect the center wire to ground. Connect the side pins to Analog ports */
#define ENC_A 14 // Analog pin A0
#define ENC_B 15 // Analog pin A1
#define ENC_PORT PINC
#define LEDPIN 9 // connect the Data In pin