Archive

Archive for the ‘General’ Category

Exposé Application windows + Spaces

August 2nd, 2010

Spaces is an amazing feature since OS X Leopard.
I’ve been using it since I switched to Mac and enjoying it, although it still has some flaws.
The main issue which at least I haven’t figured it out yet is how to navigate between different windows of an application while they are in different Spaces. Mac Command Icon + ~ Doesn’t help. Although I have most of my main applications assigned to specific Spaces, there are some applications that are being used regularly and for different purposes, like TextEdit which I want to paste a temporary value or write down something, or open a ReadMe file or etc.
This could happen in different Spaces and I don’t have the option to navigate through different windows while they’re are in different spaces.

Exposé for Application windows

This can be activated using F10 in old Macs or Control+F3 in new Macs, and it shows all the windows of the front most application, no matter in which Space they are.

I Know! it’s not a great discovery but it’s a time saver feature ;)

General, Mac, osx , ,

JavaScript, how life has changed

June 1st, 2010

If you’ve been a web-developer/design for a while, you definitely remember this picture :

What a headache ! huh ? I remember whenever I wrote a JavaScript code or snippet, when I hit F5 to run it, I was praying all the time not to see this freaking error message again. It gave no clue what’s going wrong, where the error is, and it did everything other than helping you out to solve the problem. Oh God! How much stupid Internet Explorer was (or maybe still is). Back then it was the most commonly used web-browser that we had to made our works compatible to.

Now we can do all the stuff we want with JavaScript, getting an error message is not much a problem anymore and debugging, is kind of fun. None of are because any change in the language itself or that stupid browser (Internet Explorer).

It’s all because of the great browser “FireFox” which was flexible enough for other third-party addons to be added to and make it enormously strong and usefull for web-developers/designers. All the tools from FireBug , Web developer toolbar and all the JavaScript Consoles (including the one which comes built-in with FireBug) have made our lives much easier.

FireFox has sort of pushed the web-browsing boundaries and forced all other existing web-browsers and the ones coming in future to be standard, and developers friendly (I’m not talking about IE, which I’m pretty glad I abandoned it since version 7).

I was thinking about the way our lives as developers/designers have changed and how much more we’re enjoying our jobs with out the need to struggle with very basic and dull stuff.

P.S: No need to mention about the JavaScript Frameworks and such pain relievers they are (most of the times though).

FireBug, FireFox, General, JavaScript, Server , , , ,

get DB handler in CodeIgniter for stand-alone Libraries

February 11th, 2010

We were working on a project where some developers were working with CI and were developing libraries there, and some developers were developing stand-alone libraries. But both groups were working on the same project.

At some point we needed all those stand-alone libraries to be  used in CI as well.
For common code it’s not a big deal, the only problem which took a little bit of time to figure out was using the DataBase. We didin’t want to make new DB connections, so how could we use the current connection, inside an stand-alone code.

The answer is pretty easy, CI’s DB class has a non-documented attribute which returns back the DB handler.

$this->db->conn_id

or if you have multiple DB cnnections that would be :

$this->dbr->conn_id;

$this->dbw->conn_id;

and then you can easily pass the DB connection to regular mysql_query function like this :

mysql_query ( string $query [, resource $link_identifier ] );

and as an example :

mysql_query ( ‘SELECT * FROM `table1`’, $this->dbr->conn_id );

CodeIgniter, General, MySQL , , ,

CodeIgniter’s log system issue

November 18th, 2009

First of all I have to admit that I love this framework. I will write more about this fantastic framework later.

But one issue I faced this morning and I was pulling my hair was its logging system.

I was editing the module which has few Ajax calls, some part was not working properly and it was absolutely because of the SQL. We have the main SQL commands being outputed in the CI log system as well. So I SSHed to server and open the log file in vi , searched for the desired point and was trying to figure out what’s the SQL problem.

At this point I got a message from a colleague asking whether our server is down or what ?

