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') );
?>