Written by:
daniel

July 21, 2010
Virtual Private Networks can be very handy, but even with easy-rsa scripts it’s a little time taking to add new computers to the network, especially if you frecuently add new machines.
With this handy php script you can automate this process a little bit - you could for example publish it on a web server and then make customers to connet to it in order to generate their access keys and configuration (It would be a good idea to password protect it first
)
You will need to generate the CA key and certificate first before you will be able to use it.
Check this guide on how to do it:
http://www.openvpn.net/index.php/open-source/documentation/howto.html#pki
and here goes the code:
//this should be unique for each client
$commonName = 'ayd-test';
$tmpDir = '/tmp/openvpn-'.time();
$dn = array(
"countryName" => 'ES',
"stateOrProvinceName" => 'Baleares',
"localityName" => 'Palma de Mallorca',
"organizationName" => 'AYD',
"organizationalUnitName" => 'AYD test',
"commonName" => $commonName,
"emailAddress" => 'test@test.com'
);
$privkeypass = null;
$numberofdays = 3650;
//load previously generated server private key
$fp=fopen("./ca.key","r");
$caData = fread($fp,8192);
fclose($fp);
// $passphrase is required if your key is encoded (suggested)
$caKey = openssl_get_privatekey($caData);
//load previously generated server cartificate
$fp=fopen("./ca.crt","r");
$caCrt = fread($fp,8192);
fclose($fp);
//--------------- generating a new user cert and key -------------
// create private key for the user
$privkey = openssl_pkey_new();
openssl_pkey_export($privkey, $privatekey, $privkeypass);
//make certificate request for the user
$csr = openssl_csr_new($dn, $privatekey);
openssl_csr_export($csr, $csrStr);
//sign certificate request with the CA key
$sscert = openssl_csr_sign($csrStr, $caCrt, $caKey, $numberofdays);
openssl_x509_export($sscert, $publickey);
//create a tmp dir
mkdir($tmpDir);
//write a private key
echo "writting private key...\n";
echo $privatekey; // Will hold the exported PriKey
file_put_contents($tmpDir."/".$commonName.'.key', $privatekey);
//write an user cert
echo "writting ceritifate...\n";
echo $publickey; // Will hold the exported Certificate
file_put_contents($tmpDir."/".$commonName.'.crt', $publickey);
//copy server certificate (we need it for openvpn config)
copy('./ca.crt', $tmpDir.'/ca.crt');
//generate and write openvpn config file
//edit data for according to your configuration
$config = "client
dev tun
tun-mtu 1200
proto udp
remote yourserver.com 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca /etc/openvpn/server_ca.crt
cert /etc/openvpn/$commonName.crt
key /etc/openvpn/{$commonName}.key
comp-lzo
verb 5
";
file_put_contents($tmpDir.'/server.conf', $config);
echo "generated files are in: ".$tmpDir;
you can then copy the generated files to your /etc/openvpn directory and you should be able to connect to the vpn.
Posted in linux, php
No Comments »
Written by:
daniel

May 19, 2010
This is some good news for the cross-browser video support in html5. As you might already know, there is a video tag, that allows videos to be played in browsers without any third party plugins (like flash player, for example).
The problem was that browser developers could not agree on which codec should be used for video encoding. There is the h263 mp4 codec used by many vendors, and which offers a ver good quality and a small size, but it’s protected by patents, which makes it a no-option for many people. (Btw. did you know that most of cameras, even the “professional” ones that allow to record natively in mp4, don’t allow for professional usage of the recorded videos by licence?)
On the other hand there is an open source theora video codec which offers quite good quality (we used it for www.tvmallorca.net project) and it seems not to be limited by any license (although some vendors like apple or microsoft say otherwise)
This gives a big headache to us, developers, because we need to prepare content in many different formats to be sure everyone will be able to watch it. Not fun at all!
Luckily, google released today an open web media project, which includes they recently aqqured vp8 codec. Will this finally bring the html5 video to the masses? Let’s hope so. Youtube, Chrome browser and Firefox already support this codec in their nightly builds, and hopefuly other vendors will jump on the wagon soon.
http://www.webmproject.org
Posted in linux, mobile
No Comments »
Written by:
daniel

April 18, 2010
http://apirocks.com/html5/html5.html#slide1
(check it out in a chrome browser - which seems to have most features implemented)
Posted in random
No Comments »
Written by:
daniel

