$('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) + '...'); } });
Thursday, December 29, 2016
No width parameter for SPAN tags, so limit width with javascript
Monday, December 19, 2016
Time seconds increment on class of elements
function updateAge() { $('.age').each(function(){ var age=$(this).text(); age++; $(this).text(age); }) } $(document).ready(function(){ console.log('document ready'); setInterval(updateAge, 1000); })
Thursday, December 1, 2016
Debian Package Creator and Installer
I made this for a particular "product", change the directory variables and final archived .deb filename per your needs.
debian.build.install.sh
#!/usr/bin/env bash
# this.is.lance.miller@gmail.com
clear;
basedir='/home/';
microdir=$basedir"micro/";
chmod 0775 $microdir'DEBIAN/postinst';
myfile=$microdir'DEBIAN/control';
echo $myfile;
myversion=`cat $myfile | grep Version | cut -d' ' -f2`;
echo $myfile' declares version '$myversion;
dpkg-deb --build $microdir;
ls -l $basedir*.deb;
sleep 5;
dpkg -i $basedir'micro.deb';
ls -l $basedir*.deb;
newfile='our_product_name_'$myversion'_all.deb';
echo 'creating this versioned deb archive: '$newfile;
mv $basedir'micro.deb' $basedir$newfile;
ls -l $basedir*.deb;
debian.build.install.sh
#!/usr/bin/env bash
# this.is.lance.miller@gmail.com
clear;
basedir='/home/';
microdir=$basedir"micro/";
chmod 0775 $microdir'DEBIAN/postinst';
myfile=$microdir'DEBIAN/control';
echo $myfile;
myversion=`cat $myfile | grep Version | cut -d' ' -f2`;
echo $myfile' declares version '$myversion;
dpkg-deb --build $microdir;
ls -l $basedir*.deb;
sleep 5;
dpkg -i $basedir'micro.deb';
ls -l $basedir*.deb;
newfile='our_product_name_'$myversion'_all.deb';
echo 'creating this versioned deb archive: '$newfile;
mv $basedir'micro.deb' $basedir$newfile;
ls -l $basedir*.deb;
Monday, November 14, 2016
Friday, October 28, 2016
CPU Analysis PHP
<?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; } ?>
Thursday, October 6, 2016
Tuesday, September 6, 2016
Perform post install scripting for Debian packages. Especially useful for setting file permissions
There 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 DEBIAN/postinst file.
The files that configure and command the Debian packaging and subsequent installation all reside in a directory named DEBIAN. Here are all the files I include in my DEBIAN directory:
Below are the contents of the files (contents changed to protect the proprietary)
cd /home/
dpkg-deb --build FOOBAR
The above dpkg-deb would create a file named FOOBAR.deb
To install the FOOBAR.deb package on a machine, you would run:
dpkg -i FOOBAR.deb
A parting note. I would rename my FOOBAR.deb to FOOBAR.1.0.40.deb to make evident the version number of the package.
The files that configure and command the Debian packaging and subsequent installation all reside in a directory named DEBIAN. Here are all the files I include in my DEBIAN directory:
- DEBIAN/conffiles
- DEBIAN/control
- DEBIAN/postinst
- DEBIAN/rules
Below are the contents of the files (contents changed to protect the proprietary)
-
DEBIAN/conffiles
...blank...
-
DEBIAN/control
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.
-
DEBIAN/postinst
#!/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"
-
DEBIAN/rules
...blank...
General File Structure
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.- /home/FOOBAR/DEBIAN
- /home/FOOBAR/etc
- /home/FOOBAR/var
cd /home/
dpkg-deb --build FOOBAR
The above dpkg-deb would create a file named FOOBAR.deb
To install the FOOBAR.deb package on a machine, you would run:
dpkg -i FOOBAR.deb
A parting note. I would rename my FOOBAR.deb to FOOBAR.1.0.40.deb to make evident the version number of the package.
Wednesday, August 10, 2016
jQuery Dialog zIndex
$( ".selector" ).dialog();
$( ".selector" ).css("background-color", "red");
console.log( 'z-index ' + $( ".selector" ).zIndex() );
Tuesday, April 5, 2016
Make Sure Element is Visible and Displayed : Javascript
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); }
Subscribe to:
Posts (Atom)