Skip to content

Instantly share code, notes, and snippets.

View Dragod's full-sized avatar
🎲
Ma le spegnene?

Fabio Dragod

🎲
Ma le spegnene?
View GitHub Profile
@Dragod
Dragod / worked-on-banch-list.sh
Created April 1, 2021 11:01
Show most recently worked on branches
git for-each-ref --sort=-committerdate refs/heads/
@Dragod
Dragod / last-commit-date-on-branch.sh
Created April 1, 2021 11:02
Date of last commint on branches
git for-each-ref --sort='-committerdate' --format='%(refname)%09%(committerdate)' refs/heads | sed -e 's-refs/heads/--'
@Dragod
Dragod / build.sh
Created April 27, 2021 17:21
Create build.js from bash script
#!/bin/bash
FILE=build.js
if test -f "$FILE"; then
printf "\r\n$FILE already exists, start use node build with \"node build --cmd\"\n"
else
echo "let build = require('sd-unity-build');" > build.js
printf "\r\nbuild.js created, start use node build with \"node build --cmd\"\n"
fi
@Dragod
Dragod / .bashrc
Last active May 6, 2021 12:52
Create and delete feature branch from dev
# Create new feature branch from sd-unity-4-0 dev branch
# Red
RED='\033[0;31m'
# Color Function
alert(){
echo -ne $RED$1$clear
@Dragod
Dragod / .bashrc
Last active May 6, 2021 12:50
2021 .bashrc
green='\e[32m'
blue='\e[34m'
clear='\e[0m'
#Green
GREEN=`tput setaf 2`
# Red
@Dragod
Dragod / .gitconfig
Created May 6, 2021 12:54
Add git lb to list of commands available
[alias]
lb = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf(\" \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}'
@Dragod
Dragod / yt-rss.sh
Last active December 15, 2022 22:20
Get youtube feed rss link
#!/bin/bash
#Script to get rss feed from special youtube links.
# Examples:
# 1) https://www.youtube.com/c/NumeroDiez --> type "./yt-rss Numerodiez c" and press enter to get RSS url
# 2) https://www.youtube.com/user/simoneaversano --> type "./yt-rss simoneaversano user" and press ENTER to get RSS url
# If the channel already have an id in the youtube url use:
# 2) https://www.youtube.com/channel/UCk8gzAOGprcGAFMWGzZ2zQw --> type "./yt-rss UCk8gzAOGprcGAFMWGzZ2zQw channel" and press ENTER to get RSS url
GREEN=`tput setaf 2`
@Dragod
Dragod / add-to-gitignore.md
Last active September 22, 2021 10:31
Remove exsisting file/repo and add it to .gitignore

Remove a file from the repo and add it to .gitignore

git rm --cached resources/sprite/dist/sprite.svg

Remove a all file from a folder in a repo and add it to .gitignore

git rm -r --cached resources/sprite/svgo

@Dragod
Dragod / winget-on-bash.md
Created September 29, 2021 17:58
Make winget work on bash

Enable windows subsystem in powershell

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Ebable virtual machine feature in powershell

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
@Dragod
Dragod / exexSync_error_catch.md
Last active October 5, 2021 15:40
Catch exexSync errors

If you want to get net wlan show profiles output no matter if it fails or not, you can use either asynchronous version of exec. The callback will have stdout set.

Or you can catch exception and get stdout from there. Something like:

let nestsh_output;
try {
  netsh_output = execSync('netsh wlan show profiles');
} catch (ex) {
 netsh_output = ex.stdout;