Skip to content

Instantly share code, notes, and snippets.

@bashenk
bashenk / wsl_x11_setup.sh
Last active August 8, 2023 09:03
Auto setup of X11 on WSL without disabling access control
#!/usr/bin/env sh
say() { if ! ${quiet:-false}; then printf '%s\n' "$@"; fi; }
err() { echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2; }
# File name of the Windows xserver program
win_xserver='vcxsrv.exe'
# Full path to the Windows xauth program for the running xserver
# PROGRA~1 is the short name for "Program Files", which solves spaces issues
@bashenk
bashenk / AndroidDeviceEnrollmentQRCreation.md
Last active May 6, 2024 11:16
Creating a QR Code for Android Device Enrollment
function Format-NewBootableUSB() {
[CmdletBinding(DefaultParameterSetName='Default')]
Param(
[Parameter(Position=0,Mandatory=$True,ParameterSetName='Default')]
[Parameter(Position=0,Mandatory=$True,ParameterSetName='CopyOnly')]
[String]$FirstPartitionSourceFolder,
[Parameter(Position=1,ParameterSetName='Default')]
[Parameter(Position=1,ParameterSetName='CopyOnly')]
[String]$SecondPartitionSourceFolder,
<#
.SYNOPSIS
Add a Wi-Fi network profile to the wlan table
#>
Function Add-WifiNetwork {
[CmdletBinding(DefaultParameterSetName='PassPhrase')]
Param(
## The name of a wireless LAN profile, as well as the SSID of the wireless LAN.
[Parameter(Position=0,Mandatory=$true)]
[String]$SSIDName,
<#
.SYNOPSIS
Removes null property values from objects.
.DESCRIPTION
Removes property values that are null (or empty, unless -LeaveEmptyStrings parameter is use) from an object or array of objects. Additional items may be removed if they are passed as input to the -AlsoRemove parameter.
.EXAMPLE
[pscustomobject]@{Number=1;String="Test";Empty="";Null=$null} | Remove-Null
Number String
------ ------
@bashenk
bashenk / fix-grub.sh
Created August 6, 2020 18:18 — forked from lovromazgon/fix-grub.sh
This script fixes GRUB for systems, that were installed according to the Manual Full System Encryption guide (https://help.ubuntu.com/community/ManualFullSystemEncryption). It is inspired by the original script used in the guide and reuses a lot of parts from it. Use an Ubuntu Live CD / USB to get to a terminal and run the script from there.
#!/usr/bin/env bash
####################################################################################################
#
# FIX GRUB FOR ENCRYPTED INSTALLATION
#
# This script is based on the Troubleshooting part of the Manual Full System Encryption for Ubuntu.
# See https://help.ubuntu.com/community/ManualFullSystemEncryption/Troubleshooting
#
# This is NOT AN OFFICIAL Ubuntu script, it can and will break your system. Use at own risk.
@bashenk
bashenk / get_android_service_call_numbers.sh
Last active January 25, 2023 19:49 — forked from ktnr74/get_android_service_call_numbers.sh
POSIX compliant and portable fork. Now has been updated with more optional parameters, more optimizations, and better error handling. If -t or -v are specified, an android device is not required.
#!/usr/bin/env sh
set -u
# https://stackoverflow.com/questions/2683279/how-to-detect-if-a-script-is-being-sourced#28776166
sourced=0
if [ -n "${ZSH_EVAL_CONTEXT-}" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1;; esac;
elif [ -n "${KSH_VERSION-}" ]; then
if [ "$(cd "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")" != "$(cd "$(dirname -- "${.sh.file}")" && pwd -P)/$(basename -- "${.sh.file}")" ]; then
sourced=1