Tuesday, December 22, 2015

Smooth expansion of DIV with jQuery

var bigWidth=800;
$("#map").width() == bigWidth ?
 $("#map").fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300).animate({ height: 400, width: 400 }) :
 $("#map").fadeOut(300).fadeIn(300).fadeOut(300).fadeIn(300).animate({ height: 400, width: 800 });

Tuesday, December 15, 2015

Javascript padding


 function pad(str, character, max, side, visibility) {
  str = str.toString();
  console.log('inside pad: '+str);
  var pad;
  var output;
  pad='';
  for (var i=str.length;i<max;i++ ) {
       pad = pad + character;
  }
  pad="<span style='visibility:"+ visibility + "'>" + pad + "</span>";
  side=='left'?  output=pad+str : output=str+pad ;
  return output;
 }

input=$('#serialnumber').text(); 
$('#serialnumber').html(  pad( input, 'F', 16, 'right', 'hidden')  );

Wednesday, November 4, 2015

GIT Merge Tool : Very Basic

#!/usr/bin/env bash
git branch -vvv;
echo "intergration branch:"
read int
echo "branch to merge:"
read mergebranch
git checkout $int && git merge --no-edit --no-ff $mergebranch
# example:  git checkout lm/generalLake && git merge --no-edit --no-ff origin/lm/ottersSwim

MySQL Count Duplicates

#!/usr/bin/env bash
echo "Table to read:"
read table
echo "Column to count and display:"
read col
echo "Threshold number:"
read num
echo "SELECT $col FROM $table GROUP BY $col HAVING count(*) > $num;";

Useage

Table to read: geocodes Column to count and display: ip Threshold number: 2 SELECT ip FROM geocodes GROUP BY ip HAVING count(*) > 2;

GIT Checkout Loop

#!/usr/bin/env bash



while true
do
 git fetch --prune; 
        git branch -vvv
 echo "provide branch name to checkout:"
 read branch
        git checkout $branch;
        git pull;
        git log --decorate --pretty=tformat:'%h %d %ar %s' --first-parent --reverse -30;
        git log -1
 $1  # arg to import a command, such as 'exit'
done

Monday, November 2, 2015

GIT Log Search Source Script

#!/usr/bin/env bash
# this.is.lance.miller@gmail.com
regex="$2*$3*$4"
clear
echo "useage"
echo "$0 2 foo fab fangs"
echo "2 is the number of results"
echo  "foo fab fangs are the search terms. wildcards are placed in between them"
echo "press [Enter] to proceed"
read
echo "search string is: $regex"
for i in `git log -$1 --decorate --pretty=tformat:'%h %d %an %ar %s' --source --all -i -G $regex | cut -d" " -f1`;
do
 echo $i
 git show $i
done
exit

Use Example

searchGIT.sh 2 foo fab fangs
2 is the number of results
foo fab fangs are the search terms. wildcards are placed in between them

Friday, October 30, 2015

Javascript: If undefined or null or string length equals zero return false

function checkExists(myVar) {

 if (typeof myVar === 'undefined')  { return false;  }
 if ( myVar === null )      { return false;  }
 if ( myVar.length == 0)            { return false; } 
 
 return true;
 
}