voice dictation – How can I test vocal commands?

I’ve defined vocal commands using System Preferences ﹥ Accessibility ﹥ Dictation (macOS 10.14.4). Sometimes they work, sometimes they don’t. I guess recognition rate is not 100%, and I’d like to improve it, for instance by chosing different wording. “Make it so” may be better recognized than “Engage”. How can I get feedback on recognition rate?

samsung – Smasung Galaxy A51 stuck in bootloop, recognized by adb, not responding to adb commands

I have a Samsung Galaxy A51 that is stuck in a Boot-loop. Phone was originally water damaged, but worked until my Dad tried to charge it. I replaced the inside part of the phone with the USB port. When I run ADB (I have drivers) my phone shows up under ADB devices. But it does not respond to ANY ADB commands, I can’t root, or push files. I also tried ODIN but I get “Odin Protocol version ERROR”.
MAIN PROBLEM: phone shows up under ADB devices but does not respond to any ADB commands.
Any advice would be appreciated, thank you.

Bazel/Gazelle chaining commands – Stack Overflow

I wanted to simplify the dependency update process for our bazel monorepo, we want to run these commands in order defined in the root BUILD.bazel (go directory contains all our go code):

bazel run //:gazelle
bazel run //:gazelle -- update-repos -from_file=go.mod`
bazel run //:gazelle

These commands will basically update any new dependencies across workspace then rebuild go code. I am guessing this can be achieved with a rule, but I couldn’t figure out how to get it to work.

Docker container with a dockerfile and commands to build, run and manage your Docker images

Say you went to the fish market to buy fish. There were two sizes of fish available. The fisherman told that the total price of the smaller fish is 3 times the total price of the bigger fish. Also, the total money that you bought from your home is Rs.100. Can you find out how much did you spend to buy the two types of fish? Run your Python application to solve the problem in a Docker container with a Dockerfile and commands to build, run, and manage your Docker images. Hint: use numpy library to solve system of linear equation.

Is there an order to placing commands in .htaccess file?

I have to keep the below block at the bottom of my htaccess file or other commands won't work. Why? I didn't think there was any order to commands in the Apache file. Is that right?
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ – (L)

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 (L)

RewriteCond %{REQUEST_FILENAME} -f (OR)
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^…

Is there an order to placing commands in .htaccess file?

Python Classes for Robot Test Framework which Open Paramiko SSH Connections and Run Commands


I am writing a custom library whose keywords can be used with Robot Framework to verify configuration files, check running processes, and eventually other things tailored to a project I work on. The Robot tests would eventually be included as part of a Jenkins job.

I’m not used to writing Python or using OOP and I would love any feedback at all. Here are some specific things I’m worried about:

  • The organization and correctness of my functions and classes.
  • Is anything obviously missing or bad or confusing?
  • Am I properly cleaning up any created paramiko sshh connections?
  • Am I doing things in a “pythonic” way?

In advanced, I greatly appreciated your time. Thanks.

Directory layout

Note, I did not include the unit tests.

├── Intrepid.py
├── SSHClient.py
└── tests
    ├── main.py
    ├── test_Intrepid.py
    └── test_SSHClient.py

An example main.py

Here is an example of using the create_new_session() function in the Python code.

import os, sys

from Intrepid import Intrepid

server ='localhost'
# Set to a valid local user on your machine.
username ='validusername'
password ='validpassword'
running_process ='sys-kernel-debug.mount'

intrepid = Intrepid(server, username, password)
intrepid.create_new_session(server, username, password)

Robot Framework example

Using the above python function in Robot would look like:

    Create new session   ${HOST}     ${USER}      ${PASSWORD}
        Check service on host  ${HOST}     ${service}
    Close session

The Code

The Intrepid Class

This class is where custom keywords could be defined which could be called from the Robot Framework.

import subprocess
import logging
import xml.etree.ElementTree as ET
from SSHClient import SSHClient


