This will guide you through setting up a replica set in a docker environment using.
- Docker Compose
- MongoDB Replica Sets
- Mongoose
- Mongoose Transactions
Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!
""" | |
This is a self contained custom data structure with dict like | |
key-value storage capabilities. | |
* Can store the key-value pairs in any sqlalchemy supported db | |
* Employs thread safe transactional scope | |
* Modular, just change the session_scope to use a different db | |
* This example uses sqlite db for demonstration purpose | |
The code is inspired by Raymond Hettinger's talk `Build powerful, |
import json | |
import os | |
import sys | |
from datetime import timedelta | |
import httpx | |
import redis | |
from dotenv import load_dotenv | |
from fastapi import FastAPI | |
from asgiref.sync import sync_to_async |
This will guide you through setting up a replica set in a docker environment using.
Thanks to https://gist.github.com/asoorm for helping with their docker-compose file!
from channels.auth import AuthMiddlewareStack | |
from rest_framework.authtoken.models import Token | |
from django.contrib.auth.models import AnonymousUser | |
from django.db import close_old_connections | |
class TokenAuthMiddleware: | |
""" | |
Token authorization middleware for Django Channels 2 | |
""" |
#!/bin/bash | |
# Download Postman | |
cd /tmp || exit | |
echo "Downloading Postman..." | |
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz | |
# Extract and install Postman to /opt | |
echo "Extracting and installing to /opt..." | |
sudo tar -xzf postman.tar.gz -C /opt/ |
import torch | |
import torch.nn as nn | |
import torch.nn.init as init | |
dropout_prob = 0.5 | |
class FlatCnnLayer(nn.Module): | |
def __init__(self, embedding_size, sequence_length, filter_sizes=[3, 4, 5], out_channels=128): | |
super(FlatCnnLayer, self).__init__() |
This is a note on how to cross compile opencv for pretty much any ARM device(HardFP supported in this case) and deploy. Native | |
compiling in ARM devices can be painfully slow and they seem to hang often during build(mine got stuck at 43%). So if you happen | |
to have a desktop/laptop/server running ubuntu or similar linux distro, u can build opencv in fractionth of the time taken for | |
native compiling without any issues. | |
Building opencv3 with TBB and NEON and VFP support can boost opencv performance. Thanks to Adrian at pyimagesearch for pointing | |
that out. | |
Both my PC and target machine aka orange pi zero are running ubuntu 16.04 with python2.7 and python 3.5. | |
Let us use the term "build machine" for your PC where you are building opencv and "target machine" for the ARM single board computer. | |
1.Run the following commands in both machines(I think installing these in target machine only would do) to install the necessary libraries etc.(mine worked with them,so they should be enough |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
import csv | |
import random | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import math | |
import os | |
os.environ["THEANO_FLAGS"] = "mode=FAST_RUN,device=gpu,floatX=float32,allow_gc=False" |