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
from contextlib import contextmanager | |
import tracemalloc | |
@contextmanager | |
def mtrace(): | |
tracemalloc.start() | |
yield | |
current, peak = tracemalloc.get_traced_memory() | |
tracemalloc.stop() | |
print(f"Peak memory usage: {peak / 1024 ** 2:.2f} MiB") |
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 random | |
import string | |
import timeit | |
def generate_random_string(length): | |
return ''.join(random.choice(string.ascii_letters) for _ in range(length)) | |
random_strings = [ |
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
FROM fluent/fluentd:v1.12-debian-1 | |
LABEL Description="Fluentd GELF forwarder" | |
USER root | |
RUN gem install fluent-plugin-input-gelf \ | |
&& gem install fluent-plugin-gelf-hs \ | |
&& gem sources --clear-all | |
COPY ./fluentd.conf /fluentd/etc/ | |
ENV FLUENTD_CONF=fluentd.conf |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<button>Click</button> | |
<script src="https://fb.me/react-with-addons-15.1.0.js"></script> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<button>Click</button> | |
<script src="https://fb.me/react-with-addons-15.1.0.js"></script> |
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
Date.prototype.addHours = function(h) { | |
this.setTime(this.getTime() + (h*60*60*1000)); | |
return this; | |
} |
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
// requires smalot/bootstrap-datetimepicker | |
function parse_date(datetime_str, format_str, language_code){ | |
try{ | |
var g = $.fn.datetimepicker.DPGlobal; | |
var format = g.parseFormat(format_str); | |
return g.parseDate(datetime_str, format, language_code, 'standard'); | |
}catch(e) { | |
return false; | |
} |