Dump existing data:
python3 manage.py dumpdata > datadump.json
Change settings.py to Postgres backend.
Make sure you can connect on PostgreSQL. Then:
| # THIS PROJECT IS AN EXAMPLE APP. SOME CODE MAY NOT BE ACTUALLY USEFUL | |
| # FOR DEMONSTRATION PURPOSES ONLY | |
| # YOUR MILEAGE MAY VARY | |
| # Requirements are Flask, Flask-WTF, Flask-SQLAlchemy | |
| import os | |
| from flask import (Flask, | |
| Blueprint, | |
| redirect, |
| [ | |
| { | |
| "name": "Aboleth", | |
| "meta": "Large aberration, lawful evil", | |
| "Armor Class": "17 (Natural Armor)", | |
| "Hit Points": "135 (18d10 + 36)", | |
| "Speed": "10 ft., swim 40 ft. ", | |
| "STR": "21", | |
| "STR_mod": "(+5)", | |
| "DEX": "9", |
| package main | |
| import ( | |
| "fmt" | |
| "github.com/spf13/viper" | |
| ) | |
| // Create private data struct to hold config options. | |
| type config struct { |
| package main | |
| // This is an example of a resilient service worker program written in Go. | |
| // | |
| // This program will run a worker every 5 seconds and exit when SIGINT or SIGTERM | |
| // is received, while ensuring any ongoing work is finished before exiting. | |
| // | |
| // Unexpected panics are also handled: program won't crash if the worker panics. | |
| import ( |
| // http://en.wikipedia.org/wiki/Pairing_function | |
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| func InvertedCantorPairing(z int) (int, int) { | |
| w := int(math.Floor((math.Sqrt(float64(8*z+1)) - 1) / 2)) |
| // Embedded in this article https://medium.com/p/c98e491015b6 | |
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "time" | |
| "github.com/graph-gophers/graphql-go" |
| // CSVToMap takes a reader and returns an array of dictionaries, using the header row as the keys | |
| func CSVToMap(reader io.Reader) []map[string]string { | |
| r := csv.NewReader(reader) | |
| rows := []map[string]string{} | |
| var header []string | |
| for { | |
| record, err := r.Read() | |
| if err == io.EOF { | |
| break | |
| } |
| # -*- coding: utf-8 -*- | |
| import Image | |
| def resize_and_crop(img_path, modified_path, size, crop_type='top'): | |
| """ | |
| Resize and crop an image to fit the specified size. | |
| args: | |
| img_path: path for the image to resize. |
| import "math" | |
| // haversin(θ) function | |
| func hsin(theta float64) float64 { | |
| return math.Pow(math.Sin(theta/2), 2) | |
| } | |
| // Distance function returns the distance (in meters) between two points of | |
| // a given longitude and latitude relatively accurately (using a spherical | |
| // approximation of the Earth) through the Haversin Distance Formula for |