Managing conda environments

Managing conda environments

Method 1

1
conda activate <environment_name>
1
vi $(dirname $(which python))/../etc/conda/activate.d/env_vars.sh
1
2
3
4
#!/bin/bash

export OLD_PATH=$PATH
export PATH=***:$PATH
1
vi $(dirname $(which conda))/../etc/conda/deactivate.d/env_vars.sh
1
2
3
4
#!/bin/bash

export PATH=$OLD_PATH
unset OLD_PATH

Method 2 (didn’t test)

1
2
3
4
5
6
7
conda activate <environment_name>
conda env config vars set <variable_name>=<value>
conda env config vars set <variable_name>=<value>
...
conda env config vars set <variable_name>=<value>
conda env export --no-builds > environment.yml
conda deactivate

debug matlab mex on linux

debug matlab mex on linux

mex it

  • An example: ELSDc
  • src/mexall.m
  • -g for debug, -l for function dsyev

debug

  • su to act as a root
  • code --no-sandbox ----user-data-dir /home/zihanwu7/tmp
  • install LLDB extention
  • use attach form
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
// 使用 IntelliSense 以得知可用的屬性。
// 暫留以檢視現有屬性的描述。
// 如需詳細資訊,請瀏覽: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "attach",
"name": "Attach",
"pid": "${command:pickMyProcess}"
}
]
}
  • matlab -nosplash -nodesktop -debug
  • attach it and enjoy debugging!

answer

answer

Suppose $\sum_{i\in X} x_i$ is convergent, which means $|a - \sum_{i\in \Omega’} x_i| < \epsilon$ for any finite subset $\Omega \subset \Omega’ \subset X$.

Consider $\sum_{i\in X} |x_i|$,

$\forall \epsilon > 0$, since $\sum_{i\in X} x_i$ is convergent, there exists a finite subset $\Omega \subset X$ such that $|a - \sum_{i\in \Omega’} x_i| < \epsilon$ for any finite subset $\Omega \subset \Omega’ \subset X$.

Note $b = \sum_{i\in \Omega} |x_i|$, then

Consider

$$
\begin{align}
f: \omega &\mapsto \sum_{i\in \omega} x_i \
g: \omega &\mapsto \sum_{i\in \omega} |x_i| \
{\Omega’ \setminus \Omega &| \Omega \subset \Omega’ \subset X} \to \mathbb{R} \
\end{align}
$$

And since ${x_i}$ is given, $X \setminus \Omega$ can be divided into two subsets $X_1$ and $X_2$ such that $x_i \ge 0$ for $i \in X_1$ and $x_i < 0$ for $i \in X_2$.

Then define

$$
\begin{align}
f_+: \omega &\mapsto \sum_{i\in \omega \cap X_1} x_i \
f_-: \omega &\mapsto \sum_{i\in \omega \cap X_2} |x_i| \
\end{align}
$$

Then $f = f_+ - f_-$ and $g = f_+ + f_-$.

Then one can prove $\sup(2f) \ge \sup(g)$. And then verify

$$
\begin{align}
|b - \sup(g)| < 2\epsilon
\end{align}
$$

Notice: the $b$ part is wrong, since $b$ should not depend on $\Omega$.

Hugging Face Dataset

Hugging Face Dataset

This notebook explores the Hugging Face dataset library.

Introduction

The Hugging Face dataset library is a powerful tool for working with various datasets in natural language processing (NLP) tasks. It provides a wide range of preprocessed datasets that can be easily loaded and used for training and evaluation.

Installation

To use the Hugging Face dataset library, you need to install it first. You can install it using pip:

1
pip install datasets

set cache dir

1
export HF_DATASETS_CACHE=/your/path/to/cache

Using ifthen package in LaTeX

Using ifthen package in LaTeX

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
\RequirePackage{ifthen}
...
\newcommand{\mytitle}[2][maintex]{%
\ifthenelse{\equal{#1}{maintex}}{%
% Fixed style for the title
\title{%
% Top rule
\rule{\textwidth}{0.4pt} \\
\vspace{0.5cm}
\textbf{\uppercase{#2}} % Title content as argument
% Bottom rule
\rule{\textwidth}{0.4pt}
}
}{%
% Alternative style for the title
\title{\textbf{\large #2}}
}
}

The above code defines a command \mytitle that takes two arguments, the first one is optional and the second one is mandatory. The first argument is used to switch between two styles for the title. The second argument is the title content. There is a default value for the first argument, which is maintex. If the first argument is maintex, the title will be styled as a horizontal rule with the title content in uppercase. Otherwise, the title will be styled as a bold text with the title content in large font size.

install vscode without sudo

install vscode without sudo

  • wget https://az764295.vo.msecnd.net/stable/6445d93c81ebe42c4cbd7a60712e0b17d9463e97/vscode_cli_alpine_x64_cli.tar.gz
  • tar -xf vscode_cli_alpine_x64_cli.tar.gz

Open VPN

Open VPN

  1. install docker
    Note: check if daemon is running

    1
    sudo systemctl status docker
  2. install openvpn

    1
    2
    3
    4
    5
    6
    7
    8
    9
    OVPN_DATA="ovpn-zihan"
    docker volume create --name $OVPN_DATA
    docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://vpn.zihanng.shop
    docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
    docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
    # or
    # docker run --privileged -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp kylemanna/openvpn
    docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full zihan nopass
    docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient zihan > zihan.ovpn
  3. pull the zihan.ovpn file to local machine

    1
    rsync -avzP zihan_aws:zihan.ovpn .

Linux solve `policykit-1.service`

Linux solve policykit-1.service: Two services allocated for the same bus name org.freedesktop.PolicyKit1, refusing operation.

1
sudo systemctl mask --now polkit.service

sudo systemctl unmask polkit.service

sudo apt install libpolkit-qt5-1-1

sudo apt-get install -y meson ninja-build

sudo apt-get install libglib2.0-dev

sudo apt-get install libexpat1-dev

sudo apt-get install duktape-dev

sudo apt-get install libpam0g-dev

sudo apt-get install libgirepository1.0-dev

sudo apt-get install libdbus-1-dev

Try

  • /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf > /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf_old
  • /usr/share/dbus-1/system.d/org.freedesktop.PolicyKit1.conf > /usr/share/dbus-1/system.d/org.freedesktop.PolicyKit1.conf_old
  • sudo cp /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf_old
  • sudo cp /usr/share/dbus-1/system.d/org.freedesktop.PolicyKit1.conf /etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf

Try 2

  • root@zihanwu7-Precision-3630-Tower:/usr/lib/systemd/system# mv policykit-1.service policykit-1.service_bak
  • /usr/lib/systemd/system/polkit.service:7:BusName=org.freedesktop.PolicyKit1