23 mars 2008

Create a form using php and html

I spent my afternoon creating a form for the Sea To Sky Women's Soccer website. What we want is people to answer an online survey about last season and what can be improved in the League.

I found that simple and clear how-to: http://www.6ma.fr/[fr]
Ok, the website is in French. My survey is working right now, and the only trouble is that it's not included in the Joomla interface, so I could lose the users.

But if you want to create your first form in php, and you speak French, that's the place to be.

On the other side, I was looking quickly to get a joomla component to get the survey done, but the best one: dbquery, doesn't want to install on my joomla...

18 mars 2008

Using remind to always be on time with birthdays

I'm sure a lot of people are like me, always forgetting the birthdays, because it's coming faster than expected (March already?? No way! it was January just yesterday!)

Step One: get remind
Anyway, if you are using Unix or Linux, you can install remind, a small software that we'll help you stay on track with your friends and their ages. To get it, with Mandriva, pretty easy:

urpmi remind

Step Two: create the reminding file
To use remind, you must create a file with the list of all your friends' birthdays. That's probably the longest part of this how-to, but you only do it once, and then it's good to go for all your life !! You can call this file file_remind for example. The file doesn't need any extension.

The file is just a plain text file. You can use vi, the simplest editor. I personally use gvim, its graphical version (with colors). Now, ready to start? Here we go !

The first line of the file is going to be the most difficult one: we are going to create an age calculating function, considering that you know in which year your friends are born. Mine looks like this:

FSET depuis(x)(year(trigdate())-x)

