PHP Debug efficiently with debug_backtrace

Hello today I write a small function for debug your PHP code. Its simple but powerful –

 $bkTrace=function ($stack) {
 $output = '';
 
 $stackLen = count($stack);
 for ($i = 1; $i < $stackLen; $i++) {
 $entry = $stack[$i];
 
 $func = (array_key_exists('class', $entry)?$entry['class'].'\\':'').$entry['function'] . '(';
 $argsLen = count($entry['args']);
 for ($j = 0; $j < $argsLen; $j++) {
 $my_entry = $entry['args'][$j];
 if (is_string($my_entry)) {
 $func .= $my_entry;
 }
 if ($j < $argsLen - 1) $func .= ', ';
 }
 $func .= ')';
 
 $entry_file = 'NO_FILE';
 if (array_key_exists('file', $entry)) {
 $entry_file = $entry['file'];
 }
 $entry_line = 'NO_LINE';
 if (array_key_exists('line', $entry)) {
 $entry_line = $entry['line'];
 }
 $output .= $entry_file . ':' . $entry_line . ' - ' . $func . PHP_EOL;
 }
 return $output;
 };
 echo '<pre>'.$bkTrace(debug_backtrace()); exit();

Image size for social media (like facebook, twitter, google+, linkedin, pinterest, instagram, youtube) profile and other picture

As we faced many problem to work in social media about size of profile picture to use. Here is the dimension that analysis by renowned email marketing tools provider constant contact. Also I add some value to enrich the list –

Facebook
————————
Cover photo 815×315
Profile photo 180×180 (display area 160×160)
Fan page profile photo 200×200 (display area 176×176)
Tab 111×74
Link Image 1200×627
Image 1200×1200
Highlighted/milestone image 1200×717

Twitter
———————–
Header 1500×500
Profile photo 400×400
Image display size 880×440 (recommended)

Google+
—————————
Profile photo 250×250
Cover photo 2120×1192
Shared image 800×600

LinkedIn
————————-
Profile photo 200×200
Cover photo 646×220

Pinterest
————————–
Profile photo 600×600
Pins 600xINFINITE
Board thumbnail 222×150

Instagram
————————
Profile photo 161×161
Image viewed on desktop in lightbox as 612×612
Image feed 510×510

YouTube
—————————
Profile photo 800×800
Channel art 2560×1224
Custom video thumbnail 1280×720

* all dimensions listed in pixels

Hope it may help you to engineering the web for your client.

Batch file that will create skeleton directories of ZF2

After a long time write a batch file to create a skeleton directory for Zend Framework 2 module. Hope it may help someone who work in windows 7 OS

@echo off
@setlocal ENABLEDELAYEDEXPANSION
@rem this file will create required empty directory of a ZF2 module
@rem author Shahadat Hossain Khan (shahadathossain.com)
ECHO.
IF "%~1"=="" GOTO noModuleName
SET modName=%~1
CALL :UCase %modName% _UCMN
CALL :LCase %modName% _LCMN
IF NOT EXIST "%_UCMN%" (
 MKDIR %_UCMN%
 MKDIR %_UCMN%\config
 MKDIR %_UCMN%\src
 MKDIR %_UCMN%\src\%_UCMN%
 MKDIR %_UCMN%\src\%_UCMN%\Controller
 MKDIR %_UCMN%\src\%_UCMN%\Form
 MKDIR %_UCMN%\src\%_UCMN%\Model
 MKDIR %_UCMN%\view\
 MKDIR %_UCMN%\view\%_LCMN%
 MKDIR %_UCMN%\view\%_LCMN%\%_LCMN%
 ECHO Directory created. Named - %modName%
) else (
 ECHO Directory already exist!
) 
GOTO:EOF
:noModuleName
ECHO You must provide module name along with this command as 1st argument
GOTO:EOF


:LCase
:UCase
:: Syntax: CALL :UCase _VAR1 _VAR2
:: Syntax: CALL :LCase _VAR1 _VAR2
:: _VAR1 = Variable NAME whose VALUE is to be converted to upper/lower case
:: _VAR2 = NAME of variable to hold the converted value
:: Note: Use variable NAMES in the CALL, not values (pass "by reference")
set varX=%1
set frstChar=%varX:~0,1%
set rstChar=%varX:~1%
FOR %%Z IN (Aa Bb Cc Dd Ee Ff Gg Hh Ii Jj Kk Ll Mm Nn Oo Pp Qq Rr Ss Tt Uu Vv Ww Xx 
Yy Zz) DO (
 SET pX=%%Z
 set c1=!pX:~0,1!
 set c2=!pX:~1,1!
 IF /I "%0"==":UCase" (
 if %frstChar%==!c1! SET _Abet=!c1!
 if %frstChar%==!c2! SET _Abet=!c1!
 )
 IF /I "%0"==":LCase" (
 if %frstChar%==!c1! SET _Abet=!c2!
 if %frstChar%==!c2! SET _Abet=!c2!
 )
)
SET _Word_Rtrn=%_Abet%%rstChar%
SET %2=%_Word_Rtrn%
GOTO:EOF


