Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
@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 / 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 / Dockerfile
Last active Aug 25, 2020
Docker PHP with OPcache and Swoole extension & OpenSSL support
View Dockerfile
FROM php:7.4-cli
ARG SWOOLE_VERSION=swoole
RUN apt-get update -q
RUN apt-get install -y --no-install-recommends \
libssl-dev
RUN docker-php-ext-install \
opcache
@sshymko
sshymko / buildspec.yml
Created Aug 27, 2020
AWS CodeBuild specification for single-page application (SPA) managed by NPM
View buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
build:
commands:
- npm install
- npm run build -- --mode=production
@sshymko
sshymko / install_php_pecl_ssh2.sh
Created Oct 14, 2020
Install SSH2 PHP7 extension on Amazon Linux 2
View install_php_pecl_ssh2.sh
#!/bin/sh
sudo yum install php-pecl-ssh2 -y
@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 / 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