Monday, 31 July 2017

Java basics


The following example uses a Class object to print the class name of an object
=======================================================

package source;

class calculate{
void print(){
System.out.println("inside print");
}

}

public class Employee {

public static void main(String args[]){

calculate obj=new calculate();

System.out.println(obj.getClass().getName());      //source.calculate
}

}


=================================================

Tuesday, 18 July 2017

Java Calendar


Calendar cal_Two = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
System.out.println(cal_Two.getTime());
and the response i got is:
Sat Jan 25 15:44:18 IST 2014

===========================
https://stackoverflow.com/questions/21349475/calendar-getinstancetimezone-gettimezoneutc-is-not-returning-utc-time

Thursday, 6 July 2017

Code camp- Java Script



https://repl.it/languages/javascript
=================================
function rot13(str) { // LBH QVQ VG!
 
 
  // console.log(str.charAt(0));
 

  // console.log(str.charCodeAt(0));
  // var x=str.charCodeAt(0)-13;
  // console.log(str.charCodeAt(0)-13);
  // console.log(String.fromCharCode(x));
   var m,n;
   var p,q,r,s;
   var arr=str.split('');
   var newStr=[];
   var finStr="";
 

 for(var i=0;i<arr.length;i++){
     // m=parseInt(str.charCodeAt(i)+13);
    // n=parseInt(str.charCodeAt(i)-13);
 
     // console.log(m);
     
      p=str.charCodeAt(i);
      //console.log(p);
      //console.log(parseInt(p));
     
      if(parseInt(p)>=78)
      {
        console.log("if");
        n=parseInt(str.charCodeAt(i)-13);
        q=(String.fromCharCode(n));
        newStr.push(q);
         //console.log(n);
      //   console.log(String.fromCharCode(n));
         // newStr.concat(String.fromCharCode(m));
   
      }
      else {
        console.log("else");
        m=parseInt(str.charCodeAt(i)+13);
         // console.log(m);
         // console.log(String.fromCharCode(m));
         
          r=(String.fromCharCode(m));
          //console.log(r);
          //finStr.concat(r);
          newStr.push(r);
      }
     
   

     
     
 
 }

     console.log(newStr.toString().replace( /,/g,"").replace(/-/g," "));
 
 
 
 
 
}
//   // console.log(arr);
 
//     for(var i=0;i<arr.length;i++){
//       m=parseInt(str.charCodeAt(i)+13);
// console.log ( str.charAt(i)+" =>"+str.charCodeAt(i) +"=> "+parseInt(str.charCodeAt(i)+13)+"=>"+String.fromCharCode(m));
//       if(parseInt(str.charCodeAt[i])>=78){
//         n=parseInt(str.charCodeAt(i)-13);
//         console.log(String.fromCharCode(n));
//       }
 
//     }
// // return str;
// }


// rot13("SERR PBQR PNZC");
//rot13("SERR CVMMN!");        //FREE PIZZA.
//rot13("GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.")
//rot13("MNOP");
//rot13("ABCD EFGH IJKL MNOP QRST UVWX YZ");



=========================



