rss
twitter
  •  

Feature Detection versus Browser Detection

| Posted in Programming |

0

WHAT IS FEATURE DETECTION ?

Feature Detection is Future Detection whether the new feature is available  in the device / browser they are using.A new feature is like the Canvas Element Detection.

WHAT IS BROWSER DETECTION ?

Browser Detection unlike Feature detection is detection of browser version so that developers can keep some additional padding mechanism so that the nuisance creating have been handled with extra functionality or eliminate those browsers which are typically old like IE 6 which would cause their functionality to work improper.

Feature Detection versus Browser Detection

The Browser war is very fierce these days and all of them want to implement the cutting edge technology in this run all developers want to support the newest of the new technology and also support the legacy ones.

Install Linux on Pendrive

| Posted in Uncategorized |

1

Everyone at some point or other has had nightmare of crashing the entire system while installing Linux.Some of us would have lot bad experiences too ! But using Linux in todays date is like buying an ice-cream.So you gotto experience different flavors of ice-cream and enjoy it thoroughly.And the Open Source community makes it one step closer, Yes ! you install your favorite Linux distro on a small Pen drive Ubuntu fedora and many more. Carry it to play games, practice UNIX, securely do a transaction,mail on the go if your system is crashed its all there on the pen drive.

Installing on Windows

Install SLAX to a Pen Drive from Windows

How to Create a SLAX Pen Drive from Windows: In the following tutorial we show you how easy it is to install SLAX Linux to a USB Pen Drive from within Windows.SLAX is a tiny 200MB Linux distribution. It is essentially a stripped down version of Slackware Linux. SLAX is offered in a compressed tar format for extraction to a USB stick, SLAX Linux does feature the ability add or remove modules on the fly and save your changes persistently for use on subsequent boots.Using SLAX is much simpler than using Ubuntu Linux or its KDE version Kubuntu.
Portable SLAX Desktop Screenshot

Distribution Home Page: slax.org

USB SLAX Pen Drive creation tutorial:

  1. Download the SLAX 6.1.2 ISO
  2. Download and run Universal USB Installer, select SLAX 6.1.2, and follow the onscreen instructions
  3. Once the script has finished, reboot your computer, set your BIOS or Boot Menu to boot from the USB device and save your settings. On next boot, you should have a successful launch of your Portable SLAX

WordPress Blog in Indian Languages : type in hindi / marathi

| Posted in CMS | Content Management Systems, PHP, Programming, Wordpress |

1

Simplistic Appoach is to write text in http://www.google.com/transliterate/ copy and paste it to your blog.

 

If you want some more freedom and type in the same editor use a plugin.
Go to Plugins -> Add New, Install INDIC IME plugin.

This will enable you to type in 12 Different Indian Languages Including Hindi , Marathi (Devnagari),Gujarathi , Bengali, Gurmukhi,Kannada, Malayalam,Oriya , Telgu, Tamil etc.

Now Important Step :
A major problem will occur when you try to save the post, It would just show you question marks. For that to function properly you should comment these two lines in wp-config.php located in directory of wordpress installation.

define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

to

//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', '');

Google adds New Speed Metric

| Posted in Programming |

0

Its good be the fastest but is google forgetting about their grannys stories such as

Slow and Steady Wins The RACE

Google has added the speed metric into their search rankings see this http://googlecode.blogspot.com/2011/12/speed-metrics-in-google-analytics.html. Now if I construct the meta tags title, backlinks and URL as the best suited for Search Engines I mean google offcourse and leave the content to coming soon then I get a position 1 without any appropriate content.

On the other hand if to ignore the critics then we have a whole lot of things to achieve today’s world have many blotting down website where the browser loading wheels gets heck’s u.Google has its own page loading at the speed of knotts so we devs get an Example from the master. :)

Remove Vertical and Horizontal Scrollbar from Syntax Highlighter

| Posted in Programming |

2

Many times we get a default unnecessary scollbar when we use Alexgorbatchev’s SyntaxHighlighter.This is a notified issue in wordpress Syntax Highlighter plugin.To remove it just change the style of this class which has the overflow property which is defined in shCore.css.

<style type="text/css">
.syntaxhighlighter { overflow : hidden !important; }
</style>

CheckBox get selected / checked as true or false in Javascript and JQuery

| Posted in Javascript-jQuery, Programming |

0

Checkbox has an attribute checked which can have two values "checked" or "unchecked" we have to just check it with "checked" value to checked attribute of checkbox.

