How to link command to correct program?

I’ve installed a command called gsutil on my Ubuntu VM with the command

sudo snap install google-cloud-sdk --classic 

However, when running gsutil I started an unrelated existing program of the same name (GSutil, a GrandStream BudgeTone phone backup, restore and reboot utility), which was stored in usr/bin/gsutil. Following advice from here I ran

sudo dpkg --purge gsutil 

which removed it. But now when I run gsutil I get

-bash: /usr/bin/gsutil: No such file or directory 

With which gsutil I get

/snap/bin/gsutil 

And I tried to make a symlink with

ln -s /snap/bin/gsutil gsutil 

but still get the same results. Why can’t bash find it? Both locations are in my PATH: echo $ PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 

Material Design Select box /Dropdown Usability which is correct interaction

I like material design, when using one of the material design components (select box/dropdown), I got confused about which interaction is correct, the link below has 2 interactions filled and filled enhanced. If you click on the filled examples the dropdown box list covers the field label, on the other hand, the list item is opening below the dropbox, which help the user to read the field label easily. So which is the correct interaction for this component? Or does simply saying filled enhanced mean that the correct interaction has been updated?

https://material-components.github.io/material-components-web-catalog/#/component/select

What is the correct way of setting and then differentiating between paid and free user in Firebase / Firestore?

I am developing a mobile application that will have both free and paid versions.

The way I see how I could differentiate between what is a paid and free user is to set a property isPaid on their respective documents.

What I want to understand is how to set the isPaid property on user‘s document securely.

One option that I see is after successful payment directly access the document that belongs to the user and change the isPaid property. All of that would be done on the mobile application side.

Another option could be to use the Firebase Functions and trigger one to set the correct value on the isPaid property for the given user.

But what could prevent a malicious user from setting these properties directly OR how to ensure that there actually is a pending subscription from Google or Apple and the user really is a paying one.

Currently my Firestore structure looks like this:

