Skip to content

Instantly share code, notes, and snippets.

View dmccreary's full-sized avatar

Dan McCreary dmccreary

View GitHub Profile
@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 := "
"
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
@dmccreary
dmccreary / ping-led-modulo
Created September 2, 2014 02:22
Display the color of an LED strip based on the modulo of the distance
#include <Adafruit_NeoPixel.h>
// Sample code for using a breadboard Arduino to drive WS2812B LED strip with Adafruit NeoPixel library
// I got mine on e-bay:
// http://www.ebay.com/itm/181268207260?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
// Note - colors for data and ground vary
// I used a 16MHZ Crystal Oscilator
#define PIN 12 // connect the Data In pin
const int pingPin = 7;
int pixelToSet = 1;
// --------------------------------------------------------------------------- Motors
// These are the pins to the the motor drive chip for the left wheel
int motor_left[] = {12, 13};
// These are the pins to the the motor drive chip for the right wheel
int motor_right[] = {6, 7};
// --------------------------------------------------------------------------- Setup
void setup() {
Serial.begin(9600);
@dmccreary
dmccreary / disable-save-when-not-dirty-or-invalid.xml
Last active August 29, 2015 14:01
Example Orbeon form for disable Save when not dirty or invalid. Depends on the Orbeon error-summary control.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://orbeon.org/oxf/xml/formatting"
xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:widget="http://orbeon.org/oxf/xml/widget">
<head>
<!-- fr:error-summary has errors-count-ref which can store number of errors to data. You can use that data to enable button. -->
<title>Example of Visit All Failing</title>
<style type="text/css">
.orbeon .xforms-control {display:block; padding:5px;}
/* not needed in a table display:inline-block; width:10ex; text-align:right; */
.orbeon .xforms-label {font-weight:bold!important; display:inline-block; margin-right: 1ex;}
@dmccreary
dmccreary / column-label-hidden-in-control.xml
Created May 6, 2014 20:02
Orbeon column label hidden within control working with multiple alerts and error summay
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fr="http://orbeon.org/oxf/xml/form-runner" xmlns:xf="http://www.w3.org/2002/xforms">
<head>
<title>XForms demo of label within table headers</title>
<xf:model>
<xf:instance xmlns="" id="save-data">
<data>
<row>
<integer1>1</integer1>
<integer2>2</integer2>
<integer3>3</integer3>
@dmccreary
dmccreary / table-pagination.xml
Last active January 29, 2020 14:55
XForms table pagination with Orbeon. In this example the Prev and Next buttons are disable by binding rules.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<head>
<title>XForms 2 Row Repeat Test Using nodeset and id for Repeat</title>
<xf:model>
<xf:instance xmlns="" id="save-data">
<data>
<row>
<first-name>Dan</first-name>
<last-name>McCreary</last-name>
<phone-ext>111</phone-ext>
@dmccreary
dmccreary / ws2812b-driver.
Created April 24, 2014 12:29
Sample code for using a breadboard Arduino to drive WS2812B LED strip with Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
// Sample code for using a breadboard Arduino to drive WS2812B LED strip with Adafruit NeoPixel library
// I got mine on e-bay:
// http://www.ebay.com/itm/181268207260?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
// Note - colors for data and ground vary
// I used a 16MHZ Crystal Oscilator
#define PIN 8 // connect the Data In pin
// Parameter 1 = number of pixels in strip - I used 12