Skip to content

Instantly share code, notes, and snippets.

Marco Lavagnino marco-lavagnino

  • Argentina
Block or report user

Report or block marco-lavagnino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@marco-lavagnino
marco-lavagnino / storages.py
Last active Jan 18, 2020
GoogleCloudStorage allows a single default location for all the files. Using this, you can separate media and static files.
View storages.py
"""
Modify django-storages for GCloud to set static, media folder in a bucket
"""
from storages.backends.gcloud import GoogleCloudStorage
class GoogleCloudMediaStorage(GoogleCloudStorage):
"""
GoogleCloudStorage suitable for Django's Media files.
"""
@marco-lavagnino
marco-lavagnino / cloudbuild.yaml
Created Jan 18, 2020
sample Cloud Build configuration for a Django Project
View cloudbuild.yaml
steps:
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/${_ENV_NAME}:$COMMIT_SHA", "."]
id: build_image
- name: "gcr.io/cloud-builders/docker"
args:
- "run"
- "--env"
- "GS_BUCKET_NAME=${_GS_BUCKET_NAME}"
- "--network=cloudbuild"
@marco-lavagnino
marco-lavagnino / Dockerfile
Created Jan 18, 2020
sample Dockerfile for a Django project
View Dockerfile
FROM python:3.6-slim
RUN apt-get update && apt install -y libjpeg-dev libpq-dev zlib1g-dev gcc
ENV APP_HOME /src
WORKDIR $APP_HOME
COPY . ./
RUN pip install -r requirements.txt
View cors-json-file.json
[{
"origin": ["*mysite.com/"],
"responseHeader": ["Content-Type"],
"method": ["GET", "HEAD"],
"maxAgeSeconds": 3600
}]
@marco-lavagnino
marco-lavagnino / settings.py
Last active Jan 18, 2020
Settings.py fragment to enable Django Storages config from environment
View settings.py
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Gcloud Bucket storage
if os.getenv('GS_BUCKET_NAME'):
DEFAULT_FILE_STORAGE = 'mysite.storages.GoogleCloudMediaStorage'
@marco-lavagnino
marco-lavagnino / settings.py
Last active Jan 18, 2020
Settings.py fragment to enable Django DB config from environment
View settings.py
if os.getenv('DB_HOST'):
default_db = {
'ENGINE': 'django.db.backends.postgresql',
'HOST': os.environ['DB_HOST'],
'PORT': 5432,
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASSWORD'],
}
else:
@marco-lavagnino
marco-lavagnino / setup_amazon.sh
Last active Nov 13, 2017
Subset of my other script to setup a new computer.
View setup_amazon.sh
# tools
sudo apt-get update
sudo apt-get install -y git zsh vim language-pack-en
# zsh
sudo chsh -s $(which zsh) $(echo $USER)
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
wget https://gist.githubusercontent.com/marco-lavagnino/dceaa26b69db3d3362b6fed13718cd93/raw/517facb30ef981e999a9365daedeba0e28d5e4ce/.zpreztorc
cp .zprezto/runcoms/zshrc .zshrc
@marco-lavagnino
marco-lavagnino / setup.sh
Last active Nov 7, 2017
This installs most important things on a new computer.
View setup.sh
mkdir ~/repos
# tools
sudo apt-get update
sudo apt-get install -y git
# zsh/terminator
sudo apt-get install -y terminator zsh vim
sudo chsh -s $(which zsh) $(echo $USER)
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
View .zpreztorc
zstyle ':prezto:*:*' color 'yes'
zstyle ':prezto:load' pmodule \
'environment' \
'terminal' \
'history' \
'directory' \
'spectrum' \
'python' \
'utility' \
You can’t perform that action at this time.