Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Marten Veldthuis http://www.textdrive.com

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Vim config

" An example for a vimrc file.
"
" Maintainer:      Bram Moolenaar 
" Last change:       2002 Sep 19
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"              for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"            for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

set nobackup              " don't keep a backup file
set history=50          " keep 50 lines of command line history
set ruler         " show the cursor position all the time
set showcmd             " display incomplete commands
set incsearch             " do incremental searching

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

color elflord


" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \   exe "normal g`\"" |
    \ endif

  augroup END

else

"  set autoindent          " always set autoindenting on

endif " has("autocmd")

set ts=4
set sw=4
set autowrite
"set textwidth=74
set number

Example lighttpd config for a Rails app

I thought I'd share my lighttpd config file. My main application driving http://www.standardbehaviour.com is at ~/web/, which means the dispatch.fcgi file is in ~/web/public/dispatch.fcgi.

# Modules to load {{{1
server.modules              = (
                                "mod_rewrite",
                                "mod_redirect",
                                "mod_access",
                                "mod_fastcgi",
                                "mod_compress",
                                "mod_accesslog" )
# }}}1

# files to check for if .../ is requested

# Mimetype mapping {{{1
mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "audio/x-wav",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
 )
# }}}

server.document-root       = "/home/mveldthuis/web/public/"
server.bind                = "standardbehaviour.com"
server.port                = 8534
server.pid-file            = "/home/mveldthuis/var/run/lighttpd.pid"
server.tag                 = "lighttpd"
server.username            = "mveldthuis"
server.groupname           = "mveldthuis"
accesslog.filename         = "/home/mveldthuis/var/log/lighttpd.access.log"
server.errorlog            = "/home/mveldthuis/var/log/lighttpd.error.log"
server.indexfiles          = ( "index.php", "index.html",
                               "index.htm", "default.htm" )
url.access-deny            = ( "~", ".inc" )

# Main site, I want this on www or no www, and on .com, .net and .org
$HTTP["host"] =~ "(www\.)?standardbehaviour\.(com|net|org)" {
  server.document-root     = "/home/mveldthuis/web/public/"
  server.error-handler-404 = "/dispatch.fcgi"
  fastcgi.server= (".fcgi" =>
    ("StandardBehaviour.com" =>
      (
        "socket" => "/home/mveldthuis/var/lighttpd-fcgi.socket",
        "bin-path" => "/home/mveldthuis/web/public/dispatch.fcgi",
        "bin-environment" => ("RAILS_ENV" => "production" ),
        "max-load-per-proc" => 4,
        "min-procs" => 1,
        "max-procs" => 2,
        "idle-timeout" => 60
      )
    )
  )
}

# This is the images subdomain, serves mainly just the files,
# but I have fileNice there which is PHP.
$HTTP["host"] =~ "images\.standardbehaviour\.(com|net|org)" {
  server.document-root     = "/home/mveldthuis/subdomains/images/"
  server.dir-listing       = "enable"
  server.indexfiles        = ("index.php")
  server.error-handler-404 = "/index.php"
  fastcgi.server = (".php" =>
    ("ImagesStandardBehaviour" =>
      ("socket" => "/home/mveldthuis/var/lighttpd-images-php.socket",
       "bin-path" => "/usr/local/www/cgi-bin/php5-fcgi",
       "bin-environment" =>
         ("PHP_FCGI_CHILDREN" => "1",
          "PHP_FCGI_MAX_REQUESTS" => "2500"
         )
      )
    )
  )
}

# Pretty much the same as images, but then for experiments.
$HTTP["host"] =~ "experiments\.standardbehaviour\.(com|net|org)" {
  server.document-root          = "/home/mveldthuis/subdomains/experiments/"
  server.dir-listing = "enable"
  server.indexfiles  = ("index.php", "index.html")
  fastcgi.server = (".php" =>
    ("ImagesStandardBehaviour" =>
      ("socket" => "/home/mveldthuis/var/lighttpd-images-php.socket",
       "bin-path" => "/usr/local/www/cgi-bin/php5-fcgi",
       "bin-environment" =>
         ("PHP_FCGI_CHILDREN" => "1",
          "PHP_FCGI_MAX_REQUESTS" => "2500"
         )
      )
    )
  )
}


Hope this helps anyone.

Marten's .zshrc

export PATH=$PATH:/usr/local/bin:/opt/local/bin

# Aliases and functions {{{1

# Xterm resizing-fu. Note that these are utf-8 fonts
alias hide='echo -en "\033]50;nil2\007"'
alias tiny='echo -en "\033]50;-misc-fixed-medium-r-normal--8-80-75-75-c-50-iso10646-1\007"'
alias small='echo -en "\033]50;6x10\007"'
alias default='echo -e "\033]50;-misc-fixed-medium-r-semicondensed--13-*-*-*-*-*-iso10646-1\007"'
alias medium='echo -en "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso10646-1\007"'
alias large='echo -en "\033]50;-misc-fixed-medium-*-*-*-15-*-*-*-*-*-iso10646-1\007"'
# This is a large font that has a corresponding double-width font for 
# CJK and other characters, useful for full-on utf-8 goodness.
alias larger='echo -en "\033]50;-misc-fixed-medium-r-normal--18-*-*-*-*-*-iso10646-1\007"'
alias huge='echo -en "\033]50;-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso10646-1\007"'
alias normal=default
if [ "$TERM" = "xterm" ] && [ "$LINES" -ge 50 ] && [ "$COLUMNS" -ge 100 ]; then
        large
fi

# Allow for use of =command to test for commands below, w/o error messages.
setopt nonomatch

alias df='df -h -x none'
alias free='free -m'
alias cls=clear
# Do we have GNU ls of a new enough version for color?
(ls --help 2>/dev/null |grep -- --color=) >/dev/null && \
        alias ls='ls -b -CF --color=auto'
alias l=ls
alias dir='ls -lha'
alias du='du -h'
alias f=finger
alias edit=$EDITOR
alias e=$EDITOR
alias ftp=lftp
alias md=mkdir
# Put alive hosts at the bottom.
alias ruptime='ruptime -rt'
alias rd=rmdir
alias k=killall
alias mtr='mtr --curses'
[[ -x =reportbug ]] && alias bug='reportbug -b --no-check-available -x -M --mode=expert'
alias slrn='slrn -n'
alias menu=pdmenu
alias xchat='xchat -C'
alias stardate='date "+%y%m.%d/%H%M"'
if [[ -x =ytalk ]]; then
        alias ytalk='ytalk -x'
        alias talk=ytalk
fi
# Finger macros alias.
if [[ -e /proc/acpi ]]; then
        alias apm=acpi
fi
# I don't like the zsh builtin time command.
[[ -x =time ]] && alias time='command time'
alias dch="dch -p -D UNRELEASED"
alias bc='bc -l -q'
alias ytalk='ytalk -x'

# QX3 toy microscope
alias bottomlight="echo bottomlight: on >!/proc/cpia/video0; echo toplight: off >!/proc/cpia/video0"
alias toplight="echo toplight: on >!/proc/cpia/video0; echo bottomlight: ff >!/proc/cpia/video0";
alias nolight="echo toplight: off >!/proc/cpia/video0; echo bottomlight: off >!/proc/cpia/video0"
alias bothlights="echo toplight: on >!/proc/cpia/video0; echo bottomlight: on >!/proc/cpia/video0"

# Longrun stuff.
alias slow='longrun -f economy; longrun -s 0 50; longrun -p'
alias fast='longrun -f performance; longrun -s 0 100; longrun -p'
# useful for games with auto rate limiting
alias full='longrun -f performance; longrun -s 100 100; longrun -p'

# Stuff that I just don't want to run, because it sucks.
alias eview='echo "eview? No"'
# Argh, mf is so bloody annoying.
alias mf='echo "Er, if you want mv, type mv; if you want mf, I pity you."'

# Calculator
calc () { echo $* |bc -l }

# This fingers @host.
@ () { finger @$1 }


# Not for root.
if [[ "$USER" != root ]]; then
        alias cardctl='sudo cardctl'
        alias fetchnews='sudo fetchnews'
fi

# I don't like this for interactive use.
setopt nomatch

# Prompt {{{1

coreprompt="%n@%m"

# The extraprompt thing can be set when I have chroots and I want to keep
# track of which I am in.
if [ ! -e /etc/zsh.extraprompt ]; then
        baseprompt="$coreprompt:%~"
else
        baseprompt="$coreprompt(`cat /etc/zsh.extraprompt`):%~"
fi

# The prompt shows up in xterm titles too.
case $TERM in
   xterm|color_xterm|screen)
        # Beware: next line has embedded raw control characters..
        PROMPT="%{]0;$baseprompt%}$baseprompt> "

        # Before each command is run, throw the command line up into the
        # titlebar! (The only problem is that very quick commands flicker..)
        preexec () {
                print -nP '\033]0;'
                print -nP "$coreprompt: "
                # Truncate at 60 chars, escape %, escape invisibles
                print -nPR "%60>...>${(V)1//\%/%%}"
                print -n '\007'
                # Also set the screen window title to programs I run.
                if [ "$TERM" = screen ]; then
                        print -nP '\033k%'
                        print -nPR "%60>...>${(V)1//\%/%%}"
                        print -n '\033\\'
                fi
        }
        
        # Add to the prompt to unset screen window title after program
        # exits.
        if [ "$TERM" = screen ]; then
                PROMPT="%{kzsh\\%}$PROMPT"
        fi

  ;;
  *) PROMPT="$baseprompt>"
  ;;
esac
unset baseprompt
[[ UID -eq 0 ]] && PROMPT=${PROMPT/\}%n/\}%U%n%u}

# Misc {{{1

limit core 0          # no core dumps
umask 022        # no user groups any more
setopt nopromptcr # No cr before prompt
#setopt extendedglob      # Lots of cool extra wildcards
#setopt mailwarning       # New mail?
setopt correct            # Correct commands
# Note that the following comment makes me cringe now, but is left in for
# historical amusement value.
setopt autolist automenu nobeep     # Filename completion: the best of csh and 4dos!
setopt autocd             # Exec directory to cd there
setopt noclobber noflowcontrol
#setopt autoresume
setopt print_exit_value
setopt list_packed
unsetopt bgnice

# History setup
setopt share_history
setopt csh_junkie_history
setopt hist_ignore_dups
setopt hist_allow_clobber
setopt hist_reduce_blanks

# Force emacs editing mode.
[[ $TERM == "xterm" ]] && bindkey -e

# ctrl-s will no longer freeze the terminal.
#stty -ixon kill ^K
stty erase "^?"

# Work around ion/xterm resize bug.
#if [ "$SHLVL" = 1 ]; then
# if [ -x `which resize 2>/dev/null` ]; then
#         eval `resize 
# fi
#fi

