Skip to content

Instantly share code, notes, and snippets.

View acosonic's full-sized avatar
💭
I may be slow to respond.

Aleksandar Pavić acosonic

💭
I may be slow to respond.
View GitHub Profile
@acosonic
acosonic / disk_speed.txt
Last active June 4, 2024 16:35
Testing of diskspeed at various hosting companies on idle machines
Command used for testing:
dd if=/dev/zero of=sb-io-test bs=1M count=1k conv=fdatasync && rm sb-io-test
Results sorted by best->top / worst->bottom
Herzner (1 cpu cloud machine)
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.23958 s, 866 MB/s
OVH Dedicated VmWare nVME
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 1.24378 s, 863 MB/s
@acosonic
acosonic / demo.rake
Last active February 14, 2024 12:17
Redmine 5 demo data generator Put this in lib/tasks and install gem faker and gem random_data
# Still a work in progress but is good enough for development
#
# `rake redmine:demo_data` for it all
# `rake redmine:demo_data:users`
# `rake redmine:demo_data:projects`
# `rake redmine:demo_data:issues`
# `rake redmine:demo_data:time_entries`
require "faker"
require "random_data"
@acosonic
acosonic / fail2ban_wp.sh
Created March 5, 2019 13:48
Protecting ubuntu 14.04 server virtualmin websites against wordpress login attack bots
#!/bin/bash
# this script will install fail2ban and enable apache-wp-login rule
# you will notice once it's done that fail2ban-client status shows apache-wp-login rule as active
apt install fail2ban
JAIL=''
JAIL="${JAIL}\n"
JAIL="${JAIL}[apache-wp-login]\n"
JAIL="${JAIL}enabled = true\n"
JAIL="${JAIL}port = http,https\n"
JAIL="${JAIL}filter = apache-wp-login\n"
@acosonic
acosonic / decrap.sh
Last active October 12, 2023 10:33
Ubuntu decrapifier
#!/bin/bash
#this script is intended to decrapify your Ubuntu, stuff like turn off unattended upgrades...
echo 'some of this should be done as root'
echo 'Fix keyboard shortcuts'
gsettings set org.gnome.desktop.input-sources xkb-options [] #remove left ctrl shift
gsettings set org.gnome.mutter overlay-key 'Super_L'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ new-tab '<Control><Shift>t'
@acosonic
acosonic / resize.sh
Last active June 7, 2023 12:28
Ubuntu resize VM disk
#!/bin/bash
echo 1 > /sys/block/sda/device/rescan
cfdisk /dev/sda
pvresize /dev/sda3
lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
@acosonic
acosonic / pubip.sh
Last active May 26, 2023 17:03
Make pubip binary which determinates public ip
#!/bin/bash
wget -qO- http://acosonic.com/ip.php && echo -e "\r"
#you can use shc and compile this like shc -vrf pubip.sh -o pubip && mv pubip ~/bin
#then just use it as pubip from anywhere or move to system bin...
@acosonic
acosonic / loadcsvdates.sql
Created May 23, 2023 10:27
Load CSV file in MySQL serverside with fixing date formats
TRUNCATE TABLE `db`.`table`;
LOAD DATA LOCAL INFILE '/home/ubuntu/file.csv' IGNORE INTO TABLE `db`.`table`
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n' IGNORE 1 LINES (`id`, `Name`,
`Status`, `AccountNumber`, @v1,
@v2, `Business_Street`)
SET Formation_Date = STR_TO_DATE(@v1,'%m/%d/%Y'),
Production_Date = STR_TO_DATE(@v2,'%m/%d/%Y');
@acosonic
acosonic / memcached.sh
Created March 10, 2023 07:10
MemacheD (memcache with d) installation for PHP (run as root)
#!/bin/bash
apt install memcached libmemcached-tools
systemctl status memcached
echo stats | nc 127.0.0.1 11211
apt install php-memcached
phpenmod memcached
apache2ctl restart
@acosonic
acosonic / cleansnap.sh
Created January 9, 2023 20:43
Ubuntu 20.04 clean snap versions cache
#!/bin/sh
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
while read pkg revision; do
sudo snap remove "$pkg" --revision="$revision"
done
@acosonic
acosonic / adduid.sql
Last active January 9, 2023 20:42
Procedure for adding truly random UUID to existing tabe in mysql database with empty UUID varchar field Existing uuid function does not generate enough randomness
#change the exit criteria 61564999 to fit your needs
CREATE DEFINER=`root`@`localhost` PROCEDURE `adduuid`()
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE a INT Default 1 ;
simple_loop: LOOP