Monday, July 22, 2013

Get Country Name From Ip


1) Right Click on Project Solution 
 





 
 
 
2) copy past this link in Address bar
http://ip.fecundtechno.com/GetCountryCode.svc?wsdl 
 
 














sad




 
 
Give Namspace name you want and Click OK 
 
now add Add namespace in c# file  
like using ServiceReference2

now

call service

GetCountryCodeClient client = new GetCountryCodeClient();
 
client.GetCountryName("<here give ip address>"); 
 
 
 

Monday, July 15, 2013

Responsive Web Design for all Devices

HTML5 and CSS 3.0 are come up with resolution of this problem, where we can create one common web site and that will be loaded in different browser (Devices) with different format.
Below are the screens which we have opened in different devices with different format
  • Screen for general  desktop





Large screen 


 Screen for tablets





Tablates Screen 

Mobile Screen



Mobile Web site screen 


We have created same web site which is loading with different style based on selected device’s screen.
To achieve this solution I have used media query listeners of CSS 3.0.
Actually there is one Viewport metadata tag controls the logical dimensions and scaling of the mobile browser’s (chrome-less) window. Setting the width equal to the device-width works around the problem:
1
<meta name="viewport" content="width=device-width, initial-scale=1.0">
And also in CSS style we have added media object with all screen resolution with font and width allocation based on specified screens.

Below are the styles for this example.














@media screen and (max-width: 478px) &nbsp;&nbsp;&nbsp; {
h1 { font-size: 30px; padding: 1px; }
h2 { font-size: 1xpx; padding: 1px; }
body { font-size: 13px; }
}
 
@media screen and (max-width: 740px) &nbsp;&nbsp;&nbsp;
{
.left-col { width: 100%; }
.sidebar { width: 100%; }
}
 
@media screen and (max-width: 480px) {
}
In above code set different font size and padding based for screen 480px width and more than 740px as well as set sidebar width based on screen.
Other option about responsive design is define two separate css and load css based on screen size selection.



<link rel="stylesheet" type="text/css" media="screen and (max-device-width: 480px)" href=" media-queries_480.css" />


 

Tuesday, July 9, 2013

Create Shared Folder on google Drive with java script

<html>
<head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">

    <script type="text/javascript">
var CLIENT_ID = '<set client id here>';
var SCOPES = 'https://www.googleapis.com/auth/drive';

function appendResults(url) {
var results = document.getElementById('results');
var a = document.createElement('a');
a.href = url;
results.appendChild(a);
a.appendChild(document.createTextNode(url));
}

function createPublicFolder(folderName) {

var body = {
'title': folderName,
'mimeType': "application/vnd.google-apps.folder"
};

var request = gapi.client.drive.files.insert({
'resource': body
});

request.execute(function(resp) {
appendResults('http://googledrive.com/host/'+resp.id);
var permissionBody = {
'value': '',
'type': 'anyone',
'role': 'reader'
};
var permissionRequest = gapi.client.drive.permissions.insert({
'fileId': resp.id,
'resource': permissionBody
});
permissionRequest.execute(function(resp) { });
});
}

/**
* Called when the client library is loaded to start the auth flow.
*/
function handleClientLoad() {
window.setTimeout(checkAuth, 1);
}

/**
* Check if the current user has authorized the application.
*/
function checkAuth() {
gapi.auth.authorize({
'client_id': CLIENT_ID,
'scope': SCOPES,
'immediate': true}, handleAuthResult);
}

/**
* Called when authorization server replies.
*
* @param {Object} authResult Authorization result.
*/
function handleAuthResult(authResult) {
var authButton = document.getElementById('authorizeButton');
var filePicker = document.getElementById('publish');
authButton.style.display = 'none';
filePicker.style.display = 'none';
if (authResult && !authResult.error) {
// Access token has been successfully retrieved, requests can be sent to the API.
filePicker.style.display = 'block';
filePicker.onclick = uploadFile;
} else {
// No access token could be retrieved, show the button to start the authorization flow.
authButton.style.display = 'block';
authButton.onclick = function() {
gapi.auth.authorize({
'client_id': CLIENT_ID,
'scope': SCOPES,
'immediate': false}, handleAuthResult);
};
}
}

/**
* Start the file upload.
*
* @param {Object} evt Arguments from the file selector.
*/
function uploadFile(evt) {
gapi.client.load('drive', 'v2', function() {
var d = new Date();
var t = (d.getTime() - d.getMilliseconds())/1000;
var fname = document.getElementById('foldername');
createPublicFolder(fname.value);
});
}

    </script>

    <script type="text/javascript" src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>

