Skip to content

Instantly share code, notes, and snippets.

@andkirby
andkirby / revert_config_dump.sh
Last active October 2, 2020 14:50
Remove added data after `magento app:config:dump`
php -r '$config = require "app/etc/config.php"; \
$config = ["modules" => $config["modules"]]; \
echo "<?php\nreturn "; var_export($config); \
echo ";";' \
> app/etc/config.php.cleaned && mv app/etc/config.php.cleaned app/etc/config.php
php -r '$config = require "app/etc/env.php"; \
unset($config["system"]); \
echo "<?php\nreturn "; \
var_export($config); \
@andkirby
andkirby / ssh_config_merge.sh
Last active October 1, 2020 11:37
Merge ssh split config files into end ~/.ssh/config.
################################################################################
# This script can merge all split SSH configuration into `~/.ssh/config` file.
#
# HOW IT WORKS
# It will merge all files by mask config.*.merge, i.e.:
# ~/.ssh/config.MY_PROJECT.merge
# Initial exists `~/.ssh/config` file will be copied to `~/.ssh/config.orig`.
# Use this `config.orig` for further changes.
#
# Anyway, you may not use this script and just run:
@andkirby
andkirby / reset_time_on_ssh_login.sh
Last active August 19, 2020 11:07
Reset time on ssh login in a Unix system
########################################
# Reset time on login #
########################################
# you may try to use system last logged time: `last ${USER} -n1 | head -1 | awk '{print $4" "$5" "$6" "$7}'`
time_sync_command='sudo ntpdate -s time.nist.gov'
# max time not logged value
not_logged_max_time_h=6
@andkirby
andkirby / sync_ssh_files_wsl_ubuntu
Created August 19, 2020 08:04
Synchronize .ssh files from Windows file system to Ubuntu WSL
#!/usr/bin/env bash
##################################################################
# Synchronize .ssh files from Windows file system to Ubuntu WSL #
##################################################################
set -o pipefail
set -o errexit
set -o nounset
#set -o xtrace
# Set magic variables for current file & dir
@andkirby
andkirby / git-downloader
Last active June 25, 2020 17:12
Downloader for Git Bash for Windows
#!/usr/bin/env bash
##################################################################
# Automatically download Git Bash for Windows portable version #
##################################################################
# Quick running:
# curl -Ls https://gist.githubusercontent.com/andkirby/16e3c7e4be8bac4c6b3bd0ae8f713552/raw/git-downloader | bash
##################################################################
@andkirby
andkirby / clip_read_write_test.ahk
Created January 30, 2020 12:29
AutoHotKey. Test reading rich text from a file
#ClipboardTimeout 2000
#SingleInstance force
; Working example
; You may test in some wysiwyg editor
; Win + R — Write clipboard
#r::
{
ClipWait
@andkirby
andkirby / fetch-all-xsd.sh
Last active August 29, 2019 14:44
Download all Amazon MWS XSD files recursively.
#!/usr/bin/env bash
#############################################################################
# Download Amazon MWS XSD file with all included ones recursively
# It will download XSD files into the same directory of this script
#############################################################################
# USAGE
# $ bash fetch-all-xsd.sh URL_START_XSD_FILE
#
# EXAMPLE
# $ bash fetch-all-xsd.sh https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_4_1/amzn-envelope.xsd
@andkirby
andkirby / bash-magento2-autocomplete-install.sh
Last active November 6, 2018 04:55
Magento 2.x binary file auto-complete installation in Bash CLI.
#!/usr/bin/env bash
###################################
# Auto-complete for Magento2 console "bin/magento" file
#
# Download and install:
# $ curl -Ls https://gist.github.com/andkirby/76c5f09d8c6bd55d0fe21a906d72defe/raw/bash-magento2-autocomplete-install.sh | bash
#
# MANUAL INSTALLATION
# "bash-completion" installation:
# $ yum install -y bash-completion
@andkirby
andkirby / ruby-bash-win.sh
Last active January 17, 2019 12:11
Fetch Ruby interpreter from GitBash for Windows or Cygwin similar CLI.
#!/usr/bin/env bash
################################################################################
# This script can install RUBY binaries on Windows in Bash.
#
# Link to this file:
# https://gist.github.com/andkirby/caf9e825e83f38ad98721956d6e0107c/raw/ruby-bash-win.sh
#
# Download latest version by command in GitBash Windows console:
# $ curl -Ls bit.ly/ruby-bash-win | bash
#
#!/usr/bin/env bash
# Script for testing options
set -o pipefail
set -o errexit
set -o nounset
#set -o xtrace
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"