Skip to content

Instantly share code, notes, and snippets.

View foxycode's full-sized avatar

Tomáš Jacík foxycode

View GitHub Profile
@foxycode
foxycode / rsync.sh
Created December 21, 2022 05:56
Fastest rsync possible
#!/bin/bash
# First run
rsync -aHAXxv --numeric-ids --no-compress --inplace -W --delete --progress \
-e "ssh -T -c aes128-ctr -o Compression=no -x" \
server1:/dir/ /dir/
# Second run
rsync -av --numeric-ids --no-compress --delete --progress \
-e "ssh -T -c aes128-ctr -o Compression=no -x" \
#!/bin/bash
sudo usb_modeswitch -W -v 12d1 -p 1f1e -J > /dev/null
@foxycode
foxycode / openssl.sh
Created April 24, 2020 16:09
OpenSSL silently create self-signed certificate
#!/bin/sh
openssl req -x509 -nodes -days 3650 -subj "/C=CZ/ST=CZ/O=Application/CN=app.test" -addext "subjectAltName=DNS:app.test" -newkey rsa:2048 -keyout app.key -out app.crt
CREATE TABLE `dns_record` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`origin` varchar(63) COLLATE utf8_bin NOT NULL,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`type` char(6) COLLATE utf8_bin NOT NULL,
`value` text COLLATE utf8_bin NOT NULL,
PRIMARY KEY (`id`),
KEY `origin` (`origin`),
KEY `type` (`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
@foxycode
foxycode / mikrotik-backup-link-over-lte
Last active October 7, 2023 14:48
MikroTik backup link over LTE
@foxycode
foxycode / BasePresenter.php
Last active July 31, 2018 19:14
Nette Multilang App
<?php declare(strict_types=1);
namespace App\Presenters;
use Kdyby\Translation\Translator;
use Nette\Application\Helpers;
use Nette\Application\UI\Presenter;
abstract class BasePresenter extends Presenter
{
@foxycode
foxycode / Passwords.php
Created October 11, 2017 20:16
Prestashop password rehash class
<?php declare(strict_types=1);
final class Passwords
{
private const OLD_SALT = 'xxx';
public const PS_OLD = 'prestashop_old';
public const PS_HASHED = 'prestashop_hashed';
public const BCRYPT = 'bcrypt';
@foxycode
foxycode / remove_old_kernels.sh
Created June 19, 2017 09:43
Remove old Ubuntu kernels
#!/bin/bash
current_version=$(uname -r | sed 's/-generic\|-virtual//')
kernels=$(dpkg -l | grep 'linux-image-[0-9]' | awk '{print $2}')
latest_kernel=$(echo $kernels | tr ' ' '\n' | tail -1)
remove_kernels=$(echo $kernels | tr ' ' '\n' | grep -v $latest_kernel | grep -v $current_version)
headers=$(dpkg -l | grep 'linux-headers-[0-9]' | awk '{print $2}')
latest_headers=$(echo $headers | tr ' ' '\n' | tail -1)
@foxycode
foxycode / sshfp.sh
Created May 17, 2017 15:50
Get SSHFP records from SSH keys
#!/bin/bash
echo "$(hostname) SSHFP 1 2 $(cut -f2 -d ' ' "/etc/ssh/ssh_host_rsa_key.pub" | base64 --decode | sha256sum | cut -f 1 -d ' ')"
echo "$(hostname) SSHFP 4 2 $(cut -f2 -d ' ' "/etc/ssh/ssh_host_ed25519_key.pub" | base64 --decode | sha256sum | cut -f 1 -d ' ')"
@foxycode
foxycode / pri.2.0.0.0.0.0.6.c.2.0.a.2.ip6.arpa
Created March 3, 2017 11:07
ipv6 reverse zone example
$TTL 3600
@ IN SOA ns.sunfox.cz. sunfox.sunfox.cz. (
2016010902 ; serial, todays date + todays serial #
7200 ; refresh, seconds
540 ; retry, seconds
604800 ; expire, seconds
86400 ) ; minimum, seconds
;
2.0.0.0.0.0.6.c.2.0.a.2.ip6.arpa. 3600 NS ns.sunfox.cz.