Interview for PHP programmer

So, in Blueliner Bangladesh, we needed some PHP programmers in the coming months. I almost took over 20  interviews from screened out CVs and found some good candidates. There’s some points we’d like the programmers of this country to be concerned about. Here are some of my observations and recommendations.

You have to learn yourself. Company may not give the opportunity!

This is one of the most common pitfalls i found in this recruitment drive. Most people complain that they don’t get enough time to learn about the latest tools and technologies. But the thing is, It’s your career! the companies will always try to get the best out of you within shortest possible budget and time. And at the same time you have to enrich yourself not only through the projects you get but also with some voluntary open source projects. What most companies don’t realize that, if the programmers are not given some room to do R&D, it’s eventually the organization who will lose by compromising with the standards of the programmer against budget. And the programmers are not updates with the latest tools technologies. So, guys! you have to take some personal effort to play with the newer things. Even if you don’t get a minute in the workplace, find some time at home to do some R&D. It will pay off inshAllah.

Ability to do things VS Ability to do things with Art.

There are hell lot of renowned Javascript programmers but how many do we know? John Resig, Jack Slocum, Remy Sharp and so on. Why do we know them ? Because they did something which others didn’t. They did things with Art for which we know them. So all the promising programmers, please concentrate on doing thing with Art. If you know jQuery, learn how it works, who’re the people behind it, follow them on twitter, read their blogs. Let alone John Resig’s Blog can give you a very good insight what’s being cooked for the next generation javascripts. BE detail oriented about things you play everyday with. You’ll always be appreciated for things you want to do not “things you had to do”.

Object Oriented Programming

PHP had been very lose in standards and conventions when it comes to Object Oriented Programming. The recent releases of PHP are much more matured that it used to be in the past. I started in 2000. We can do lot of things without even following the standard way. But dear PHP programmers, better companies or promising companies will take you because you’ll make some magical changes, add some new dimensions in the organization. So please be very clear and efficient about Object Oriented Concepts and way of doing those things in PHP. There’s a difference between a programmer who declares a class “abstract” knowing when it’s needed and a programmer who knows OOP but doesn’t want to declare the class abstract. PHP is not at the pick of it’s maturity. So try to discover which things are absent in OO PHP which are there in other languages (C++,Java, Ruby).

Have some publishing activities

To present yourself as a passionate programmer, you gotta have a blog or some sort of publishing which is visible on the WWW. If you have a blog and you write about things you play with, problems, time saving solutions, it will help you a lot getting the attention as a good, focused and passionate programmers. So start your blog now if you don’t have one. It takes a little time to get used to with some writing habit.

Care more on the CV

May people simply flooded of with bunch of tools and technologies. Many of cv looked like they are Jack of All trades. But hardly anyone was proficient in all they mentioned. So please, do not put items on which you don’t have substantial hold of and just for the sake of filling up CV. If you write you are good at Javascript, expect advanced level questions from JS. If you write “Good in OOP” , expect higher level questions from OOP.  Make the CV withing 3 pages maximum. It irritates the interviewer when people have long descriptions about each project you have worked on.

There are other points i wanted to write but the post will become longer than the comfortable or acceptable length. So i’ll share some more next hopefully.

Sorting table columns in mysql by adminer

Sorting columns in a mysql table has always been a nasty way to deal with. It can be done some sql commands of course but this is not what we do more often. Even the most popular DB admin package – phpmyadmin doesn’t provide such utility to sort or re-arrange fields in mysql. It occurred to me a lot of times that i had to bring some filed to a different position for convenience after i first created it. But i had to run some queries which i never liked, to do this task.

So ADMINER (formerly phpminadmin) comes up with a nifty utility in their one file standalone package.

If you haven’t heard of Adminer yet (you must have missed a great tool), download from http://www.adminer.org/en/

And run it from your web server from any location. After entering credentials and selecting database, just select a table from the left which appears like this.

adminer_table_select

Now you get some options like – Alter table   |   Default values  |   Select table  |  New item

Select Alter Table and you get a screen like this

adminer

Alright, you pretty know what to do with those up and down arrows now. Don’t forget to save the changes :)

Killing session on browser close in Codeigniter

