Skip to content

Instantly share code, notes, and snippets.

@sshymko
sshymko / .zshrc
Last active August 7, 2023 16:05
Zsh configuration of colors and Bash-style cursor navigation and auto-completion
unsetopt multios
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PROMPT='%F{cyan}%n%f@%F{green}%m:%f%B%F{yellow}%0~%f%b%(!.#.$) '
autoload -U select-word-style && select-word-style bash
autoload -Uz +X compinit && compinit
autoload -Uz +X bashcompinit && bashcompinit
@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
@sshymko
sshymko / DefaultKeyBinding.dict
Last active December 1, 2021 18:13
macOS key mapping for PC keyboard navigation
{
/*
~/Library/KeyBindings/DefaultKeyBinding.dict
*/
// Home/End Keys
"\UF729" = "moveToBeginningOfLine:"; // Home
"\UF72B" = "moveToEndOfLine:"; // End
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; // Shift + Home
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; // Shift + End
@sshymko
sshymko / aws_codepipeline_lambda_invalidate_cloudfront.js
Last active July 12, 2022 14:31
Invalidate CloudFront distribution from CodePipeline via Lambda function
const aws = require('aws-sdk');
const codepipeline = new aws.CodePipeline();
const cloudfront = new aws.CloudFront();
exports.handler = async (event, context) => {
let job = event['CodePipeline.job'];
let config = job.data.actionConfiguration.configuration.UserParameters;
try {
let params = JSON.parse(config);
if (!params || !params.distributionId) {
@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 / 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 / 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 / install_pecl_imagick_amzn2.sh
Last active December 9, 2023 17:40
Install latest ImageMagick 7.x and imagick PHP extension from PECL on Amazon Linux 2
#!/bin/sh
# Uninstall ImageMagic library and imagick PHP extension using it (installed previously)
yum remove -y php-pecl-imagick ImageMagick
# Install libraries for JPG, PNG, GIF, WebP, and TIFF image formats
yum install -y libpng-devel libjpeg-devel openjpeg2-devel libtiff-devel libwebp-devel giflib-devel
# Install latest ImageMagick library compiled from downloaded sources
yum install -y gcc
@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);