Skip to content

Instantly share code, notes, and snippets.

View giner's full-sized avatar

Stanislav German-Evtushenko giner

View GitHub Profile
@giner
giner / lib_y2j.sh
Last active February 15, 2024 02:17
How-to YAML
# Usage:
# source lib_y2j.sh
# cat some.yml | y2j
# cat some.yml | ys2j
# y2j some.yml
# ys2j some.yml
# Reading a single YAML document
y2j () { ruby -r yaml -r json -e 'puts JSON.pretty_generate(YAML.load(ARGF))' -- "$@"; }
@giner
giner / install_go.sh
Last active August 1, 2024 09:44
How-to Golang
VERSION=1.21.12
PLATFORM=$(uname -s | tr [:upper:] [:lower:]) # linux / darwin
SRC_URL="https://dl.google.com/go/go$VERSION.$PLATFORM-amd64.tar.gz"
DST_TGZ="/tmp/go.tgz"
# Download
if which curl >/dev/null; then curl "$SRC_URL" -o "$DST_TGZ"; else wget "$SRC_URL" -O "$DST_TGZ"; fi
# Extract
@giner
giner / fix_vim.sh
Last active January 24, 2024 09:47
VIM: make vim useful
## VIM: Unbound copy/paste buffer (default is 50 lines or 10 Kbyte)
echo "set viminfo='100,h" >> ~/.vimrc
## VIM: Increase max tabs limit (useful with `vim -p`, default is 10)
echo "set tabpagemax=100" >> ~/.vimrc
## VIM: Remember more commands and search patterns in history (default is 50)
echo "set history=1000" >> ~/.vimrc
## VIM: Highlight trailing witespaces
@giner
giner / configure_bash.sh
Created October 24, 2019 14:01
BASH: add some usefulness
## bash: keep longer history
sed -i 's/^HISTSIZE=1000$/HISTSIZE=10000/' ~/.bashrc
sed -i 's/^HISTFILESIZE=2000$/HISTFILESIZE=20000/' ~/.bashrc
## Enable search through history with PgUp/PgDn
cat > ~/.inputrc << 'EOF'
$include /etc/inputrc
# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
@giner
giner / configure_gnome.sh
Last active May 19, 2022 04:25
Gnome: configure
## Move window buttons to the left (mimic Unity)
gsettings set org.gnome.desktop.wm.preferences button-layout 'close,maximize,minimize:'
## Show date, week day, week number
gsettings set org.gnome.desktop.interface clock-show-weekday true
gsettings set org.gnome.desktop.calendar show-weekdate true
## Assign '<Ctrl><Shift>d' to detach a tab in gnome-terminal
GSETTINGS_SCHEMA=org.gnome.Terminal.Legacy.Keybindings
GSETTINGS_PATH=/org/gnome/terminal/legacy/keybindings/
@giner
giner / configure_git_to_use_keyring.sh
Last active October 28, 2020 05:56
GIT: store credentials in GNOME Keyring
sudo apt install libsecret-1-dev
dest_bin="$HOME/bin/git-credential-libsecret"
# Compile git-credential-libsecret
cd "$(mktemp -d)"
cp /usr/share/doc/git/contrib/credential/libsecret/* .
make
# Install git-credential-libsecret
@giner
giner / install_libs_for_savage-xr.sh
Last active March 8, 2020 04:52
Install libs needed to run Savage XR on Ubuntu 18.04
#!/bin/bash
# This script installs libraries needed to run Savage XR on Ubuntu 18.04 Desktop x86_64
# NOTE: To run Savage XR successfully you also need to do the following
#
# Run the script to install the required libraries:
# wget https://gist.githubusercontent.com/giner/deda63984b3e45cced7af1d3dcd792ea/raw/install_libs_for_savage-xr.sh
# chmod +x ./install_libs_for_savage-xr.sh
# sudo ./install_libs_for_savage-xr.sh
@giner
giner / extlib.rb
Created April 27, 2020 04:33
RUBY: Call an arbitrary function from a shared C library
# Call an arbitrary function from a shared C library
#
# Usage example:
# require './extlib'
#
# ExtLib.init('libc.so.6', 'char* gnu_get_libc_version()');
# puts ExtLib.gnu_get_libc_version()
#
# OUTPUT: 2.27
@giner
giner / fix_ibus-mozc.sh
Last active October 27, 2024 13:16
JAPANESE: Make ibus-mozc remember last used mode
# Make ibus-mozc remember the last used mode (e.g. hiragana) and not switch back to Alphabet on restart
# See https://github.com/google/mozc/issues/381
cd $(mktemp -d)
apt source ibus-mozc
cd mozc-*/
patch src/unix/ibus/property_handler.cc << 'EOF'
--- src/unix/ibus/property_handler.cc.orig 2020-10-28 17:21:18.000849932 +0900
+++ src/unix/ibus/property_handler.cc 2020-10-28 17:21:34.172696046 +0900
@@ -80,7 +80,7 @@
@giner
giner / install_ansible.sh
Last active November 25, 2020 15:45
Install ansible to a dedicated directory with all dependencies
ansible_version="2.9.*"
sudo apt-add-repository universe
sudo apt install -y python3-pip python3-venv
[[ -d "$HOME/bin" ]] || { mkdir "$HOME/bin"; source $HOME/.profile; }
python3 -m venv ~/ansible
~/ansible/bin/pip3 install wheel