Tuesday, April 28, 2015

GIT Reset Branch shell script

#!/usr/bin/env bash
echo "enter name of branch to checkout and hard reset"
read branch
git fetch; 
git checkout $branch ;
git branch -vvv;
git reset --hard origin/$branch;

Tuesday, April 14, 2015

If IE HTML5 JS

<!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
     </script>
    <![endif]-->

Sunday, March 29, 2015

SSH Forever Script

#!/usr/bin/env bash
while true
do
ssh $1
done

Tuesday, February 10, 2015

Javascript Element Diagnostic Function

function elementResearch(elementType, searchVal) {
 // e.g. elementType = 'input'
 console.log(" elementResearch begin in element type " + elementType);
 $('body').find(elementType).each(
           function(unusedIndex, child) {
               if(child.value==searchVal && searchVal!='') { 
                  console.log("___ELEMENTRESEARCH FOUND THE VALUE YOU ARE TESTING!!!___"); 
                  console.log("the child.name you are wanting is: " + child.name); 
                  $(child).each(function() {
               $.each(child.attributes, function() {
               if(this.value!='hidden') {
                         console.log( elementType + " || attribute name:" +  this.name + " || attribute value:" +this.value);
                 }
                 }); // each attr
              }); // each child
            } // if big match
                  if(searchVal=='') {
                  $(child).each(function() {
                  $.each(child.attributes, function() {
                  console.log( elementType + " || attribute name:" +  this.name + " || attribute value:" +this.value);
               }); // each attr  
                }); // each child
                } // if searchVal==""
       }); // each input
} // function



elementResearch('input', 'TEST');

Wednesday, December 17, 2014

Javascript jQuery Scroll Event Listener Print Scroll Position to Console Log

$(window).scroll(function (event) {
    var scroll = $(window).scrollTop();
    console.log(scroll);
});

Save scroll position for reload or ajax call for new content

var scroll = 0;
scroll = $(window).scrollTop();
console.log(scroll); 
location.reload();
$(window).scrollTop(scroll);

Thursday, December 4, 2014

Iterating over all cookies and local storage

console.log('COOKIES LIST BEGIN');
var theCookies = document.cookie.split(';');
 for (var i = 1 ; i <= theCookies.length; i++) {
        console.log(theCookies[i-1]);
    }
console.log('COOKIES LIST END');
console.log('localStorage LIST BEGIN');
for(var i in localStorage) {
       console.log(localStorage[i]);
        }

 for(var i=0, len=localStorage.length; i " + value);
    if(key == 'GetSystemStatus') {
            var bill = value.search(/ bill=\"8\" /);
            console.log(bill);
            bill != -1 ? console.log('did NOT find') : console.log('found it'); }
        }
        } 

Wednesday, November 12, 2014

jQuery. Get ID of each element in a class using .each

$('.myClassName').each(function() {
    console.log( this.id );
});