3.8
13 Dec, 2019
19.2.3
// Basic public access | |
service cloud.firestore { | |
match /databases/{database}/documents { | |
match /{document=**} { | |
allow read, write: if true; | |
} | |
} | |
} |
const { Firestore } = require('@google-cloud/firestore'); | |
const firestore = new Firestore(); | |
const INVENTORY_COLLECTION = 'inventory'; | |
async function updateInventory(productId, quantityChange) { | |
const productRef = firestore.collection(INVENTORY_COLLECTION).doc(productId); | |
try { | |
await firestore.runTransaction(async (transaction) => { |
from django.contrib import admin | |
from .models import ModelName | |
class CustomModelAdmin(admin.ModelAdmin): | |
def __init__(self, model, admin_site): | |
self.list_display = [field.name for field in model._meta.fields] | |
super(CustomModelAdmin, self).__init__(model, admin_site) |
import librosa | |
import soundfile as sf | |
filepath = "sample.wav" | |
y, s = librosa.load(filepath, sr=16000) | |
sf.write(filepath, y, s) |
## Python Websockets SSL with Lets Encrypt | |
This code uses the `python-websockets` library. | |
You'll need to generate the certificate and keyfile using Let's Encrypt. | |
After generating the files correctly, you need to make them accessible to the current user who runs the script, my way of doing this was to copy it to the home directory of the current user and change the owner to the current user, set the permissions of the files to 400. | |
To know more about this process, read the blog here - https://xprilion.com/python-websockets-ssl-with-lets-encrypt/ |
import nltk | |
import ssl | |
try: | |
_create_unverified_https_context = ssl._create_unverified_context | |
except AttributeError: | |
pass | |
else: | |
ssl._create_default_https_context = _create_unverified_https_context |
def cm(cf): | |
tn = cf[0][0] | |
fp = cf[0][1] | |
fn = cf[1][0] | |
tp = cf[1][1] | |
print("TP: %d\nTN: %d" % (tp, tn)) | |
print("FP: %d\nFN: %d" % (fp, fn)) |
[ | |
{ | |
"sepal_length": 5.1, | |
"sepal_width": 3.5, | |
"petal_length": 1.4, | |
"petal_width": 0.2, | |
"species": "setosa" | |
}, | |
{ | |
"sepal_length": 4.9, |
<?php | |
/* * | |
* @filename downloader.class.php | |
* @author PsyKzz | |
* @edited_by xprilion | |
* @version 2.0.0 | |
* @description Simple class to rate limit your downloads, while also providing a custom tickrate to combat timeout issues. | |
* @url http://www.psykzz.co.uk | |
* @url https://xprilion.com | |
* |