Wikipedia:Reference desk/Archives/Computing/2014 October 29
Computing desk | ||
---|---|---|
< October 28 | << Sep | October | Nov >> | October 30 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
October 29
[edit]Facebook groups
[edit]- I've taken the liberty of moving this from the Science Refdesk. Wnt (talk) 03:21, 29 October 2014 (UTC)
what is suggested groups in facebook and how is the suggested groups list created , what is the algorithm behind it .I see that a person whose timeline i am frequently visitng and who was never my friend on fb and do not share any common friend with me that is a member of public but the groups to which that belong are appearing in my suggested groups list how and why is this happening.I have graph search enabled or turned on.Can that person sense somehow directly/indirectly that i am very frequently visiting that guys page whenever i type the first letter of his name in search box on top i am getting his name with profile and pic as suggested searck although he is a member of public in fb terms whats the reason for this and how is it so what is the significance. — Preceding unsigned comment added by 117.194.240.19 (talk) 03:15, 29 October 2014 (UTC)
- Companies like Facebook tend to try to keep those algorithms secret in order to prevent people from trying to game the system for whatever reason. So I doubt we'll have an answer for you on this one. SteveBaker (talk) 15:28, 29 October 2014 (UTC)
- From what I understand, it works along the lines of the predictive text function on smartphones, so it "learns" the common words you search for and provides those words as the first suggestions for what you are searching for. The person you are searching for will have no idea you are searching for him. As to the suggested groups list, I believe it's based on the groups your friends are a member of, rather than on random groups coming up. --TammyMoet (talk) 15:46, 29 October 2014 (UTC)
- In general, suggestion algorithms on the Internet are based on collaborative filters. You take a population and tell everyone in the population that they like the same thing. For example, if Facebook looks at you and your friends and most of the people like David Hasselhoff, but for some reason you don't, Facebook will suggest that you behave similar to your friends. This is very general though. They can use more complicated rules (but why?). Further, they often use marketing as well. If some new movie is coming out and the producers pay a fee to Facebook, then Facebook will add weight to that movie and suggest it to people. Even without money, Facebook admitted that they purposely skew suggestions just to
screw withstudy people. 209.149.115.7 (talk) 17:45, 31 October 2014 (UTC)
linux test command: how to negate a composite result
[edit]Hello everyone, if i can use the command test instead of [ i test to use the former. The problem arise with composite expressions. For example if i want to negate test "a" != "b" && test "a" != "c" && test "a" != "d"
i have no idea of how can i do that. I tried, of course, to write
! test "a" != "b" && test "a" != "c" && test "a" != "d"
or test ! "a" != "b" && test "a" != "c" && test "a" != "d"
but it negates just the first test (as expected).
How can i group and negate the entire result? With the [ version i would just use
[ ! \( "a" != "b" -a "a" != "c" -a "a" != "d" \) ]
or in an equivalent way test ! \( "a" != "b" -a "a" != "c" -a "a" != "d" \)
.
I appreciate suggestion of other way to evaluate conditional expression but i would like to ask you if you are kind enough to provide a solution that involves a combination of test one_expression
and shell operators (as i wrote at the start, with 3 test commands with && shell operators).
Pier4r (talk) 15:18, 29 October 2014 (UTC)
- You may find this disgustingly inelegant, but whenever I need to negate a test expression, I just write
if test
whatever complicated expressionthen : do nothing
else
whatever I wanted to dofi
- —Steve Summit (talk) 18:27, 29 October 2014 (UTC)
- the || operataor can be used to that end, too:
[ ! -e ~/foo.txt ] && echo foo.txt not found
can be written as[ -e ~/foo.txt ] || echo foo.txt not found
. as to the OP's question, I can't say I understand it Asmrulz (talk) 19:37, 29 October 2014 (UTC) - It is my current solution too (at the end, inelegant or not, it has to work given a certain syntax) 91.66.224.104 (talk) 10:49, 30 October 2014 (UTC)
- the || operataor can be used to that end, too:
- I apologize in advance if this isn't helpful, but you should seriously consider using a better programming language if you can. I'm not sure Python has attained ubiquity yet, but I think Perl is available everywhere Bash is these days, and it has much saner syntax and semantics. -- BenRG (talk) 22:46, 29 October 2014 (UTC)
- bash is a shell and as such first and foremost about process control and interactivity. sane syntax alone does not a good shell make if you for example have to set up child processes and redirect file descriptors by hand (imagine doing something like
diff <(cd foo; find|sort) <(cd /backup/2014-10-29/foo; find|sort)
). I don't know either language, sadly, but if it's anything like (pseudocode and API) x=createProcess("find");x.stdin=...;x.stdout=...;x.workingDir=...; x.run(); x.wait(); - well, that's fine as programming goes but one will tire typing that everytime into the interpreter Asmrulz (talk) 23:53, 29 October 2014 (UTC) - If you meant running perl from bash (perl -e 'code') then I agree. some stuff is better done in a real language, but there may be issues with quoting and how to pass variables to that language and getting results back Asmrulz (talk) 23:55, 29 October 2014 (UTC)
- Actually, constructing command lines in a language such as Perl often avoids quoting problems, because you have other ways than quotation marks and spaces to delimit things on the line. It does tend to make things more verbose, though. For example, a Perl call like
system("commandname", $file1, $file2);
will do the right thing no matter what funny characters may be in the two filenames. --174.88.134.249 (talk) 04:05, 30 October 2014 (UTC)
- Actually, constructing command lines in a language such as Perl often avoids quoting problems, because you have other ways than quotation marks and spaces to delimit things on the line. It does tend to make things more verbose, though. For example, a Perl call like
- yes i could use a different programming language, but i'm asking exactly because i would like to know if it is just my limited knowledge of the syntax. For me suggesting completely different solution is ok, but are a workaround of the main question (the question can even have the answer "no is not possible", it is nothing bad.) --Pier4r (talk) 11:07, 30 October 2014 (UTC)
- bash is a shell and as such first and foremost about process control and interactivity. sane syntax alone does not a good shell make if you for example have to set up child processes and redirect file descriptors by hand (imagine doing something like
As for the original question, I suggest using de Morgan's Laws to rewrite the expression. To negate
test "a" != "b" && test "a" != "c" && test "a" != "d"
you can just use
test "a" == "b" || test "a" == "c" || test "a" == "d"
That is, reverse each of the tests and swap "and" for "or". --174.88.134.249 (talk) 04:05, 30 October 2014 (UTC)
- WARNING: such simple rule works fine for expressions with 'ands' only or with 'ors' only! For complex conditions like
A and B or C
you may have to consider operators precedence and use some parenthesing to get appropriate meaning of the expression:
(!A or !B) and !C
--CiaPan (talk) 06:19, 30 October 2014 (UTC)- "And" and "or" don't have a well defined precedence anyway; it varies between languages. In shell programming, && and || have equal precedence and are processed left to right. --174.88.134.249 (talk) 07:42, 30 October 2014 (UTC)
- Yep i'm aware of de Morgan's laws, but i wanted to "toggle" the result of the condition with just an operator. Maybe i can write:
main_test=test "a" != "b" && test "a" != "c" && test "a" != "d" ; let main_test_toggled=1^${main_test} test ${main_test_toggled} -eq 0
- but it is a bit verbose. Pier4r (talk) 11:07, 30 October 2014 (UTC)
- I have a hard time telling what you really want:
- What difference do you think there is between test and [ ("With the [ version i would just use")—aside from having to type ] to close the latter?
- Doesn't the
test ! \( "a" != "b" -a "a" != "c" -a "a" != "d" \)
(or the [ version) you provided work? - Why would you want test invoked multiple times rather than once with its operators? (But see below about arbitrary strings; I could also see it if the latter tests involved some expensive shell substitution or so…)
- All that said, I do have two answers:
- Be careful of complicated expressions if your test data might be arbitrary strings: bash 4.1.5's builtin chokes on parsing
[ \( "(" = "(" \) ]
(where the quotes are meant to suggest that those arguments might have come from variables), while test 7.4 accepts that but rejects[ \( "(" = ")" \) ]
which bash interprets as two nested parenthesizations of the single argument = which, being non-empty, is true. Using fewer than 5 arguments can help in that the parsing is not based so much on keywords: for example,[ "(" = ")" ]
is a comparison rather than a parenthesized single-argument test. - You can apply the shell operator ! to a compound command:
! (true && false)
or! { true && false; }
(note the semicolon and spaces). --Tardis (talk) 13:56, 30 October 2014 (UTC)
- yep i know that if i ask questions like this preferring some "hard" constraints ("if possible using only this and/or using only that") that mostly make sense only for me, then volunteers that wants to reply are a bit annoyed. When i have to answer questions of this kind i get annoyed too sometimes. I use to pose questions like this because my idea is "i would like to know if it is possible to reach a certain result given those tools" and not "i would like to reach the result with whatever tool set".
- Said that. Many thanks for your reply i will test it asap. Pier4r (talk) 16:35, 30 October 2014 (UTC)
- Be careful of complicated expressions if your test data might be arbitrary strings: bash 4.1.5's builtin chokes on parsing
Follow-up: AT&T data throttling
[edit]See Wikipedia:Reference_desk/Archives/Computing/2014_October_23#AT.26T_behavior. They've just been charged with illegal data throttling, so apparently I'm not the only one they did this to. StuRat (talk) 15:34, 29 October 2014 (UTC)
- Fascinating. Here's the FTC's public complaint for permanent injunction, and a brief from their webpage, "AT&T Has Misled Millions of Consumers with ‘Unlimited’ Data Promises." Here's AT&T's press release in response. Here's a summary article from Ars Technica, US sues AT&T... Nimur (talk) 18:31, 29 October 2014 (UTC)
- The big issue is a semantic one. Does "unlimited" refer to speed as well as quantity. AT&T says no. Unlimited means you can keep getting data, but the speed is not guaranteed. The FTC says yes. Unlimited means that you will keep getting data and the speed will not be decreased if you use too much. I'd like to see how this works so I can sue the seafood restaurant if their unlimited crab legs slows down after the fifth plate. 209.149.115.7 (talk) 17:33, 31 October 2014 (UTC)