Forms – Common input fields for registering and logging in with separate buttons

While working on the registration / login page for mine AppI came up with the idea of ​​combining the two into one. When you click Register, users are redirected to a new page where you can enter the rest of the details.

Enter the image description here

I want to keep onboarding users as easy as possible. For example, using the traditional approach, users first see a login page. If you want to register, click on a Sign in instead Button that opens a new page.

By using my approach, users are saved by an additional click and a page load. But what are the advantages and disadvantages here?

Rush Limbaugh: "There was always something we had in common, that is, we were American, and there was great pride in being American."

Wrong: Rush was one of the most controversial people in this country. He is a hateful, bigoted propagandist who got rich and tore this country apart. Rush has always held the concept that liberals and democrats are not even real Americans. His constant, minor attacks on the political opposition were supposed to stir up hatred of the political opposition and call it anti-American. Rush is a disgusting hypocrite.

[ Law & Ethics ] Open question: What legal principles apply if a data breach publishes personal financial information? Common law negligence? Which laws regulate this?

[Law & Ethics] Open question: Which legal principles apply if a data breach publishes personal financial information? Common law negligence? Which laws regulate this?

Why does Facebook recommend my friend to my other friends even though he has nothing in common and hid my list?

I only use Facebook as a means of making contact (mainly messenger).
I have set my privacy settings as low as possible, and everything is only visible to me. Basically, I did everything that could be deactivated for publication.

