Check These Out
I often use "vim -p" to open in tabs rather than buffers.
The `-q' arg forces tail to not output the name of the current file
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
% cat ph-vmstat.awk
# Return human readable numbers
function hrnum(a) {
b = a ;
if (a > 1000000) { b = sprintf("%2.2fM", a/1000000) ; }
else if (a > 1000) { b = sprintf("%2.2fK", a/1000) ; }
return(b) ;
}
# Return human readable storage
function hrstorage(a) {
b = a ;
if (a > 1024000) { b = sprintf("%2.2fG", a/1024/1024) ; }
else if (a > 1024) { b = sprintf("%2.2fM", a/1024) ; }
return(b) ;
}
OFS=" " ;
$1 !~ /[0-9].*/ {print}
$1 ~ /[0-9].*/ {
$4 = hrstorage($4) ;
$5 = hrstorage($5) ;
$9 = hrnum($9) ;
$10 = hrnum($10) ;
$17 = hrnum($17) ;
$18 = hrnum($18) ;
$19 = hrnum($19) ;
print ;
}
An old USB A/B cable is all you need to make your own Smart Home hardware!
Cut off and discard the B-portion of the USB cable. On the A side, connect the RED (+) and WHITE (D-) wires via a 1 kiloohm resistor.
$Picture:
http://imgur.com/dJGVlAU
Now plug the cable into a USB port on your Linux computer. Your hardware is ready!
Run the above command after changing variable mysms to your personal email-to-SMS gateway info as required by your cellular service provider.
The command uses the amazing usbmon tool (see link below) to detect the cable.
For the curious, to view the raw usbmon output, run this command: (Also see the sample output)
$usbmon -i usb0
How does it work? When the red and white wires are connected (via the 1 kiloohm resistor) the USB hardwere is tricked into thinking that a new USB device is trying to start up.
We then use the usbmon utility to capture the host USB events as it tries to talk to the cable.
The expect utility watches the usbmon stream and waits for the disconnect text "-2:128" before sending the SMS message.
Finally, the sendmail tool is used to email the SMS message to your smartphone via your cellular provider's SMS-to-email gateway.
As a result, when the electrical connection between the red and white wire is interrupted, or the USB cable is unplugged from your computer, you get an SMS notification of the disconnect event on your smartphone.
Could this be the cheapest smart home gadget ever? What are YOU going to sense with it?
Please let me know in the comments and please don't forget to click it up!
$
$Links:
$
http://www.linuxcertif.com/man/8/usbmon/
http://en.wikipedia.org/wiki/USB#Pinouts
http://imgur.com/dJGVlAU
Using this command you can track a moment when usb device was attached.
If you need to xdebug a remote php application, which is behind a firewall, and you have an ssh daemon running on that machine. you can redirect port 9000 on that machine over to your local machine from which you run your xdebug client (I am using phpStorm)
So, run this command on your local machine and start your local xdebug client, to start debugging.
more info:
http://code.google.com/p/spectator/wiki/Installing
create an iso from your cd/dvd-rom device . You need to umount /dev/cdrom
before using the cli