Skip to content

Latest commit

 

History

History
2079 lines (1389 loc) · 54 KB

bash.md

File metadata and controls

2079 lines (1389 loc) · 54 KB

-----------------------------------------ZIP UTILS----------------------------------------------------------------------------------------- 4.)Recursive-unzip:()===>

find . -name "*.zip" | while read filename; do unzip -o -d "dirname "$filename"" "$filename"; done;

find . -name "*.zip" -type f -print -delete


Install node modules recursevly ( npm i -g recursive-install ):

npm-recursive-install ---------------------------------------------------Main Commands--------------------------------------------------------------------------- find . -empty -type d -print -delete OR find . -depth -exec rmdir {} ;

find . -empty -type f -print -delete

find . -empty -type d -print -delete

find . ( -name ".git" -o -name ".gitignore" -o -name ".gitmodules" -o -name ".gitattributes" ) -exec rm -rf -- {} +

find . ( -name "*SECURITY.txt" -o -name "*RELEASE.txt" -o -name "*CHANGELOG.txt" -o -name "*LICENSE.txt" -o -name "*CONTRIBUTING.txt" -name "*HISTORY.md" -o -name "*LICENSE" -o -name "*SECURITY.md" -o -name "*RELEASE.md" -o -name "*CHANGELOG.md" -o -name "*LICENSE.md" -o -name "*CODE_OF_CONDUCT.md" -o -name "*CONTRIBUTING.md" ) -exec rm -rf -- {} +

find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +

find . -name 'right.html' -type f -prune -exec rm -rf '{}' +

find . -name 'left.html' -type f -prune -exec rm -rf '{}' +

----------------------------------------------Remove Spaces In File/Folder Names-----------------------------------------------------------

find . -name "* " -type d | rename 's/ /_/g'
find . -name "
*" -type f | rename 's/ /_/g'

------------------------------------Truncate folder names down to 12 char------------------------------------------------------------------------

for d in *; do mv $d ${d:0:12}; done -------------------------------------Remove Numbers From File Names------------------------------------------------------------------------

find $dir -type f | sed 's|(./)[^a-z]([A-Z].*)|mv "&" "\1\2"|' | sh

find $dir -type d | sed 's|(./)[^a-z]([A-Z].*)|mv "&" "\1\2"|' | sh

for i in .html; do mv "$i" "${i%-}.html"; done

for i in .; do mv "$i" "${i%-}.${i##.}"; done

-------------------------------------FIND AND REPLACE IN STRING/FOLDER NAMES----------------------------------------------------------------

find . -type f -exec rename 's/string1/string2/g' {} +

find . -type d -exec rename 's/-master//g' {} +

rename 's/.js.download$/.js/' *.js.download

find . -type d -exec rename 's/es6//g' {} +


Remove double extensions :

#!/bin/bash

for file in *.html.html do mv "${file}" "${file%.html}" done

#!/bin/bash

for file in *.html.png do mv "${file}" "${file%.png}" done

#!/bin/bash

for file in *.md.md do mv "${file}" "${file%.md}" done

find . -type f -exec rename's/.js.download$/.js/' *.js.download ' {} +


clone all of a user's git repositories

CNTX={users}; NAME={xriley}; PAGE=1 curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=100" | grep -e 'git_url*' | cut -d " -f 4 | xargs -L1 git clone

CNTX={users}; NAME={bgoonz}; PAGE=1 curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=200"?branch=master | grep -e 'git_url*' | cut -d " -f 4 | xargs -L1 git clone

CNTX={organizations}; NAME={hasura}; PAGE=1 curl "https://api.github.com/$CNTX/$NAME/repos?page=$PAGE&per_page=200"?branch=master | grep -e 'git_url*' | cut -d " -f 4 | xargs -L1 git clone

Clone Orginization:

#!/bin/bash for i in $(curl "https://api.github.com/orgs/hasura/repos" | grep -oP '"clone_url":\s*"\K[^"]+'); do echo git clone "$i" done

Clone Orginization:

