Skip to content

Instantly share code, notes, and snippets.

@fabiopiovam
fabiopiovam / readme.md
Last active February 20, 2019 07:06
Django deploy using Nginx + Gunicorn + Supervisor

Django deploy using Nginx + Gunicorn + Supervisor

Introduction

This implementation was made using Debian 8.

Requirements

  • Install packages:

    aptitude install nginx supervisor
    
@fabiopiovam
fabiopiovam / validators.py
Created March 17, 2017 22:31 — forked from dokterbob/validators.py
Validator for files, checking the size, extension and mimetype.
from os.path import splitext
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import filesizeformat
class FileValidator(object):
"""
Validator for files, checking the size, extension and mimetype.
@fabiopiovam
fabiopiovam / validators.py
Created March 17, 2017 22:30 — 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
@fabiopiovam
fabiopiovam / instructions.txt
Created April 12, 2015 23:20
Running Multiple Versions of XAMPP on Linux
1. Download a version of XAMPP:
- latest version: https://www.apachefriends.org/pt_br/index.html
- older version: http://sourceforge.net/projects/xampp/files/
Consult the best version 4u: http://code.stephenmorley.org/articles/xampp-version-history-apache-mysql-php/
2. Install xampp:
- To older versions:
Use the following command and extract the downloaded distribution into /opt/xampp directory:
sudo tar xvfz xampp-linux-x.x.x.tar.gz -C /opt
/* ===========================================================
* bootstrap-tooltip.js v2.2.2
* http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame
* ===========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
/* ===========================================================
* bootstrap-popover.js v2.0.1
* http://twitter.github.com/bootstrap/javascript.html#popovers
* ===========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@fabiopiovam
fabiopiovam / comments.php
Created March 5, 2015 14:16
Hierarchy commenting system php using self-relation
<?php
/*
* Solution to list with hierarchy using self-relation
* Found here: http://stackoverflow.com/questions/7730889/hierarchy-commenting-system-php
* */
// getting the comments from mysql, I'm obviously not bothering
// to check the return value, but in your code you should do it
$result = mysqli_query("SELECT id, parent FROM comments WHERE thread_id = 123");
@fabiopiovam
fabiopiovam / backup_files.sh
Last active August 29, 2015 14:12
Backup into removable device using rsync
#!/bin/bash
############################################################################################
##### Script created by Romulo Grandini with my changes ####################################
##### (read the orginal script in 'backup_files_original.sh' file) #########################
##### Publication: http://www.vivaolinux.com.br/script/Backup-em-HD-Externa-com-Rsync #####
############################################################################################
# USE
# ./backup_files.sh SRC DEST
@fabiopiovam
fabiopiovam / project_name.wsgi
Created October 5, 2014 23:30
Deployment config of Django project using Apache
import os, sys, site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('PATH_TO_YOUR_PROJECT/venv/local/lib/python2.7/site-packages')
sys.path.append('PATH_TO_YOUR_PROJECT')
os.environ['DJANGO_SETTINGS_MODULE'] = 'PROJECT_NAME.settings'
os.environ['PYTHON_EGG_CACHE'] = 'PATH_TO_YOUR_PROJECT/.python-egg'
@fabiopiovam
fabiopiovam / postgres_backup.sh
Created October 5, 2014 03:39
Postgres 9.1 backup script to Cron
#!/bin/bash
# script by http://www.emidioleite.com.br/um-simples-script-para-backup-de-bases-postgres-sql-usando-linux/
# thanks!
# Location to place backups.
backup_dir="$1"
#String to append to the name of the backup files
backup_date=`date +%Y-%m-%d`