It may be well known to some people how to kill sessions on browser close but the default config in codeigniter doesn’t provide so. In lot of application which has admin interface, we don’t want browser to store the session. So it needs to kill the session when browser is closed. Example behavior can be found in yahoo email page.

So how do we do that in Codeigniter ? It’s simple, although this feature is not well commented or documented. Ok, now open system/application/config/config.php file

And find the settings called $config[‘sess_expiration’] under the section Session Variables and put the value like this

That’s it. Now your session will be killed in the event of browser closing.

Form Validation Callbacks in HMVC in Codeigniter

Many of us are using the HMVC extension (Hierarchical Model View Controller) in codeigniter which is available. http://codeigniter.com/wiki/Modular_Extensions_-_HMVC

HMVC helps developing modular apps in a very convenient way. All the things work simply fine just like a clean CI installation. There’re 1 or two exceptions which i have found. One is the callback of Form_validation class. If we are making some forms like registration we check emails and usernames and we do it in the form validation class using callbacks. If we look at the basic callback structure when validating forms from CI documentation, it appears like.

 

But this callback will not simply work. Some of my precious hours went why it was not working. Then i navigated the Form_validation.php in /system/libraries folder around line 580 which looks like

 

The function – method_exists returns false even if the callback function is there in the Controller and after all in the CI loader object. So it came out from the forum that you have to do a little extension to Form Validation class which is

 

And when running the validation like in earlier code

you have to provide an addition $this as a parameter to run method. which will look like

Now, your validation callbacks will work perfectly.

Another note, if you’re trying to access a public variable of a controller via the get_instance() in hooks , you’ll have to write in your controller like this.

CI::instance()->var_name = “Some Value”;

May be there are some other required adjustments when using HMVC, but i came across this two time killing adjustments.

Python for Codeigniter developers

So, you use codeigniter and  want to develop something in python ? And you have following things in mind :

1. An MVC framework which has almost zero installation.

2. A framework that behaves quite in the same fashion like Codeigniter.

3. Small footprint

4. Has Similar or even easier libraries than codeigniter.

5. And you want something which works both in Windows/mac/Linux.

You have probably heard of developing web apps using python and python frameworks like django. But the installation on your windows machine or linux machine along with apache is a big headache. You want something short and sweet, something works out of the box.

OKKEYS, the name is web2py – an enterprise web development framework – entirely written in python. If i start to write all good things about it, the post might become really big. So let’s jump into the installing of this framework and see some actions.

Things needed

Python 2.5.2

web2py Framework

Steps :

1. For windows XP, install python 2.5.2 – the .msi package. It’ll probably install in your c:/Python25 directory. Now you have to add 2 environment variables.  Right click “My Computer” -> Properties ->Advanced -> Environment Variables (at the bottom).  Under the “System Variables” double click “Path” and put ;C:\python25;C:\python25\scripts at end of the Variable Value.  For windows users, a restart is sometimes necessary to propagat

For Ubuntu, if you have already installed python latest version which is 3.X, you have to install python 2.5.2. They can run simultanously. So in terminal,

sudo apt-get install python2.5

2. Unzip the folder from you have downloaded http://www.web2py.com/examples/static/web2py_src.zip to some place. May be c:/web2py or in Ubuntu /home/username/web2py [or anything you like ]

3. Now it’s assumed that python runs from command prompt or terminal. To verify type python in command prompt in windows (not in CYGWIN or any Bash Shell) or in terminal in linux. If you get something like this

Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

It means you have successfully installed python. Now from the command prompt go to your web2py directory using cd web2py

4. TIME FOR ACTION!!! Now that you’re into the web2py directory, simply type

python web2py.py

You’ll get a greeting screen and the a screen like this both in windows and linux.


web2py_server

It asks for an admin password. Choose anything simple for the time being and hit “Start Server”. That’s it. A window will open with the web2py admin panel like this.

welcome_1247640873997

Alright, from this point, i think you can start playing with the links and most of the options are self explanatory. Click the links, go deeper and have fun with an easy MVC framwork in Python.

Keep discovering!!

Michael Jackson died !

michael_jackson_king_of_pop

