Skip to content

Instantly share code, notes, and snippets.

@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 / 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_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
@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 / HelloFeign.java
Last active August 29, 2021 11:39
Java, OpenFeign: Minimalistic quick start example
// Usage:
// curl -L -O https://repo1.maven.org/maven2/io/github/openfeign/feign-core/11.6/feign-core-11.6.jar
// java -cp feign-core-11.6.jar HelloFeign.java
import feign.Feign;
import feign.RequestLine;
public class MyFeignClient {
private static final String uriPrefix = "https://github.com";
@giner
giner / java-mtls-client.sh
Last active August 29, 2021 12:33
Java: Enable client side mTLS without modifying application
# Notes:
# - option javax.net.ssl.trustStore replaces default java truststore
# i.e. TLS connections other than mTLS won't be possible unless
# the new truststore contains Common CA certificates
# - The custom CA certificate from truststore.pkcs12 will be used by
# all TLS connections initiated from the app. Make sure you can
# fully trust this CA in your specific case.
# - Generation of the keystores is not a part of this snippet and can
# be easily found on other resources
#
@giner
giner / HelloWorldJava
Last active August 29, 2021 13:35
Java: Run Java code without compiling (JEP 330)
#!/usr/bin/env -S java --source 11
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
@giner
giner / xorg_remap_play_to_micmute.sh
Last active November 30, 2021 03:46
Remap Play button to Mic Mute (primarily for Bluetooth Headsets)
#!/bin/sh
# NOTE: This change won't persist if package xkb-data is reinstaled or updated
sudo sed -i '/key <I208>/s/\bXF86AudioPlay\b/XF86AudioMicMute/' /usr/share/X11/xkb/symbols/inet
@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/