Saturday, July 25, 2015

GIT checkout and reset --hard for all remote branches


#!/usr/bin/env bash
echo "present working directory is:";
pwd; 
echo ; 
echo "enter your GIT project dir, or .(dot) followed by [ENTER]:"
read directory
cd $directory;
echo "present working directory is:";
pwd; 
echo 'git fetch' 
git fetch
for branch in `git branch`; do
    echo "$branch";
    echo "git checkout $branch"
    git checkout $branch
    echo "git reset --hard origin/$branch"
    git reset --hard origin/$branch
    git log -1;
done
exit

Friday, July 17, 2015

Class.each with ajax for each

$('.routeInfo').each(function(){
    // 
    fid = $(this).attr("fid");
    id = $(this).attr("id");
    uniqueID = $(this).attr("uniqueID");
    $.ajax({
            url: '/route.php',
            type: 'GET',
            data: { fid: fid , user: 'fred' } ,
            success: function (response ) {
                 if(response.length > 5) {
                        $("#" + id).html('ROUTE STATUS: '+response);                   
                                     }  else {
                                     $("#" + id).html('ROUTE STATUS: Not Routed');
                                       }
            },
            error: function () { console.log('ajax error'); }
        });
     });  

Thursday, July 16, 2015

Button click animation

$("button").click(function(){
 this.animate({ opacity: '0.1'}, "slow" );
 this.animate({ opacity: '1.0'}, "fast");
});

Wednesday, July 8, 2015

Server side log of javascript user notification

<?php
 
$file = 'htmlMsg.txt'; 
 
$input=date("D M d, Y G:i a"); 
$input=$input."\n";
foreach($_REQUEST as $key=>$value) {
 $input=$input.$key.": ".$value."\n";
}

$filesize = (filesize($file) * .0009765625) * .0009765625; // bytes to MB
if($filesize > 1) {
 file_put_contents($file, $input); // overwrite and thus downsizing the $file
} else {
 file_put_contents($file, $input, FILE_APPEND);
}

die($filesize);  

// ajax call to this script.
// $.post("/ls/htmlMsg.php", { msg: htmlMsg }, console.log('posted htmlMsg') );
?>

Saturday, June 27, 2015

GIT New Branch Creator


#!/usr/bin/env bash
echo "present working directory is:";
pwd; 
echo ; echo "enter your GIT project dir, followed by [ENTER]:"
read directory
cd $directory;
echo "present working directory is:";
pwd; 
echo 'git branch -vvv;';
git branch -vvv;
echo "this is the branch you are on [ENTER]";  
read a 
echo ; echo "enter branch you want to hard reset and use as new branch, followed by [ENTER]:"
read branch
git fetch; 
git checkout  $branch; 
git reset --hard origin/$branch;
echo ; echo "enter the new branch name, followed by [ENTER]:"
read newBranch
git checkout -b $newBranch $branch;
git push -u origin $newBranch;
echo 'git branch -vvv;';
git branch -vvv;
echo "this is the branch you are on [ENTER]"; 

Friday, May 1, 2015

Parse Google Geocode XML

function parseXml(xml) { // CURRENT EDIT  
 $(xml).find("address_component").each(function() {
    if($(this).text().indexOf("locality")!= -1) {
        city =$(this).find('long_name').text();
    }
    if($(this).text().indexOf("administrative_area_level_1")!= -1) {
        adminLevel =$(this).find('long_name').text();
    }
    if($(this).text().indexOf("country")!= -1) {
       country =$(this).find('long_name').text();  
    }
   console.log($(this).text()); // just to see them all
 });
  
  console.log(city + " " + adminLevel + " " + country);
  $('#test').text(city + " " + country);

}




<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>route</type>
  <formatted_address>Nnewi-Okigwe Road, Amichi, Nigeria</formatted_address>
  <address_component>
   <long_name>Nnewi-Okigwe Road</long_name>
   <short_name>Nnewi-Okigwe Rd</short_name>
   <type>route</type>
  </address_component>
  <address_component>
   <long_name>Amichi</long_name>
   <short_name>Amichi</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Anambra</long_name>
   <short_name>Anambra</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Nigeria</long_name>
   <short_name>NG</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>5.9868133</lat>
    <lng>6.9893765</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>5.9843302</lat>
     <lng>6.9857796</lng>
    </southwest>
    <northeast>
     <lat>5.9894128</lat>
     <lng>6.9930699</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>5.9843302</lat>
     <lng>6.9857796</lng>
    </southwest>
    <northeast>
     <lat>5.9894128</lat>
     <lng>6.9930699</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJb1nthTaiQxAREtwqA9BC5k0</place_id>
 </result>
 <result>
  <type>locality</type>
  <type>political</type>
  <formatted_address>Igbo Ukwu, Nigeria</formatted_address>
  <address_component>
   <long_name>Igbo Ukwu</long_name>
   <short_name>Igbo Ukwu</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Anambra</long_name>
   <short_name>Anambra</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Nigeria</long_name>
   <short_name>NG</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>6.0166670</lat>
    <lng>7.0166670</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>5.9819729</lat>
     <lng>6.9909096</lng>
    </southwest>
    <northeast>
     <lat>6.0420653</lat>
     <lng>7.0363998</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>5.9819729</lat>
     <lng>6.9909096</lng>
    </southwest>
    <northeast>
     <lat>6.0420653</lat>
     <lng>7.0363998</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJvehBRPuhQxARwZIdLwwUaj0</place_id>
 </result>
 <result>
  <type>administrative_area_level_1</type>
  <type>political</type>
  <formatted_address>Anambra, Nigeria</formatted_address>
  <address_component>
   <long_name>Anambra</long_name>
   <short_name>Anambra</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Nigeria</long_name>
   <short_name>NG</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>6.2757656</lat>
    <lng>7.0068393</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>5.6926150</lat>
     <lng>6.6130860</lng>
    </southwest>
    <northeast>
     <lat>6.7795999</lat>
     <lng>7.3559340</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>5.6926150</lat>
     <lng>6.6130860</lng>
    </southwest>
    <northeast>
     <lat>6.7795999</lat>
     <lng>7.3559340</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJ-cKEFhqFQxAR0LT76AGtYs8</place_id>
 </result>
 <result>
  <type>country</type>
  <type>political</type>
  <formatted_address>Nigeria</formatted_address>
  <address_component>
   <long_name>Nigeria</long_name>
   <short_name>NG</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>9.0819990</lat>
    <lng>8.6752770</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>4.2698571</lat>
     <lng>2.6769320</lng>
    </southwest>
    <northeast>
     <lat>13.8856450</lat>
     <lng>14.6779820</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>4.2698571</lat>
     <lng>2.6769320</lng>
    </southwest>
    <northeast>
     <lat>13.8856450</lat>
     <lng>14.6779820</lng>
    </northeast>
   </bounds>
  </geometry>
  <place_id>ChIJDY2kfa8LThARyAvFaEH-qJk</place_id>
 </result>
</GeocodeResponse>

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;