Skip to content

Instantly share code, notes, and snippets.

View MartijnR's full-sized avatar

Martijn van de Rijdt MartijnR

View GitHub Profile
list:
* a
+ b
- c
list:
* a
+ b
- c
@MartijnR
MartijnR / Vagrantfile
Last active August 29, 2015 14:24
node-libxslt build error
Vagrant.configure("2") do |config|
config.vm.box = "trusty"
config.vm.box_url = "ubuntu/trusty64"
config.vm.provision "shell", inline: <<-SHELL
curl -sL https://deb.nodesource.com/setup_0.10 | sudo bash -
apt-get install -y git build-essential nodejs
npm explore npm -g -- npm install node-gyp@latest
npm install libxslt
SHELL
end
@MartijnR
MartijnR / gist:2e03a7938d74dd884136
Last active October 16, 2015 15:10
A+ SSL installation with NGINX (for enketo-express)
server {
listen 80;
server_name odk.enke.to;
return 307 https://$server_name$request_uri;
}
server {
listen 443;
ssl on;
@MartijnR
MartijnR / resize
Created March 26, 2015 17:11
whisper-resize command
sudo find ./core -type f -name '*.wsp' -exec ./whisper-resize.py --nobackup {} 1h:1d 1d:5y 7d:10y \;
@MartijnR
MartijnR / webhook
Last active August 29, 2015 14:17
Webhook in Node
"use strict";
var gith = require( 'gith' ).create( 9001 ),
execFile = require('child_process').execFile;
gith( {
repo: 'enketo/enketo-core'
} ).on( 'all', function( payload ) {
console.log( 'Post-receive happened' );
if ( payload.branch === 'master' ) {
@MartijnR
MartijnR / convertIndexRepeatToPositionedPath
Created March 7, 2014 23:42
converts XPath indexed-repeat( ) to a positioned path - indexed-repeat(/path/to/repeat/node, /path/to/repeat, 3) -> /path/to/repeat[position() = 3]/node
/**
* Converts an indexed-repeat(node, path, position, path, position, etc) to its native XPath
* equivalent using [position() = x] predicates
*
* @param {string} expr the XPath expression
* @return {string} converted XPath expression
*/
FormModel.prototype.convertIndexedRepeatToPositionedPath = function( expr ) {
var indexedRepeats = expr.match( /(indexed-repeat\s?\([^\)]+\))/g );
var dpi, printStyleSheet, $printStyleSheetLink;
// make sure setDpi is not called until DOM is ready
$( document ).ready( function() {
setDpi();
} );
/**
* Calculates the dots per inch and sets the dpi property
*/
@MartijnR
MartijnR / enketo-xslt-test
Created November 1, 2013 17:48
enketo-xslt-test
/**
* Checks for general transformation or xml form errors by comparing stats. It is helpful,
* though an error is not always important
*/
FormView.prototype.checkForErrors = function( ) {
var i,
paths = [ ],
total = {},
$stats = $form.find( '#stats' );
@MartijnR
MartijnR / enketo-hints-tooltip
Created November 1, 2013 17:40
enketo-hints-tooltip
//add 'hint' icon, could be moved to XSLT, but is very fast even on super large forms - 31 msecs on bench6 form
if (!modernizr.touch){
$hint = '<span class="hint" ><i class="icon-question-sign"></i></span>';
$form.find('.jr-hint ~ input, .jr-hint ~ select, .jr-hint ~ textarea').before($hint);
$form.find('legend > .jr-hint').parent().find('span:last-child').after($hint);
$form.find('.trigger > .jr-hint').parent().find('span:last').after($hint);
}
/**
* setHints updates the hints. It is called whenever the language or output value is changed.
@MartijnR
MartijnR / enketo-compliant-widget-template
Last active September 5, 2017 16:12
Enketo-compliant Widget Template
'use strict';
/**
* My Fancy Widget
*
* A jQuery plugin form widget that is compatible with Enketo Smart Paper
* and extends a base Enketo Widget class (see https://github.com/enketo/enketo-core)
*/
var Widget = require('../../js/Widget');