Skip to content

Instantly share code, notes, and snippets.

@robshep
robshep / geojson.js
Last active August 29, 2015 14:19
basic restify/node.js based server for providing GeoJSON features
// npm install restify pg
/**
* Configure the tables and the columns required as properties
*/
var tables = {
'boundary' : { geom:'polygon', cols:['id', 'area_id', 'org_id'] },
'stage' : { geom:'route', cols:['id', 'event_id', 'name', 'outandback', 'start_time', 'num', 'distance'] },
'stagepoi' : { geom:'point', cols:['id', 'stage_id', 'type' ] }
};
@robshep
robshep / index.html
Last active August 29, 2015 14:21
Touch Wheel Menu
<!DOCTYPE html>
<!-- saved from url=(0065)http://konvajs.github.io/downloads/code/sandbox/Star_Spinner.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Konva WheelSpin Demo</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #F0F0F0;
@robshep
robshep / delete_eav_from_hstore.sql
Last active August 29, 2015 14:22
Build an HStore-based query index for EAV attributes
CREATE OR REPLACE FUNCTION delete_thing_att_map_hstore()
RETURNS trigger AS
$BODY$BEGIN
update
thing
set
att_map = ( att_map - OLD.def_id::text )
WHERE
id = NEW.thing_id;
@robshep
robshep / PGJSONSerialiser.java
Created June 5, 2015 16:13
PostgreSQL JSON DataType binding using Jackson
import java.io.IOException;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Properties;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
@robshep
robshep / http_config.ng.js
Last active August 29, 2015 14:23
Common AngularJS HTTP configurations
/**
* @author Rob Shepherd
*/
'use strict';
;(function(){
angular.module('sbHttpConfig', [])
.factory('httpRedirectionInterceptor', ['$location', function($location) {
var width = 0.7; // to 2.3
var freq = 20; // to 100;
var i = null;
var go = function(){
i = setInterval(function() {
digitalPulse(B10, 1, width);
}, freq);
};
@robshep
robshep / gulpfile.js
Last active January 4, 2017 09:17
gulpfile.js
/**
*
*/
var version = '1.0.0';
var bsThemeVariables = "bootstrap-variables-sarbase2";
var PRODUCTION = (process.env.FE_PROD) || false;
console.log("PRODUCTION = " + PRODUCTION);
@robshep
robshep / writeup.md
Last active August 29, 2015 14:26
JSOxford - Hacking the NodeBots - July 2015

JSOxford - Hacking the NodeBots - July 2015

Last saturday saw the middle of three events in the Summer of Hacks series from JSOxford.

The guys put together a great event in partnership with Gordon from Pur3. Gordon is the talented inventor of the Espurino family of javascript powered microcontrollers and had previously given a talk to the group about the boards, so most people were already juiced up to try it out.

A heap of wires, batteries, servos and other electronics had been duly arranged and Gordon had even gone to the supreme effort of developing a printed circuit board to form the chassis of the mobile robot and had instructions prepared to give us a head start of assembling our soon-to-be planet destroying synthetic lifeform underlings!

@Grapes(
@Grab(group='com.drewnoakes', module='metadata-extractor', version='2.8.1')
)
import java.nio.file.*;
import java.nio.file.attribute.*;
import com.drew.metadata.*;
import com.drew.imaging.*;
import com.drew.metadata.exif.*;
@robshep
robshep / bootWebTx.groovy
Created January 6, 2016 12:27
Single file REST controller with transactional service support, in Groovy using Spring Boot
@Grapes(
@Grab(group='com.h2database', module='h2', version='1.4.190')
)
import org.springframework.transaction.annotation.Transactional
import javax.sql.DataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;