Skip to content

Instantly share code, notes, and snippets.

View rbeucher's full-sized avatar

Romain Beucher rbeucher

View GitHub Profile
@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()

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

Empty file just for gist title
@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" % (
@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 <andrew.harvey4@gmail.com>
#
# To the extent possible under law, the person who associated CC0