Programming Experiences

Revision control is the process of managing multiple versions of information. Simply form, people do these manually when any automated system doesn’t exist. When we have new revision of file we saved it with a new name. Sometimes with date identifiers and sometimes with higher numbers than one another. But still there are strong chances of errors and messing up of clean code.

Software system ease the not only life of normal person but rapidly growing industry put also whole effort to facilitate the IT programmers.  In early stages the basic revision control system intended to help the single user to manage the single file or directory structure.  From last decade the scope has been wide and automated revision control system designed for multiple users to work together on a single project. In some large projects thousands of people working on a single project and thousand of files need to be manage.

 

There are a lot of reasons that purse you to go for any revision control system; I am writing some of the basic reasons that can ease your life if you use it frequently;

  • Tracking history will create the log of your changes, in manually its tedious task that who made the log and what exact things you have done.
  • If you are working without any revision control system, you can’t revert the code at any previous state. Revision control system provides you the flexibility of reverting the code with proper date/time history of tracking.
  • Two developers / Programmers are working on a same project on a same file on different locations, it will help you out to identify the changes and give you feasibility to fix the conflicts of the code

These are the basic reasons of version control system that are understable for any non-IT person also J

People don’t confuse with the different terms in the project it’s almost the same thing which different name; List of names which you can find generally;

  • Revision control (RCS)
  • Software configuration management (SCM), or configuration management
  • Source code management
  • Source code control, or source control
  • Version control (VCS)

The name of OS SCM projects which we are going to discuss in next blog post

  • CVS
  • Subversion (Most Famous tool on internet for sub versioning)
  • Git
  • Mericual

 

Sometimes you need to put the email address in your webpages for direct contact. And after that you are getting too many spam emails. Specially in this case when you want to shout the email on contact us link. Spam lists are updated very frequently by spam-crawlers and spam bots. The purpose of the spam bots are list the email address and they grab the email address where ever they found. They beneficial thing for developer or site owner is Crawlers has large data to scan so generally they didn’t put their effort to execute the JavaScript.

Spam crawlers just check the plain text and didn’t bother to execute the JavaScript of encoded ASCII characters. It’s the best use for prevent the email address from spam bots.

Somedays ago in my working experience I listened the complain that on my company website the email address of different authors is continue crawling and they are getting bunch of spam emails.

First solution came to mind is prevent the things with captcha or any other logical question which can identify the human or bot. But we couldn’t involve any lengthy procedure in the current workflow. So I implemented the following solution which works perfectly for mine. I am sharing the little bunch of code of PHP and JavaScript which can ease your life: D

PHP Solution & JavaScript Solution:

Php has some built-in function which can encode the string into ASCII characters and that wasn’t readable for spam bots.I have used with the combination of javascript and PHP, Just paste the following functions into the php file and check the output.

<?php

define('USE_JAVASCRIPT', TRUE);

