Skip to content

Instantly share code, notes, and snippets.

Avatar

Anthony Axenov anthonyaxenov

View GitHub Profile
@anthonyaxenov
anthonyaxenov / dc.sh
Last active Feb 20, 2022
[SHELL] Simple tool for your docker-compose environment
View dc.sh
#!/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 / convert.php
Last active Jan 17, 2022
[PHP] Simple Postman Collection to http converter
View convert.php
#!/bin/php
<?php
/***********************************************************************************************************************
* Simple Postman Collection Converter
*
* Author: Anthony Axenov (c) 2021
* Version: v1.1
* License: MIT
* Dependecies: php8.0, php-json
@anthonyaxenov
anthonyaxenov / install-golang.sh
Last active Feb 23, 2022
[BASH] Install golang
View install-golang.sh
#!/bin/bash
# GoLang installer
# https://golang.org/doc/install
# https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu
# if [ "$EUID" -ne 0 ]
# then echo "*** root permissions required ***"
# exit
@anthonyaxenov
anthonyaxenov / output.php
Last active Dec 24, 2021
[PHP] Simple and universal file logger
View output.php
<?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 / BasicTestCase.php
Last active Jan 21, 2022
[PHP] Useful phpunit asserts
View BasicTestCase.php
<?php
declare(strict_types = 1);
namespace Tests;
use Illuminate\Support\Collection;
use PHPUnit\Framework\TestCase;
class BasicTestCase extends TestCase
@anthonyaxenov
anthonyaxenov / set-resolution.sh
Created Jun 20, 2021
[BASH] Set display resolution
View set-resolution.sh
#!/bin/bash
#########################################################################
# #
# Set display resolution #
# #
# Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.0 #
# License: WTFPL #
# #
#########################################################################
@anthonyaxenov
anthonyaxenov / args.sh
Last active May 27, 2021
[BASH] Argument parser for bash scripts without getopt or getopts
View args.sh
#!/bin/bash
#########################################################################
# #
# Argument parser for bash scripts #
# #
# Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.5 #
# License: MIT #
# #
#########################################################################
@anthonyaxenov
anthonyaxenov / stacktrace.sh
Last active Aug 29, 2021 — forked from akostadinov/stack_trace.sh
[BASH] Print stacktrace
View stacktrace.sh
# Original: https://gist.github.com/akostadinov/33bb2606afe1b334169dfbf202991d36
# The difference is that this func outputs stacktrace in reverse order (from top level to lower ones)
function print_stacktrace () {
STACK=""
local i
local stack_size=${#FUNCNAME[@]}
echo "Stacktrace:"
# skip this function and "MAIN non_file_source:0"
for (( i=$stack_size-1; i>=1; i-- )); do
local func="${FUNCNAME[$i]}"
@anthonyaxenov
anthonyaxenov / io.sh
Last active Jan 30, 2021
[BASH] Полезные скрипты для переиспользования
View io.sh
#!/bin/bash
# source: https://misc.flogisoft.com/bash/tip_colors_and_formatting
########################################################
# Иконки
########################################################
IINFO="[ i ]"
INOTE="[ * ]"
IWARN="[ # ]"
@anthonyaxenov
anthonyaxenov / menu.php
Created Oct 13, 2020
[PHP] Пример рекурсивного вывода меню
View menu.php
<?php
$nav = [
[
'name' => 'Home',
'title' => 'Homepage',
// ...something else...
'sub' => [
[
'name' => 'sub11',
'title' => null,