Snippets Collections
#!/usr/bin/env bash

is_root () {
    return $(id -u)
}

has_sudo() {
    local prompt

    prompt=$(sudo -nv 2>&1)
    if [ $? -eq 0 ]; then
    echo "has_sudo__pass_set"
    elif echo $prompt | grep -q '^sudo:'; then
    echo "has_sudo__needs_pass"
    else
    echo "no_sudo"
    fi
}

elevate_cmd () {
    local cmd=$@

    HAS_SUDO=$(has_sudo)

    case "$HAS_SUDO" in
    has_sudo__pass_set)
        sudo $cmd
        ;;
    has_sudo__needs_pass)
        echo "Please supply sudo password for the following command: sudo $cmd"
        sudo $cmd
        ;;
    *)
        echo "Please supply root password for the following command: su -c \"$cmd\""
        su -c "$cmd"
        ;;
    esac
}

if is_root; then
    echo "Error: need to call this script as a normal user, not as root!"
    exit 1
fi


elevate_cmd which adduser
prompt=$(sudo -nv 2>&1)
if [ $? -eq 0 ]; then
  # exit code of sudo-command is 0
  echo "has_sudo__pass_set"
elif echo $prompt | grep -q '^sudo:'; then
  echo "has_sudo__needs_pass"
else
  echo "no_sudo"
fi
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
 -activate -configure -access -on \
 -configure -allowAccessFor -allUsers \
 -configure -restart -agent -privs -all
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-deactivate -configure -access -off
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-activate -configure -access -on \
-clientopts -setvnclegacy -vnclegacy yes \
-clientopts -setvncpw -vncpw mypasswd \
-restart -agent -privs -all
$ ls -l /proc/self/fd/ <<< "TEST"
total 0
lr-x------ 1 user1 user1 64 Aug 20 13:43 0 -> /tmp/sh-thd.761Lj9 (deleted)
lrwx------ 1 user1 user1 64 Aug 20 13:43 1 -> /dev/pts/4
lrwx------ 1 user1 user1 64 Aug 20 13:43 2 -> /dev/pts/4
lr-x------ 1 user1 user1 64 Aug 20 13:43 3 -> /proc/10068/fd
minimap2 -a /home/rezaeir/NanoporeData/ont-guppy/bin/17-05-2021-cas9-drunkCas9-combined/ref/HSV_US9_ref.fasta HSV-US9-Cas9-0.001.fastq.gz > HSV-US9-Cas9-0.001.sam

samtools view -S -b HSV-US9-Cas9-0.001.sam > HSV-US9-Cas9-0.001.bam

samtools view -b -F 4 HSV-US9-Cas9-0.001.bam > HSV-US9-Cas9-0.001.mapped.bam

samtools sort -@ 16 HSV-US9-Cas9-0.001.mapped.bam > HSV-US9-Cas9-0.001.mapped.sorted.bam

samtools index -@ 16 HSV-US9-Cas9-0.001.mapped.sorted.bam
cat >> ~/.inputrc <<'EOF'
"\e[A": history-search-backward
"\e[B": history-search-forward
EOF

# then
bind -f  ~/.inputrc
#!/bin/bash    
wlan=`/sbin/ifconfig wlan0 | grep inet\ addr | wc -l`    
if [ $wlan -eq 0 ]; then    
    /sbin/ifdown wlan0 && /sbin/ifup wlan0
else    
    echo interface is up    
fi


# Then chmod 555 /root/checkwanup and add it to your crontab:

crontab -e
*/15 * * * * /bin/bash /root/checkwanup
$sleepDuration = Get-Random 2,3
$ps = [powershell]::Create().AddScript("Start-Sleep -Seconds $sleepDuration; 'Done!'")

# execute it asynchronously
$handle = $ps.BeginInvoke()

# Wait 2500 milliseconds for it to finish
if(-not $handle.AsyncWaitHandle.WaitOne(2500)){
    throw "timed out"
    return
}

# WaitOne() returned $true, let's fetch the result
$result = $ps.EndInvoke($handle)

return $result
~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
star

Thu Dec 22 2022 17:23:32 GMT+0000 (Coordinated Universal Time) https://superuser.com/questions/553932/how-to-check-if-i-have-sudo-access

#bsh
star

Thu Dec 22 2022 17:22:25 GMT+0000 (Coordinated Universal Time) https://superuser.com/questions/553932/how-to-check-if-i-have-sudo-access

#bsh
star

Fri Nov 18 2022 03:36:42 GMT+0000 (Coordinated Universal Time) https://apple.stackexchange.com/questions/30238/how-to-enable-os-x-screen-sharing-vnc-through-ssh

#bsh #macos #commandline #vnc #remotemanagement #mac
star

Fri Nov 18 2022 03:35:52 GMT+0000 (Coordinated Universal Time) https://apple.stackexchange.com/questions/30238/how-to-enable-os-x-screen-sharing-vnc-through-ssh

#bsh #vnc #macos #remotemanagement
star

Thu Nov 17 2022 22:38:28 GMT+0000 (Coordinated Universal Time) https://apple.stackexchange.com/questions/30238/how-to-enable-os-x-screen-sharing-vnc-through-ssh

#bsh #mac #vnc
star

Thu Nov 17 2022 22:38:13 GMT+0000 (Coordinated Universal Time) https://apple.stackexchange.com/questions/30238/how-to-enable-os-x-screen-sharing-vnc-through-ssh

#bsh #mac #vnc
star

Mon May 09 2022 13:17:56 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/678915/whats-the-difference-between-and-in-bash

#bsh
star

Wed Mar 16 2022 09:19:46 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/15520/how-can-i-tell-ubuntu-to-do-nothing-when-i-close-my-laptop-lid

#bsh
star

Sat May 29 2021 21:47:05 GMT+0000 (Coordinated Universal Time)

#bsh
star

Sat May 29 2021 21:22:39 GMT+0000 (Coordinated Universal Time) https://unix.stackexchange.com/questions/184502/bash-how-to-run-a-command-after-the-previous-finished/184503

#bsh
star

Sat May 29 2021 21:21:45 GMT+0000 (Coordinated Universal Time) https://superuser.com/questions/748809/bash-smart-autocomplete-based-on-history

#bsh
star

Sat Dec 19 2020 04:03:35 GMT+0000 (Coordinated Universal Time) https://unix.stackexchange.com/questions/74520/can-i-redirect-output-to-a-log-file-and-background-a-process-at-the-same-time

#bsh
star

Fri Dec 04 2020 04:50:26 GMT+0000 (Coordinated Universal Time) https://apple.stackexchange.com/questions/317140/brew-bash-autocompletion?rq

#bsh
star

Thu Aug 20 2020 23:26:44 GMT+0000 (Coordinated Universal Time) https://askubuntu.com/questions/4037/automatically-reconnect-wireless-connection

#bsh
star

Tue Jul 07 2020 08:31:09 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/60676732/test-path-timeout-for-powershell

#bsh
star

Fri Jun 12 2020 11:17:48 GMT+0000 (Coordinated Universal Time) https://apple.stackexchange.com/questions/366386/is-it-possible-to-script-what-applications-should-open-certain-file-extensions

#bsh

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension