Redmine for heroku


Image
Redmine version: 2.5.1 (2014-03-29)

Redmine

Redmine is a flexible project management web application. Written using the Ruby on Rails framework, it is cross-platform and cross-database.

Redmine-for-heroku

Redmine for heroku is a Redmine fork with settings for heroku, amazon s3 for upload files and madrill for mail system.

Installation

0. git clone git@github.com:alejandrok5/Redmine-for-heroku.git
1. bundle install --without development test
2. rake generate_secret_token
3. heroku create NAME_FOR_YOUR_APP
4. git push heroku master
5. heroku run rake db:migrate RAILS_ENV="production"
6. heroku addons:add mandrill
7. heroku config:add AWS_ACCESS_KEY_ID="XXXXXXXXX"
8. heroku config:add AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXX"
9. heroku config:add S3_BUCKET_NAME="XXXXXXX"
10. heroku run RAILS_ENV=production rake redmine:load_default_data

 

Anuncio publicitario
Ajustes de privacidad

Arduino with Django and Python


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.

What you need to know?

  • Python
  • Django
  • Arduino

What you need to download?

The circuit

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!

...
TEMPLATE_DIRS = (
    "/home/YOUR_USER/WEBSITE_NAME/template"
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    ...
    'WEBSITE_NAME.APP_NAME',
)

urls.py

The URL declarations for this Django project; a «table of contents» of your Django-powered site. edit your urls.py like this

...
urlpatterns = patterns('APP_NAME.views',
    (r'^$','DEF_FUNCTION'),
)

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

<html>
    <body>
        <h1>Arduino Morse</h1>
        <form action="." method="get">
            {{ form.text }}
            <input type="submit" value="Encode" />
        </form>
    </body>
</html>

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

HTML5 – the best way to learn it


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.

 

 

Solucionar problemas con Django y la codificación ascii utf-8


djangoDespué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 table TABLA2 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!

Linksys WRT54GL con DD-WRT como repetidor de señal


Objetivo

utilizar un linksys 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

topología Repetidor

Requisitos

  1. Router (Vecino) configurado en modo AP (access point)
  2. 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).
  3. 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).
  4. 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)

Pantallazo

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)

Pantallazo-1

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

Pantallazo-2

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

Sugarizando fedora


Requerimientos previos
Fedora 11 instalado


El objetivo de este documento es explicar como configurar Fedora-11 para que tenga todo el aspecto de Sugar on a Stick-Strawberry

Instalar Sugar

# yum install sugar-*

Activar el clic del touchpad

# cp /usr/share/hal/fdi/policy/20thirdparty/10-synaptics.fdi /usr/share/hal/fdi/policy/

En el fichero /usr/share/hal/fdi/policy/10-synaptics.fdi lo editamos con el comando

# nano /usr/share/hal/fdi/policy/10-synaptics.fdi

Y remplazamos todo el contendió del fichero por este

<deviceinfo version="0.2">
 <device>
   <match key="info.capabilities" contains="input.touchpad">
            <merge key="input.x11_options.TapButton1" type="string">1</merge>
            <merge key="input.x11_options.TapButton2" type="string">3</merge>
            <merge key="input.x11_options.TapButton3" type="string">2</merge>
            <merge key="input.x11_driver" type="string">synaptics</merge>
   </match>
 </device>
</deviceinfo>

Bootloader tipo soas

# 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

Como configurar el lector de huella o lector biométrico


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.

sitio web: http://reactivated.net/fprint/wiki/Main_Page
el hardware soportado específicamente es este:

  • aes1610: Authentec AES1610
  • aes2501: Authentec AES2501
  • aes4000: AuthenTec AES4000
  • fdu2000: SecuGen FDU 2000
  • upeksonly: UPEK TouchStrip sensor-only
  • upektc: UPEK TouchChip
  • upekts: UPEK TouchStrip with biometric co-processor
  • uru4000: Digital Persona U.are.U 4000/4000B
  • vcom5s: Veridicom 5thSense

para los que lo quieran configurar esto a pesar que no sirve para nada según vimos en cazadores de mitos Episodio 59 – “Crimes and Myth-Demeanors 2”

podemos hacer lo siguiente.

instalar las dependencias

apt-get install libmagick9

Descargamos los paquetes y hacemos


$ wget "http://legacy.madman2k.net/files/fprint-packages.tar"
$ tar -xvzf fprint-packages.tar
$ cd fprint-packages/
$ su
# dpkg -i *.deb

Editamos el fichero /etc/pam.d/common-auth

# nano /etc/pam.d/common-auth

Agregamos estas lineas

auth sufficient pam_fprint.so
auth required pam_unix.so nullok_secure

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:

touch /etc/udev/rules.d/fprint.rules
nano /etc/udev/rules.d/fprint.rules

y escribimos:

SUBSYSTEM=="usb_device", MODE="0664", GROUP="plugdev"

debemos conceder permisos completos de lectura y escritura a el fichero .fprint

# chmod 777 -R ~/.fprint

miramos que el usuario este en el grupo de plugdev

# cat /etc/group |grep 46

debe salir algo como

plugdev:x:46:usuario1,usuario2,...,usuario_n

caso dado que no salga el usuario lo agregamos.

AMSN 0.97 desde CVS y Solucionado Errores


dejo acá un script para que puedan probar la versión de CVS para Amsn, recuerden es necesario correrlo como root funciona en debian y ubuntu 😀

¿Este script que hace?

  • Instala las posibles dependencias que vaya a necesitar y las herramientas necesarias para compilar todo correctamente.
  • Descarga y compila las últimas versiones de tcl8.5 y tk8.5, ya que son necesarias para tener el Antialiasing (alisado de fuentes).
  • Descarga la última versión en desarrollo de aMSN y la compila.

Descargar script

amsn_beta.sh

Solución de problemas

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:

play$sound

entonces hay que cambiarla por:

aplay$sound

Importar un mirror al anillo de claves


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

este documento es para ti.
¿que debemos hacer?

#gpg --keyserver wwwkeys.eu.pgp.net --recv-keys xxxxxxxxxxxxxxx
#gpg --armor --export xxxxxxxxxxxxxxx | apt-key add -

Donde están las xxxxxxxxxxxxxxx pones el numero de la llave que nos da el error que es algo como:07DC563D1F41B907

y listo.