Rayed's Real Life

FreeBSD, Linux, Apache, PHP, MySQL, and very little of my life ;)

Archive for the ‘alriyadh.com’ Category

FreeBSD 7

leave a comment

FreeBSD

FreeBSD 7 is available, many new improvements performance and feature wise, check the announcement.

One of the most impressive improvements is SMP (Symmetric multiprocessing):

Dramatic improvements in performance and SMP scalability shown by various database and other benchmarks, in some cases showing peak performance improvements as high as 350% over FreeBSD 6.X under normal loads and 1500% at high loads. When compared with the best performing Linux kernel (2.6.22 or 2.6.24) performance is 15% better

Update: OnLamp has a nice article about the amazing FreeBSD 7: What’s New in FreeBSD 7.0

Written by Rayed

February 28th, 2008 at 9:20 am

Posted in MySQL,UNIX,alriyadh.com

alriyadh.com new search engine

4 comments

Solr

After serving Alriyadh.com the past 3 years, I am replacing Swish-e with Solr search server, Solr is a search server based on Lucene text search engine.

Lucene

Solr has many advance features I didn’t utilize most of them yet, but hopefully you will see them soon. I will write a post about Solr and how it works and its integrate with PHP soon.

For now please have a look at it and tell me what you think.

Written by Rayed

November 22nd, 2007 at 8:11 pm

Posted in PHP,alriyadh.com

MySQL: fixing errors of the past

5 comments

Old MySQL versions didn’t have good support for Arabic, so what I used to do is to configure MySQL tables with any character set e.g. latin-1 and configure PHP to read it and write in Windows-1256 and pass it to MySQL as is i.e. MySQL think it is “Latin-1″ but in fact it is “Windows-1256″.

Needless to say cheating in the character set have many bad consensuses:

  • Sorting will not work as expected
  • Other applications will assume you are using the correct character set and you won’t be able to read or write your data. e.g. PHPMyAdmin could display something like this:
    “ÈÓã Çááå ÇáÑÍãä ÇáÑÍíã”

How to fix it
I found this trick in MySQL documentation, what you need to do is convert any character field to “blob” then convert it back to the desired field type with the desired character set:

ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET cp1256;

You can change it and test it from phpMyAdmin.

Of course it would be wiser to automate the process using a php script.

If you want to store the data in UTF-8, you can convert it using the command:

ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;

NOTE: don’t convert from “blob” to “utf8″ unless your data is actually stored using “utf8″.

Windows-1256 or UTF8
If you are application use only Arabic and English you can store the data in Windows-1256 (aka CP1256), but if you want to store more character set you need to use UTF8.

Even if you use Windows-1256 to store your data in MySQL you can still build applications with UTF8 interface, this done by using the SQL command:

SET NAMES utf8

This command means all data communication between your application (PHP page) and the server is UTF8, MySQL server could store in Windows-1256 or UTF-8 it doesn’t really matter. Keep in mind storing Arabic data in UTF8 means double sizing your MySQL data files.

??????
If you see your data in question mark like this “????? ?????? ????” it means your “MySQL connection” character set is incompatible with “MySQL storage” character set, and when MySQL doesn’t know how to convert any character it replaces it with “?”.

UPDATE:
A great way to migrate your application is to set the server default charset to “cp1256″, and set all new connections to use it:

[mysqld]
init-connect='SET NAMES cp1256'
character_set_server=cp1256

Written by Rayed

September 1st, 2007 at 2:37 pm

Posted in MySQL,alriyadh.com

Alriyadh.com converted to CSS based design

5 comments

Warning: It is the same design converted to CSS.

After 5 weeks of development and testing, Alriyadh.com is now converted to CSS based design, it still not 100% complete.

You can view the design by using this URL:
www2.alriyadh.com

Some benefits of moving to CSS:

  • Fonts look the same a cross browsers: I am using Yahoo! User Interface Library fonts file to guarantee that font have the same size a cross browsers.
  • Page are bit smaller: because many presentation tags are now removed from the HMTL and put in the CSS.
  • Printer friendly by default: we now have have separate CSS file for printing, so no need for printer friendly page since all page are automatically are.
  • PDA friendly by default: same as printer CSS, not implemented yet.
  • Rendering is faster.
  • It will simplify future redesign. (since we are talking about redesign, suggestion are welcomed :) )

Written by Rayed

May 18th, 2007 at 12:53 am

Posted in alriyadh.com,css

CakePHP under Lighttpd

8 comments

After moving alriyadh.com to Lighttpd I had some problem making a CakePHP application I wrote to work properly.

I searched the net for a solution and I found this post, but unfortunately the solution they proposed didn’t work, I spent several hours trying to make it work until I gave up, I decide to do it from scratch and luckily it worked.

The mod_rewrite rules I used in lighttpd.conf file:

url.rewrite-once = (
"^/cake/(css|files|img|js|stats)/(.*)$" => "/cake/app/webroot/$1/$2",
"^/cake/(.*)$" => "/cake/app/webroot/index.php?url=$1"
)

Where cake is you cakePHP application.

I tried to login and add a comment to the CakePHP Bakery site, but I got an error when I try to comment!

Written by Rayed

February 9th, 2007 at 11:28 pm

Posted in PHP,UNIX,alriyadh.com

Submitting Forms using Ajax

leave a comment

When you build AJAX based form, you need to provide visual feedback to tell the user that something is really happening.

I created small template for this purpose:


Ajax Form

Hopefully you will see it in the next alriyadh.com CSS based theme :)

Written by Rayed

February 7th, 2007 at 11:57 am

Posted in alriyadh.com,css

Improving thumbnails quality

2 comments

Inpired by Flickr’s Dirty Little Secret post, about how Flickr thumbnails make the photo prettier than the original photo.

The article suggest that Flick sharpen the image before it resize it.

So I did my own test, this the result and you are the judge:

Image 1, normal resize.
Image 2, sharpen before resize.

Sharpened and saturated +100:

All I need to know is how to do it from inside PHP.

Written by Rayed

February 5th, 2007 at 12:51 pm

Posted in Blog,PHP,alriyadh.com