Skip to content

Instantly share code, notes, and snippets.

@anthonyaxenov
anthonyaxenov / convert.php
Last active August 3, 2023 08:38
[PHP] Simple Postman Collection to http converter
<?php
// This gist was erased.
// I recommend you to take a closer look at my new cli-tool:
//
// https://packagist.org/packages/axenov/pm-convert
//
// It can convert multple collections v2.1 to http/wget/curl formats
// very quickly and without 3rd-party dependencies.
@anthonyaxenov
anthonyaxenov / install-golang.sh
Last active June 28, 2023 14:07
[SHELL] Install golang
#!/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 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 / 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 / set-resolution.sh
Last active June 28, 2023 14:07
[SHELL] Set display resolution
#!/bin/bash
#########################################################################
# #
# Set display resolution #
# #
# Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.0 #
# License: WTFPL #
# #
#########################################################################
@anthonyaxenov
anthonyaxenov / args.sh
Last active September 11, 2023 12:30
[SHELL] Argument parser for bash scripts without getopt or getopts
#!/bin/bash
#########################################################################
# #
# Argument parser for bash scripts #
# #
# Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.5 #
# License: MIT #
# #
#########################################################################
@anthonyaxenov
anthonyaxenov / stacktrace.sh
Last active June 28, 2023 14:10 — forked from akostadinov/stack_trace.sh
[SHELL] Print stacktrace
# 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 / menu.php
Created October 13, 2020 11:00
[PHP] Пример рекурсивного вывода меню
<?php
$nav = [
[
'name' => 'Home',
'title' => 'Homepage',
// ...something else...
'sub' => [
[
'name' => 'sub11',
'title' => null,
@anthonyaxenov
anthonyaxenov / coalesce.php
Created September 23, 2020 10:14
[PHP] Simple equivalent of Oracle's coalesce()
<?php
/**
* Simple php equivalent of Oracle's coalesce()
*
* It can be used as simple oneline-alternative to switch or if operators in many
* cases without difficult logic. For example, get first non-empty value from bunch of vars:
*
* echo coalesce($var1, $var2, $var3, ...);
*
@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');
*