Skip to content

Instantly share code, notes, and snippets.

Avatar
🐱
Meow

Evgenii Danilin danilin-em

🐱
Meow
View GitHub Profile
@danilin-em
danilin-em / webm2mp4.desktop
Created Nov 14, 2020
KDE | Dolphin | Service menu | Convert WebM to MP4
View webm2mp4.desktop
# webm2mp4.desktop
# KDE | Dolphin | Service menu | Convert WebM to MP4
# --- INSTALL ---
# 1. Copy `webm2mp4.desktop` to `$HOME/.local/share/kservices5/ServiceMenus/`
# 2. Update entries `kbuildsycoca5`
[Desktop Entry]
Type=Service
Icon=video-webm
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
@danilin-em
danilin-em / dbus_session_lock.py
Created Dec 1, 2019
Lock Screen via DBus (Python)
View dbus_session_lock.py
"""DBus Display Manager Session Lock
@author Evgenii Danilin <evgenii.danilin.m@gmail.com
"""
import dbus # type: ignore
SERVICE_NAME = 'org.freedesktop.DisplayManager'
@danilin-em
danilin-em / docker-php-alpine-entrypoint.sh
Created Nov 27, 2019
Docker Entrypoint for PHP Alpine
View docker-php-alpine-entrypoint.sh
#!/bin/sh
set -e
COMPOSER_BIN=/usr/local/bin/composer
if [ "$SKIP_COMPOSER" == "false" ]; then
if [ ! -f $COMPOSER_BIN ]; then
curl -sS https://getcomposer.org/installer | php
mv composer.phar $COMPOSER_BIN
fi
@danilin-em
danilin-em / wait_db.php
Created Nov 26, 2019
[PHP] Waiting DB Connection (Default: pgsql > PostgreSQL)
View wait_db.php
<?php
$driver = getenv('DB_DRIVER') ?: 'pgsql';
$host = getenv('DB_HOST') ?: 'localhost';
$port = getenv('DB_PORT') ?: 5432;
$dbname = getenv('DB_NAME');
$user = getenv('DB_USER');
$pass = getenv('DB_PASSWORD');
$dsn = sprintf('%s:host=%s;port=%d;dbname=%s', $driver, $host, $port, $dbname);
$tries = 10;
while (true) {
@danilin-em
danilin-em / line_animation.py
Last active Nov 24, 2019
Animation for long string
View line_animation.py
""" Animation for long string
Usage:
myapp.py:
-----------------------------------------------------------------------------------
line = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod'
idx = 0
while True:
idx, short_line = line_animation(line, idx, 5)
print(short_line, end='\r')
@danilin-em
danilin-em / dev_shm.py
Last active Nov 24, 2019
Using /dev/shm as Storage
View dev_shm.py
""" Saving Value in to /dev/shm
See: https://gerardnico.com/os/linux/shared_memory
Usage:
myapp.py
-----------------------------------------
ds = DevShm('myapp')
idx = int(ds.get('index', 0))
print('My App index:', idx)
idx += 1