Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / .bash_aliases
Last active June 28, 2023 13:49
[SHELL] My favorite bash aliases
#!/bin/bash
# alias bashrc='source ~/.bashrc'
alias zshrc='source ~/.zshrc'
alias realias='source ~/.bash_aliases'
alias reload='exec ${SHELL} -l'
alias sudo='sudo ' # enable aliases to be sudo’ed
alias g='git'
alias hosts="sudo nano /etc/hosts"
alias shrug="echo '¯\_(ツ)_/¯' | xclip -selection c"
@anthonyaxenov
anthonyaxenov / s3-backup.sh
Last active December 23, 2023 20:26
[SHELL] Backup your project to another server
#!/bin/bash
#####################################################################
# #
# Stupidly simple backup script for own projects #
# #
# Author: Anthony Axenov (Антон Аксенов) #
# Version: 1.2 #
# License: WTFPLv2 More info (RU): https://axenov.dev/?p=1272 #
# #
#####################################################################