Tagged: Programming

Truncate last N lines of a file using PHP

For one of my project I needed to remove certain footer / tail-end lines from the file to make it clean as it was containing some summary of records within the file. Because if I do that it can be directly loaded into database by LOAD DATA command. To remove lines from the end of file you can use following snippet of code:

Simple / Plain Ajax – without any JavaScript library

Yes, we are in the world of AJAX where we don’t live without jQuery, Prototype or Mootools but when it comes to explaining someone that how raw ajax works, you need an example of plain AJAX which we have been using 5 years back when these libraries were either just born and were not as famous as today. Because my favorite jQuery has become a de facto standard when it comes to DOM manipulation or AJAX.

Recently I have to give an example to one of my friend on how raw AJAX works and here I am sharing that sample with my blog readers as a reference.

Posting or Uploading Files using cURL with PHP

cURL is very important tool for PHP programmers, we tends to do so many thing with using this tool. Posting data, imitating a form post and lot more, it’s usage is countless. Some time back I came across situation where we have to post files to a 3rd party faxing service. I knew there are many possibilities but I didn’t wanted to get into sockets and file stream to get this done, just wanted to post FILE in addition to rest of the post data.

jQuery Magnet Multi-Select List – DG Magnet Combo

No Control+Click combo or list, just with your simple HTML and little jQuery magic (or magnet)
dg-magnet-combo is smart combo won’t require you to provide 2 list/combo-box in user interface to have them choose options easily, Users don’t need to keep CTL pressed while they select another option of the select-control. If you’re wondering how just try this sample.

The perfect regular expression for email validation

Okey..! You are looking for “The perfect regular expression for email validation……” aaah..! That’s great. I have come across an article as author has done lot of analysis to find out the perfect regular-expression and benchmark it against hundreds of test-cases.

A Mind Teaser – good one..!

Last fortnight my team has put their mind on test with one puzzle (passed on to us by other programming department) and it went quite well for everyone.
It was more about basic math rather than programming and it was good to see everyone refreshing their mind with roots of math/programming. I am sharing this puzzle/question on my blog and want my reader to put their mind and some of their time to crack this and put down their results as comments on this post.