Skip to content

Instantly share code, notes, and snippets.

@ssaki
ssaki / upgrade-php.sh
Last active December 15, 2024 16:25
[APT / PHP] Upgrading all installed php8.3 packages to php8.4
#/bin/sh
apt-mark showmanual | grep php8.3 | sed 's|8\.3|8.4|' | xargs apt install -y && apt-mark showmanual | grep php8.3 | xargs apt purge -y
@ssaki
ssaki / UniformCivilNumber.php
Created March 30, 2019 19:35
Symfony validator for Bulgarian uniform civil number (EGN)
<?php
namespace App\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* Constraint for Bulgarian uniform civil number (EGN).
*/
class UniformCivilNumber extends Constraint
@ssaki
ssaki / docker-cleanup-resources.md
Created June 27, 2018 17:55 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@ssaki
ssaki / .bashrc
Created April 19, 2017 09:55
XDebug/PHPStorm "bookmarklets" for CLI
# Couple of functions to set/clean the necessary ENV variables and enable debugging with PHPStorm
# in the same manner as debug bookmaklets for web debugging
#
# The server name argument is name of the server in PHPStorm's "Run/Debug configurations" settings screen
# ( "Run" > "Edit configurations" > "PHP Web Applications" )
#
xdebug_on()
{
if [ "$1" == "" ]; then
@ssaki
ssaki / fix-sf-permissions.sh
Last active March 28, 2017 14:27
CLI script to setup Symfony's cache/log directory permissions (supports both 2.7- and 2.8/3.0+)
#!/usr/bin/env bash
#
# Based on instructions from Symfony's documentation (setfacl section) without any modifications:
# http://symfony.com/doc/current/setup/file_permissions.html
#
# Usage:
# 1. Copy to /usr/local/bin (or any other directoy in your path)
# 2. make the script executable: chmod +x /usr/local/bin/fix-sf-permissions.sh
# 3. Invoke from within a directory hosting a symfony project (top level only)
@ssaki
ssaki / .php_cs.php
Last active January 2, 2018 11:27
Customized php-cs-fixer rules and alias
<?php
// Only fix files in the current directory
$finder = PhpCsFixer\Finder::create()
->in(getcwd())
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->depth('== 0')
;
@ssaki
ssaki / .bashrc
Last active December 15, 2024 16:27
Syntax higlighted sql output for the symfony/doctrine CLI
# requires `sudo apt install python3-pygments`
alias dump-sql='bin/console doctrine:schema:update --dump-sql | pygmentize -l mysql -f terminal'
@ssaki
ssaki / drop_all_tables.sql
Created October 2, 2016 08:46
Snippet to empty the current database regargless of FK constraints
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
@ssaki
ssaki / secondary-skype.sh
Last active May 11, 2022 06:56
Script to setup a secondary skype on a Ubuntu/Mint box
#!/bin/sh
#
# A simple script to create a skype launcher
# that will pass alternative data home directory
# thus making it easy to run two Skype instances alongside
#
# Tesed on Mint 18
# Requires the latest skypeforlinux.deb (v.8) from Microsoft