That was so confusing, some parts of the application were working and some parts were not. All the sections which were working like a Swiss watch few seconds ago. So what was wrong!
As usual everything was working properly on localhost.
I didn’t even give it a small chance that having the log file open for reading [I'm stressing this out : JUST FOR READING] could be the problem. CI couldn’t proceed with logging in the sections where we had used it. I just quit the vi editor and Voila. Coming back to life.

This is not a proper approach for log system, if it can not write to the log file it shouldn’t prevent the whole system from working. Or may be it should ! Depends on how logging is important for your system.

CodeIgniter, General, PHP , , ,

Yahoo! Mail + FireFox + Mac ; Home , End shortcuts issue

November 16th, 2009

Yahoo Mac FireFox Home / End Issue

If you are a Firefox/Mac/Yahoo lover, you might have come across this annoying issue in Yahoo! Mail in Firefox [Mac version] that when you want to go to the home or end of a line with + Left  Arrow [command - left] or + Right Arrow [command - right] , it acts like a browser’s Back or Forward button and messes up the email you are composing or sometimes even ruins the whole thing.

You can see that everybody blames Yahoo! about not following the standard rules in their editor over the net. But this can be fixed through a very very simple FireFox add-on.
KeyConfig
is the handy tool for configuring your FireFox keyboard shortcuts. After installing if [and restarting the firefox] simply go to tools > KeyConfig and there search for “goBackKb” and “goForwardKb” and disable the ones allocated to + Left Arrow and + right Arrow.

From then on, on the newly opened windows this will be fixed and you will no longer have the same problem with those lovely combination [FireFox , Yahoo! , Mac]

FireFox, General, Mac, osx , , , ,

Stress ! The good one … webserver stress benchmark

April 27th, 2009

It’s been for several years that I have not been in need of using a stress tool for testing my applications, for load-balancing and at those ages I used to use “Microsoft [ough] Web Application Stress Tool [link]“. At those ages I didn’t have any other FREE tool to stress the webserver and get the benchmarks [at least I wasn't aware of].

On the other hand we’re facing a very high traffic application which needs to be optimized byte by byte so we got a optimization guru on board and today he introduced me this fantastic Apache tool for benchmarking the load and traffic and I wanted to share it with you.

It’s “ab” [ Apache HTTP server benchmarking tool] and you can find it here. It’s a command prompt utility which works just perfect. And you can see the result of every single line that you change and how does it affect the performance.

Apache, General, Server, load-balance , , , ,

WAMP server: right-click and select your version

April 27th, 2009

Have you ever been in a situation that you need to install PHP5 to have one application which is spcifically written in PHP5 and you have also some legacy applications which are written in PHP4 and are not compatible with PHP5 but you want to have them both.

I used to hate all those software bundles installing Apache/MySQL/PHP for you easily. I prefered to have them separately installed by myself to have more control over it. But considering WAMP server with an amazing feature of having many versions of Apache/MySQL/PHP and just switch from one to another by right-clicking and selecting it, is awesome.

I’ll definitely consider it for my local machine. [First need to be done with my exam on Wednesday]

Apache, General, MySQL, PHP, Server , , , , ,

MySQL - group results by second/minute/hour

April 27th, 2009

This is a simple MySQL tip, but it helped me a lot.

We have a traffic table which monitors every single coming traffic to our applciation. I wanted to get the real values for how many requests I we have per Second / Minute / Hour and also what times of the the day are high traffic and what times are low traffic, to do some load-balancing on the application and server.

The query is very simple, just COUNT the number and do a GROUP BY and extract the minute/hour/…

Like :

SELECT tr_date_time,count(*) AS NUM FROM `traffic` WHERE DATE(`tr_date_time`) = ‘2009-04-25′ GROUP BY EXTRACT(HOUR_MINUTE FROM tr_date_time)

The script above extracts the number of hits per minute during the day.
Don’t forget that if you want to have the result by minutes, you have to add the hour as well to make it unique.

p.s: I hope your Date/Time/DateTime field is human friendly not Unix_timestamp, which will add some more extra calcuations on the result set.

General, PHP, SQL , ,

CodeIgniter xss_clean semicolon addings

April 17th, 2009

When you use that perfect xss_clean function from CodeIgniter’s library to make your content more robust, sometimes you may face a strange content being updated in DB having “;” after “&” or before “=” .

That “;” is added by xss_clean, to make the link more robust, but if in your case it will add some malfunctioning in your system you’d better use something else in your validations like “htmlentities” :

$rules['link']                =     “required|trim|htmlentities”;

For more information regarding that you can refer to CI forums. [thread1] [thread2]

CodeIgniter, General, PHP , ,

ActionSctip 3.0 Event Object

February 22nd, 2009

ActionScript 3.0 has perfect way of handling events.

It is different from the way it used to be in previous versions, but in this version it has become mature and powerful. I highly recommend you to read chapeter 12 of Essesntial ActionSctipt 3.0 by Collin Moock. You’ll definitely learn alot.

The new structure is great and as soon as you learn it, you’ll love it.

One of the tricky issues could be the differences between these two properties of MouseEvent Object : target vs currenttarget.
This is a quick and great article about it, I love the way he concluded the article :

- if we associate the event to an empty MovieClip, best to use the property target
- if we associate the event to a MovieClip containing different objects, best to use the property currentTarget

General , , , ,