</head>
<body>
    <!--Add a file picker for the user to start the upload process -->
    <input type="button" id="publish" style="display: none" value="Publish" />
    <input type="button" id="authorizeButton" style="display: none" value="Authorize" />
    <input type="text" id="foldername" placehoder="Give folder name" />
    <div id="results">
    </div>
</body>
</html>

Upload file on Google Drive and get Listing From Google Drive with java script


<html>
<head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <style>
        li
        {
            background-color: white;
            box-shadow: 1px 1px 4px;
            margin-bottom: 10px;
            padding: 2px;
        }
    </style>

    <script type="text/javascript">
      var CLIENT_ID = '<Set your Client Here>';
      var SCOPES = [
          'https://www.googleapis.com/auth/drive.file',
          'https://www.googleapis.com/auth/userinfo.email',
          'https://www.googleapis.com/auth/userinfo.profile',
          // Add other scopes needed by your application.
        ];

//      'https://www.googleapis.com/auth/drive';

      /**
       * Called when the client library is loaded to start the auth flow.
       */
      function handleClientLoad() {
        window.setTimeout(checkAuth, 1);
      }

      /**
       * Check if the current user has authorized the application.
       */
//      function checkAuth() {
//        gapi.auth.authorize(
//            {'client_id': CLIENT_ID, 'scope': SCOPES, 'immediate': true},
//            handleAuthResult);
//      }
    function checkAuth() {
        gapi.auth.authorize(
            {'client_id': CLIENT_ID, 'scope': SCOPES.join(' '), 'immediate': true},
            handleAuthResult);
            makeApiCall();
      }


      /**
       * Called when authorization server replies.
       *
       * @param {Object} authResult Authorization result.
       */
      function handleAuthResult(authResult) {
        var authButton = document.getElementById('authorizeButton');
        var filePicker = document.getElementById('filePicker');
        authButton.style.display = 'none';
        filePicker.style.display = 'none';
        if (authResult && !authResult.error) {
          // Access token has been successfully retrieved, requests can be sent to the API.
          filePicker.style.display = 'block';
          filePicker.onchange = uploadFile;
        } else {
          // No access token could be retrieved, show the button to start the authorization flow.
          authButton.style.display = 'block';
          authButton.onclick = function() {
              gapi.auth.authorize(
                  {'client_id': CLIENT_ID, 'scope': SCOPES, 'immediate': false},
                  handleAuthResult);
          };
        }
      }

      /**
       * Start the file upload.
       *
       * @param {Object} evt Arguments from the file selector.
       */
      function uploadFile(evt) {
        gapi.client.load('drive', 'v2', function() {
          var file = evt.target.files[0];
          insertFile(file);
        });
      }

      /**
       * Insert new file.
       *
       * @param {File} fileData File object to read data from.
       * @param {Function} callback Function to call when the request is complete.
       */
      function insertFile(fileData, callback)
      {
     
        const boundary = '-------314159265358979323846';
        const delimiter = "\r\n--" + boundary + "\r\n";
        const close_delim = "\r\n--" + boundary + "--";

        var reader = new FileReader();
        reader.readAsBinaryString(fileData);
        reader.onload = function(e)
        {
          var contentType = fileData.type || 'application/octet-stream';
          var metadata = {
            'title': fileData.name,
            'mimeType': contentType
        };

          var base64Data = btoa(reader.result);
          var multipartRequestBody =
              delimiter +
              'Content-Type: application/json\r\n\r\n' +
              JSON.stringify(metadata) +
              delimiter +
              'Content-Type: ' + contentType + '\r\n' +
              'Content-Transfer-Encoding: base64\r\n' +
              '\r\n' +
              base64Data +
              close_delim;

          var request = gapi.client.request({
              'path': '/upload/drive/v2/files',
              'method': 'POST',
              'params': {'uploadType': 'multipart'},
              'headers': {
                'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'
              },
              'body': multipartRequestBody});
          if (!callback) {
            callback = function(file) {
              console.log(file)
            };
          }
          request.execute(callback);
          makeApiCall();
        }
      }
     
       function makeApiCall() { 
      
            gapi.client.load('drive', 'v2', makeRequest);  
        }

        function makeRequest() {
            var request = gapi.client.drive.files.list({'maxResults': 100 });
            request.execute(function(resp) {         
                for (i=0; i<resp.items.length; i++) {
                    var titulo = resp.items[i].title;
                    var fechaUpd = resp.items[i].modifiedDate;
                    var userUpd = resp.items[i].lastModifyingUserName;
                    var userEmbed = resp.items[i].embedLink;
                    var userAltLink = resp.items[i].alternateLink;

                    var fileInfo = document.createElement('li');
                    fileInfo.appendChild(document.createTextNode('Title: ' + titulo +
                        ' - LAST MODIF: ' + fechaUpd + ' - By: ' + userUpd ));               
                    document.getElementById('content').appendChild(fileInfo);
                }
            });   
        }

        $(document).ready(function() {
        makeApiCall();
          $('#authorize-button').on('click', handleAuthClick);
          $.getScript('//apis.google.com/js/api.js', function() {
            gapi.load('auth:client', handleClientLoad);
          });
        });
    </script>

    <script type="text/javascript" src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>

