Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
Esta son aplicaciones de django muy utiles, para como dice la filosofia de Instagram no reinventar la rueda :). | |
django-mingus | |
django-ratings | |
django-ajax-validation | |
django-google-analytics |
# Create sudo user | |
adduser <user> | |
usermod -a -G sudo <user> | |
logout | |
# Update and clean | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get dist-upgrade | |
sudo apt-get autoremove |
from django.db import models | |
class MyModel(models.Model): | |
myimage = models.ImageField( | |
verbose_name = 'Imagen', | |
upload_to='mis_imagenes' | |
) | |
.... otros campos del modelo |
function uf_getLastDir($sUrl) | |
{ | |
$sPath = parse_url($sUrl, PHP_URL_PATH); // parse URL and return only path component | |
$aPath = explode('/', trim($sPath, '/')); // remove surrounding "/" and return parts into array | |
end($aPath); // last element of array | |
if (is_dir($sPath)) // if path points to dir | |
return current($aPath); // return last element of array | |
if (is_file($sPath)) // if path points to file | |
return prev($aPath); // return second to last element of array | |
return false; // or return false |
#!/usr/bin/env python | |
""" | |
MSN ApplicationId patcher for pidgin/bitlbee/whatever | |
(because you're too lazy to rebuild the whole thing.) | |
Usage examples: | |
python patch.py /usr/sbin/bitlbee | |
python patch.py /usr/lib/purple-2/libmsn.so |
<VirtualHost *:80> | |
ServerAdmin [email protected] | |
ServerName mejorandola.vac.io | |
ProxyRequests Off | |
ProxyVia Off | |
ProxyErrorOverride Off | |
ProxyPreserveHost On | |
<Proxy *> | |
Order deny, allow |
[user] | |
name = Pavan Kumar Sunkara | |
email = [email protected] | |
[core] | |
editor = vim | |
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol | |
excludesfile = ~/.gitignore | |
[sendemail] | |
smtpencryption = tls | |
smtpserver = smtp.gmail.com |
""" | |
Two things are wrong with Django's default `SECRET_KEY` system: | |
1. It is not random but pseudo-random | |
2. It saves and displays the SECRET_KEY in `settings.py` | |
This snippet | |
1. uses `SystemRandom()` instead to generate a random key | |
2. saves a local `secret.txt` |
# -*- encoding: utf-8 -*- | |
###################################################################################################### | |
## ## | |
## SCRIPT EN PYTHON PARA EL RESPALDO DE BASES DE DATOS POSTGRES ## | |
## ## | |
## Almacenará tres tipos de copia: ## | |
## - Diarias: el sistema realizará una copia diaria por base de datos y eliminará aquellas ## | |
## que tengan más de N_DAYS_AGO_DIARY_BACKUP días de antiguedad ## | |
## - Semanales: el sistema realizará una copia semanal cada viernes de cada base de datos y ## |