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 22, 2015
Smooth expansion of DIV with jQuery
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; }
Thursday, October 15, 2015
PHP disk_free_space
$diskFreeSpace = round(disk_free_space($data_drive) / 1024 / 1024 / 1024);Nice little uptimeRobot alert script:
isset($_REQUEST['threshold']) ? $driveThresold=$_REQUEST['threshold'] : $driveThresold=11; function killMe($input) { header('HTTP/1.1 500 Internal Server Error'); die(); } function allGood($input) { header("Content-Type:text/plain") ; die($input); } $diskFreeSpace = round(disk_free_space($data_drive) / 1024 / 1024 / 1024); $diskfreespace < $driveThresold ? killMe($diskfreespace) : allGood(strval($diskfreespace)); die();
Friday, October 2, 2015
Directory List to XML
<?php header("Content-type: text/xml"); print "<?xml version='1.0' encoding='UTF-8'?>\n<response?>\n"; $files = glob('*.xml'); foreach($files as $file) { print "<file?>".$file."</file?>\n<!-- ".date("F d Y H:i:s.",filemtime($file))."--?>\n"; } die(''); ?>
Tuesday, August 11, 2015
GIT Rebase Basic with Force Push.
#!/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 "enter name of experiment branch"; read experiment echo $experiment git checkout $experiment echo "enter name of master branch"; read master echo $master git checkout $master git rebase $master echo "git push --force origin $experiment:$experiment WILL HAPPEN AFTER YOU PRESS ENTER"; read reply git push --force origin $experiment:$experiment exit;
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;
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
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');
Subscribe to:
Posts (Atom)