Friday, June 4, 2010

Good Bye Blog, Hello Wiki

It has been a long time since my last update. I've been busy with other personal projects that keep me from maintain the blog. Now I have more time, but it's still difficult to write good postings.

The main reason for start the blog a year ago was to document all my development facts and progress. For that purpose, the most easy way was to start a blog, because it was a known platform for me. But, after a few months after I started to use it, I found it very limited as a development resource.

Previously to the blog, Codepixel author, Xabier Loureiro, suggested that I should start a personal wiki, which is more suited for continuous maintenance. I started to migrate "Fallen Apples" most useful content to a new Google Site (kind of Google wiki) and, at the moment, I agree with him. While you can achieve a similar functionality with a blog using static pages, I found more comfortable to do it on a platform like Google Sites.

Now, I will use http://sites.google.com/site/manelvf/ to store, classify and upgrade my personal notes, as I was doing before at this blog.

Saturday, January 9, 2010

Linkedin network fail

I've been suffering a lot of network connections trying to access LinkedIn site from my home. In fact, I couldn't access services as accept invitations and change my profile.
After sending an email to them, they answer me a long email with a conclusion: to connect to LinkedIn the mtu (maximun transmit unit) must be lower than usual. It seems it's a scale problem they haven't solved. A practical reference value is 1360. So, the Linux way to solve the problem is this:

sudo ifconfig eth0 mtu 1360

Where eth0 is the name of the card device (wifi is wlan0, i.e.) and 1360 is an acceptable mtu value for my connection. In distros like Fedora, maybe you have to login as root in console with "su -" or similar.

Saturday, December 26, 2009

Install mp3 for Audacious on Fedora Core 12

Fedora Core is an outstanding distro that competes against Ubuntu, but lacks some commodities. One of them is MP3 support. We can add it installing the correct packages:

1st: Find libmad rpm package. Mad is an old nice mp3 decode library. I found one here:
http://www.rpmfind.net/linux/RPM/rpmfusion/free/fedora/devel/x86_64/libmad-0.15.1b-13.fc12.i586.html

2nd: Find audacious plugins 'freeworld' that link mp3 library with player: http://fr2.rpmfind.net/linux/RPM/rpmfusion/free/fedora/12/x86_64/audacious-plugins-freeworld-mp3-2.1-1.fc12.x86_64.html

These two are for 64bit version, so maybe are not suited for your version. The most useful keyword to search for a specific package on Fedora is fcXX (where XX is the version number, i.e.: fc12).

Thursday, December 24, 2009

F.lux: rest your eyes

F.lux is a freeware (not open source) utility for Linux, Windows and Mac that changes the intensity of the screen light based on time of day. So it makes the screen darker on night and brighter on day. It also uses latitude or ZIP code to calculate sunset, so it fits to your location anywhere.

Thursday, December 3, 2009

Using rsync on local folders

This command line synchronizes the 'test' folder with production folder, as simple deploy system. It uses the popular command 'rsync':
rsync -crv --delete --stats --exclude "*smarty*" test/www/ www/

It excludes smarty folder contents as is mostly used for auto-generated compiled templates.
On rsync command, it doesn't use the common -a (archive) flag as it tryes to maintain date and time from old files, and some servers don't let it and provoke a warning when syncing.
'--delete' is a potencially dangerous flag, that erases existing files if they are different than source ones.
Other interesting flag is -n, that performs a "dry run" that shows the results without perform the copy.

Thursday, October 22, 2009

Remote deployment with Fabric

Fabric is a Python module that allows to execute scripts on remote hosts. It uses configuration scripts to perform the tasks.

import re
import pysvn
from fabric.api import run, env

baseurl = ""

def site(  ):
    env.hosts = ['xxx.yyyypixel.com:22']
    env.user = 'jailed'
    env.baseurl = "http://pixelame.googlecode.com/svn/tags"

def deploy(  ):

    client = pysvn.Client()

    tagList = client.ls(env.baseurl)

    tagDict = {}

    while True:
        i = 0
        for k in tagList:
            name = k._PysvnDictBase__name
            tag = re.compile('[^/]*$').search(name).group()
            i += 1
            tagDict[i] = name
            print str(i) + ") " + tag

        key = input( "Tag to export " )
       
        key = int( key )

        if (  tagDict.has_key( key )) :
            url = tagDict[key]
            break
   
    print url
    run( 'svn export ' + url + ' /var/www/pixelame ') // this command is executed on remote host

   
To invocate this script use:

fab -f script.py site deploy   

Where script.py is the previous script and site and deploy are the methods that will be called. It connect thru ssh to the server and perform the subversion command on it with the method "run".
This is a very simple example, but fabric can perform very complex tasks.


Tuesday, October 13, 2009

Javascript custom function generator

This example uses a javascript lambda function to generate a custom call inside a for loop.
Code from an event function for an ExtJs core.



for k in ...
var rid = content[k].id;
rate.on( "change", function(rid) { // receives current rid value
return function(e) {
Ext.Ajax.request({
url:"/rate",
success: function() {
},
failure: function() {
alert( "unable to rate" );
},
params:{id:rid, value: e.value}
});
}
}(rid) ); // pass rid with current value
...


The parameter rid is evaluated 'on the fly'. If it was sent in an usual way, function would evaluate rid as last context[k].id cycled.