Moodle installation problem

I just installed moodle on my server and got into a big mysql error complaining about binlog and other stuffs…

Cannot execute statement: impossible to write to binary log since 
BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine 
limited to row-based logging. InnoDB is limited to row-logging when 
transaction isolation level is READ COMMITTED or READ UNCOMMITTED

After a bit of googling and understand what this was about I figured I should add the following in my my.cnf file and then restart mysql.

binlog_format=row

I did that and it’s working very well.

How to download a youtube video under linux command line

Here is a great python script very useful to download an HD video from Youtube using the command line in Linux.

http://rg3.github.com/youtube-dl

It’s very simple, download and run. The result is an mp4 file that you can watch offline with VLC or Media Player Classsic under Windows or any other mp4 player under Linux.

Bonne Idée

I finally decided to create my company (Bonne Idée: bonneidee.biz) and do something with it. I am now involved in two projects.

Yaentrainement.fr (french version of nimenhuuto.com)

Yaentrainement is an online sport team management platform which is having a huge success in Finland (170K+ users and 43M sign-ups as of may 2012).

Yaentrainement est une plateforme de gestion d’équipe sportive qui a un succès gigantesque en Finlande (plus de 170 000 utilisatteurs et 43 millions de présences enregistrées en may 2012)

Bliubliu.com (the name may change)

Bliubliu is one of these sound a baby makes when starting to learn to speak. Bliubliu is also a language learning service. It’s working like a mother available 24/7. It will correct you, challenge you, keep you busy and interested all the time.

Bliubliu will use the power of the crowd by connecting language learners. 

Bliubliu est l’un des sons qu’un bébé fait lorsqu’il apprend à parler. Bliubliu est aussi un service d’apprentissage de langue. Un service qui marche comme une Maman, disponible 24h/24 et 7 jours sur 7. Il vous corrige, vous pause des colles, vous tient occupé et intéressé tout le temps.

Bliubliu va utiliser la puissance de la foule en connectant les utilisateurs.

Fix a ubuntu upgrade problem with Grub2

With Ubuntu 10.04 came a new version of Grub. During an upgrade from a previous version to 10.04 or higher there will be a time when the system will ask you if you want to keep your own version of the configuration or get the package maintener version.

If I am not mistaken, you should say you want the maintener one.

But then something strange may happen depending on your upgrade path.

If like me you are operating a server and you can’t see the bootup process because it’s all remote, then you probably have only one good configuration and you want to use it and never change.

So how to do that when it’s too late?

If you have access to a rescue mode, this is the time to start it. I am using a dedibox from Free. So I go on my console and I start the rescue mode for that server.

Then you need to connect using ssh to that server in rescue mode.

Once connected you can chroot to your server environment. I suggest the following process:

sudo su -
cd /mnt
mkdir chroot
d=/mnt/chroot
cd.. 
mount /dev/sda2 $d

/dev/sda2 is my root file system
/dev/sda1 is my /boot file system 

mount /dev/sda1 $d/boot

then

mount -o bind /dev $d/dev
mount -o bind /sys $d/sys
mount -o bind /dev/shm $d/dev/shm
mount -o bind /proc $d/proc
chroot $d
df -h 

If you see a df which looks familiar after the last command, you are on a good way.

Reinstall grub and update the configuration with the automatic tool (in that order):

update-grub
grub-install /dev/sda
update-grub

Get out of the rescue mode and hope for the best!

How to connect to someone out of your network on Linkedin

These days I am looking for a web developer in Lithuania. It is not very easy because it’s a small country… but on Linkedin you can find quite many profiles.

The problem is, sometimes you can’t connect to these people because they are too far out of your network.

Usually you would get the first name of the person and some skills in his profile.

So I simply search in google with the first name of the guy, and some of the skills I can find in his profile. Google will give me a list of profiles of people with the right first name and certainely some people with different last names.

All I have to do is click on each link to find out the one I was looking at before.

But now, because I know the direct link to their profile, Linkedin doesn’t hide the last name anymore, and on top of that it lets me click on Connect. So I can simply say “we’ve done business together” and add something in my request to make sure I will get an answer.

So far: 100% feedback 🙂

And no need to pay for a premium account at Linkedin. 

How to get the value of the latest auto-incremented value on a mysql table with concurrent connections

When building a web application it can seem a bit tricky to get the value of the id (primary key) of the latest row inserted in a mysql table.

It is not that complicated.

The function LAST_INSERT_ID() can help you finding that. This function will return the latest auto-incremented value. No need to specify the table, it just takes the latest one.

SELECT LAST_INSERT_ID() ;

The next question is: what happens when I have many concurrent sessions on the same server? Will I get the latest inserted id from another user?

And the answer is NO. Or almost NO. If you are using mysql_connect() to open your DB connection then you will get the latest inserted id of the current session.

If you are using mysql_pconnect(), the result is unpredictable since the LAST_INSERT_ID can come from another session which just reused the connection.

In other words, I would recommend not to use mysql_pconnect(). The advantages of this function are vastly outweighted by the difficulties it introduces and there are other better ways to implement scalabiliy with mysql.

install a lamp server on ubuntu

Easy!

sudo apt-get install lamp-server^

Be careful not to delete the ^ character.

This will install: 

apache2 apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common 
libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 
libaprutil1-ldap libdbd-mysql-perl libdbi-perl libhtml-template-perl 
libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.1 
mysql-client-core-5.1 mysql-common mysql-server mysql-server-5.1 
mysql-server-core-5.1 php5-cli php5-common php5-mysql ssl-cert

Modify the session timeout in phpmyadmin

Login and re-login and re-re-login in phpmyadmin is a huge pain.

Here is the way to extend sessions duration.

Open the file config.inc.php in /usr/share/phpmyadmin or in /etc/phpmyadmin

Add the following line:

$cfg['LoginCookieValidity']=86400;

And in php.ini, modify the following line:

session.gc_maxlifetime = 86400

Restart apache.

apache2ctl restart

You now have 24h sessions.

Assign a fix MAC address to a vmware network interface

MAC addresses are assigned at the bootup of a virtual machine. But there is a way to assign a fix hardware address to a vmware network interface by editing the virtual machine with Vi.

Simply connect with SSH to your ESXi and go to /vnfs/datastore1 or anywhere you put your vm.

If your virtual machine is called vm1, go to /vmfs/datastore1/vm1

Open the file vm1.vmx using Vi.

Around the end of the file there will be the configuration of the network interfaces.

You should see things like:

ethernet0.virtualDev = “e1000”
ethernet0.networkName = “VM Network”
ethernet0.addressType = “generated”

Add a line at the end of this section:

ethernet0.address = 00:50:56:00:00:80

If you have more than one NIC, replace ethernet0 by the appropriate value.

I chose 00:00:80 for this vm but you can choose anything with that patern:

00:50:56:XX:YY:ZZ

Start or restart your VM and you should see the changes.