Shivakvs

Let's share my code

Cross compile Qt for Arm October 24, 2011

Each language has its own advantage. you can include Qt C++ also. Its has advantage of “same code work over different OS ” . Yes its Independent one. I got a chance to work on Qt c++. Hence I knew Java, Its quite easy for me to understand.  Everyone get struck while begin to learn new language, samething happened to me also.  from my experience,  I used  Makefile utility for compiliation. but Qt uses QMake utility for compiling. So I learnt one more tool QMake.

But at last, I ran the program successfully in arm devices. That time I understood the power of Qt. Later, I built Library (.so) for arm. I have adopted Qt C++ and  thinking so comfortable to use Qt C++.  Those who want to try out Qt for arm. This post may help them.

Steps for Cross compile Qt C++ version of Arm Linux (X11 – opensource):

1. Download Qt source for Linux (X11)  from http://qt.nokia.com/downloads/linux-x11-cpp .

2. Extract the file. Let’s say Qt-dir : qt-everywhere-opensource-4.6.2

3. Replace  <arm-none-linux-gnueabi-gcc> with your compile name in Qt-dir/mkspecs/qws/linux-arm-g++/qmake.conf configuration file.

4. Save those changes.

5. Then,  edit  Qt-dir/mkspecs/common/qws.conf  file.

Set values to the below variables:

QMAKE_INCDIR_X11 =  /opt/…./arm-none-linux-gnueabi-gcc/include

QMAKE_LIBDIR_X11 =  /opt/…./arm-none-linux-gnueabi-gcc/lib

// LD library X11, XExt

QMAKE_LIBS_X11 = -lXext -lX11 -lm

6.  Save changes

7. Go to Qt-dir and Configure by giving below as parameters:

  • -arch arm
  • -xplatform qws/linux-arm-g++
  • -prefix /usr/local/
  •  -platform linux-g++
  •  -little-endian
  •  -armfpa
  •  -no-sm
  •  -qt-mouse-tslib  // Qt Touch screen library
  •  -fast
  •  -no-qt3support
  •  -silent

8. make

9. make install

10. done

 

Qt June 14, 2010

Filed under: Qt Programming — myworldkvs @ 2:46 pm

Qt Config parameters:

Cross Compile the Qt Source code:


./configure -arch arm -xplatform qws/linux-arm-g++ -prefix /usr/local/ -little-endian -armfpa -qt-mouse-tslib -L-lts -no-qt3support -no-largefile -optimized-qmake -no-sm

Qt compilation error:

