Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import pcap #requires the python-libpcap module
def libpcap_net_data(cap_file, net_iface, filter_expr=None):
"""A decorator that can be used to sniff network data for the duration of a function call
if there is heavy traffic on the network interface the captured data will contain spurious packets
not related to the function call
@ykmm
ykmm / wraplabel.py
Last active November 2, 2019 12:03
Kivy wrap label
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from kivy.uix.label import Label
from kivy.graphics import Color
from kivy.graphics import Rectangle
from kivy.metrics import sp
from kivy.logger import Logger
from kivy.properties import ListProperty, BooleanProperty
@ykmm
ykmm / collectionjson.py
Created February 24, 2014 17:22
Collection+json python library
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#Based on http://amundsen.com/media-types/collection/format/
import json
from collections import OrderedDict as odict
#from ContentType import ContentType
import logging
COLLECTION = 'collection'