Pages

Saturday, April 16, 2011

Google Translate on an xmonad toggle

NS "translate" "chromium-browser --app=http://translate.google.com/#" (name =? "Google Translate") nonFloating,




,((modMask myConfig .|. shiftMask, xK_t),  namedScratchpadAction scratchpads 




This is great, now I hit Mod-shift t and a chromium "app" containing google
translate appears/disappears.



--
My Emacs Files At GitHub

Friday, April 15, 2011

Exim4 handling redirecting mails from your apache vhost an external email


The Problem




Consider the Apache vhost myweb.com. Someone sends an email to
info@myweb.com. We want exim4 to spot that and use sendmail to send the mail to
the approved user. frequently that person might be sat behind gmail or something
similar.






The components





  • Everything is done via exim4 config with the addition of a new router and
    vhost specific alias files which contain the email mappings.

  • The text here assumes you have NOT split your configuration

  • All exim configuration is done using the exim4.conf.template file.








The solution





  • Edit /etc/exim4/exim4.conf.template.

  • Modify the local domains definition



    # List of domains considered local for exim. Domains not listed here
    # need to be deliverable remotely.
    domainlist local_domains = @:localhost:dsearch;/etc/exim4/virtualhosts






This tells exim which domain names are considered for for further processing.


  • Insert the following additional router code before systemalias handling (400):-



    #####################################################
    ### router/350_exim4-config_vdom_aliases
    #####################################################
    vdom_aliases:
    driver = redirect
    allow_defer
    allow_fail
    domains = dsearch;/etc/exim4/virtualhosts
    data = ${expand:${lookup{$local_part}lsearch*@{/etc/exim4/virtualhosts/$domain}}}
    retry_use_local_part
    pipe_transport = address_pipe
    file_transport = address_file
    no_more
    #####################################################
    ### end router/350_exim4-config_vdom_aliases
    ########################################################################################




  • A cursory glance at the code suggests that /etc/exim4/virtualhosts will play a
    part. It does!

  • Create a file for each vhost you wish to redirect email for. From our example
    we create /etc/exim4/virtualhosts/myweb.com. In it we place our email
    mappings. Here is an example:-



info: info@gmail.com
webmaster: webmaster@gmail.com




--
My Emacs Files At GitHub

Sunday, April 10, 2011

Emacs at work developing facebook friendly meta data in php....

Copy named files to remote host and recreate directories


A script to copy only certain file name from tree to remote host and recreate
the directory structure. Had thought scp -r or something would do it. or rsync
directly but well, the rsync manual leaves me cold for things like what to
include and what to exclude… It's probably a lot simpler than this of course ;(





#!/bin/bash
host=${1:-dev}
filename=$2
destdir=$3

if [ "${host}" = "" ]; then
echo "No destination host specified"
echo "Usage : copy-files HOSTNAME FILENAME DESTDIR"
exit
fi

if [ "${filename}" = "" ]; then
echo "No FILENAME specified"
echo "Usage : copy-files HOSTNAME FILENAME DESTDIR"
exit
fi

if [ "${destdir}" = "" ]; then
echo "No DESTDIR specified"
echo "Usage : copy-files HOSTNAME FILENAME DESTDIR"
exit
fi

find . -type f -iname "${filename}" 2> /dev/null | while read -r FILE
do
REMDESTDIR="~/${destdir}/`dirname ${FILE#./}`"
echo "Found : ${FILE} .. Attempting : rsync -avz ${FILE} ${host}:${REMDESTDIR}"
rsync -avz "${FILE}" "${host}:${REMDESTDIR}/"
done




--
My Emacs Files At GitHub