Skip to content

Instantly share code, notes, and snippets.

@brendancol
brendancol / getisord_example.py
Last active December 19, 2024 13:29
Running Getis Ord using PySAL
from __future__ import print_function
# std lib
import os
import sys
# 3rd party
import pandas
import numpy
numpy.random.seed(10)
# install-on-workers.sh
while read slave_url; do
echo "Installing dependencies to ${slave_url}"
ssh root@${slave_url} 'bash -s' < worker-install.sh
done <persistent-hdfs/conf/slaves
# worker-install.sh
yum install libgeos-devel -y
yum install python-devel -y
@brendancol
brendancol / fix_spark_ebs.sh
Last active October 1, 2015 02:14
When deploying Spark with spark-ec2 with --ebs-vol-size option, the mount location is wrong by default, this script: stops cluster, fixes mount location, reformats hdfs and restarts.
#!/usr/bin/env bash
~/persistent-hdfs/sbin/stop-all.sh
sed -i 's#vol/persistent-hdfs#vol0/persistent-hdfs#g' ~/persistent-hdfs/conf/core-site.xml
~/spark-ec2/copy-dir.sh ~/persistent-hdfs/conf/core-site.xml
~/persistent-hdfs/bin/hadoop namenode -format -y
~/persistent-hdfs/sbin/start-all.sh
  1. sudo apt-get install python-setuptools
  2. wget http://downloads.sourceforge.net/project/s3tools/s3cmd/1.5.0-alpha1/s3cmd-1.5.0-alpha1.tar.gz
  3. tar xvfz s3cmd-1.5.0-alpha1.tar.gz
  4. cd s3cmd-1.5.0-alpha1
  5. python setup.py install
  6. s3cmd --configure
@brendancol
brendancol / soe_utils.py
Created October 17, 2013 18:22
SOE Utils (taken from ArcGIS Server Admin Toolbox) requires requests
'''
This script will upload and register an SOE
==Inputs==
ServerName
Port
AdminUser
AdminPassword (sent in clear text)
SOE (file)
@brendancol
brendancol / gist:6816393
Created October 3, 2013 20:14
python: list of dictionaries to csv example
def write_csv(outputRowDictionaries, outputFile, fieldNames=None, defaultFieldValue='', removeDuplicates=False, sortField=None):
dictionaryList = []
if removeDuplicates:
for row in outputRowDictionaries:
if row not in dictionaryList:
dictionaryList.append(row)
else:
dictionaryList = outputRowDictionaries

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
using System;
using System.Collections.Generic;
using ESRI.ArcGIS.DataSourcesRaster;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
internal enum CurveDirection { RIGHT, UP, LEFT, DOWN };
public sealed class BoundingCurve
{
@brendancol
brendancol / overlapping_polygon_example.cs
Created August 8, 2013 16:09
Example of handling overlapping polygons when using ArcObjects IZonalOps
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Server;
"""
Zonal Statistics
Vector-Raster Analysis
Copyright 2013 Matthew Perry
Usage:
zonal_stats.py VECTOR RASTER
zonal_stats.py -h | --help
zonal_stats.py --version