/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShmDetach'
/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShapeCombineRegion'
/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShapeCombineMask'
/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShmCreateImage'
/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShmAttach'
/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShmQueryVersion'
/qt-x11-opensource-src-4.5.3/lib/libQtGui.so: undefined reference to `XShmCreatePixmap'

Solution:

Linking problem: add -lXext to the linker options(QMAKE_LIBS_X11).

 

Wordwrap using Javascript January 4, 2010

Wordwrap, the below code wrap the length of string and return the wrapped text.

function wordwrap(str,wraplen)
{
var len= (str).length;
var sl;
var total=0;
var wrap=wraplen;
var l = len/wrap;
for(var k=0;k<=l;k++)
{
var e = ((k+total)<slen)? wrap+total: slen;
var b = (k==0)? total:total;
var m = str.substring(b,e);
sl = (k==0)? m:sl+"
“+m;
total=total+wrap;
}
return sl;
}
 

Sending Mail with an attachment July 14, 2009

Here is the source code for sending mail with Image as an attachment. In my example, I have used Linux -Debian -PHP 5 version to check mail attachment. I tried with sending Gif and PNG image. Its works well. I hope it works for other too.. Change the content type image/gif to image/png for PNG and image/jpeg for JPG images.

/* Editable part */
$subject = ‘PHP Mail Attachment Test’;
$bound_text = “shiva123″;
$bound = “–”.$bound_text.”\r\n”;
$bound_last = “–”.$bound_text.”–\r\n”;
/* ////////////////FILE NAME & PATH //////////////*/
$filename=”logo.png”;
$file_path=”/tmp/”.$filename;

/* //////////From and To Address ////////////////*/
$to =”from@domain.com”;
$headers =”From: to@domain.com\r\n”;

/* /////////////////////NON-EDITABLE PART /////////////////*/
$headers .= “MIME-Version: 1.0\r\n”
.”Content-Type: multipart/mixed; boundary=\”$bound_text\”";
$message .= $bound;
$message .= “Content-Type: text/html; charset=\”iso-8859-1\”\r\n”
.”Content-Transfer-Encoding: 7bit\r\n\r\n”;

$message.=”Hai this is example of sending Mail with Attachments\r\n”.$bound;

$file = file_get_contents($file_path);

$message .= “Content-Type: image/gif; name=\”".$filename.”\”\r\n”
.”Content-Transfer-Encoding: base64\r\n”
.”Content-disposition: attachment; file=\”".$filename.”\”\r\n”
.”\r\n”
.chunk_split(base64_encode($file))
.$bound_last;
/*////////////////////////////// NON-EDITABLE ENDS HERE ////////// */

mail($to, $subject, $message, $headers); // sending mail

Thanks Jim Plush!

 

Editing the web content on browser May 14, 2009

  1. Install Add-on “Firebug” in the Firefox
  2. Go to Firebug javascript console.
  3. Type the following in the console
    document.body.contentEditable=true;
  4. followed by
    document.designMode=’on’;
    void 0;
  5. Now you can edit the content of any site in screen itself.
 

File Upload – PHP – curl February 12, 2009

  1. Upload file from html page.
  2. Uploaded file coming to same server. The server reads the file and passing it into Another Server. The server passing only data to remote server not as file.( You cant retrieve using $_FILES @ remote server side)
    $data =$_FILES['myfile']; // Retrieve the file in presence server
    $curl = curl_init();
    $filename =”b_”.time().$data['name']; // giving dynamic file name
    move_uploaded_file($_FILES['myfile']['tmp_name'],$filename); // Moving the file to presence server
    $fp = fopen($filename,”r”); // Open the file
    print “File Uploaded Successfully to the Server using Curl“;
    curl_setopt($curl, CURLOPT_URL, “url”);
    curl_setopt($curl, CURLOPT_PUT, 1);
    curl_setopt($curl,CURLOPT_UPLOAD,true);
    curl_setopt($curl,CURLOPT_REFERER,true);
    curl_setopt($curl, CURLOPT_INFILE,$fp);
    curl_setopt($curl, CURLOPT_INFILESIZE,filesize($filename));
    $result = curl_exec($curl);
    unlink($filename);
    fclose($fp);
    curl_close($curl);
  3. Remote Server received the file using the below code and Display the data.
    $putdata=file_get_contents(‘php://input’); // retrieve the data in Remote server
    $filename =”b_”.time();
    $fp = fopen($filename,”w”);
    fwrite($fp,$putdata);
    fclose($fp);
    $file_details =exec(“file $filename”); // using linux command retrieve file information.
    print “**********************At Server Side********************”;
    print “File Details:“.$file_details.”";
    print ‘Contents are :‘;
    echo $putdata;
  4. finish
 

Mysql Questions October 13, 2008

Filed under: Mysql — myworldkvs @ 4:12 pm
Tags: , , ,

Mysql:

1. What is difference between Order By and Group By?

  • Order by – Sorts the data by ascending or decending.  Ex: select username from users order by email
  • Group by – Grouping the records based on field. Ex: Suppose, you are asked to give the total of visits by each user. then the query would be  like this. select count(visit), username from users group by username.

2. How many types of storage engines?

  • Total of 13 engines are available in Mysql.

3. what is default engine in mysql?

- MyISAM

4. What is difference between MyISAM and InnoDB?

- MyISAM : Its autocommit. once you added/updated/deleted the record, you cant rollback.

- InnoDB: Manual commit. Rollback possible. Takes lot of memory until commit. Slower than MyISAM.

5. What is difference b/w primary key and Unique?

6. Primary Key and foreign Key?

7. How do you store binary data in mysql?

8. Data will be stored in which format of file in MyISAM and InnoDB?

9. How many primary keys are allowed in a table?

10. How many unique keys are allowed in a table?

11. How to increase the speed of query execution?

12. What is Stored procedure and why we use this?

13. Difference between truncate and delete command?

14. Why do need to use InnoDB?

15. How do you import or take a backup of database?

16. I want to change the field data type from int to varchar how to do?

17. How do you start/stop/restart mysql server?

18. have you used Phpmyadmin?

19. How to set privileges to the user?

20. What is Having clause and when it to be used?

21. How to you change the date format?

22. Bulk insert data is possible? if yes, then how?

23. How to make a copy of one table to another?

 

PHP Questions October 6, 2008

Filed under: PHP — myworldkvs @ 12:20 pm
Tags: , , ,

1. What is difference b/w PHP 4 and PHP 5?

2. Suppress Errors?

3. Difference b/w split and Explode.

4. How to set and unset the cookie and session.

5. Difference b/w unset and unlink?

6. Types to connect Mysql?

7. File Upload.?

8. Difference b/w Include and Include_once?

9. Difference b/w Require and require_once?

10. Static variable and static method?

11. private static method?

12. Inheritance concepts..?

13. Is php supports multiple inheritance..?

14. Error handling describe?

15. How to increase the performance of PHP application?

16. What is register_globals and why its off by default?

17. Magic quotes..how its differ from addslashes method?

18. Which method can be used to change the configuration file at run time?

19. Describe Constructor?

20. what is __ (two underscore) represented in PHP?

21. How to get the size of the image?

22. About mail() function?

23. Difference between mysql_fetch_array and mysql_fetch_object?

more Q & A checkout this link: http://www.scribd.com/doc/3904877/PHP-interview-questions-by-ajay1kumar1

My friend is shared the above link.

 

Ajax September 9, 2008

Filed under: Ajax — myworldkvs @ 1:07 pm
Tags: , , ,

Ajax ( Asychronous javascript and Xml)  nowadays used in Web development.

Synchronous:

In ajax, all the request are sending in the form of request. If the request mode is in Synchronous, then the program can continue ONLY after the response got it. Else it wait for some span of time and continue the program after the time elapsed.

Asynchronous :

This type of request, the program will continue the execution and will not wait for the response. The readystate which tells whether response arrived or not.

Where we differentiate the Sync or Async request in a code:

  1. xmlHttp = new XmlHttpRequest();

    xmlHttp.open(“GET”,”test.php”,true); // Asynchronous

    xmlHttp.open(“GET”,”test.php”,false);  // Synchronous

if true means Asynchronous Mode. false means Synchronous mode.

Drawback of Ajax:

* Does not supported cross domain access.

Note : since Firefox 3.0.10, Support for Cross-Site XmlHttpRequest has been removed until the specification becomes more stable and the security model is improved.

I tried to fetch the data from other server. but its failed.
If you want to access the cross domain thru Ajax, use JSON instead.  JSON will support to fetch the data thru javascript.

 

Passing form values in an array format July 24, 2008

Filed under: Form — myworldkvs @ 6:11 am
Tags: , ,

Here is the code that you shall pass the form values in an array format. The name with [] that identify is an array. At the php side, just mention $_POST['dorm'] to receive the parameter values posted from Form.

  1. Html Code:

    <form name=”myform” method=”post” onsubmit=”check()”>
    <input type=”text” name=”dorm[]“>
    <input type=”text” name=”dorm[]“>
    <input type=”text” name=”dorm[]“>
    <input type=”text” name=”dorm[]“>
    <input type=”text” name=”dorm[]“>
    <input type=”text” name=”dorm[]“>
    <input type=”submit” name=”submit” value=”S”>
    </form>

  2. Javascript Validation:
    function check_All()
    {
    var form = document.myform.elements;
    for(var i=0;i<form.length;i++)
    {
    //  alert(form[i].name);
    }
    }
    function check_particular()
    {
    var txtbox = document.myform.elements['dorm[]‘]; // Returns the node list; node list stored as an array;
    // Find an length
    var len = txtbox.length
    // Retrive the value
    if (txtbox[0].value==”")
    alert(” Mandatory to fill up the first field”);

    }

  3. //Receiving the passing values at PHP side
    <?
    $values = $_POST['dorm'];
    print_r($values);
    ?>
 

 
Follow

Get every new post delivered to your Inbox.