Skip to content

Instantly share code, notes, and snippets.

View guerrerocarlos's full-sized avatar
:octocat:
On shoulders of giants.

Carlos Guerrero guerrerocarlos

:octocat:
On shoulders of giants.
View GitHub Profile
@guerrerocarlos
guerrerocarlos / enviar_correo.py
Created March 7, 2012 20:36
send_email.py function
# -*- coding: utf-8 -*-
import smtplib
from email.mime.text import MIMEText
def enviar_correo(asunto,texto,destinatario,origen="[email protected]"):
msg = MIMEText(texto)
# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = asunto
@guerrerocarlos
guerrerocarlos / django-fastcgi
Created July 27, 2012 23:08
init.d script for easy Django instances start,stop,restart. to INSTALL: just copy in /etc/init.d and run 'update-rc.d django-fastcgi defaults'
#! /bin/sh
### BEGIN INIT INFO
# Provides: FastCGI servers for Django
# Required-Start: networking
# Required-Stop: networking
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description: Django, in order to operate with FastCGI, must be started
# in a very specific way with manage.py. This must be done
@guerrerocarlos
guerrerocarlos / nginx-fastcgi-app
Created July 27, 2012 23:40
NGINX config file for fastcgi Django app
server{
server_name www.ejemplo.net ejemplo.net;
location / {
# host y puerto para servicio fastcgi
fastcgi_pass 127.0.0.1:8080;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
@guerrerocarlos
guerrerocarlos / htpasswd.py
Created July 27, 2012 23:55
Python script for generating htaccess passwords
#!/usr/bin/python
"""Replacement for htpasswd"""
# Original author: Eli Carter
import os
import sys
import random
from optparse import OptionParser
# We need a crypt module, but Windows doesn't have one by default. Try to find
@guerrerocarlos
guerrerocarlos / app_with_auth
Created July 28, 2012 00:01
nginx fastcgi with auth
server{
server_name www.ejemplo.com ejemplo.com;
auth_basic "Acceso restringido, solo permitido mediante credencial";
auth_basic_user_file /var/www/archivo.access;
location / {
# host and port to fastcgi server
fastcgi_pass 127.0.0.1:8080;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
@guerrerocarlos
guerrerocarlos / php-fastcgi
Created July 30, 2012 15:55
fastcgi php script for NGINX
#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
@guerrerocarlos
guerrerocarlos / html_copy_button
Created August 2, 2012 17:42
clippy html object
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
width="110"
height="14"
id="clippy" >
<param name="movie" value="/flash/clippy.swf"/>
<param name="allowScriptAccess" value="always" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param NAME="FlashVars" value="text=#{text}">
<param name="bgcolor" value="#{bgcolor}">
@guerrerocarlos
guerrerocarlos / supervisord
Created August 6, 2012 16:43
supervisord init.d file
#! /bin/bash -e
SUPERVISORD=/usr/local/bin/supervisord
PIDFILE=/tmp/supervisord.pid
OPTS="-c /etc/supervisord.conf"
test -x $SUPERVISORD || exit 0
. /lib/lsb/init-functions
@guerrerocarlos
guerrerocarlos / .vimrc
Created August 9, 2012 16:37
Some vim tunning
syntax on
filetype indent plugin on
au FileType python setlocal tabstop=8 expandtab shiftwidth=4 softtabstop=4
"F2 activa y desactiva el auto-indent para poder pegar sin que se dañe el
""contenido
nnoremap <F2> :set invpaste paste?<CR>
nnoremap <F8> :tabn<CR>
nnoremap <F7> :tabp<CR>
set pastetoggle=<F2>
@guerrerocarlos
guerrerocarlos / whoisrobot.py
Created August 21, 2012 06:46
Python Whois Robot
import itertools
import subprocess
archivo = open("disponibles","a")
for LENGTH in range(3,8):
a = itertools.product("ABCDEFGHIJKLMNOPQRSTUVWXYZ",repeat=LENGTH)
for each in a:
domain = "".join(each)+".com"
print domain