Skip to content

Instantly share code, notes, and snippets.

View bosswissam's full-sized avatar

Wissam Jarjoui bosswissam

View GitHub Profile
import json
import tornado.ioloop
import tornado.web
DB = dict()
class BaseHandler(tornado.web.RequestHandler):
def validate_input(self):
if not isinstance(self.json_args.get('key'), str):
@bosswissam
bosswissam / keybase.md
Created February 26, 2018 21:57
keybase.md

Keybase proof

I hereby claim:

  • I am bosswissam on github.
  • I am bosswissam (https://keybase.io/bosswissam) on keybase.
  • I have a public key ASBFsCO1ewPVUnKwET9gTU_LVnga1Gj-3eIvzPZOpd9D-go

To claim this, I am signing this object:

import sys
def get_size(obj, seen=None):
"""Recursively finds size of objects"""
size = sys.getsizeof(obj)
if seen is None:
seen = set()
obj_id = id(obj)
if obj_id in seen:
return 0
@bosswissam
bosswissam / get_size.py
Created February 3, 2016 05:12
Get the true size of an object in memory
import sys
def get_size(obj):
size = 0
if isinstance(obj, dict):
size+= sum([get_size(v) for v in obj.values()])
size+= sum([get_size(k) for k in obj.keys()])
elif hasattr(obj, '__dict__'):
size+= get_size(obj.__dict__)
elif hasattr(obj, '__iter__'):