#!/bin/bash for i in $(curl "https://api.github.com/orgs/mdn/repos" | grep -oP '"clone_url":\s*"\K[^"]+'); do echo git clone "$i" done

#!/bin/bash for i in $(curl "https://api.github.com/orgs/chartjs/repos" | grep -oP '"clone_url":\s*"\K[^"]+'); do echo git clone "$i" done


tree -d -I 'node_modules'

tree -I 'node_modules'

tree -f -I 'node_modules' >TREE.md

tree -f >README.md

full path: tree -f ~/


find . -name *right.html -type f -exec sed -i 's/target="_parent"//g' {} +

find . -name *right.html -type f -exec sed -i 's/target="_parent"//g' {} +

sudo npm i prettier -g

prettier --write .

"pretty": "prettier --write "./*/.{js,jsx,py,md,html,css}""


find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + find . -name '.vscode' -type d -prune -exec rm -rf '{}' +


find ./ -iname "*.md" -type f -exec sh -c 'pandoc --standalone "${0}" -o "${0%.md}.html"' {} ;

find ./ -iname "*.html" -type f -exec sh -c 'pandoc --wrap=none --from html --to markdown_strict "${0}" -o "${0%.html}.md"' {} ;

find ./ -iname "*.docx" -type f -exec sh -c 'pandoc "${0}" -o "${0%.docx}.md"' {} ;


Remove lines contaning string:

sudo sed -i '/githubusercontent/d' ./*sandbox.md

sudo sed -i '/github.com/d' ./*out.md

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.min.js" integrity="sha384-j0CNLUeiqtyaRmlzUHCPZ+Gy5fQu0dQ6eZ/xAww941Ai1SxSY+0EQqNXNE6DZiVc" crossorigin="anonymous"></script>

https://bgoonz-blog.netlify.app/

<iframe id="inlineFrameExample" title="Inline Frame Example" frameborder="no" loading="lazy" allowtransparency="true" allowfullscreen="true" width="800" height="800" src="https://deploy-preview-5--jolly-austin-0c1a1d.netlify.app/organizer"> </iframe>

// schemas/documents/post.js

export default { type: "document", title: "Blog post", name: "post", fields: [ { type: "string", name: "title" }, { title: "Body", name: "body", type: "array", of: [{ type: "block" }] } ] };


https://repl.it/@bgoonz/PyScript-Docs?lite=true&amp;referrer=https%3A%2F%2Fbryanguner.medium.com


sudo sed -i '/stargazers/d' ./repo.txt sudo sed -i '/node_modules/d' ./index.html sudo sed -i '/right.html/d' ./index.html sudo sed -i '/right.html/d' ./right.html


zips directory excluding .git and node_modules all the way down (linux)

#!/bin/bash TSTAMP=date '+%Y%m%d-%H%M%S' zip -r $1.$TSTAMP.zip $1 -x "**.git/*" -x "**node_modules/*" shift; echo $@;

printf "\nCreated: $1.$TSTAMP.zip\n"

usage:

- zipdir thedir

- zip thedir -x "*anotherexcludedsubdir/" (important the double quotes to prevent glob expansion)

if in windows/git-bash, add 'zip' command this way:


Delete files contaning a certain string:

find . | xargs grep -l www.redhat.com | awk '{print "rm "$1}' > doit.sh vi doit.sh // check for murphy and his law source doit.sh


https://github.com/stackbit-projects/best-celery-b2d7c/commit/b423b88323a79d11e5979f92b0a185025b3ca86a ------------------------------------------------GIT--------------------------------------------------------- ------------------------------------------------GIT--------------------------------------------------------- ------------------------------------------------GIT---------------------------------------------------------

git init git add . git commit -m"update" git push -u origin master

git init git add . git commit -m"update" git push -u origin main

git init git add . git commit -m"update" git push -u origin bryan-guner

git init git add . git commit -m"update" git push -u origin preview


git pull keeping local changes:

git stash git pull git stash pop


Remove Submodules:

git submodule deinit


download up to 8 submodules at once

git submodule update --init --recursive --jobs 8

git clone --recursive --jobs 8 [URL to Git repo]

-------------------------------GET GISTS:

wget -q -O - https://api.github.com/users/bgoonz/gists | grep raw_url | awk -F" '{print $4}' | xargs -n3 wget

wget -q -O - https://api.github.com/users/drodsou/gists | grep raw_url | awk -F" '{print $4}' | xargs -n1 wget

wget -q -O - https://api.github.com/users/thomasmb/gists | grep raw_url | awk -F" '{print $4}' | xargs -n1 wget

wget -q -O - https://api.github.com/users/koraktor/gists | grep raw_url | awk -F" '{print $4}' | xargs -n1 wget

watch -n '100' "git pull && (git ls-files --modified --others --exclude-standard | grep . > /dev/null) && { git add . ; git commit -m '' ; git push; }"


git remote remove origin


just clone .git folder:

git clone --bare --branch=master --single-branch https://github.com/bgoonz/My-Web-Dev-Archive.git

Undo recent pull request: git reset --hard master@{"10 minutes ago"}


Open PowerShell and enter wslconfig.exe /l to confirm WSL is installed correctly and list the currently available Linux distributions within your system. Confirm a valid distribution has (default) next to it. To change the default distribution, enter wslconfig.exe /setdefault "distributionNameAsShownInList" The terminal not working when running the 32-bit Windows client on 64-bit Windows?# The easy fix for this issue is to use the 64-bit version. If you must use the 32-bit version, you need to use the sysnative path when configuring your shell path instead of System32. Adding this setting should fix the issue:

"terminal.integrated.shell.windows": "C:\Windows\Sysnative\cmd.exe",

To remove a submodule you need to:

Delete the relevant section from the .gitmodules file. Stage the .gitmodules changes git add .gitmodules Delete the relevant section from .git/config. Run git rm --cached path_to_submodule (no trailing slash). Run rm -rf .git/modules/path_to_submodule (no trailing slash). Commit git commit -m "Removed submodule " Delete the now untracked submodule files rm -rf path_to_submodule ----------------------------------------Lebab----------------------------------------------------------------- safe:

lebab --replace ./ --transform arrow lebab --replace ./ --transform arrow-return lebab --replace ./ --transform for-of lebab --replace ./ --transform for-each lebab --replace ./ --transform arg-rest lebab --replace ./ --transform arg-spread lebab --replace ./ --transform obj-method lebab --replace ./ --transform obj-shorthand lebab --replace ./ --transform multi-var

ALL:

lebab --replace ./ --transform obj-method lebab --replace ./ --transform class lebab --replace ./ --transform arrow lebab --replace ./ --transform let lebab --replace ./ --transform arg-spread lebab --replace ./ --transform arg-rest lebab --replace ./ --transform for-each lebab --replace ./ --transform for-of lebab --replace ./ --transform commonjs lebab --replace ./ --transform exponent lebab --replace ./ --transform multi-var lebab --replace ./ --transform template lebab --replace ./ --transform default-param lebab --replace ./ --transform destruct-param lebab --replace ./ --transform includes lebab --replace ./ --transform obj-method lebab --replace ./ --transform class lebab --replace ./ --transform arrow lebab --replace ./ --transform arg-spread lebab --replace ./ --transform arg-rest lebab --replace ./ --transform for-each lebab --replace ./ --transform for-of lebab --replace ./ --transform commonjs lebab --replace ./ --transform exponent lebab --replace ./ --transform multi-var lebab --replace ./ --transform template lebab --replace ./ --transform default-param lebab --replace ./ --transform destruct-param lebab --replace ./ --transform includes

npm i @bgoonz11/repoutils

---------------------------------------Trouble Shooting------------------------------------------------------------------ input/Output error

wsl.exe --shutdown Get-Service LxssManager | Restart-Service


Fudge2312!

IP: 173.70.97.51

Log into postgres: sudo -u postgres psql -------------------------------------------------------------Symbolic Link-------------------------------------------- sudo ln -s ./mnt/c/MY-WEB-DEV

ln -s "$(pwd)" ~/NameOfLink

ln -s "$(pwd)" ~/Downloads

return to bash from zsh sudo apt --purge remove zsh

cat w07_data-structures-and-algorithms.md* | codedown javascript > code.js

cat README.md* | codedown javascript > code.js cat interview Questions.md* | codedown javascript > code.js cat README.md* | codedown javascript > code.js

cat w08_getting-to-know-the-network.html* | codedown javascript > code.js

cat *.html | codedown javascript > code.js

cat *.markdown | codedown javascript > code.js

----------------------------------auto generate readme-----------------------------------------------------------------------

rename existing readme to blueprint.md

npx @appnest/readme generate


npm i -g mdt-docs-generator

RENAME README.md ===> README_RAW.md

mdt-docs

---------------------------------Export Medium as Markdown------------------------------------------------------------------------

mediumexporter https://medium.com/codex/fundamental-data-structures-in-javascript-8f9f709c15b4 >ds.md

-------------------------Delete within size range--------------------------------------------------------------------------------

find . -size +386b -a -size -390b -exec rm -f {} ;

find . -size +2000b -exec rm -f {} ;


Create symbolic link to working directory

ln -s "$(pwd)" ~/mylink

npm install redux-logger redux-thunk styled-components



find -type f -exec sed -i 's///g' {} +

find . -type f -exec rename 's/-master//g' {} +

find . -type f -exec rename 's/-main//g' {} +

INSTEAD OF GIT PUSH _F :git reset --hard upstream/master

TRIM ALL(USE WITH CAUTION): find . -depth -exec rmdir {} ;
find . -empty -type f -print -delete find . -empty -type d -print -delete

find . ( -name ".git" -o -name ".gitignore" -o -name ".gitmodules" -o -name ".gitattributes" ) -exec rm -rf -- {} +

find . ( -name "*SECURITY.txt" -o -name "*RELEASE.txt" -o -name "*CHANGELOG.txt" -o -name "*LICENSE.txt" -o -name "*CONTRIBUTING.txt" -name "*HISTORY.md" -o -name "*LICENSE" -o -name "*SECURITY.md" -o -name "*RELEASE.md" -o -name "*CHANGELOG.md" -o -name "*LICENSE.md" -o -name "*CODE_OF_CONDUCT.md" -o -name "*CONTRIBUTING.md" ) -exec rm -rf -- {} +

find . ( -name "*SECURITY.txt" -o -name "*RELEASE.txt" -o -name "*CHANGELOG.txt" -o -name "*LICENSE.txt" -o -name "*CONTRIBUTING.txt" -name "*HISTORY.md" -o -name "*LICENSE" -o -name "*SECURITY.md" -o -name "*RELEASE.md" -o -name "*CHANGELOG.md" -o -name "*LICENSE.md" -o -name "*CODE_OF_CONDUCT.md" -o -name "*CONTRIBUTING.md" ) -exec rm -rf -- {} +


Replace spaces in filenames with underscores

for file in *; do mv "$file" echo $file | tr ' ' '_' ; done



Netlify error: 1:32:52 AM: Error checking out submodules: fatal: No url found for submodule path '2-content/awesome-resources/Cumulative-Resource-List-master' in .gitmodules

git rm --cached 2-content/awesome-resources/Cumulative-Resource-List-master



find . -name "*right.md" -type f -print -delete

find . -name "*right.html" -type f -print -delete

find . -name "*analytics.js" -type f -print -delete

find . -name "*.zip" | while read filename; do unzip -o -d "dirname "$filename"" "$filename"; done;

find . -name "*desktop.ini" -type f -print -delete

find . -name "*.zip" -type f -print -delete

find ./ -type f -name *.tar.gz -exec tar -xf {} ;

git remote remove origin

find . -name "*.gz" -type f -print -delete dac9ba0

find . -name "*.tgz" -type f -print -delete

lebab --replace ./ --transform obj-method lebab --replace ./ --transform class lebab --replace ./ --transform arrow lebab --replace ./ --transform let lebab --replace ./ --transform arg-spread lebab --replace ./ --transform arg-rest lebab --replace ./ --transform for-each lebab --replace ./ --transform for-of lebab --replace ./ --transform commonjs lebab --replace ./ --transform exponent lebab --replace ./ --transform multi-var lebab --replace ./ --transform template lebab --replace ./ --transform default-param lebab --replace ./ --transform destruct-param lebab --replace ./ --transform includes

lebab --replace ./ --transform obj-method lebab --replace ./ --transform class lebab --replace ./ --transform arrow

lebab --replace ./ --transform arg-spread lebab --replace ./ --transform arg-rest lebab --replace ./ --transform for-each lebab --replace ./ --transform for-of lebab --replace ./ --transform commonjs lebab --replace ./ --transform exponent lebab --replace ./ --transform multi-var lebab --replace ./ --transform template lebab --replace ./ --transform default-param lebab --replace ./ --transform destruct-param lebab --replace ./ --transform includes


PRISM:

<script async defer src="https://cdn.jsdelivr.net/gh/bgoonz/GIT-CDN-FILES/misc/web-dev-utils/personal-utilities/prism/prism.js"></script>

Powershell unzip:

$folderPath="PWD";

Get-ChildItem $folderPath -recurse | %{

if($_.Name -match "^*.`.zip$")
{
    $parent="$(Split-Path $_.FullName -Parent)";
    write-host "Extracting $($_.FullName) to $parent"

    $arguments=@("e", "`"$($_.FullName)`"", "-o`"$($parent)`"");
    $ex = start-process -FilePath "`"C:\Path\To\7zip\7z.exe`"" -ArgumentList $arguments -wait -PassThru;

    if( $ex.ExitCode -eq 0)
    {
        write-host "Extraction successful, deleting $($_.FullName)"
        rmdir -Path $_.FullName -Force
    }
}

}


<iframe width="560" height="315" src="https://www.youtube.com/embed/xGZSWvFess8?start=2" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

find ./ -iname "*.md" -type f -exec sh -c 'pandoc --standalone "${0}" -o "${0%.md}.html"' {} ;

for f in *.html; do printf '%s\n' 0a '

<title>Document</title> <script async defer src="./prism.js"></script> ;' . x | ex "$f"; done echo "" | tee -a *.html

------------------------------------Concat all files of same type recursively---------------------------------------------------------------------

find /path/to/directory/ -name *.csv -exec cat {} + > merged.file

find './' -name *.html -print0 | xargs -0 -I file cat file > merged.file.html

pandoc *.md > final.md

find . -name *.html -exec cat {} + > merged.file.html

find . -name *.md -exec cat {} + > merged.file.md

find . -name *.html -exec cat {} + > merged.file.html

for f in *.html; do cat "${f}"; echo; done > output.html


Flatten all sub folders into one folder contaning files.

find ./ -mindepth 1 -type f -exec mv -t ./ --backup=t '{}' +


find . -type f -exec sed -i '/Mirrored from/d' ./*.html {} ;

find . -type f -exec sed -i '/path/d' ./scrap.md {} ;

sudo sed -i '/description/d' *.html

sudo sed -i '/WEEK-/d' README.html

sudo sed -i '/// Date :/d' *.js

find . -type f -exec sed -i '/Created by/d' ./*.html {} ;

find . -type f -exec sed -i '/Mirrored from/d' ./*.md {} ;

find . -type f -exec sed -i '/image004/d' ./*.html {} ;

find . -type f -exec sed -i '/:::/d' ./*.md {} ;

find . -type f -exec sed -i '/Mirrored from/d' ./*.html {} ;

find . -type f -exec sed -i '/ Created by /d' ./*.html {} ;

find . -type f -exec sed -i '/

Document generated by Confluence on/d' ./*.html {} ;

find . -type f -exec sed -i '/