This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Netcat | |
====== | |
The Netcat tool is known as the Swiss Army knife for TCP/IP connections. | |
(netcat or nc both are same) | |
nc -h | |
netcat -h | |
man netcat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import this | |
''' | |
The Zen of Python, by Tim Peters | |
Beautiful is better than ugly. | |
Explicit is better than implicit. | |
Simple is better than complex. | |
Complex is better than complicated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import hashlib | |
""" | |
one.txt | |
This sentence is encrypted using XOR cipher. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Just for practicing the file operation in python | |
def file_basics(): | |
print ' File Operations\n', '*' * 80 | |
types_of_file = """ | |
Text Files represent content as normal str strings, perform unicode and decoding automatically (plain) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def lists_examples(): | |
print 'List examples in Python\n', '======================================' | |
L = [] | |
L = ['abc', 123, 1.23, {}] | |
L = ['Bob', 40.0, ['dev', 'mgr']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
def main(): | |
print int('5') | |
print ord('s') | |
print chr(115) | |
print bin(13) | |
print hex(26) | |
print hex(255) | |
print oct(255) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Set - an unordered collection of unique and immutable objects | |
""" | |
def main(): | |
x = set('abcdef') | |
y = set('bdexyz') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys, getopt | |
def __help(): | |
sys.stderr.write('\n Usage: \n ip_classifier.py -h \n ip_classifier.py --help \n ip_classifier.py -i 128.12.14.23 \n ip_classifier.py --ipv4=128.12.14.23 \n ') | |
sys.exit() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. How to read and XML file using Python ? | |
# For example purpose, kindly save the above XML content into a file named as 'data.xml' | |
# import a class named xml.etree.ElementTree | |
import xml.etree.ElementTree as element_tree | |
# Before reading we should parse the whole XML file content as tree | |
tree = element_tree.parse('data.xml') | |
# Now with tree we have to fetch the root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'admin' | |
import sqlite3 | |
db = sqlite3.connect('books_store.db') | |
cursor = db.cursor() | |
try: | |
cursor.execute('''DROP TABLE books''') | |
print 'Deleted the old table' |