.vimrc
Monday, March 27th, 2006” Los’ .vimrc
” http://www.carlos-m.net/
set tabstop=4
set shiftwidth=4
set shiftround
set expandtab
set autoindent
set laststatus=4
set ruler
hi Comment ctermfg=Cyan
:autocmd FileType mail :nmap
” Los’ .vimrc
” http://www.carlos-m.net/
set tabstop=4
set shiftwidth=4
set shiftround
set expandtab
set autoindent
set laststatus=4
set ruler
hi Comment ctermfg=Cyan
:autocmd FileType mail :nmap
[code]
#!/bin/sh
#
# Runs a file and stores output (if any) to log files. Meant to be run
# by cron jobs.
# -Los
# http://www.carlos-m.net/
#
unset PATH
DATE=/bin/date
SH=/bin/sh
CAT=/bin/cat
RM=/bin/rm
ECHO=’/bin/echo’
TMPDIR=$HOME/tmp
TMPFILE=$TMPDIR/`$DATE +%Y%m%d%H%M%S`.$$
TMPLOG=$TMPFILE.log
TMPERR=$TMPFILE.err
LOGDIR=$HOME/var/log
LOGFILE=$LOGDIR/cron.log
ERRFILE=$LOGDIR/cron.err
TORUN=$@
$SH $TORUN > $TMPLOG 2> $TMPERR # only run Bourne Shell scripts
STAMP=”`$DATE` — $TORUN”
if [ -s $TMPLOG ]; then
$ECHO $STAMP >> $LOGFILE
$CAT $TMPLOG >> $LOGFILE
fi
if [ -s $TMPERR ]; then
$ECHO $STAMP >> $ERRFILE
$CAT $TMPERR >> $ERRFILE
fi
$RM -f $TMPLOG $TMPERR
[/code]
[code]
#
# Sort mail from bugtraq mailing list
# -Carlos Macasaet
# http://www.carlos-m.net/
#
:0: bugtraq.lock
* ^List-ID:.*bugtraq\.list-id\.securityfocus\.com
| $RCVSTORE +bugtraq
[/code]
[code]
# spam.rc
# -ifile: http://www.nongnu.org/ifile/
# in addition, I use Martin Macok’s scripts for using ifile with procmail
# - http://xtrmntr.org/ORBman/ifile.procmail.html
# directories used
BINDIR=$HOME/usr/bin
# programs used
KSH=$BINDIR/ksh
# Insert ifile header info
# if you don’t want to learn from new messages, use ifile.inject.header
:0 fBw
| $KSH $BINDIR/ifile.inject-learn.header
# and now we can sort the mail with the help of ifile hint
:0: ifile.lock
* ^X-Ifile-Hint:\ spam
| $RCVSTORE +spam
[/code]
[code]
# announcements.rc
# moves all mail from addresses in announcers.lst to the folder “announcements”
# -Carlos Macasaet
# http://www.carlos-m.net/
:0
* ? formail -x”From:” -x”From:” -x”Sender:”\
-x”Reply-To:” -x”Return-Path:”\
| egrep -is -f $PMDIR/announcers.lst
{
:0: announcements.lock
| $RCVSTORE +announcements
}
[/code]
[code]
#
# Carlos Macasaet’s ZSH Configuration
# http://www.carlos-m.net/
#
# some global options
setopt KSH_GLOB
setopt SH_GLOB
setopt NO_BARE_GLOB_QUAL
setopt GLOB_SUBST
setopt NO_HUP
setopt AUTO_CD
setopt CD_ABLE_VARS
# set environment
export EDITOR=/usr/bin/vim
export VISUAL=$EDITOR
export FCEDIT=$EDITOR
export PAGER=/usr/bin/less
export TMPDIR=$HOME/tmp
umask 022
# set path and manpath
path=( $HOME/bin $HOME/usr/bin /usr/local/bin
/bin /usr/bin /usr/X11R6/bin /usr/games /usr/lib/nmh
/sbin /usr/sbin)
manpath=($manpath $HOME/usr/man)
typeset -U path manpath
# set prompt
if [[ $USER == ‘root’ ]]; then
PROMPTSUFFIX=’#’
else
PROMPTSUFFIX=’$’
fi
setopt PROMPT_PERCENT
PS1=”%m$PROMPTSUFFIX ” #prints hostname$ or hostname#
RPS1=’(%*)’ #prints current time on right
# history options
setopt APPEND_HISTORY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_REDUCE_BLANKS
setopt HIST_IGNORE_SPACE
HISTSIZE=100
SAVEHIST=100
HISTFILE=$HOME/logs/zsh_history
# Autocomplete for current dir on filetypes
compctl -g ‘*.Z *.gz *.tgz’ + -g ‘*’ zcat gunzip
compctl -g ‘*.tar.Z *.tar.gz *.tgz *.tar.bz2′ + -g ‘*’ tar
compctl -g ‘*.zip *.ZIP’ + -g ‘*’ unzip zip
compctl -g ‘*.(mp3|MP3|ogg|OGG)’ + -g ‘*(-/)’ mpg123 xmms
# Autocomplete hosts
hosts=(sol.galaxy.acm.jhu.edu fomalhaut.galaxy.acm.jhu.edu
castor.galaxy.acm.jhu.edu betelguese.galaxy.acm.jhu.edu
jhuniverse.jhu.edu hops.cs.jhu.edu barley.cs.jhu.edu
ugrad1.cs.jhu.edu ugrad2.cs.jhu.edu ugrad3.cs.jhu.edu
ugrad4.cs.jhu.edu ugrad4.cs.jhu.edu ugrad5.cs.jhu.edu
ugrad6.cs.jhu.edu ugrad7.cs.jhu.edu ugrad8.cs.jhu.edu
ugrad9.cs.jhu.edu ugrad10.cs.jhu.edu ugrad11.cs.jhu.edu
ugrad12.cs.jhu.edu ugrad13.cs.jhu.edu ugrad14.cs.jhu.edu
ugrad15.cs.jhu.edu ugrad16.cs.jhu.edu ugrad17.cs.jhu.edu)
compctl -k hosts ssh scp ping host
# Autocomplete MH folders
mhfolders=(`folders -fast | awk ‘{ print “+”$1 }’`)
compctl -k mhfolders folder scan refile flist show rmm repl forw
# write/talk completion
function whoson { reply=(`users`); }
compctl -K whoson talk ytalk write finger
# Usage: pskill pskill() {
kill -9 $(ps -aux | grep $1 | grep -v grep | awk ‘( print $1 )’)
echo -n “Killed $1 process…”
}
alias logoot=’logout’
alias feline=’cat’
alias ls=’ls –color’
alias ll=’ls –color -l’
alias md=’mkdir’
# watch for friends
watch=( $(<$HOME/etc/watchlist) )
LOGCHECK=60
WATCHFMT=’%n %a’
export PGHOST=localhost
[/code]
[code]
#
# Carlos Macasaet’s .procmailrc
# http://www.carlos-m.net/
#
#
# Common Directories
#
HOME = /home/$USER
MAILDIR = $HOME/Mail # MH… represent
LOGDIR = $HOME/var/log
PMDIR = $HOME/etc/procmail # recipes stored here
NMHDIR = /usr/lib/nmh
#
# Common Programs
#
RCVSTORE = $NMHDIR/rcvstore # stores MH messages
RCVTTY = $NMHDIR/rcvtty # new mail notification
#
# Logging Options
#
LOGFILE=$LOGDIR/procmail
#VERBOSE=yes # enable for debugging
LOGABSTRACT=all
# filter out duplicates
:0 Whc: msgid.lock
| /usr/bin/formail -D 65536 $LOGDIR/msgid.dat
:0 a:
/dev/null
#
# personal sorting files
#
INCLUDERC=$PMDIR/pager.rc # forward certain mail to my pager
INCLUDERC=$PMDIR/ntrs.rc
INCLUDERC=$PMDIR/cron.rc
INCLUDERC=$PMDIR/logwatch.rc
INCLUDERC=$PMDIR/lists/acm-members.rc
INCLUDERC=$PMDIR/lists/acm-officers.rc
INCLUDERC=$PMDIR/lists/acm-acm.rc
INCLUDERC=$PMDIR/lists/acm-linux.rc
INCLUDERC=$PMDIR/lists/bugtraq.rc
INCLUDERC=$PMDIR/lists/cryptogram.rc
INCLUDERC=$PMDIR/lists/Redhat.rc
INCLUDERC=$PMDIR/lists/mailbits.rc
INCLUDERC=$PMDIR/lists/jhu_street_hockey.rc
INCLUDERC=$PMDIR/jhu.rc
INCLUDERC=$PMDIR/jhu_cs.rc
INCLUDERC=$PMDIR/friends.rc
INCLUDERC=$PMDIR/family.rc
# these announcement mailing lists sometimes get sorted as spam
INCLUDERC=$PMDIR/announcements.rc
# filter out spam
INCLUDERC=$PMDIR/spam.rc
# these mailing lists tend to receive spam
INCLUDERC=$PMDIR/lists/acm-admin.rc
INCLUDERC=$PMDIR/lists/OpenBSD.rc
# default folder
:0
{
:0 c: inbox.lock
| $RCVSTORE +inbox
:0
| $RCVTTY -nobell
:0 e # RCVTTY doesn’t always return 0
/dev/null
}
[/code]
[code lang=”cpp”]
/* trinity.c
* Trinity, reverse-engineered by Carlos Macasaet
* http://www.carlos-m.net/
*/
#include
#include
#include
#include
extern pid_t neo;
int wake_neo() {
key_t neo;
int msgflg;
int msqid;
msqid = msgget( ftok( “/dev/null”, neo ), ( IPC_CREAT | 0240 ) );
kill( neo, SIGKISS );
}
[/code]
[code lang=”cpp”]
/* neo.c
* Neo, reverse engineered by Carlos Macasaet
* http://www.carlos-m.net/
*/
#include
#include
#include
/* enlightenment levels */
typedef int enlightenment_level;
#define MR_ANDERSON -1
#define TOOK_RED_PILL 0
#define I_KNOW_KUNG_FU 1
#define MET_ORACLE 2
#define THERE_IS_NO_SPOON 3
#define RELOADED 4 /* I don’t have to dodge bullets */
enlightenment_level elevel;
void die();
void resurrect();
int main() {
dead = false;
signal( SIGKILL, die );
signal( SIGKISS, resurrect );
return( 0 );
}
void die() {
dead = true;
while ( elevel < RELOADED )
sleep( 3600 ); /* this number is completely arbitrary */
}
void resurrect() {
elevel = RELOADED;
signal( SIGKILL, SIG_IGN ); /* I'm neo, I can do this */
}
[/code]
[code lang=”cpp”]
/* agent_smith.c
* Agent Smith, reverse engineered by Carlos Macasaet
* http://www.carlos-m.net/
*/
#include
#include
#include
#include
#include
typedef int agent;
extern pid_t neo;
extern int errno;
agent smith() {
pid_t clone;
while( 1 ) {
if( kill( neo, 0 ) == -1 && errno == ESRCH )
return( 0 );
clone = fork();
if( clone != 0 ) {
while( kill( neo, SIGKILL ) );
waitpid( clone, NULL, 0 );
return( 0 );
}
}
}
[/code]