February 18, 2010
éste es uno de los nuevos proyectos más prometedores que he visto últimamente. es un servidor de javascript, basado en la misma idea de callbacks que tiene por ejemplo Twisted de python.
según varias fuentes el servidor es rápido, permite muchos usuarios concurrentes y, lo que no es sin importancia, en muchos casos permite reusar el código js que uno tiene por allí, lo que puede accelerar bastante el desarrollo. hay bastante librerías externas en github.
combinado con xmpp, websockets o incluso cometm abre muchas posibilidades de crear aplicaciones web interactivas de nueva generación.
muy recomendable!
www.nodejs.org
Posted in random
No Comments »
Written by:
daniel

November 17, 2009
Hace algún tiempo escribí como configurar Kaffeine para poder recibir IB3 usando TDT.
Desde hace unos días otra televisión local, TVMallorca (a la cual, por cierto, ayudamos en su día configurar la emisión a través de internet), está emitiendo en el formato digital.
Desgraciadamente, Kaffeine, al no tener configuradas las frecuencias, no encuentra este canal. Para remediarlo hay que añadir en el archivo (yo uso ubuntu, pero debe ser algo parecido en otras distribuciones):
~/.kde/share/apps/kaffeine/dvb-t
la siguiente línea:
T 602000000 8MHz 2/3 NONE QAM64 8k 1/4 NONE # TVM
Ahora reiniciamos el Kaffeine y voilá! El programa ya encuentra este canal y algunos más. (Ahora tengo 29 canales de tv + 15 de radio).
Posted in linux
No Comments »
Written by:
daniel

November 12, 2009
Estamos tan rodeados por el software libre y tan acostrumbrados a estar acompañados por él, que casi no nos damos cuenta de la cantidad de open source en todos los sitios. Como el aire, es esencial para la vida, pero ¿quién lo habrá notado antes de verse privado de él?
Quizás esa es la razón por la cuál hay muchas confusiones a la hora de pensar en un modelo de negocio basado en el open source. Aunque, no hay que olvidarse que la gran mayoría de empresas ha podido existir únicamente gracias a ello (y en muchos casos sin darse cuenta).
Hoy en día, (casi) cualquiera puede iniciar su negocio con un coste cercano a cero, por no tener que pagar licencias de todo tipo: sistemas, software etc.. Pero bueno, como ya estamos acostumbrados a respirar el software abierto como si fuera el aire, pocos se dan cuenta que lo que ahora viene gratis antes costaba mucho dinero. Es un ejemplo tópico decir que Google no habría podido sostenerse económicamente, si tuviese que desembolsar los costes de licencias para sus miles de servidores.
OK! Pero ¿dónde está el negocio para una empresa pequeña de open source? Siendo un cliente final, seguro que puedo aprovecharme y ahorrar costes, pero ¿cómo puede sobrevivir una empresa que crea código libre? Antoni Aloy y Jordi Esteve, los ponentes de la III Jornada sobre Soluciones Open Source para PYMES intentarón contestar a esta pregunta.
Una respuesta (obvia) es: “servicios”. Si el software en sí, puede ser gratis (aunque no tiene por qué serlo) - todo lo que lo rodea, puede ser una fuente potencial de ingresos. Consultoría, personalización, mantenimiento, venta de hardware y atención al usuario pueden ser útiles para nuestros clientes.
No hay que olvidar que gracias al acceso al código fuente, podemos fácilmente construir sobre una base sólida, creando un valor añadido, por el cual muchos clientes estarán dispuestos a pagar. Para una empresa de software privativo, que tiene que crearlo todo de cero, será muy difícil competir con nosotros. (Luego, ¿por qué no?, podemos devolverlo a la comunidad
)
La comunidad, es otro aspecto muy importante del éxito (si no el más importante). Muchos colaboradores externos, pueden ayudarnos crear un producto mejor que si lo tuvieramos que desarrollar con sólo nuestro propio esfuerzo.
Como vemos, en el mundo de software abierto la clave de conseguir beneficios es principalmente de bajar los gastos y ser más competitivo sin comprometer la calidad.
Con esto, el nivel de entrada para clientes finales puede ser (y normalmente es) menor, con lo cual podemos ganar un numero mayor de ventas al hacer el producto más accesible.
Una cosa, que en los tiempos de crisis, no es poco.
Una joya open source de la conferencia: OpenERP
Veo un mundo de oportunidades 
Posted in linux, negocio
No Comments »
Written by:
daniel

