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
import ftplib | |
import os | |
import sys | |
import subprocess | |
from optparse import OptionParser | |
from datetime import datetime | |
DB_USER = 'databaseuser' | |
DB_NAME = 'databasename' |
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
import shapefile | |
import shapely | |
#Load the shapefile of polygons and convert it to shapely polygon objects | |
polygons_sf = shapefile.Reader("C:/PolygonShapeFile.shp") | |
polygon_shapes = polygons_sf.shapes() | |
polygon_points = [q.points for q in polygon_shapes ] | |
from shapely.geometry import Polygon | |
polygons = [Polygon(q) for q in polygon_points] |
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
CREATE OR REPLACE FUNCTION ST_CreateFishnet( | |
nrow integer, ncol integer, | |
xsize float8, ysize float8, | |
x0 float8 DEFAULT 0, y0 float8 DEFAULT 0, | |
OUT "row" integer, OUT col integer, | |
OUT geom geometry) | |
RETURNS SETOF record AS | |
$$ | |
SELECT i + 1 AS row, j + 1 AS col, ST_Translate(cell, j * $3 + $5, i * $4 + $6) AS geom | |
FROM generate_series(0, $1 - 1) AS i, |
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
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] | |
dictionary = dict(zip(keys, values)) | |
#result looks like this {'a': 1, 'b': 2, 'c': 3} | |
# ordered dictionary | |
import collections | |
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] |
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
{ | |
"name": "newprojectname", | |
"version": "1.0.0", | |
"description": "test-map", | |
"main": "main.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1", | |
"build": "webpack --progress -p", | |
"watch": "webpack --progress --watch", | |
"server": "webpack-dev-server --open" |
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 to top of script with the correct path to your app | |
import sys, os | |
sys.path.append('/path/to/your/django/app') | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' | |
from django.conf import settings |
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
import pip | |
from subprocess import call | |
for dist in pip.get_installed_distributions(): | |
call("pip install --upgrade " + dist.project_name, shell=True) |
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
#In a terminal, type: | |
sudo -u postgres psql postgres | |
# this connects as a role with same name as the local user, i.e. "postgres", to the database called "postgres" (1st argument to psql). | |
# Set a password for the "postgres" database role using the command: | |
\password postgres |
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
# original post http://askubuntu.com/questions/831262/how-to-install-pgadmin-4-in-desktop-mode-on-ubuntu-16-04 | |
sudo apt-get install python3-venv python3-pip libpq-dev python3-dev | |
mkdir myVenvs | |
cd myVenvs | |
pyvenv pgadmin4-ve | |
source pgadmin4-v/bin/activate | |
wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.1/pip/pgadmin4-1.1-py3-none-any.whl |
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
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get install postgresql-9.6 | |
sudo apt-get install postgresql-9.6-postgis-2.3 | |
sudo apt-get install postgresql-9.6-pgrouting | |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable | |
sudo apt-get update |