ack = a better grep "ignores most of the crap you don't want to search"

If you've ever use grep to search a svn directory you'll know the issues re .svn folders, easiest solution is to use ack from http://betterthangrep.com/

Why: 
- refer point 5 below "ack ignores most of the crap you don't want to search" 

How to install:

- "curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3"

Top reasons to use ack instead of grep.

  • It's blazingly fast because it only searches the stuff you want searched.
  • ack is pure Perl, so it runs on Windows just fine.
  • The standalone version uses no non-standard modules, so you can put it in your ~/bin without fear.
  • Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories.
    • Which would you rather type?
    • $ grep pattern $(find . -type f | grep -v '\.svn')
    • $ ack pattern
  • ack ignores most of the crap you don't want to search
    • VCS directories
    • blib, the Perl build directory
    • backup files like foo~ and #foo#
    • binary files, core dumps, etc
  • Ignoring .svn directories means that ack is faster than grep for searching through trees
  • Lets you specify file types to search, as in --perl or --nohtml
    • Which would you rather type?
    • $ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn)
    • $ ack --perl pattern
    • Note that ack's --perl also checks the shebang lines of files without suffixes, which the find command will not
  • File-filtering capabilities usable without searching with ack -f. This lets you create lists of files of a given type
    • $ ack -f --perl > all-perl-files
  • Color highlighting of search results
enjoy

.htaccess and Apache VirtualDocumentRoot

If you using VirtualDocumentRoot in your Apache set you need to make a minor change to your .htaccess rewrites to make them work 
- just add a slash before the url and it'll work 

refer below

from: 
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)$ index.php?module=$1&view=$2 [L]

to: 
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/?([a-zA-Z0-9_]+)-([a-zA-Z0-9_]+)$ /index.php?module=$1&view=$2 [L]

Connecting to an OpenVPN (untangle) network from linux: How to

Just connected to an OpenVPN (untangle) network from linux and it was super easy (way easier than a normal cisco vpn anyway)

All you have to do is:

install the openvpn client for your distro and  get your config files from the network admin
-- the files should look somethign like below
--- replace 'xyz-co' with and 'you' with your username

xyz-co.conf
xyz-co.ovpn
untangle-vpn/
untangle-vpn/xyz-co-ca.crt
untangle-vpn/xyz-co-you.crt
untangle-vpn/xyz-co-you.key

copy the above files into your /etc/openvpn directory

then connect using the below command

sudo openvpn /etc/openvpn/xyz-co.conf

all done - too easy

shell script to check if ExLibris Aleph is running OK

If you have to admin Aleph from ExLibris you may be wondering why there is minimal tools to help you make sure its all running ok

Below is a simple shell script that checks various 'ue_' process (PC server, publishing, etc..) and emails if they are down

Add this to your crontab to run each 15 minutes or so

Note:
- replace the email address with your email address
- replace LIB with your 3 character library code
- add/remove ue_ sections as you need

#!/bin/bash

SUBJECT='Aleph: alert'
TO='youremailaddress@you.com'

if [[ $ps =~ "ue_21_a_LIB30" ]]
then
        echo LIB30 ue_21 all OK
else
        message="LIB30 ue_21 is not running
"
fi

if [[ $ps =~ "ue_21_a_LIB01" ]]
then
        echo LIB01 ue_21 all OK
else
        message="${message}
LIB01 ue_21 is not running"
fi


if [[ $ps =~ "ue_08_a_LIB01" ]]
then
        echo LIB01 ue_08 all OK
else
        message="${message}
LIB01 ue_08 is not running"
fi

if [[ $ps =~ "ue_08_a_LIB10" ]]
then
        echo LIB10 ue_08  all OK
else
        message="${message}
LIB10 ue_08 is not running"
fi

if [[ $ps =~ "ue_06_a_LIB50" ]]
then
        echo LIB50 ue_06  all OK
else
        message="${message}
LIB50 ue_06 is not running"
fi

if [[ $ps =~ "-d_/exlibris/aleph/u20_1/alephe/apache" ]]
then
        echo Apache looks OK
else
        message="${message}
Apache doesn't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/pc_server" ]]
then
        echo PC_Server looks  all OK
else
        message="${message}
PC_Server doen't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/www_server" ]]
then
        echo www_server looks all OK
else
        message="${message}
wwww_server doens't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/sip2_server" ]]
then
        echo SIP2 looks OK
else
        message="${message}
SIP2 doesn't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/oclc_server" ]]
then
        echo OCLC server looks OK
else
        message="${message}
OCLC server doesn't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/ncip_server" ]]
then
        echo NCIP server looks OK
else
        message="${message}
NCIP server doesn't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/sru_server" ]]
then
        echo SRU server looks OK
else
        message="${message}
SRU server doesn't look to be running"
fi

if [[ $ps =~ "-f_/exlibris/aleph/a20_1/aleph/proc/z39_server" ]]
then
        echo Z39 server looks OK
else
        message="${message}
Z39 server doesn't look to be running"
fi

if [[ $ps =~ "ue_01_a_LIB01.a20_1" ]]
then
        echo LIB01 indexing looks OK
else
        message="${message}
LIB01 indexing doesn't look to be running"
fi

if [[ $ps =~ "ue_01_a_LIB10.a20_1" ]]
then
        echo LIB10 indexing looks OK
else
        message="${message}
LIB10 indexing doesn't look to be running"
fi

if [[ $ps =~ "ue_01_a_LIB30.a20_1" ]]
then
        echo LIB30 indexing looks OK
else
        message="${message}
LIB30 indexing doesn't look to be running"
fi

if [[ -n $message ]]
then
        echo $message
        /bin/mail -s "$SUBJECT" "$TO" <<EOM
        $message
EOM
else
        echo "No email needs to be sent - all working OK"
fi

GNU Screen: how to bind Alt + Left Arrow & Alt + Right Arrow to prev/next

for a simple way to switch between GNU Screen 'screens' using Alt +
Arrow key, use the below key bindings in your .screenrc file

 
# Arrow keys to switch terminals (only works with X) 
# Alt + left 
bindkey ^[[1;3D prev 
# Alt + right 
bindkey ^[[1;3C next 

note:
- not use Ctrl + Alt + Left/Rigth Arrow as its used by GNOME to swap
virtual desktops
- nor firefox style as its used by GNOME Terminal for switching its tabs
- to find out what Alt/Fn/Ctrl characters equal what just execute cat
and start typing

simple bash regex example

since versions 3 bash has included a simple regular expression operation "=~"
below is a simple example of it in action

######### example code #########
#search for a process and print specific section
ps=`ps aux | grep stuff | awk '{print $12 "_" $13}' `
...
#do some stuff
if [[ $ps =~ "something im looking for" ]]; then
       #do what you want
fi
##############################

simple gpg password protected file encryption example

Creating the file:

vi passwords.txt

Encrypt the file:

gpg -c -a passwords.txt

and enter a password when prompted

now delete the original plain text file

rm passwords.txt

Viewing the file:

to view the file with less
gpg -d passwords.txt.asc | less

and enter the password when prompted

Editing the file:

To edit the password file decrypt the file to plain txt
gpg passwords.txt.asc

this will place a plain text file call passwords.txt in the current directory