Skip to content

Instantly share code, notes, and snippets.

@wayhoww
wayhoww / Dockerfile
Last active July 20, 2024 06:05
Dockerfile for Cloud ML
FROM runpod/pytorch:2.2.1-py3.10-cuda12.1.1-devel-ubuntu22.04
RUN apt-get update -y \
&& apt-get install -y htop jq gh vim git-lfs tmux tree \
&& git lfs install \
&& curl -L 'https://code.visualstudio.com/sha/download?build=stable&os=cli-alpine-x64' --output /tmp/vscode_cli.tar.gz \
&& tar -xf /tmp/vscode_cli.tar.gz -C /usr/bin --no-same-owner \
&& rm /tmp/vscode_cli.tar.gz \
&& curl -L 'https://gist.github.com/wayhoww/8ebbcf31d95ae66c9828e3fba6866dfd/raw' --output /usr/bin/sendmail \
&& chmod +x /usr/bin/sendmail \
@wayhoww
wayhoww / sendmail.py
Last active July 19, 2024 00:24
Send email via SMTP. It works with Gmail.
#!/usr/bin/env python3
import smtplib
import argparse
import os
import sys
def send_email(
host: str,
username: str,
#!/bin/bash
apt-get update -y && apt-get install htop jq -y
name=$(curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.runpod.io/graphql?api_key='$RUNPOD_API_KEY \
--data '{"query": "query Pod { pod(input: {podId: \"'$RUNPOD_POD_ID'\"}) { name } }"}')
name=$(echo $name | jq -r '.data.pod.name')
@wayhoww
wayhoww / select-cuda.sh
Last active May 26, 2024 13:47
A bash script used to select one or multiple free CUDA device(s).
#!/bin/bash
# Usage:
# source ./select-cuda.sh [-c <cnt>] [-f]
# -c cnt: count of GPUs that you want to use
# -f : select a GPU even it's being used
#
# Source this file everytime before running your ML scripts.
count=1
force=0
"""
pip install watchdog
watchmedo tricks tricks.yaml
tricks.yaml
-----------
tricks:
- autocompile.AutoCompileTrick:
patterns: ["*"]
@wayhoww
wayhoww / converter.h
Created January 3, 2021 16:18
Boost.Python: Automatical Type Conversion
/**
* For Boost.Python
*
* Automatically convert between Python list, dict, tuple and C++ STL std::vector, std::map, std::tuple, respectively.
* --------------------------------------
* 自动转换 Python 和 STL 的几个常用数据类型。
*
* I am familiar with neither metaprogramming nor Boost.Python. This header works but I believe
* there are better ways (or even existing libraries) to do these conversions. Please comment at
* this page to help me improve it.
@wayhoww
wayhoww / simpleio.rs
Created July 18, 2020 16:28
simple code for reading integers and floats from stdin in Rust, for OI/ICPC/Codeforces players
/*
How to use it:
let stdin = std::io::stdin();
let (a, b): (i32, f64) = stdin.tuple_2();
let v: Vec<i32> = stdin.line();
let v: std::collections::BTreeSet<i32> = stdin.line();
let s: i32 = stdin.scalar();
let s: f64 = stdin.scalar();
diff --git a/CMakeMain.txt b/CMakeMain.txt
index 1c75719..c403f1e 100644
--- a/CMakeMain.txt
+++ b/CMakeMain.txt
@@ -6,7 +6,7 @@
project(${ELEMENTS_APP_PROJECT} LANGUAGES CXX)
-if (UNIX AND NOT APPLE)
+if (UNIX AND NOT APPLE OR MINGW)