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 / 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 / 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 / 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 / create_launcher_xampp.sh
Last active May 8, 2023 01:38
Create a launcher for XAMPP on Lubuntu 18.04 LTS
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo 'need root!'
exit
fi
cat << EOF > /usr/share/polkit-1/actions/org.freedesktop.policykit.xampp.policy
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
@ailtonbsj
ailtonbsj / time-gitlog
Created July 14, 2018 23:29
Get total of hours spend in a git repository
#!/usr/bin/env node
var exec = require('child_process').exec
var child;
var initialHoursBeforeCommit = 0.5
if(process.argv[2] == '--help'){
console.log(`Usage: time-gitlog [option]
--initial hour Hours before commit. Default 0.5h.
@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