Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathis Gauthey mathisgauthey

View GitHub Profile
@mathisgauthey
mathisgauthey / download_subreddit_wiki.sh
Created August 8, 2022 13:11
This bash script helps downloading a whole subreddit wiki. Thanks to u/ThePixelHunter (https://www.reddit.com/user/ThePixelHunter/) for the original script adapted to work on Windows machine with added line 10.
View download_subreddit_wiki.sh
#! /bin/bash
set -x
# Requires: bash coreutils curl jq
USER_AGENT='superagent/1.0'
EXPORTDIR="exports"
while read -r line; do
SUBREDDIT="$line"
SUBREDDIT=`echo $SUBREDDIT | sed 's/\\r//g'`
@mathisgauthey
mathisgauthey / sync_script.sh
Created August 5, 2022 09:33
Bash script to sync Obsidian with Git on android with Termux Widget
View sync_script.sh
#!/bin/bash
cd storage/shared/LifeWiki
git pull && git add -A && git commit -a -m "android vault backup: `date +'%Y-%m-%d %H-%M-%S'`" && git pull
@mathisgauthey
mathisgauthey / compare_loop_in_list.py
Created June 30, 2022 14:54
Compare execution time of different lists in python.
View compare_loop_in_list.py
master='''
data=[2*x for x in range(10000)]
'''
test1='''
for i in range(len(data)):
data[i]=data[i]*5
'''
test2='''
@mathisgauthey
mathisgauthey / list_of_list_initialisation_problem.py
Created June 30, 2022 12:59
Problem I had with the lists of lists in python. I had a big folder, with 14 subfolders and each 3 or 7 csv files. I got the list of all the csv paths, and the list of folder names. My goal was to create a folder list, including a list of csv path. And another folder list including a list of csv panda dataframes. When initializing, I used the sa…
View list_of_list_initialisation_problem.py
# Storing every csv found in PATH dir (including subfolders) in a list
EXT = "*.csv"
all_csv_path = [file
for path, subdir, files in os.walk(PATH)
for file in glob(os.path.join(path, EXT))]
# Creating the poteau/lisse couple we ran Ansys analysis on
couple = [
"port_4_lis_1_pot_IPE360_lis_IPE120",
"port_4_lis_1_pot_IPE360_lis_IPE180",
@mathisgauthey
mathisgauthey / replace_space_by_underscore.sh
Created June 28, 2022 18:40
Script that replaces spaces in filenames by an underscore
View replace_space_by_underscore.sh
for file in *
do
mv "${file}" "${file// /_}"
done
View copy_and_rename_files_by_ext.sh
for file in *.ans.txt
do
cp "$file" "${file%.ans.txt}.dat"
done
@mathisgauthey
mathisgauthey / ANSYS_KILLER.bat
Created June 20, 2022 12:42
Tired of ANSYS APDL crashing and manually killing processes to relaunch your model ? Kill them all, fast.
View ANSYS_KILLER.bat
taskkill /F /IM ANSYS.exe
@mathisgauthey
mathisgauthey / clean_by_ext.sh
Last active June 23, 2022 08:44
Remove files in current directory and subdirectories by specifying extensions
View clean_by_ext.sh
myExt="bat page tmp DSP esav ldhi mntr rdb rst err log r001 out full s01 s02 rsx mlv XML lock bak"
for ext in $myExt;
do
find . -name "*.$ext" -type f
done
echo
read -p "Do you want to remove these ? (y/n)" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then