Skip to content

Instantly share code, notes, and snippets.

@sshymko
sshymko / redis.service
Last active May 8, 2024 14:56
Redis service for systemd on Linux
[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 March 14, 2024 20:10
Install MySQL 5.7 client on Amazon Linux 2
#!/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 December 10, 2019 20:52
CSS styling to print GitHub Markdown docs
/* 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 July 5, 2024 04:28
Google Chrome auto-update block for Mac OS
#!/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 August 17, 2019 00:44
Docker image of PHP 7.4 with Foreign Function Interface (FFI) support
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 July 23, 2020 02:18
Install Nginx and PHP-FPM on Amazon Linux 2 from Amazon Linux Extras
#!/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 October 23, 2023 01:06
Install Nginx and PHP-FPM on Amazon Linux 2 from REMI repository
#!/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 January 29, 2020 19:29
Wrapper launching single process using its execution permission as concurrency semaphore
#!/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 February 16, 2020 04:45
PHP7 function/method signature overloading
<?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 February 15, 2020 06:10
Chaining of immutable throwable exceptions/errors (PHP8 proposal)
<?php
interface Throwable
{
/**
* Return immutable copy with causal chain extended by given root cause
*
* @return Throwable
*/
public function chain(Throwable $cause = null): Throwable;