Skip to content

Instantly share code, notes, and snippets.

View MartijnR's full-sized avatar

Martijn van de Rijdt MartijnR

View GitHub Profile
@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' );
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 / 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 );
@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 / 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 / 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 / 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
list:
* a
+ b
- c
list:
* a
+ b
- c
@MartijnR
MartijnR / index.html
Last active November 17, 2015 17:34
Demonstrates issue with Chrome retrieving and displaying a File from indexedDB
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<ol>
<li>Add image file to input</li>
<li>Confirm image preview is shown to verify that blob is succesfully saved in indexedDB and can be retrieved</li>
<li>Refresh page, confirm image preview is still shown</li>
@MartijnR
MartijnR / index.html
Last active November 17, 2015 17:54
Demonstrates issue with Chrome retrieving and displaying blobs from indexedDB
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<ol>
<li>Image preview is shown to verify that blob is succesfully saved in indexedDB and can be retrieved</li>
<li>Refresh page, confirm image preview is still shown</li>
<li>Load or refresh page a few hours, or a day, later: Image can still be retrieved from store, is blob, has file size, but cannot be shown any more (404). See console.</li>