Skip to content

Instantly share code, notes, and snippets.

@vicyap
vicyap / index.html
Created September 6, 2023 16:46
HTML/CSS Whitespace Examples
<html>
<body>
<div style="background-color: #cccccc">
<!--
The <p> element is a block element. White space around it is effectively ignored.
Block elements are laid out in the direction of the document, in this case that
is top to bottom.
-->
@vicyap
vicyap / lxd-lxc-macos_setup.txt
Last active December 28, 2023 22:19
Setup lxd/lxc on MacOS with multipass
~ 17:47:44
❯ alias mp=multipass
~ 17:47:47
❯ mp launch -n lxd -c 2 -m 4G -d 40G
Launched: lxd
~ 21s 17:48:15
❯ mp shell lxd
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-120-generic aarch64)
@vicyap
vicyap / boto3_auto_refresh_session.py
Created June 15, 2022 16:14
A boto3 Session Factory that creates sessions that auto refresh their credentials. Primarily intended for assuming a role, since assume role credentials expire.
from boto3 import Session
from botocore.credentials import RefreshableCredentials
from botocore.session import get_session
class AutoRefreshSessionFactory:
"""A Factory that creates boto3.Session sessions that auto refresh their credentials.
Primarily intended for assuming a role, since assume role credentials expire.
"""
@vicyap
vicyap / _ray-operator.log with 0 initial pods
Last active February 9, 2022 23:52
debugging logs for https://github.com/ray-project/ray/issues/22122 with Kubernetes v1.22.5 running through Docker Desktop 4.4.2
# with 0 initial worker pods, the resource demand jumps to 200+ pending
# but once a worker pod is connected, the resource demand goes to 10+ pending
# see lines 225, 332 which have 200+ pending
# then line 1019 which has 10+ pending
ray-cluster,default:2022-02-09 15:21:55,711 INFO monitor.py:521 -- Logging raw resource message pulled from GCS.
ray-cluster,default:2022-02-09 15:21:55,711 INFO monitor.py:522 -- batch {
node_id: "\215\336\277\207<\'\201.[\323\220Ul6\026ba\212\353@\322\202|\212\321\005;0"
resources_available {
key: "memory"
import ray
import time
import logging
ray.init(address="auto", logging_level=logging.DEBUG)
remote_args = {
"num_cpus": 1,
"num_gpus": None,
"max_calls": 0,
"max_retries": 3,
import ray
import time
import logging
ray.init(address="auto", logging_level=logging.DEBUG)
remote_args = {
"num_cpus": 1,
"num_gpus": None,
"max_calls": 0,
"max_retries": 3,
import logging
import ray
@ray.remote
def task():
import time
time.sleep(30)
======== Autoscaler status: 2022-02-08 09:02:10.177916 ========
Node status
---------------------------------------------------------------
Healthy:
1 head
1 wkr-15cpu30g-ondemand
Pending:
(no pending nodes)
Recent failures:
(no failures)
from pprint import pprint
import ray
ray.init("ray://mycluster.internal:10001")
@ray.remote
def task():
import time
time.sleep(30)
@vicyap
vicyap / karpenter-launch-templates.tf
Created January 19, 2022 16:35
Karpenter with Custom Launch Templates
data "aws_ami" "aws_eks_gpu_optimized" {
owners = ["602401143452"]
most_recent = true
filter {
name = "name"
values = ["amazon-eks-gpu-node-${var.eks_cluster_version}-v20220112*"]
}
}