Skip to content

Instantly share code, notes, and snippets.

@mojodna
mojodna / 0_register_planet.sql
Last active May 18, 2022 17:51
Sample OSM Athena queries
--
-- This will register the "planet" table within your AWS account
--
CREATE EXTERNAL TABLE planet (
id BIGINT,
type STRING,
tags MAP<STRING,STRING>,
lat DECIMAL(9,7),
lon DECIMAL(10,7),
nds ARRAY<STRUCT<ref: BIGINT>>,
@gunar
gunar / recursiveDir.js
Last active March 6, 2016 00:21
Comparison of recursive directory listing methods in JavaScript
/*
* Comparison of methods to list all files in a directory
* and subdirectories ("recursive directory walk").
*
* gunargessner.com 2015-12-25
*
*/
var fs = require('fs');
var fsPath = require('path');
var _ = require('highland');
@dypsilon
dypsilon / highland_readdirp.js
Last active August 29, 2015 14:24
Recursive readdir using highland streams.
/**
* This function takes a directory path and returns a flat stream
* with stat objects + full file path in the .path property.
*/
var path = require('path');
var h = require('highland');
var readdir = h.wrapCallback(require('fs').readdir);
var stat = h.wrapCallback(require('fs').stat);
@nickjevershed
nickjevershed / Convert Google spreadsheet to JSON and save to S3
Created August 21, 2013 23:10
Converts Google spreadsheet to JSON and saves to an S3 bucket. Spreadsheet needs to be public or accessible with link.
#!/usr/bin/env python
import urllib2
import csv
import json
import boto
#Replace Google spreadsheet URL with your spreadsheet URL
url = "GOOGLE SPREADSHEET URL" + "&output=csv"
@jonlabelle
jonlabelle / string-utils.js
Last active October 30, 2023 20:33
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@furf
furf / _.deep.js
Created July 30, 2012 17:06
underscore.js mixin for plucking nested properties
_.mixin({
// Get/set the value of a nested property
deep: function (obj, key, value) {
var keys = key.replace(/\[(["']?)([^\1]+?)\1?\]/g, '.$2').replace(/^\./, '').split('.'),
root,
i = 0,
n = keys.length;
@dsibilly
dsibilly / gist:2992412
Created June 26, 2012 01:00
Node.js clustered HTTP server example
(function () {
'use strict';
var cluster = require('cluster'),
http = require('http'),
os = require('os'),
/*
* ClusterServer object
@dstroot
dstroot / install-redis.sh
Created May 23, 2012 17:56
Install Redis on Amazon EC2 AMI
#!/bin/bash
# from here: http://www.codingsteps.com/install-redis-2-6-on-amazon-ec2-linux-ami-or-centos/
# and here: https://raw.github.com/gist/257849/9f1e627e0b7dbe68882fa2b7bdb1b2b263522004/redis-server
###############################################
# To use:
# wget https://raw.github.com/gist/2776679/04ca3bbb9f085b192f6aca945120fe12d59f15f9/install-redis.sh
# chmod 777 install-redis.sh
# ./install-redis.sh
###############################################
echo "*****************************************"
@michaelcontento
michaelcontento / lxc-ubuntu.sh
Created January 3, 2012 20:45 — forked from dkulchenko/lxc-ubuntu
Script to generate LXC containers for EC2
#!/bin/bash
#
# Template script for generating ubuntu container for LXC with the same
# ubuntu relase as the host
#
# This script is based on lxc-debian for EC2 (Daniil Kulchenko <daniil@kulchenko.com>)
# wich itself is based on lxc-debian (Daniel Lezcano <daniel.lezcano@free.fr>)
#
@codebox
codebox / Mosaic.java
Created September 21, 2011 19:46
Java code to create a mosaic image from multiple small tiles (the code is a bit rough, sorry)
package uk.org.codebox.mosaic;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;