{   "users": [     {          "uid": "123123123123123",         "name":"Bob",         "isPaid": false,         "messages": [             {                 "messageText":"hello"             }         ]     },     {          "uid": "456456456456456",         "name":"Alice",         "isPaid": true,         "messages": [             {                 "messageText":"hey"             }         ]     },      ... } 

Thanks!

Linked SharePoint List not producing correct data in REST query?

I am trying to use the Office 365 SharePoint REST API to pull data stored in a list on SharePoint.

There are 2 columns in the list that lookup to another list.

I am trying to query the list using:

.../site/_api/web/lists/getbytitle('Sample Lists')/items?$  select=Email/Title&$  expand=Email 

The Email column in the list stores a lookup to a user table that then stores the Email. However, when I run the expand in this manner, I am not given a list of the Emails and am instead given a list of names (the other lookup value in the original list).

Is the definition of an Associative Array on Wikipedia correct?

I’m authoring the Automaton Standard Code for Information Interchange Data Types, which defines contiguous map and associative array types and I was checking my definitions of Associative Array on Wikipedia to be precise in my language and I noticed that the definition was murdered. An Abstract data type by definition is a data type that is defined by set theory. The Wiki read/currently reads after a revision undo volley that an Associative Array is a Collection of Key-value tuples such that each key appears only once, and the article refers to the mappings between the keys and values as “bindings”; which is no good because a Collection isn’t an Abstract data type nor is it part of Set theory. The Wiki article also states that an associative array is a map, which is like saying that all shapes are circles; all Dictnoaries are maps but not all maps are dictionaries; this confusion comes from C++ naming their dictionary map. An ASCII map is used to for instance to map a TCP port number to a socket and also to create hash table. Either my definition is wrong or the Wiki is completely wrong. This is problematic for the Computer Science community because the article makes no mention of a set, an operation on a set, and the result of the operations, which are requirements of abstract data types defined by set theory. “It’s defined as set theory, only we don’t mention a set” sounds REALLY bad!

The proposed definition I’m asking the community if it’s correct is that an Associative Array is a Surjective Abstract Data Type that maps a set of Unique strings in the domain, commonly called Keys and sometimes called Symbols, to instances of objects or the empty set in the codomain. The association between the key and value is called a Key-value Tuple. The association between a Key and a Value is defined by set theory as a “mapping”, and where a mapping may also refer to the action of modifying an existing mapping called remapping, and where the action of remapping a Key to the empty set is called Unmapping. The mappings are Surjective because each member of the codomain maps to at least one member of the domain.

The above definition defines the Abstract data type with set theory. I left out 3 words though: should have “The mappings are Surjective because each member of the codomain maps to at least one member of the domain read such that X->Y”, which is the Surjective definition; I implied it when I shouldn’t have. I can’t just engage in a revision undo war else I’ll be banned. We need a Computer Scientist with high credentials on Wikipedia to update the Wiki and fill in the gaps. Is my definition correct? Do you know of a definition with a Wiki-approved citation that is easier for those unknowledgeable of set theory to digest?

enter image description here

Reinstalling correct grub package to Acer device 18.04

After installing ubuntu to my machine (Acer Aspire F5-572G), UEFI is unable to detect grub as the boot manager. The closest answer to fixing this is Unable to install Ubuntu on Acer Aspire ES1-533.

The issue is that this solution above proposess sudo apt-get install --reinstall grub-efi-amd64. However my machine is of Intel 64 bit architecture.. and not AMD.. When preforming apt-cache search grub-efi it provides the possible packages:

grub-efi grub-efi-amd64 grub-efi-amd64-bin grub-efi-amd64-dbg grub-efi-amd64-signed grub-efi-ia32 grub-efi-ia32-bin grub-efi-ia32-dbg 

Since my computer is Intel 64-bit arch, I’m not completely sure of the consequences either installing a ia32 or amd64…

Hence I am wanting to know:

  • Would amd64 bit work?
  • Is there any risk to choosing ia32 with 64 bit archeture?
  • Any other possible method of getting grub noticed by UEFI?

Note: I have wiped hard disk recently and able to reinstall ubuntu to hard drive if anything breaks 🙂

Cheers

How to write correct test? [on hold]

I can write some unittests but have no idea how to write test about createAccount() which connect other functions together.

createAccount() contains some steps in order:

  1. Handle Email

  2. Handle Password

  3. Handle Security Keyword

  4. Instantiate new account object

Every step has some test cases. So, my questions are: 1. How to write createAccount() test case ? Should I list all possible combination test cases then test them.

For example:

TestCase0. Email is invalid

TestCase1. App stops after retrying email 3 times

TestCase2. Email is ok, password is not valid

TestCase3. Email is ok, password is valid, 2nd password doesnt match the first one

TestCase4. Email is ok, password is valid, both password match, security is valid

TestCase5. Email is ok, password is vailid, both password match, security is valid, account was create succesfully

  1. Don’t I know how to test because my createAccount() sucks ? If yes, how to refactor it for easier testing ?

This is my code:

class RegisterUI:      def getEmail(self):         return input("Please type an your email:")      def getPassword1(self):         return input("Please type a password:")      def getPassword2(self):         return input("Please confirm your password:")      def getSecKey(self):         return input("Please type your security keyword:")      def printMessage(self,message):         print(message)   class RegisterController:     def __init__(self, view):         self.view = view       def displaymessage(self, message):         self.view.printMessage(message)      def handleEmail(self, email):         """get email from user, check email         """         self.email = email         email_obj = Email(self.email)         status = email_obj.isValidEmail() and not accounts.isDuplicate(self.email)         if not status:             raise EmailNotOK("Email is duplicate or incorrect format")         else:             return True       def handlePasswordValid(self, password):         """         get password from user, check pass valid         """         self.password = password         status = Password.isValidPassword(self.password)         if not status:             raise PassNotValid("Pass isn't valid")         else: return True      def handlePasswordMatch(self, password):         """         get password 2 from user, check pass match         """         password_2 = password         status = Password.isMatch(self.password, password_2)         if not status:             raise PassNotMatch("Pass doesn't match")         else: return True      def createAccount(self):         retry = 0         while 1:             try:                 email = self.view.getEmail()                 self.handleEmail(email) #                 break             except EmailNotOK as e:                 retry = retry + 1                 self.displaymessage(str(e))                 if retry > 3:                     return          while 1:             try:                 password1 = self.view.getPassword1()                 self.handlePasswordValid(password1)                 break             except PassNotValid as e:                 self.displaymessage(str(e))          while 1:             try:                 password2 = self.view.getPassword2()                 self.handlePasswordMatch(password2)                 break             except PassNotMatch as e:                 self.displaymessage(str(e))          self.seckey = self.view.getSecKey()         account = Account(Email(self.email), Password(self.password), self.seckey)         message = "Account was create successfully"         self.displaymessage(message)         return account  class Register(Option):     def execute(self):          view = RegisterUI()         controller_one = RegisterController(view)         controller_one.createAccount()   """========================Code End=============================="""  """Testing""" @pytest.fixture(scope="session") def ctrl():     view = RegisterUI()     return RegisterController(view)  def test_canThrowErrorEmailNotValid(ctrl):     email = 'dddddd'     with pytest.raises(EmailNotOK) as e:         ctrl.handleEmail(email)     assert str(e.value) == 'Email is duplicate or incorrect format'  def test_canHandleEmail(ctrl):     email = 'hello@gmail.com'     assert ctrl.handleEmail(email) == True  def test_canThrowErrorPassNotValid(ctrl):     password = '123'     with pytest.raises(PassNotValid) as e:         ctrl.handlePasswordValid(password)     assert str(e.value) == "Pass isn't valid"  def test_PasswordValid(ctrl):     password = '1234567'     assert ctrl.handlePasswordValid(password) == True  def test_canThrowErrorPassNotMatch(ctrl):     password1=  '1234567'     ctrl.password = password1     password2 = 'abcdf'     with pytest.raises(PassNotMatch) as e:         ctrl.handlePasswordMatch(password2)     assert str(e.value) == "Pass doesn't match"  def test_PasswordMatch(ctrl):     password1=  '1234567'     ctrl.password = password1     password2 = '1234567'     assert ctrl.handlePasswordMatch(password2)