giovedì 29 novembre 2012

4 html5 css frameworks


four interesting framework css designed for html5 and also for mobile.


these frameworks includes tables, forms, tabs ... ie all those you need for a good ui. update: see also: http://imperavi.com/kube/

lunedì 26 novembre 2012

python pil and ubuntu 12.10


python PIL on ubuntu 12.10
install deps:
sudo apt-get install libfreetype6-dev libjpeg62-dev zlib1g-dev
ubuntu 12.10 uses stanges path for this library so, we make symlinks
for 32bit:
sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib
for 64bit:
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib

enjoy :-)

giovedì 22 novembre 2012

python 2.4 and python 2.6 on ubuntu 12.10


For business reasons I am forced to use python 2.6 and python 2.4.
Compile the python on each  *buntu 12.10 machine that i have is a frustrating job. (some real, many virtual)
I made packages with checkinstall, these are not true ppa but maybe someone can find them useful.
I've also tested on Ubuntu 12.10 server and Lubuntu 12.10
First install the dependencies:

sudo apt-get install zlib1g libncurses5 libncursesw5 libc6 libbsd0 libreadline5 libreadline6 libsqlite3-0 bzip2 libgdbm3 libssl1.0.0

then download and install the packages:

sudo dpkg -i python2.6.deb
sudo dpkg -i python2.4.deb

(for now are hosted on dropbox doh!)

https://dl.dropbox.com/s/0cvh8jm7qcbq5py/python2.4.deb
https://dl.dropbox.com/s/jbdgbt2smu352ry/python2.6.deb

Everything is provided in the hope that it is useful to someone; but with no guarantee.
The paths are:

/opt/python-2.6.8/ (for python 2.6)
/opt/python-2.4.6/ (for python 2.4)

you can add to $PATH or make symlinks.

sudo ln -s /opt/python-2.4.6/bin/python2.4 /usr/bin/python2.4
sudo ln -s /opt/python-2.6.8/bin/python2.6 /usr/bin/python2.6

or even better using virtualenv, ex:

virtualenv -p /opt/python-2.6.8/bin/python --no-site-packages myenv
source myenv/bin/activate
(myenv)  ... your environment, your python, your packages.

I hope someday to have the time to create a real ppa with better packages.
The only supported architecture is i686, at least for the moment.

Build yourself!

(pre) sudo apt-get install build-essential zlib1g-dev libncurses5-dev libncursesw5-dev libc6-dev libbsd-dev libcurl4-openssl-dev libreadline-dev libreadline6-dev libsqlite3-dev libbz2-dev libgdbm-dev libssl-dev

for python 2.4.6

./configure --prefix=/opt/python-2.4.6/ --enable-unicode=ucs4 --with-ssl --without-tkinter

edit setup.py, change:

lib_dirs = self.compiler.library_dirs + [
    '/lib64', '/usr/lib64',
    '/lib', '/usr/lib',
    ]
 
to:

lib_dirs = self.compiler.library_dirs + [
'/lib64', '/usr/lib64',
'/lib', '/usr/lib', '/usr/lib/i386-linux-gnu',
]

then:

make
sudo make install

for python 2.6.8

./configure --prefix=/opt/python-2.6.8/ --enable-unicode=ucs4 --with-ssl --without-tkinter

edit setup.py, change:

lib_dirs = self.compiler.library_dirs + [
    '/lib64', '/usr/lib64',
    '/lib', '/usr/lib',
    ]
 
to:

lib_dirs = self.compiler.library_dirs + [
'/lib64', '/usr/lib64',
'/lib', '/usr/lib', '/usr/lib/i386-linux-gnu',
]

edit Modules/Setup, change:

#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto

to:

SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

edit Modules/_ssl.c, change:

  else if (proto_version == PY_SSL_VERSION_SSL2)
        self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */

to:

#ifndef OPENSSL_NO_SSL2
    else if (proto_version == PY_SSL_VERSION_SSL2)
        self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
#endif

then:

make
sudo make install

.....
good luck ;-)

TODO:

* find a better host
* a better english page
* an italian page
* more testing
* more check on deps
* 64bit version
* real package for ppa in chroot env

any help is appreciated. (thanks to Riccardo Lemmi for helping me on python, even at impossible hours.)

sabato 3 novembre 2012

P.js


P.js, an object oriented javascript system in 559 bytes!
an example:

// P.js exposes the `P` variable
(function()
{
    var Animal = P(function(self)
    {
        self.init = function(name)
        {
            self.name = name;
        };
        self.move = function(meters)
        {
            console.log(self.name + " moved " + meters + "m.");
        }
    });

    var Snake = P(Animal, function(self, base)
    {
        self.move = function()
        {
            console.log("Slithering...");
            base.move.call(self, 5);
        };
    });

    var Horse = P(Animal, function(self, base)
    {
        self.move = function()
        {
            console.log("Galloping...");
            base.move.call(self, 45);
        };
    });

    var sam = Snake("Sammy the Python"),
        tom = Horse("Tommy the Palomino");

    sam.move()
    tom.move()
})();

i love it!