Upgraded to Wordpress 2.5

General No Comments »

Yesterday I made an upgrade to my blog bringing Wordpress 2.5, I’m quite impressed about the easy way to upgrade. The admin panel is very well “drawn” making things more clear and easier. The last admin was a little to cluttered and colorful in my case to much blue. 2.5 version represents 6 month of work from the WP community and brings lot’s of improvements as I saw far now.
One of the improvement is the top right bar from WYSIWYG editor with media features like: add video, add audio or add media.

Back on my blog

General No Comments »

Hi people,
I’m back on my blog after a long absence, being busy and let’s admit sometimes lazy to write any post. First of all Wordpress 2.5 is here and I want to upgrade the blog asap.
I need to search a way to get ridd of the houndreds of spam messages that are bombarding me daily and least but not last I prepare a new orginal theme for this blog, this one being “taken” and modified for my needs.

Merry Christmas and Happy Holidays

Xhtml/CSS No Comments »

Holidays are here, a moment of joy and good time for all of us in the middle of friends and family. I wish Happy Holidays and Merry Christmas to everyone and if this will be the last post of this year, I also say: Happy New Year!

Generate a unique string in PHP

PHP No Comments »

Here is an example of generating a unique string in PHP very useful in some cases especially when you work with large amounts of rows in a db table and you want unique and "hard to find" keys for every row.
My usual method to do this was using the strtotime() function, with "now" as the argument and to the result I was applying the md5() to get a random unique id. The result is fine until you run the script more then 1 time in a second when you get the same string. Here is the new way I do to get a real unique ID not depending on time:

CODE:
  1. function unique_id(){
  2. $better_token = md5(uniqid(rand(), true));
  3. $unique_code = substr($better_token, 16);
  4. $uniqueid = $unique_code;
  5. return $uniqueid;
  6. }
  7.  
  8. $id = unique_id();
  9. echo $id;

This time I use the rand() and uniqid() functions.

Got 12000+ downloads on sxc.hu

Free Photos 3 Comments »

My photos posted on sxc.hu received more then 12 000 downloads in less then a year. I have only 15 photos posted taken by me an almost an year ago, a single photo received more then 4 000+ downloads (that means much I think).
Take a look to my profile and download from there if you find something interesting.

Still alive

General 1 Comment »

Hi to everyone, I know it passed a lot of time since I wrote something but I was busy meanwhile and I ignored completely my blog. I announce everyone that I'm ok and healthy and in few days some new post will appear, I have also in mind to go deeper with cakephp study and to write some nice examples and posts about it.

Valid XHTML 1.0 Strict pages with flash on them

JavaScript, Xhtml/CSS No Comments »

Everyone knows there is a problem in having a valid XHTML 1.0 strict page when you want to use some flash on it. In another post I described how this can be done but unfortunately that thing wasn't complying with the XHTML 1.0 strict instead was fine for the pages validating using the Transitional Standard of W3C XHTML specifications.
Now I came back on this subject with a solution that fix the "Strict" problem, for this I appealed to a little help from Javascript using the getElemementById method.
To insert a flash code in a web page according to the adobe specification you have to use a code almost similar with this one:

CODE:
  1. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="590" height="400">
  2.     <param name="movie" value="swf/flash.swf">
  3.     <param name="quality" value="high">
  4.     <embed src="swf/flash.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="590" height="400"></embed>
  5.   </object>

Above code will insert an flash movie with the width of 590 and the height of 400, the flash movie is called flash.swf and it is situated in the swf directory. This code will cause some errors (I will not tell you here which) and the page fails to validate.
My method is to remove all the flash code from the page and to insert it using a small external javascript file.
The javascript file we will call it flash.js and place it in the /js directory inside the site root and should have the following content:

CODE:
  1. function flash(){
  2. document.getElementById('flash').innerHTML = "<object width=\"590\" height=\"400\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"><param value=\"swf/flash.swf\" name=\"movie\"/><param value=\"high\" name=\"quality\"/><embed width=\"590\" height=\"400\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" quality=\"high\" src=\"swf/flash.swf\"/></object>";
  3. }

Be careful to write all this code on a single line because it is a string and a string in javascript can't be stretched on multiple lines. As you see we are using the document.getElementById('flash').innerHTML method to write some content on a div with the id flash. The page should have the following code:

CODE:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html>
  4. <head>
  5. <title>Insert valid Flash in XHML 1.0 Strict</title>
  6. <script type="text/javascript" src="js/flash.js">   
  7. </script>
  8. <style type="text/css">
  9. #flash {
  10. width: 590px;
  11. height: 400px;
  12. background-color: #777;
  13. }
  14. </style>
  15. </head>
  16. <body onload="flash()">
  17. <h1>Insert flash animation using javascript</h1>
  18. <div id="flash"></div>
  19. </body>
  20. </html>


The result will display a valid page with a flash on it. As you see we include the javascript external file and we load the flash() function from it using the body event onload. The flash code is not displayed and everything we have at View source is the empty div.
That's all.

The Twelve Days of Scaleout

MySQL No Comments »

On the MySQL website can be found some articles posted under the name of: "The Twelve Days of Scaleout", this articles talks about success stories at clients which are using MySQL services. In this articles you can find case studies on website and services like: Wikipedia (the world largest online encyclopedia), Zimbra (a leader in open source collaboration software), Alcatel (where MySQL implemented Cluster Carrier Edition database), ofcourse there are more case studies all of them are largely described on the MySQL website on the Press Releases section.

Safari 3 for Windows

Internet No Comments »

Apple released a version of their browser Safari for Windows Xp and Vista. You can found it here and you can download it for free. Now Apple made both iTunes and Safari available for Windows. Safari 3 is a beta version, on the Apple website it's said that Safari is twice as fast as Internet Explorer.
I download it and tested and I'm quite impressed by it, but most of the time I will remain to the Firefox 2.0 I think.

CakePHP - Some controller functions

CakePHP No Comments »

Interacting with your views:

set($variable, $value);
string $variable;
mixed $value;

The principal use of this function is to extract data from a controller and transfer it to a view.
It can be used to transfer single values, whole arrays and so on etc. The moment you utilize set(), the variable can be accessed in your view: doing set(name, john) in your controller makes the variable name available in the view.

validateErrors() - displays the number of all the errors produced by an unsuccessful save.
validate() - this function is used to validate a model data respecting the rules of validation defined in to the model.

render($action, $layout, $file) - this function may not always be needed because render is called by default when every controller action ends, so the view specific to your action is rendered. On the other side, you can call this function to render the view anywhere in the controller code.

 
Entries RSS Comments RSS Log in