endlocal

Usage

<your batch file name> <the module name>

Install Zend Framework 2 into Windows IIS

This article will show you how you can install Zend Framework 2 into your windows OS without composer.phar help.

1. Download latest stable copy of ZF2 from http://framework.zend.com/downloads/latest and unpack, we call it ZF2

2. Download latest stable copy of ZF2 skeleton app from https://github.com/zendframework/ZendSkeletonApplication/ and unpack, we call it ZF2Skeleton

3. Create folder like <ZF2Skeleton folder>/vendor/ZF2. Now copy ZF2/* into <ZF2Skeleton folder>/vendor/ZF2 And the final directory structure may look like following image (for ZF2 version 2.3.1 dated 20140426)

zf2 basic folder structure

4. Now point any domain into “public” folder. e.g. zf2.localhost.tld

  • 4.a. Open notepad as administrator user
  • 4.b. Add an entry to your hosts (file) like – “127.0.0.1 zf2.localhost.tld” [one host in each line]
    • 4.b.1 hosts file is typically located at C:\WINDOWS\system32\drivers\etc\hosts
  • 4.c Now save the hosts file and close
  • 4.d. Now create an entry in your IIS (6 or 7 both are same procedure) by following http://support.microsoft.com/kb/816576 with the above host name i.e. zf2.localhost.tld

5. Now you need to fix ZF2_PATH or $zf2Path variable at “/init_autoloader.php” file of root to point our “/vendor/ZF2” folder

Find following code:

$zf2Path = false;
if (getenv(‘ZF2_PATH’)) { // Support for ZF2_PATH environment variable
$zf2Path = getenv(‘ZF2_PATH’);
} elseif (get_cfg_var(‘zf2_path’)) { // Support for zf2_path directive value
$zf2Path = get_cfg_var(‘zf2_path’);
}

Replace by following code:

define(‘DS’, DIRECTORY_SEPARATOR);
define(‘APP_ROOT_PATH’, dirname(__FILE__).DS);
$zf2Path = false;
if (is_dir(APP_ROOT_PATH.’vendor’.DS.’ZF2′.DS.’library’)) {
$zf2Path = APP_ROOT_PATH.’vendor’.DS.’ZF2′.DS.’library’;
} elseif (getenv(‘ZF2_PATH’)) { // Support for ZF2_PATH environment variable or git submodule
$zf2Path = getenv(‘ZF2_PATH’);
} elseif (get_cfg_var(‘zf2_path’)) { // Support for zf2_path directive value
$zf2Path = get_cfg_var(‘zf2_path’);
}

You can now visit zf2.localhost.tld to get your expected site.

Please note, you must run latest copy of PHP (at least bigger then 5.3.23 when I write this article there I found version 5.3.28 stable for windows non thread safe version installer for download) from http://windows.php.net/download/

Now the problem is URL route in IIS. That means when you lookup into ZF2 getting started docs you may find some code to edit .htaccess of apache. What about IIS in this case?

IIS have solution of URL rewrite problem. Visit www.iis.net/urlrewrite to get the latest copy of the plugin to attach into your IIS installation. Just install this addon/plugin/extension/demon/program whatever name you called.

After installation you need a file web.config into your “<ZF2Skeleton folder>/public” folder. No matter, here we do a small trick. Just download Drupal 7+ core from https://drupal.org/project/drupal and unpack it. There you found a web.config file at root path. Just copy and paste that file into your <ZF2Skeleton folder>/public folder.

That’s all folk!

ckeditor installation into drupal with imce

As a professional app developer, I faced to install ckeditor into drupal many times. Each times I need to dig again and again to its working. So, now I think I have to write it down that will help me and others too😉

Install ckeditor into Drupal with IMCE

Its simple two step > Download & Put it into right place, Configure & use.

Download & Put it into right place

1. Download Drupal module of ckeditor from https://drupal.org/project/ckeditor
2. Download Drupal module for IMCE from https://drupal.org/project/imce
3. Put those module into “sites/all/modules” folder or where you think appropriate
4. Now download full version of ckeditor from http://ckeditor.com/download
5. Put full version of ckeditor into “<path where you put your ckeditor drupal module>/” please visit http://docs.cksource.com/CKEditor_for_Drupal/Open_Source/Drupal_7/Installation for details instruction where to put

That’s it, you are done the first step

Configure & use

Now enable that two module from your Drupal control panel.

1. Fix permission for ckeditor
2. Configure IMCE
3. Configure text format – Administration > Configuration > Content authoring > Text formats
3.a) For Advanced Html >> enable filter “limit allowed html tags” and leave it as it is or put “<a> <p> <div> <h1> <h2> <h3> <img> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <em> <b> <u> <i> <strong> <del> <ins> <sub> <sup> <quote> <blockquote> <pre>” allowed or as your requirement
3.b) For Full Html >> enable filter “limit allowed html tags” and put “<a> <abbr> <acronym> <address> <area> <article> <aside> <audio> <b> <bdo> <bgsound> <big> <blockquote> <br> <br /> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <command> <datalist> <dd> <del> <details> <dfn> <div> <dl> <dt> <em> <fieldset> <figcaption> <figure> <font> <footer> <form> <h1> <h2> <h3> <h4> <h5> <h6> <header> <hgroup> <hr> <hr /> <i> <img> <input> <ins> <kbd> <keygen> <label> <legend> <li> <link> <map> <mark> <marquee> <menu> <meter> <nav> <object> <ol> <optgroup> <option> <output> <p> <param> <pre> <progress> <q> <rp> <rt> <samp> <section> <select> <small> <source> <span> <strong> <sub> <summary> <sup> <table> <tbody> <td> <textarea> <tfoot> <th> <thead> <time> <tr> <tt> <ul> <var> <video> <wbr>” allowed or define tag to allow as your requirement
4. Now configure ckeditor. Specially for file browser settings. Point it to IMCE. Please configure both profile (Full, Advanced)

That’s it. nJoy….

pure-ftpd status error – pure-config.pl dead but subsys locked

I’m experienced to install VSFTPd and I’m using it for 2/3 years. But for a recent project I need to setup a test linux box and there I install pure-ftpd for test purpose. Its easy to install but when I start the server I face a problem. I’ll tell you that story, but before that story I want to share the experience install pure-ftpd in my linux box.

Everything goes fine with out any problem. I always try to install from source i.e. make and install. And always try to install into default directory if there has no security issue. In this case to install pure-ftpd every thing goes fine as usual. Install complete! Now how can I start the server that I just installed…..?????? Actually in latest version (1.0.29) there has no init script installed. So, I can’t start pure-ftpd by service command!!! So, I search the net, here and there but didn’t find a init script that I can use. So, I decide to make it by myself. For that I go to source directory for getting the default path of the installed program. Owo!!! thats I found the init script. Thanks the pure-ftpd team. But you should write instruction so that our time may saved. So, finally I copy it to “init.d” and started server. Server starting normally. And now the problem arised!!!!!

When I try to get the status of pure-ftpd server for monitoring purpose. It shows following message –

pure-config.pl dead but subsys locked

Ohh, I didn’t mention yet! I use “pure-config.pl” script to start my server. Now, when I get this status message I was worried that I fail to setup properly and start googling on this error. Sad, they all point the wrong direction! Anyway, after 12 hour of searching I realize that it’s not a common problem. Its may be a small mistake that can’t get run pure-ftpd. So, I start to find the problem internally. I find that my server is running well. And I’m able to do ftp through it!!!

Finally, I start digging the init script and perl script for the problem. And find that in init script there has line which checking the status of “pure-config.pl” not pure-ftpd daemon!!! So, I just change to check the status of pure-ftpd instead checking status of “pure-config.pl”.

Actually, what happened there when I try to get status? My init script geting status of pure-config.pl and find that the script is run and not active. But the sub-sys (i.e. pure-ftpd) that start by the script is still running. So, its show status like that!!! And its really confusing, specially for the user of my kind who don’t know linux at all.

Normal user privilege problem for using WiMax USB Modem in windows 7

This is my first post from my laptop. From now on I can write from my home. Recently I buy a Dell Core i3 laptop made in china. Please note, I’m from Bangladesh. Here we all enjoy duty free & all kind of tax fee computer peripheral. Thats why we get these technological facilities with cheap rate. Anyway, Its not my issue. After getting laptop I get a connection from our local WiMax service provider Bangla Lion. Their’s modem is USB modem. Its nice after installation and configuration. Problem is for other users of my laptop…

I always like to use computer with normal user rather then administrator user. Here I can impose many restriction for security reason to fight with VIRUS. So, when I login with my another normal user I fail to connect with my provider… I phone them customer support they didn’t get any solution. So, I start R&D for this issue and finally got success for 6 hours. I’m using windows 7 that was with my laptop and off-course pirated copy (thanks MS, really we Bangladeshi techi personnel can’t achieve the latest trend if we don’t get this facilities). So, guys if you face any problem just do following……

  1. Install your modem with administrator account as usual normal installation. Nothing special while installation process.
  2. Now go to the folder where you installed your modem and change security settings
  3. Add your user’s for permit to use modem with read-write permission to that folders & its content’s and sub-folders.
  4. Then go to windows firewall settings and add your modem software permit for both communication of home and public. I know this may cause a security whole if you can’t trust your provider. But if you trust your provider’s software its not a problem at all.

Actually my modem need write permission to that folder. May be some file it modify before starting to program file path. And it can’t write to that path and forbidden to use the modem.

Hope this post will save someone’s 5~6 hours just for 15 mins…. lols

How reduce your image size without losing quality for using profile picture of web page

Many of us worry about our picture that is too big size. Some website didn’t permit big size image to upload as profile picture. Some website has some restriction and limit on file size. You need to determine what type of restriction that website has. There are three types of restriction. They are –
1. File size
2. Image dimension
3. Image type
We will not discuss about image type. Image type may be JPG or GIF. You can read more about these formats on net.
Image dimension consist with width and height that measure with pixel. Other measurement unit exists to measure width and height but we will ignore those unit cause maximum website deal with pixel. For change file dimension you need to use image editing software and you need to have a little bit expertise about image. I just show you how you can reduce or enlarge an image dimension with most common and popular software Photoshop. Please note, I just show you a way to change. There has several ways to change the image dimension. Now just follow the following steps…
Step # 01: Open your document into Photoshop.
Step # 02: Go to “Image” >> “Image Size”

You will get a dialogue box to change image size.

Step # 03: Now in image size dialogue box you need to change “Pixel Dimension”. Before change pixel dimension you need to care about some properties…

  1. Mark check box of “Constrain Proportions”
  2. Resolution of “Document Size” portion can be 96. If it is not 96 then change it to ‘96’. And the unit will be ‘pixel/inch’

Step # 04: Now change your desire width and height at “Pixel Dimensions” area. Please note, you must not touch width and height at “Document Size” area.

Step # 05: Click ok and save your image with default options.

That’s all you saved your image with desire width and height. But still your document is big in size. Don’t worry continue reading you will get a solutions. Ohh, please note, when you change resolution, the image width and height may be change automatically. Doesn’t worry just ignore it! You must follow the steps sequentially i.e. at first check “Constrain Proportions” then change “Resolution” then change dimensions.

Image files size measure with Byte, Kilo Byte, Mega Byte, etc. Most website permit user in Kilo Byte size. If you want to know more about file size then you need to surf net. But for this tutorial you need to know the hierarchy of unit.

Bit ———- unit
Byte ——— its also an unit but its big then bit by 8 times
Kilo Byte ——– big size then byte 1000 times
And Mega, Giga… so on

Now at first you need to check your image file size. It’s easy, right click of your mouse on to your image and click properties. There you will get information of your image file size. If it is less then restricted size then don’t need to read down. Just upload your image into that site!

So, you have a big file sized image! Don’t worry; I’m here to help you. Just follow these steps –

Step # 01: Open ‘mspaint’. Go to start >> click on run

Step # 02: You will get a small box. Type ‘mspaint’ and click ‘Ok’

Step # 03: This command will open Microsoft Piant tools for your service. Open your document.

Step # 04: Now save as the document by File >> Save As. Please choice JPEG from ‘Save as type’ drop down list

Step # 05: Save your image with a different name.

Step # 06: Now check file size again by right click on file and go properties.

It’s done! The size is down dramatically.

Enjoy computing…

Font chooser macro

When we need a fine font for specific text we need to write down the text and test the text by changing its font. Its time consuming. So, I make a small macro in microsoft word by VBA macro that prompt you to input the text and draw that text by assigning all available font from your system into different line. Moreover it input the corresponding font name at the starting point of each line.

Here is the macro code FYI:

Sub fontChooserByRazon()
' ' fontChooserByRazon Macro V:1.02 (razonklnbd [at] yahoo [dot] com) ' ' Dim txtStr As String, fntIdx As Long, fntNameLen As Long txtStr = InputBox("Input a text to show through various font of your computer", "Text for font chooser", "The quick brown fox jumps over the lazy dog.") fntIdx = 1 For fntIdx = 1 To Application.FontNames.Count
fntNameLen = Len(Application.FontNames(fntIdx)) Selection.TypeText Text:=Application.FontNames(fntIdx) & ": " & txtStr Selection.StartOf Unit:=wdParagraph Selection.StartIsActive = False Selection.MoveRight Unit:=wdCharacter, Count:=fntNameLen + 2 Selection.StartIsActive = True Selection.MoveEnd Unit:=wdParagraph Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend With Selection.Font
.Name = Application.FontNames(fntIdx) .Size = 12
End With Selection.MoveRight Selection.TypeText Chr(13)
Next fntIdx
End Sub

 

Sub selectedFontChooserByRazon()
' ' selectedFontChooserByRazon Macro V:1.05 (razonklnbd [at] yahoo [dot] com) ' ' Dim txtStr As String, fntIdx As Long, fntNameLen As Long, getInputFromUser As Boolean getInputFromUser = True txtStr = Trim(CStr(Selection.Text)) If Len(txtStr) > 2 Then
getInputFromUser = False Selection.StartOf Unit:=wdParagraph Selection.MoveEnd Unit:=wdParagraph Selection.MoveRight Selection.TypeText Chr(13) Selection.MoveLeft
End If If getInputFromUser Then
txtStr = InputBox("Input a text to show through various font of your computer", "Text for font chooser", "The quick brown fox jumps over the lazy dog.")
End If If Len(txtStr) > 2 Then
Selection.TypeText Chr(13) fntIdx = 1 For fntIdx = 1 To Application.FontNames.Count
With Selection.Font
.Name = "Verdana" .Size = 12
End With fntNameLen = Len(Application.FontNames(fntIdx)) Selection.TypeText Text:=Application.FontNames(fntIdx) & ": " & txtStr Selection.StartOf Unit:=wdParagraph Selection.StartIsActive = False Selection.MoveRight Unit:=wdCharacter, Count:=fntNameLen + 2 Selection.StartIsActive = True Selection.MoveEnd Unit:=wdParagraph 'Selection.EndKey Unit:=wdLine, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend With Selection.Font
.Name = Application.FontNames(fntIdx) .Size = 12
End With Selection.MoveRight Selection.TypeText Chr(13)
Next fntIdx
End If
End Sub

Here is the screenshot:

This is my first VBA macro… If you have more suitable version please share with me…

Be organized: File Name Convention and Digital Storage Organizing Tips

When I’m at class IX, that time I take a crash course for good hand writing. But today I do most of my job at my PC where no hand writing is needed? Is it a wasted of time that everyone value?

Do you do a lot of work with documents that constantly have to be saved? Well, if you do, you should know that the first time you save a file, you should choose a “file name” for it to be stored under. Note that some programs will automatically put a file name in for you, but it is much better if you name your own files. That way, you have a better chance of finding them later on.

The first time you save your work, you should use the Save As command to tell your computer what “file name” you want to save your work in. (In some programs, if you use the Save command, the first time you save, it will act as if you clicked on the Save As command anyway, but this is only in some programs. So, all in all, you should develop a habit of using the Save As command the first time you save a new file). The Save As and Save commands are usually under the File menu as well.

So, when you are typing a new document in your word processing program, the first time you go to save it, click on File to bring the menu down and then click on Save As to bring its dialogue box up. In the Save As dialogue box, you can tell your computer where to put your file and what to call it. I won’t get into where to put your file here, except to say that if the computer is putting your files in the My Documents folder, that is fine for now. You can always go and change it later.

Another point is for file extension is; many OS hide the file extension for normal user. It’s a good practice to show extension all the time so that you know by which program is best suit for open that file by analyzing extension.

Next, you have to tell your computer what “file name” to save your file under. You should name your file according to what is in it. For example, if it is a letter to your son, John, call it “Letter to John.” Don’t just name it “Letter.” That is too vague.

Here are some examples of good file names:

2009 Taxes for Bob Smith
Personal Budget 2008
Car Prices 2009
Investment Notes from June 2007 Course
Daily Weight for John Starting March 2008
To Do List

Please note: Careful about to do not use periods, especially at the end of your file names.

Here are some examples of bad file names (the problem is listed beside each one):

John This does not say what is in the file (if this is a letter, calculations, genealogy information, etc).
Letter This does not say who it is for.
Letter to John. This has a period at the end of it, which causes problems.
To Do List March 20/09 This file name has a slash ( / ) between the 20 and the 09. The computer will not accept this.
Letter to “Mom” The quotes around Mom will not be accepted by the computer.
Interest * Principal – List of Payments This file has an asterisk ( * ) in it, which the computer will not accept. The dash ( – ) is okay.

So, rather than memorizing all the details and risk having a problem, keep it simple. When you name a file, use only letters and/or numbers, with no punctuation marks. This will make everything easier on you and on your computer!

When create a file that is personal; Start them with your initials (i.e PR: Pronay Rozario) also do the same for important Personal file folders. It’s extremely easy to find your personal and important files by searching for your initials. One more thing…if you create any general use folders, you know the name initials of that folder. If you want to delete it, it’s easy!

When I’m thinking to find files from my colleague’s computer I’m very much scared that I can find it. A well organized file system may work easy for all to find important file from other’s computer. This is not only important for one who uses that computer but also for one who want to help him when he is out of office or at leave. And for common PC this is extremely important, isn’t it?

You need to remember following point to organize your folders –

  • Other users need to find the entire required file quickly.
  • You want to search your required file from archive.
  • You may guess file location for particular working file and find it to that location.
  • You may backup your data for safety purpose.

For above reason you may want your entire file into a common place that is easy to backup and find. Also it’s easy to other to find to that location.

For a well organized file system you may divide your entire file system into category. The basic category I can suggest – Work, Personal, Important Collection, Entertainment, Archive or Past Work, Others etc. I’m always kept a folder named others. In this folder I like to put those file which has no head or name or category, temporary file that might need to save for a limited times. I like to use drive for each root category. If you have not enough drive into your system or you use flat system like Linux or Unix you can create folder into root directory or to that drive you use for store data. I don’t like to use system directory for store data.

Here are some tips to organize your computers files and folders:

  1. One place for all: For many reasons, it’s smart to take advantage of the Documents feature (called My Documents in Windows XP and earlier versions) in Microsoft Windows but I don’t rely on this because it placed into system directory or system drive.  But it’s important to keep the entire document into a central place to take following advantage –
    1. Find files. It’s easy for indexing by OS to provide search result if you keep your file in one place.
    2. Back up files. You should back up files regularly—and keeping all your files in one place helps make backup a snap into backup media like CD, DVD or Magnetic Tape.
    3. Keep files separate from programs. By separating document files and program files you reduce the risk of accidentally deleting your documents when you install or upgrade programs.
  2. Adopt consistent methods for file and folder naming: Every company has their own naming convention. If your company haven’t one develop a naming scheme for the kinds of files you create most often and then stick to it. Do not use spaces in file names, keep file names under 27 characters, and use all lower case. So a file named should be “square_pharma” rather than “Square Pharmaceuticals Limited”. Oracle developer may be wanted to put all UPPER CASE and java programmer may want to do it with Camel Case. But I recommend you that, if you break any of these rules, be consistent about it.
  3. Keep names short: Even though Windows allows you to use long file names, it does not necessarily mean you should. Long file names are harder to read.
    1. Use abbreviations. Keep file names short by using common abbreviations, such as “MTNG” for meeting or “ACCNTNG” for accounting. This makes the file names more descriptive and you can more easily find files through Search if it’s necessary. I like to trim all vowels except first one for abbreviations. If possible create your own abbreviations style. But you must keep log and explanation written into a text file into root directory. Named that text file – “abbreviations.txt” or “readme.txt”. Please note, if you consistent with one rule you don’t need to put the text file.
    2. Let your folder structure do some of the naming: For example, rather than create a file called “great_bangladeshi_novel_chapter_one_first_effort.doc”, you can build a structure like:

      creative_writtings >> great_bangladeshi_novel >> draft01_u20091110_dr3 >> ch1 >> <then your file name>.doc

      creative_writtings/great_bangladeshi_novel/draft01_u20091110_dr3/ch1

  4. Nest folders within folders: Create other folders within these main folders as need arises. For instance, a folder called “invoices” might contain folders called “2004”, “2005” and “2006”. A folder named for a client might include the folders “customer_data” and “correspondence”. The goal is to have every file in a folder rather than having a bunch of orphan files listed.
  5. Organize files by dates: Use a date in the document name. Such as dv20081215, this would mean December 15, 2008. This puts all the DV sent at that specific date together and sorted by date.
  6. Be specific: Give files logical, specific names and include dates in folder names if possible. The goal when naming folder is to be able to tell what the file is about without having to open it and look. So if the document is a letter to a customer reminding him that payment is overdue, call it something like “overdue20081206” rather than something like “letter”. How will you know who the letter is to without opening it?
  7. Don’t save unnecessary files: Be selective about the files you keep. You probably don’t need to keep them all. With e-mail, for example, you rarely need to keep everything you receive.
  8. Keep individual folder for a project: Keep your entire document related a project into a folder. So, you can take back up for a project and burn CD.
    1. Separate ongoing and completed work. To keep the Documents folder from becoming too unwieldy, use it only for files you’re actively working on. As a result, you can reduce the number of files you need to search through and the amount of data you need to back up. Every month or so, move the files you’re no longer working on to a different folder or location, such as a folder on your desktop, a special Archive folder, flash drive, external hard drive, or even on a CD.
    2. Use common names. To make it easier to search for documents, name your files and folders with easily found names, such as model numbers, project names, or the project lead in the title. Suppose every project should have proposal. So, named this file as “proposal.doc” something like this. Every project need images file so create a folder named “images” into your project folder. So, that every image is related on that project can be stored into that folder.
  9. Use shortcuts and shortcut links instead of multiple copies: If you need to get to the same file from multiple locations, don’t create copies of the file. Create shortcuts to it instead. To create a shortcut, right-click on the file and click Create Shortcut. You can drop and drag the shortcut to other locations. Moreover you may need to organize your folder such way like current working folders, folder of MD sir, folder of software department etc. Those folders may be categorized by different way. So you can create shortcut of those folders and organize several way.
  10. Cull your files regularly: Sometimes what’s old is obvious as in the example of the folder named “Invoices” above. If it’s not, keep your folders uncluttered by clearing out the old files. Do NOT delete business related files unless you are absolutely certain that you will never need the file again. Instead, in your main collection of folders in your data storing drive or root folder, create a folder called “Old” or “Inactive” and move old files into it when you come across them.
  11. Back up your files regularly. Whether you’re copying your files onto another drive or onto tape, it’s important to set up and follow a regular back up regimen.
  12. Put Reference on the desktop: Put a folder named “important_shortcut” on the desktop. Put your entire folders or files shortcut icon into that folder. So, you can save several clicks of the mouse to get where you want to be sooner.

Proposed convention for a well organized file or folder name:

The proposed file naming convention defines a readable, delimited, long filename format. The delimiting character is an underscore or hyphen.  In all cases where an alphabetical character is called for, the character must be lower case. OS may be treat upper and lower case letters the same or not.  The required contents of the filename will be as follows, in order: “File Name,[ Version Information, Create Date with Time, Last Updated Date with Time]” Additional information may be added as required by the user.  The working group suggests that the additional information be in the following order: “Optional 1, Optional 2, and so on”. Additional information will add before optional information. If additional information exists there must be present optional information.  The extension will always follow.

So the template for the file name is as follows –
[File Name]__[Additional Information]__[Optional Information].[Extension]

Here point to be noted that, delimiter is double underscore of each section. So, you can’t use double underscore into a section. You can use single underscore or single hyphen to delimit each word. Double hyphen is reserved for system purpose or automatically generated file name. And we discourage you to use single hyphen too.

File Name & Additional Information:

File Name will discuss later. Additional information is totally determined by user. And we discourage to use additional information because you have full right to make your own style file name.

Optional Information:

Optional information is consisting with “Create Date with Time and Last Updated Date with Time, Version Information”. For put create date you need to put leading ‘c’ and for update date you need to put ‘u’. You can give any one information. And total information is optional. But it good practice to put this information into your file name. But if you put this information you must follow the order and delimit each section with single underscore.

Each version number will followed by ‘v’ and then version number without any delimiter. Example: v1, v35. Please don’t use 01 or 02 just count from 1 and so on. This is also suggested to use ‘dr’ for draft version followed by revise number. You also suggested putting application version information though it’s optional. I suggest to use application version cause, we will easily recognize by file name to what version I need to use to open this file. I faced the problem when I use Adobe Illustrator or Photoshop. Please follow this order to form version information “application version, version/draft number”. Example: av11v5-3, av9v6, dr9 etc. Here version 5.3 represent as 5 hyphen 3. So, you can user hyphen as delimiter.

Using a date in the file name always state the date ‘back to front’. Why? Because then when you look at your folder and sort it by file name, all the files will sort in the order of the dates. It’s a super-easy way of organizing your files by date. Use four digit years, two digit months, two digit days, two digit hour and two digit minute (we will recognized this minute with NN): YYYYMMDDHHNN or YYYYMMDD or YYYYMM or YYYY or YYYYtoYYYY or MMtoMM or mMMdDD or mMMdDDtomMMdDD or hrHHmnNN

Extension:

Most programs automatically add the correct “file extension”—a 3-letter addition to the end of the filename that identifies the type of file to your computer (.doc = MS Word document; .wpd = WordPerfect document). In general, do not alter the file extension. If your program didn’t provide it automatically provide by yourself with your own standard and according your file type, format and by which program you want to open this file.

Example: (Some examples of good file names with their explanation)

y2009_taxes_for_bob_smith__c20100121_u20100202.doc Here you can’t start file name with number so I use ‘y’ and it also including optional information (create date and last date of modify)
personal_budget_2008__v1.doc Here into optional information we put version information.
car_prices_2009.xls No optional information
investment_notes_from_june_2007_course__av2007dr15.doc It is creating by MS office 2007 and it’s a draft file that is revised 15 times till now.
js_daily_weight_200803__u20080401_v35.doc Here we last update this file at April 1 of 2008 and its revised 35 times when update.
to_do_list__av2007v3.doc The list of what to do today.

The conventions comprise the following 18 rules:

  1. The default file name is determined by that file contains.
  2. The name is formed by taking the full expanded name of the unit and replacing the separating dots with hyphens and using lowercase for all letters.
  3. File names must not contain spaces or any special characters such as “& + # \ / : * ? ” ‘ < > | ! .” or non-alphanumeric characters.
  4. Do not start the file name with a number.
  5. When in doubt, keep the file name as short and simple as possible, but meaningful. For example use hist_100a_readings.html not hist100ab*readings
  6. Be sure to include the extension after the filename – for example .htm, .php, .doc, .xls, .pdf, .ppt, .psd, .ai, .jpg
  7. Avoid using four digit extension name of a file format.
  8. Avoid unnecessary repetition and redundancy in file names and file paths. Example: Goodhttp://www.eg.edu/business/sell/staff/, Redundanthttp://www.eg.edu/business/sell/sellstaff/
  9. Use underscores or hyphens to delimit words, not spaces or capital letters.
  10. When including a number in a file name always give it as a two-digit number, i.e. 01-99, unless it is a year or another number with more than two digits.
  11. If using a date in the file name always state the date ‘back to front’, and use four digit years, two digit months, two digit days, two digit hour and two digit minute (we will recognized this minute with NN): YYYYMMDDHHNN or YYYYMMDD or YYYYMM or YYYY or YYYYtoYYYY or MMtoMM or mMMdDD or hrHHmnNN
  12. When including a personal name in a file name give the family name first followed by the initials i.e PR: Pronay Rozario
  13. Avoid using common words such as ‘draft’ or ‘letter’ at the start of file names, unless doing so will make it easier to retrieve the record.
  14. Order the elements in a file name in the most appropriate way to retrieve the record.
  15. The file names of records relating to recurring events should include the date and a description of the event, except where the inclusion of any of either of these elements would be incompatible with rule 8.
  16. The file names of correspondence should include the name of the correspondent, an indication of the subject, the date of the correspondence and whether it is incoming or outgoing correspondence, except where the inclusion of any of these elements would be incompatible with rule 8.
  17. The file name of an email attachment should include the name of the correspondent, an indication of the subject, the date of the correspondence, ‘attach’, and an indication of the number of attachments sent with the covering email, except where the inclusion of any of these elements would be incompatible with rule 8.
  18. The version number of a record should be indicated in its file name by the inclusion of ‘v’ followed by the version number and, where applicable, draft use ‘d’ followed by the version number. Also use application version (av) with their number by which the file created, except where the inclusion of any of these elements would be incompatible with rule 8.

Finally…

Everyone should have their own policy. But you must think about how can your public accessible file is more accessible in easy way, isn’t it?

For your information, I forgot my good hand writings. Really I missed those style…

Disclaimer:

This article is written for established a common concept for a well organized file structure. Many many thanks to Rahinur Rahman Reza of Square InformatiX Ltd. for his valuable comment on this article that easy for me to write it.

by-

| Md. Shahadat Hossain Khan
|
Web Developer, Square InformatiX Ltd.

« Older entries

Follow

Get every new post delivered to your Inbox.