k4d3 commited on
Commit
eb1fe03
1 Parent(s): 6ec5189

zsh and remove_boys update

Browse files

Signed-off-by: Balazs Horvath <acsipont@gmail.com>

Files changed (2) hide show
  1. .zshrc +32 -0
  2. remove_boys +39 -0
.zshrc CHANGED
@@ -1,3 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  export LANG=ja_JP.UTF-8
2
  export LC_ALL=ja_JP.UTF-8
3
 
 
1
+ alias ezc="nvim ~/.zshrc && source ~/.zshrc"
2
+
3
+ # This function, `update_conda`, automates the process of upgrading all packages in every conda environment.
4
+ # It performs the following steps:
5
+ # 1. Retrieves the list of all conda environments using `conda env list` and extracts their names.
6
+ # 2. Iterates through each environment name.
7
+ # 3. Activates each environment using `conda activate`.
8
+ # 4. Upgrades all packages in the activated environment using `conda upgrade --all -y`.
9
+ # 5. Deactivates the environment using `conda deactivate`.
10
+ # 6. Prints a message indicating that all environments have been upgraded.
11
+ #
12
+ # Note: This script assumes that the user has the necessary permissions to activate and deactivate conda environments.
13
+ # It also assumes that `conda` is installed and properly configured in the user's PATH.
14
+ #
15
+ # Usage:
16
+ # Simply call the `update_conda` function in your shell to upgrade all packages in all conda environments.
17
+ update_conda() {
18
+ # Get the list of all conda environments
19
+ envs=$(conda env list | awk '{print $1}' | tail -n +4)
20
+
21
+ # Loop through each environment and run conda upgrade --all
22
+ for env in $envs; do
23
+ echo "Activating environment: $env"
24
+ source activate $env
25
+ echo "Upgrading all packages in environment: $env"
26
+ conda upgrade --all -y
27
+ conda deactivate
28
+ done
29
+
30
+ echo "All environments have been upgraded."
31
+ }
32
+
33
  export LANG=ja_JP.UTF-8
34
  export LC_ALL=ja_JP.UTF-8
35
 
remove_boys ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ import os
4
+ import re
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ def remove_boys(target_dir='.'):
9
+ # Use pathlib to handle the directory
10
+ target_path = Path(target_dir)
11
+
12
+ # Walk through the directory and its subdirectories using glob
13
+ for file_path in target_path.rglob('*.txt'):
14
+ with open(file_path, 'r+', encoding='utf-8') as f:
15
+ content = f.read()
16
+ # Remove occurrences of [1-9]boy, [1-9]boys, [1-9]girl, and [1-9]girls along with a comma and space character
17
+ content = re.sub(r',\s*([1-9]boy|[1-9]boys|[1-9]girl|[1-9]girls)', '', content)
18
+ # Remove any remaining occurrences of the tags without the comma and space
19
+ content = re.sub(r'([1-9]boy|[1-9]boys|[1-9]girl|[1-9]girls)', '', content)
20
+ # Remove any trailing spaces and commas
21
+ content = re.sub(r',\s*,', ',', content) # Remove double commas
22
+ content = re.sub(r',\s*$', '', content) # Remove trailing comma
23
+ content = re.sub(r'^\s*,', '', content) # Remove leading comma
24
+ content = re.sub(r'\s*,\s*', ', ', content) # Normalize comma spacing
25
+ # Remove any leftover commas at the end of the line
26
+ content = re.sub(r',\s*$', '', content)
27
+ # Remove any leftover commas at the beginning of the line
28
+ content = re.sub(r'^\s*,', '', content)
29
+ # Remove any leftover commas in the middle of the line
30
+ content = re.sub(r',\s*,', ',', content)
31
+ f.seek(0)
32
+ f.write(content)
33
+ f.truncate()
34
+
35
+ if __name__ == "__main__":
36
+ # Get the directory from the command line argument or use the current directory
37
+ target_dir = sys.argv[1] if len(sys.argv) > 1 else '.'
38
+ remove_boys(target_dir)
39
+