This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION truncate_all_tables() RETURNS void AS $$ | |
DECLARE | |
stmt RECORD; | |
statements CURSOR FOR SELECT tablename from pg_tables where schemaname = 'public'; | |
BEGIN | |
FOR stmt IN statements LOOP | |
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.tablename) || ' CASCADE;'; | |
END LOOP; | |
END; | |
$$ LANGUAGE 'plpgsql'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ] ; then | |
echo "Debe especificar host destino" | |
exit 1 | |
fi | |
echo "Para generar archivo con datos aleatorios:" | |
echo " $ dd if=/dev/urandom of=random bs=1024k count=512" | |
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MIDDLEWARE_CLASSES = ( | |
'django.middleware.common.CommonMiddleware', | |
'django.contrib.sessions.middleware.SessionMiddleware', | |
'django.middleware.csrf.CsrfViewMiddleware', | |
'utils.AutomaticLoginUserMiddleware', | |
'django.contrib.auth.middleware.AuthenticationMiddleware', | |
'django.contrib.messages.middleware.MessageMiddleware', | |
'django.middleware.transaction.TransactionMiddleware', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
import subprocess | |
class CustomHandler(logging.Handler): | |
def __init__(self, *args, **kwargs): | |
logging.Handler.__init__(self, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Assert migrations are applied management command. | |
""" | |
import sys | |
from optparse import make_option | |
from django.core.management.base import BaseCommand | |
from django.conf import settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# To be downloaded on /etc/yum.repos.d/riptano.repo | |
# | |
[riptano] | |
name=Riptano Repo for CentOS $releasever – $basearch | |
baseurl=http://rpm.riptano.com/community | |
failovermethod=priority | |
enabled=1 | |
gpgcheck=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
import zmq | |
def main(): | |
logging.basicConfig(level=logging.INFO) | |
msg = {'un': 'dict'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
import zmq | |
def main(): | |
logging.basicConfig(level=logging.INFO) | |
msg = {'un': 'dict'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import logging | |
import zmq | |
def main(): | |
logging.basicConfig(level=logging.INFO) | |
# Creamos contexto de ZeroMQ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core import serializers | |
class ModelOneAdmin(admin.ModelAdmin): | |
actions = ['exportar'] | |
def exportar(self, request, queryset): | |
response = HttpResponse(content_type="text/javascript") | |
response['Content-Disposition'] = 'attachment; filename=exportado.json' | |
serializers.serialize("json", queryset, stream=response, ensure_ascii=False, indent=2) | |
return response |