Skip to content

Instantly share code, notes, and snippets.

@anthonyaxenov
anthonyaxenov / here.php
Last active March 24, 2023 08:38
[PHP] Get caller class, function and line number
<?php
/**
* Returns caller class/file name, function and line where current
*
* Potentially doesn't cover all cases, but is simple and pretty handy for use in frameworks.
*
* @param bool $as_array result as array or string in this format: `<file|class>:<func>():<line>`
* @return string|array
*/
@anthonyaxenov
anthonyaxenov / dc.sh
Last active December 7, 2022 15:01
[SHELL] Simple tool for your docker-compose environment
#!/bin/bash
CONTAINER="ds-php" # the name of the container in which to 'exec' something
CONFIG="$(dirname $([ -L $0 ] && readlink -f $0 || echo $0))/docker-compose.yml" # path to compose yml file
CMD="docker-compose -f $CONFIG" # docker-compose command
APP_URL='http://localhost:8000/'
open_browser() {
if which xdg-open > /dev/null; then
xdg-open "$1" </dev/null >/dev/null 2>&1 & disown
elif which gnome-open > /dev/null; then
@anthonyaxenov
anthonyaxenov / ytdlcue.sh
Last active October 9, 2022 05:23
[SHELL] CUE-sheet generator for youtube-dl
#!/bin/bash
# CUE-sheet generator for youtube-dl
# Usage:
# 0. Install 'jq' utility
# 1. Download any audio file with metadata from YouTube or Youtube Music, e.g.
# $ youtube-dl \
# --extract-audio \
# --audio-format flac \
# --audio-quality 0 \
@anthonyaxenov
anthonyaxenov / .gitconfig
Created September 28, 2022 00:02
My favourite global .gitconfig with aliases (ru comments)
[user]
# ...
# signingkey = <key>
# git config user.signingkey ... -- установить ключ
[commit]
gpgSign = true
[tag]
gpgSign = true
[push]
default = current
@anthonyaxenov
anthonyaxenov / quick-backup.sh
Last active August 24, 2022 05:02
[SHELL] Backup your project to another server
#!/bin/bash
#####################################################################
# #
# Stupidly simple backup script for own projects #
# #
# Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.0 #
# License: WTFPLv2 More info: https://axenov.dev/?p=1423 #
# #
#####################################################################
@anthonyaxenov
anthonyaxenov / zsh-fancify.sh
Last active May 13, 2022 15:58 — forked from AlexZeitler/setup-oh-my-zsh-powerlevel9k.sh
Installing zsh / oh-my-zsh / Powerlevel10k on Ubuntu 20.04
#!/bin/bash
# Based on:
# https://github.com/Powerlevel9k/powerlevel9k/wiki/Install-Instructions
# https://github.com/ohmyzsh/ohmyzsh
# https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation
# https://gist.github.com/dogrocker/1efb8fd9427779c827058f873b94df95
# https://linuxhint.com/install_zsh_shell_ubuntu_1804/
echo "*********************************************"
echo " zsh fancifier"
@anthonyaxenov
anthonyaxenov / BasicTestCase.php
Last active January 21, 2022 05:52
[PHP] Useful phpunit asserts
<?php
declare(strict_types = 1);
namespace Tests;
use Illuminate\Support\Collection;
use PHPUnit\Framework\TestCase;
class BasicTestCase extends TestCase
@anthonyaxenov
anthonyaxenov / output.php
Last active December 24, 2021 13:10
[PHP] Simple and universal file logger
<?php
function output(...$data)
{
$result = [];
foreach ($data as $something) {
if ($something instanceof Illuminate\Support\Collection) {
$something = $something->toArray();
}
if (is_array($something)) {
$something = var_export($something, true);
@anthonyaxenov
anthonyaxenov / menu.php
Created October 13, 2020 11:00
[PHP] Пример рекурсивного вывода меню
<?php
$nav = [
[
'name' => 'Home',
'title' => 'Homepage',
// ...something else...
'sub' => [
[
'name' => 'sub11',
'title' => null,
@anthonyaxenov
anthonyaxenov / decode.php
Last active September 23, 2020 10:27
[PHP] Simple equivalent of Oracle's decode()
<?php
/**
* Simple php equivalent of Oracle's decode()
*
* It can be used as simple oneline-alternative to switch or if operators in many
* cases without difficult logic. For example, get string mnemocode of some value:
*
* echo 'State: '.decode($state, 0, 'disabled', 1, 'enabled', 'unknown');
*