Skip to content

Instantly share code, notes, and snippets.

View rbeucher's full-sized avatar

Romain Beucher rbeucher

View GitHub Profile
@rbeucher
rbeucher / Makefile
Last active August 29, 2015 14:26 — forked from andrewharvey/Makefile
Download and index 250k scanned geological maps from Geoscience Australia
## About
# This script will download the maps and associated meta data for 250k
# Geological Maps at http://www.geoscience.gov.au/geoportal-geologicalmaps/
#
# Running `make all` shall suffice to run this script.
# ## License
# This script is licensed CC0 by Andrew Harvey <[email protected]>
#
# To the extent possible under law, the person who associated CC0
@rbeucher
rbeucher / gist:4524c7edec124d68da3d419d0266cbf3
Created March 5, 2018 10:53 — forked from simonw/gist:7000493
How to use custom Python JSON serializers and deserializers to automatically roundtrip complex types.
import json, datetime
class RoundTripEncoder(json.JSONEncoder):
DATE_FORMAT = "%Y-%m-%d"
TIME_FORMAT = "%H:%M:%S"
def default(self, obj):
if isinstance(obj, datetime.datetime):
return {
"_type": "datetime",
"value": obj.strftime("%s %s" % (
def inside_polygon(x, y, points):
"""
Return True if a coordinate (x, y) is inside a polygon defined by
a list of verticies [(x1, y1), (x2, x2), ... , (xN, yN)].
Reference: http://www.ariel.com.au/a/python-point-int-poly.html
"""
n = len(points)
inside = False
p1x, p1y = points[0]
Empty file just for gist title

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@rbeucher
rbeucher / FK.py
Created May 14, 2019 11:06 — forked from Attila03/FK.py
Django bulk insert with Foreign Key
from stocks import wsgi
from django.core.exceptions import ObjectDoesNotExist
from api.models import Stock, Company
import csv
csvpath = r'prices.csv'
batch_size = 500
t1 = time.time()
@rbeucher
rbeucher / django-shell-notebook-setup.md
Created May 14, 2019 11:59 — forked from madyasiwi/django-shell-notebook-setup.md
Guide to setup Django-shell Jupyter notebook running in Docker container

Setting Up Django-Shell Jupyter Notebook in Docker Container

This guide assumes that your django application already running in the container.

1. Install required python packages

You will have to make sure that django-extensions and jupyter packages are installed in the container's python virtual environment.

If you need to shell into the container as root user to do this, you can do so from the host PC:

@rbeucher
rbeucher / projection.py
Created June 20, 2019 05:02 — forked from joferkington/projection.py
Spießbürger's stereonet: Fixed coordinate conversions. See http://stackoverflow.com/questions/27622007
import matplotlib
from matplotlib.axes import Axes
from matplotlib.patches import Circle
from matplotlib.path import Path
from matplotlib.ticker import NullLocator, Formatter, FixedLocator
from matplotlib.transforms import Affine2D, BboxTransformTo, Transform
from matplotlib.projections import register_projection
import matplotlib.spines as mspines
import matplotlib.axis as maxis
import matplotlib.pyplot as plt
@rbeucher
rbeucher / demo.ipynb
Created August 12, 2019 23:31 — forked from jmansour/demo.ipynb
UW28 blog post demo2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rbeucher
rbeucher / slcn_supg.ipynb
Last active August 16, 2019 07:55 — forked from julesghub/slcn_supg.ipynb
The rotating cone problem SLCN vs SUPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.