Skip to content

Instantly share code, notes, and snippets.

View Alexfilus's full-sized avatar

Alexfilus Alexfilus

View GitHub Profile
@Alexfilus
Alexfilus / shared_folder_centos_virtualbox.txt
Created January 17, 2019 18:54 — forked from larsar/shared_folder_centos_virtualbox.txt
Mount shared folder on CentOS in VirtualBox
# The VirtualBox documentation[1] for how to install guest additions
# for Linux on a virtual host is somewhat messy. So here is what
# I did to make it work.
# Install the packages required
yum update
yum install gcc kernel-devel make
reboot
useradd -m -c "Admin User" lord
passwd lord
usermod -aG sudo lord
sudo nano /etc/ssh/sshd_config
PermitRootLogin yes -> no
systemctl restart sshd
@Alexfilus
Alexfilus / redis_session.txt
Created June 28, 2019 14:16
PHP сессии в редисе без настроек сервера
session_start([
'save_handler' => 'redis',
'save_path' => 'tcp://127.0.0.1:6379?database=1',
'cookie_lifetime' => 86400,
'gc_maxlifetime' => 86400,
'serialize_handler' => 'igbinary',
'name' => 'project',
'cookie_httponly' => true
]);
@Alexfilus
Alexfilus / php-pools.md
Created October 22, 2019 15:38 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@Alexfilus
Alexfilus / docker-gitlab.md
Last active November 26, 2019 12:12
docker gitlab
sudo docker run --detach \
  --hostname gitlab.example.com \
  --publish 8443:443 --publish 8080:80 --publish 2222:22 \
  --name gitlab \
  --restart always \
  --volume /srv/gitlab/config:/etc/gitlab \
  --volume /srv/gitlab/logs:/var/log/gitlab \
  --volume /srv/gitlab/data:/var/opt/gitlab \
 gitlab/gitlab-ce:latest
@Alexfilus
Alexfilus / postgres-upgrade.md
Created November 26, 2019 12:14
Upgrade PG 10->12
/usr/lib/postgresql/12/bin/pg_upgrade \
  --old-datadir=/var/lib/postgresql/10/main \
  --new-datadir=/var/lib/postgresql/12/main \
  --old-bindir=/usr/lib/postgresql/10/bin \
  --new-bindir=/usr/lib/postgresql/12/bin \
  --old-options '-c config_file=/etc/postgresql/10/main/postgresql.conf' \
  --new-options '-c config_file=/etc/postgresql/12/main/postgresql.conf' \
  --check
@Alexfilus
Alexfilus / pg_to_csv.txt
Created December 9, 2019 11:28
PG to CSV
psql -U postgres -d name -h host.com -p 5432 -c "COPY (SELECT id, name FROM user LIMIT 10) TO STDOUT With CSV HEADER DELIMITER ',';" > foo_data.csv
@Alexfilus
Alexfilus / print.php
Created May 24, 2020 11:51
print range to count and array
/**
* @param string $range
* @return string
*/
public static function cleanRange(string $range): string
{
return preg_replace('/[^0-9\-,]/', '', $range);
}
/**
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@Alexfilus
Alexfilus / latency.txt
Created August 27, 2021 14:46 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD