<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://www.nain.cc/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="http://www.nain.cc/feed.php">
        <title>Madan</title>
        <description></description>
        <link>http://www.nain.cc/</link>
        <image rdf:resource="http://www.nain.cc/lib/images/favicon.ico" />
       <dc:date>2012-02-22T12:18:08-06:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=thisthefirst_title&amp;rev=1317170266&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=pythoninfo&amp;rev=1291079313&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=pythongrep&amp;rev=1291079313&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=pydeleteoldfiles&amp;rev=1291079313&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=withsftp&amp;rev=1290820679&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=wiki:playground&amp;rev=1290820679&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=vim&amp;rev=1290820678&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=unixtricksandtips&amp;rev=1290820678&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=unixtips&amp;rev=1290820678&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=tki2&amp;rev=1290820678&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=timerotationlogging&amp;rev=1290820678&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=testmessagedigest&amp;rev=1290820677&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=strrev&amp;rev=1290820677&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=strlen&amp;rev=1290820677&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=stdinfromuser&amp;rev=1290820677&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=start&amp;rev=1290820676&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=sqlserverbackup&amp;rev=1290820676&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=shellcolor&amp;rev=1290820676&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=sedinfo&amp;rev=1290820676&amp;do=diff"/>
                <rdf:li rdf:resource="http://www.nain.cc/doku.php?id=screenrc&amp;rev=1290820675&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="http://www.nain.cc/lib/images/favicon.ico">
        <title>Madan</title>
        <link>http://www.nain.cc/</link>
        <url>http://www.nain.cc/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="http://www.nain.cc/doku.php?id=thisthefirst_title&amp;rev=1317170266&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2011-09-27T19:37:46-06:00</dc:date>
        <dc:creator>aamantamap</dc:creator>
        <title>thisthefirst_title - created</title>
        <link>http://www.nain.cc/doku.php?id=thisthefirst_title&amp;rev=1317170266&amp;do=diff</link>
        <description>Hi to all on this webpage its content</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=pythoninfo&amp;rev=1291079313&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-29T19:08:33-06:00</dc:date>
        <dc:creator>madan</dc:creator>
        <title>pythoninfo</title>
        <link>http://www.nain.cc/doku.php?id=pythoninfo&amp;rev=1291079313&amp;do=diff</link>
        <description>Python examples

	*  Basic example
	*  Example with sftp of an entire directory
	*  Logging with Rotating log file
	*  Tk example
	*  Logging config file
	*  Use Python to access an Oracle database
	*  Python Scheduler example
	*  Python Daemon example
	*  Python example to delete old files
	*  Decrypt using openssl and python
	*  Encrypt using openssl and python
	*  Send email using Python
	*  Compile Python scripts to .exe for MS Win only
	*  Python class Config to handle configuration values
…</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=pythongrep&amp;rev=1291079313&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-29T19:08:33-06:00</dc:date>
        <dc:creator>madan</dc:creator>
        <title>pythongrep</title>
        <link>http://www.nain.cc/doku.php?id=pythongrep&amp;rev=1291079313&amp;do=diff</link>
        <description>Grep using Python


Thanks to Adam Ginsburg &lt;http://casa.colorado.edu/~ginsbura/python.htm&gt;


#py grep command 
#sample command: grep(&quot;^x&quot;,dir()) 
#syntax: grep(regexp_string,list_of_strings_to_search) 
import re 

def grep(string,list): 
	expr = re.compile(string) 
	for text in list: 
		match = expr.search(text) 
		if match != None: 
			print match.string 
			
# Two alternate solutions, courtesy of Gene H 
# These are more elegant, and more detailed descriptions can be found here: 
# http://www…</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=pydeleteoldfiles&amp;rev=1291079313&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-29T19:08:33-06:00</dc:date>
        <dc:creator>madan</dc:creator>
        <title>pydeleteoldfiles</title>
        <link>http://www.nain.cc/doku.php?id=pydeleteoldfiles&amp;rev=1291079313&amp;do=diff</link>
        <description>Python example to delete old files


#!python

# get file date / time info

import os, sys, time
import logging
import logging.config
import ConfigParser

__logConfigFile = 'py_logging.conf'
__log_name = 'pylog.log'
__MAX_LOG_FILE_SIZE = 100 * 1000
__confFile = 'path.conf'
__enableDelete = False

def checkLogFileSize(logFileName):
	fileSize = 0
	try:
		fileSize = os.path.getsize(logFileName)
	except:
	    print(__log_name + &quot; not found or could not delete&quot;)

	if fileSize &gt; __MAX_LOG_FILE_SIZE:
	…</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=withsftp&amp;rev=1290820679&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:59-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>withsftp - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=withsftp&amp;rev=1290820679&amp;do=diff</link>
        <description>An example which sftp's an entire directory