function email_ascii_encode($string, $js) {

if ($js) {

$output = "<script type='text/javascript'><!--

document.write('";

}

for ($i=0; $i < strlen($string); $i++)          {

$char = substr($string, $i, 1);

$encode .= '&#'.ord($char).';';

if ($js) {

if (in_array($char, array('.', '@'))) {

$encode .= "'+'";

}

}

}

if ($js) {

$output .= "<a href=\"mailto:'+'$encode'+'\">'+'$encode'+'</a>";

}

else {

$output .= $encode;

}

if ($js) {

$output .= "');

//-->

</script>";

}

return $output;

}

function email_encode($match){

return $match[1].email_ascii_encode($match[2], USE_JAVASCRIPT).$match[3];

}

function email_prevent($string = ''){

$pattern = "!(<p>|<li>|<br />|[ \n\r\t\(])([A-Za-z0-9._-]+@[A-Za-z0-9._-]+\.[A-Za-z]{2,4})([.,]?)(?=(</p>|</li>|<br />|[ \n\r\t\)]))!i";

return preg_replace_callback($pattern, 'email_encode', $string);

}

$str  = '<p>Integer dapibus gravida turpis, vitae ullamcorper velit mollis in. Donec malesuada ullamcorper quam ut gravida.';
$str .= 'Curabitur et mattis purus. Ut sem felis, fringilla eu volutpat ut, venenatis eget dui my_email_address@hotmail.com .';
$str .= 'Quisque lobortis scelerisque sollicitudin. In turpis velit, malesuada nec adipiscing quis, viverra a massa! . </p>';

echo(email_prevent($str)); 

?>

Its very easy to understand. Just use the email_prevent function for text, this will search into the content and change the email address to ascii characters. Meanwhile i have defined the constant at top for javascript. If you are not willing to use javascript, replace with FALSE.
If you need any kind of help you can contact me.

Have fun Guys!

I was working on a content based site some days ago. My client’s requirement is that he needs a button of Zoom in and Zoom out on top of the article. By clicking on Zoomin button the font should be increased by +1 size and similarly on zoomout it reduces the size by -1. After surfing on internet i concluded that this type of Jquery / Prototype plugin is not available or maybe it is,but,i was unable to get it.
So i decided to do it at my own. This was not based on allot coding. here is a small piece of code that worked for me.

I am writing for those developers who are a bit familiar with jquery or any JavaScript library. Small piece of code with handy functionality.here is a little chunk of code for demonstration.

Suppose your content is displaying on site like this;

<div><p>Your Content</p></div>

1.include the Jquery in head section of HTML page.

2.copy paste the following code and save into js file. I saved it as zoomer.js

// js Document

var fontSize = 1;

function zoomIn() {
fontSize += 0.1;
$(‘.zoom’).each(function(ind,p){
p.style.fontSize = fontSize + "em";
});
var $kids = $(‘.zoom’).children();
$kids.each(function(index, e){
e.style.fontSize = fontSize + "em";
}
);
}

function zoomOut() {
fontSize -= 0.1;
$(‘.zoom’).each(function(ind,p){
p.style.fontSize = fontSize + "em";
});
var $kids = $(‘.zoom’).children();
$kids.each(function(index, e){
e.style.fontSize = fontSize + "em";
}
);

}

3. Include the zoomer.js file with following code.
<script src="zoomer.js"></script>

Don’t forget to include the zoomer.js after the Jquery js library.

4.assign the class "zoom" to div or whatever html element, you want to zoom in and out.

<div class="zoom"><p>Your Content</p></div>

5.After doing this, i have placed two links of Zoom-In and Zoom-out on the top of article.

Example:
<a href="javascript:void(0)" onclick="zoomIn()">Zoom IN</a>

<a href="javascript:void(0)" onclick="zoomOut()">Zoom OUT</a>

We are done with zoom in and zoom out.

If you are familiar with Jquery plugins or click functions. it can be used as plugin too.

After suffering on internet, it is understood that programming is not an easy job. Mostly languages are not user friendly or might be not good enough yet. People think that we designed our languages in hard way so we keep away the people to programming. But the real truth is programmers (software engineers) couldn’t try to make the programming difficult. No doubt its based on logics, maths and engineering rules. And we can say it difficult.

Today a friend of mine arguged with me that we need to give-up text languages and should use only GUI languages. If its the matter of GUI, than every person should be good enough in mechanical and engineering as well. Only electrical engineer can connect the wires and understands the circuits.  Maths, Logics is an essential part in any programming (like electrical, mechanical etc)

I do believe on one thing that if you are good in logics, maths you can be a good programmer. Even i experimented with some non-technical guys, and i got the good results. But Some happening forced me to write that every person is not good in each every field.

I ll write in more details. Microsoft put their whole effort in penetration and capture the web market share with their awesome toolkit .NET, besides all their effort, they couldn’t break the share of PHP. Isn’t the matter of easiness or something else?

Personally i do believe that PHP is the easiest language in programming. We have different frameworks in each language. and one thing also to consider that frameworks are developers friendly not language friendly. So we can say that programmers are sloping curve towards non-technical persons.

If you are good in maths, logics and general engineering rules, you are Good to go with programming. But no doubt its difficult for incoherent and lazy persons :)

Twitter Updates

  • Eid Mubarak to all those celebrating tomorrow. 8 hours ago
  • RT @Ali_Abbas_Zaidi: "Man is naturally unhappy. He has to invent reasons for his misery!" 3 days ago
  • Low-born, I start liking this term 3 days ago
  • RT @khamenei_ir: What’s #Israel?A fake regime&a false nation. They gathered some greedy ppl fr across the world on the pretext of a better … 6 days ago
  • Finally got the first payment of my own book. Well! its not much, but it feels good :) 6 days ago
Follow

Get every new post delivered to your Inbox.