I recently saw that my good friend I met on the Internet (and not related to any of my other friends! He doesn't even live in the same part of the country.) Has appeared in my friend's "recommended friends" from in real life, although I have no special contact with him through Facebook. He's only on my friends list, I don't even send him a message or anything.
Of course there was a hint on the recommended list that there was a mutual friend but did not show who because I was hiding my friend list.

If he has mine somehow Recommended as a private internet friend (for some reason I can't even think of) it means that any of my friends can recommend him too. It kind of bothers me because I have disabled my friends list for a reason. I don't want others to see my friends at all and when they see that there is a single mysterious mutual friend, then you can easily assume that it is me because there are not many people like me who deactivate everything.

I could understand if there was more than one mutual friend, but it's just me, with everything that's hidden, and it's a person I'd rather not be floating around with my real friends. You could just invite her and then she would see her in my friends list because it shows mutual friends. I think that's kind of a privacy concern and there should be an option to NOT share some of your friends with everyone around you. I'm pretty sure there are hundreds of other friends who could be recommended who actually have something in common.

Is there a way to prevent this from happening other than deleting it?

Terminology – is there a common notation to indicate the final form of a simplified definition?

I try to get better by using correct terminology and standard notation when making notes, which leads me to consider the following:

Similar to providing complete evidence using the Q.E.D. Mark or "∎", is there a standard way to indicate the end of a simplified definition?

Hash card – map of objects with common characteristics

Please note the following code:

@Test
public void test() {
    // This is the input:
    Map> map = new HashMap>() {{
        put("a", Arrays.asList("calculating", "label", "farm", "anger", "able", "aboriginal"));
        put("e", Arrays.asList("injure", "label", "anger", "teeny-tiny", "able", "mindless"));
        put("i", Arrays.asList("injure", "calculating", "teeny-tiny", "mindless", "aboriginal"));
    }};

    // This is my algorithm:
    Map> result = new HashMap<>();
    for (List values : map.values()) {
        for (String str : values) {
            Set l = result.getOrDefault(str, new HashSet<>());
            l.addAll(values);
            l.remove(str);
            result.put(str, l);
        }
    }

    // result contains this:
    // {
    //      able=(teeny-tiny, farm, calculating, aboriginal, label, mindless, anger, injure),
    //      teeny-tiny=(able, calculating, aboriginal, label, mindless, anger, injure),
    //      farm=(able, calculating, aboriginal, label, anger),
    //      calculating=(able, teeny-tiny, farm, aboriginal, label, mindless, anger, injure),
    //      aboriginal=(able, teeny-tiny, farm, calculating, label, mindless, anger, injure),
    //      label=(able, teeny-tiny, farm, calculating, aboriginal, mindless, anger, injure),
    //      mindless=(able, teeny-tiny, calculating, aboriginal, label, anger, injure),
    //      anger=(able, teeny-tiny, farm, calculating, aboriginal, label, mindless, injure),
    //      injure=(able, teeny-tiny, calculating, aboriginal, label, mindless, anger)
    // }
}

It's a simplification of a problem I'm struggling with.

In the first few lines you can see that I have a card whose key is some characteristics (here it is simply letters) and values ​​are lists of objects with these characteristics (here they are simply words that contain the given letter).

The next lines accomplish what I want to do: extract a second card from the card, the key of which is each word, and the values ​​are a list of other words that have at least one characteristic in common.

For example, the value assigned to the key farm contains label (because both contain a) but does not contain injure (there farm and injure have none of a, e or i together).

Note that the result does not contain the original keys (a, e, i), I don't really care.

My question is: is there a way to make things faster?

For my real problem, I don't have three letters, but a few thousand values. I don't have 10 words, but about 1 million.

Side question: If there is a common name for this problem, I would like to know.

Common Lisp – My solution to the challenge of the 100 prisoners

I encountered the problem with 100 prisoners in the Rosetta Code. I thought it would be fun to add a Common Lisp solution, see below.

Before I publish my solution, I want to have some feedback on my code. I used lists for the task because I think this is the most natural in CL and performance is not a problem here.

Thanks for your comments!

(defparameter *samples* 10000)
(defparameter *prisoners* 100)
(defparameter *max-guesses* 50)

(defun range (n)
  "Returns a list from 0 to N."
  (loop
     for i below n
     collect i))

(defun nshuffle (list)
  "Returns a shuffled LIST."
  (loop
     for i from (length list) downto 2
     do (rotatef (nth (random i) list)
                 (nth (1- i) list)))
  list)

(defun build-drawers ()
  "Returns a list of shuffled drawers."
  (nshuffle (range *prisoners*)))

(defun strategy-1 (drawers p)
  "Returns T if P is found in DRAWERS under *MAX-GUESSES* using a random strategy."
  (loop
     for i below *max-guesses*
     thereis (= p (nth (random *prisoners*) drawers))))

(defun strategy-2 (drawers p)
  "Returns T if P is found in DRAWERS under *MAX-GUESSES* using an optimal strategy."
  (loop
     for i below *max-guesses*
     for j = p then (nth j drawers)
     thereis (= p (nth j drawers))))

(defun 100-prisoners-problem (strategy &aux (drawers (build-drawers)))
  "Returns T if all prisoners find their number using the given STRATEGY."
  (every (lambda (e) (eql T e))
         (mapcar (lambda (p) (funcall strategy drawers p)) (range *prisoners*))))

(defun sampling (strategy)
  (loop
     repeat *samples*
     for result = (100-prisoners-problem strategy) 
     count result))

(defun compare-strategies ()
  (format t "Using a random strategy in ~4,2F % of the cases the prisoners are free.~%" (* (/ (sampling #'strategy-1) *samples*) 100))
  (format t "Using an optimal strategy in ~4,2F % of the cases the prisoners are free.~%" (* (/ (sampling #'strategy-2) *samples*) 100)))

Keyboard – what are the most common special characters in email addresses?

You can't go wrong with emulating the layout of Apple / Android phones. It is what people are used to seeing, and it helps users to enter their data quickly.

If you introduce an unexpected layout, your users will have to pause to figure out how to use the keyboard, and this will interrupt their train of thought.

The layout you have there seems to me to be simple and straightforward.

In the database with 800,000 email addresses I have here (customers of a large software company)

  • Over 300,000 email addresses include a period (& # 39;. & # 39;) in front of the & # 39; @ & # 39;
  • 50,000 email addresses contain a & # 39; – & # 39; symbol
  • 50,000 email addresses contain a & # 39; _ & # 39; symbol
  • Among 400 email addresses contain a & # 39; + & # 39; symbol
  • Among 30 email addresses contain a & # 39;! & # 39; symbol
  • Under 30 email addresses contain a & # 39; # & # 39; symbol
  • Among 30 email addresses contain a & # 39; && # 39; symbol
  • out of 140 email addresses contain a & # 39; & # 39; & # 39; symbol (apostrophe)
  • Among 30 email addresses contain a & # 39; * & # 39; symbol
  • under 5 email addresses contain a & # 39; = & # 39; symbol
  • under 10 email addresses contain a & # 39;? & # 39; symbol
  • under 5 email addresses contain a & # 39; ^ & # 39; symbol
  • Zero email addresses contain a & # 39; ~ & # 39; symbol

Hopefully, these statistics will help you to see the relative popularity of symbols in email addresses.

I imagine that the answers for the "+" symbol come from people who use this function (UX geeks are not really representative of the larger population (no offense is meant)).

Since you are using a cursor-controlled interface, I would highly recommend specifying the most common email suffixes for your country. For here in the UK that would be ".com" and ".co.uk". These would really help the input speed.

If there is enough space on the screen, you can also include the most important email providers (Outlook.com, Gmail.com, etc.).

c – Longest dynamic programming for common substrings

I want to solve the longest common substring problem. Given two strings $ X $ and $ Y $ of lengths $ m $ and $ n $ I want to determine the length of the longest common substring. They are represented as arrays of characters that are defined on $ {1, ldots, m } $ and $ {1, ldots, n } $ respectively.

I first coded a non-dynamically programmed recursive algorithm:

int lcs(char *X, char *Y, int i, int j, int L) {
   if (i == 0 || j == 0) return L;
   if (X(i) == Y(j)) L = lcs(X, Y, i - 1, j - 1, L + 1);
   L = max(L, max(lcs(X, Y, i, j - 1, 0), lcs(X, Y, i - 1, j, 0)));
   return L;
}

This algorithm works perfectly when called by lcs(X, Y, m, n, 0). To make it dynamic, I created a 2D array mem(m + 1)(n + 1) defined on $ {0, ldots, m }, {0, ldots, n } $ initialized to $ 0 $. I modified the above algorithm as such:

int lcsDP(char *X, char *Y, int i, int j, int L, int **mem) {
   if (i == 0 || j == 0) return L;
   if (mem(i)(j) > 0) return mem(i)(j) + L;
   if (X(i) == Y(j)) L = lcsDP(X, Y, i - 1, j - 1, L + 1, mem);
   L = max(L, max(lcsDP(X, Y, i, j - 1, 0, mem), lcsDP(X, Y, i - 1, j, 0, mem)));
   mem(i)(j) = L;
   return L;
}

This works for all input pairs I tested with the exception of one pair:

Entry: X = "zxabcdezy", Y = "yzabcdezx"

The longest common substring is "abcdez" and has a length of 6, but the DP solution outputs 7. Any help in locating the error in my DP solution or debugging would be appreciated.