Skip to content

Instantly share code, notes, and snippets.

View willnaoosmith's full-sized avatar
🐧
Torvalds take the wheel 🙏🏻

William Brochensque Júnior willnaoosmith

🐧
Torvalds take the wheel 🙏🏻
View GitHub Profile
@willnaoosmith
willnaoosmith / gist:ccd1f0d5545d3b4c2bf29047efe354a0
Created May 24, 2023 11:57
delete all files with an specific extension on a directory an it's subdirectories
find . -name "*.log" -type f -delete
@willnaoosmith
willnaoosmith / gist:12a37168d49aea3d294afccf4ba3b431
Created May 24, 2023 11:56
print all files in a directory recusively with the full path
find ./ -print > file.txt
@willnaoosmith
willnaoosmith / awkCSV.sh
Created May 18, 2023 13:10
deal with strings separated by an delimiter with awk
cat examplefile.csv -F 'delimiterhere' '{printf "field1 - $1, field2 - $2",$1,$2}'
@willnaoosmith
willnaoosmith / fileExists.sh
Created May 18, 2023 13:10
linux command to test if file exist
test -e filehere && echo "file exists" || echo "file doesn't exist"
@willnaoosmith
willnaoosmith / DeleteWorkflowRuns.sh
Created May 9, 2023 12:33
Delete WorkflowRuns from github
OWNER=yourUsername
REPO=YourRepo
WORKFLOW_ID=YourWorkflow.yml
gh api -X GET /repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs | jq '.workflow_runs[] | .id'
gh api -X GET /repos/$OWNER/$REPO/actions/workflows/$WORKFLOW_ID/runs | jq '.workflow_runs[] | .id' | xargs -I{} gh api -X DELETE /repos/$OWNER/$REPO/actions/runs/{}
@willnaoosmith
willnaoosmith / RunCommandNTimes.sh
Created May 9, 2023 12:32
Run command n times
for run in {1..10}; do command; done
@willnaoosmith
willnaoosmith / gist:cd88d8abaa4c0eb43953bb9fcf66917f
Created May 9, 2023 10:50
clear commit's history on a github repository
git checkout --orphan latest_branch
git add -A
git commit -am "init"
git branch -D master
git branch -m master
git push -f origin master
@willnaoosmith
willnaoosmith / LimitedMemoryUsage
Created May 3, 2023 12:08
run a Linux command with limited memory usage
systemd-run --user --scope -p MemoryMax=MaxMemoryInBytes CommandToExecute
@willnaoosmith
willnaoosmith / LinuxDiff
Created May 3, 2023 12:04
Linux command to find a difference between 2 files
grep -v -f FirstFile.txt FileToSearchAllNewOcurrences.txt
@willnaoosmith
willnaoosmith / SendErrorBackupAlert.tsql
Last active April 27, 2023 12:05
TSQL script to send a custom HTML based E-mail to a recipient when a backup job is NOT executed successfully. Includes error message.
declare @bodyMsg nvarchar(max)
select @bodyMsg = 'The backup task coudn't be executed succesfully, here's the error message: <br /><br />Log:<br /><i>' +
(
SELECT
top 1
concat(
'<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
replace(replace(replace(replace(message, 'Executing query', '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Executing query'), 'Started:', '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Started:'), 'End Progress', ''), 'DTExec:', '<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DTExec:')
)