eval `dircolors 2>/dev/null` # set up color-ls variables
watch=(notme)   # watch for everybody but me
LOGCHECK=120    # check every 2 min for login/logout activity

if [ -e ~/.security-environment ]; then
        printf "Current security environment: "
        cat ~/.security-environment
fi

# Turn on full-featured completion (needs 2.1) {{{2
if [[ "$ZSH_VERSION" == (3.1|4)* ]]; then
        autoload -U compinit
        compinit
        if [[ -e ~/.ssh/known_hosts ]]; then
                # Use .ssh/known_hosts for hostnames.
                hosts=(${${${(f)"$(<$HOME/.ssh/known_hosts)"}%%\ *}%%,*})
                zstyle ':completion:*:hosts' hosts $hosts 
        fi
fi
        
# Key bindings {{{1

bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
bindkey '^K' kill-whole-line
bindkey -s '^L' "|less\n"         # ctrl-L pipes to less
bindkey -s '^B' " &\n"                        # ctrl-B runs it in the background
bindkey "\e[1~" beginning-of-line # Home (console)
bindkey "\e[H" beginning-of-line  # Home (xterm)
bindkey "\e[4~" end-of-line               # End (console)
bindkey "\e[F" end-of-line                # End (xterm)
bindkey "\e[2~" overwrite-mode            # Ins
bindkey "\e[3~" delete-char               # Delete
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed