Skip to content

Instantly share code, notes, and snippets.

View ngbeslhang's full-sized avatar

ngb ngbeslhang

View GitHub Profile
@ngbeslhang
ngbeslhang / request_time.py
Last active July 8, 2022 23:12 — forked from andrewwatts/request_time.py
urllib2 vs urllib3 vs requests; updated for Python 3
#!/usr/bin/env python3
import time
# REMEMBER TO CHANGE THE VARIABLES BELOW BEFORE YOU RUN THE SCRIPT
_URL = 'http://localhost/tmp/derp.html'
_NUMBER = 1000
def test_urllib2():
@ngbeslhang
ngbeslhang / dot_dict.py
Created July 29, 2017 14:30 — forked from floer32/dot_dict.py
DotDict is a variation of the classic "Bunch" recipe - just a dictionary, with all the normal dictionary methods, but the attributes are accessible by dot notation. Use this when you just really want to turn some dictionaries (i.e. from JSON) into something like JavaScript objects. Achieved with very little code. See bottom of docstring for Stac…
class DotDict(dict):
""" A dictionary whose attributes are accessible by dot notation.
This is a variation on the classic `Bunch` recipe (which is more limited
and doesn't give you all of dict's methods). It is just like a dictionary,
but its attributes are accessible by dot notation in addition to regular
`dict['attribute']` notation. It also has all of dict's methods.
.. doctest::
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person