import argparse | |
import csv | |
def split_csv(filename): | |
""" | |
Splits a CSV file into two files with approximately half the rows each. | |
Args: | |
filename: The path to the CSV file to split. | |
""" |
The following instructions describe a set of processes allowing you to run Django database migrations against a production database without having to bring the web service down.
Note that in the below instructions, migrations are all run manually at explicit points, and are not an automatic part of the deployment process.
- Make the model or column addition in your code.
A git choose-your-own-adventure!
This document is an attempt to be a fairly comprehensive guide to recovering from what you did not mean to do when using git. It isn't that git is so complicated that you need a large document to take care or your particular problem, it is more that the set of things that you might have done is so large that different techniques are needed depending on exactly what you have done and what you want to have happen.
Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create
. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.
Note that on Heroku, you must always use master
as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch
seen below (in this example, we push the local staging
branch to the master
branch on heroku.
$ git remote add staging https://git.heroku.com/staging-app.git
import jwt | |
from django.conf import settings | |
from django.contrib.auth.models import User | |
from rest_framework import exceptions | |
from rest_framework.authentication import TokenAuthentication | |
class JSONWebTokenAuthentication(TokenAuthentication): |
require 'active_support/testing/time_helpers' | |
# the class below could have any name | |
class Tempo | |
include ActiveSupport::Testing::TimeHelpers | |
end | |
# any desidered date | |
desired_date = Date.today - 2.days |
#!/bin/sh | |
# This is to automate the process of db snapshots with | |
# https://github.com/fastmonkeys/stellar | |
# read current git branch name | |
BRANCH=$(git rev-parse --abbrev-ref HEAD ) | |
if stellar list | grep $BRANCH; then | |
# checkout the existing db snapshot | |
stellar restore $BRANCH |