Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Harshavardhana harshavardhana

💭
I may be slow to respond.
Block or report user

Report or block harshavardhana

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View clean_html.py
def clean_html(html):
""" Remove HTML markup from the given string. """
# remove inline JavaScript / CSS
x = re.sub(r'(?is)<(script|style).*?>.*?(</\1>)', '', html.strip())
# remove html comments. must be done before removing regular tags since comments can contain '>' characters.
x = re.sub(r'(?s)<!--(.*?)-->[\n]?', '', x)
# remove the remaining tags
x = re.sub(r'(?s)<.*?>', ' ', x)
# remove html entities
x = remove_entities(x)
@harshavardhana
harshavardhana / grabURLsharecount.py
Created Dec 5, 2012
URL share count on Twitter
View grabURLsharecount.py
#!/usr/bin/env python
import urllib
import pycurl
import time
import sys
import json
import cStringIO
from optparse import OptionParser
@harshavardhana
harshavardhana / grab_followers_tweets_following.py
Created Dec 6, 2012
Get Followers Tweets and Following through "https://twitter.com/<userid>/followers" and encode into json
View grab_followers_tweets_following.py
#!/usr/bin/env python
import sys
import logging
import chardet
import json
from optparse import OptionParser
from boilerpipy import (Extractor, isValidhtml,
compat_urllib_request)
@harshavardhana
harshavardhana / get_tasks_asana.py
Created Dec 25, 2012
Get Asana tasks from User API key and Project ID
View get_tasks_asana.py
#!/usr/bin/env python
import urllib
import pycurl
import sys
import json
from optparse import OptionParser
parser = OptionParser(usage="%prog: [options] [URL]")
parser.add_option('-p', '--projectid', help="Project ID")
@harshavardhana
harshavardhana / dircmp.go
Last active Dec 17, 2015
Trivial dircmp in Golang - [Continue to enhance..]
View dircmp.go
package main
import (
"path/filepath"
"os"
"flag"
"fmt"
)
type fileattr struct {
@harshavardhana
harshavardhana / trees.sh
Created Jun 5, 2013
Print directory tree structure
View trees.sh
#!/bin/sh
# 1st sed: remove colons
# 2nd sed: replace higher level folder names with dashes
# 3rd sed: indent graph three spaces
# 4th sed: replace first dash with a vertical bar
if [ $# -eq 1 ]; then
ls -R $1 | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
elif [ $# -gt 1 ]; then
echo "Only one directory at a time please!!"
exit 255
@harshavardhana
harshavardhana / tshark.sh
Last active Dec 19, 2015
Sharking network traffic
View tshark.sh
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Please provide the pcap file for sharking.."
exit 255
fi
capinfos $1 1>/dev/null 2>/dev/null
if [ $? -eq 1 ]; then
@harshavardhana
harshavardhana / test_mmap.cpp
Created Aug 1, 2013
./test_mmap.static 1>nostrace.rhel63.static.log 2>&1 &
View test_mmap.cpp
/*
* g++ -O3 --std=c++0x -o test_mmap test_mmap.cpp
*/
#include <vector>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@harshavardhana
harshavardhana / isvalidhostname.py
Created Aug 17, 2013
Check for valid hostname
View isvalidhostname.py
import re
def isvalidhostname(hostname):
"""
Validate hostname
"""
regex = re.compile("[^A-Z\d-]", re.IGNORECASE)
if len(hostname) > 255:
return False
@harshavardhana
harshavardhana / file_changed.sh
Last active Dec 22, 2015
Tar read test on Gluster NFS volume
View file_changed.sh
#!/bin/bash
_init()
{
DIRZ=$( seq 1 100 )
}
cleanup()
{
echo "Cleaning the test"
You can’t perform that action at this time.