Skip to main content

Posts

Showing posts from June, 2014

How to find the Operating sysetm(OS) name using JavaScript?

<html>     <title>         How to find the Operating sysetm(OS) name using JavaScript?     </title>     <script>         function find_browser ()         {             var nAgt = window.navigator.userAgent ;             if (nAgt.indexOf('Mac') != -1) {                 alert(' Mac OS ');             }else if (nAgt.indexOf('Linux') != -1) {                 alert(' Linux ');             }else if (nAgt.indexOf('X11') != -1) {   ...

How to find the browser name using JavaScript?

<html>     <title>         How to find the browser name using JavaScript?     </title>     <script>         function find_ browser ()         {             var nAgt = navigator.userAgent;             if (nAgt.indexOf(' Chrome ') != -1) {                 alert('Chrome');             }else if (nAgt.indexOf(' Firefox ') != -1) {                 alert('Firefox');             }else if (nAgt.indexOf(' Opera ') != -1) {     ...

How to detect a mobile device using javascript (iphone/ipad/android/blackberry/webos/ipod/iemobile)?

<html>     <script>         function is_mobile () {             if( navigator.userAgent.toLowerCase ().search(' iphone ') > -1) {                 alert('iphone');             }else if(navigator.userAgent.toLowerCase().search(' android ') > -1){                 alert('android');             }else if(navigator.userAgent.toLowerCase().search(' ipad ') > -1){                 alert('ipad');             }else if(navigator.userAgent.toLowerCase().search(' blackberry ') > -1){                 alert('blackberry');             }else if(navigator.userAgent.toLowerCase().search(' webos ') > -1){         ...

Your IP address has changed. For security reasons, please login again in PHPLIST

You are connecting through multiple proxies and this means that your IP address isn’t the same for every page request. You can solve this in config_extended.php inside the config folder, by setting   1.  config/config_extended.php     define("CHECK_SESSIONIP",0); 2. admin / init.php       if (!defined("CHECK_SESSIONIP")) define("CHECK_SESSIONIP",1);     Change to      if (!defined("CHECK_SESSIONIP")) define("CHECK_SESSIONIP",0);    

Identify the Android device using javascript

<html>   <head>     <script>       function finddevice() {         var ua = navigator.userAgent.toLowerCase();         var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");         if(isAndroid){           alert('Android....');         }else{           alert('Other Device');         }       }     </script>   </head>   <body onload="finddevice()">     <h1> Identify the Android device using javascript </h1>   </body> </html>

Automatically refresh and redirect the Html page using meta tag

<html>   <head>     <meta http-equiv="refresh" content="10" />   </head>   <body>     <p> Automatically refresh the Html page using meta tag </p>   </body>  </html>  => The page reload every 10 seconds.  Html Page Redirection using meta tag  After loading for 10 seconds the page will redirect to www.learnpoint.info  Example:  <html>   <head>      <meta http-equiv="Refresh" content="10;URL=http://www.learnpoint.info">   </head>   <body>     <p> Automatically refresh the Html page using meta tag </p>   </body>  </html>

9 quick steps to create Ruby on Rails Application

1. ganesh > rails new sample 2. ganesh > cd sample 3. Open application_controller.rb    sample/app/controllers/application_controller.rb    4. Create method inside the application_controller     class ApplicationController < ActionController::Base          def index       end     end     6. Now create application folder (name) inside the views and create index.html.erb     sample/app/views/application/index.html.erb     Add this text to html page : Welcome to Rails 7. Need to edit routes.rb - sample/config/routes.rb       Add :       root 'application#index'             application => Controller name       index        => method name ...

Call restful services from AngularJS

AngularJS is a Javascript MVC framework created by Google.It is best framework to build better architecture web projects, especially for RESTful web services.Here is the simple example for calling rest api from AngularJS. $scope.login = function() {     var aUserName=document.getElementById(‘username’).value; // Username     var aPassword=document.getElementById(‘password’).value; // Password     var symbol = “MSFT”;     var xmlhttp = new XMLHttpRequest();         // XML Input     var xml = ‘<?xml version=”1.0″ encoding=”utf-8″?>’ +     ‘<soap:Envelope xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/soap/envelope/”>’ +     ‘<soap:Body> ‘ +     ‘<UserAuthnetication xmlns=”http://www.sample.com/NativeApp”>’ +...

Calling a method from another controller in ROR

redirect_to is the preferred way of doing this. CommentsController : class CommentsController < ApplicationController def country redirect_to :controller => ‘countries’, :action => ‘sample’ end end CountriesController : class CountriesController < ApplicationController def sample render :text => ‘Test’ end end Output : Test

Error : Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

Error : ganesh$ rails s Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0 Solution : If you type rvm list and it shows a 2.0 version of ruby as your current version and you are still getting this error,typing rvm use (ruby version) fixed this issue 1. ganesh$ rvm list rvm rubies =* ruby-1.9.3-p429 [ x86_64 ] ruby-2.0.0-p247 [ x86_64 ] ruby-2.1.0 [ x86_64 ] # => – current # =* – current && default # * – default 2. ganesh$ rvm use ruby-2.0.0-p247 Using /Users/ganesh/.rvm/gems/ruby-2.0.0-p247 3. ganesh$ rails s

Purpose of robots.txt file

When search engine crawlers (robots) look at a website, the first file they will look at is not your index.html page.  It is your robots.txt file. This little file that sits in the root “/” of your website contains instructions on what files the robot can and cannot look at within the website. Read More: http://www.hallaminternet.com/2014/the-importance-of-a-robots-txt-file/

Simple Image and File Upload using Ruby on Rails (CarrierWave gem)

I’m going to show you a very simple way to upload your attachments or a picture using CarrierWave gem. Steps: 1.    Open Terminal. 2.   Create a new project terminal > rails new imageupload 3.   Add this line to Gemfile     gem ‘ carrierwave ‘ 4.   terminal > bundle install 5.   terminal > rails g uploader image 6.   terminal > rails g scaffold Painting name:string image:string 7.   terminal > rake db:migrate 8.   Add this line to painting.rb (app/models/painting.rb)     class Painting < ActiveRecord::Base      mount_uploader :image, ImageUploader     end 9.   And then in your app/views/paintings/_form.html.erb edit your code, which become     <%= f.label :image %>     <%= f. text_field :image %>   ...