Skip to content

Instantly share code, notes, and snippets.

@dgreyling
dgreyling / geojson-length.py
Created June 10, 2016 20:00 — forked from bmcbride/geojson-length.py
Calculate the length of a GeoJSON linestring using the Python GDAL/OGR API
from osgeo import ogr
from osgeo import osr
source = osr.SpatialReference()
source.ImportFromEPSG(4326)
target = osr.SpatialReference()
target.ImportFromEPSG(3857)
transform = osr.CoordinateTransformation(source, target)
@dgreyling
dgreyling / install.sh
Last active August 11, 2016 02:31 — forked from wdullaer/install.sh
Install Latest Docker and Docker-compose on Ubuntu
# Ask for the user password
# Script only works if sudo caches the password for a few minutes
sudo true
# Install kernel extra's to enable docker aufs support
# Alternatively you can use the official docker install script
wget -qO- https://get.docker.com/ | sh
# Install docker-compose
@dgreyling
dgreyling / haversine.py
Created October 7, 2016 13:57
Calculate distance between latitude longitude pairs with Python
import math
def distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371 # km
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1)
a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) \
@dgreyling
dgreyling / pypdf_to_image.py
Created November 11, 2016 23:21 — forked from rririanto/pypdf_to_image.py
Python Convert PDF to Image
"""
Problem:
How to Convert PDF to Image with Python Script ?
Installation:
I use ubuntu OS 14.04
We use wrapper for ImageMagick [http://www.imagemagick.org/script/index.php] to Convert The PDF file
in Python do:
$ sudo apt-get install libmagickwand-dev
@dgreyling
dgreyling / flask-login-example
Created November 11, 2016 23:23 — forked from benjiao/flask-login-example
Flask Login Example
from flask import session
from flask import request
from flask import redirect
from functools import wraps
app = Flask(__name__)
app.secret_key = '86A611287CE4DC76545575687F84F'
def login_required(test):
@dgreyling
dgreyling / app.DockerFile
Created May 1, 2019 18:14 — forked from satendra02/app.DockerFile
docker+rails+puma+nginx+postgres (Production ready)
FROM ruby:2.3.1
# Install dependencies
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable where the Rails app is installed to inside of Docker image:
ENV RAILS_ROOT /var/www/app_name
RUN mkdir -p $RAILS_ROOT
# Set working directory, where the commands will be ran: