Skip to content

Instantly share code, notes, and snippets.

@prashtx
prashtx / gist:2765574
Created May 22, 2012 00:06
jquery json post
$.ajax(create_url, {
contentType: 'application/json',
dataType: 'json',
type: 'POST',
data: JSON.stringify(data)
})
.done(function(result) {
var id = result.surveys[0].id;
navigateToSurvey(id);
});
#!/bin/sh
/usr/bin/opendiff "$2" "$5" -merge "$1"
/**
* Fix an issue where checkbox questions were stored with the name "undefined"
* - Saves the data in the format QUESTION_NAME-ANSWER_NAME
* - Removes the undefined keys
*
* Usage:
* $ mongo server:port/database_name -u username -p password fixGaryMultiples.js
*
*/
@prashtx
prashtx / deploy-slug.js
Last active April 8, 2022 13:26
Deploy a slug tarball to Heroku from node.
#!/usr/bin/env node
/*jslint node:true */
'use strict';
/*
* Usage:
* ./deploy-slug.js my-cool-git-free-app slug.tgz `heroku auth:token`
*/
var fs = require('fs');
[
{ "name": "foo", "location": [37.8045, -122.402] },
{ "name": "bar", "location": [37.78, -122.391] },
{ "name": "baz", "location": [37.7753, -122.3954] }
]
@prashtx
prashtx / simplify.js
Created April 9, 2015 01:02
Simplify a Polygon and MultiPolygon FeatureCollection
#!/usr/bin/env node
/*
* cat my-features.json | ./simplify.js 0.0001 > my-simplified-features.json
*/
'use strict';
var simplify = require('turf-simplify');
var concat = require('concat-stream');
var TOLERANCE = 0.01;