Skip to content

Instantly share code, notes, and snippets.

View gollum23's full-sized avatar
:octocat:
Learning all days

Diego Forero gollum23

:octocat:
Learning all days
View GitHub Profile
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

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

  • virtualenv
  • Django
  • nginx
  • uwsgi
# 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
@gollum23
gollum23 / gist:0b861de47ced51f8a50e
Last active July 6, 2019 20:24
Get last part URL with php
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
@gollum23
gollum23 / patch.py
Last active August 29, 2015 14:10 — forked from dequis/patch.py
#!/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
@gollum23
gollum23 / myapp.conf
Created December 5, 2014 15:02
Archivo de configuración Proxy con Apache curso Admin de servidores y dev ops mejorandola
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName mejorandola.vac.io
ProxyRequests Off
ProxyVia Off
ProxyErrorOverride Off
ProxyPreserveHost On
<Proxy *>
Order deny, allow
@gollum23
gollum23 / .gitconfig
Last active August 29, 2015 14:14 — forked from pksunkara/config
[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 ##