Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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_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 / 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 / install_go.sh
Last active August 28, 2023 09:20
How-to Golang
VERSION=1.21.0
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 / 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))' -- "$@"; }