Skip to content

Instantly share code, notes, and snippets.

View YouJiacheng's full-sized avatar

You Jiacheng YouJiacheng

  • IIIS, Tsinghua University
  • Beijing, China
View GitHub Profile
@YouJiacheng
YouJiacheng / osxvpnrouting.markdown
Created September 2, 2022 12:38 — forked from taldanzig/osxvpnrouting.markdown
Routing tips for VPNs on OS X

Routing tips for VPNs on OS X

When VPNs Just Work™, they're a fantastic way of allowing access to a private network from remote locations. When they don't work it can be an experience in frustration. I've had situations where I can connect to a VPN from my Mac, but various networking situations cause routing conflicts. Here are a couple of cases and how I've been able to get around them.

Specific cases

Case 1: conflicting additional routes.

In this example the VPN we are connecting to has a subnet that does not conflict with our local IP, but has additional routes that conflict in some way with our local network's routing. In my example the remote subnet is 10.0.x.0/24, my local subnet is 10.0.y.0/24, and the conflicting route is 10.0.0.0/8. Without the later route, I can't access all hosts on the VPN without manually adding the route after connecting to the VPN:

INFO global: Vagrant version: 2.3.3
INFO global: Ruby version: 2.7.6
INFO global: RubyGems version: 3.1.6
INFO global: VAGRANT_EXECUTABLE="C:\\HashiCorp\\Vagrant\\embedded\\gems\\2.3.3\\gems\\vagrant-2.3.3\\bin\\vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="C:\\HashiCorp\\Vagrant\\embedded"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_LOG="debug"
WARN global: resolv replacement has not been enabled!
DEBUG global: Loading core plugin: C:/HashiCorp/Vagrant/embedded/gems/2.3.3/gems/vagrant-2.3.3/plugins/commands/autocomplete/plugi
@YouJiacheng
YouJiacheng / f-str.py
Last active September 26, 2024 14:34
from dataclasses import dataclass
class Default(dict[str, str]):
def __missing__(self, key: str):
return f"{{{key}}}"
@dataclass
class Pair:
import os
import base64
# dynamically generated at test time
A_identifier = base64.urlsafe_b64encode(os.urandom(6)).decode()
B_identifier = base64.urlsafe_b64encode(os.urandom(6)).decode()
meta_prompt = f"""
import os
from typing import cast
import torch
import torch._inductor.config as config
import torch.distributed as dist
def zeropower_via_newtonschulz5(G, steps=10, eps=1e-7) -> torch.Tensor: ...
import torch
from torch.distributed.device_mesh import init_device_mesh
from torch.distributed.tensor import DTensor, Shard
mesh_1d = init_device_mesh("cuda", (4,), mesh_dim_names=("shard",))
rank = mesh_1d.get_rank()
dtensors: list[DTensor] = []
import torch
import torch.utils.benchmark as benchmark
def benchmark_in_us(f, *args, **kwargs):
t0 = benchmark.Timer(
stmt="f(*args, **kwargs)", globals={"args": args, "kwargs": kwargs, "f": f}
)
return t0.blocked_autorange().mean * 1e6
import os
import sys
import torch._dynamo.compiled_autograd
with open(sys.argv[0]) as f:
code = f.read() # read the code of this file ASAP, for logging
import uuid
import glob
import time