Random Post: "ping" in PHP
RSS .92| RSS 2.0| ATOM 0.3
  • Home
  • About Me
  • My Publications
  • My Work Domain
  • phpResource Feeds
  •  

    Fastest Solution to Count Number of Lines Inside a File

    August 23rd, 2006

    Here is another PERL stuff to share.

    Many systems have a wc program to count lines in a file:
    ——————————-
    $count = `wc -l < $file`; die "wc failed: $?" if $?; chomp($count); ------------------------------- You could also open the file and read line-by-line until the end, counting lines as you go: open(FILE, "< $file") or die "can't open $file: $!"; $count++ while ;
    # $count now holds the number of lines read

    Here’s the fastest solution, assuming your line terminator really is “\n”:

    $count += tr/\n/\n/ while sysread(FILE, $_, 2 ** 16);

    Enjoy PERL. Enjoy Programming.


    Browser Detection by PERL

    August 23rd, 2006

    I am enjoying PERL a lot. I am seeing everything new in PERL. I want to share interesting and important PERL stuffs through my blog.

    Here is a PERL subroutine that detects whether the browser is Firefox or NOT.

    sub is_firefox {
    my $agent = ”;
    $agent = $ENV{“HTTP_USER_AGENT”} || ”;
    if (length($agent) && $agent =~ m/firefox/si) {
    return 1;
    }
    return 0;
    }

    Enjoy PERL, the scripting pioneer.

    $Rupom


    Important Issues in Sending HTML Email

    August 8th, 2006

    If you want your HTML email to put into recipient’s INBOX, you have to follow some rules.
    Following are some important issues for sending HTML email:

    1. Remove unnecessary HTML tags:

    Remove these tags from your mail content:
    – DOCTYPE
    – <html>, </html>
    – META Tag
    – HEAD
    – BASE
    – LINK
    – TITLE
    – Comments

    2. Use table for layout

    Because of the very limited support of style sheets in webmail clients, the best and safe way to layout your html e-mail is to use tables.

    3. Use Online Image

    4. Hide Image Toolbar

    5. Use Shortcut URLs:
    URLs of email should be short/small.

    6. Dont Use Anchors

    7. Use Simple Inline Stylesheet

    For example:
    <td style=”font-family: Verdana, Arial, Helvetica, sans-serif; font-size:
    10px;” >Vivamus ut sem. Fusce aliquam nunc vitae purus. </td >

    8. Create your design with a white background color

    Most webmail and e-mail clients use a white background color to display messages.

    <td bgcolor=”#FF0000″>

    9. Use the title attribute instead of alt

    The alt attribute for images doesn’t work in Gecko-based browsers such as Firefox and Mozilla

    10. Use <br /> instead of <p>

    11. Don’t use forms

    12. Don’t use _JavaScript:
    _JavaScript in HTML e-mail is never a good idea because of all the dangerous scripting (for example XSS attacks) that can be executed. For this reason most webmail and e-mail clients disable _JavaScript by removing or ignoring it.

    13. Provide a link for display in the browser

    14. Keep Your Subject Short and Informative

    15. Don’t Use DHTML and Flash

    16. Send your e-mail as multipart/alternative

    If you send a HTML e-mail to people with a webmail or e-mail client who can’t read HTML e-mail, they will only see the HTML code. If you don’t know what your recipients use, send your e-mail as multipart/alternative. This is the HTML version and the plain text version.

    These issues greatly affect the HTML email. Currently I am working on a project where the emails must have to be sent to INBOX. I got success following these issues. I am researching more on that.

    Regards,
    $Rupom


    Nurul Islam, Our Brother :: Save Him

    August 3rd, 2006

    Nurul Islam, A fourth year Electrical Enginerring student of Rajshahi University of Engineering & Technology (RUET), is suffering from kidney damage problem. Doctors’ tests said that his both kideneys are damaged. A lot money is needed to save Nurul from this condition. But his family can’t afford that. So people from the different levels of the society are trying to help Nurul. Can’t we help Nurul to get life back to this nice world ? Or should not we try to save Nurul Islam ?


    See the innocent face of Nurul Islam. Our minimal combined contribution can save a thousands of Nurul Islam. Please broaden your hands, let Nurul keep among us.

    Please contribute as much as you can to save our brother Nurul Islam.

    To help Nurul Islam, please send your contribution to:
    ——————————————————–
    TAHMINA AKTAR
    Saving account no – 34115593
    JANATA BANK.
    Dilkusha Corporate Branch, Dhaka.
    Bangladesh
    ——————————————————–

    Please forward this content to others.

    $Rupom


    Prize “CGI Programming with Perl” to Dhaka

    July 25th, 2006

    Yesterday I got “Innovation Award” winning prize from PHP Classes, an O’relly book named “CGI Programming with Perl”. The prize reached to Dhaka three days earlier, I released it by UPS and got in my hand yesterday. I started my reading on “CGI Programming with Perl” just after receiving the book. I developed two projects by Perl, but I had no “hard copy” book on Perl. This book will help me to know more about Perl. I have already digged a bit and found a lot resources there.

    Once again my thanks to “PHP Classes” members for their votes that made me the winner of the “Innovation Award” of May 2006.

    I am happy in programming !

    $Rupom


    Gmail Address Book Grabber :: New Demo

    July 23rd, 2006

    Yesterday I updated the “Gmail Addressbook Grabber” class and put it to my site’s demo section. From now on, you will see the live example of this class in my site. Please follow this location and see the addressbook grabber:

    http://www.rupom.info/demos/grab_gmail/

    Changes took places in this version are:
    – CURL enability is no longer the only option to use this class
    – fsockopen has been used as an alternative of CURL
    – “Connection Closing” is performed as soon as the data is retrieved from Gmail

    Feel free to suggest me about this new version.

    Regards,
    $Rupom


    Submit Codes to phpResource Coding Contest

    July 23rd, 2006

    We, phpResource Group, started the coding contest at the beginning of this month. We were expecting many codes from the members of the group. Already some members participated the coding contest. But the expectation was too much big for this coding contest. We expected at least 50 codes from the members, but got a very few. This is because many members thought that their codes might not be good enough for the contest. But I would like to express my theme positively for them. You no need to hesitate about your code – feel free and participate the contest, may be something very innovative is hidden inside your code. We encourage you to submit codes to the contest.

    To submit code, please go to http://contest.phpresgroup.org and login with your login credientials. If you are not a member of phpResource Group, please join phpResource Group first, register at http://contest.phpresgroup.org and submit your codes. Once you submitted your code, you will get your code listed to Code Gallery as a participant.
    Best wishes for you – you may be winner of this month.

    Currently we have three sponsors for this coding contest. Three prizes will be distributed among the winners.

    Participate the coding contest – broaden your coding horizon !

    Regards,
    $Rupom


    Submit Demo to phpResource Group

    July 18th, 2006

    We, at phpResource Group, started to keep solutions of problems posted to our group’s site. Already two solutions have been deployed there. In future, we will provide more solutions of the problems posted to phpResource Group. In this regard, we would like to request you all members to send your demos (runnable solutions without major dependencies) of problems.

    Once you solved any problem (of phpResource Group), post the solution to the group and then if you want to provide your solution as a demo solution to our group’s site, please send it to info@phpresgroup.org. We will deploy it to the demo section of http://www.phpresgroup.org/

    Before submitting the demo, make sure:
    – You mentioned the problem number (message number of phpResource)
    – You mentioned your name, email, and website(if any) – we will keep it
    along with the demo.
    – Your solution does not depend on another programs of size is 1+ MB
    – The demo is tested and it runs properly.

    Once again, we request and encourage you all to send your demos.

    Regards,
    $Rupom


    Common Problems with MySQL and PHP

    July 13th, 2006

    We get some common problems during our development work by PHP/MySQL. Here is a short list of common problems with MySQL and PHP along with possible solutions:

  • Error: Maximum Execution Time Exceeded: This is a PHP limit; go into the php.ini file and set the maximum execution time up from 30 seconds to something higher, as needed. It is also not a bad idea to double the RAM allowed per script to 16MB instead of 8MB.
  • Fatal error: Call to unsupported or undefined function mysql_connect() in …: This means that your PHP version isn’t compiled with MySQL support. You can either compile a dynamic MySQL module and load it into PHP or recompile PHP with built-in MySQL support. This process is described in detail in the PHP manual.
  • Error: Undefined reference to ‘uncompress': This means that the client library is compiled with support for a compressed client/server protocol. The fix is to add -lz last when linking with -lmysqlclient.
  • Error: Client does not support authentication protocol: This is most often encountered when trying to use the older mysql extension with MySQL 4.1.1 and later. Possible solutions are: downgrade to MySQL 4.0; switch to PHP 5 and the newer mysqli extension; or configure the MySQL server with –old-passwords. (See “Client does not support authentication protocol”, for more information.)
  • [reference: http://dev.mysql.com]

    See more about it here:
    http://dev.mysql.com/doc/refman/5.0/en/php-problems.html

    Enjoy PHPing !

    Regards,
    Rupom


    Google Checkout API :: Another Option for Online Transaction

    July 6th, 2006

    Google Checkout is a checkout process that you integrate with your website, enabling your customers to buy from you quickly and securely, using a single username and password. Once they do, you can use Google Checkout to charge their credit cards, process their orders, and receive payment in your bank account.

    Google Checkout works with Google’s search advertising program, AdWords, to increase your sales and minimize your expenses. Shoppers who see the Google Checkout badge on your AdWords ads will more easily find you when they search, and for every dollar you spend on AdWords, you can process $10 in sales for free.

    See more of Google Checkout API

    Google Checkout will spread light to the world of online transaction — no doubt.
    Google is greatly serving the online peoples and making life easier.

    $Rupom