October 24, 2009
Como empresario, siempre he sido en contra de las ayudas financieras directas a los desempleados, ya que considero (y mi experiencia lo afirma) que al final se convierten a unas vacaciones de pago a costa del estado para un 90% de los que cobran este tipo de prestaciones.
Claro, cada uno aprovecha estos meses de protección como quiere. Unos no moverán un dedo y otros dedicarán el tiempo para mejorar su situación en el mercado laboral - formarse, buscar otro empleo etc. etc.
Sin embargo, no entiendo que los que somos pequeños empresarios autónomos, no tengamos la misma protección del subsidio cuando nos quedamos en el paro, a pesar de que solemos pagar más impuestos que los que trabajan por cuenta ajena. En un país como España, donde la mayoría de empresas no tiene más de 5-10 empleados (y una gran parte de ellas se constituye de una sola persona), me parece una injusticia social.
Creo que está muy bien, que el gobierno quiera proteger a los miles de familias que se han quedado sin empleo, designando una partida importante de sus presupuestos para este fin. En una crisis que estamos sufriendo, el labor social del estado es importante. Pero, ¿realmente su manera de hacerlo - regalando dinero a la gente - ayuda a mejorar su situación? ¿No sería mejor, en vez de hacer esto (o darle el dinero a los bancos), aprovechar estos fondos para crear nuevos puestos de trabajo? Habría más de un empresario dispuesto a contratar a la gente (o mantener los puestos de trabajo) si se viese apoyado por el govierno. Sin hablar de los beneficios sociales y personales que supone para una persona tener un empleo. Pero, teniendo en cuenta la inminente subida de impuestos, el gobierno, parece que prefiere regalar pasta al pueblo (y a los causantes de la crisis) sacándola y aumentando la presión fiscal a los que crean la riqueza en este páis.
“Todos somos iguales, pero hay unos más iguales que los demás”.
* Si alguien no reconoce esta cita es de “Rebelión en la granja” - una fabulosa novela de George Orvell, el autor también de “1984″ - la novela donde intventó el termino “el Gran Hermano”. En España no tienen la misma popularidad que en Polonia, pero son muy, pero muy recomendables.
Posted in random
No Comments »
Written by:
daniel

October 22, 2009
Importing a powerpoint presentation into a web application has been always a huge headache for a web developer, especially if your everyday environment is labeled with a penguin. I have seen dozens of converters for windows desktop, but they could not be used in our case.
Unfortunately, the old friend OpenOffice combined with some open source technologies come to rescue!
OpenOffice opens and stores documents in many formats and it can be started in a service mode, which works perfect for servers and these scripts from the JODConverter project make the job very easy.
The only thing I miss is to be able to add some parameters to the output format, for example autoplay for presentations instead of having to click at each frame to go on.
Links:
JODConverter
More info on installation
Note:
It seems it’s also possible to use Google Docs API for this purpose.
Posted in linux
No Comments »
Written by:
daniel

September 12, 2009
I have been using punjab for a while as an interface for BOSH protocol between my browser Strophe applications and other xmpp clients. This worked perfectly until the (sad) day I had no internet connection. Suddenly I could not connect through punjab with a local ejabberd server and got very confusing “not authorized” error messages.
I double checked all configuration data and do a couple of tests and debugging until I found out what the problem was.
Apparently punjab tries to resolve any domain in your usernames using a dns server. That is unfortunately true even for “localhost”. Moreover, it totally ignores your /etc/hosts file (or at least I did not know how to make it use it), so until you are ready to deploy a local dns server, you cannot use it without an internet connection.
I was about to give up, when I found out that ejabberd had a native module for BOSH connections, (which btw I had know about and it had given me a lot of troubles when I had tried to use it months ago)
Fortunately, this time everything went very smoothly. All I did was uncommenting the line:
{mod_http_bind, []}
restarted ejabberd and when I accessed:
http://localhost:5280/http-bind
I could see the BOSH interface response. Boy! That was easy.
I had to change a little bit the apache proxy module configuration and it worked perfectly.
On the other hand, the native ejabberd http bind module is said to have better performance than punjab (which is not very surprising after all). Check out this post to find out more.
EDIT: September, 12th
I have checked the setup with punjab, having internet connection activated and it is still not working, so I guess I was wrong about this being a dns server issue. Or maybe it has some problem with “localhost” being the ejabberd domain? I will post here any news.
EDIT: September, 19th
I was wrong! Thanks to some helpful hints from Tofu the REAL problem could be identified as some bug in Strophe. I was using some old version (although it’s hard to trace as there seems to be no version number in the file) and when I changed it to the one I just downloaded - voilá! It worked! The lessons learned are:
- check if you use the latest version. bugs are fixed all the time.
- sometimes (especially with many components in the middle) error messages (and even initial tests) may be misleading and testing each component separately or in different configurations may help isolate the problem.
Posted in linux
3 Comments »