function rot13(str) { // LBH QVQ VG!
 
   var m,n;
   var p,q,r,s;
   var arr=str.split('');
   var newStr=[];
 
 for(var i=0;i<arr.length;i++){
     // m=parseInt(str.charCodeAt(i)+13);
    // n=parseInt(str.charCodeAt(i)-13);
 
     // console.log(m);
     
      p=str.charCodeAt(i);
      //console.log(p);
      //console.log(parseInt(p));
     
      if(parseInt(p)>=78)
      {
        n=parseInt(str.charCodeAt(i)-13);
         //console.log(n);
        // console.log(String.fromCharCode(n));
         // newStr.concat(String.fromCharCode(m));
        q=(String.fromCharCode(m));
        newStr.push(q);
   
      }
      else {
        m=parseInt(str.charCodeAt(i)+13);
         // console.log(m);
         // console.log(String.fromCharCode(m));
         
          r=(String.fromCharCode(m));
          //console.log(r);
          //finStr.concat(r);
          newStr.push(r);
      }
     
 
 }

     //console.log(newStr.toString().replace(/\,/g,""));
 
   str=newStr.toString().replace( /,/g,"").replace(/-/g," ");
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");


======================================

Wednesday, 5 July 2017

JavaScript

JavaScript


https://codepen.io/pen/


mdn Learning area


============================

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
  <title>Apply JavaScript example</title>
</head>
<body>


  <button>Click me</button>

<script>

  // JavaScript goes here
  function createParagraph() {
  var para = document.createElement('p');
  para.textContent = 'You clicked the button!';
  document.body.appendChild(para);
}

var buttons = document.querySelectorAll('button');

for (var i = 0; i < buttons.length ; i++) {
  buttons[i].addEventListener('click', createParagraph);
}

</script>


</body>
</html>


=======================


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
  <title>Apply JavaScript example</title>
</head>
<body>


  <p>Update your name</p>
   <style>

   p {
  font-family: 'helvetica neue', helvetica, sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: center;
  border: 2px solid rgba(0,0,200,0.6);
  background: rgba(0,0,200,0.3);
  color: rgba(0,0,200,0.6);
  box-shadow: 1px 1px 2px rgba(0,0,200,0.4);
  border-radius: 10px;
  padding: 3px 10px;
  display: inline-block;
  cursor:pointer;
}
   </style>



<script>

  // JavaScript goes here
  var para = document.querySelector('p');

para.addEventListener('click', updateName);

function updateName() {
  var name = prompt('Enter your name:');
  para.textContent = 'Your Name ' + name;
}


</script>


</body>
</html>


=========================================

JavaScript

Array.prototype.splice()



var numbers=['one','two','three','five'];


numbers.splice(1);     // [ 'one' ]
numbers.splice(2);     // [ 'one', 'two' ]
numbers.splice(3);     // [ 'one', 'two', 'three' ]

console.log(numbers);



==============================================================
Insert

numbers.splice(1,0,'nine');  //[ 'one', 'nine', 'two', 'three', 'five' ]


numbers.splice(3,0,'eight'); // [ 'one', 'two', 'three', 'eight', 'five' ]



====================================================================

Delete

numbers.splice(0,2);  // [ 'three', 'five' ]

numbers.splice(2,1);    //[ 'one', 'two', 'five' ]


numbers.splice(1,2);     //[ 'one', 'five' ]

===========================================================
Delete & Insert


numbers.splice(1,1,'zero'); // [ 'one', 'zero', 'three', 'five' ]



numbers.splice(2,1,'six');  // [ 'one', 'two', 'six', 'five' ]


=================================================================




function mutation(arr) {
  
          var m,n;
          
     m=arr[0].toLowerCase().split('').sort().join('');
     n=arr[1].toLowerCase().split('').sort().join('');
    console.log(m);
    console.log(n);
    console.log(m==n);
   
}

mutation(["Hello", "hey"]);  // false
mutation(["Alien", "line"]);  // false
mutation(["rat", "tar"]);        //true


mutation(["Alien", "line"]);
 console.log(m.indexOf(n)!=-1);




==================================================

var numbers=[1,2,3,4,5];

 var doubles=numbers.map(function(x){
     return x*2;
   
 })
 console.log(doubles);   // [ 2, 4, 6, 8, 10 ]


===========================================================

filter



var numbers=[12,34,2,45,64];


numbers.filter(greater);


function greater(x){
  
  return x>30;
}


//[ 34, 45, 64 ]
====================================
var numbers=[12,34,2,45,64];


// numbers.filter(greater);


// function greater(x){
 
//   return x>30;
// }


numbers.filter(function(x){
    return x>30;
 
})


//[ 34, 45, 64 ]



======================================




Friday, 16 June 2017

free Code Camp


HTML5 & CSS
========================================================


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>



=================================================================


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>


=================================================================


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

==================================================================



<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .smaller-image {
    width: 100px;
  }
  .thick-green-border{
    border-width:10px;
    border-style:solid;
    border-color:green;
 
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

====================================================================



===================================================================


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>


<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">

<a href="http://freecatphotapp.com">cat photos</a>
<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

=======================================================================





<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>View more <a href="http://www.freecatphotoapp.com">cat photos</a> </p>

<img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">

<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

=====================================================================




<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. ">cat photos</a>.</p>



<p class="red-text">Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
<p class="red-text">Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>

====================================================================






<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back. "></a>
<ul>
  <li>milk</li>
  <li>cheese</li>
  <li>meat</li>
</ul>

========================================================




<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back. " src="https://bit.ly/fcc-relaxing-cat"></a>

<p>Things cats love:</p>
<ul>
  <li>cat nip</li>
  <li>laser pointers</li>
  <li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
  <li>flea treatment</li>
  <li>thunder</li>
  <li>other cats</li>
</ol>
<input type="text">


===============================================================



<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back. " src="https://bit.ly/fcc-relaxing-cat"></a>

<p>Things cats love:</p>
<ul>
  <li>cat nip</li>
  <li>laser pointers</li>
  <li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
  <li>flea treatment</li>
  <li>thunder</li>
  <li>other cats</li>
</ol>

<form action="/submit-cat-photo">
<input type="text" placeholder="cat photo URL"> </form>


============================================================



<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back. " src="https://bit.ly/fcc-relaxing-cat"></a>

<p>Things cats love:</p>
<ul>
  <li>cat nip</li>
  <li>laser pointers</li>
  <li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
  <li>flea treatment</li>
  <li>thunder</li>
  <li>other cats</li>
</ol>
<form action="/submit-cat-photo">
  <input type="text" placeholder="cat photo URL" required>
  <button type="submit">Submit</button>
  <label><input type="radio">indoor</label>
  <label><input type="radio">outdoor</label>
</form>
=========================================================



<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }

  h2 {
    font-family: Lobster, Monospace;
  }

  p {
    font-size: 16px;
    font-family: Monospace;
  }

  .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
    border-radius: 50%;
  }

  .smaller-image {
    width: 100px;
  }
