Skip to content

Instantly share code, notes, and snippets.

@sshymko
sshymko / .zshrc
Last active Jan 4, 2022
Zsh configuration of cursor navigation and colors
View .zshrc
autoload -U select-word-style
select-word-style bash
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PROMPT='%F{cyan}%n%f@%F{green}%m:%f%B%F{yellow}%0~%f%b%(!.#.$) '
@sshymko
sshymko / sysctl.conf
Created Dec 1, 2021
macOS TCP connection keep alive
View sysctl.conf
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 Dec 1, 2021
macOS key mapping for PC keyboard navigation
View DefaultKeyBinding.dict
{
/*
~/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 Jul 12, 2022
Invalidate CloudFront distribution from CodePipeline via Lambda function
View aws_codepipeline_lambda_invalidate_cloudfront.js
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 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 / 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 / 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 / install_pecl_imagick_amzn2.sh
Last active Feb 1, 2022
Install latest ImageMagick 7.x and imagick PHP extension from PECL on Amazon Linux 2
View install_pecl_imagick_amzn2.sh
#!/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 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);