My blog has moved.

Hello Archers !

I’ve moved my personal blog to https://crouse.us/ ……. so visit me there if you want to see what I’m up too :) But never fear, I’ll be maintaining this site as well. My current project: https://crouse.us/?p=127

test 3

try:
    from OpenSSL import SSL
except ImportError:
    SSL = None

TEST

try:
    from OpenSSL import SSL
except ImportError:
    SSL = None

VIM: Auto Indenting php/html files.

This is pretty easy...but a handy tip none the less.

VIM: AutoIndent php/html files.
:set ft=phtml
gg=G

 

Vim encryption , encrypting with vim and blowfish.

I am always on the search for the other ways to encrypt my documents on a server.
I’ve used gpg keys, gpg symetric encryption, but this one seems to fit the bill the best.
Encrypting with vim is a very painless process, it does take some setup, but not much, I promise.

The first thing I do is to setup an alias in my .bashrc file.  I alias the following :

alias vime=”vim -u ~/.vimencrypt -x″

vime is short for “vim encrypted”, at least in my head wink
WHEW! Step one finished, that was easy! ……hey, where is that “easy button” again ?

Next is to edit/and or/create a separate .vimrc just for this, and I name mine  .vimencrypt
This file will be in your home directory.  ~/.vimencrypt     
It contains the following:

source ~/.vimrc 
set nobackup 
set noswapfile 
set nowritebackup 
set cm=blowfish

Note: Since Vim 7.3 (2010-08-15)(and newer), vim can now use Blowfish encryption.
If your using an older vim — remove the “set cm=blowfish” line. It will then default to crypt for encryption.

I know, very complicated right ?  wink   That’s it folks, you are now READY to use encryption with vim!
Now, simply type “vime something.txt”  and you’re on your way.

You will then see:

Enter encryption key:

Enter same key again:

If you entered the same key twice, then you should be presented with a normal vim interface.

If you use “vime” to encrypt the document the first time, it will stay encrypted.
You can then just use vim normally to edit it endlessly (vim will ask for your password, you only have to use “vime” on the initial creation of the document), and it’s encrypted when you close it.

Now you will see VimCrypt~02……. when you cat your encrypted file, and it’s encrypted with blowfish, a MUCH MUCH stronger encryption than just “crypt” which can be broken fairly easily.

> cat test VimCrypt~02!sD~wLПYEx

I hope you have fun with vim and encryption.

 

Getting colors to work for ls and vim on Solaris 11

Just some quick notes, for myself and in case someone else ever wants this. In this day and age, I hate having to setup color on terminals ….colors make things very easy to see, quickly. So here are my notes so i don’t have to go spend time figuring it out yet again lol.

in your .profile or .bashrc
export TERM=xtermc
alias ls=”/usr/gnu/bin/ls -lah –color=auto”

in your .vimrc
syntax on
set showmatch
set bg=dark
set incsearch
set tabstop=4
set shiftwidth=4
set expandtab
set bs=2

bs=2 makes your backspace erase instead of inserting weird chars
syntax=on will enable color
the rest of it is just my personal settins in vim :)

My vmware workstation Archlinux Desktop

Host OS is Windows 7, running vmware workstation, and i’m 99% of the time in my ArchLinux virtual machine … and I love it.

Anyway, here is a screenshot of my current desktop, xfce4.

Archlinux – fixing vmware errors in log

 

 

When using open-vmware-tools, I was having the following errors reported every 30 seconds.
Below is how I fixed it.

[root@ArchLinux vmware-tools]# tail -f /var/log/messages.log
Sep 28 13:18:46 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoOSData: Error: no distro file found
Sep 28 13:18:46 localhost vmsvc[696]: [ warning] [guestinfo] Failed to get OS info.
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoReadDistroFile: Cannot work with empty file.
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoReadDistroFile: Cannot work with empty file.
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoOSData: Error: no distro file found
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [guestinfo] Failed to get OS info.
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoReadDistroFile: Cannot work with empty file.
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoReadDistroFile: Cannot work with empty file.
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [vmsvc] HostinfoOSData: Error: no distro file found
Sep 28 13:19:16 localhost vmsvc[696]: [ warning] [guestinfo] Failed to get OS info.

I simply put the following into a file located at:  /etc/release

ArchLinux Kernel 3.x

That stopped the error messages from showing up in /var/log/message.log

ArchLinux on VMware WorkStation on WinXP (Host)

I love my job, I really do.  However I hate that I have to run windows to administer unix/linux machines (just seem counter intuitive ya know ?).  Ah but in the corporate world, you have to bend to the will of the masters.  They are ok with running Linux in a vmware setting though (I know, I know, I know … ).  Enter vmware workstation.  I shelled out the money myself for vmware workstation so that I could run Linux on the desktop.

So far, it’s running very well…and I don’t have a powerhouse machine by todays standards by any means… only 2 gigs of ram in this machine.  For anyone thinking about running Arch on VmWare Workstation, I say go for it, it works great. The Arch Wiki has all the information you really need, albeit in perhaps a few places.   I tried various wm and desktop setups, settled with KDE.  I know, alot of the Arch peeps think “KDE” and snicker… but it works, and I have all the tools I need to get my work done :)  I’ve used Arch at home for about 5 years now, on servers and in a business enviroment.  I love using Arch with vmware center, in a server capacity. vmware center makes it simple to clone servers and with a few scripts, it’s great. Taking snapshots before “updating” makes updates painless and worry free, vmware workstation offers that same feature.  Cost for Vmware Workstation, $139.

