Extracting Email Addresses From File (via CLI)
perl -n -e 'if (/\s*([\w._-]+@[\w._-]+)\s*.*/) { print "$1\n"; } elsif (grep(/@/,$_)) { print "MISSED $_"; }' .delmenow
Color Coder to the Rescue ….
What would code be without with a little color: CodeColorer
Email makes a GREAT Backup
mutt myName@truepath.wpengine.com $(set *.cgi; echo ${*/#/-a}) -s "File Backups" < /dev/null
Who Loves You More?
Neat Chrome plugin (Graph Your Inbox) that will allow you to run charts on your email! In this run I look at to/from Amy (my wife)
GMail Icon Cheat-Sheet
Here’s a little sheet that I created to make sense out of all the icons I am putting on my emails. Drop me a line if you would like the Ai file to rework.
Stepping Through Traces in an Eagle Board
Found this great trick (script) on this board: http://www.element-14.com/community/message/13435
Turin Netcool Lookup Table Via Ops Guide
Wrote a script to pull in the (highest) default values for all traps found within the Node Operations and Maintenance Guide
Anything not (easily) found from the doc was kept at it’s default value (1,0,0)
Full sev lookup table can be found here: turin-TURIN-MIB.sev.snmptrap.lookup
(..snip..)
SNMPTRAP-turin-TURIN-MIB-aco-trap 2 13 0
SNMPTRAP-turin-TURIN-MIB-admintask-trap 2 13 0
SNMPTRAP-turin-TURIN-MIB-ais-l-trap 5 1 0
SNMPTRAP-turin-TURIN-MIB-ais-p-trap 5 1 0
SNMPTRAP-turin-TURIN-MIB-ais-s-trap 2 1 0
SNMPTRAP-turin-TURIN-MIB-ais-vc-trap 5 1 0
SNMPTRAP-turin-TURIN-MIB-ais-v-trap 5 1 0
(..snip..)
Finding Large Emails in Gmail via FindBigMail
Found a great site “http://www.findbigmail.com” that sorts your largest emails in a separate folder to explore and delete. This is a free service, all online!
op5 Nagvis Root Node
Nagvis wants to use by default localhost for it’s root within the auto map.
Go into the file
/opt/monitor/op5/nagvis/etc/nagvis.ini.php
and edit the line with the name of your op5 host
defaultroot=”myprod-op5″
Prototype your microcontroller project with Toolduino
http://nootropicdesign.com/toolduino/
Switch Da’ Pins (Faster!)
Amazing CNC Build
http://mtm.cba.mit.edu/machines/mtm_az/index.html
Android Meets Arduino
http://www.amarino-toolkit.net/index.php
Edit a google doc with vim
CLI users rejoice!
$ google docs edit –title “To-Do List” –editor vim
Full docs with examples can be found at:
Very Fun Virtual Java Circuit
http://www.falstad.com/circuit/
Dropbox on Unix == Great SVN !!
I’ve been looking for a way I can (securely) sync a (local) SVN repo for my many projects. In comes Dropbox with Win/Linux support!
Here’s the CLI install for Linux:
http://wiki.dropbox.com/TipsAndTricks/TextBasedLinuxInstall
Define Arduino…
Define Arduino: http://en.wikipedia.org/wiki/Arduino
In short, it’s an opensource circuit layout with an Atmel chip. Easy to program using a high-level arduino language using sketches (software is free) which looks a lot like Wiring/Processing/etc. It’s setup to program/burn from a standard USB port. There are built in LEDs and the layout allows for *shields* to be mounted on top. A typical shield would use some ports (pass others through) and give your Arduino/circuit new functions like sensors, motor control, etc.
There are TONs of resources out there. Easy examples, walk-throughs, etc.
- http://arduino.cc/
- http://fritzing.org/projects/
- http://www.adafruit.com
- http://www.sparkfun.com/commerce/categories.php?c=103
- http://blog.makezine.com/archive/arduino/
- https://www.makershed.com/collections/books-magazines
- http://www.instructables.com/id/The-Ardweeny-the-little-friend-of-the-Arduino-an/
Just a few files please….
Simple way to grab some files out of a RPM
$ rpm2cpio php-5.1.4-1.esp1.x86_64.rpm | cpio -idmv
watch Command
While researching some issues I’m having with iostat, I found an interesting command called ‘watch’
Instead of running the usual command (up arrow, return, up arrow, return)
[root@nms-tpt-1 ~]# cat /proc/diskstats | grep “sda ”
8 0 sda 42113 18004 1395004 80723 18000492 45624354 508998694 7650613 0 4953776 7730941
[root@nms-tpt-1 ~]# cat /proc/diskstats | grep “sda ”
8 0 sda 42113 18004 1395004 80723 18000492 45624354 508998694 7650613 0 4953776 7730941
[root@nms-tpt-1 ~]# cat /proc/diskstats | grep “sda ”
8 0 sda 42113 18004 1395004 80723 18000497 45624372 508998878 7650614 0 4953777 7730942
…or writing a never ending while loop. You can issue “watch” which will run your program (clearing the screen each time) and even show you (highlighted) the diffs between each call … pretty nice:
[root@nms-tpt-1 ~]# watch -n 1 -d ‘cat /proc/diskstats | grep “sda “‘
would show in a new screen:
Every 1.0s: cat /proc/diskstats | grep “sda ” Mon Dec 7 09:42:18 2009
<p style="box-sizing: inherit; border: 0px; font-size: 16px; font-style: normal; font-weight: 400; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; color: rgb(47, 47, 46); font-family: Lato, sans-serif; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial;">8 0 sda 42113 18004 1395004 80723 18000540 45624456 508999894 7650638 0 4953787 7730966
Adding Perf Data (which op5 will auto graph!) w/NRPE
The NRPE command for checking procs simply returnsPROCS OK: 112 processes
PROCS OK: 112 processes
Using some code off the net, we can create a little wrapper to print the Nagios Performance Data way (if that’s even a sentence)
[root@op5 op5_custom_plugins]# cat /opt/local/tpt/op5_custom_plugins/check_procs_wp.sh
#!/bin/bash
LINE=`/opt/plugins/check_procs $*`
RC=$?
COUNT=`echo $LINE | awk ‘{print $3}’`
echo $LINE \| procs=$COUNT
exit $RC
[root@op5 op5_custom_plugins]#
Running this by hand gives us:
[root@op5 op5_custom_plugins]# /opt/local/tpt/op5_custom_plugins/check_procs_wp.sh
PROCS OK: 114 processes | procs=114
[root@op5 op5_custom_plugins]#
Create a newline in the config file
[root@op5 op5_custom_plugins]# cat /etc/nrpe.d/op5_commands.cfg | grep total_procs
command[total_procs]=/opt/plugins/check_procs -w 150 -c 200
command[total_procs_wp]=/opt/local/tpt/op5_custom_plugins/check_procs_wp.sh -w 150 -c 200
[root@op5 op5_custom_plugins]#
Using the name “total_procs_wp” in the nrpe call, we’ll get the total procs running AND with op5, it’ll start auto graphing that for us.
Code walking….
I’ve been working on someone elses code that calls external programs one after another… I found this great tip in VIM that allows you to open the file thats under the cursor
gf open in the same window (“goto file”)
and to return
CTRL-o (that’s Ohhh)
Full Details: http://vim.wikia.com/wiki/Open_file_under_cursor
tgimboej – Samsung Box …. in TruePath style
Wget NASA Photos
Here’s a great wget trick to download all the Photos of the Day from NASA. There’s some great switches in there I never new existed.
wget -r -l2 -t1 -nd -N -np -w2 -A.jpg -erobots=off http://apod.nasa.gov/apod/archivepix.html
(source lifehacker)
Removing Stale RRD Files
I’ve found that when dealing with rrdfiles, they can show the wrong lastmodified time. This means if I go with the usual: delete all files that haven’t been modified within say 2 days, I could be deleting some GOOD rrd files…
Here’s my solution. Use rrdtool lastupdated to spit out epoch time of last updated and anything that’s older than 2 days we’ll delete:
for myfile in *.rrd
do
#rrdtool lastupdate $myfile | tail -1 | awk -F: ‘{if ($1 < systime()-172800) print strftime(“%c”,$1)}’;
RETURN=`rrdtool lastupdate $myfile | tail -1 | awk -F: ‘{if ($1 < systime()-172800) print 0}’`
if [ “$RETURN” == 0 ]; then
echo “Deleting $myfile”
# uncomment to really remove file
#/bin/rm -f $myfile
else
echo “Skipping File $myfile”
fi
done
Perl Pretty Print Hash Data::Dumper
print Data::Dumper->new([\%hArray],[qw(hArray)])->Indent(3)->Quotekeys(0)->Dump;
Internet to the rescue! Only a 1000 diff options to Data::Dumper but this little one liner does the trick!
Project HiJack
Hijacking power and bandwidth from the mobile phone’s audio interface.
Creating a cubic-inch peripheral sensor ecosystem for the mobile phone.
http://www.eecs.umich.edu/~prabal/projects/hijack/
XBee Internet Gateway
The XBee Internet Gateway gives any device the ability to connect seamlessly to the Internet by mirroring the interactions humans have with web browsers.
Grab Excel WorkSheet Names Into 1 Sheet
Here’s a nice macro that will combine all your worksheet names into a new sheet.
Some more good excel tips here too plus a cool util called RDBMerge!
Finding Zero Graph Hosts in Cacti
Sometimes when we do all this nice trimming of graphs/etc we trim a host down to having NO graphs at all. these need to be looked at (either remove the host or add some interfaces to be graphed).
Here’s some SQL that will give a list of hosts that don’t have any graphs:
SELECT id, description, hostname, notes
FROM host
WHERE host.id NOT IN (
SELECT host_id
FROM graph_local
WHERE host.id = graph_local.host_id)
Vim: How To Fold Functions
The is really a tip on how to fold any code block including functions. Navigate your cursor somewhere inside of the code block you want to fold, make sure you are in command/normal mode (press escape if you need to) then type zfa}
To save your folds between vim sessions you need to issue the command :mkview otherwise when you close vim your folds will be lost (your folds, not your code). To make life easier on you, you can have your folds automatically saved for you by adding this to your .vimrc file
au BufWinLeave * mkview
au BufWinEnter * silent loadview
Source: Refreshingly Blue » Blog Archive » Vim: How To Fold Functions.
Arduino Tutorials
Here’s a great site with PLENTY of Arduino examples and tutorials: Arduino Tutorials « t r o n i x s t u f f.
High Low data values
Great tutorial on showing the diff values between High Low data values
Boot your PC with the Arduino using the Wake on Lan command
Boot your PC with the Arduino using the Wake on Lan command | Dangerous Prototypes.
CircuitLab | sketch, simulate, and share your circuits
CircuitLab | sketch, simulate, and share your circuits.
Tar Extract a Single File(s) From a Large Tarball
$ tar -ztvf config.tar.gz
$ tar -zxvf config.tar.gz etc/default/sysstat
$ tar -xvf {tarball.tar} {path/to/file}
Git tricks, tips and workflows
Great site that lists a bunch of Git tricks, tips and workflows
VIM Macros
High Level Steps to Record and Play inside Vim
- Start recording by pressing q, followed by a lower case character to name the macro
- Perform any typical editing, actions inside Vim editor, which will be recorded
- Stop recording by pressing q
- Play the recorded macro by pressing @ followed by the macro name
- To repeat macros multiple times, press : NN @ macro name. NN is a number
Perl Executing External Commands
There are many ways to execute external commands from Perl. The most commons are:
- system function
- exec function
- backticks (“) operator
- open function
All of these methods have different behaviour, so you should choose which one to use depending of your particular need. In brief, these are the recommendations:
method | use if … |
system() | you want to execute a command and don’t want to capture its output |
exec | you don’t want to return to the calling perl script |
backticks | you want to capture the output of the command |
open | you want to pipe the command (as input or output) to your script |
No Ding (Bell)
It’s the little things that help …. turning off the auto-complete bell at night (forever!)
in /etc/inputrc
add the line: set bell-style none
Git Diff with Vimdiff « Jonathan’s Techno-tales
Using Git Diff with Vimdiff
mtop – MySQL Monitoring Tool
Here’s a cool “top” like tool for MySQL Monitoring
Compatibility Master Table
Wondering what works with what browsers? Have a look at the Compatibility Master Table
Doodle: easy scheduling
Getting people in 1 room or on 1 call can be tough! Here’s a free online tool to make for some easy scheduling.
So you got a Raspberry Pi: now what?
Great walkthrough on using your new Raspberry Pi — (orig from Engadget)
Video style tutorials
Watch people code (videos) and learn HTML5, CSS3, Javascript ( TheCodePlayer )
Free Partition Magic
Need to expand your VM virtual disks? This (free) tool couldn’t be easier! Best Free Partition Manager – EaseUS Partition Master Home Edition. Wow this sounds like a sales spam ad but its not… really :)
You gotta Branch-per-Feature!
Great article on ways to work with GIT: Branch-per-Feature – Adam Dymitruk
Git Branching Model
Great article on using a successful Git branching model.
Test DB … Create!
Neat little online tool to create (and download) data for your test DB. You can even download in SQL
VIM Trick: norm
Needed to add something to the end of EVERY line that matched… found out norm is the answer
:g/.*AlertGroup = ".*[^"]$/norm A"
Here’s a nice write-up: http://briancarper.net/blog/165/vim-g-norm
Text to columns in Excel
Tip on using return with text to columns for your data: choose delimited, select other, put the cursor inthe box and hold down alt while typing 010 on the numpad, release alt
Send Files Dropbox Without Using Dropbox
We’re always using dropbox here.
Here’s some way to use dropbox Without Using Dropbox.
Vimdiff Tutorial | Core Dump
Quicky on Vimdiff
git reflog … your safety net
Even with the best repo you need some saving grace. Many thanks to git’s reflog
LifeHacker Picks Best System Rescue Disc
We’re all forced to use windows at some point. When things won’t boot you need a bootCD. Looks like the most popular System Rescue Disc goes to Hirens BootCD.
Raspberry Pi and Breadboard Leaf
Dr. Monks DIY Electronics Blog: Raspberry Pi and Breadboard Raspberry Leaf.
OAM Performance Monitoring
Good video on OAM Perf Mon which our LMS software rocks at!
Using pv to limit pipes
While looking to tame down our tar backups, I found a good write up on using pv tool to throttle bandwidth of a pipe
tar cf - mydata | pv -L 1m >/media/MYDISK/backup.tar
Grabbed and installed from yum but this looks to the be the source
JSON Data
For those that work with JSON data … this online tool is very helpful!
http://www.jsoneditoronline.org/
op5 Management Packs
op5’s new Management Packs. Even easier to setup monitoring across your devices!
Another Fun Marketing Cartoon
Everyone Loves Candy!
Experimenting with custom printed M&Ms. See if your next order includes a pack of these!