$('#mycheckbox').is(':checked') ? true : false;

In plain javascript we can do it simply by

var checkbox = document.getElementById("mycheckbox").checked;

				

Java Database Derby : JDBC to Derby connectivity

| Posted in Database, Java, Netbeans, Programming |

0

Apache Derby is an open source relational database implemented entirely in Java and has some key advantages include:

  • Derby has a small footprint — about 2.6 megabytes for the base engine and embedded JDBC driver.
  • Derby is based on the Java, JDBC, and SQL standards.
  • Derby provides an embedded JDBC driver
  • Derby is easy to install, deploy, and use.
So without wasting time lets start

IN NETBEANS

Netbeans Derby Connect

Derby

  • Steps To Create Derby Database and Table
  1. First goto Windows => Services
  2. Navigate to the Databases section and click Java DB
  3. Right click and say Start Server
  4. Now create a database by again right clicking on Java DB ‘create database’
  5. Enter your database name , user-name and your password
  6. now you would see an active connection in the Databases column such as jdbc:derby://localhost:1527/meraDB [swapnil on SWAPNIL]
  7. Right click connect
  8. create a table by Right clicking on database connection you have established by clicking Execute Command
CREATE TABLE USERS (
FIRST_NAME VARCHAR(30) NOT NULL,
LAST_NAME VARCHAR(30) NOT NULL,
EMP_NO INTEGER NOT NULL CONSTRAINT EMP_NO_PK PRIMARY KEY
);
CREATE TABLE PC (
TYPE VARCHAR(10) NOT NULL,
SERIAL VARCHAR(50),
OS VARCHAR(20),
EMP_NO INTEGER,
CODE_NO INTEGER NOT NULL CONSTRAINT CODE_NO_PK PRIMARY KEY
);

Insert some values like this

INSERT INTO USERS VALUES('Bill','Gates',1);
INSERT INTO USERS VALUES('Joe','Bloggs',2);
INSERT INTO USERS VALUES('Peter','Kropotkin',3);
INSERT INTO PC VALUES('Desktop','01010','Linux',1,1);
INSERT INTO PC VALUES('Laptop','101010','BSD',2,2);
INSERT INTO PC VALUES('Desktop','101010','XP',3,12);

Now you are ready to jdbc ! Include the derbyclient.jar in your library / classpath by right clicking library in project and Add jar

Derby Library Derby Client jar inclusion in netbeans

Derby Library import in Netbeans

package nik;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSetMetaData;

public class Derby {
    private static String dbName = "meraDB";
    private static String dbUser = "swapnil";
    private static String dbPass = "redhat";

 private static String dbURL = "jdbc:derby://localhost:1527/"+dbName+";create=true;user="+dbUser+";password="+dbPass;
    private static String tableName = "USERS";
    // jdbc Connection
    private static Connection conn = null;
    private static Statement stmt = null;

    public static void main(String[] args)
    {
        createConnection();
        selectInput();
        //insertUser("LaVals", "Berkeley",9);
        selectUsers();
        shutdown();
    }

    private static void createConnection()
    {
        try
        {
            Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
            //Get a connection
            conn = DriverManager.getConnection(dbURL);
        }
        catch (Exception except)
        {
            except.printStackTrace();
        }
    }

    private static void insertUser( String firstName, String lastName,int emp_no)
    {
        try
        {
            stmt = conn.createStatement();
            stmt.execute("insert into " + tableName + " values ('" + firstName + "','" + lastName + "'," + emp_no +")");
            stmt.close();
        }
        catch(java.sql.SQLIntegrityConstraintViolationException insExp){
            insertUser(firstName,lastName,++emp_no);
        }
        catch (SQLException sqlExcept)
        {
            sqlExcept.printStackTrace();
        }
    }

    private static void selectUsers()
    {
        try
        {
            stmt = conn.createStatement();
            ResultSet results = stmt.executeQuery("select * from " + tableName);
            ResultSetMetaData rsmd = results.getMetaData();
            int numberCols = rsmd.getColumnCount();
            for (int i=1; i<=numberCols; i++)
            {

                //print Column Names
                System.out.print(rsmd.getColumnLabel(i)+"\t\t");
            }

            System.out.println("\n-------------------------------------------------");

            while(results.next())
            {
                int id = results.getInt(3);
                String restName = results.getString(1);
                String cityName = results.getString(2);
                System.out.println(id + "\t\t" + restName + "\t\t" + cityName);
            }
            results.close();
            stmt.close();
        }
        catch (SQLException sqlExcept)
        {
            sqlExcept.printStackTrace();
        }
    }

