This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Interactive execution with automatic history, tries to mimic Mathematica's | |
prompt system. This environment's main features are: | |
- Numbered prompts (In/Out) similar to Mathematica. Only actions that produce | |
output (NOT assingments, for example) affect the counter and cache. | |
- The following GLOBAL variables always exist (so don't overwrite them!): | |
_p: stores previous result which generated printable output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[T]he difference between a bad programmer and a | |
good one is whether he considers his code or his | |
data structures more important. Bad programmers | |
worry about the code. Good programmers worry about | |
data structures and their relationships. | |
-- Linus Torvalds | |
~~~ | |
Clarity and brevity sometimes are at odds. | |
When they are, I choose clarity. | |
-- Jacob Kaplan-Moss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
__author__ = "github.com/ruxi" | |
__license__ = "MIT" | |
import requests | |
import tqdm # progress bar | |
import os.path | |
def download_file(url, filename=False, verbose = False): | |
""" | |
Download file with progressbar | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
from tqdm import tqdm | |
def download_from_url(url, dst): | |
""" | |
@param: download file URL | |
@param: output file name | |
""" | |
file_size = int(requests.head(url).headers["Content-Length"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Very simple HTTP server in python. | |
Usage:: | |
./dummy-web-server.py [<port>] | |
Send a GET request:: | |
curl http://localhost |