tag:blogger.com,1999:blog-70933593198129983912024-03-18T19:52:48.110-07:00small code<a href="mailto:this.is.lance.miller@gmail.com">
this.is.lance.miller@gmail.com</a>
<br>
<a href="https://www.gofundme.com/lancemiller-ez-contractors-app">GoFundMe</a>LanceMillerhttp://www.blogger.com/profile/12967321155433918187noreply@blogger.comBlogger169125tag:blogger.com,1999:blog-7093359319812998391.post-71058391735173844292020-06-28T08:58:00.000-07:002020-06-28T08:58:31.610-07:00Come Ear Boya Bot<div>My 12 year old son asked to create a web crawler bot. The project will progress at the link below.</div><div><br></div><div><a href="https://lancemiller.org/come_ear_boya_bot.php" title="https://lancemiller.org/come_ear_boya_bot.php">https://lancemiller.org/come_ear_boya_bot.php</a><br></div>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-55590793686558074822017-09-23T19:32:00.000-07:002017-09-23T21:04:10.870-07:00Guitar Fretboard Notes in PHP
<p>Jump <a href="#here">to here</a> to see how the specific strings are populated with correct note values.</p>
<pre>
<?php
$notes = [
['C' , '16.35'] ,
['C♯' , '17.32'] ,
['D' , '18.35'] ,
['E♭' , '19.45'] ,
['E' , '20.60'] ,
['F' , '21.83'] ,
['F♯' , '23.12'] ,
['G' , '24.50'] ,
['G♯' , '25.96'] ,
['A' , '27.50'] ,
['B♭' , '29.14'] ,
['B' , '30.87'] ,
['C' , '32.70'] ,
['C♯' , '34.65'] ,
['D' , '36.71'] ,
['E♭' , '38.89'] ,
['E' , '41.20'] ,
['F' , '43.65'] ,
['F♯' , '46.25'] ,
['G' , '49.00'] ,
['G♯' , '51.91'] ,
['A' , '55.00'] ,
['B♭' , '58.27'] ,
['B' , '61.74'] ,
['C' , '65.41'] ,
['C♯' , '69.30'] ,
['D' , '73.42'] ,
['E♭' , '77.78'] ,
['E' , '82.41'] ,
['F' , '87.31'] ,
['F♯' , '92.50'] ,
['G' , '98.00'] ,
['G♯' , '103.80'] ,
['A' , '110.00'] ,
['B♭' , '116.50'] ,
['B' , '123.50'] ,
['C' , '130.80'] ,
['C♯' , '138.60'] ,
['D' , '146.80'] ,
['E♭' , '155.60'] ,
['E' , '164.80'] ,
['F' , '174.60'] ,
['F♯' , '185.00'] ,
['G' , '196.00'] ,
['G♯' , '207.70'] ,
['A' , '220.00'] ,
['B♭' , '233.10'] ,
['B' , '246.90'] ,
['C' , '261.60'] ,
['C♯' , '277.20'] ,
['D' , '293.70'] ,
['E♭' , '311.10'] ,
['E' , '329.60'] ,
['F' , '349.20'] ,
['F♯' , '370.00'] ,
['G' , '392.00'] ,
['G♯' , '415.30'] ,
['A' , '440.00'] ,
['B♭' , '466.20'] ,
['B' , '493.90'] ,
['C' , '523.30'] ,
['C♯' , '554.40'] ,
['D' , '587.30'] ,
['E♭' , '622.30'] ,
['E' , '659.30'] ,
['F' , '698.50'] ,
['F♯' , '740.00'] ,
['G' , '784.00'] ,
['G♯' , '830.60'] ,
['A' , '880.00'] ,
['B♭' , '932.30'] ,
['B' , '987.80'] ,
['C' , '1047.00'] ,
['C♯' , '1109.00'] ,
['D' , '1175.00'] ,
['E♭' , '1245.00'] ,
['E' , '1319.00'] ,
['F' , '1397.00'] ,
['F♯' , '1480.00'] ,
['G' , '1568.00'] ,
['G♯' , '1661.00'] ,
['A' , '1760.00'] ,
['B♭' , '1865.00'] ,
['B' , '1976.00'] ,
['C' , '2093.00'] ,
['C♯' , '2217.00'] ,
['D' , '2349.00'] ,
['E♭' , '2489.00'] ,
['E' , '2637.00'] ,
['F' , '2794.00'] ,
['F♯' , '2960.00'] ,
['G' , '3136.00'] ,
['G♯' , '3322.00'] ,
['A' , '3520.00'] ,
['B♭' , '3729.00'] ,
['B' , '3951.00'] ,
['C' , '4186.00'] ,
['C♯' , '4435.00'] ,
['D' , '4699.00'] ,
['E♭' , '4978.00'] ,
['E' , '5274.00'] ,
['F' , '5588.00'] ,
['F♯' , '5920.00'] ,
['G' , '6272.00'] ,
['G♯' , '6645.00'] ,
['A' , '7040.00'] ,
['B♭' , '7459.00'] ,
['B' , '7902.00']
] ;
function wrapNote($input) {
$letter=$input[0];
$hz=$input[1];
return "<span class='note ".$hz."'>".$letter."</span> <span class='note '>".$hz."</span>";
}
<a name='here'></a>
foreach($notes as $key=>$note) {
switch($notes[$key][1]) {
case 82.41:
$E=$key;
break;
case 110.00:
$a=$key;
break;
case 146.80:
$d=$key;
break;
case 196.00:
$g=$key;
break;
case 246.90:
$b=$key;
break;
case 329.60:
$e=$key;
break;
}
}
$E = array_slice($notes, $E, 13);
$a = array_slice($notes, $a, 13);
$d = array_slice($notes, $d, 13);
$g = array_slice($notes, $g, 13);
$e = array_slice($notes, $e, 13);
foreach($E as $key=>$value) {
print wrapNote($e[$key]);
print wrapNote($b[$key]);
print wrapNote($g[$key]);
print wrapNote($d[$key]);
print wrapNote($a[$key]);
print wrapNote($E[$key]);
print "<br />";
print "<br />";
}
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-70543341758139314902017-08-08T05:23:00.001-07:002017-08-08T05:26:32.277-07:00Javascript Memory Limit and Usage in Chrome<br />
<br />
<script><br />
// Thank you stackoverflow user B. Gruenbaum<br />
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
console.log('performance.memory.jsHeapSizeLimit='+performance.memory.jsHeapSizeLimit);<br />
// will give you the JS heap size<br />
console.log('performance.memory.usedJSHeapSize='+performance.memory.usedJSHeapSize);<br />
// how much you're currently using<br />
</script><br />
<br />
Slightly off topic from post title, the following may be an issue in the problem set being thought on in regards to memory limits: JSON object sizes.<br />
In my scenario I had static reference data in CSV format. I converted to JSON files ( e.g. materials.json). Here is standalone PHP script you can place in directory of JSON files and get file sizes and javascript memory info all together.<br />
<br />
<!DOCTYPE html><br />
<html><br />
<head><br />
<span style="white-space: pre;"> </span><meta charset="utf-8"><br />
<span style="white-space: pre;"> </span><meta name="viewport" content="width=device-width, initial-scale=1"></meta><br />
<span style="white-space: pre;"> </span><meta name="format-detection" ></meta><br />
<span style="white-space: pre;"> </span><title>JS Memory Size</title> <span style="white-space: pre;"> </span><br />
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script><br />
<?php<br />
foreach(glob('*.json') as $file) {<br />
print "<script type='text/javascript' src='".$file."' ></script>".PHP_EOL;<br />
}<span style="white-space: pre;"> </span><br />
?><span style="white-space: pre;"> </span><br />
<br />
<script><br />
$(document).ready(function(){<br />
console.log('performance.memory.jsHeapSizeLimit='+performance.memory.jsHeapSizeLimit);<br />
// will give you the JS heap size<br />
console.log('performance.memory.usedJSHeapSize='+performance.memory.usedJSHeapSize);<br />
// how much you're currently using<br />
$('#jsHeapSizeLimit').text(performance.memory.jsHeapSizeLimit);<br />
$('#usedJSHeapSize').text(performance.memory.usedJSHeapSize);<br />
});<span style="white-space: pre;"> </span><br />
</script><br />
<style><br />
<span style="white-space: pre;"> </span>td {<br />
<span style="white-space: pre;"> </span>align:left;<span style="white-space: pre;"> </span><br />
<span style="white-space: pre;"> </span>border:1px dotted #000000;<br />
<span style="white-space: pre;"> </span>padding:5px;<br />
<span style="white-space: pre;"> </span>}<br />
</style><span style="white-space: pre;"> </span><br />
</head><br />
<body><br />
<span style="white-space: pre;"> </span><h1>JS Memory Size</h1><br />
<table><tr><br />
<th>Size</th><th>Info</th><br />
</tr><span style="white-space: pre;"> </span><br />
<td id='jsHeapSizeLimit'></td><td>Size Limit</td><br />
</tr><tr><br />
<td id='usedJSHeapSize'></td><td>Currently Used</td><br />
</tr><br />
<?php<br />
foreach(glob('*.json') as $file) {<br />
print "<tr><td>".filesize($file)."</td><td>".$file."</td></tr>".PHP_EOL;<br />
}<span style="white-space: pre;"> </span><br />
?><span style="white-space: pre;"> </span><br />
</table><br />
</body><br />
</html><br />
<?php<br />
die();<br />
?><br />
<br /> this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-82921400885582394312017-06-08T04:17:00.002-07:002017-06-08T04:24:04.034-07:00Dynamically create input name and id via associated label text<span class="Apple-tab-span" style="white-space: pre;"> </span>var groupA = "";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$('label').each(function(index, item) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>var a = $(this).text();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>a = a.replace(/\W/g, '');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>a = a.replace(/\s/g, '');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>a = a.toLowerCase();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>groupA = $(this).attr('group');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$('input:text').each(function(index,item) {<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if ($(this).attr('group') == groupA) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$(this).attr('name', a + $(this).attr('typeB') );<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$(this).attr('id', a + $(this).attr('typeB') );<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>});<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>});this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-42328693942145806932017-04-04T11:48:00.005-07:002017-04-04T11:49:43.980-07:00Force use of HTTPS with Javascript<script><br />
location.protocol=='https:' ? console.log(window.location.href) : replace('https:'+location.hostname+location.pathname);<br />
</script>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-56691658060393053772017-03-17T11:10:00.001-07:002017-03-17T11:16:22.463-07:00See inventory of function in javascript filesPlace this script in same directory your javascript files are, view in browser.<br />
(and yes I know there is<i> grep -n 'function' *.js </i>but I like things I can see in browser)<br />
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier; color: #28fe14; background-color: #000000; background-color: rgba(0, 0, 0, 0.9)}
span.s1 {font-variant-ligatures: no-common-ligatures}
</style>
<?php<br />
header("Content-Type:text/plain") ;<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
$files=glob('*.js');<br />
$searchfor = 'function';<br />
foreach($files as $file) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>print $file.PHP_EOL;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$contents=file_get_contents($file);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$pattern = preg_quote($searchfor, '/');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>$pattern = "/^.*$pattern.*\$/m";<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(preg_match_all($pattern, $contents, $matches)){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> print count($matches[0])." total functions".PHP_EOL;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> print implode("\n", $matches[0]);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
?><br />
<br />
Example out:<br />
<br />
<pre style="white-space: pre-wrap; word-wrap: break-word;">main.js
37 total functions
function checkExists(myVar) {
function consoleLogTime(input) {
function debugMsg(input) {
function getQuerystring(key, default_)
function selectCustomer(input) {
function listCreate(arrayValues, arrayText, myClass) {
function optionListCreate(arrayValues, arrayText) {
function validateEmail(x) {
function checkEmailExists(email) {
success: function(result) {
error: function(result) {
function passwordReset(email) {
success: function(result) {
error: function(result) {
function listArray(myArray) {
function getJsonTable(url, table, tag) {
$.getJSON(url+'?table='+table, function(data){
$.each(data, function(index,item) {
$(document).ready(function(){
success: function(result) {
error: function(result) {
$('#signin').click(function() {
$('#signup').click(function() {
$("#passwordReset").click(function() {
$("#emailB").blur(function() {
$('.mytype').click(function() {
$("#passwordconfirmB").keyup(function() {
$("#passwordconfirmB").blur(function() {
$("#workorder").ready(function() {
$("select").ready(function() {
$("#bids").change(function() {
$("#about").click(function() {
$('.submit').click(function() {
success: function(result) {
error: function(result) {
$("#selectacustomer").click(function() {
$(".customerSelect").click(function() { </pre>
<br />
<br />this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-6455314317382752952017-02-02T13:10:00.000-08:002017-02-02T13:10:30.410-08:00Firefox about:config devtools.debugger<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXEkDHgMvS_wWladjYMgN1X0KkOWHiVmZllgE8qgh_MLF1DxEBrBbmt6kyMHr4HNj7VlD6AYKlsBgtgHvkth2P6JUjCp6n2sUrps4wiKYC3MxlWR1HGrVvu3t5siLYGF24bvSIlJXGwPg/s1600/Firefix-about-debug.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="236" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXEkDHgMvS_wWladjYMgN1X0KkOWHiVmZllgE8qgh_MLF1DxEBrBbmt6kyMHr4HNj7VlD6AYKlsBgtgHvkth2P6JUjCp6n2sUrps4wiKYC3MxlWR1HGrVvu3t5siLYGF24bvSIlJXGwPg/s640/Firefix-about-debug.jpg" width="640" /></a></div>
this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-15028960243828865802017-02-01T11:35:00.000-08:002017-02-01T11:35:38.039-08:00Web Browser Sniffing<pre>
function get_browser_name($user_agent)
{
if (strpos($user_agent, 'opera') || strpos($user_agent, 'opr/')) return 'opera';
elseif (strpos($user_agent, 'edge')) return 'edge';
elseif (strpos($user_agent, 'chrome')) return 'chrome';
elseif (strpos($user_agent, 'safari')) return 'safari';
elseif (strpos($user_agent, 'firefox')) return 'firefox';
elseif (strpos($user_agent, 'msie') || strpos($user_agent, 'trident/7')) return 'internet explorer';
elseif (strpos($user_agent, 'ipad')) return 'ipad';
return 'Other';
}
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
$browser = get_browser_name($userAgent);
(javascript)
var userAgent = '<?php print $userAgent ?>';
var browser = '<?php print $browser ?>';
console.log('userAgent '+userAgent);
console.log('browser '+browser);
</pre>
this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-29730751915351637442017-01-17T11:52:00.002-08:002017-01-17T11:52:30.616-08:00Javascript checkExists<pre>
function checkExists(myVar) {
if (typeof myVar === 'undefined') { return false; }
if ( myVar === null ) { return false; }
if ( myVar.length == 0) { return false; }
return true;
}
</pre>
this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-32408823773854447022017-01-13T05:13:00.004-08:002017-01-13T05:14:33.055-08:00MYSQL Query for Timestamp Age in Hours
SELECT `route_id` FROM `route` where `is_active`=1 <br />AND TIMESTAMPDIFF(HOUR,`dt_update`,CURRENT_TIMESTAMP())< 48;
this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-24379265306051581482017-01-09T05:42:00.003-08:002017-01-09T05:42:46.991-08:00Javascript misterClean string cleaner<pre>
function misterClean(x) {
x = x.replace(/^\s+|\s+$/gm,''); // remove end whitespace
x = x.replace(/(\r\n|\n|\r)/gm,""); // remove line breaks
return x;
}
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-50618251045286360552016-12-29T14:00:00.003-08:002016-12-29T14:00:45.164-08:00No width parameter for SPAN tags, so limit width with javascript<pre>
$('span').each(function(index, value) {
var limit = 30;
var myID = $(this).attr('id');
if(myID=='decoderip') {
limit=60;
}
var mytext = $(this).text();
if (mytext.length > limit) {
// console.log('span text: '+mytext);
$(this).text(mytext.slice(0, limit) + '...');
}
});
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-34015927314522566292016-12-19T06:15:00.000-08:002016-12-19T06:15:08.319-08:00Time seconds increment on class of elements<pre>
function updateAge() {
$('.age').each(function(){
var age=$(this).text();
age++;
$(this).text(age);
})
}
$(document).ready(function(){
console.log('document ready');
setInterval(updateAge, 1000);
})
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-64578525063625174052016-12-01T05:47:00.001-08:002016-12-01T06:08:55.382-08:00Debian Package Creator and InstallerI made this for a particular "product", change the directory variables and final archived .deb filename per your needs.<br />
<br />
debian.build.install.sh<br />
#!/usr/bin/env bash<br />
# this.is.lance.miller@gmail.com<br />
clear;<br />
basedir='/home/';<br />
microdir=$basedir"micro/";<br />
chmod 0775 $microdir'DEBIAN/postinst';<br />
myfile=$microdir'DEBIAN/control';<br />
echo $myfile;<br />
myversion=`cat $myfile | grep Version | cut -d' ' -f2`;<br />
echo $myfile' declares version '$myversion;<br />
dpkg-deb --build $microdir;<br />
ls -l $basedir*.deb;<br />
sleep 5;<br />
dpkg -i $basedir'micro.deb';<br />
ls -l $basedir*.deb;<br />
newfile='our_product_name_'$myversion'_all.deb';<br />
echo 'creating this versioned deb archive: '$newfile;<br />
mv $basedir'micro.deb' $basedir$newfile;<br />
ls -l $basedir*.deb;this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-32851535824426824872016-11-14T04:31:00.003-08:002016-11-14T04:31:48.621-08:00Kill process <pre>
target='Encoder'
kill `ps -x | grep $target | cut -d" " -f2`
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-81202168996161141862016-10-28T04:38:00.000-07:002016-10-28T14:46:56.875-07:00CPU Analysis PHP
<pre>
<?php
header("Content-Type:text/plain") ;
$free = shell_exec('free');
$free = (string)trim($free);
$free_arr = explode("\n", $free);
$mem = explode(" ", $free_arr[1]);
$mem = array_filter($mem);
$mem = array_merge($mem);
$memory_usage = $mem[2]/$mem[1]*100;
print "Report for host: ".gethostname()." ".$_SERVER['SERVER_ADDR']." timestamp: ".date("Y:m:d:h:i:s a")." year/month/date/hour/minute/seconds ".PHP_EOL.PHP_EOL;
$loadArray = sys_getloadavg();
$cpu = $loadArray[2];
$memoryMsg = "Memory ".$memory_usage." percent in use.".PHP_EOL;
print PHP_EOL."++++++++++++ operating system profile +++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL;
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL;
echo 'Operating System: '.php_uname('s').PHP_EOL;
echo 'Release Name: '.php_uname('r').PHP_EOL;
echo 'Version: '.php_uname('v').PHP_EOL;
echo 'Machine Type: '.php_uname('m').PHP_EOL;
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL;
if(file_exists('/proc/cpuinfo')) {
$retval=file_get_contents('/proc/cpuinfo');
$mycount=explode(PHP_EOL, $retval);
$cores = round( (count($mycount)/26), 0, PHP_ROUND_HALF_DOWN);
$load = $cpu/$cores;
$load = $load*100;
print PHP_EOL."++++++++++++ hardware profile +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL;
print "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL;
print "CPU has ".$cores." cores".PHP_EOL;
print PHP_EOL.'Memory:'.PHP_EOL.$free.PHP_EOL;
print PHP_EOL."+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++".PHP_EOL.PHP_EOL;
print "CPU load ".$load." percent averaged over last 15 minutes. [ sys_getloadavg() is ".$loadArray[0]." ".$loadArray[1]." ".$loadArray[2]." ]".PHP_EOL;
print $memoryMsg;
print PHP_EOL."Detailed CPU Information ( /proc/cpuinfo ) below.".PHP_EOL;
print $retval.PHP_EOL;
} else {
print "CPU load ".$cpu.PHP_EOL;
print $memoryMsg;
}
print PHP_EOL."Uptime information below.".PHP_EOL;
exec('uptime', $retval);
foreach($retval as $ret) {
print $ret.PHP_EOL;
}
?>
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-44537534417501181302016-10-06T10:40:00.002-07:002016-10-06T10:41:46.410-07:00Unix/Linux how to run a command in background<pre>
nohup myFooCommand > /dev/null 2>&1 &
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-77444413933900256002016-09-06T17:16:00.004-07:002016-09-07T04:12:19.011-07:00Perform post install scripting for Debian packages. Especially useful for setting file permissionsThere are plenty of thorough references for creating Debian .deb packages, but not enough short examples that present the bare essentials. This is a minimal example with post install scripting
-especially useful for setting file permissions- which is done specifically with the <span style="font-weight:bold;font-style:italic;color:red;">DEBIAN/postinst</span> file.<br />
<br />
<br />
<br />
The files that configure and command the Debian packaging and subsequent installation all reside in a directory named <span style="font-weight:bold;font-style:italic;color:red;">DEBIAN</span>. Here are all the files I include in my <span style="font-weight:bold;font-style:italics;">DEBIAN</span> directory:<br />
<ol>
<li>
DEBIAN/<span style="font-weight:bold;font-style:italic;color:red;">conffiles</span>
</li><li>
DEBIAN/<span style="font-weight:bold;font-style:italic;color:red;">control</span>
</li><li>
DEBIAN/<span style="font-weight:bold;font-style:italic;color:red;">postinst</span>
</li><li>
DEBIAN/<span style="font-weight:bold;font-style:italic;color:red;">rules</span>
</li></ol>
<br />
<br />
<br />
Below are the contents of the files (contents changed to protect the proprietary)
<br /><br />
<ol><li>
<div style="border:1px solid #000000;padding:2px">
DEBIAN/conffiles <br />
<pre style="border:1px dotted #00FF00;padding:5px">
<i>...blank...</i>
</pre>
</div>
</li><li>
<div style="border:1px solid #000000;padding:2px">
DEBIAN/control<br />
<pre style="border:1px dotted #00FF00;padding:5px">
Package: foo-for-bar
Version: 1.0.40
Section: Network
Priority: optional
Architecture: all
Depends:
Maintainer: Jane Doe jane.doe@example.com
Description: Acme FooBar WWW UI
User interface for Acme FooBar.
</pre>
</div>
</li><li>
<div style="border:1px solid #000000;padding:2px">
DEBIAN/postinst<br />
<pre style="border:1px dotted #00FF00;padding:5px">
#!/usr/bin/env bash
cat $0
chmod 777 /var/lib/foobar/conf/www/*
chmod 777 /var/lib/foobar/*
chmod 777 /var/lib/foobar/foobaringdaemon.py
chmod 777 /etc/local.d/80_figlets_with_foobar.sh
echo "hello there from postinst file"
</pre>
</div>
</li><li>
<div style="border:1px solid #000000;padding:2px">
DEBIAN/rules<br />
<pre style="border:1px dotted #00FF00;padding:5px">
<i>...blank...</i>
</pre>
</div>
</li></ol>
<h2>General File Structure</h2>
Let's say I want a .deb package to install files that will reside in the /var/www and /etc/local.d directories. In my case I'll create everything in the /home/ directory. Here is the root and first layer of directories.<br />
<ul><li>
/home/FOOBAR/DEBIAN
</li><li>
/home/FOOBAR/etc
</li><li>
/home/FOOBAR/var
</li></ul>
With all the above as environment to operate on, here is a .deb creation command:
<br />
<br />
cd /home/<br />
dpkg-deb --build FOOBAR
<br />
<br />
The above dpkg-deb would create a file named FOOBAR.deb
<br />
To install the FOOBAR.deb package on a machine, you would run:
<br />
<br />
dpkg -i FOOBAR.deb
<br />
<br />
A parting note. I would rename my FOOBAR.deb to FOOBAR.1.0.40.deb to make evident the version number of the package.
<br />
this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-83415880394529090542016-08-10T03:58:00.000-07:002016-08-10T03:58:38.630-07:00jQuery Dialog zIndex<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
$( ".selector" ).dialog();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
$( ".selector" ).css("background-color", "red");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
console.log( 'z-index ' + $( ".selector" ).zIndex() );this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-10532297063246880402016-04-05T13:25:00.000-07:002016-04-05T13:25:10.955-07:00Make Sure Element is Visible and Displayed : Javascript <pre>
function makeVisible(id) {
if($('#'+id).css('display') == 'none') {
$('#'+id).css('display','block');
}
if($('#'+id).css('visibility') == 'hidden') {
$('#'+id).css('visibility','visible');
}
console.log('makeVisible visibility '+$('#'+id).css('visibility'));
console.log('makeVisible display '+$('#'+id).css('display'));
}
function testPreviewImage() {
makeVisible('Preview_Div');
makeVisible('Preview_Image');
$('#Preview_Div').zIndex(16777261);
$('#Preview_Image').zIndex(16777271);
}
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-75026032351637895182015-12-22T11:02:00.000-08:002015-12-22T11:02:13.287-08:00Smooth expansion of DIV with jQuery<pre>
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 });
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-73837120912430613412015-12-15T13:20:00.003-08:002015-12-15T13:20:58.248-08:00Javascript padding<pre>
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') );
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-85929042000726237882015-11-04T11:48:00.001-08:002015-11-04T11:49:30.370-08:00GIT Merge Tool : Very Basic<pre>
#!/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
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-81716535709675525702015-11-04T11:17:00.001-08:002015-11-04T11:17:20.892-08:00MySQL Count Duplicates<pre>
#!/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;";
<h3>Useage</h3>
Table to read:
geocodes
Column to count and display:
ip
Threshold number:
2
SELECT ip FROM geocodes GROUP BY ip HAVING count(*) > 2;
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0tag:blogger.com,1999:blog-7093359319812998391.post-79719460556714273892015-11-04T10:18:00.002-08:002015-11-04T10:18:43.409-08:00GIT Checkout Loop<pre>
#!/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
</pre>this.is.lance.millerhttp://www.blogger.com/profile/09165673069819044872noreply@blogger.com0