Skip to content

Instantly share code, notes, and snippets.

View ailtonbsj's full-sized avatar

José Ailton ailtonbsj

View GitHub Profile
@ailtonbsj
ailtonbsj / gnuplot-like-matlab.py
Created October 15, 2022 19:20
Using Python Gnuplot like Matlab
from numpy import *
from matplotlib.pyplot import *
import Gnuplot, Gnuplot.funcutils
import time
#Inicializa e usa linhas
g = Gnuplot.Gnuplot(debug=0)
g('set style data lines')
for i in arange(1,100,0.1):
@ailtonbsj
ailtonbsj / fabapp_itempage.html
Created August 17, 2021 00:56
Item de Lista para FabApp
<style type="text/css">table {
border-collapse: collapse;
border-spacing: 0;
width: 100%;
border: 1px solid #ddd;
}
th, td {
text-align: left;
padding: 8px;
@ailtonbsj
ailtonbsj / diffpercent
Created May 10, 2021 06:31
Difference between two files in percentage
#!/bin/bash
# DESCRIPTION: Difference between two files in percentage
# USAGE:
# ./diffpercent file1 file2
cat $1 | base64 -w 0 > /tmp/1.64
cat $2 | base64 -w 0 > /tmp/2.64
sed 's/./\0\n/g' /tmp/1.64 > /tmp/3.64
sed 's/./\0\n/g' /tmp/2.64 > /tmp/4.64
@ailtonbsj
ailtonbsj / fix-pdf-thumbnails-lubuntu.sh
Created December 24, 2020 20:47
This script fix PDF Thumbnails on Lubuntu
#!/bin/bash
armorFile="/etc/apparmor.d/usr.bin.evince"
hadWxFixed=$(cat $armorFile | grep "WinuniX")
if [ "$hadWxFixed" == "" ]; then
NUM=$(cat $armorFile | grep 'owner /tmp/evince-thumbnailer\*/{,\*\*} rw,' -n | cut -d':' -f1)
sed -i $(($NUM+1))"i\ \ # WinuniX added this line" $armorFile
sed -i $(($NUM+2))"i\ \ owner /home/\*/.cache/thumbnails/\*/\*.\* rw," $armorFile
apparmor_parser -r $armorFile
@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"
@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 / 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 / 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 / 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