class Intrepid:
    def __init__(self, server = 'localhost', username = 'defaultuser', password = 'defaultpassword'):

        logging.basicConfig(format='%(asctime)s %(message)s', 
            datefmt='%m/%d/%Y %I:%M:%S %p',
        self.log = logging.getLogger(__name__)

        self.ssh_client = None
        self.create_new_session(server, username, password)
        # Downloaded files will go here
        self.working_directory = '/tmp'
        self.downloaded_files = ()

    def create_new_session(self, server, username, password):
            Robot users call this function to begin an SSH session.
        self.log.info('Creating new ssh session')
        self.ssh_client = SSHClient(server, username, password)

    def is_process_running(self, process_name):
            Check if a process is running on a remote system.

            Use from Robot like so:
            Is process running  | ing-flowgen
        cmd = 'systemctl status' + ' ' + str(process_name)

        if self.ssh_client.run_remote_command(cmd) == 0:
            self.log.info('Found process %s', process_name)
            return True

        # The Robot framework uses exceptions to
        # figure out whether a keyword test passed.
        error_string = "Process " + process_name + " is not running."

        raise ServiceNotRunning(error_string)

    def xml_file_contains(self, xml_file, expected_text, xpath):
            Search for text in an XML file. Raise an exception
            if it doesn't exist.

            Use from Robot like so:
            XML file contains | Full path to XML file | Expected text | XPath to xml element
        xml_file = self.ssh_client.download_file(xml_file, self.working_directory)

        tree = ET.parse(xml_file)
        root = tree.getroot()
        value = root.find(xpath)
        if value is None:
            message = "Could not find: " + xpath
            raise XMLElementNotFound(message)
        elif value.text != str(expected_text):
            message = "Expected value " + expected_text + " does not match actual value " + value.text
            raise XMLElementDoesNotMatch(message)

        print("Values match")
        return True

    def close_session(self):
            Robot users must choose when to close the connection.
        self.log.info('Closing ssh session')

class ServiceNotRunning(Exception):
        If Robot catches an exception it reports
        that the test has failed.
class XMLElementNotFound(Exception):
class XMLElementDoesNotMatch(Exception):

The SSHClient Class

import paramiko
from paramiko.ssh_exception import BadHostKeyException, AuthenticationException, SSHException
import socket
from time import sleep
from sys import exit
import os
import logging


class SSHClient:
    def __init__(self, server, username, password,
            print_stdout=None, retries=None,
            interval=None, timeout=None):

        logging.basicConfig(format='%(asctime)s %(message)s', 
            datefmt='%m/%d/%Y %I:%M:%S %p',
        self.log = logging.getLogger(__name__)

        self.username = username
        self.password = password 
        self.server = server
        self.print_stdout = print_stdout if print_stdout is not None else True
        self.retries = retries if retries is not None else 3

        # interval and timeout are in seconds.
        self.interval = interval if interval is not None else 2   
        self.timeout = timeout if timeout is not None else 5

            self.ssh_client = self._get_ssh_client(server, username, password)
            raise ConnectionError('Could not establish an SSH connection. Exiting')

    def __enter__(self):
        return self

    def _get_ssh_client(self, server, username, password):
        ssh_client = paramiko.SSHClient()

        # No need to enforce host key checking. Testing is done on
        # a private network.

        for attempt in range(self.retries):
                ssh_client.connect(server, username=username, 
                password=password, timeout=self.timeout)
                self.log.info('Successfully started ssh_client')
                return ssh_client

            except (BadHostKeyException, AuthenticationException, 
            SSHException, socket.error) as e: 
                error_message = "Failed to connect on attempt " + str(attempt) + " " + str(e)

        # Could not successfully create an ssh session
        raise Exception('Failed to establish ssh connection')

    def download_file(self, remote_file, local_path):
        filename = os.path.basename(remote_file)
        local_file = os.path.join(local_path, filename)

        sftp = self.ssh_client.open_sftp()
        self.log.info('Downloading remote file: %s from server %s to %s',
         filename, self.server, local_file)
            sftp.get(remote_file, local_file)
            self.log.info('Successfully saved file %s', local_file)
            return local_file
        except Exception as e:
            raise Exception('Failed to download file ', e)
            if sftp: sftp.close()

    def close(self):
        self.username = None
        self.password = None
        self.server = None 
        self.print_stdout = None
        self.retries = None
        self.interval = None
        self.timeout = None

        self.log.info('Closing ssh connection.')

    def run_remote_command(self, cmd_to_execute):
        '''Run a command on a remote machine.

            We do not explicitly close the ssh connection here incase we want to chain 
            multiple commands over one ssh connection. Leave the decision to close 
            the connection to the user.
        self.log.info('Attempting to run command %s on server %s',
            cmd_to_execute, self.server)
            stdin, stdout, stderr = self.ssh_client.exec_command(cmd_to_execute)
            self.log.info('Command succeeded')
        except (BadHostKeyException, AuthenticationException, SSHException, socket.error) as e:
            self.warning("Failed to run ssh command with error: ", e)
            error_message = "Failed to run ssh command " + e
            raise Exception(error_message)

        if self.print_stdout == True:

        remote_return_code = stdout.channel.recv_exit_status()

        if remote_return_code != 0:
            print("Remote command failed with return code: ", remote_return_code)
        return remote_return_code

    def _print_output(self, command_output):
        for line in iter(command_output.readline, ""):
            print(line, end="")

    def __exit__(self, exc_type, exc_value, traceback):

General commands for getting help and/or documentation for command line utilities in terminal on macOS?

Some command line interfaces or command line utilities give some comprehensive documentation or help when --help is appended to the name of the command, for example git:

git --help
# shows comprehensive help docs

Some others show only the command and its arguments (that’s all), for example grep:

grep --help
usage: grep (-abcDEFGHhIiJLlmnOoqRSsUVvwxZ) (-A num) (-B num) (-C(num))
    (-e pattern) (-f file) (--binary-files=value) (--color=when)
    (--context(=num)) (--directories=action) (--label) (--line-buffered)
    (--null) (pattern) (file ...)

And others give some assistance, but only because --help is not recognised as a legal option, for examples ls:

ls --help
ls: illegal option -- -
usage: ls (-@ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1%) (file ...)

and netstat:

netstat --help
netstat: illegal option -- -
Usage:  netstat (-AaLlnW) (-f address_family | -p protocol)
    netstat (-gilns) (-f address_family)
    netstat -i | -I interface (-w wait) (-abdgRtS)
    netstat -s (-s) (-f address_family | -p protocol) (-w wait)
    netstat -i | -I interface -s (-f address_family | -p protocol)
    netstat -m (-m)
    netstat -r (-Aaln) (-f address_family)
    netstat -rs (-s)


Are there any generally safe way(s) of getting documentation or help with a CLI or utility without having to google (i.e. from within the terminal)? I currently try --help or -h, but other than that I go straight to google, but would like to know if there are other things to (safely) try before going to google.

bash – rbenv not allowing me to use ruby commands

I tried installing rbenv in my ubuntu 18.04 server and it worked (shows list of versions, locally or globally) but ruby -vreturns

mr2552@ip-10-5-121-225:~$ ruby -v

Command 'ruby' not found, but can be installed with:

snap install ruby  # version 3.0.1, or
apt  install ruby

See 'snap info ruby' for additional versions.

As rbenv failed, I tried to install ruby with snap
sudo snap install ruby --classic --channel=latest/stable
and then removed it because I was going to need rbenv later on.
sudo snap remove ruby --classic --channel=latest/stable

now ruby -v returns
bash: /snap/bin/ruby: No such file or directory

How do I revert from bash: /snap/bin/ruby: No such file or directory to

mr2552@ip-10-5-121-225:~$ ruby -v

Command 'ruby' not found, but can be installed with:

snap install ruby  # version 3.0.1, or
apt  install ruby

See 'snap info ruby' for additional versions.

I want to solve the main issue (ruby -v not showing rbenv version) but I think this new problem might interfere in the future?

sharepoint online – Using date commands in calculated fields

I am following this article:

A simple sample is this:

However when i save the column I get following error:

Sorry, something went wrong The formula contains a syntax error or is
not supported.

If I just do this it works:

However I need to calculate hours and days between two dates so I need some of the commands. Any pointer what I am doing wrong?