This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### VISUAL TERMINAL SETTINGS | |
############################ | |
# Configure prompt | |
EMOJIS=("🌮" "🍍" "🎉" "🚀") | |
DEFAULT_EMOJI=${EMOJIS[$RANDOM % ${#EMOJIS[@]} ]} | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import typing as t | |
import pickle | |
import os | |
import numpy as np | |
from tqdm import tqdm | |
from sklearn.neighbors import BallTree | |
# The embedded word vectors that work with this gist can be downloaded at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from statistics import mean | |
from math import sqrt | |
from functools import reduce | |
from sentence_transformers import SentenceTransformer | |
import numpy as np | |
from scipy.spatial.distance import cosine | |
model = SentenceTransformer("distilbert-base-nli-stsb-mean-tokens") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Register the Ubuntu Nvidia PPA | |
add-apt-repository ppa:graphics-driver/ppa | |
apt update | |
ubuntu-drivers autoinstall | |
# Restart the machine | |
reboot | |
# Then, once rebooted... | |
# Install the latest toolkit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ENVIRONMENT | |
############# | |
cd ~ | |
mkdir code | |
mkdir code/sandbox | |
# Make desktop environment clock be AM/PM instead of 24h. | |
gsettings set org.gnome.desktop.interface clock-format '12h' | |
# DEVELOPER ESSENTIALS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Error-handling middleware for the docker-compose CLI. Greps through the stdout of a docker-compose command, | |
finding the highest exit code produced by any services that exited prematurely. After docker-compose | |
exits, prints the message associated with that highest code then exits with that code. Useful | |
when you want to exit with an error code if *any* of your containers fail, and not just if the one | |
specified by `--exit-code-from` fails. | |
Example usage: | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_storage_bucket" "my_bucket" { | |
name = "my-unique-bucket-name" | |
cors { | |
origin = ["*"] | |
method = ["*"] | |
response_header = [ | |
"Content-Type", | |
"Access-Control-Allow-Origin", | |
"X-Goog-Content-Length-Range" | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "google_storage_bucket_iam_member" "bucket_admin" { | |
bucket = google_storage_bucket.my_bucket.name | |
role = "roles/storage.admin" # this includes the `roles/storage.objectCreator` role | |
member = "serviceAccount:${google_service_account.my_service_account.email}" | |
} | |
resource "google_project_iam_member" "token_creator" { | |
project = "my-gcp-project" | |
role = "roles/iam.serviceAccountTokenCreator" | |
member = "serviceAccount:${google_service_account.my_service_account.email}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
from datetime import timedelta | |
from google import auth | |
from google.auth.transport import requests | |
from google.cloud.storage import Client | |
def make_signed_upload_url( | |
bucket: str, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from "axios"; | |
const uploadFile = async ( | |
file: File, | |
signedUrl: string | |
): Promise<void> => { | |
await axios.put(signedUrl.replace(/"/g, ""), file, { | |
headers: { | |
"Content-Type": "application/octet-stream", | |
"X-Goog-Content-Length-Range": "1,1000000" |
OlderNewer