Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:
sysctl -a | grep machdep.cpu.features | grep VMX
If there's output, you're good!
| import sys | |
| import random | |
| def producer(): | |
| while True: | |
| data = random.randint(0, 9) | |
| print('生產了:', data) | |
| yield data | |
| def consumer(): |
| import time | |
| import psycopg2 | |
| from iter_file import IteratorFile | |
| conn = psycopg2.connect(host="localhost", database="test") | |
| # args = [(1,2), (3,4), (5,6)] | |
| args = [(i,i+1) for i in range(1,1*10**4,2)] |
By: Matt Barackman
A collection of objects or case classes that share a sealed trait.
In the example below, the type family would be a collection of traffic light colors with Red, Yellow, and Green as member objects.
| function adb_toggle_airplane_mode { | |
| # Open airplane mode settings | |
| adb shell am start -a android.settings.AIRPLANE_MODE_SETTINGS | |
| # Key UP to focus on the first switch = toggle airplane mode, then sleep 100ms | |
| adb shell input keyevent 19 ; sleep 0.1 | |
| # Key CENTER to toggle the first switch, then sleep 100ms | |
| adb shell input keyevent 23 ; sleep 0.1 |
| class CompositeRouter(routers: Seq[Router]) extends SimpleRouter { | |
| override def documentation: Seq[(String, String, String)] = | |
| routers.flatMap(_.documentation) | |
| override def routes: Router.Routes = | |
| routers.map(_.routes).fold(Router.empty.routes)(_ orElse _) | |
| } | |
| object CompositeRouter { | |
| def fromPrefixedRoutes(routers: (String, Router.Routes)*): CompositeRouter = |
| """ | |
| Simple example of building your own context manager. | |
| Resources: | |
| - http://preshing.com/20110920/the-python-with-statement-by-example/ | |
| - https://docs.python.org/3/library/contextlib.html | |
| - PEP 343 -- the "with" statement: https://www.python.org/dev/peps/pep-0343/ | |
| """ |
If you use Amazon AWS for nearly anything, then you are probably familiar with KMS, the Amazon Key Management Service.
KMS is a service which allows API-level access to cryptographic primitives without the expense and complexity of a full-fledged HSM or CloudHSM implementation. There are trade-offs in that the key material does reside on servers rather than tamper-proof devices, but these risks should be acceptable to a wide range of customers based on the care Amazon has put into the product. You should perform your own diligence on whether KMS is appropriate for your environment. If the security profile is not adequate, you should consider a stronger product such as CloudHSM or managing your own HSM solutions.
The goal here is to provide some introductory code on how to perform envelope encrypt a message using the AWS KMS API.
KMS allows you to encrypt messages of up to 4kb in size directly using the encrypt()/decrypt() API. To exceed these limitations, you must use a technique called "envelope encryptio
| package utils | |
| import java.nio.ByteBuffer | |
| import cats.data.Xor | |
| import io.circe.Json | |
| import play.api.http.LazyHttpErrorHandler | |
| import play.api.http.Status._ | |
| import play.api.libs.iteratee.{Iteratee, Traversable} | |
| import play.api.mvc.BodyParsers.parse._ |
This small subclass of the Pandas sqlalchemy-based SQL support for reading/storing tables uses the Postgres-specific "COPY FROM" method to insert large amounts of data to the database. It is much faster that using INSERT. To acheive this, the table is created in the normal way using sqlalchemy but no data is inserted. Instead the data is saved to a temporary CSV file (using Pandas' mature CSV support) then read back to Postgres using Psychopg2 support for COPY FROM STDIN.