Skip to content

Instantly share code, notes, and snippets.

View loplex's full-sized avatar

Martin (Lopin) Lopatář loplex

  • DataPLEX
  • Brno, Czech Republic
  • 05:42 (UTC +02:00)
View GitHub Profile
#!/bin/bash
function sampleImput() {
printf "%s\0" 'a b' 'c d'
}
# using read:
#!/bin/bash
# Computes the CRC16 - XMODEM (also known as ZMODEM or CRC-16/ACORN)
# rewritten to bash from C code found at: https://beebwiki.mdfs.net/CRC-16
declare -i poly=0x1021
declare -i init=0x0000
function crc16() {
local input="$1"
#!/bin/sh
set -xe
endpoint="$1"
# append specification to use port 443 if no port is provided
[[ ! "$endpoint" =~ ^.*:[0-9]+$ ]] && endpoint="${endpoint}:443"
# remove leading protocol if it is provided (e.g. https://)
endpoint="$(echo "$endpoint" | sed -e 's/^[^\:]*\:\/\/*//')"
#!/bin/sh
# pipe "file.har" to this script
jp "log.entries[*].response.content.text" | jq -c '.[]' | tr '\n' '\0' | xargs -0 -I '{}' sh -c 'echo -e {} $"\0"'
# If you want to write responses to separate files, pipe response of this script to
# |xargs -0 sh -c 'count=0; for fl in "$@"; do echo "$fl" > "fl$(printf "%03d" "$count")"; (( count++ )); done'
# 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}"

Keybase proof

I hereby claim:

  • I am loplex on github.
  • I am loplex (https://keybase.io/loplex) on keybase.
  • I have a public key ASCr9HiXXruZUN56Tq0Y2RfjyTQcmt4OGRWp0p9KuJcTKwo

To claim this, I am signing this object:

#!/bin/bash -e
###
### * Save this script and make it executable:
### 1. Put the script to your filesystem into this filepath:
### - /usr/local/bin/fix-etc-resolv.conf-wsl.sh
### 2. Make it excecutable using:
### - sudo chmod a+x /usr/local/bin/fix-etc-resolv.conf-wsl.sh
###
### * Allow the script to be run as root without providing a password using:
### 1. Run:
@loplex
loplex / remap_caps_lock_key_to_left_shift_key.sh
Created June 27, 2020 08:12
remap Caps Lock key to Shift Left key
#!/bin/sh
### inspiration taken from: https://askubuntu.com/questions/371394/how-to-remap-caps-lock-key-to-shift-left-key
set -x
# this will make Caps Lock to act as Shift_L
xmodmap -e "keycode 66 = Shift_L NoSymbol Shift_L"
echo "xmodmap exit code: $?"
set +x
@loplex
loplex / dlocate.sh
Created June 4, 2020 06:57
locate command filtered to directories only
#!/bin/sh
for directory in `locate $@`; do
if [ -d "$directory" ]; then echo $directory; fi;
done
@loplex
loplex / get_tds_cert.py
Last active June 2, 2020 13:50 — forked from lnattrass/get_tds_cert.py
A terrible way to connect to MS SQL Server and dump the certificate as a PEM
#!/usr/bin/python3
import sys
import pprint
import struct
import socket
import ssl
from time import sleep
# Standard "HELLO" message for TDS