Skip to content

Instantly share code, notes, and snippets.

View bhumpert's full-sized avatar

Brandon Humpert bhumpert

  • San Francisco Bay Area, California, USA
View GitHub Profile
@bhumpert
bhumpert / animated.py
Created March 21, 2018 20:17
Quick CLI animation context manager
import threading
import time
import sys
from itertools import cycle
class Animated():
def __init__(self, anim="|/-\\"):
self.anim = anim
self.run_lock = threading.Lock()
In [31]: class A(object):
...: @classmethod
...: def show(cls, x):
...: print(x)
...:
In [32]: a = A()
In [33]: A.show(1)
1
In [23]: def test_17(n):
....: for _ in range(n):
....: x = random()
....: assert x == float('{:1.16e}'.format(x))
....: print('Test success')
....:
In [24]: test_17(1000000)
Test success

Keybase proof

I hereby claim:

  • I am bhumpert on github.
  • I am bhumpert (https://keybase.io/bhumpert) on keybase.
  • I have a public key whose fingerprint is 638E 4A0D 4B58 D5D8 2386 1E5E F551 F365 8DCE 0DD4

To claim this, I am signing this object: