This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # ^^^ 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |