Skip to content

Instantly share code, notes, and snippets.

View loplex's full-sized avatar

Martin (Lopin) Lopatář loplex

  • DataPLEX
  • Brno, Czech Republic
  • 14:06 (UTC +02:00)
View GitHub Profile
# add to your ~/.bashrc either direct content of this file or the following line:
# . /path/to/this/file.sh
jhome() {
java_home="$(/usr/libexec/java_home -f -v "$@")"
local err_handler='{ printf "%s\n" "ERROR!!!"; ls -ld "${java_home}"{,/bin,/bin/java}; /usr/libexec/java_home -V; return 1; }'
{ [ -n "${java_home}" ] && [ -d "${java_home}" ] && [ -d "${java_home}/bin" ] && [ -f "${java_home}/bin/java" ] && [ -x "${java_home}/bin/java" ]; } || eval "${err_handler}"
@dimo414
dimo414 / _README.md
Last active November 28, 2022 07:25
Bash array expansion patterns for use with -u

Expanding Bash arrays safely with set -u

Prior to Bash 4.4 set -u treated empty arrays as "unset", and terminates the process. There are a number of possible workarounds using array parameter expansion, however almost all of them fail in certain Bash versions.

This gist is a supplement to this StackOverflow post.

@loplex
loplex / VirtualBox_on_Windows-use_raw_partition_without_UAC.ps1
Last active April 17, 2020 11:47
VirtualBox_on_Windows-use_raw_partition_without_UAC.ps1
# hard-coded:
# user: 'vbox'
# disk: PhysicalDrive0
# partition: Partition5 (Harddisk0Partition5)
######### set permission for physical drive #############
$account = "vbox"
drivesPaths = "\\.\PhysicalDrive0", "\\.\Harddisk0Partition5"
@wizcas
wizcas / winterm-callout.ahk
Last active May 5, 2022 07:37
AHK Script for Calling Out Windows Terminal
; How much height of screen size the terminal window takes.
VRatio := 0.8
; The path to the Windows Terminal exe file.
WtPath = "%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe"
#SC29::ToggleTerminal()
ShowAndPositionTerminal()
{
ScreenX := GetScreenLeft()
@loplex
loplex / ptswrite.py
Created April 14, 2019 08:45
allows to send data to STDIN of another process already running having STDIN attached to terminal
#!/usr/bin/python2.7
### allows to send data to STDIN of another process already running having STDIN attached to terminal
### FROM: https://stackoverflow.com/a/29616465/3295944
### but it doesn't work (fail process command line argument), but fixed here
'''
Here is how you use it:
@detunized
detunized / join.sh
Last active March 6, 2024 20:09
Join repos into subfolders with flat history
#!/bin/bash
set -euo pipefail
$REPO_DIR=~/devel
repos="1password bitwarden dashlane lastpass opvault passwordbox roboform stickypassword truekey zoho-vault"
# pull all repos
(
for repo in $repos; do
echo $repo
@xiaokangwang
xiaokangwang / ubuntu-cli-install-android-sdk.sh
Last active September 13, 2023 19:16 — forked from zhy0/ubuntu-cli-install-android-sdk.sh
Install Android SDK on headless Ubuntu linux machine via command line, so that you can compile open source Android apps.
#!/bin/bash
# Thanks to https://gist.github.com/wenzhixin/43cf3ce909c24948c6e7
# Execute this script in your home directory. Lines 17 and 21 will prompt you for a y/n
# Install Oracle JDK 8
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install -y oracle-java8-installer
apt-get install -y unzip make expect # NDK stuff
@weihanglo
weihanglo / openssl-cheatsheet.sh
Last active December 5, 2020 02:01
OpenSSL CheatSheet
# Create X509 self-signed certificate.
openssl req \
-newkey rsa:2048 -nodes -keyout cert.key \
-x509 -days 365 -out cert.pem
# Convert from PEM format to DER.
openssl pkcs12 \
-inkey cert.key -in cert.pem \
-export -out cert.pfx
#!/bin/sh
### it will call 'inspect' on found docker volumes by default, you can delete them providing 'rm' as parameter
docker_volume_action=${1:-inspect}
#echo $docker_volume_action
docker volume ls -qf dangling=true | xargs -r docker volume $docker_volume_action
lib_name='trap'
lib_version=20121026
stderr_log="/dev/shm/stderr-$(date +%s).log"
#
# TO BE SOURCED ONLY ONCE:
#
###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##