This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: timeout [ OPTIONS ] CMD [ ARG... ] | |
# | |
# Runs CMD and waits for it to terminate, signalling it with a primary signal after a timeout, and optionally signalling | |
# it with a secondary signal after an additional timeout. | |
# | |
# Termination of any subprocesses launched by CMD is not guaranteed: it depends on the signals sent to CMD and the | |
# behavior of CMD (such as propagating signals to subprocesses). CMD may be made the process group leader, with signals | |
# correspondingly sent to all processes in the group, with the -g option. Even in this case, a signal causing CMD to | |
# terminate may not cause a CMD subprocess to terminate, if the two processes handle signals differently. timeout only | |
# waits for CMD to terminate, not its subprocesses. If CMD terminates before the primary signal timeout, neither |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
randomString() { | |
local LC_ALL=C IFS= | |
local i byte word string | |
local -ar alphabet=( | |
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z | |
a b c d e f g h i j k l m n o p q r s t u v w x y z | |
0 1 2 3 4 5 6 7 8 9 - _ | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
uuidV4() { | |
local LC_ALL=C IFS= | |
local byte i | |
local -a bytes | |
for ((i = 0; i < 16; i++)); do | |
read -r -d '' -n1 byte && printf -v byte '%d' "'$byte" | |
bytes[i]=$byte |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eE | |
main() { | |
local -A physicalIds coreIds | |
local count=0 | |
local name _ value | |
while IFS=$' \t' read -r name _ value; do | |
case "$name" in | |
processor) count=$((count + 1)) ;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
waitPortOpen() { | |
local host=$1 | |
local port=$2 | |
local timeoutSeconds=$3 | |
local intervalSeconds=$4 | |
local connectTimeoutSeconds=$5 | |
if [[ -z "$intervalSeconds" ]]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trap onError ERR | |
onError() { | |
local exitCode=$? command=(${BASH_COMMAND}) | |
if [[ ${BASH_SUBSHELL} -gt 0 ]]; then | |
exit ${exitCode} | |
fi | |
echo -e "\nERROR: Failed with exit code $exitCode when executing: ${command[@]}" >&2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WaitSpinLocksExample { | |
public static void main(String[] args) { | |
Thread thread1, thread2; | |
Base bad = new BadImplementationSubjectToSpuriousWakeup(); | |
thread1 = new Thread(bad::print); | |
thread2 = new Thread(bad::calculate); | |
thread1.start(); | |
thread2.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.security.SecureRandom; | |
public class SimpleIoTest { | |
private static final int BLOCK_SIZE = 1024 * 1024; | |
private static final int TOTAL_SIZE = 1024 * 1024 * 1024; | |
private static final int SEQUENTIAL_ITERATIONS = 32; | |
private static final int RANDOM_ITERATIONS = 16; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Power-Delete { | |
[CmdletBinding()] | |
param( | |
[parameter(Position = 0, ValueFromRemainingArguments = $true, ValueFromPipelineByPropertyName = $true)] | |
$FullName, | |
[switch] | |
$AllHardLinks | |
) | |
process { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo tail -c 29 /sys/firmware/acpi/tables/MSDM && echo |
NewerOlder