    private static void shutdown()
    {
        try
        {
            if (stmt != null)
            {
                stmt.close();
            }
            if (conn != null)
            {
                DriverManager.getConnection(dbURL + ";shutdown=true");
                conn.close();
            }
        }
        catch (SQLException sqlExcept)
        {
             sqlExcept.printStackTrace();
        }

    }

    private static void selectInput() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            do{
                System.out.println("Insert Employee First Name");
                String fname = br.readLine();
                System.out.println("Insert Employee Last Name");
                String lname = br.readLine();
                System.out.println("Insert Employee Private Code");
                int emp_code = Integer.parseInt(br.readLine());
                insertUser(fname, lname, emp_code);
                System.out.println("Thankyou for Inserting please press any key to continue and small 'q' to exit");
                char str =(char) br.read();
                System.out.println(str);
                if(str == 'q')break;
                System.out.println("Press Enter to continue");
                br.readLine();
              }while(true);
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}

Browser Detection Code in Javascript

| Posted in Javascript-jQuery, Programming |

0

I strongly recommend using FEATURE DETECTION versus BROWSER DETECTION because of the simple reason that Browser Detection may not guarantee you if one feature is supported by its release of the browser then the other feature will also be supported.So you’ll have to settle for a higher version in the run which may reduce your target audience.Feature detection allow the web developer to focus on the general capabilities of a browser, rather than the specific details of each browser release. You can always see more here.


Explaination to use this Code :
When the Script runs a BrowserDetect.init() function; BrowserDetect Object is to be initialized.

Requirement : Get the Browser Category
Solution : The Browser Category like Firefox Chrome can be obtained from BrowserDetect.browser value

Requirement : Get the Browser Version
Solution : The Browser Version like 15.0 can be obtained from BrowserDetect.version value

Requirement : Get the Operating System
Solution : The Operating System like Windows iPad/iPhone can be obtained from BrowserDetect.OS value

FB.login() called before calling FB.init()

| Posted in Javascript-jQuery, Programming |

0

Solution for FB.login() called before calling FB.init() :

 

  • Check if your App ID is not blank  in FB.init()
  • Check whether all.js is not called twice because of repetition
  • If you have two or more social plugins from facebooks they would call their own code and load the all.js and inturn cause repition of all.js so the it is same as solution 2.
This error (FB.login() called before calling FB.init()) can be viewed in console of Web-Developer and Chrome Error Console.

ASP.NET Facebook login (ASP.NET Facebook Integration)

| Posted in Programming |

0

Firstly let me explain “what we want to do” ?
We want to use Facebook’s  “fb login” for users who are registered on facebook can authenticate to your website. For this we want some of their details such as Name, Email etc. Facebook will not give the details of the user unless the user allows you to access the  details. When the user approves his permission you get an access token which you can use to access his resources. The way facebook provides this information is through the open graph api , simply say you query it in ‘REST’ fashion through an URL and you get a JSON result eg. to view json in browser open

https://graph.facebook.com/[user-name]

eg:  https://graph.facebook.com/elections2012india  this gives you JSON information about the user

Now the access of the user is stored in an access token which is returned to you by Facebook and you can query other things such photoes , friends wall etc refer: http://developers.facebook.com/docs/reference/api using the access token.

To gain a valid access token you have to pass your app authorization request to the following url :

https://www.facebook.com/dialog/oauth?client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&scope=email,read_stream

this will return you the access code to the return url in this format :

http://YOUR_URL?code=A_CODE_GENERATED_BY_SERVER
use this code to retrieve the data :
WebClient client = new WebClient();
string JsonResult = client.DownloadString(string.Concat("https://graph.facebook.com/me?access_token=", code));
Newtonsoft.Json.Linq.JObject jsonUserInfo = JObject.Parse(JsonResult);
string name = jsonUserInfo.Value<string>("name");
string email = jsonUserInfo.Value<string>("email");

Note : You have to use a popular Json library Newtonsoft.Json you can download it using the Package Manager Console(in tools) :

PM>Install-Package Newtonsoft.Json

ASP.Net Does not necessarily need DOT-NET-OPEN-AUTH (dotNetOpenAuth2.0.dll) for you to connect / integrate / register your users with the facebook.Yes facebook does use Open Auth but you just dont need the pain anymore to understand the OAuth specification or any library.