#!/usr/bin/python

import os
import sys
import pprint
import re
import tempfile
import logging

__logger = logging.getLogger(&quot;asset_mgmt&quot;)
__logger.setLevel(logging.DEBUG)
# create log filehandler
fh = logging.FileHandler(&quot;am.log&quot;)
fh.setLevel(logging.DEBUG)
# create formatter
formatter = logging.Formatter(&quot;%(asctime)s - %(name)s - %(levelname)s - %(message)s&quot;)
# add formatter to ch and fh
fh.setFormatter(formatter)
# add ch and fh to logger
__logger…</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=wiki:playground&amp;rev=1290820679&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:59-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>wiki:playground - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=wiki:playground&amp;rev=1290820679&amp;do=diff</link>
        <description></description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=vim&amp;rev=1290820678&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:58-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>vim - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=vim&amp;rev=1290820678&amp;do=diff</link>
        <description>Vim editor tips

	*  Delete duplicate lines
	*  Incremental numbering in vi
	*  Join all lines between patternA and patternB
	*  Cancel a vim command

----------

	*  Back to Main</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=unixtricksandtips&amp;rev=1290820678&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:58-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>unixtricksandtips - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=unixtricksandtips&amp;rev=1290820678&amp;do=diff</link>
        <description>Unit Tricks and Tips

alias l='ls -AFC'

-A all files except . and ..
-F add * to the end of executables, / to dirs, and @ to symlinks
-C multi-column output

By the way, if you are an old time Unix geek annoyed by how
ls now does a case-insensitive sort on filenames who wants the
old behaviour back, add</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=unixtips&amp;rev=1290820678&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:58-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>unixtips - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=unixtips&amp;rev=1290820678&amp;do=diff</link>
        <description>*  Sed
	*  Vimrc
	*  Screenrc
	*  Recover P4 deleted files
	*  Unix Tips
	*  Change directory to where file is
	*  Shell color highlighted text
	*  Use C Tags with VIM
	*  Unix find command

----------


Back to Main</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=tki2&amp;rev=1290820678&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:58-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>tki2 - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=tki2&amp;rev=1290820678&amp;do=diff</link>
        <description>Tk example


from Tkinter import *

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.button = Button(
            frame, text=&quot;QUIT&quot;, fg=&quot;red&quot;, command=frame.quit
            )
        self.button.pack(side=LEFT)

        self.hi_there = Button(frame, text=&quot;Hello&quot;, command=self.say_hi)
        self.hi_there.pack(side=LEFT)

    def say_hi(self):
        print &quot;hi there, everyone!&quot;

root = Tk()

app = App(root)

root.mainloop()</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=timerotationlogging&amp;rev=1290820678&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:58-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>timerotationlogging - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=timerotationlogging&amp;rev=1290820678&amp;do=diff</link>
        <description>Python logging TimedRotation

This example using timerotation.in (below) to configure logging rotation every minute



# log.ini

[loggers]
keys=root

[handlers]
keys=default

[formatters]
keys=default

[logger_root]
level=INFO
handlers=default
qualname=(root) # note - this is used in non-root loggers
propagate=1 # note - this is used in non-root loggers
channel=
parent=

[handler_default]
class=handlers.TimedRotatingFileHandler
level=INFO
formatter=default
args=('tr.log', 'm', 1)
filename=tr.lo…</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=testmessagedigest&amp;rev=1290820677&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:57-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>testmessagedigest - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=testmessagedigest&amp;rev=1290820677&amp;do=diff</link>
        <description>Test generation of random session keys (in java)


