<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Kumar303's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 08:38:55 GMT</pubDate>
    <description>DZone Snippets: Kumar303's Code Snippets</description>
    <item>
      <title>solve svn error "can't recode string" on Mac OS X</title>
      <link>http://snippets.dzone.com/posts/show/172</link>
      <description>was getting this error on certain files until I added this to ~/.bash_profile :&lt;br /&gt;&lt;code&gt;export LC_CTYPE="en_US.UTF-8"&lt;br /&gt;export LANG="en_US.UTF-8"&lt;/code&gt;</description>
      <pubDate>Fri, 15 Apr 2005 01:32:37 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/172</guid>
      <author>kumar303 (kumar mcmillan)</author>
    </item>
    <item>
      <title>automatically authorize a remote host (SSH key swap)</title>
      <link>http://snippets.dzone.com/posts/show/86</link>
      <description>use with caution!  This script will copy your pub key to a remote host so you can login or run remote scripts without a password.  IMPORTANT: if you need to run a single script on the remote host, it would be better to authorize a key for just that script.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;#!/bin/bash&lt;br /&gt;# kumar.mcmillan -at- farmdev.com&lt;br /&gt;&lt;br /&gt;function usage()&lt;br /&gt;{&lt;br /&gt;    echo ""&lt;br /&gt;    echo "Authorizes a host for automatic SSH use by sending your key to the remote host ..."&lt;br /&gt;    echo "Usage: $0 remote_host_to_authorize [username:=defaults to current username]"&lt;br /&gt;    echo ""&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function cleanup()&lt;br /&gt;{&lt;br /&gt;    if [ -f $TEMP_PUB_KEY_XFER ]&lt;br /&gt;    then&lt;br /&gt;        rm $TEMP_PUB_KEY_XFER&lt;br /&gt;    fi&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function exit_on_error()&lt;br /&gt;{&lt;br /&gt;    cleanup&lt;br /&gt;    exit 1&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if [ $# -lt 1 -o "$1" = "-h" -o "$1" = "--help" ]&lt;br /&gt;then&lt;br /&gt;    usage&lt;br /&gt;    exit 0&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;PUB_KEY=~/.ssh/id_dsa.pub&lt;br /&gt;if [ $# -eq 2 ]; then&lt;br /&gt;    USER=$2&lt;br /&gt;else&lt;br /&gt;    USER=`whoami`&lt;br /&gt;fi&lt;br /&gt;HOST_TO_AUTH=$1&lt;br /&gt;TEMP_PUB_KEY_XFER=/tmp/$USER"_TEMP_KEY"&lt;br /&gt;&lt;br /&gt;echo "checking for $PUB_KEY ..."&lt;br /&gt;if [ ! -f $PUB_KEY ]; then&lt;br /&gt;    echo "generating your dsa public key (leave passphrase blank and save to $PUB_KEY when prompted) ..."&lt;br /&gt;    ssh-keygen -t dsa&lt;br /&gt;    if [ $? -ne 0 ]; then&lt;br /&gt;        echo "ssh-keygen failed"&lt;br /&gt;        exit_on_error&lt;br /&gt;    fi&lt;br /&gt;fi&lt;br /&gt;echo "OK"&lt;br /&gt;&lt;br /&gt;echo "for the following commands you will be asked to supply your password for $HOST_TO_AUTH :"&lt;br /&gt;&lt;br /&gt;echo "copying a temp pub key to $HOST_TO_AUTH ..."&lt;br /&gt;cat $PUB_KEY &gt; $TEMP_PUB_KEY_XFER&lt;br /&gt;chmod 700 $TEMP_PUB_KEY_XFER&lt;br /&gt;echo "OK"&lt;br /&gt;&lt;br /&gt;remote_key=`basename $TEMP_PUB_KEY_XFER`&lt;br /&gt;scp $TEMP_PUB_KEY_XFER $USER@$HOST_TO_AUTH:~/$remote_key&lt;br /&gt;if [ $? -ne 0 ]; then&lt;br /&gt;    echo "scp failed"&lt;br /&gt;    exit_on_error&lt;br /&gt;fi&lt;br /&gt;    &lt;br /&gt;echo "authorizing $HOST_TO_AUTH for automatic SSH use ..."&lt;br /&gt;ssh $USER@$HOST_TO_AUTH "cat ~/$remote_key &gt;&gt; ~/.ssh/authorized_keys; rm ~/$remote_key"&lt;br /&gt;if [ $? -ne 0 ]; then&lt;br /&gt;    echo "ssh failed"&lt;br /&gt;    exit_on_error&lt;br /&gt;fi&lt;br /&gt;echo "OK"&lt;br /&gt;&lt;br /&gt;cleanup&lt;br /&gt;echo "authorization successful!  you can now login automatically to $HOST_TO_AUTH"&lt;br /&gt;exit 0&lt;/code&gt;</description>
      <pubDate>Sat, 09 Apr 2005 00:48:13 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/86</guid>
      <author>kumar303 (kumar mcmillan)</author>
    </item>
    <item>
      <title>Browse pydoc locally ...</title>
      <link>http://snippets.dzone.com/posts/show/66</link>
      <description>Opens pydoc in your browser.  If pydoc has not been started it starts it for you.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;&lt;br /&gt;PYDOC=`which pydoc`&lt;br /&gt;if [ ! -x ${PYDOC} ]&lt;br /&gt;then&lt;br /&gt;    echo "could not find executable pydoc (tried: ${PYDOC})"&lt;br /&gt;    exit 1&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;# passthru ...&lt;br /&gt;if [ $# -gt 0 ]&lt;br /&gt;then&lt;br /&gt;    ${PYDOC} $@&lt;br /&gt;    exit $?&lt;br /&gt;fi&lt;br /&gt;&lt;br /&gt;#--------------------------------------&lt;br /&gt;# or else... start it up automagically :&lt;br /&gt;&lt;br /&gt;PYDOC_PORT=9000&lt;br /&gt;PYDOC_SERVER=http://localhost:${PYDOC_PORT}/&lt;br /&gt;running=0&lt;br /&gt;pydoc_pses=0&lt;br /&gt;&lt;br /&gt;function browse_docs()&lt;br /&gt;{&lt;br /&gt;    open ${PYDOC_SERVER}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;for ps in `ps ax | grep "${PYDOC}" | awk '{ print $1 }'`&lt;br /&gt;do&lt;br /&gt;    let pydoc_pses++&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;if [ $pydoc_pses -ge 2 ]&lt;br /&gt;then&lt;br /&gt;    browse_docs&lt;br /&gt;else&lt;br /&gt;    ${PYDOC} -p ${PYDOC_PORT} &amp;&lt;br /&gt;    until `curl -o /dev/null ${PYDOC_SERVER} &amp;&gt;/dev/null`&lt;br /&gt;    do&lt;br /&gt;        echo "waiting for pydoc server ..."&lt;br /&gt;        sleep 2&lt;br /&gt;    done&lt;br /&gt;    browse_docs&lt;br /&gt;fi&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 08 Apr 2005 03:39:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/66</guid>
      <author>kumar303 (kumar mcmillan)</author>
    </item>
  </channel>
</rss>
