A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
from pymongo import Connection | |
from bson import ObjectId | |
from itertools import imap | |
class Model(dict): | |
""" | |
A simple model that wraps mongodb document | |
""" | |
__getattr__ = dict.get |
# Kernel sysctl configuration file for Linux | |
# | |
# Version 1.12 - 2015-09-30 | |
# Michiel Klaver - IT Professional | |
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant | |
# | |
# This file should be saved as /etc/sysctl.conf and can be activated using the command: | |
# sysctl -e -p /etc/sysctl.conf | |
# | |
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details. |
sudo vi /etc/sysctl.conf | |
# Add the following to sysctl.conf: | |
# Decrease TIME_WAIT seconds | |
net.ipv4.tcp_fin_timeout = 30 | |
# Recycle and Reuse TIME_WAIT sockets faster | |
net.ipv4.tcp_tw_recycle = 1 |
#!/bin/bash | |
MONGO_DATABASE="your_db_name" | |
APP_NAME="your_app_name" | |
MONGO_HOST="127.0.0.1" | |
MONGO_PORT="27017" | |
TIMESTAMP=`date +%F-%H%M` | |
MONGODUMP_PATH="/usr/bin/mongodump" | |
BACKUPS_DIR="/home/username/backups/$APP_NAME" |
# $ pip install fdb | |
# use this documentation for the moment http://www.firebirdsql.org/file/documentation/drivers_documentation/python/3.3.0/tutorial.html#connecting-to-a-database | |
import fdb as kinterbasdb | |
con = kinterbasdb.connect(dsn='/var/lib/firebird/2.5/data/rdbgraph.fdb', user='sysdba', password='masterkey') | |
cur = con.cursor() | |
# Execute the insert statement: | |
name="name" |
plugins = {} | |
def get_input_plugins(): | |
return plugins['input'].items() | |
class Plugin(object): | |
plugin_class = None | |
@classmethod | |
def register(cls, name): | |
plugins[cls.plugin_class][name] = cls |
title | subtitle | author | date | source |
---|---|---|---|---|
Docker Compose Cheatsheet |
Quick reference for Docker Compose commands and config files |
Jon LaBelle |
April 7, 2019 |
The MIT License (MIT) | |
Copyright (c) 2013 Michael E. Cotterell | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
#!/usr/bin/env python3 | |
''' | |
@desc Simple MongoDB Client class. Offers the entire API | |
of AsyncioMotorCollection. | |
@author SDQ <[email protected]> | |
@version 1.0.0 | |
@date 2020-02-17 | |
@note 1.0.0 (2020-02-17) : First functional version | |
''' | |
from typing import Any, Optional |