</head>
<body>
    <!--Add a file picker for the user to start the upload process -->
    <input type="file" id="filePicker" style="display: none" />
    <input type="button" id="authorizeButton" style="display: none" value="Authorize" />
    <br />
    <div id="content">
        Files:</div>
</body>
</html>

Change Google Drive Default Folder Location in Windows

Google Drive for Windows is a client program that will let you sync online and local files. It also gives you the opportunity to transfer and share files to other users without going through the online login. When Google Drive for Windows is installed on the computer, selected files will be accessible from anywhere.

1. Disconnect Google Drive Account

Go to system tray and click on the Google Drive icon. Choose Preferences. It will open a window, click on  Disconnect Account. This will break your current connection so be sure that there is no existing file transfer before you execute this step.

Change Google Drive Default Folder Location in Windows

2. Delete the existing Google Drive folder

Please delete the existing Google Drive folder as well as shortcut under the Favorites. You can execute this through Windows Explorer. No worries trust me.

3. Sign in again

Back again at the system tray, please click on Sign in. Enter your user name and password.

4. We do here

On the next screen, click on Advance Setup. Then, click on Change button and navigate to the new location of Google Drive folder. You can create a new folder by clicking on a Make New Folder button if you want the drive to be inside a folder. Choose a drive letter if you prefer Google Drive folder to be on the root.

Google Drive Default Folder
Move Existing Google Drive Folder

5. Remember

Be sure that the folder you are choosing is empty, otherwise it will display the message “The Google Drive folder you selected is not empty. Please select an empty folder”, you have no other choice but to delete all contents of the target folder.

6. Done

Click Start Sync. That will set your new location as default Google Drive folder. You can now delete the old folder.


*******ENJOY ************

Monday, July 8, 2013

Using Google Drive As A Web Host

  1. Go to Google Drive Of course, you gotta have a Google account to begin in the first place and then just type in drive.google.com
  2. Create a public folder This is important. If you want to use Google Drive as a web host, you need to keep your files in a public directory. Create a new folder and then simply choose the 'share' button and give it public access. Lets assume my folder is called 'ryan'
  3. Dumping your static files Lets say that your site has a lot of html pages, css stylesheets, jQuery, javascript, images - the usual stuff. Just add all your files in the same directory structure in which they are present in your local system to the public folder that you just created. So, all my files are dumped into the public folder called 'ryan' in my google drive.
  4. Naming convention Ensure that at least one file in the public folder is named as index.html. This will act as the landing page for your site.
  5. What to publish Now comes an important step. In order to share your site, you need to share a link to the public folder. Initially I thought that you would need to share the link to the index.html but that did not work as expected. So what you need to do is,  note the google drive file-id of your public folder. To do that, just open your public folder in google drive. By default it lists all the files in that folder. In the url at the top, you will see that it contains a long string of garbled aphanumeric characters after the last slash. That is your folder id. Copy it.
  6. Creating a url to publish Now all you need is a url that points to your folder. To create your url, simply append the file id to the following string - http://googledrive.com/host/ For eg. The raw link to my profile on google drive is http://gdriv.es/chetan

And that pretty much does it. Clicking on the above URL serves the index.html page of your public folder.  Other Tips 
  1. If you want to use a neat little name instead of the long string of garbled alphanumeric characters that appear at the end of the url, go to Gdriv.es and convert your folder id custom name. That's what I did for my profile, and now it looks like this - http://gdriv.es/chetan. Much more neat i'd say.
  2. Sometimes its just easier to download Google Drive for the desktop, edit your files right in your local machine and then watch them automatically get uploaded.
  3. When multiple pages are interlinked, I have observed that the url in the address bar remains the same. So, I guess bookmarking will be an issue in this case.

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...