Skip to content

Instantly share code, notes, and snippets.

View digitalsadhu's full-sized avatar

Richard Walker digitalsadhu

View GitHub Profile
@digitalsadhu
digitalsadhu / Html.php
Created October 10, 2013 15:48
Html helper class, extends CHtml to provide other useful view methods.
<?
/**
* URL-ify
* Returns the value in a URL-ified version.
* @return string
*/
function urlify($string) {
$string = strtolower($string);
$string = str_replace(array('*', '!', '&', '=', '/', '?'), '', $string);
@digitalsadhu
digitalsadhu / admittance-simple.js
Last active August 29, 2015 13:57
Idea for new interface for admittance js
var fs = require('fs')
, admittance = require('admittance')
//read from the text file where we store pairs of user ids and permissions
var storeR = fs.createReadStream(__dirname + '/my-store.txt')
//read in permissions
storeR.pipe(admittance)
//do a permissions check
@digitalsadhu
digitalsadhu / gist:1c1798536e9b726c548d
Last active December 15, 2020 07:10
Installing postgis on mac
# installation commands
brew update
brew install postgresql
brew install postgis
# start the server
postgres -D /usr/local/var/postgres
# setup commands
createdb <name>
@digitalsadhu
digitalsadhu / osm-geojson-to-2-node-ways.js
Created October 6, 2014 13:31
Script to convert osm geojson data to osm ways geojson feature pairs
#!/usr/bin/env node
'use strict';
//Streaming parser that filters out osm data leaving just ways.
//Ways are then broken down into node pairs.
//
//ie.
//{
// "type":"Feature",
@digitalsadhu
digitalsadhu / tmps-to-postgis.js
Created October 6, 2014 13:36
Inserts TMP data into a POSTGIS database
#!/usr/bin/env node
'use strict';
var pg = require('pg')
, geojsonStream = require('geojson-stream')
, fs = require('fs')
, stdout = require('stdout-stream')
, through2 = require('through2')
, Q = require('q')
@digitalsadhu
digitalsadhu / augment-geojson-data.js
Created October 6, 2014 13:42
Intersects geojson features with a POSTGIS database
#!/usr/bin/env node
'use strict';
var through = require('through2')
, geojsonStream = require('geojson-stream')
, fs = require('fs')
, chalk = require('chalk')
, pg = require('pg')
@digitalsadhu
digitalsadhu / leaflet-snap-example.js
Last active August 29, 2015 14:07
Leaflet, leaflet snap and some snippity dippity
/**
* Requires leaflet
* Requires leaflet-geometryutil plugin loaded
* Requires leaflet-snap plugin loaded
*/
//geojson guide layer, this is a linestring around the old town hall
var guideLayer = L.geoJson({
"type": "FeatureCollection",
"features": [
var findContract = _.flip(_.wrapCallback(Contract.findById.bind(Contract)), {remoteCtx: ctx});
var findContractPeriods = _.flip(_.wrapCallback(ContractPeriod.find.bind(ContractPeriod)), {remoteCtx: ctx});
var findContractPeriod = _.flip(_.wrapCallback(ContractPeriod.findById.bind(ContractPeriod)), {remoteCtx: ctx});
var findReviews = _.flip(_.wrapCallback(Review.find.bind(Review)), {remoteCtx: ctx});
var sendEmail = _.wrapCallback(sendReminderEmail);
var contractPeriodStream1 = findReviews(query).flatten().pluck('contractPeriodId').map(findContractPeriod);
var contractPeriodStream2 = findContractPeriods(query).flatten();
contractPeriodStream1.merge(contractPeriodStream2)
This file has been truncated, but you can view the full file.
<?xml version="1.0"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Media Releases</title>
<link>http://www.nzta.govt.nz/media-releases/rss</link>
<atom:link href="http://www.nzta.govt.nz/media-releases/rss" rel="self" type="application/rss+xml" />
<description></description>
<item><title>Wellington highways closed due to surface flooding - update 11.45am</title><link>http://www.nzta.govt.nz/media-releases/wellington-highways-closed-due-to-surface-flooding-update-11-45am</link><pubDate>2016-11-15 11:45:00</pubDate><guid>http://www.nzta.govt.nz/media-releases/wellington-highways-closed-due-to-surface-flooding-update-11-45am</guid><description></description><category>Media release</category><category>Central</category></item>
@digitalsadhu
digitalsadhu / propsed-ash-orm-levels.md
Created January 19, 2017 21:31
Proposal for ORM data access options

3 layers of data access (proposal)

Model methods: (layer 3)

These mirror ember data methods. They are high level and aim to be useable by the API via the url query string etc. They follow jsonapi spec where appliable. They are:

findAll