Skip to content

Instantly share code, notes, and snippets.

View zviryatko's full-sized avatar
😱
Kill beavers - save tree!

Oleksandr Davyskiba zviryatko

😱
Kill beavers - save tree!
  • Ukraine, Kiev
View GitHub Profile
name: automated-tests
# only manual run
on:
workflow_dispatch:
jobs:
automated-tests:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v2
@zviryatko
zviryatko / Dockerfile
Created April 11, 2024 09:11
Drupal development
FROM skilldlabs/php:82 as spx
RUN apk update && apk add php82-dev libzip-dev libxml2-dev openssl git unzip acl zlib-dev autoconf g++ make \
&& cd /opt \
&& wget https://github.com/NoiseByNorthwest/php-spx/archive/refs/heads/master.zip -O php-spx.zip \
&& unzip php-spx.zip \
&& rm php-spx.zip \
&& cd php-spx-master \
&& phpize82 \
&& ./configure --with-php-config=/usr/bin/php-config82 \
&& make \
@zviryatko
zviryatko / invoke.sh
Last active October 25, 2023 10:52
Invoke aws lambda with http request
#!/bin/bash
# Payload example:
# '{"httpMethod": "GET", "path": "/foo/bar"}'
FUNCTION_NAME=$1
PAYLOAD=$2
aws lambda invoke --function-name ${FUNCTION_NAME} --invocation-type RequestResponse --cli-binary-format raw-in-base64-out --payload "${PAYLOAD}" /tmp/response.json && cat /tmp/response.json | jq -r '.body' | jq
@zviryatko
zviryatko / README.md
Last active August 16, 2023 08:46
Useful bash scripts for analyzing AWS Aurora DB audit logs.

Usage

  1. Enable RDS logger
  2. Run some huge operations
  3. Download each audit log one by one in single folder.
  4. Run next command to join all logs to single file: cat * | awk -F "'" 'BEGIN{OFS="'\''"} NF-=1 {$1=""; print $0}' | cut -c2- > all.sql
  5. Download and run analyze.sh.

image

@zviryatko
zviryatko / BetterRestExportNested.php
Created August 7, 2023 20:03
Better REST export for Drupal 10 Views
<?php
namespace Drupal\better_rest_api\Plugin\views\display;
use Drupal\Core\Render\RenderContext;
use Drupal\Component\Utility\Html;
use Drupal\rest\Plugin\views\display;
use Drupal\views\Render\ViewsRenderPipelineMarkup;
/**
@zviryatko
zviryatko / Translate-video.md
Last active November 15, 2023 11:59
Extract subtitles from video and translate them

Put video file with name video.mp4

# create virtual env
python -m venv .venv
source .venv/bin/activate
# install dependencies for extracting audio file from video
pip install -r requirements.txt
python extract_audio.py
# install OpenAi Whisper to extract text and translate on the fly
pip install openai-whisper
@zviryatko
zviryatko / gd-tutor.ipynb
Created April 13, 2023 12:14
Very simple NN with one layer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zviryatko
zviryatko / build.xml
Created July 11, 2018 16:25
Phing tasks for local drupal development
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Phing configuration file
-
- Installation:
- `curl -OLsS https://www.phing.info/get/phing-latest.phar`
- `chmod +x phing-latest.phar`
- `mv phing-latest.phar /usr/local/bin/phing-latest`
-
- Configuration:
@zviryatko
zviryatko / README.md
Last active December 3, 2018 16:02
phpstan for Drupal 8

Installation

  1. composer require --dev phpstan/phpstan
  2. Add composer patch https://github.com/phpstan/phpstan/pull/1080.patch
  3. Put this files to your project in phpstan directory
  4. Run it: ./bin/phpstan analyse -c ./phpstan/phpstan.neon -l max docroot/modules/custom/
@zviryatko
zviryatko / random-wallpaper.sh
Last active December 19, 2016 21:26
Get random wallpaper from http://desktoppr.co/
#!/bin/bash
# Download random wallpaper from desktoppr.co
# Save this file:
# $ curl -s https://gist.githubusercontent.com/zviryatko/055f8f4850bf17323c4f127a4daeccdf/raw/random-wallpaper.sh > $HOME/.local/bin/random-wallpaper
# $ chmod a+x $HOME/.local/bin/random-wallpaper
# $ crontab -e
# and add this line to the end:
# */20 * * * * $HOME/.local/bin/random-wallpaper
IMG_PATH="$HOME/.cache/wallpaper.jpg"
curl -s `curl -s https://api.desktoppr.co/1/wallpapers/random | python -c "import json,sys; obj=json.load(sys.stdin); print obj['response']['image']['url'];"` > $IMG_PATH