Los duendes de las estadísticas de WordPress.com prepararon un reporte para el año 2011 de este blog.
Aqui es un extracto
Un teleférico de San Francisco puede contener 60 personas. Este blog fue visto por 3.200 veces en 2011. Si el blog fue un teleférico, se necesitarían alrededor de 53 viajes para llevar tantas personas.
Before I start, I want to say that I bought an Arduino with the simple idea to make domotics trough a web service so if I have the possibility I’ll post all kind of advance or development with the Arduino.
Now, If you have some experience with Arduino you must know the basic example called Blink. So, for this project is basically the same example mixed with Django and Python.
I’m gonna create a Morse device controlled from a web page, where you’ll write a message in the American Standard Code for Information Interchange(ASCII) and then the Arduino is going to write this message in Morse.
Well, is the same as the blink example, so here is.
Step zero:
First of all, you need to install the Django and the firmata, with the Arduino software you don’t need to install anything because run with java
Django installation
$ tar xzvf Django-1.3.tar.gz
$ cd Django-1.3
$ sudo python setup.py install
Python firmata installation
$ tar xzvf lupeke-python-firmata-9826040.tar.gz
$ cd lupeke-python-firmata-9826040
$ sudo python setup.py install
Please make sure that the version of django and the firmata are the same.
First step:
After installing the Arduino IDE you must upload the firmata to your the Arduino board.
Open the arduino IDE, then select File->Examples->Firmata->Standard Firmata.
If you have problems uploading, be sure you have the right board and serial port selected under tools.
Second step:
Now is time to prepare the Django, we’re not gonna use database and we’re not gonna create any kind of model, so it makes work easier.
To create a new website we use the following command (where say WEBSITE_NAME replace with the name of your website)
$ django-admin.py startproject WEBSITE_NAME
Then we are gonna create a new app, to create a new app we use the following command (where say APP_NAME replace with the name of your app)
$ cd WEBSITE_NAME
$ python manage.py startapp APP_NAME
Additional you must create a folder with the index.html file this folder must go inside the WEBSITE_NAME folder and form.py file inside the APP_NAME folder.
$ mkdir -p template/APP_NAME/ & touch template/APP_NAME/index.html
$ touch APP_NAME/form.py
After those steps you must have a directory like that:
Now we are gonna edit just the following files:
settings.py
urls.py
form.py
views.py
index.html
My idea is just to explain the basic files you need to edit but you can see the full example after downloading the project.
settings.py
This file is the configuration for the Django project. We are gonna add tow lines inside TEMPLATE_DIRS and INSTALLED_APPS!
Note: DEF_FUNCTION is a function that we are going to define in views.py file
form.py
We are gonna create a Text Field using the django API
from django import forms
class SearchForm(forms.Form):
text = forms.CharField(max_length=500)
views.py
In the views.py file we’ll create the communication with the Arduino the logic of the Morse code and a render to response for the HTML request.
I decide to use threads in order to have a fast HTML response, while the Arduino works
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from forms import SearchForm
from arduino.arduinoMorse import ArduinoMorse
from threading import Thread
from firmata import *
a = Arduino('/dev/ttyUSB0')
a.pin_mode(13, firmata.OUTPUT)
def dot():
a.digital_write(13, firmata.HIGH)
a.delay(0.5)
a.digital_write(13, firmata.LOW)
a.delay(0.5)
def slash():
a.digital_write(13, firmata.HIGH)
a.delay(1.5)
a.digital_write(13, firmata.LOW)
a.delay(0.5)
...
class ArduinoMorse (Thread):
def __init__(self, text):
Thread.__init__(self)
self.text=text
def run(self):
for x in self.text :
if x=='a' or x=='A':
dot()
slash()
spaceL()
...
ELif x=='z' or x=='Z':
...
def encode(request):
if request.method == 'GET':
form = SearchForm(request.GET)
if form.is_valid():
text = form.cleaned_data['text']
arduino=ArduinoMorse(text)
arduino.start()
else:
queryset = []
form = SearchForm()
return render_to_response("arduino/index.html", {'form': form})
index.html
The index.html file is a normal HTML file but with some syntax is from Django
The Source Code – full project https://github.com/alejandrok5/arduinoWEB
The source code is licensed under GPL, don’t forget to update the settings.py file.
use to run: $ python arduinoWEB/manage.py runserver
If you want to be a good writer, you need to read books, If you want to be a good programmer, you need to read code. I heared this phrase long time ago and I feel that is true so, I always do this «Read Code». In this case I’m reading HTML5 code and today I found this site https://demos.mozilla.org/ with some HTML5 demos from Mozilla Firefox to show how HTML5 works in firefox 4, I checked the code for this example https://mozillademos.org/demos/londonproject/demo.html.
Was a really surprise saw this funny but really good License «DO WHAT THE FUCK YOU WANT TO» inside the code, the best part is that this is a web page with some videos and image moving. No external JS or CSS file. One big single HTML5 file as you can read in the license.
<!– AUTHOR: @paulrouget <paul@mozilla.com>
LICENSE: DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Everyone is permitted to copy and distribute verbatim or modifiedcopies of this license document, and changing it is allowed as longas the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSETERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO.
BLABLA: This is a web page with some videos and image moving.No external JS or CSS file. One big single HTML5 file.Now, stop reading the comments, and read the code. –>
For example I checked sentences to add videos with HTML5, I recomend you to do the same and check the full code.
Después de trabajar algunos meses en Django note uno de sus problemas mas comunes y con menos documentación en internet, Los caracteres como [ñ, a, á, é, í , ó, ú, ü, ö, …] en pocas palabras caracteres especiales
Este post tiene dos partes y tu puedes utilizar una sola o las dos según sea tu problema.
Parte-1: Si al insertar información con este tipo de caracteres mediante la interfaz de administrador te saca error, es problema con el python.
Parte-2: Si tienes información en tu base de datos MySQL con este tipo de caracteres y en la interfaz de administrador no se visualizan bien es problema con el Mysql
Parte 1 Problema con Python
Para solucionar este problema basta con edite el archivo de configuración
EN PYTHON 2.6 /usr/lib/python2.6/site.py en la linea 456 donde dice:
456: encoding = «ascii»# Default value set by _PyUnicode_Init()
Cambiamos por:
456: encoding = «utf-8»# Default value set by _PyUnicode_Init()
EN PYTHON 2.7
/usr/lib/python2.7/site.py en la linea 493 donde dice:
493: encoding = «ascii»# Default value set by _PyUnicode_Init()
Cambiamos por:
493: encoding = «utf-8»# Default value set by _PyUnicode_Init()
Guardan y listo Solucionado el primer problema!
Parte 2 Problema con MySQL
Para este problema debemos modificar la configuración directamente en las columnas de las tablas que presentan este problema para esto entramos al MySQL y escribimos
alter table TABLA1 modify COLUMNA1 blob;
alter tableTABLA2 modify COLUMNA2 blob;
alter table TABLAn modify COLUMNAn blob;
alter database NOMBREBASE charset=utf8;
alter table TABLA1 modify COLUMNA1 varchar(255) character set utf8;
alter table TABLA2 modify COLUMNA2 varchar(255) character set utf8;
alter table TABLAn modify COLUMNAn varchar(255) character set utf8;
Con esto quedaran solucionados los problemas de codificación ascii utf-8, espero les sea de ayuda!
utilizar unlinksys WRT54GLcon DD-WRT como repetidor de señal y de esta forma ampliar la zona de cobertura de la señal wireless. con una SSID propia.
Topologia
Requisitos
Router (Vecino) configurado en modo AP (access point)
Conocer el modo wireless del Router (Vecino) puede ser B, G, B+G(Mixed) para esto puedes usar wireshark en caso tal que no tengas acceso a la configuracion del router (No se esplicara en este post como hacer esto).
Conocer la Clave WEP o WAP del router vecino en caso que tenga. si no la conoces puedes usar aircrack-ng(No se esplicara en este post como hacer esto).
router linksys WRT54GLcon firmware DD-WRT(No se esplicara en este post como cambiar el firmware).
Manos a la obra!
vamos a configurar el Linksys como repetidor para tal fin vamos hacer lo sigueinte
Conectarnos al Linksys por cable UTP directo (LAN)
En el navegador web abrimos la sigueinte direccion: 192.168.1.1
Pinchamos en Setup
Nos pide usuario y clave
Escribimos el usuario y clave correspondiente (por omision es user: root , password: admin)
En Setup->Basic Setup
configuramos el servidor DHCP a activo.
signamos una IP para la nueva red (Debe ser diferente a la que nos dal el Router Vecino)
ahora vamos a wireless->Bassic Settings y configuramos:
Wireless Mode = Repeater
Wireless Network Mode=B, G, Mixed segun sea el caso del router Vecino
SSID=vecino (el ssid del router fuente)
Creamos una Virtual Interface
SSID Virtual=Mi-Hogar (el ssid que tu le quieras poner)
Lo ultimo es la seguridad inalámbrica (encriptación) en caso que aplique, para tal caso vamos a wireless->Wireless Security
Security Mode=El modo del Router Vecino (WAP/WEP)
WPA Algorithms=el metodo de encriptacion que use el router Vecino(TKIP,AES,ETC) (importante usar el mismo metodo)
WPA Shared Key=la clave del router vecino
si quieres configurar seguridad para tu conecixion lo haces en la parte de virtual interfaces
Y listo ya tenemos wifi en nuestro hogar con el patrocinio de nuestro vecino.
si tienes la oportunidad de desabilitar el firewall del router Vecino puede ser bueno para evitar problemas
# cd /usr/share/plymouth/themes/
# wget "http://wiki.sugarlabs.org/images/9/9f/Soas.tar.gz"
# tar -xvzf soas.tar.gz
# rm soas.tar.gz
# plymouth-set-default-theme soas
# /usr/libexec/plymouth/plymouth-update-initrd
Reiniciamos para que la nueva configuración tenga efecto. después de haber reiniciado en el GDM debemos de seleccionar como sección SUGAR en vez de GNOME es importante para el siguiente paso haber seleccionado SUGAR en el GDM ya que después de este paso deshabilitaremos el GDM para que simpre entre al GDM. Vamos a
# nano /etc/gdm/custom.conf
y agregamos lo siguiente:
[daemon]
TimedLoginEnable=true
AutomaticLoginEnable=true
AutomaticLogin=username
TimedLogin=username
TimedLoginDelay=0
Actualmente muchos laptops traen lector de huella y obvio es un nuevo hardware para linux afortunadamente hay un buen proyecto que ya tiene su tiempo trabajando con esto.
Esto se hace para que al escáner la huella y no la reconozca pida la contraseña en debian esta función queda configurada solamente para el root si queremos que quede para el usuario normal hay que hacer lo siguiente:
En algunos casos al instalar Amsn no detecta correctamente el tls o por el contrario no se encuentra instalado a pesar de que existe una aplicación dentro de este programa que supuestamente soluciona el problema, entonces para la eliminar este inconveniente se instala los siguiente
# aptitude install tcltls
después de ello modificamos el archivo /usr/lib/tls1.50/pkgIndex.tcl
# nano /usr/lib/tls1.50/pkgIndex.tcl
y modificamos la linea que dice:
package ifneeded tls 1.5
por:
package ifneeded tls 1.50
Problemas con el sonido
En algunas distribuciones es posible que los sonidos de diferentes aplicaciones no funcionen simultáneamente, debido a que no están instaladas las librerías del ALSA o en su defecto no lo tienen como salida de sonido, por lo tanto para solucionar este problema se instala lo siguiente:
# apt-get install libesd-alsa0
Sin embargo esta solución es un poco extrema ya que Amsn posee una manera mas fácil de solucionar este problema y es de la siguiente forma:
Nos dirigimos a Cuenta
>Preferencias
> Otros
y en la parte de servidor de sonido elegimos la opción usar un comando o programa distinto, por consiguiente la opción por default se encuentra:
si alguna ves has modificado el fichero /etc/apt/sources.list en debian o ubuntuy al hacer el update te encuentras con algunos de estos errores.
W: GPG error: http://sitioX.org sitioX Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY xxxxxxxxxxxxxxx
W: You may want to run apt-get update to correct these problem
W: There is no public key available for the following key IDs: xxxxxxxxxxxxxxx