This file contains hidden or 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 pandas as pd | |
| df = pd.DataFrame({ | |
| 'a': ['a', 'a', 'b', 'b', 'cc'], | |
| 'b': ['d', 'e', 'f', 'g', 'h'], | |
| }) | |
| df.a.astype('category').cat.codes # + df.b.astype('category') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| /* | |
| Name: Base16 Monokai Dark | |
| Author: Wimer Hazenberg (http://www.monokai.nl) | |
| CodeMirror template adapted for IPython Notebook by Nikhil Sonnad (https://github.com/nsonnad/base16-ipython-notebook) | |
| CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools) | |
| Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) | |
| Fixed by DKhodakov | |
| vim ~/.jupyter/custom/custom.css |
This file contains hidden or 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
| /* | |
| Name: Base16 Monokai Dark | |
| Author: Wimer Hazenberg (http://www.monokai.nl) | |
| CodeMirror template adapted for IPython Notebook by Nikhil Sonnad (https://github.com/nsonnad/base16-ipython-notebook) | |
| CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-chrome-devtools) | |
| Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16) | |
| Fixed by DKhodakov | |
| vim ~/.jupyter/custom/custom.css |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 time | |
| import psutil | |
| import os | |
| class Timer: | |
| def __init__(self, logger=None, msg='', log_start=True): | |
| self.logger = logger | |
| self.msg = msg | |
| self.enter_memory_usage_mb = 0 |
This file contains hidden or 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
| [unix_http_server] | |
| file=/tmp/supervisor.sock ; path to your socket file | |
| [supervisord] | |
| logfile=/var/log/supervisord/supervisord.log ; supervisord log file | |
| logfile_maxbytes=50MB ; maximum size of logfile before rotation | |
| logfile_backups=10 ; number of backed up logfiles | |
| loglevel=error ; info, debug, warn, trace | |
| pidfile=/var/run/supervisord.pid ; pidfile location | |
| nodaemon=false ; run supervisord as a daemon |
This file contains hidden or 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 logging | |
| import logging.handlers | |
| import os.path as path | |
| LOG_FORMAT = '[%(asctime)s] %(levelname)s %(message)s' | |
| TIME_FORMAT = '%Y-%m-%d %H:%M:%S' | |
| LOG_DEFAULT_LEVEL = logging.DEBUG | |
This file contains hidden or 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 socket | |
| import time | |
| CARBON_SERVER = '0.0.0.0' | |
| CARBON_PORT = 2003 | |
| def send_to_carbon(metric: str, value, server: str, port=2003): | |
| message = '{} {} {}\n'.format(metric, value, int(time.time())) |
This file contains hidden or 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
| Latency Comparison Numbers | |
| -------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |