Install, build and debug a react native app in WSL2 (Windows Subsystem for Linux) and Ubuntu.
class IndexedDBStorage { | |
constructor(dbName = 'localStorageDB', storeName = 'localStorageStore') { | |
this.dbName = dbName; | |
this.storeName = storeName; | |
this._init(); | |
this.cache = {}; | |
} | |
_init() { | |
const request = window.indexedDB.open(this.dbName, 1); |
#!/bin/bash | |
set -o pipefail | |
KERNEL_WORKING_DIRECTORY="/usr/src" | |
KERNEL_VERSION=$(uname -r) | |
REQUIRED_DEPENDENCIES="git bison flex elfutils-libelf-devel openssl-devel" | |
KERNEL_SRC_DIR="$KERNEL_WORKING_DIRECTORY/WSL2-Linux-Kernel-$(uname -r)" | |
echo "Warning: This script has to be run on sudo permissions. If you encounter issues please report it immediately." |
# Setup QEMU for x86-64 Docker images on Raspberry Pi 4 | |
# Install Python3 and Docker first: https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl | |
# Install QUEMU (https://www.qemu.org/) | |
sudo apt-get install qemu binfmt-support qemu-user-static | |
# Use QUS in Docker (https://github.com/dbhi/qus) to configure x86_64 architecture | |
docker run --rm --privileged aptman/qus -s -- -p x86_64 | |
# Test x86-64 image: |
# First let's update all the packages to the latest ones with the following command | |
sudo apt update -qq | |
# Now we want to install some prerequisite packages which will let us use HTTPS over apt | |
sudo apt install apt-transport-https ca-certificates curl software-properties-common -qq | |
# After that we will add the GPG key for the official Docker repository to the system | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
# We will add the Docker repository to our APT sources |
const fs = require('fs'); | |
const fetch = require('node-fetch'); | |
const FormData = require('form-data'); | |
const filePath = `path/to/file.ext`; | |
const form = new FormData(); | |
const stats = fs.statSync(filePath); | |
const fileSizeInBytes = stats.size; | |
const fileStream = fs.createReadStream(filePath); | |
form.append('field-name', fileStream, { knownLength: fileSizeInBytes }); |
-
When writing a string of multiple utility classes, always do so in an order with meaning. The "Concentric CSS" approach works well with utility classes (i.e,. 1. positioning/visibility 2. box model 3. borders 4. backgrounds 5. typography 6. other visual adjustments). Once you establish a familiar pattern of ordering, parsing through long strings of utility classes will become much, much faster so a little more effort up front goes a long way!
-
Always use fewer utility classes when possible. For example, use
mx-2
instead ofml-2 mr-2
and don't be afraid to use the simplerp-4 lg:pt-8
instead of the longer, more complicatedpt-4 lg:pt-8 pr-4 pb-4 pl-4
. -
Prefix all utility classes that will only apply at a certain breakpoint with that breakpoint's prefix. For example, use
block lg:flex lg:flex-col lg:justify-center
instead ofblock lg:flex flex-col justify-center
to make it very clear that the flexbox utilities are only applicable at the
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')): | |
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering | |
Args: | |
logits: logits distribution shape (vocabulary size) | |
top_k >0: keep only top k tokens with highest probability (top-k filtering). | |
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering). | |
Nucleus filtering is described in Holtzman et al. (http://arxiv.org/abs/1904.09751) | |
""" | |
assert logits.dim() == 1 # batch size 1 for now - could be updated for more but the code would be less clear | |
top_k = min(top_k, logits.size(-1)) # Safety check |
In needed include base64 encoded simple image into HTML page in two formats:
1st as PNG format has length 196 characters and looks like this:
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAWElEQVR42mNkwA/qgbgRnwJGAgb8BwI7RkbGw5QYUAs0oGXUAPwGgKKqgYF0ANLTyAi1xhZI2WOYzsjYDJTbC2QewGHIwcERBsPcgHqgAX8pMQAcxfhyIwATTkxL+hgX2QAAAABJRU5ErkJggg==
2nd as CUR format has length 1536 characters and looks like this:
`AAACAAEAEBAAAAcABwBoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///z0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////3wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
#!/usr/bin/env bash | |
if [[ $UID != 0 ]]; | |
then | |
echo "Please run this script with sudo or as root:" | |
echo | |
echo "sudo $0 $*" | |
exit 1 || return 1 | |
fi |