Skip to content

Instantly share code, notes, and snippets.

View ailtonbsj's full-sized avatar

José Ailton ailtonbsj

View GitHub Profile
@ailtonbsj
ailtonbsj / rmfreeze.sh
Created June 21, 2017 02:11
Removendo “freeze” do LE5
#!/bin/bash
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
awk -F':' '{ print $1}' /etc/passwd | grep aluno > usrs
cat usrs | while read line; do
userdel -r $line
@ailtonbsj
ailtonbsj / getAliveIps.sh
Created October 24, 2017 02:59
Get all IPs alives on your local network
#Needs apt install nmap
nmap -sP 192.168.1.* | grep for | awk {'print $5 " " $6'}
@ailtonbsj
ailtonbsj / android-studio.desktop
Created February 1, 2018 03:27
Android Studio Launcher for Ubuntu
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec="/opt/android-studio/bin/studio.sh" %f
Icon=/opt/android-studio/bin/studio.png
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
@ailtonbsj
ailtonbsj / packettracer7.desktop
Last active February 1, 2018 03:31
Packet Tracer 7 Launcher for Ubuntu
[Desktop Entry]
Version=1.0
Name=Packet Tracer 7
Exec=/opt/pt/packettracer
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/pt/art/app.png
Categories=Development;
@ailtonbsj
ailtonbsj / dam.js
Created February 6, 2018 16:43
Desvio médio absoluto em JS
//Desvio medio absoluto
function dam(input){
let sum = input.reduce((acc,val) => acc+val);
let mean = sum/input.length;
let desvAbs = input.map(val => Math.abs(val - mean));
let sumDesv = desvAbs.reduce((acc,val) => acc+val);
return sumDesv/input.length;
}
console.log(dam([34,29,39,34]));
@ailtonbsj
ailtonbsj / stdDeviation.js
Created February 7, 2018 17:06
Standard Deviation in JS
function stdDeviation(input, isAmostra){
let amostral = 0;
if(isAmostra != null) amostral = 1;
let sum = input.reduce((acc,val) => acc+val);
let mean = sum/input.length;
let diff2 = input.map(val => Math.pow(val - mean,2));
let sumDiff = diff2.reduce((acc,val) => acc+val);
let desv = Math.sqrt(sumDiff/(input.length-amostral));
console.log(mean);
console.log(desv);
@ailtonbsj
ailtonbsj / rename2dos
Created May 28, 2018 17:56
Rename files and folders to move from linux to windows cleaning specials characters
#!/bin/bash
#
# HOW TO INSTALL: move to /usr/bin and change permissions to execute
if [ "$1" == "--help" ]; then
cat << EOF
Usage: rename2dos pathfolder counter
pathfolder --> Initial folder
counter --> Restart counter added in filename
@ailtonbsj
ailtonbsj / symbolic-folders-on-ubuntu.sh
Created July 4, 2019 14:51
Migration of symbolic folders to drive d
#!/bin/bash
rm -rf ~/Downloads && ln -s /mnt/d/Downloads/ ~/Downloads
rm -rf ~/Documentos && ln -s /mnt/d/Documents/ ~/Documentos
rm -rf ~/Imagens && ln -s /mnt/d/Pictures/ ~/Imagens
rm -rf ~/Música && ln -s /mnt/d/Music/ ~/Música
rm -rf ~/Vídeos && ln -s /mnt/d/Videos/ ~/Vídeos
rm -rf ~/Modelos && ln -s /mnt/d/Models/ ~/Modelos
rm -rf ~/Público && ln -s /mnt/d/Public/ ~/Público
@ailtonbsj
ailtonbsj / expressions-without-if.sh
Last active July 4, 2019 14:52
A trick about expressions in bash without use of if
#!/bin/bash
function expressionsWithoutIf {
A=$1
B=$2
[ "$A" -ge "$B" ] ; C=$?
if [ "$C" == "0" ]; then
echo "TRUE!"
else
@ailtonbsj
ailtonbsj / deb-boilerplate.sh
Created July 30, 2020 04:07
An boilerplate to projects of debian package (.deb)
#!/bin/bash
GithubId="ailtonbsj"
Email="ailton.ifce@gmail.com"
AppDomain="com.github.ailtonbsj"
AppName="sample"
AppNameEn="Sample"
AppNameBr="Exemplo"
Comment="A Sample of application"
CommentBr="Um exemplo de aplicativo"