This gist is just a personal practice record of Logstash Multiple Pipelines.
The following summary assumes that
the PATH
contains Logstash and Filebeat executables
and they run locally on localhost
.
# refactor of https://lukeplant.me.uk/blog/posts/double-checked-locking-with-django-orm/ | |
# untested | |
def double_checked_lock_iterator(queryset): | |
for item_pk in queryset.values_list("pk", flat=True): | |
with transaction.atomic(): | |
try: | |
yield queryset.select_for_update(skip_locked=True).get(id=item_pk) | |
except queryset.model.DoesNotExist: | |
pass |
import _xxsubinterpreters as interpreters | |
import threading | |
import textwrap as tw | |
import pickle | |
# Create a sub-interpreter | |
interpid = interpreters.create() | |
# If you had a function that generated a numpy array | |
arry = [5,4,3,2,1] |
This gist is just a personal practice record of Logstash Multiple Pipelines.
The following summary assumes that
the PATH
contains Logstash and Filebeat executables
and they run locally on localhost
.
from __future__ import print_function, absolute_import, unicode_literals | |
import time | |
try: | |
from Queue import Empty | |
except ImportError: | |
from queue import Empty | |
from multiprocessing import Process, cpu_count, Manager | |
import logging |
from inspect import iscoroutinefunction, isawaitable | |
import sys | |
from collections import deque | |
# NOTE: this follows the contextlib.ExitStack implementation | |
class _BaseExitStack: | |
def __init__(self): |
db.votes.aggregate([{
$lookup: {
from: "users",
localField: "createdBy",
foreignField: "_id",
import sys | |
import re | |
def format_dict_recursively(mapping, raise_unresolvable=True, strip_unresolvable=False, conversions={'True': True, 'False': False}): | |
"""Format each string value of dictionary using values contained within | |
itself, keeping track of dependencies as required. | |
Also converts any formatted values according to conversions dict. |
#!/usr/bin/env python | |
''' | |
Kanban + Pomodoro + Reminder | |
If you use linux please install sox first (sudo apt-get install sox) | |
You can use these formats in order to remind you of the tasks: | |
* Y:m:d H:M:S | |
* Y:m:d H:M | |
* everyday H:M[:S] | |
* every [monday|tuesday|wednesday|thursday|friday|saturday] H:M[:S] | |
* *:m:d H:M[:S] |
#!/usr/bin/env python | |
# export data sheets from xlsx to csv | |
from openpyxl import load_workbook | |
import csv | |
from os import sys | |
def get_all_sheets(excel_file): | |
sheets = [] |