Skip to content

Instantly share code, notes, and snippets.

@zarza
zarza / gist:4bcc07159a14f342f324831a6bbfe926
Created November 27, 2022 16:57
Sort folders into firstChar folder
for f in *; do
firstChar="${f:0:1}";
mkdir -p -- "$firstChar";
mv -- "$f" "$firstChar";
done
# Remember to setup your ssh-copy-id first
# https://www.ssh.com/academy/ssh/copy-id
# And then
ls --indicator-style=none /home/admin/web/ | xargs -n1 -P4 -I% rsync -avzhP % root@xx.21.xx.233:/root/OLD_CLOUDSTORAGE/
# Just replace your SERVER_IP and setup the destination folder.
@zarza
zarza / gist:335234deb37ec038c6957a8ea0d4efcd
Last active November 14, 2022 01:33
Port forwarding from eth0 to wireguard
# VESTA PORTS #
#<?php
#// Enter your code here, enjoy!
#$array = explode(',','21,22,25,53,80,443,110,143,465,783,993,995,3306,8083');
#foreach( $array as $port ){
#echo 'iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport '.$port.' -j ACCEPT' . PHP_EOL;
#echo 'iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport '.$port.' -j ACCEPT' . PHP_EOL;
#echo 'iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport '.$port.' -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:'.$port.'' . PHP_EOL;
iptables -t nat -A OUTPUT -p tcp --dport 25 -j DNAT --to-destination :587
@zarza
zarza / gist:2ce099ba6130e7c9010b4d02408ea327
Created June 25, 2021 19:48
Massive unlike/unfollow from Facebook
You can star on https://m.facebook.com/pages/?category=liked&ref=bookmarks
then from console:
const unlike_all = ()=> {
[].slice.call(document.querySelectorAll('a[role=button]')).filter(x=>x.innerText=='Unlike').map(x=>{x.click(); x.remove()});
[].slice.call(document.querySelectorAll('a[role=button][action=cancel]')).map(x=>x.click());
window.scrollTo(0,document.body.scrollHeight);
window.setTimeout(unlike_all, 3 * 1000)
};
@zarza
zarza / gist:8a23ba480ff8b8642258bff74717ea42
Created November 6, 2019 03:44
- The user specified as a definer ('root'@'localhost') does not exist
mysql -u admin -p`cat /etc/psa/.psa.shadow`
CREATE USER 'root'@'localhost' IDENTIFIED BY '';
GRANT ALL PRIVILEGES ON * . * TO 'root'@'localhost';
FLUSH PRIVILEGES;
exit;
Y luego reboot.
@zarza
zarza / ajax-cache-include.js
Created November 17, 2018 06:12 — forked from jasondmoss/ajax-cache-include.js
jQuery: Load external scripts and cache them.
/**
* Cache AJAX-included scripts.
*/
$.cachedScript = function (url, options) {
options = $.extend(
options || {}, {
dataType: "script",
cache: true,
url: url
}
@zarza
zarza / fastestRandomSelect.sql
Last active March 10, 2018 15:41
Fastest SQL to get random rows from MySQL in LARGE and small databases
# Ejemplo 1
SELECT * FROM post AS r1 JOIN (SELECT (RAND() * (SELECT MAX(postid) FROM post)) AS postid) AS r2 WHERE r1.postid >= r2.postid ORDER BY r1.postid ASC LIMIT 10
# Ejemplo 2
SELECT * FROM (SELECT * FROM `comprobantes` WHERE `ind-estado` = 'procesando' OR (`ind-estado` = 'rechazado' AND `respuesta-xml` IS NULL)) AS r1 JOIN (SELECT (RAND() * (SELECT MAX(id) FROM comprobantes)) AS id) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 100
@zarza
zarza / checknstart_service_if_down.sh
Created January 19, 2018 17:54
If this found your service stopped it will try to start it
#!/bin/bash
echo '[Start service if it is down]'
echo
# ZARZA | A HEAD OF OUR TIME
# https://zarza.com
service=nginx
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is up!"
@zarza
zarza / create_emails_from_txt.sh
Created October 14, 2017 23:23
Create multiple email addresses in Plesk from a text file easily
#!/bin/bash
echo '[Create multiple email addresses in Plesk from a text file easily]'
echo
# ZARZA | A HEAD OF OUR TIME
# https://zarza.com
FILE='mails.txt'
if [ -f $FILE ]; then
while read p; do