Obligatory link: http://store.vmware.com/store/vmware/en_US/DisplayProductDetailsPage/ThemeID.2485600/productID.221027300/?SRC=EM_11Q3_CHRISTMASINJULY_WK_BUY&elq=e39f3a6b9a594c4ab6dc019650eda9fa   CODE: PREHOLSALE  Good through midnight Aug 4th.

My setup has dual monitors, and I have Archlinux spanning both monitors full screened, now, I can just pretend that M$ OS doesn’t really run on my machine… hey, I’m not proud.  :D

Bash – some .bashrc functions

# bu – A quick backup function

bu () { cp $1 ~/Backups/${1}-`date +%Y%m%d%H%M`.backup ; }

# hs – History Search

hs() {
history | grep ${1} | uniq –skip-fields=1 | sort -biz | uniq –skip-fields=2
}

# stock – Stock information search.

stock ()
{
lynx -dump “http://www.google.com/finance?client=ob&q=${1}” \
| sed ‘s/.*’]’//’ | perl -00ne “print if /Watch this stock/i”  \
| sed ‘s/Watch this stock//’ | sed ‘s/Disclaimer//’  \
| sed ‘/^$/d’ | sed ‘s/Currency in USD//’
}

# smallurl – create a shorter url link.

smallurl ()
{
lynx –dump http://api.fwd4.me/?url=${1}
}

# grepp – Imitate grep -p functions from Tru64 OS.

grepp ()
{
perl -00ne “print if /$1/i” < $2
}

# clock – A stupid clock function

clock ()
{
while true;do clear;echo “===========”;date +”%r”;echo “===========”;sleep 1;done
}

# dirsize – Directory contents sorted by size.

dirsize ()
{
du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep ‘^ *[0-9.]*[MG]‘ | sort -n > /tmp/list
egrep ‘^ *[0-9.]*M’ /tmp/list
egrep ‘^ *[0-9.]*G’ /tmp/list
rm /tmp/list
}

#extract – Extract most types of compressed files easily

extract ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2)   tar xvf $1     ;;
*.tar.gz)    tar xvf $1     ;;
*.bz2)       bunzip2 $1      ;;
*.rar)       unrar x $1      ;;
*.gz)        gunzip $1       ;;
*.tar)       tar xvf $1      ;;
*.tbz2)      tar xvf $1     ;;
*.tgz)       tar xvf $1     ;;
*.zip)       unzip $1        ;;
*.Z)         uncompress $1   ;;
*.7z)        7z x $1         ;;
*)           echo “‘$1′ cannot be extracted via >extract<” ;;
esac
else
echo “‘$1′ is not a valid file”
fi
}

#############################################################
########### ENCRYPTION / DECRYPTION FUNCTIONS ###############
#############################################################

dc ()
{
# Passphrase decryption program
# Created by Dave Crouse 10-20-2009
# Decrypts symetrically encrypted file to std out.
gpg –no-options –output .tempdc.txt “$1″
cat .tempdc.txt | less; rm -f .tempdc.txt
}

ec ()
{
# Passphrase encryption program
# Created by Dave Crouse 01-13-2006
# Reads input from text editor and encrypts to screen.
clear
echo ” ”
echo “**************************************************”;
echo “*         Passphrase Encryption Program          *”;
echo “**************************************************”; echo “”;
which $EDITOR &>/dev/null
if [ $? != "0" ];
then
echo “It appears that you do not have a text editor set in your
.bashrc file.”;
echo “What editor would you like to use ? ” ;
read EDITOR ; echo “”;
fi
echo “Enter the name/comment for this message :”
read comment
$EDITOR passphraseencryption
gpg –armor –comment “$comment” –no-options –output \

passphraseencryption.gpg –symmetric passphraseencryption
shred -u passphraseencryption ; clear
echo “Outputting passphrase encrypted message”; echo “” ; echo “” ;
cat passphraseencryption.gpg ; echo “” ; echo “” ;
shred -u passphraseencryption.gpg ;
read -p “Hit enter to exit” temp; clear
}

# Passhprase edit encrypted file program
# Created by Dave Crouse 11-02-2009
# Allow editing of symetrically encrypted files.
eedit ()
{
gpg –force-mdc –no-options –output .tempeec $1
emacs .tempeec
#vi .tempeec
gpg –armor –force-mdc –no-options –output $1 –symmetric .tempeec
shred -u .tempeec~ ;shred -u .tempeec ; clear
#shred -u .tempeec
}

enc ()
{
gpg –armor –no-options –output tempenc.txt –symmetric “$1″
mv tempenc.txt “$1″
}

dec ()
{
gpg $1
}

encnotes ()
{
echo “dc = decrpyt to screen”
echo “ec = encrypt to screen”
echo “enc = encrypt file to disk – overwrite existing”
echo “dec = decrypt file to disk – creates new file”
}