Skip to content

Instantly share code, notes, and snippets.

@anupsabraham
anupsabraham / pprint_request_response.py
Last active December 5, 2019 13:04
Pretty print request(json/xml/form-data) and response in python
import re
import json
from urllib import unquote_plus
from xml.dom import minidom
from xml.parsers.expat import ExpatError
def remove_blanks_xml(node):
"""Remove blank texts from xml"""
for child_node in node.childNodes:
if child_node.nodeType == minidom.Node.TEXT_NODE:
@anupsabraham
anupsabraham / Check Internet
Created May 19, 2015 06:07
Check if internet is up or down
((count = 100)) # Maximum number to try.
((internet = 0))
while [[ $count -ne 0 ]] ; do
ping -c 1 8.8.8.8 # Try once.
rc=$?
if [[ $internet -eq 0 ]] ; then
if [[ $rc -eq 0 ]] ; then
echo `say internet is up`
((internet = 1)) # If okay, flag to exit loop.
fi