Python
''' | |
Proof of Concept: | |
Django devs built an ORM that seems way more straightforward than many existing tools. This class lets you leverage the django-orm without any project settings or other aspects of a django setup. | |
There are probably weak points and functionality missing, but it seems like a relatively intuitive proof of concept | |
''' | |
import os | |
import django | |
from django.conf import settings |
#!/bin/bash | |
# Script to cleanup GCP virtual machine images | |
# How many images of this family do we wish to retain | |
desired_images=8 | |
image_project="PROJECTHERE" | |
clean_images() | |
{ | |
# Function to clean up images, set the default family to megatron base |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
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.
- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
from django.db.models import CharField | |
from django.core.exceptions import ImproperlyConfigured | |
from django.utils.translation import ugettext_lazy as _ | |
class NullCharField(CharField): | |
""" | |
Subclass of the CharField that allows | |
empty strings to be stored as NULL in database | |
""" |
type below:
brew update
brew install redis
To have launchd start redis now and restart at login:
brew services start redis
Benchmark results: | |
Date: 2016/03/20 | |
Version: asgi_redis 0.8.3 / daphne master / channels master / cpython 2.7.11 | |
Environment: AWS, 3x m3.large (1 daphne, 1 worker, 1 redis) | |
Source: 1x m3.medium, different AZ, ab for HTTP, channels benchmarker for WS | |
HTTP GET, Django View (concurrency 10, 10,000 total) | |
Failures: 0.0% | |
Rate: 160 req/s |
#!/bin/bash | |
# | |
# This script surrounds the command passed in with start and finish notifications | |
# to the cronitor monitoring application. | |
# | |
# === SETUP | |
# | |
# * Make sure the cronitor script is executable. | |
# | |
# chmod +x cronitor |
This tutorial will turn your Raspberry PI into a simple Bluetooth audio receiver, which plays music through connected speakers. It's like a regular car audio system, but it can be used anywhere and it's a good value.
Audio source (i.e. smartphone)
|
v
((( Wireless Bluetooth Channel )))
|