Create a Design for PHP Classes

You have until 15 of december to create a , using only CSS and PHP, not javascript, to improve the old (and ugly) design of PHP Classes. The prizes are 3000$ to your Paypal and fame as the saviour of PHP Classes. Well hope this work better than the Postgres Contest, that well sucked big time, they just dissapear withouth telling much more info than "Because the few design you send suck we are not going to continue with the contest", and yes i was a contester XD, an no, my design didnt suck.

Directoy Problems with Drupal

So im testing Drupal, the uber CMS. Its so great to have a tool like Drupal to create webpages. But well im new into this and i had an interesting problem.

I create a site called Akami*, and made the mistake of creating it in a subdirectory called Amaki, notice the 'm' and the 'k'. In my localhost the page works as it should, but then i deployed it on a real server, in his REAL subdirectory "Akami", so i was having problems because all the routes where pointing at Amaki instead of Akami.

The Solution:
Flush the cache. For this I recommend to install the Admin Menu Module, it will make you life easy, and well if you use Drupal 6.14 (the last version) use the Alpha.3 version of the AdminMenu, or the latest alpha. Anyway in orden to recreate the menu you have to flush it. In this case you have to go to the url pointing that is pointing to the Flush button in the admin menu:

And the go to that site, of course here amaki is wrong so you have to manually change the wrong name to the true name. In this case from amaki to akami.Then press the flush all caches and youre done. Hope this will be helpfull for someone.

* The true site name is hidden for security reasons ^^

Custom Css Tips for Jquery Tabs

I love Jquery Tabs , it just make your life easier... well, only when you use his custom CSS.

But how about integrating it with your custom CSS, instead of his restrictive-gun-in-head Themes? , of course we know how to create a Tab Menu in CSS, but integrate it with Jquery Tabs is not so easy. So after one day of debugging my own code i will give you some tips to create your custom css for jquery tabs.

Tip 1: Know the classes for the Navigation Tab Bar: There is only one class that you will need to know little grasshoper:
  • ui-state-active: As the name implied, this class is added to the tab that is currently selected, dont mind the other classses, you will not need them, this is the silver bullet class for jquery tabs.
So we will need 4 css for know
  1. The Default Navigation Bar Css
  2. The Css for the a tag inside tha navbar
  3. The Css of the ui-state-active bar
  4. And the a tag inside the active navbar

So the css for this navigation bar(1) will go like this:

ul.grindyMenu li{
padding:1px 15px 1px 15px;

Then we add the a tag css(2)

ul.grindyMenu a{

And for the active tab css(3), it will be like this :

ul.grindyMenu li.ui-state-active{

Finally the a tag inside the active tab (4):

ul.grindyMenu li.ui-state-active a{

Now there is a small catch, your css file should have those rules written in that order. Maybe here you will not need to follow that tip, but what if you need to create a rule for the ui-state-default class. Do you notice how the active and not active tabs, both have the ui-state-default class? If you declare ui-state-default after ui-sate-active, it will override it:

So make your life easier and put those rules in order, first the default class, and then the active class in your css file.

Tip 2: Know the classes for the Panels, here also we wil only need one class:
  • ui-tabs.hide: This is the most important class, this class make the non active panels to hide


And that's it. Put this class and everything will be allright. Happy coding!

Fixing WAMP 2.0 i and not so friendly extensions

WAMP2 is like a defacto standard for developing and testing PHP in a Windows enviroment. Particulary i used to use Wamp 2.0A in a WinXP SP2 platform. Also i use Postgres instead of Mysql, just because Pg owns Mysql big time. But there was a problem...

Also it didnt work in other WAMP versions

Like a year ago i wanted to use the next version of Wamp2... the B version. But I couldn't. Well i could install the Wamp server but there was an error when i wanted to activate the php_pgsql extension, an error like...

PHP Unable to Load the muthaphucking Dynamic Library 'c:\blah\blah\ext\php_pgsql.dll' - The specified module could not be found.

Yup, something like that. So after a lot of search and falses promises in google, i found the solution not only for that postgres extension, but for all other extensions that doesnt want to be loaded dinamically.

The Solution: Make sure that you are using the right php.ini file when you....

Ah Ha..Just kidding, the fast and furious solution is to search for this file libpq.dll in your wamp directory and then copy it to WINDOWS/system32 if youre using win XP(sorry for those using Vista, btw Vista sucks).
Hate & Love this file

And its done, you can now use Postgres with WAMP2 version I (yes version I, not 2.. long story).

I dont know exactly why its works, but it works and that the only thing i want to know. And for fixing others extensions, well u got to look for the access library of that extension and put it on system32, and replace it, if it is the case. Hope it helps someone. =)

I found it looking here., but they fix mysql, so this is my sand grain for the Postgres Project. Website Design Contest

Yup my favorite database is making a contest to redesign his Website. Of course im givin' it a try so you will see me with one of my design there. This is the first time I go to a contest like this but i will make my best there.

Of course there's a 2000$ prize that make me like much more Postgres, but the initial love is there. The price is divided between 1000$ for the winner Design and 1000$ for makin that Design go online.

My strategy is to create the CSS without hacks, and then use some jquery to make it web 2.0

So if youre a Web Designer you can go ahead and make your best.

Getting seconds from a timestamp PG and My

UPDATE 17nov2010: I Change the URL of my uberfancyfull game, give it a try.. although its in Alpha Stage.

In my game i need to do a lot of date and time calculations which i prefer to do on the database instead of doing it on PHP. But unfortunately (or fortunately?) i had to change my DB from a Postgres DB to a Mysql DB a while ago.. but i finally bought a hosting with Posgtres 8.3.X. So i had been practicing in getting the same data stuff from the two databases.

And here comes the interesting stuff. Do you ever needed to get the difference between 2 timestamps and get it on seconds? Well let me show you the way:

SELECT TIME_TO_SEC(TIMEDIFF(example_time,now())) AS clock FROM movements

Ok let go step by step(uh baby!!):
1) TIMEDIFF(example_time,now()) This will get the difference between example_time and now(). As you know now() get the actual time in the server. So lets say example_time is '2009/10/10 23:10:10' and now() give us '2009/10/10 23:05:05' the result will be '00:05:05'
, Thats ok but we need it in seconds so.
2) TIME_TO_SEC(time) This function get a time value and return that number in secods.. so in our example it will give us 5*60 +5 = 395 seconds.


SELECT EXTRACT(EPOCH FROM example_time - now())::integer AS clock FROM movements;

Thast totally different from Msql .. let me give you a brief explanation fo the sintax:

1) EXTRACT(EPOCH FROM example_time - now()) The EXTRACT function is a tricky one, it will extract some part of the timestamp invlolved here , in this case the rest of example_time minus now(). Putting EPOCH first make the EXTRACT function transforms the answer of example_time - now() into seconds . Be carefull with putting SECOND instead of EPOCH.. that will extract only the secods of the answer (from 1 to 59), so in our example with EPOCH we will get 395.45.. and with SECONDS we will get 5.45..

2) EXTRACT(...)::integer This will transform our answer into integers so intead of 395.45.. we will get 395.And just btw.. this will not round our answer, it will get just the integer part of the result.

A POSTGRES Frebbie anyone?:
This is a Postgres Function I created to simulate the TIME_TO_SEC() funtion in mysql. USe it free of charge ;):

CREATE OR REPLACE FUNCTION "public"."time_to_sec" (first timestamp, second timestamptz) RETURNS integer AS
segundos integer;
segundos = EXTRACT(EPOCH FROM first - second)::integer;
return segundos;

Thougth of a Numeric ID in Jquery

I have devoted some of my time to create a Web Browser Game. This game has a Map (It is just a table with a lot of CSS to make it look like an Real Battle Map)... Well i started to work on it an created each tag with a numeric ID.. heres some code example:

But when I tried to select a ROW from the table by its ID like $('tr#0'), it doesnt work. So debuggin and debuggin I figured out that using a numeric Id in any TAG make jquery crazy. There are two solutions for fixing this behaviour:

A) Use eq to get the element of your desire: Something like $('tr').eq(1) will make the trick

B) Dont use a numeric ID at all: I think this is the best solution, so instead use something like:

Hope it help somebody with the same problem