Author Archives: Yash - Page 5

Run PHP from HTML – .html as .php – Execute PHP in .html

How can I execute PHP code on my existing myfile.html page?:

When a web page is accessed, the server checks the extension to know how to handle the page. Generally speaking if it sees a .htm or .html file, it sends it right to the browser because it doesn’t have anything to process on the server. If it sees a .php extension (or .shtml, or .asp, etc), it knows that it needs to execute the appropriate code before passing it along to the browser.
Read more »


/*ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its
declaration and binary logging is enabled (you *might* want to use the less safe
log_bin_trust_function_creators variable)*/

Set this value using mysql console
(mysql> SET GLOBAL log_bin_trust_function_creators = 1;)

Jquery autocomplete with multiple data

     source: [{ label: 'My First Item', value: '/items/1' }, 
                  { label: 'My Second Item', value: '/items/2'}]
    ,focus: function (event, ui) {
                return false;
   ,select: function (event, ui) {
              window.location = ui.item.value;
              return false;

Read more »

Get row height and Column width of QListView

Row Height of QListView
sizeHintForRow (int row);

Column width of QListView
sizeHintForColumn (int column)

Set QIcon or say Icon in QListView

Create a new model class based on QSqlQueryModel and implement data() method like below:

    QVariant SqlQueryModel::data ( const QModelIndex & item, int role) const
    if (role == Qt::DecorationRole)
    case 0: // column 0 contains text data
    QPixmap image;
    // column 1 contains BLOB data
    return image.scaled(160, 160, Qt::KeepAspectRatio, 
   if (value.isValid() && role == Qt::DisplayRole) {
        if (item.column() == 0)
            return value.toString().prepend("#");
        else if (item.column() == 1)
            return value.toString().toUpper();
    if (role == Qt::TextColorRole && item.column() == 0)
        return qVariantFromValue(QColor(Qt::blue));   
    return QSqlQueryModel::data(item, role);

Then connect it to QListView like this:

    queryModel = new SqlQueryModel(this);
    queryModel->setQuery(query, sqlDatabase);
    QListView *pView = new QListView(ui.tab_2);

Different Mouse Events in Qt

bool MyQMainWindowEventFilter::eventFilter (QObject* o, QEvent* e)
        // play with all mouse events
       if ((e->type() == QEvent::MouseButtonPress) ||
           (e->type() == QEvent::MouseButtonRelease) ||
           (e->type() == QEvent::MouseButtonDblClick) ||
           (e->type() == QEvent::MouseMove))
           cout < < "mouse event" << endl;
           return false;
   return true;
//Mouse in and out events  
//Do this first
//now check
QWidget::leaveEvent(QLeaveEvent *)
QWidget::enterEvent(QLeaveEvent *)

Get objectname of event sender in Qt

What would be object name which sends event ?

Use QObject::sender() to get the sending object.

void myslot()
    QObject* pObject = sender();
    QString name = pObject-&gt;objectName();

A Crash-Course in CSS Media Queries

Method 1: Within your Stylesheet

@media screen and (min-width : 1200px) {
/* let's do somethin' */

Method 2: Import from within your Stylesheet

@import url( small.css ) screen and ( min-width: 1200px );

Note that you can also add addition rules, by applying a comma — much like you would when using multiple selectors.

Method 3: Link to a Stylesheet

<link rel="stylesheet" media="screen and (min-width: 1200px)" href="small.css" />

Method 4: Targeting the iPhone

<ink rel="stylesheet" media="only screen and (max-device-width: 480px)" href="mobile.css" />

An interesting note, after a bit of research around the web, is that, despite the fact that iPhone 4 sports a resolution of 640×960, it still we pick up mobile.css, referenced in the code above. How strange? If you have more information on this, please leave a comment for the rest of us!

Browsers that Support CSS Media Queries

Firefox 3.5+
Opera 9.5+
Safari 3+
Internet Explorer 9+

Please note that Internet Explorer 8 and below do not support CSS media queries. In those cases, you should use a JavaScript fallback.

Best design scripts, tools and websites collection

Compass is a stylesheet authoring framework that makes your stylesheets and markup easier to build and maintain. With compass, you write your stylesheets in Sass instead of CSS. Using the power of Sass Mixins and the Compass community, you can apply battle-tested styles from frameworks like Blueprint to your stylesheets instead of your markup.

Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.

The dynamic stylesheet language.
LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. LESS runs on both the client-side (IE 6+, Webkit, Firefox) and server-side, with Node.js.

Modernizr adds classes to the element which allow you to target specific browser functionality in your stylesheet. You don’t actually need to write any Javascript to use it.

CSS3 selectors for IE
selectivizr is a JavaScript utility that emulates CSS3 pseudo-classes and attribute selectors in Internet Explorer 6-8. Simply include the script in your pages and selectivizr will do the rest.

A Javascript CSS3 Selector and Matcher not using XPath
standard compliance to published specs
ensure result sets are “document ordered”
CSS3 support (including “of-type” pseudos)
correct resolution of case-sensitivity in attributes
singleton, no dependencies, few JS1.2 native functions
no XPath used just loops and one getElementsByTagName
not extending anything, not adding to objects or arrays
minified code 18Kbytes, only 6Kbytes if served compressed
multi-frame/multi-document aware, fully cross-browser compatible

Getting Offline Access with HTML5 Application Cache using Htaccess

Just when you thought you’d seen all the cool features of HTML5, I’m here to bring you yet another one. The internet is no longer about just websites; it’s about web applications. Often, our users are on portable or mobile devices, and they won’t always have access to a network. With HTML5’s Application Cache, you can provide them with all or some of the functionality they would have online, no matter where they go.

Step 1: Make the Cache Manifest

The trick here is using a cache manifest file. In its most basic form, it’s incredibly simple:

   # version 0.1

Step 2: Serve the Manifest Correctly

This file needs to be served with a content-type header of text/’s really simple to do this with a .htaccess file:

AddType text/cache-manifest manifest

This will serve all files with an extention of “manifest” with the appropriate content-type header.

Step 3: Hook the Manifest In

To use the cache manifest file, you simply add a property to the html element:

<!DOCTYPE html>
<html lang="en" manifest="site.manifest">
<meta charset='utf-8'>

Now, the next time a user visits your site / app, their browser will cache the required files. It’s that easy. If they browse to your URL when they’re offline, they’ll get the cached content.

Caveat: Refreshing the Cache

It’s important to note that even when the user is online, the browser will only go to the server to get new content in three cases:

The user clears their cache (obviously removing your content).
The manifest file changes.
The cache is updated via JavaScript

So, to force all your users to reload their cache, you can change something in the manifest file (not the files linked to, the actual content of the manifest file). Most of the time, you’ll probably just want to change a comment, and that will be enough.

If you want, build cache updating into your app via the JavaScript API; that’s beyond the scope of this quick tip, but if you want to learn more, check out this article at

Browser Support

Like a lot of other HTML5 features, the Application Cache is supported by all the modern browsers.

Chart from

And that’s HTML5′s Application Cache; it’s pretty cool, and I’m sure it will be used by developers, of almost any site, to provide a gracefully degrading experience that keeps their users happy wherever they are. Thanks for reading!

Page 5 of 9« First...34567...Last »