Skip to content

Instantly share code, notes, and snippets.

@andkirby
andkirby / revert_config_dump.sh
Last active Oct 2, 2020
Remove added data after `magento app:config:dump`
View revert_config_dump.sh
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 Oct 1, 2020
Merge ssh split config files into end ~/.ssh/config.
View ssh_config_merge.sh
################################################################################
# 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 Aug 19, 2020
Reset time on ssh login in a Unix system
View reset_time_on_ssh_login.sh
########################################
# 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 Aug 19, 2020
Synchronize .ssh files from Windows file system to Ubuntu WSL
View sync_ssh_files_wsl_ubuntu
#!/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 Jun 25, 2020
Downloader for Git Bash for Windows
View git-downloader
#!/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 Jan 30, 2020
AutoHotKey. Test reading rich text from a file
View clip_read_write_test.ahk
#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 Aug 29, 2019
Download all Amazon MWS XSD files recursively.
View fetch-all-xsd.sh
#!/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 Nov 6, 2018
Magento 2.x binary file auto-complete installation in Bash CLI.
View bash-magento2-autocomplete-install.sh
#!/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 Jan 17, 2019
Fetch Ruby interpreter from GitBash for Windows or Cygwin similar CLI.
View ruby-bash-win.sh
#!/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
#
View bash-script-template.sh
#!/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)"