Skip to content

Instantly share code, notes, and snippets.

View BlueskyFR's full-sized avatar

Hugo Cartigny BlueskyFR

View GitHub Profile
import debug from "debug";
import type { Sensor } from "./types";
let dbg = debug("sauter:LineProtocol");
// Log to stdout instead of stderr by default
dbg.log = console.log.bind(console);
// Escape special chars depending on the field (see https://is.gd/wdaALB)
const escape = {
@BlueskyFR
BlueskyFR / git-smart-rebase
Last active July 2, 2024 14:50
Rebases a branch and manages history when the target branch rebases itself off another one
#!/usr/bin/env bash
# Fail on first non-zero exit code
set -e
setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
@BlueskyFR
BlueskyFR / via-PKGBUILD.patch
Last active July 18, 2023 09:48
Patch to upgrade the Via AUR package (Aruba VPN) to v4.5
diff --git a/PKGBUILD b/PKGBUILD
index 6cecc0f..72c3be0 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
# Maintainer: Matthew Hiles <[email protected]>
pkgname=via
-pkgver=4.2.0.2105106
-pkgrel=4
+pkgver=4.5.0.2301032

Conda CUDA environnement that takes precedence over the host's

The following is a code snippet that installs torch along with a full cuda environment that takes precedence over the host's. The only problem is that $TORCH_VERSION must be compatible with/compiled against $CUDA_VERSION, and the latter should be available in conda's nvidia channel (older CUDA versions are not available).

ENV_NAME=segformer CUDA_VERSION=11.1 TORCH_VERSION=1.9 cli=mamba
$cli deactivate
$cli env remove -n $ENV_NAME
$cli create -n $ENV_NAME -c conda-forge -c nvidia python=3.10 gcc=11 gxx cuda-runtime=$CUDA_VERSION cuda-nvcc=$CUDA_VERSION cudatoolkit=$CUDA_VERSION cuda-libraries=$CUDA_VERSION cuda-libraries-dev=$CUDA_VERSION cuda-cudart=$CUDA_VERSION cudnn &amp;&amp; \
@BlueskyFR
BlueskyFR / glossary.typ
Last active March 25, 2024 14:26
A glossary for Typst that uses native functions!
// Glossary code by Hugo Cartigny (BlueskyFR) 🍉
#let glossary(indent-defs: false, doc) = {
// ✨ The glossary displays its items using level 99 headings
let glossary = state("wow", (:))
// Hide the numbering for level 99 titles
show heading.where(level: 99): it => text(weight: "regular", it.body)
let page-refs-color = rgb("#7630EA")
@BlueskyFR
BlueskyFR / proxy.sh
Last active June 5, 2023 12:53
Linux live proxy patcher - A bash script that patches all running processes using GDB to either enable or disable proxy. Manage your proxy's state without having to logout anymore! You may have to restart your browser though :D
#!/bin/bash
# The proxy url to use when enabled
proxy=http://<proxy_ip>:<proxy_port>/
# -----------------------------------------------------
# Set proxy to "" if arg is "off"
# If arg is neither "on" or "off", exit
[[ $1 = "off" ]] && proxy= || ([[ $1 = "on" ]] || exit)
# To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# %%
import time
global_start_time = time.time()
# %%
import tensorflow as tf
print(f"✨ Using TensorFlow {tf.__version__}!")
for device in tf.config.experimental.list_physical_devices('GPU'):