FSET means (c'mon you're not morons!) Function SET.
depuis is the actual name of my function ('cause I'm French)
x is the variable (you can call it toto, fcuk or yr if you like, it doesn't matter)
year is a remind function which gets the year from a date
trigdate() result is the exact date where you launched the remind command

So if we analyse quickly, depuis is going to get the year from the actual date (the year we are in right now), and substract x from it.

You'll understand better when I show you the second line of my file:

REM 9 Nov +7 MSG Anniversaire POIPOI: [depuis(1982)] ans %b


REM tells remind that this line is a reminder. If you're looking for the others, here is Remind man page. You can also access it by typing man remind in your console.
9 Nov is the date of the birthday I want to remember (and you should remember it too, that's mine! ;))
+7 tells remind to give me this information for 7 days before the birthday date. If you want to be reminded only the day before, just put +1.

MSG and what is following is the actual message that remind will show upon using remind.
[depuis(1982)] is the function we created in the first step, where x is 1982 here, my birth year. So dpeuis is going to substract 1982 to whatever year we are in today. (2007-1982 = 25)
%b shows, when you run remind, the number of days remaining until the actual date of the reminder.

Step Three: Result
To run remind, you just have to launch the command remind, followed by your file's name. And here is the result I get (on Nov 3rd 2007):

remind file_remind

Anniversaire POIPOI: 25 ans dans 6 jours

Everything that was behind MSG is showed. Anniversaire POIPOI just appears normally, then the depuis function calculates my age (you must put "ans" to actually get a French sentence, because depuis only gives you the number). And thanks to %b we know that it's "dans 6 jours" i.e. in 6 days.

Now you just have to copy and paste this line as many time as friends' birthdays you want to remember, change the dates and years, and you are good to go. If you don't want to deal with this (basic though) programming, there is a graphical version of remind, that you can find on the official site. And here is the Wiki, if you want to know more!

P.S: now the next step is to get remind to be launched when your computer start, because is you forget to run remind, you'll miss so birthdays for sure !

18 janv. 2008

IM, Pidgin, Amsn and the others

I'm a Pidgin (former Gaim) lover. I've been using it for 3 years now. In 2001 we were all using ICQ in the university residences, even to talk to our neighbour (and even if our doors were open, shouting wasn't the way to communicate at that time. Internet was!)

And then 2004 the new promotions arrived and brought us MSN, so we had to stay in the progress and switch. But I didn't want to have 17 different IM softwares on my computer, so Gaim was the solution: one platform to talk to all my friends at the same time, even if they are talking via icq, msn, or yahoo. Well, I must say, I started with Trillian, but it's not an open source software (even if it's free), so I choose the open source one.

And I'm very happy with my Pidgin, I can talk to my world of friends, and many at the same time without a big bunch of windows (tabs are the best things on earth ;)).

But today another technology gap to face: Pidgin doesn't support webcam conversations. Argh !! It's planned in the 3.0 release, but for when? Please don't ask!? Luckily, if you are like me, a Linux user, and you would like to see your friend (or them to see you) while sending them messages, then you've got to urpmi (i.e. install) AMSN.

The webcam is working with AMSN. There is no sound, but the image is good and clear, so it's worth it. But I can't wait for my Pidgin to be the best again !! And of course my Pidgin groups are not appearing in Amsn...

9 janv. 2008

I'm a Hoaxbuster !!

I read an article from 01Net[fr] yesterday saying that 96% of the e-mails in the world are spam. But in these ones, I don't think they include the mails of hoaxes that our friends send us, believing they are saving the girl who disappeared or the boy who needs a bone marrow transfusion...

We call these emails hoax ou canulars. Most of the time it's a chain letter, and if you don't forward it you to your best friends will die of sudden death, have 7 years of misery of any other bad thing... They can also be a emergency call because a girl/boy disappeared, or is going to die if they don't find the right blood/bone/brain/lung/kidney/nose donor...

If you receive any email like this, please, please, please, DON'T SEND IT BACK !! Go and check
http://hoaxbusters.ciac.org/ if you speak English, or http://www.hoaxbuster.com/ if you speak French.

Just type or paste a sample of your email in the hoaxbuster search engine, and click go to see if the email you received is true or not. If not, please stop the chain and delete the mail. If it's true, you can send it back, but write a word saying that you checked the truth of the content.

Et pour les Français qui sont sur Facebook, je vous conseille de devenir fan de hoaxbuster. Recherchez HoaxBuster dans les groupes, et devenez fan !!

7 janv. 2008

Using ll and chmod

What is great with Linux is the console thing. You seem like you are the master of everything when you are typing commands in your shell. That's the way I feel anyway :)

You can easily change the permissions and access to your files via the console, without having to look for the file in your exploration window and then do the click right and all the stuff. Open a console window, get to the folder you need with cd. The syntax is cd way/to/the/folder/you/want/to/be/in.

[root@localhost poipoi]# cd /var/lib/mlocate/

Check your file status with ll (or ls-l) the-name-of-your-file.

[root@localhost mlocate]# ll mlocate.db
-rw-r----- 1 root slocate 3326223 2007-10-21 19:06 mlocate.db

The first dash shows us that the file is NOT a directory (or you would have a d instead of a dash), then you can see 3 sets of 3 dashes or letters. I'll tell you about it in 1 minute.

We can now use chmod.

Two ways to use chmod:
1/ with the letters
you have four different types of users hidden behind the letters U, G, O or A

  • the file's owner, called with a U as User
  • the users from the group (if a group is defined), called with G
  • the others, called with O
  • everybody at the same time, called with A (and so stand for U, G and O at once)
And you can give the users three different permissions:
  • Read, or R = the user can only read it, no editing permitted
  • Write, or W = the user can read and write
  • Execute, or X = the user can use the file if it's an executable file (script,...)
If we get back to our ll result:
-rw-r----- 1 root slocate 3326223 2007-10-21 19:06 mlocate.db
We can see that the user/owner is root and can read and write the file, but not execute it. We can see that the group of users is slocate and can only read the file. The other users have no access to the file.

The syntax is: if you want to add permissions:
chmod [users]+[permissions] file
or chmod [users]-[permissions] file if you want to withdraw them.

So now, if you want to make your file mlocate.db writable and executable by the group and the others, you type: chmod go+wx mlocate.db. ll will then give you:

[root@localhost mlocate]# ll mlocate.db
-rw-rwx-wx 1 root slocate 3326223 2007-10-21 19:06 mlocate.db

But if you want to make it writable and executable for the group but just executable by the other users, you'll have to run chmod twice. That's the case when using numbers is faster.

2/ with numbers
Numbers as in binary numbers. Hey don't go !! I'll make it easy ;) You have the 3 sets of permissions:
rw- r - - - - - To convert them in numbers, just put a 1 when there is a permission, and a 0 if not.
110 100 000

In binary we start to count from the right, so every set corresponds to 22 21 20, 4 2 1. So the rw combinaison is worth 4+2 =6, or only r is worth 4. The next table shows you them all.

PermissionsBinaryBecomes
---0000
--x0011
-w-0102
-wx0113
r--1004
r-x1015
rw-1106
rwx1117


So now, you know that if you want your file to be readable and executable (r-x) you must choose the number 5. Let's see how to use it if we want to get this mlocate.db writable and executable for the group, and just executable for the other people.

chmod 671 mlocate.db will do what you want: get the user to read and write (rw- 4+2+0), the group to do everything (rwx 4+2+1), and the others just to execute the file (--x 0+0+1). And now you can see that my example is a bad choice, because the group will have more permissions than the actual owner, which is a very bad idea !! :)

Be careful with the numbers, you must take care of all the type of users, and not just give one number or you might lose your owner's rights! Trouble you don't have using the letters, because they only apply on what you actually say, and don't change anything about what you don't say !

In real life, what I just wanted to do is give the read to group and user to mlocate.db, because locate (my computer search engine) is not working with my user right now. So i'll just chmod 644 mlocate.db. And now it's working :)

My source: chmod by the numbers