</style>

<h2 class="red-text">CatPhotoApp</h2>

<p>Click here for <a href="#">cat photos</a>.</p>

<a href="#"><img class="smaller-image thick-green-border" alt="A cute orange cat lying on its back. " src="https://bit.ly/fcc-relaxing-cat"></a>

<p>Things cats love:</p>
<ul>
  <li>cat nip</li>
  <li>laser pointers</li>
  <li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
  <li>flea treatment</li>
  <li>thunder</li>
  <li>other cats</li>
</ol>

<form action="/submit-cat-photo">
  <label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
  <label><input type="radio" name="indoor-outdoor"> Outdoor</label>
  <label><input type="checkbox" name="personality" checked> Loving</label>
  <label><input type="checkbox" name="personality"> Lazy</label>
  <label><input type="checkbox" name="personality"> Energetic</label>
  <input type="text" placeholder="cat photo URL" required>
  <button type="submit">Submit</button>
</form>

=============================================================






=================================================================

Padding , margin & border


Padding


Margin





==========================================






====================================

margins









==============================================
CSS Color styles -overriding



<style>
  .injected-text {
    margin-bottom: -25px;
    text-align: center;
  }

  .box {
    border-style: solid;
    border-color: black;
    border-width: 5px;
    text-align: center;
  }

  .yellow-box {
    background-color: yellow;
    padding: 20px 40px 20px 40px;
  }

  .red-box {
    background-color: red;
    padding: 20px 40px 20px 40px;
  }

  .green-box {
    background-color: green;
    padding:40px 20px 20px 40px
  }
</style>
<h5 class="injected-text">margin</h5>

<div class="box yellow-box">
  <h5 class="box red-box">padding</h5>
  <h5 class="box green-box">padding</h5>

</div>







=================================================



Tuesday, 13 June 2017

Java - Calendar

 if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
         System.out.println("Weekend");
     } else {
        System.out.println("Weekday");
     }