Thursday, July 26, 2012

How to create a cool and usable CSS3 search box

Source: http://www.red-team-design.com/how-to-create-a-cool-and-usable-css3-search-box


In this new article, you’ll learn how create a cool and usable CSS3 search box using the HTML5placeholder attribute. For the browsers that don’t support this new HTML5 attribute, a fallback is created using Modernizr’s feature detection.

STRUCTURE

The form element is used as the wrapper, while the two inputs are used as search field and search button respectively.

The HTML code


You may notice the placeholder attribute, but just ignore it for now, as we will talk later about it.
The reason why there are so many id’s (instead of CSS3 advanced selectors asinput[type="text"] or input[type="submit"]) is because I wanted this to degrade gracefully for older browsers.

THE CSS

Form wrapper

#searchbox
{
 background: #eaf8fc;
 background-image: -moz-linear-gradient(#fff, #d4e8ec);
 background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #d4e8ec),color-stop(1, #fff));
 
 -moz-border-radius: 35px;
 border-radius: 35px;
 
 border-width: 1px;
 border-style: solid;
 border-color: #c4d9df #a4c3ca #83afb7;            
 width: 500px;
 height: 35px;
 padding: 10px;
 margin: 100px auto 50px;
 overflow: hidden; /* Clear floats */
}
Below you can see the current result:

Inputs

Quick tip:
When adding float: left to an element, there’s no need to add also display: block. The last one it’s implied.
#search, #submit
{
 float: left;
}

#search
{
 padding: 5px 9px;
 height: 23px;
 width: 380px;
 border: 1px solid #a4c3ca;
 font: normal 13px 'trebuchet MS', arial, helvetica;
 background: #f1f1f1;
 
 -moz-border-radius: 50px 3px 3px 50px;
  border-radius: 50px 3px 3px 50px;
  -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset, 0 1px 0 rgba(255, 255, 255, 1);
  -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset, 0 1px 0 rgba(255, 255, 255, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset, 0 1px 0 rgba(255, 255, 255, 1);            
}

/* ----------------------- */

#submit
{  
 background: #6cbb6b;
 background-image: -moz-linear-gradient(#95d788, #6cbb6b);
 background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #6cbb6b),color-stop(1, #95d788));
 
 -moz-border-radius: 3px 50px 50px 3px;
 border-radius: 3px 50px 50px 3px;
 
 border-width: 1px;
 border-style: solid;
 border-color: #7eba7c #578e57 #447d43;
 
  -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;     

 height: 35px;
 margin: 0 0 0 10px;
        padding: 0;
 width: 90px;
 cursor: pointer;
 font: bold 14px Arial, Helvetica;
 color: #23441e;
 
 text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

#submit:hover
{  
 background: #95d788;
 background-image: -moz-linear-gradient(#6cbb6b, #95d788);
 background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #95d788),color-stop(1, #6cbb6b));
} 

#submit:active
{  
 background: #95d788;
 outline: none;
   
  -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
  -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;  
}

#submit::-moz-focus-inner
{
       border: 0;  /* Small centering fix for Firefox */
}  

HTML5 PLACEHOLDER ATTRIBUTE

This new HTML5 attribute shows a text in a field as long as the field is empty and not focused, then hides the text. You surely have seen this technique before with JavaScript!
Browser support:
  • Firefox 3.7+
  • Safari 4.0+
  • Chrome 4.0+
  • Opera 11+
  • IE10+
Opera 11 supports it, but you cannot style it (yet). As for the others above, here’s how you can style it:
#search::-webkit-input-placeholder {
   color: #9c9c9c;
   font-style: italic;
}

#search:-moz-placeholder {
   color: #9c9c9c;
   font-style: italic;
}  

#search:-ms-placeholder {
   color: #9c9c9c;
   font-style: italic;
}   

Fallback support

For web browsers that are not supporting the this new HTML5 attribute, I made a fallback.
I used Modernizr to detect native support for the HTML5 placeholder attribute. Even if this could have been done by writing a short function, I love Modernizr as it also enables you to use more semantic elements from the HTML5 specs.
#search.placeholder {
   color: #9c9c9c !important;
   font-style: italic;
} 
$(document).ready(function() {           
 if (!Modernizr.input.placeholder)
 {  
  var placeholderText = $('#search').attr('placeholder');
  
  $('#search').attr('value',placeholderText);
  $('#search').addClass('placeholder');
  
  $('#search').focus(function() {    
   if( ($('#search').val() == placeholderText) )
   {
    $('#search').attr('value','');
    $('#search').removeClass('placeholder');
   }
  });
  
  $('#search').blur(function() {    
   if ( ($('#search').val() == placeholderText) || (($('#search').val() == '')) )                      
   { 
    $('#search').addClass('placeholder');       
    $('#search').attr('value',placeholderText);
   }
  });
 }                
});

CHROME’S INSET BOX-SHADOW BUG

There is a bug on Chrome when both border-radius and inset box-shadow are used. Anyway, there is good news about that. Paul Irish announced last month that Chrome’s inset box-shadow bug is fixed.

Later update

The demo was updated, thanks for pointing this out Atul.
So, if you’re using Chrome beta 10.0.648.119 or a greater version, this should work just perfect!

CONCLUSION

This example it’s mostly about progressive enhancement.
Regarding the CSS, as you will notice, this example will degrade gracefully for other old browsers. Now, regarding the HTML5 placeholder attribute, if native support is missing, then the Javascript code will do it for you.

Reverse search of Stock quotes

Hello All,

We've seen a lot of stock market applications which would try to put together a great amount of information relevant to us for which you will feed in a list of stocks you are interested in or you've invested in. As we all know, we don't know a lot of public companies in this world which are comparably making good profits than the stocks you already know. There may be a huge amount of hype given for certain quotes, but some may go unnoticed. There might be some stocks which are kind of underdogs but are earning a lot(at least comparatively). 

Say, you have an interest of investing about $500 with about $12 per share in some profitable company. So you have a question in front of you i.e. what are all stocks that have a current value around $12. This has invoked an idea of building a tool which will fetch you all stocks for a given range of your interest.

You provide us with your lower cap and upper cap for current ask value and we fetch you the relevant stocks ordered by their current value. You wanna check more details about a quote listed, it's just a click away - click on the stock name - you see the details in the box beside!

This is just the beginning and lot more usable functionality coming soon. Watch this space for more updates. Thank you all for trying this tool.

Friday, July 13, 2012

Sports n Pics - Timeline of Sports in pictures

The following article is about Sports n Pics: http://mycollect.in/snp



The morning after euro2012 final happened, I woke up and was curious to see how did people around the world reacted before, during and after the match. I am sure there will be mixed reactions, exciting moments, celebrations for some and sadness for some. I can get all these in the form of news articles or boston.bigpicture or something like that. 

But I wanted to see the real feelings of people, their preparation for the match, their arrangements and cool merchandise bought, funny hats, happiness in their faces, love towards their favorite team, heartfelt situations during the match followed by elated moments. Finally celebrations in winning team and  other team's feelings for their defeat. Every moment mentioned above is felt by all football fans, I wanted to see them in personal. 




Best way I found is Instagram! People post every activity as mentioned above, which is a huge resource for fulfilling my request. But there was no way I can see them as a sequence in a nice UI where I need not do many clicks or run through several pages. 

With this pain point, I decided to develop an application which would solve this purpose. You can select your favorite league and filter the teams, select a team to see a timeline of pictures being listed and will keep on coming as you scroll down - that's it - select a team with single click and watch a huge set of pictures from all around the world depicting different feelings and moments of every one's life for a given sports event or a team. 

Link for my application is http://mycollect.in/snp

Now this application hosts all teams of MLB, NFL, NHL, MLS, NBA. So this would be a treat for fans of baseball, football, hockey, soccer and basketball!

Show your love by sharing and liking it. 

This is still in beta and adding many more features to make a perfect applications for a sports fan.

Please let me know your feedback. 

Tuesday, April 12, 2011

Does Human knows everything about his capabilities?

Human Being - The most intelligent being on Earth so far.

Is that true???

Human brain and body is the most advanced and complex system, but there are some limitations!

For instance, we have got te "Eyes+Brain" system, much powerful than the state of the art cameras in terms of lens and focus - but, some things are missing!

  1. He doesn't have Zoom capability!
  2. He can always see the colors, but can't switch between gray scale and colors!
  3. and many more!!!

Why are they missing?

Are these features missing in human being or does he don't know the control for them?

Do we actually know what all things we are capable of doing?

Do we actually know all the controls for doing different complex things?

What's the human potential and how far we have explored it?

Thursday, January 6, 2011

Why RSS have to die?

Most of the people are saying that "RSS is died", but why should we consider it as dead, only fact is that world has moved forward and services of RSS feeds is now enough. That doesn't mean that RSS have to die! It can start serving in a different format or provide service compatible to existing trend. Many of major companies are blocking social networking sites just in order to restrict their employees from getting distracted during work.

integrate RSS with twitter/FB
set digest time/period by company or user(3hrs/6hrs)
receive feeds in the form of mail, so that you dont miss ur frnds feed.

This is just one of apps where RSS can reincarnate itself to keep up with existing trends. please suggest any more apps that could save RSS.

Friday, September 3, 2010

Learning MySQL and PHP

  • PHP and MySQL are two different languages that work hand in hand very well.
  • In order to get us started the right way we will need our database up and running and the web server to be able to run php code. XAMPP is an excellent tool to put your localhost "alive" in under 5 minutes.
  • We will need 3 informations in order to access and manipulate our databases: host ("localhost" usually), username and password (in XAMPP this comes by default with username "root" and no password.
  • At first, we stored our host name (localhost), username and password in variables to call and update them a little bit easier (I can use the variable '$host' in 1000 pages and update it by only modifying this step instead of modifying all those pages one by one, that's why we store the info in variables).
  • Next we define '$connect' with the actual connection code. This is very important because it's a little different from most of the examples out there.
  • Notice the '@' character right at the start of the 'mysql_connect' command. It's used to hide the errors that php produces if any of the variables contain informations that are not correct and the script can't connect to the host.
  • This is a very important step in writing secure code that will not leave empty doors.
  • The errors can output a lot of sensitive informations and we don't wanna put that kind of info in the wrong hands so we will hide the default errors and put our own messages to identify where the error is.
  • Let's take a live example for a better understanding: Instead of 'root' as the database username, I will put 'rosot' and delete the '@' that is supposed to hide my errors. Here's the ugly output: 'Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'rosot'@'localhost' (using password: YES) in D:\xampp\htdocs\test\index.php on line 9' It gives out my username, it's not a big thing since it's the wrong one but keep in mind that the same error will be shown if we enter a wrong password so it's not safe.
  • Let's put back the '@' character and run this code again. The output is somehow the same because I defined this way but you can change it to whatever you want since you're in full control. We managed to control the errors and display only what we need by using an if statement.
  • By default, the command 'mysql_query' executes a query the we define and store in a variable or inside the parenthesis (it's the same thing). This mysql command returns TRUE or FALSE (TRUE = I executed the query successfully, FALSE = no I didin't) and this boolean return will help us figure out if we should display an error message or success.
  • if ( ! @mysql_query ( "CREATE DATABASE `roscripts`" ) )
    Another character (!) is joining the game: if ( ! //code here ) means that if the code that follows the character is not true than the condition is true. In pure english it goes this way: "If I can't execute this query, I do this...". This condition is the same with the following but a little more elegant:
    if ( @mysql_query ( "CREATE DATABASE `roscripts`" ) == FALSE )
    So if the code can't execute the query command, it hides the default errors (thanks to '@') and displays the message that I want (in our case the code dies and displays the mysql error : 'die ( mysql_error() );').

Sample Application that takes a word and Enters into database.

  1. create a empty php file and name it as index.php
  2. lets have a text box to enter the word and 2 buttons, one for submit and other for reset.




  3. My Term Storage



    " method="post">


    First name






  4. In form action we are writing , because we are going to write the php functionality in the same page.
  5. Now we have to write a functionality in php which will insert the word entered in text box to a specified table in the mysql database.
  6. Specifying the database parameters
  7. $database="mystore";
    $conn = @mysql_connect( 'localhost', 'username', 'password' ) or die( mysql_errno().': '.mysql_error().NL );
    @mysql_select_db($database) or die( "Unable to select database");
  8. Now get the value of text box into a variable $name = $_POST['first'];
  9. Build a sql query :$sql = "INSERT INTO terms VALUES ('$name',NULL,NULL,NULL)";
  10. Run the query
  11. $result = mysql_query( $sql,$conn );
    mysql_free_result( $result );
  12. Thus, we have inserted the record successfully.
Display of data from mysql table onto a html page.
  1. Now i want the display of records in the same page as and when i insert.
  2. So, we need to write a code for displaying the data in mysql table onto html page.
  3. For getting the data, we need to fire a sql query "select * from terms".
  4. Build the query :$query="select * from terms";
  5. execute the query and store the result set in a variable.
  6. $rt=mysql_query($query);
  7. putting the data into a unordered list.
  8. echo "
      ";
      while($nt=mysql_fetch_array($rt)){
      echo "
    • $nt[term]
    • "; //nt will contain each row.
      }
      echo "
    ";


Friday, August 27, 2010

Information Extraction versus Information Retrieval

Information extraction (IE). Unlike information retrieval (IR), which concerns how to identify relevant documents from a document collection, IE produces structured data ready for post-processing, which is crucial to many applications of Web mining and searching tools.

Programs that perform the task of IE are referred to as extractors or wrappers. A wrapper was originally defined as a component in an information integration system which aims at providing a single uniform query interface to access multiple information sources. In an information integration system, a wrapper is generally a program that “wraps” an information source (e.g. a database server, or a Web server) such that the information integration system can access that information source without changing its core query answering mechanism.

Wrapper induction (WI) or information extraction (IE) systems are software tools that are designed to generate wrappers.


Source: Survey of Web Information Extraction Systems
Traditional IE aims at extracting data from totally unstructured free texts that are written in natural language. Web IE, in contrast, processes online documents that are semi-structured and usually generated automatically by a server-side application program. As a result, traditional IE usually takes advantage of NLP techniques such as lexicons and grammars, whereas Web IE usually applies machine learning and pattern mining techniques to exploit the syntactical patterns or layout structures of the template-based documents.

There are five main tasks defined for text IE, including named entity recognition, coreference resolution, template element construction, template relation construction and scenario template production.

RISE (Repository of Online Information Sources Used in Information Extraction Tasks).

Classification

Message Understanding Conferences (MUCs) have classified as MUC Approaches and Post MUC Approaches.

MUC Approaches:
  1. AutoSolg
  2. LIEP
  3. PALKA
  4. HASTEN
  5. CRYSTAL
Post MUC Approaches:
  1. WHISK
  2. RAPIER
  3. SRV
  4. WIEN
  5. SoftMealy
  6. STALKER
Hsu and Dung classified into 4 categories, hand-crafted wrappers using general programming languages, specially designed programming languages or tools, heuristic-based wrappers, and WI approaches.

Chang classified based on the degree of automation, They classified IE tools into four distinct categories, including systems that need programmers, systems that need annotation examples, annotation-free systems and semisupervised systems.

Mulsea classified IE tools into 3 classes:
IE Tools based on
  1. Syntactic/Semantic Constraints
  2. Delimiters
  3. Both 1 and 2.
Kushmerick classified many of the IE tools into two distinct categories finite-state and relational learning tools.

Laender proposed a taxonomy for data extraction tools based on the main technique used by each tool to generate a wrapper, which are
  1. Languages for Wrapper Development.
  2. HTML-Aware Tools.
  3. NLP-Based tools.
  4. Wrapper Induction tools.
  5. Modeling based tools.
  6. Ontology based tools.
Laender compared among the tools by using the following 7 features: degree of automation, support for complex objects, page contents, availability of a GUI, XML output, support for non-HTML sources, resilience, and adaptiveness.

Sarawagi classified HTML wrappers into 3 categories according to the kind of extraction tasks.
  1. Record level wrappers. - exploits regularities to discover record boundaries and then extract elements of a single list of homogeneous records from a page.
  2. Page level wrappers. - extracts elements of multiple kinds of records.
  3. Site level wrappers. - populate a database from pages of a Web site.