So, nobody lasts longer! I watched the news all day long about MJ. I’m kinda deeply shock at his death at the age of 50.  He was the music hero for almost all of us. It’s not only normal people but also to Gods of Rock – Metallica, i remember they suddenly started playing riff of “BEAT IT” in one of videos. There would hardly be any party/ celebrations in my childhood without some of MJ’s music. I still play the riff of “BEAT IT” in my acoustic guitar. It just refreshes.

This morning when i just saw “Breaking News” in CNN, it was unbelivable. I had to make sure in other channels and websites whether it really was. And it really was! The king of pop died of cardiac arrest at his home in LA and later in UCLA. A legend is gone!

I don’t have to write stories about him – we all know much. Just “Thank you” to Michael Jackson for his music, style, dance, love for people.

Google chrome now on Linux and Mac

Wow, so we don’t have to be more patient to run Chrome on Ubuntu. Google gives early access to dev channel for google-chrome’s unstable release of Linux (only debian at the moment) and Mac.

Just installed it on my Ubuntu – Jaunty and it works fine till now. Here’s how it looks like. Fonts are little crispy though.

chrome-on-ubuntu

Early stable versions can be obtained from http://dev.chromium.org/getting-involved/dev-channel.  Microsoft will be a toast soon. lol

16 jQuery Plugins i used the most

It’s been over 2 years for me using jQuery in different web applications. In the beginning, there were not much alternatives to a plugin. In the modal box area, Thickbox was the uncrowned King. Bassistance.de ‘s validation was the only good validation plugin earlier. But now, millions have embraced jQuery and developed quite a lot of plugins. Most of them has alternatives. I requested jQuery.com to allow people post similar plugins on plugins pages so that people know in a nutshell about the available alternatives.  But it’s still not there. Anyways, I’m going to list out the plugins i used practically more frequently. Let’s see them by category.

Interface
jQGrid
Flexigrid
Table Drag And Drop
Tooltip Related
jGrowl
Tooltip
SlideShow
Cycle
Scrollable
Forms
Validation
Masked Input
Modals & Overlays
Boxy
Thickbox
Colorbox
Nyromodal
BlockUI
Navigation
Lavalamp
jScrollPane
Ui Tabs

Guitar Chord Finder : Yet another old day script

Yet another one of my old days of Javascript – Guitar Chord finder. I can play Spanish Guitar a little. So in the beginning (2000-01) i needed the chord chart often visually. All of the guitar tab site write their tabs in similar fashion. Like if you talk about A major it will be like 002220 which means 6th and 5th strings are open,  your fingers are at 4th,3rd and 2nd fret and sting 1 is open again. If you play guitar, u know that A major has other combinations in the other octaves. So this XXXXXX notation helps us read the tabs correctly for which chord at which fret has to be used. Like , in the song Hotel California, the last E Minor at the end of first solo is actually the 335450 rather than 022000.  Anyways, as i was kind of beginner in 2000-2001, i built it for first octave chords only. Here’s how it looks.

chord-finder

It’s a chord chart for the right handed people 😉

You can see it in action here and can download the files here.

Upload all your files in lowercase in Codeigniter

You might all probably know that *nix systems treat myPic.jpg and MYpic.jpg different while windows systems don’t . So there’s always been a need to deal with filenames across different systems. We upload files which may be in lower case, uppercase or a mixture of both. This sometimes kills our valuable time and effort. To deal with files uploading, edit and delete if we always assume that file names are in lowercase, it’s lot better unless we have significant reasons to keep the case of the files intact.  Codeigniter has a good uploading library which resides at /system/libraries/Upload.php. But unfortunately there’s no property of the uploading class that lets us to upload the file in lower case. So, the shortcut is to override the native method by your own library. When we initialize a library CI tries to find it within your application directory and then it’s System directory. So if we make a class MY_Upload extending CI_Upload, it can do the job. This is no trick, it’s documented on CI. So, now , we just need to override two functions in the CI_Upload class. These are _prep_filename and get_extension Here is how it looks




		


The code can be downloaded from here

my_upload

Unzip and put it in your /system/application/libraries directory.

Now for any upload you do using CI’s uploading class, will produce lowercased filenames.