Skip to content

Instantly share code, notes, and snippets.

@leonirlopes
leonirlopes / check_update.sh
Created July 18, 2022 19:27 — forked from codatory/check_update.sh
CentOS / Fedora Weekly update checking script
#!/bin/bash
UPDATES=`yum check-update -q | awk '{print $1}'`
COUNT=`printf "%s\n" "$UPDATES" | grep -v "^$" | wc -l`
YUM=`printf "%s\n" "$UPDATES" | grep -v "^$" | grep yum`
echo '--------------------------------------------------------------------------------'
echo " Weekly Update Notification for `hostname`"
echo " -> $COUNT update(s) available"
if [ -n "$YUM" ]; then
echo ' -> IMPORTANT: A Yum update is available. Perform this separately and first.'
fi
@leonirlopes
leonirlopes / tg.sh
Last active July 13, 2022 12:56 — forked from HirbodBehnam/tg.sh
Telegram bash shell upload file ~ A dead simple script to upload files on your server through Telegram bot
#!/bin/bash
# This is a simple script that takes some files as arguments and sends them to a special chat
# Just create a new bot at @BotFather and get your chat ID from @myidbot and enter them here
# You can also make a shortcut in '~/.bashrc' like "alias tg='bash /opt/scripts/tg.sh'"
# After that restart bash and use it like 'tg file1.txt file2.jpg'
# EDIT TOKEN and CHAT_ID:
TOKEN="TOKEN"
CHAT_ID="12341234"
# Make sure curl is installed
for arg in "$@"
@leonirlopes
leonirlopes / index.html
Created May 20, 2022 17:03 — forked from leowebguy/index.html
Responsive iframe full screen. Display page without and hide original url address.
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
html body {width: 100%;height: 100%;padding: 0px;margin: 0px;overflow: hidden;font-family: arial;font-size: 10px;color: #6e6e6e;background-color: #000;} #preview-frame {width: 100%;background-color: #fff;}</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
//function to fix height of iframe!
var calcHeight = function() {
@leonirlopes
leonirlopes / rmhash.sh
Created March 31, 2022 14:31 — forked from apolzek/rmhash.sh
Remove files with the same hash
# by: apolzek
md5sum * | sort -n > .file
filename='.file'
n=1
x=1
while read line; do
current_hash=$(echo $line | awk {'print $1'})
echo "[debugging] current_hash: $current_hash"
x=$(($n + 1))
// ==UserScript==
// @name BlockBlockAdBlock
// @namespace http://github.com/anka-213
// @version 0.1.1
// @description Block the BlockAdBlock script
// @author Andreas Källberg
// @match http://blockadblock.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
@leonirlopes
leonirlopes / linux-kill-pts.md
Created September 21, 2020 18:38 — forked from holmberd/linux-kill-pts.md
Kill tty/pts sessions in Linux

Kill user tty/pts sessions in Linux

Commands

  • w: show who is logged on and what they are doing
  • who: show who is logged on
  • tty: show current users pseudo terminal
  • ps -ft pts/1: get process id for the pseudo terminal
  • pkill: signal process based on name and other attributes
@leonirlopes
leonirlopes / letsencrypt-proxmox.md
Created September 7, 2020 14:09 — forked from lichti/letsencrypt-proxmox.md
Proxmox with letsencrypt ssl
git clone https://github.com/certbot/certbot /opt/letsencrypt
ln -s /opt/letsencrypt/certbot-auto /usr/bin/certbot
certbot certonly --expand --agree-tos --text --non-interactive \
 --standalone \
@leonirlopes
leonirlopes / valida-cpf.php
Last active April 21, 2018 17:09
Script para Validar CPF em PHP
<?php
function validaCPF($cpf = null)
{
// Verifica se um número foi informado
if (empty($cpf)) {
return false;
}
// Elimina possivel mascara
$cpf = preg_replace('/[^0-9]/', '', $cpf);
@leonirlopes
leonirlopes / mask.php
Created April 20, 2018 19:32
Máscara PHP para CNPJ, CPF, Data e qualquer outra coisa
<?php
// PHP Máscara CNPJ, CPF, Data e qualquer outra coisa
// http://blog.clares.com.br/php-mascara-cnpj-cpf-data-e-qualquer-outra-coisa/
// ver em funcionamento ~~> https://ideone.com/wP7zN2
function mask($val, $mask)
{
$maskared = '';
$k = 0;
<?php
// veja em funcionamento ~~> https://ideone.com/IMDNHT
// defino a data de hoje
$ano = date('Y');
$mes = date('m');
$dia = date('d');
// calculo uma senha de 6 digítos com base na data
$senha = substr((substr($ano, -2) * $mes * $dia * ($ano - 1900) * 6666), -6);