Skip to content

Instantly share code, notes, and snippets.

View bashkirtsevich's full-sized avatar
:octocat:
bashkirtsevich.github.io

D.A.Bashkirtsev bashkirtsevich

:octocat:
bashkirtsevich.github.io
View GitHub Profile
@bashkirtsevich
bashkirtsevich / docker
Created September 15, 2023 20:24
Original /etc/init.d/docker file from deb (usefull for WSL2)
#!/bin/sh
set -e
### BEGIN INIT INFO
# Provides: docker
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: cgroupfs-mount cgroup-lite
# Should-Stop: cgroupfs-mount cgroup-lite
# Default-Start: 2 3 4 5
@bashkirtsevich
bashkirtsevich / demo.sh
Created July 8, 2022 14:15
Save composer images
for img in $(docker-compose -f some-docker-composecompose.yml images -q); do fn=$(docker inspect $img | jq -r '.[] | .RepoTags | .[-1]' | sed -r 's/[\/]+/_/g'); docker image save $img > gqip > /docker/dump/$fn.tar.gz; done
@bashkirtsevich
bashkirtsevich / docker-prune-unnamed.sh
Last active April 21, 2022 12:30
Delete unnamed docker images
docker rmi $(docker images -f 'dangling=true' -q)
@bashkirtsevich
bashkirtsevich / split.sh
Last active February 9, 2022 21:06
Enum os envs values by pattern
#!/bin/sh
vals=""
while read -r line ; do
val=$(echo $line | cut -d= -f2)
vals+="$val "
done < <(env | grep ENV)
for val in $vals ; do
echo "Found val $val"
@bashkirtsevich
bashkirtsevich / utc_tz_diff.py
Created December 20, 2021 19:20
UTC Timezone Diff
from datetime import datetime
from pytz import UTC
from pytz import timezone
def utc_tz_diff(tz):
diff = (t1 := UTC.localize(now := datetime.utcnow())) - (t2 := timezone(tz).localize(now).astimezone(UTC))
return f"{'+' if t1 > t2 else '-'}{diff.seconds // 3600:02}:{diff.seconds // 60 % 60:02}" if diff.seconds else "Z"
@bashkirtsevich
bashkirtsevich / docker-compose.yml
Last active February 14, 2023 21:53
Self signed ssl nginx
version: '3.7'
services:
nginx:
image: nginx:alpine
command: >
sh -c "
apk add openssl &&
mkdir -p /var/www/backend/certs/ &&
cd /var/www/backend/certs/ &&
@bashkirtsevich
bashkirtsevich / upload.sh
Created October 11, 2021 19:28
Automatic github uploader
#!/bin/bash
TOKEN="..."
ORG="..."
for repo in */ ; do
repo_name=$(echo $repo | sed 's/\///')
echo "Found folder $repo_name"
cp LICENSE $repo_name/LICENSE
@bashkirtsevich
bashkirtsevich / facebook.py
Created July 5, 2021 17:19
aiohttp oauth2
from aiohttp import web
from aiohttp_oauth2.client.contrib import oauth2_app
from aiohttp_session import SimpleCookieStorage, get_session, setup as session_setup
async def index(request: web.Request):
session = await get_session(request)
return web.json_response({"user": session.get("user")})
$ apm list --installed
Community Packages (15) ~/.atom/packages
├── busy-signal@2.0.1
├── duplicate-removal@0.1.3
├── file-icons@2.1.44
├── git-blame@1.8.0
├── git-log@0.4.1
├── git-time-machine@2.1.0
├── intentions@1.1.5
├── language-docker@1.1.8
@bashkirtsevich
bashkirtsevich / delete.sh
Created May 3, 2021 18:35
RabbitmqCtl delete queues
rabbitmqctl list_queues | sort -r | awk '{if (length($1) == 36) print $1}' | while read queue ; do rabbitmqctl delete_queue $queue & done