import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class TestEncryption {

	String msg = null;
	
	public TestEncryption() {
	}
	
	public TestEncryption(String m) {
		msg = m;
	}
	
	// return MD5(string)
	public String encrypt(String m) {
		byte[] byteArray = m.getBytes();
		StringBuffer bld = new StringBuffer();
	    try {
	    	MessageDigest md = MessageDigest.getInstance(&quot;MD5&quot;);
	    	
	    	byte[] resul…</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=strrev&amp;rev=1290820677&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:57-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>strrev - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=strrev&amp;rev=1290820677&amp;do=diff</link>
        <description>String reverse


#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main(int argc, char **argv, char **envp);
void strrev(char *s);

int main(int argc, char **argv, char **envp)
{
    char *name = &quot;madan nain&quot;;
    cout &lt;&lt; &quot;orig = &quot; &lt;&lt; name &lt;&lt; endl;
    strrev(name);
    cout &lt;&lt; &quot;rev  = &quot; &lt;&lt; name &lt;&lt; endl;
    return 0;
}

void strrev(char *s)
{
    int slen = strlen(s);
    int i = 0;
    char *st = s;
    char *t = s + slen -1;
    char temp;

    if (slen &gt; 1)
    {
        cout …</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=strlen&amp;rev=1290820677&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:57-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>strlen - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=strlen&amp;rev=1290820677&amp;do=diff</link>
        <description>String length


#include &lt;stdio.h&gt;


int main(int argc, char **argv);
int strlen(char *);
char *stlen(char *);

int main(int argc, char **argv)
{
  int len = 0;
  while (--argc &gt; 0)
    {
      ++argv;
      printf(&quot;Recursive Len = %d\n&quot;, strlen(*argv));
      len = stlen(*argv) - (*argv) - 1;
      printf(&quot;NonRecur Len = %d\n&quot;, len);
    }
  return 0;
}

int strlen(char *s)
{
  if (*s == 0)
    return 0;
  return strlen(++s)+1;
}

char *stlen(char *s)
{
  while (*s++)
    ;
  return s;
}</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=stdinfromuser&amp;rev=1290820677&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:57-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>stdinfromuser - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=stdinfromuser&amp;rev=1290820677&amp;do=diff</link>
        <description>Read from STDIN using Ruby


# 1.rb

print &quot;Enter your Name:&quot;
name = STDIN.gets

print &quot;Hello #{name}&quot;




Back to Ruby page</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=start&amp;rev=1290820676&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:56-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>start - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=start&amp;rev=1290820676&amp;do=diff</link>
        <description>Welcome to dokuwiki at &lt;http://mnain.org/dokuwiki&gt;.

Links on This site include

	*  Bookmarks
	*  Information on Java with examples
	*  Information on Ruby with examples
	*  Information on Python with examples
	*  Information on Powershell with examples
	*  Database related links / info
	*  C++ program snippets and info
	*  Unix/Linux tips and tricks
	*  Excel tips
	*  Info on PHP with examples
	*  Misc. Links
	*  Apache
	*  Vi/Vim editor tips
	*  Imaging / Sysadmin
	*  AutoIt scripts</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=sqlserverbackup&amp;rev=1290820676&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:56-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>sqlserverbackup - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=sqlserverbackup&amp;rev=1290820676&amp;do=diff</link>
        <description>SQL Server Backup Script


DECLARE @DBName varchar(255)

DECLARE @DATABASES_Fetch int

DECLARE DATABASES_CURSOR CURSOR FOR
    select
        DATABASE_NAME   = db_name(s_mf.database_id)
    from
        sys.master_files s_mf
    where
       -- ONLINE
        s_mf.state = 0 

       -- Only look at databases to which we have access
    and has_dbaccess(db_name(s_mf.database_id)) = 1 

        -- Not master, tempdb or model
    and db_name(s_mf.database_id) not in ('Master','tempdb','model')
    …</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=shellcolor&amp;rev=1290820676&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:56-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>shellcolor - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=shellcolor&amp;rev=1290820676&amp;do=diff</link>
        <description>Use color text in shell


#!/bin/zsh
# My color scheme presumes a black background.  If you don't like my choices,
# pick your own via the color wheel:
for f in 0 1 4 7 ; do;
    for g in 30 31 32 33 34 35 36 37; do;
        echo `echo '\e['$f';'$g'm'$f $g'\e[0;37m\n'`;
    done;
done;</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=sedinfo&amp;rev=1290820676&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:56-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>sedinfo - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=sedinfo&amp;rev=1290820676&amp;do=diff</link>
        <description>SED tips

	*  Typical sed command line


sed -n -e '/pattern1/,/pattern2/p' &lt; filein &gt; fileout


	*  Insert 'COMMIT' in a large file of ORACLE insert statements using sed. (Add COMMIT every 100'th line)


1~100a \
commit;


----------


Back to Unix/Linux tips</description>
    </item>
    <item rdf:about="http://www.nain.cc/doku.php?id=screenrc&amp;rev=1290820675&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2010-11-26T19:17:55-06:00</dc:date>
        <dc:creator>mnain</dc:creator>
        <title>screenrc - Sync_nov_26_2010</title>
        <link>http://www.nain.cc/doku.php?id=screenrc&amp;rev=1290820675&amp;do=diff</link>
        <description>.screenrc file


# .screenrc file
#
# $Id$
#
# This is an example for the global screenrc file.
# You may want to install this file as /etc/screenrc.
# Check config.h for the exact location.
#
# Flaws of termcap and standard settings are done here.
#
 
#startup_message off
 
#defflow on # will force screen to process ^S/^Q
 
deflogin on
#autodetach off
 
vbell off
vbell_msg &quot;   Wuff  ----  Wuff!!  &quot;
 
# all termcap entries are now duplicated as terminfo entries.
# only difference should be the s…</description>
    </item>
</rdf:RDF>

