Skip to content

Instantly share code, notes, and snippets.

View shobhit's full-sized avatar

Shobhit shobhit

View GitHub Profile
@shobhit
shobhit / k-means.py
Created October 25, 2012 07:12
Using python and k-means to find the dominant colors in images
from collections import namedtuple
from math import sqrt
import random
try:
import Image
except ImportError:
from PIL import Image
Point = namedtuple('Point', ('coords', 'n', 'ct'))
Cluster = namedtuple('Cluster', ('points', 'center', 'n'))
@shobhit
shobhit / send_pdf_with_boto_ses.py
Created August 24, 2012 21:06 — forked from yosemitebandit/send_pdf_with_boto_ses.py
send PDF attachment with boto and SES
''' quick example showing how to attach a pdf to multipart messages
and then send them from SES via boto
'''
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
import boto
@shobhit
shobhit / nwxpython.py
Created August 2, 2012 11:21
Put Images as Nodes using Networkx and Python
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img=mpimg.imread('/home/shobhit/Desktop/shobhit.jpg')
# draw graph without images
G =nx.Graph()
G.add_edge(0,1,image=img,size=0.1)
G.add_edge(1,2,image=img,size=0.05)
G.add_edge(2,3,image=img,size=0.02)
G.add_edge(3,4,image=img,size=0.075)