Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
@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 / 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 / Dockerfile
Last active August 25, 2020 04:19
Docker PHP with OPcache and Swoole extension & OpenSSL support
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 August 27, 2020 06:06
AWS CodeBuild specification for single-page application (SPA) managed by NPM
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 October 14, 2020 03:37
Install SSH2 PHP7 extension on Amazon Linux 2
#!/bin/sh
sudo yum install php-pecl-ssh2 -y
@sshymko
sshymko / chrome_update_block.sh
Last active October 27, 2020 13: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 / sysctl.conf
Created December 1, 2021 18:10
macOS TCP connection keep alive
net.inet.tcp.keepidle=20000
net.inet.tcp.keepintvl=20000
net.inet.tcp.keepinit=20000
net.inet.tcp.always_keepalive=1