Friday, January 20, 2012

SOPA sacked!

The sponsor of the SOPA bill, Lamar Smith, pulled the bill from consideration in the House. Its a win situation against the government intentions of taking our freedom. Congratulation to all the internet users, freedom is still yours.
Remember PIPA is still in the house. We respect the Intellectual Property right of the owner, but laws should not interfere in our freedom.

Thursday, January 19, 2012

Against SOPA and PIPA

Thank you for your support against SOPA and PIPA.

Internet is the place in the world where we are actually have freedom and are democratic. Please be there always to keep it that way. The day this freedom is gone, we will never say words like freedom and democracy again.

Share the story.

I will be posting a blog against the action being taken by Delhi High Court, India against 21 companies including Google, Facebook and Yahoo. Please support the cause.

Sunday, January 8, 2012

Tag hinting or label hinting javascript library

Tag hinting or label hinting is a very useful thing for forums and blogs, where it is used to tag post.
 
tag-hinting.js is a Javascript library for embedding tah hinting to a webpage, it is very useful on blogs and forums where you tag post. I have created it in such a way that it is easy to use and understand. All you have to do is include the tag-hinting.js file in your webpage and write the following lines:
arr = ['your','tag','values'];
and a div to show the hints.

The function which is to be called is:
hint(this, event)
Note:
Other style values can be added to above div.
id of the div has to be hintwords.
arr has to be declared and should be after file inclusion.
hint take only the specified arguments.
hint can work on keypress, keyup and keydown events.

There is a example file on this in repository on git. Pretty soon i'll be sharing a library which interacts with database and can be helpful in searches.

Friday, January 6, 2012

Javascript Library for dynamic element creation

d-element.js is a javascript library I have created. With the help of it you can easily create dynamic elements, in just one line. Try it!

Required: d-element.js

Using:

$('div').addelement('p',{'background-color':'blue'},'hi');


Explanation:
     This has identical syntax as of jQuery. 'div' here is selector which selects all the div tags.
     addelement method takes three arguments of which first is required and null can be given in other two.

Note:
    Only element(ex: div), id(ex: .id), class(ex: #class) can be used as selector for now, element under which element has to be created.
    First argument of addelement is required which is the element to be created.
    Second argument if given should be associative array, it is for the attributes of the element to be created.
    Third argument is data, if any string to be inserted. It can be a string having other html elements.
    Check console for error logs.

Wednesday, January 4, 2012

jQuery plugin - cycle: Slideshow of your own in a sec

The jQuery Cycle Plugin is a slideshow plugin that supports many different types of transition effects. It supports pause-on-hover, auto-stop, auto-fit, before/after callbacks, click triggers and much more.


Requires: Javascript, jquery


Using:
 


Explanation:
          Line 12: it means check if document is ready to apply javascript over it.
          Line 13: $('#classObject') selects the object having class name classObject. # is called selector. We apply a method cycle over this class.
          Line 14: fx(function/effect) is required parameter which can be defined in many ways here it is shuffle.
          Line 15: shuffle is optional, if its not defined there is default value top:15px and left: width of container. Here both are defined in line 16 and 17.
         Line 19: easing can only be used with easing plugin of jquery.
         Line 20: delay is also required parameter, which takes time for effect for single transition in milliseconds.

Note:
         Take care of the brackets people usually get it wrong. 
         "id" can also be used instead of class (instead of #(hash) .(dot) is used as selector). 
         jquery.js is required.
         jquery easing plugin will make it great.
         Give 3-4 div same class name, by this way there will equal number of div having slideshow of there own. Like if you need multiple slides at a time slideshow.
         There are many other cool fx. You can also create custom.
         There are also some other parameter apart from fx, delay etc. Take a look into the coding of jquery.cycle for other parameters.


There some great demos on the site of jQuery cycle. You can also find easing plugin on this site.

Tuesday, January 3, 2012

MySQL: Alternate to INNER JOIN

I came across a good way to write queries in mysql. Instead of using INNER JOIN there is a easy way to do it, sort of renaming the tables while writing query. Below is the example:

Requires: MySQL

Using:
table1(
   id int,
   name varchar(30)
   age int)
table2(
   id int,
   address varchar(300))

SELECT a.name, a.age, b.address FROM table1 a, table2 b WHERE a.id = b.id;


Explanation:
Look at the query renaming of table is done before retrieving the information we want. WHERE clause is very important in the query because there should be something which is common in both the tables in order to fetch the data.

Note: You can also write queries instead of table name in FROM clause i.e., sub-queries.
          If you are not getting results as you expect, there is something wrong with the way query has been written. Try writing it some other way. And this will happen a lot with complex queries. :P

So, this method will make your queries really powerful and easy. Time to replace INNER JOIN.