Skip to content

Instantly share code, notes, and snippets.

@sshymko
sshymko / redis.service
Last active Oct 15, 2021
Redis service for systemd on Linux
View redis.service
[Unit]
Description=Redis persistent key-value storage
After=network.target
[Service]
Type=notify
ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd --daemonize no
ExecStop=/usr/bin/redis-cli -p 6379 shutdown
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
@sshymko
sshymko / install_mysql_client.sh
Last active Sep 29, 2022
Install MySQL 5.7 client on Amazon Linux 2
View install_mysql_client.sh
#!/bin/sh
sudo yum install -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo yum install -y mysql-community-client
@sshymko
sshymko / github-print.css
Last active Dec 10, 2019
CSS styling to print GitHub Markdown docs
View github-print.css
/* Hide GitHub UI controls */
header,
.pagehead,
.footer,
.repository-content > :not(.Box),
.repository-content > .Box--condensed:not(#readme),
.Box-header {
display: none !important;
}
@sshymko
sshymko / chrome_update_block.sh
Last active Oct 27, 2020
Google Chrome auto-update block for Mac OS
View chrome_update_block.sh
#!/bin/sh
sudo tee -a /etc/hosts << EOF
# Block Google Chrome auto-update
0.0.0.0 tools.google.com
EOF
@sshymko
sshymko / Dockerfile
Created Aug 17, 2019
Docker image of PHP 7.4 with Foreign Function Interface (FFI) support
View Dockerfile
FROM phpdaily/php:7.4.0-dev
RUN apk add --no-cache --virtual .persistent-deps libffi-dev \
&& docker-php-ext-configure ffi --with-ffi \
&& docker-php-ext-install ffi
@sshymko
sshymko / install_nginx_php7_amzn2_extra.sh
Last active Jul 23, 2020
Install Nginx and PHP-FPM on Amazon Linux 2 from Amazon Linux Extras
View install_nginx_php7_amzn2_extra.sh
#!/bin/sh
sudo yum update -y
sudo amazon-linux-extras install -y epel
sudo amazon-linux-extras install -y php7.2
sudo yum install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
@sshymko
sshymko / install_nginx_php7_amzn2_remi.sh
Last active Jun 21, 2022
Install Nginx and PHP-FPM on Amazon Linux 2 from REMI repository
View install_nginx_php7_amzn2_remi.sh
#!/bin/sh
sudo yum update -y
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --setopt="remi-php72.priority=5" --enable remi-php72
sudo yum install -y nginx
sudo systemctl enable nginx
@sshymko
sshymko / only.sh
Last active Jan 29, 2020
Wrapper launching single process using its execution permission as concurrency semaphore
View only.sh
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <command> [args...]"
exit
fi
trap ':' SIGINT SIGTERM
chmod u-x "$0"
@sshymko
sshymko / overload.php
Last active Feb 16, 2020
PHP7 function/method signature overloading
View overload.php
<?php
declare(strict_types=1);
function overload(callable ...$implementations): callable
{
return function (...$args) use ($implementations) {
$error = new \LogicException('Invalid overloaded implementations');
foreach ($implementations as $candidate) {
try {
return $candidate(...$args);
@sshymko
sshymko / throwable_chaining.php
Created Feb 15, 2020
Chaining of immutable throwable exceptions/errors (PHP8 proposal)
View throwable_chaining.php
<?php
interface Throwable
{
/**
* Return immutable copy with causal chain extended by given root cause
*
* @return Throwable
*/
public function chain(Throwable $cause = null): Throwable;