Skip to content

Instantly share code, notes, and snippets.

```dataviewjs
// find dates based on format [[YYYY-MM-DD]]
const findDated = (task)=>{
if( !task.completed ) {
task.link = " " + "[[" + task.path + "|*]]";
task.date="";
const found = task.text.match(/\[\[([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))\]\]/);
if(found) task.date = moment(found[1]);
return true;
}
@hgascon
hgascon / curl_cookies.txt
Created March 15, 2022 14:18
Download a file/site with cookies with curl
Use google chrome, activate the developer tools and go to the network
tab. Request the file/site and see it in the list. Right button shows "Copy
as cURL"
@hgascon
hgascon / unzip_all.sh
Created March 15, 2022 14:16
Unzip all files in a dir and zip in a new file
for item in *
do
unzip $item
name=$(echo $item | cut -f1 -d ' ' )
echo "all_files.zip" $name".ext"
done
@hgascon
hgascon / decompress_gzip_no_ext.sh
Created March 15, 2022 14:15
Decompress gzip files without .gz extension
gzip -d "" -f gzippe_file
# for several files under several directories:
for item in $(ls -d -1 $PWD/##/#); do echo $item; zcat $item > temp; sed -i 's/, / /g' temp; gzip temp; mv temp.gz $item; done;
@hgascon
hgascon / move_with_new_extension.sh
Last active March 15, 2022 14:14
Move files and files with new extension to new dir
for FILE in $(ls #.pckl); do
NAME=$(echo $FILE | cut -d '_' -f 1)
NAMEAPK=$NAME.apk
mv $FILE DONE/
mv $NAMEAPK DONE/
done
for FILE in $(ls #.pckl); do NAME=$(echo $FILE | cut -d '_' -f 1); NAMEAPK=$NAME.apk; mv $FILE DONE/; mv $NAMEAPK DONE/; done
@hgascon
hgascon / rename.sh
Created March 15, 2022 14:11
Rename files using substring of another file name
for FILE in $(ls | grep -v \\.); do
PCKL_FILE=$(echo ${file:0:60}.pckl)
NEW_PCKL_FILE=$FILE.pckl
mv $PCKL_FILE $NEW_PCKL_FILE
done
@hgascon
hgascon / move_too_many_files.sh
Created March 15, 2022 14:10
Move a very long list of files to a directory. Useful when $(ls) gives and error that the file list is too long.
find . -name "#.zip" -exec mv {} /dest_dir/ \;
@hgascon
hgascon / change_extensions.sh
Created March 15, 2022 14:08
Change extension to all files in a dir
find . -type f -exec mv '{}' '{}'.jpg \;
@hgascon
hgascon / clean_pdb_set_trace.py
Created March 15, 2022 14:06
Unset pydebugger breakpoint after stopping
(Pdb) pdb.set_trace = lambda: None # This replaces the set_trace() function!
@hgascon
hgascon / fast_rsync.sh
Created March 15, 2022 14:04
Very fast file copy between servers with rsync
rsync -aHAXxv --numeric-ids --progress -e "ssh -T -c arcfour -o Compression=no -x" user@<source>:<source_dir> <dest_dir>
# If it gives an error:
rsync -av --numeric-ids --progress -e "ssh -T -c arcfour -o Compression=no -x" user@<source>:<source_dir> <dest_dir>