Skip to content

Instantly share code, notes, and snippets.

View jterstriep's full-sized avatar

Jeff Terstriep jterstriep

View GitHub Profile
@jterstriep
jterstriep / csv_gdf.py
Created August 29, 2019 21:40
Convert CSV with Lat Long to GeoDataFrame
## https://gis.stackexchange.com/questions/174159/convert-a-pandas-dataframe-to-a-geodataframe
from geopandas import GeoDataFrame
from shapely.geometry import Point
geometry = [Point(xy) for xy in zip(df.Lon, df.Lat)]
df = df.drop(['Lon', 'Lat'], axis=1)
crs = {'init': 'epsg:4326'}
gdf = GeoDataFrame(df, crs=crs, geometry=geometry)
@jterstriep
jterstriep / ansible-bootstrap-ubuntu-16.04.yml
Created March 9, 2017 00:07 — forked from gwillem/ansible-bootstrap-ubuntu-16.04.yml
Get Ansible to work on bare Ubuntu 16.04 without python 2.7
# Add this snippet to the top of your playbook.
# It will install python2 if missing (but checks first so no expensive repeated apt updates)
# gwillem@gmail.com
- hosts: all
gather_facts: False
tasks:
- name: install python 2
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
@jterstriep
jterstriep / pedantically_commented_playbook.yml
Created December 6, 2016 05:36 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@jterstriep
jterstriep / source.py
Created March 2, 2016 15:50
Source a shell script from within a python program.
from subprocess import Popen, PIPE
from os import environ
def source(script, update=True):
"""Source a bash script from within Python
Two step process of creating a new shell with updated environmental variables and
using its env to update the scripts's environment.
http://pythonwise.blogspot.com/2010/04/sourcing-shell-script.html
# issuing basic ssh commands with paramiko
import paramiko
HOST = 'site.com'
USER = 'user'
PASSWORD = 'xxx'
PRIVATEKEY = '/home/%s/.ssh/id_rsa' % USER
ssh = paramiko.SSHClient()
class BaseWorker(ConsumerMixin):
# The name of the queue that this worker consumes (see queues.py)
worker_queue = None
def __init__(self, connection, config):
print "Worker Init"
self.connection = connection
self.config = config