Skip to content

Instantly share code, notes, and snippets.

@maikkoko
maikkoko / validators.py
Created February 28, 2019 05:36 — forked from jrosebr1/validators.py
Validator for files, checking the size, extension and mimetype for Django.
# @brief
# Performs file upload validation for django. The original version implemented
# by dokterbob had some problems with determining the correct mimetype and
# determining the size of the file uploaded (at least within my Django application
# that is).
# @author dokterbob
# @author jrosebr1
import mimetypes
@maikkoko
maikkoko / heroku_database_copy.md
Created February 7, 2018 07:12 — forked from kosyfrances/heroku_database_copy.md
To copy heroku database from one app to another and from local to heroku

To copy database from one heroku app to another -

heroku pg:backups capture [database_name]
heroku pg:backups restore $(heroku pg:backups public-url --app source_app) DATABASE_URL --app target_app

You can refer to https://devcenter.heroku.com/articles/heroku-postgres-backups for more information.

To copy database from local to heroku - Dump your local database in compressed format using the open source pg_dump tool: PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump where myuser is your database username and mydb is the database name.

Mongo DB Backup

Source: liberseeds.ca

Create Backup

$ docker run --rm --link witb_mongo_1:mongo -v $(pwd)/witb-mongo-dump:/dump mongo bash -c 'mongodump --host $MONGO_PORT_27017_TCP_ADDR'

Restore Backup

// Given 5 Points
const coordsA = [
{x: 589.4542, y: 1250.2301},
{x: 682.36816, y: 487.62726},
{x: 904.16284, y: 836.44556},
{x: 373.65402, y: 839.444},
{x: 724.32935, y: 710.51117}
]
// Get SSS Of Triangle