Skip to content

Instantly share code, notes, and snippets.

@wilensky
wilensky / mysql_mongo_geo_migration.sql
Last active August 29, 2015 14:20
(MySQL > MongoDB) + (Latitude, Longitude > GeoJSON) data migration
SELECT name, country, region, latitude, longitude
INTO OUTFILE '/tmp/dump.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'
FROM table
--
-- mongoimport -d db_name -c collection_name -type csv -f name,country,region,latitude,longitude --drop /tmp/dump.csv
--
/** -- Mongo shell script --
@wilensky
wilensky / nodejs_fs_mkdirsync_recursive.js
Last active June 16, 2019 20:05
Recursive directory creation using `fs.mkdirSync()`. Recreates directory tree in series.
var fs = require('fs');
/**
* Splits whole path into segments and checks each segment for existence and recreates directory tree from the bottom.
* If since some segment tree doesn't exist it will be created in series.
* Existing directories will be skipped.
* @param {String} directory
*/
function mkdirSyncRecursive(directory) {
var path = directory.replace(/\/$/, '').split('/');