Does sendmail need to be configured before sending emails?

Question: The "sendmail" is preinstalled and I think it needn't configuration.
Am I right or wrong?
But I failed to send out the emails actually!
<code>[root@jiaoyou ~]# cat mail2.txt
From: email@example.com
To: email@example.com
MIME-Version: 1.0
Content-Type: multipart/alternative;
Subject: Test HTML e-mail.

This is a MIME-encapsulated message

[root@jiaoyou ~]# sendmail -t -d <mail2.txt
Version 8.14.3
 Compiled with: DNSMAP HESIOD HES_GETMAILHOST LDAPMAP LOG MAP_REGEX
                MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6
                NETUNIX NEWDB NIS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS
                TCPWRAPPERS USERDB USE_LDAP_INIT
getla(): 0.00
setoption SevenBitInput (7)=False
setoption AliasWait (a)=10
setoption MinFreeBlocks (b)=100
setoption BlankSub (B)=.
setoption HoldExpensive (c)=False
setoption DeliveryMode (d)=i
setoption QueueFileMode (0xbe)=0660
setoption TempFileMode (F)=0600
setoption HelpFile (H)=/etc/mail/helpfile
setoption SendMimeErrors (j)=True
setoption ForwardPath (J)=
setoption ConnectionCacheSize (k)=2
setoption ConnectionCacheTimeout (K)=5m
setoption UseErrorsTo (l)=False
setoption LogLevel (L)=9
setoption CheckAliases (n)=False
setoption OldStyleHeaders (o)=True
setoption DaemonPortOptions (O)=Name=NoMTA, Addr=127.0.0.1, M=E
Daemon NoMTA flags: <NOETRN>
setoption UseMSP (0xcc)=True
setoption PrivacyOptions (p)=goaway,noetrn,restrictqrun
setoption QueueDirectory (Q)=/var/spool/clientmqueue
setoption Timeout (r).queuereturn=5d
setoption Timeout (r).queuewarn=4h
setoption SuperSafe (s)=True
setoption StatusFile (S)=/var/spool/clientmqueue/sm-client.st
setoption TimeZoneSpec (t)=
setoption SmtpGreetingMessage (0x90)= 0x81 j Sendmail  0x81 v/ 0x81 Z;  0x81 b
setoption UnixFromLine (0x91)=From  0x81 g  0x81 d
setoption OperatorChars (0x92)=.:%@!^/[]+
setoption DontInitGroups (0x93)=True
setoption RunAsUser (0x9d)=smmsp
setoption DontProbeInterfaces (0xa1)=True
setoption TrustedUser (0xa7)=smmsp
setoption PidFile (0x9f)=/var/run/sm-client.pid
drop_privileges(0): Real[UG]id=0:0, get[ug]id=0:0, gete[ug]id=0:51, RunAs[UG]id=51:51
getauthinfo: root@localhost

============ SYSTEM IDENTITY (after readcf) ============
      (short domain name) $w = jiaoyou
  (canonical domain name) $j = jiaoyou
         (subdomain name) $m = <null>
              (node name) $k = jiaoyou
========================================================

assign_queueid: assigned id n7QFdKGA008587, e=0x7f32a15d1fa0
assign_queueid: assigned id n7QFdKGB008587, e=0x7f32a15d1fa0
getla(): 0.00
setsender()

--parseaddr(root)
rewrite: ruleset canonify           input: root
rewrite: ruleset Canonify2          input: root
rewrite: ruleset Canonify2        returns: root
rewrite: ruleset canonify         returns: root
rewrite: ruleset parse              input: root
rewrite: ruleset Parse0             input: root
map_lookup(dequote, root) => NOT FOUND (0)
rewrite: ruleset Parse0           returns: root
rewrite: ruleset Parse1             input: root
rewrite: ruleset Parse1           returns:  0x96  local  0x98  root
rewrite: ruleset parse            returns:  0x96  local  0x98  root
rewrite: ruleset 2                  input: root
rewrite: ruleset 2                returns: root
rewrite: ruleset EnvToL             input: root
rewrite: ruleset EnvToL           returns: root
rewrite: ruleset final              input: root
rewrite: ruleset final            returns: root
parseaddr-->0x7f32a15d1fc0=root:
        mailer 3 (local), host `'
        user `root', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=180<QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)
rewrite: ruleset canonify           input: root
rewrite: ruleset Canonify2          input: root
rewrite: ruleset Canonify2        returns: root
rewrite: ruleset canonify         returns: root
rewrite: ruleset 1                  input: root
rewrite: ruleset 1                returns: root
rewrite: ruleset final              input: root
rewrite: ruleset final            returns: root
EOH
----- collected header -----
Return-Path: < 0x81 g>
Received:(  0x81 ?sfrom  0x81 s  0x81 . 0x81 ?_( 0x81 ?s 0x81 |from  0x81 . 0x81 _)\n\t 0x81 . 0x81 ? 0xa5 (authenticated 0x81 ? 0xa6  bits= 0x81  0xa6  0x81 .)\n\t 0x81 .by  0x81 j ( 0x81 v/ 0x81 Z) 0x81 ?r with  0x81 r 0x81 . id  0x81 i 0x81 ? 0xa7 \n\t(version= 0x81  0xa7  cipher= 0x81  0xa8  bits= 0x81  0xa9  verify= 0x81  0xaa ) 0x81 . 0x81 ?u\n\tfor  0x81 u;  0x81 |;\n\t 0x81 . 0x81 b)  (from root@localhost)\n\tby jiaoyou (8.14.3/8.14.3/Submit) id n7QFdKGB008587;\n\tWed, 26 Aug 2009 11:39:20 -0400
Resent-Date:(  0x81 a)  Wed, 26 Aug 2009 11:39:20 -0400
Date:(  0x81 a)  Wed, 26 Aug 2009 11:39:20 -0400
Resent-From:(  0x81 ?x 0x81 x < 0x81 g> 0x81 | 0x81 g 0x81 .) crackaddr( root <root>)
crackaddr=>` root < 0x81 g>'
 root <root>
From:<NULL>
Full-Name:(  0x81 x)  root
Resent-Message-Id:( < 0x81 t. 0x81 i@ 0x81 j>)  <200908261539.n7QFdKGB008587@jiaoyou>
Message-Id:( < 0x81 t. 0x81 i@ 0x81 j>)  <200908261539.n7QFdKGB008587@jiaoyou>
From: email@example.com
To: email@example.com
sendto:  email@example.com
   ctladdr=[NULL]

--parseaddr(firstname.lastname@example.com)
rewrite: ruleset canonify           input: shore . cloud @ gmail . com
rewrite: ruleset Canonify2          input: shore . cloud < @ gmail . com >
map_lookup(host, gmail.com) => host_map_lookup(gmail.com) => map_rewrite(gmail.com), av =
        gmail.com
map_rewrite => gmail.com.
FOUND gmail.com
gmail.com. (0)
rewrite: ruleset Canonify2        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset canonify         returns: shore . cloud < @ gmail . com . >
rewrite: ruleset parse              input: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0             input: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0           returns: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse1             input: shore . cloud < @ gmail . com . >
rewrite: ruleset MailerToTriple     input: < > shore . cloud < @ gmail . com . >
rewrite: ruleset MailerToTriple   returns: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse1           returns:  0x96  esmtp  0x97  gmail . com .  0x98  shore . cloud < @ gmail . com . >
rewrite: ruleset parse            returns:  0x96  esmtp  0x97  gmail . com .  0x98  shore . cloud < @ gmail . com . >
rewrite: ruleset 2                  input: shore . cloud < @ gmail . com . >
rewrite: ruleset 2                returns: shore . cloud < @ gmail . com . >
rewrite: ruleset EnvToSMTP          input: shore . cloud < @ gmail . com . >
rewrite: ruleset PseudoToReal       input: shore . cloud < @ gmail . com . >
rewrite: ruleset PseudoToReal     returns: shore . cloud < @ gmail . com . >
rewrite: ruleset MasqSMTP           input: shore . cloud < @ gmail . com . >
rewrite: ruleset MasqSMTP         returns: shore . cloud < @ gmail . com . >
rewrite: ruleset EnvToSMTP        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset final              input: shore . cloud < @ gmail . com . >
rewrite: ruleset final            returns: shore . cloud @ gmail . com
parseaddr-->firstname.lastname@example.com:
        mailer 5 (esmtp), host `gmail.com.'
        user `email@example.com', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=180<QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)

recipient (0): firstname.lastname@example.com:
        mailer 5 (esmtp), host `gmail.com.'
        user `firstname.lastname@example.com', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)
maplocaluser: email@example.com:
        mailer 5 (esmtp), host `gmail.com.'
        user `email@example.com', ruser `<null>'
        state=OK, next=0x0, alias 0x0, uid 0, gid 0
        flags=182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; email@example.com"
        rstatus="(none)"
        statdate=(none)
rewrite: ruleset localaddr          input: shore . cloud @ gmail . com
rewrite: ruleset Local_localaddr    input: shore . cloud @ gmail . com
rewrite: ruleset ParseRecipient     input: shore . cloud @ gmail . com
rewrite: ruleset CanonAddr          input: shore . cloud @ gmail . com
rewrite: ruleset canonify           input: shore . cloud @ gmail . com
rewrite: ruleset Canonify2          input: shore . cloud < @ gmail . com >
map_lookup(host, gmail.com) => host_map_lookup(gmail.com) => CACHE gmail.com
map_rewrite(gmail.com), av =
        gmail.com
map_rewrite => gmail.com.
gmail.com. (0)
rewrite: ruleset Canonify2        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset canonify         returns: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0             input: shore . cloud < @ gmail . com . >
rewrite: ruleset Parse0           returns: shore . cloud < @ gmail . com . >
rewrite: ruleset CanonAddr        returns: shore . cloud < @ gmail . com . >
rewrite: ruleset ParseRecipient   returns: shore . cloud < @ gmail . com >
rewrite: ruleset Local_localaddr  returns:  0x96  relay  0x97  [ 127 . 0 . 0 . 1 ]  0x98  shore . cloud < @ gmail . com >
rewrite: ruleset localaddr        returns:  0x96  relay  0x97  [ 127 . 0 . 0 . 1 ]  0x98  shore . cloud < @ gmail . com >
rewrite: ruleset 2                  input: shore . cloud < @ gmail . com >
rewrite: ruleset 2                returns: shore . cloud < @ gmail . com >
rewrite: ruleset MasqSMTP           input: shore . cloud < @ gmail . com >
rewrite: ruleset MasqSMTP         returns: shore . cloud < @ gmail . com >
rewrite: ruleset final              input: shore . cloud < @ gmail . com >
rewrite: ruleset final            returns: shore . cloud @ gmail . com

recipient (1): email@example.com:
        mailer 8 (relay), host `[127.0.0.1]'
        user `email@example.com', ruser `<null>'
        state=OK, next=0x0, alias 0x7f32a16a4598, uid 0, gid 0
        flags=182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; email@example.com"
        rstatus="(none)"
        statdate=(none)
MIME-Version: 1.0
Content-Type: multipart/alternative;
Subject: Test HTML e-mail.
----------------------------
From person = "root"
getla(): 0.00

===== SENDALL: mode i, id n7QFdKGB008587, e_from 0x7f32a15d1fc0=root:
        mailer 3 (local), host `'
        user `root', ruser `<null>'
        state=SENDER, next=0x0, alias 0x0, uid 0, gid 0
        flags=181<QGOODUID,QPINGONFAILURE,QPINGONDELAY>
        owner=(none), home="/root", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="(none)"
        rstatus="(none)"
        statdate=(none)
        e_flags = 4605041<OLDSTYLE,DELETE_BCC,GLOBALERRS,METOO,HAS_DF,IS_MIME,SPLIT>
sendqueue:
email@example.com:
        mailer 8 (relay), host `[127.0.0.1]'
        user `email@example.com', ruser `<null>'
        state=OK, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; email@example.com"
        rstatus="(none)"
        statdate=(none)
email@example.com:
        mailer 5 (esmtp), host `gmail.com.'
        user `email@example.com', ruser `<null>'
        state=REPLACED, next=0x0, alias 0x0, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; firstname.lastname@example.com"
        rstatus="(none)"
        statdate=(none)

>>>>> queueing /var/spool/clientmqueue/./qfn7QFdKGB008587 (new id) >>>>>
queueing email@example.com:
        mailer 8 (relay), host `[127.0.0.1]'
        user `email@example.com', ruser `<null>'
        state=OK, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; firstname.lastname@example.com"
        rstatus="(none)"
        statdate=(none)
remotename(email@example.com)
remotename(email@example.com)
<<<<< done queueing n7QFdKGB008587 <<<<<

--deliver, id=n7QFdKGB008587, mailer=relay, host=`[127.0.0.1]', first email@example.com'
remotename(root)
rewrite: ruleset canonify           input: root
rewrite: ruleset Canonify2          input: root
rewrite: ruleset Canonify2        returns: root
rewrite: ruleset canonify         returns: root
rewrite: ruleset 1                  input: root
rewrite: ruleset 1                returns: root
rewrite: ruleset EnvFromSMTP        input: root
rewrite: ruleset PseudoToReal       input: root
rewrite: ruleset PseudoToReal     returns: root
rewrite: ruleset MasqSMTP           input: root
rewrite: ruleset MasqSMTP         returns: root < @ *LOCAL* >
rewrite: ruleset MasqEnv            input: root < @ *LOCAL* >
rewrite: ruleset MasqEnv          returns: root < @ jiaoyou . >
rewrite: ruleset EnvFromSMTP      returns: root < @ jiaoyou . >
rewrite: ruleset final              input: root < @ jiaoyou . >
rewrite: ruleset final            returns: root @ jiaoyou
remotename => `root@jiaoyou'
hostsignature([127.0.0.1]) = [127.0.0.1]

send to firstname.lastname@example.com:
        mailer 8 (relay), host `[127.0.0.1]'
        user `firstname.lastname@example.com', ruser `<null>'
        state=OK, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=(none), status=(none)
        finalrcpt="RFC822; firstname.lastname@example.com"
        rstatus="(none)"
        statdate=(none)
checkcompat(firstname.lastname@example.com, from=root)
openmailer: TCP [127.0.0.1]
makeconnection ([127.0.0.1] [127.0.0.1].25 (10))
makeconnection: fd=6
Connecting to [127.0.0.1]...
Connect failed (Connection refused by [127.0.0.1]); retrying with AF_INET....
makeconnection ([127.0.0.1] [127.0.0.1].25 (2))
makeconnection: fd=6
Connecting to [127.0.0.1]...
Connect failed (Connection refused by [127.0.0.1])
openmailer: makeconnection => stat=75, errno=111
openmailer: MCI@0x7f32a16926c8: flags=0,
        errno=111, herrno=0, exitstat=75, state=0, pid=0,
        maxsize=0, phase=initial connection, mailer=relay,
        status=4.4.1, rstatus=(null),
        host=[127.0.0.1], lastuse=Wed Aug 26 11:39:21 2009

dropenvelope 0x7f32a15d1fa0: id=n7QFdKGB008587, flags=4605043<OLDSTYLE,INQUEUE,DELETE_BCC,GLOBALERRS,METOO,HAS_DF,IS_MIME,SPLIT>

>>>>> queueing /var/spool/clientmqueue/./qfn7QFdKGB008587 >>>>>
queueing firstname.lastname@example.com:
        mailer 8 (relay), host `[127.0.0.1]'
        user `email@example.com', ruser `<null>'
        state=QUEUEUP, next=0x7f32a16a4598, alias 0x7f32a16a4598, uid 0, gid 0
        flags=80000182<QPRIMARY,QPINGONFAILURE,QPINGONDELAY,QRCPTOK>
        owner=(none), home="(none)", fullname="(none)"
        orcpt="(none)", statmta=[127.0.0.1], status=4.4.1
        finalrcpt="RFC822; firstname.lastname@example.com"
        rstatus="(none)"
        statdate=Wed Aug 26 11:39:21 2009

remotename(email@example.com)
remotename(email@example.com)
<<<<< done queueing n7QFdKGB008587 <<<<<

====finis: stat 75 e_id=NOQUEUE e_flags=4405043<OLDSTYLE,INQUEUE,DELETE_BCC,GLOBALERRS,METOO,IS_MIME,SPLIT>
</code>
Comment: What a brilliant question. It's almost recursive. +1 to you.
Answer: Short answer is "No, it doesn't need to be configured to send out emails."
Long answer is, "You're probably going to want to look it over and configure it if you want to send/receive emails.  You're also going to want to look at your DNS, SPF records, reverse PTR records, etc if you want to have a GOOD functional mail server."
There's actually quite a decent amount of work to configuring a mail server PROPERLY.
If all you want to do is have a script send out the occasional email though... you're probably fine.  (Unless YOUR mail server is aggressive on spam and checking to mail sure sending servers are REALLY mail servers... but I digress...)
Hope this helps.
Comment: I wouldn't send from "root" and the "127.0.0.1" doesn't look too good either.  Looks like you're trying to send to Google and I can assure you, Google is NOT going to consider your server to be a legit mail server.  So yes... you're probably going to have to do some configuration.
Comment: It's not fine,I can't send out emails now,don't know why
Answer: Sendmail will only send mails outbound with its initial installation on many systems. If you wish to receive e-mail on the system from external services, you will need to reconfigure it.
Comment: But in my environment it sucks,the emails can't be sent out


Issue with declaring global variable in c++?

Question: I am not that much experienced in c++. Here I am declaring two global variable
n and cache.This is my code for the same.
#include<iostream>
using namespace std;
#include<vector>
int n;
int cache[n][n];
int find_max_profit(vector<int> &v,int l,int r)
{
if(l>r)
{
    return 0;
}
else
{
    int year=l+n-r;
    return max(find_max_profit(v,l+1,r)+year*v[l],find_max_profit(v,l,r-1)+year*v[r]);
}
}
int main()
{
    cout<<"enter the number of wines"<<endl;
cin>>n;
int i,j;
cout<<"enter the prices"<<endl;
vector<int> v;
for(i=0;i<n;i++)
{
    for(j=0;j<n;j++)
    {
        cache[i][j]=-1;
    }
}
for(i=0;i<n;i++)
{
    int num;
    cin>>num;
    v.push_back(num);
}
int max=find_max_profit(v,0,n-1);
cout<<"maximum profit is "<<max<<endl;
return 0;
}

When i compile this code I get the following error:
||=== Build: Debug in selling wine (compiler: GNU GCC Compiler) ===|
/home/kaminey/makichut/selling wine/main.cpp|5|error: array bound is not     an integer constant before ']' token|
/home/kaminey/makichut/selling wine/main.cpp|5|error: array bound is not an integer constant before ']' token|
/home/kaminey/makichut/selling wine/main.cpp||In function 'int main()':|
/home/kaminey/makichut/selling wine/main.cpp|29|error: 'cache' was not   declared in this scope|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

But this should get compiled, I want to know what is wrong with my code here.
Comment: @user2738777 You need the value of `n` known at compile time. You can't magically expand it at runtime. Use `std::vector` or something else appropriate.
Comment: what is the value of `n` in `int cache[n][n];`?
Comment: @silentboy n is input.
Answer: You can't declare an array using size as an input integer. Either you have to depend on probable array size 10 like as follows;
int cache[10][10];

otherwise you can use std::vector<>  instead array.
Answer: You can't do this.
Compiler should know how to calculate array size.
int n;
int cache[n][n];

You can dynamically allocate cache array.
Comment: OKay , so any idea?,specially in dp questions how do we create a table because we can know input at the run time.
Comment: @user2738777 In dp solution, you just know how many states are there. Aren't you?
Answer: Possibility solutions:
cache = new int*[n];
for( int i = 0; i < n; i++ ) {
    cache[i] = new int[n];
}

or
std::vector< std::vector<int> > cache;
cache.resize( n, std::vector<int>( n, 0 ) );

Answer: It is a non-issue that your variables are global (The fact that they're global is  more related to best-practices and scoping, but is unrelated to your compile error.) The issue instead is that the compiler does not know how large your cache is at compile time.
I'm not super clear on the reasoning behind why, but when you declare an array in C++ that is NOT dynamically allocated, the array-size must be known at the time of compilation. Since your current version of the code requires user-input to define the size of the array, the compiler does not know the size at the time of compilation ("Could the user want n = 10? Or perhaps n = 100? I do not know how much room to give cache ]: ").
In order to get around this, I would personally try to follow the other users' solutions; either dynamically allocate your cache, or use a std::vector.
Here is some general information on arrays. I have also quoted some relevant lines from this link that touch upon your issue:

A fixed array (also called a fixed length array or fixed size array) is an array where the length is known at compile time.

and

Because fixed arrays have memory allocated at compile time, that introduces two limitations:

Fixed arrays cannot have a length based on either user input or some other value calculated at runtime.

Fixed arrays have a fixed length that can not be changed.
Answer: the first Error is that the Array bound of cache (n) must be Const .. or you can make your array as dynamic array like this..
int **cache=new int*[n];
for (int i=0;i<n;i++)
{
cache[i]=new int[n];
}

Comment: Can you add any explanation of your code to the answer post instead of the comments? Comments are easily missed or deleted.
Comment: the first Error is that the Array bound of cache (n) must be Const ..
or you can make your array as dynamic array
like this..


How to ensure successful update after system failure during updb causing the site to remain in maintenance mode?

Question: Running drush updb to upgrade drupal core or other modules, puts the site in maintenance mode. I recently faced an issue (probably an edge case) where the site was stuck in maintenance mode after running updb in a pipeline of a containerized infrastructure. Here is the sequence of events:

Run drush updb -y
Container terminated (system failure or unknown reason)
Re-attempt at drush updb
drupal returns "no updates were required" (this tells me that the step 1 may have completed the update in the background?"
Site remains in maintenance mode.
I manually bring the site back online.

After all this it looked like the update was successful.
How do I ensure the integrity of the system when this happens without restoring a backup and running the updates again? When running subsequent drush updb that says "no updates required" does this guarantee the previous updates were successful.
Comment: You also can run `drush state:set system.maintenance_mode 0` to disable maintenance mode. When you've run drush updb there must have been some output of which updates exactly are going to be run and you should also see the output of the last hook that was run before it failed. Do you remember the hook name and have you looked at what it was supposed to be doing and checked that it has done it? I'd also assume that the registry of performed updates will only be updated if an update was run successfully til the end. But that's just an assumption.
Answer:
When running subsequent drush updb that says "no updates required" does this guarantee the previous updates were successful.

When Drush queues up batch items to be processed for drush updb, it adds these operations:

Any module schema updates
Any entity definition updates (off by default, not supported after 8.7)
A cache clear & post hook update functions (on by default)
Toggle off maintenance mode (if it not already enabled)

If the only updates were module schema updates then you might be in a scenario where things are ok; there are no post-update hooks needed (e.g. some batch data ops following a schema change) and only the last step of toggling off maintenance mode didn't complete.

How do I ensure the integrity of the system when this happens without restoring a backup and running the updates again?

You'd have to audit the list of updated modules to double-check each schema update was applied and there were no post-update hooks missed in the update.
Depending on your update scenario this may or may not be easy, hence the best practice is doing a DB rollback and re-applying updates to ensure data integrity when uncertain.


The links to .xls files will not work on my intranet site?

Question: I am currently building an asp intranet site.
There are various helpful links that I need to include and some of them happen to be .xls files that are located on a local network within the company.
I link these documents just like I would any word docs (which work fine by the way).
Schedule

The link above works if I simply copy and paste the raw address into my browser (a pop-up window comes up asking me to open the file in Excel). But when I make this a link on the intranet site and try to click on it, nothing happens. I can see the link when I hover over it on the status bar but that's it. It is non-clickable. Anyone have any idea what is causing this and how to fix it?
I should mention that two of these .xls files are password-protected but one of them is simply a read-only file which can be opened by anyone.
I am 100% sure this has nothing to do with css styling because the same thing happens in the current (old) intranet site made by someone else and I use these links on different menu bars as well.
Answer: I think you use wrong syntax for shared files, try this:
file:///P:\-Projects-\SCHEDULE.xls
Backslashes are still valid for the path part. Moreover, I'm not sure whether Sharepoint may recognize correctly path to most likely network drive P:.
For me such link to local share works:
file:///\\fs-1\Install\Windows\Servers\DB\MSSQL\SQL2005\en_sql_server_2005_service_pack_4_x64.exe
Comment: I tried changing it to what you suggested but the problem still occurs. Curiously, the status bar still displays it as "file:///P:/-Projects-/SCHEDULE.xls" when I hover over the anchor but when I inspect the element, the slash changes have definitely been applied.
Comment: `file://///fs-1/Install/Windows/Servers/DB/MSSQL/SQL2005/` - this is how Firefox shows opened link in address bar. I'd rather look towards `P:` suggestion.
Comment: I just found this article: http://kb.mozillazine.org/Links_to_local_pages_don%27t_work However, it says IE should be able to open local files (and suggests an IE tab add-on), but the links don't work in IE8 for me either.
Comment: @user1781568 I have no more suggestions, sorry. perhaps others will bring something new.
Answer: The solution to this problem is to add the site to the "Trusted Sites" list.
Opening intranet files without the user knowing is considered a secruity threat.
In IE go to Internet Options ->  Security -> Trusted Sites then add the site.
http://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/after-latest-update-ie-wont-open-network-file/172e4ac3-1c1f-4948-8a3f-c8c344eae06d


Granting a user permissions to PS Remote without allowing RDP

Question: Is there a way I can grant a user the ability to use Invoke-Command in PowerShell remotely without giving them RDP Access to the server?
Answer: According to Microsoft TechNet, you don't want to add the user to the Remote Management Users group. You want to add the user to the WinRMRemoteWMIUsers_ Group. WinRMRemoteWMIUsers_ Group will give the user the ability to run remote PowerShell commands. Remote Management Users Group is for managing the server using Server Manager.
Comment: It seems like that did not help.
I got "access denied" when using only this group.


How to update the language in a existing node entity?

Question: Using kint($node) gives me some available methods to use but none seems to be able to set the language of the node.
By guessing, I found $node->langcode, which gives me a method setLangcode($langcode), but it does not work.
After loading the $node->langcode->setLangcode('cat'); and $node->save();, the node in the interface does not have the updated language.
Comment: Did you ever solve this? Did you get a chance to try my suggestion?
Comment: Hello, super late response, sorry. But i could not try your solution, but it looks good, gave it a +1
Answer: You should be using the get()/set() methods (of the FieldableEntityInterface), sth like this:
// Get the current node's language.
$node->get('langcode')->value;
// Set the current node's language.
$node->set('langcode', 'de');
// Save the node to persist the change.
$node->save();

Hope this answers the question for you.
Comment: This will not update the langcode column in the node_field_data table.
Comment: Probably related issue on drupal.org: [Allow default_langcode field value to be changed](https://www.drupal.org/project/drupal/issues/2443991)
Comment: Testing with Drupal 8.9.13, using the above code to change a node's language from 'und' to 'en', seems to work as a charm. It also updates node_field_data table and all field tables.
Comment: Following up above comment, you have to ensure that there is a pathauto pattern specified for the CTs of the nodes to get updated, else their path aliases will get lost.


If $y=\frac25+\frac{1\cdot3}{2!}\left(\frac25\right)^2 +\frac{1\cdot3\cdot5}{3!}\left(\frac25\right)^3+\ldots$ then what is the value of $y^2+2y$?

Question: If
$$y=\frac25+\frac{1\cdot3}{2!}\left(\frac25\right)^2 +\frac{1\cdot3\cdot5}{3!}\left(\frac25\right)^3+\ldots$$
then what is the value of $y^2+2y$?
This is a question from my coaching material in which binomial theorem, multinomial theorem and binomial theorem with fractional and negative indices are covered. How do I approach this problem? What is the pattern in it?
Comment: You've been around for seven months. Didn't you notice that you are supposed to use MathJax?
Comment: Note that $1\cdot3\cdot 5=6!/2^3/3!$
Comment: If by pattern, you mean the summation, it appears to be

$$\sum_{n=1}^\infty \frac{(2n-1)!!}{n!} \cdot \left( \frac{2}{5} \right )^n$$

where "$x!!$" is denoting the double factorial, for clarity's sake. I'm not really sure where to go from there myself though. My gut instinct is that definition which states the double factorial in terms of the regular factorial, but I wouldn't trust me on that.
Comment: I'm voting to close this question as off-topic because it lacks efforts and it is an abstract duplicate of *so many* questions.
Comment: Please read this [tutorial](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) on how to typeset mathematics on this site.
Comment: See https://math.stackexchange.com/questions/746388/calculating-1-frac13-frac1-cdot33-cdot6-frac1-cdot3-cdot53-cdot6-cdot
Comment: Good ol' central binomial coefficients / Catalan numbers / Lagrange's inversion theorem. But before asking, *please try something*.
Comment: @JackD'Aurizio I haven't studied Catalan numbers or Lagrange's inversion theorem. I had studied the basic binomial theorem as well as the binomial theorem formula for negative and fractional indices but at first it seemed to me to be unrelated to either. I had forgotten to use MathJax in my question and so I hadn't seen the similar questions.I just noticed that there were some similar questions after I got an answer. I'm sorry.
Answer: Recall the binomial series  $(1+x)^\alpha=1+\alpha x+\frac{\alpha(\alpha-1)}{2!}+\dots$
Let $x=\frac{-4}{5}$ and $\alpha=\frac{-1}{2}$. Then
$$
\sqrt{5} = \left(1-\frac{4}{5}\right)^{\frac{-1}{2}}
= 1 +\frac{2}{5} + \frac{1\cdot3}{2!}\cdot\left(\frac{-1}{2}\right)^2\cdot\left(\frac{-4}{5}\right)^2+\dots =y+1
$$
so $y^2+2y=(y+1)^2-1=4$
How to arrive at this: in your question you stated that you want to use the binomial theorem. The thing stopping you is that the numerators are decreasing by two each time, rather than by one. This suggests that the exponent is a half-integer. Once you have this it's just a matter of fiddling to come up with the values of $x$ and $\alpha$.
Answer: Some hints:
We should look at the series
$$f(x):=\sum_{k=1}^\infty{(2k-1)!!\over k!}\>x^k\ .$$
I suggest you bring ${1\over\sqrt{1-2x}}$ into the game. This should allow you to obtain a nice expression for $f(x)$.


HQL - Return a List of Complex Objects

Question: Currently have 2 very basic Classes, one is nested in the other one.
Class Job:
public Class Job {
   private String name;
   private int salary;
   ... // Basic Constructors + Getters/Setters
}

Class Company:
public Class Company {
   private String name;
   private Collection<Job> jobs;
   ... // Basic Constructors + Getters/Setters
}

You probably guessed it, trying to make a query that will return a list of Companies that each contain their Collection of Jobs.
The query:
select COMPANY_NAME, JOB_NAME, count(*) FROM COMPANY_REPORT cr, JOB_DECLARATIONS jd
where cr.COMPANY_NAME = jd.COMPANY_NAME
group by cr.COMPANY_NAME , cr.JOB_NAME
order by cr.COMPANY_NAME , cr.JOB_NAME

Will return something like this:
Company Name | Job Name | Count
--------------------------------
Soni           Assistant    3
Soni           Manager      1
Zoom           Potographer  5

But I can't seem to understand the HQL syntax for it.
Select new com.stuff.Company(cr.COMPANY_NAME, ...how to add collection??) FROM ...

Answer: Select  c.name, j.name, count(*) from company c, job j where c.name=:name    group by c.name, c.jobs
Order by c.name,c.jobs

find setparameterList here

HQL - Return a List of Complex Objects


Determining which overload was selected

Question: Let's say I have some arbitrary complicated overloaded function:
template <class T> void foo(T&& );
template <class T> void foo(T* );
void foo(int );

I want to know, for a given expression, which foo() gets called. For example, given some macro WHICH_OVERLOAD:
using T = WHICH_OVERLOAD(foo, 0);       // T is void(*)(int);
using U = WHICH_OVERLOAD(foo, "hello"); // U is void(*)(const char*);
// etc.

I don't know where I would use such a thing - I'm just curious if it's possible.
Comment: I don't think this is possible. This is very similar to the library fundamentals TS's invocation type traits, and the latter is known to require compiler magic to implement.
Comment: @PreferenceBean My insatiable curiosity is an actual, practical problem that I face.
Comment: Note that the type is not enough for distinguish overload btw.
Comment: @T.C. Ah, yeah, that's what I thought. [This one](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3866.html)?
Comment: It is possible (at least in gcc), but I could not find solution again. I remember idea, it was to provide some fake construct that will fail during compilation time and print error with whole template.
Comment: _"I don't know where I would use such a thing - I'm just curious if it's possible."_ You should ask questions about actual, practical problems that you face.
Comment: Could you elaborate, you want to know which overload was used during compile time, or you would like to use return function type in the code?
Comment: You could replace with typedef decltype(bind(foo, 0)) T; //T is std::bind Technically it is very close...
Comment: @user3545806 Did you try it? That cannot compile, since you cannot pass an overloaded function into a template.
Comment: You are right it compiles only for int...
Comment: It might be quite interesting for testing, if you want to make sure that you got your overloads right...
Comment: Instead of overloading the function what about inheriting from a fake object and then checking at run-time which is the actual object ?
Answer: Barry, sorry for the misunderstanding in my first answer. In the beginning I understood your question in a wrong way. 'T.C.' is right, that it is not possible except in some rare cases when your functions have different result types depending on the given arguments. In such cases you can even get the pointers of the functions.
#include <string>
#include <vector>
#include <iostream>

//template <class T> T foo(T ) { std::cout << "template" << std::endl; return {}; };
std::string foo(std::string) { std::cout << "string" << std::endl; return {}; };
std::vector<int> foo(std::vector<int>) { std::cout << "vector<int>" << std::endl; return {}; };
char foo(char) { std::cout << "char" << std::endl; return {}; };

template<typename T>
struct Temp
{
    using type = T (*) (T);
};

#define GET_OVERLOAD(func,param) static_cast<Temp<decltype(foo(param))>::type>(func);

int main(void)
{
    auto fPtr1 = GET_OVERLOAD(foo, 0);
    fPtr1({});

    auto fPtr2 = GET_OVERLOAD(foo, std::string{"hello"});
    fPtr2({});

    auto fPtr3 = GET_OVERLOAD(foo, std::initializer_list<char>{});
    fPtr3({});

    auto fPtr4 = GET_OVERLOAD(foo, std::vector<int>{});
    fPtr4({});

    auto fPtr5 = GET_OVERLOAD(foo, std::initializer_list<int>{});
    fPtr5({});

    return 0;
}

The output is:
char
string
string
vector<int>
vector<int>

Answer: I'm probably far from what you have in mind, but I've spent my time on that and it's worth to add an answer (maybe a completely wrong one, indeed):
#include<type_traits>
#include<utility>

template <class T> void foo(T&&);
template <class T> void foo(T*);
void foo(int);

template<int N>
struct choice: choice<N+1> { };

template<>
struct choice<3> { };

struct find {
    template<typename A>
    static constexpr
    auto which(A &&a) {
        return which(choice<0>{}, std::forward(a));
    }

private:
    template<typename A>
    static constexpr
    auto which(choice<2>, A &&) {
        // do whatever you want
        // here you know what's the invoked function
        // it's template<typename T> void foo(T &&)
        // I'm returning its type to static_assert it
        return &static_cast<void(&)(A&&)>(foo);
    }

    template<typename A>
    static constexpr
    auto which(choice<1>, A *) {
        // do whatever you want
        // here you know what's the invoked function
        // it's template<typename T> void foo(T *)
        // I'm returning its type to static_assert it
        return &static_cast<void(&)(A*)>(foo);
    }

    template<typename A>
    static constexpr
    auto
    which(choice<0>, A a)
    -> std::enable_if_t<not std::is_same<decltype(&static_cast<void(&)(A)>(foo)), decltype(which(choice<1>{}, std::forward(a)))>::value, decltype(&static_cast<void(&)(A)>(foo))>
    {
        // do whatever you want
        // here you know what's the invoked function
        // it's void foo(int)
        // I'm returning its type to static_assert it
        return &foo;
    }
};

int main() {
    float f = .42;
    static_assert(find::which(0) == &static_cast<void(&)(int)>(foo), "!");
    static_assert(find::which("hello") == &static_cast<void(&)(const char *)>(foo), "!");
    static_assert(find::which(f) == &static_cast<void(&)(float&)>(foo), "!");
    static_assert(find::which(.42) == &static_cast<void(&)(double&&)>(foo), "!");
}

I'll delete this answer after a short period during the which I expect experts to curse me. :-)
Comment: If you're just going to enumerate all the overloads, you don't need `choice<>`. You can just have all the overloads return the signature [demo](http://coliru.stacked-crooked.com/a/49779a83d15d0e36)
Comment: Actually, the aim is to give priorities to all the not templated functions (as `void foo(int);`), then to the templated ones. This way you are enumerating two specializations plus all the available not templated functions (not only the `int` one of your example). Surely it can be done with less code, not the one you linked anyway.
Comment: I read a comment of yours to another answer (*it won't work if I change it in `void foo(char)`*). Because of that, I thought the goal was to get the not templated function if any exists, the right specialization otherwise. The `choice` simply helps to iterate over them. It could have been done with a sort of `int`/`char` dispatching maybe or whatever. Anyway, I hope I succeeded in explaining what the target was.
Comment: The goal is to pick the correct overload - based on the normal overload resolution mechanism. That's the target. If you're going to just enumerate all the possible overloads - you don't need any additional dispatching, what I linked is sufficient. But enumerating the overloads can never work (e.g. what if somebody adds a `namespace N { struct X {}; void foo(X ) }` somewhere else...)
Comment: You say *I want to know, for a given expression, which foo() gets called*. In which form do you expect this information to be? Just to know, for I guess I've completely misunderstood the problem. I'm sorry.

Determining which overload was selected


Configure Sympa: Command output usage error

Question: I have a problem on configuring Sympa.
I've created a new list firstname.lastname@example.com, but when I try to send mail to this list, I get an error in my maillog:
postfix/pipe[13544]: C699261227: firstname.lastname@example.com, relay=sympa, delay=0.33, delays=0.31/0.01/0/0.01, dsn=5.3.0, status=bounced (command line usage error. Command output: /home/sympa/bin/queue: usage error, one one list-name argument expected. ).

Can anybody tell me what command argument Sympa needs?
I have configured /etc/postfix/main.cf and /etc/postfix/master.cf. Every member that subscribed to this mailing list gets mail.
In /home/sympa/etc/sympa_aliases I have records about new lists:
new_test_list: "| /home/sympa/bin/queue firstname.lastname@example.com"
new_test_list-request: "| /home/sympa/bin/queue firstname.lastname@example.com"
new_test_list-editor: "| /home/sympa/bin/queue email@example.com"
new_test_list-unsubscribe: "| /home/sympa/bin/queue email@example.com"
new_test_list-owner: "| /home/sympa/bin/bouncequeue firstname.lastname@example.com"

postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases,hash:/home/sympa/etc/sympa_aliases
allow_percent_hack = no
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
myhostname = ns1.example.com
newaliases_path = /usr/bin/newaliases.postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_domains = $mydestination, lists.examle.com
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sender_bcc_maps = hash:/etc/postfix/bcc
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_bind_address = 10.0.1.10
smtp_tls_note_starttls_offer = yes
smtp_use_tls = yes
smtpd_recipient_restrictions =  permit_mynetworks permit_sasl_authenticated
                                reject_unauth_destination
                                check_policy_service unix:/var/spool/postfix/postgrey/socket
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain =
smtpd_sasl_security_options = noanonymous
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_auth_only = no
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
transport_maps = regexp:/home/sympa/etc/transport_regexp
unknown_local_recipient_reject_code = 550
virtual_alias_maps = hash:/etc/postfix/virtual

grep C699261227 /var/log/maillog
Mar 18 20:05:52 ns1 postfix/pickup[13491]: C699261227: uid=553 firstname.lastname@example.com
Mar 18 20:05:52 ns1 postfix/cleanup[13515]: C699261227: firstname.lastname@example.com
Mar 18 20:05:52 ns1 postfix/qmgr[9232]: C699261227: email@example.com, size=438, nrcpt=1 (queue active)
Mar 18 20:05:52 ns1 postfix/pipe[13544]: C699261227: firstname.lastname@example.com, relay=sympa, delay=0.33, delays=0.31/0.01/0/0.01, dsn=5.3.0, status=bounced (command line usage error. Command output: /home/sympa/bin/queue: usage error, one one list-name argument expected. )
Mar 18 20:05:52 ns1 postfix/bounce[13546]: C699261227: sender non-delivery notification: CCF93615E7
Mar 18 20:05:52 ns1 postfix/qmgr[9232]: C699261227: removed

cat /home/sympa/etc/transport_regexp
/^.*-owner\@lists\\.example\\.com$/ sympabounce:

/^.*\@lists\\.example\\.com$/       sympa:

/etc/postfix/master.cf
### Added for sympa
sympa   unix    -       n       n       -       -       pipe
  flags=R user=sympa argv=/home/sympa/bin/queue ${recipient}

sympabounce     unix    -       n       n       -       -       pipe
    flags=R user=sympa argv=/home/sympa/bin/bouncequeue ${recipient}

Comment: Please post the output of `postconf -n` and `grep C699261227 mail.log`
Comment: I've posted the output of this commands in my question, because I have a limit of characters in comment.
Comment: what's the content of `/home/sympa/etc/transport_regexp` and `master.cf`? Please post it in the question
Comment: Do you need all output of master.cf or only that I've added for Sympa?
Comment: Are you sure the lines in `transport_regexp` is `/^.*\@lists\\.example\\.com$/       sympa:` not `/^.*\@lists\.example\.com$/       sympa:`???
Comment: line in transport_regexp is:   /^.*\@lists\.example\.com$/ sympa: Sorry, when I typed this message, it is seen with one "\".
Comment: Good. Can you try the little experiment in my answer below? `queue` program only [expect 1 or 2 parameter](http://www.sympa.org/distribution/current/src/queue.c).
Comment: Yes, This line from my maillog: C9B8661C20: to=, relay=sympa, delay=0.33, delays=0.31/0.01/0/0.01, dsn=5.3.0, status=bounced (Command died with status 2: "/tmp/printargs.sh". Command output: args: firstname.lastname@example.com )
Comment: Hmm it's expected result. If you send email to new_test_list, did you still get same error as before (sympa argument error)?
Comment: It's work after your test. Magic. Thank you very much! Do you know what happened?
Comment: Dunno, maybe you don't restart postfix after adding transport_maps. Maybe there are typo in your master.cf, especially in sympa service. Anyway congratulations
Comment: Even though this question is already over a year old - there is also a bug in the main.cf on
relay_domains = $mydestination, lists.examle.com

- just in case someone copies the content ...
Answer: I've tried to reproduce your case, but I wasn't successful.
Based on your maillog lines
Mar 18 20:05:52 ns1 postfix/pipe[13544]: C699261227: email@example.com, relay=sympa, delay=0.33, delays=0.31/0.01/0/0.01, dsn=5.3.0, status=bounced (command line usage error. Command output: /home/sympa/bin/queue: usage error, one one list-name argument expected. )

Postfix piped email to /home/sympa/bin/queue because of transport_maps parameter instead /home/sympa/etc/sympa_aliases.
To debug further you can do this step

Create file /tmp/printargs.sh with content
#!/bin/sh
echo "args: $@"
exit 2

it will echo all arguments.
Set appropriate  permission
chown sympa /tmp/printargs.sh
chmod u+x /tmp/printargs.sh

Change master.cf entry with
sympa   unix    -       n       n       -       -       pipe
    flags=R user=sympa argv=/tmp/printargs.sh ${recipient}

Restart postfix and see the maillog entry. In my case, it would output
Mar 23 03:23:38 sy postfix/pipe[1702]: 914A04042B: to=<firstname.lastname@example.com>, relay=sympa, delay=0.06, delays=0.03/0.01/0/0.02, dsn=5.3.0, status=bounced (Command died with status 2: "/tmp/printargs.sh". Command output: args: firstname.lastname@example.com )


Websites from the same hosting doesn't open only from my router/proovider

Question: Faced with a strange problem.
I have a hosting with few websites. Starting from today I can't navigate any of them from any device, connected to home wifi. But I can ping each domain.
Chrome fails with Timeout, while mobile browser fails with Connection Refused.
And there are nobody (as far as I know) who experiencing the same problem.
The only changes were made during this period are (for domain config):
1. added TXT domain_key record
2. added TXT @ SPF record

Tried to restart router, get a new IP, flush DNS, restart hosting.
UPD.
nslookup shows:
nslookup domain.com
Server: unknown
Address: 192.168.1.1

Non-authoritative answer:
Name: domain.com
Address: <correct IP>

tracert domain.com
output doesn't show any errors and show trace without any problems tight to the domain.com

Answer: On my box there was installed iRedMail bundle with fail2ban.
By some reason fail2ban banned my ip automatically.
to watch all banned items execute:
fail2ban-client -S

To unban IP from iRedMail postfix list:
fail2ban-client set postfix-iredmail unbanip <ip>

where postfix_iredmail is fail2ban JAIL name (the list of all jails can be retrieved by status command).


My login form seems to have disappeared

Question: I'm developing a custom theme and even though I have placed the "user login" block in a region, I can't find it and now I'm locked out.
My site is on Drupal 8.
Comment: Have you tried going to something.com/user/login to login?
Answer: The login block is "a" way to get logged in. Another solution to get loged in is to navigate to an URL like <code>/user/login</code>.
So try that, and see what happens then. Of course, if you get logged in, hurry to move that disappeared block to some region that for sure you now is OK. To QA test it, use another browser before logging out again ...
Comment: Thanks Pierre. But /user/login does not show the user form either.
Comment: Maybe I should mention that I dont have the block "main page content" enabled in any of the content regions. Could this be  problem?
Answer: Phew!!. After hours of almost going crazy, I finally solved this by removing the custom theme from the theme directory. The default theme presented me with a login form and I'm back in. Thanks guys for help.

My login form seems to have disappeared


Can you formulate a $ \phi, \theta $ restriction in spherical coordinates for a great circle?

Question: Further to this question
Quaternion rotation has a nice property that you can trace any great circle you like.  You specify the axis of rotation, and you will automatically follow the great circle when rotating.
However spherical coordinates only trace a great circle when $ \theta (elevation) = 0 $, and $\phi (azimuth) $ is allowed to travel $ 0.. 2\pi$.
So my question is, is there a way to formulate a $\theta, \phi$ restriction that will allow me to trace an arbitrary great circle in spherical coordinates?
Comment: There are at least two ways to start with constructing the parametric equations of a great circle: one involves finding the plane through the origin where your great circle lies in, and the other involves finding two points where your great circle passes through.
Comment: Do you have a little more detail?  I've got 4 points in each plane, so can do both!
Answer: Since you've got four points in the plane of the great circle, you can find its normal $n$. Then the equation for the spherical coordinates is simply
$$\pmatrix{\sin\theta\cos\phi\\\sin\theta\sin\phi\\\cos\theta}\cdot n=0\;.$$
If you like, you can solve this for $\theta$ in terms of $\phi$:
$$\theta=-\arctan\left(\frac{n_z}{n_x\cos\phi+n_y\sin\phi}\right)\;,$$
where you have to add $\pi$ to negative values if you want $\theta$ in the usual range $[0,\pi]$.


Adding a List Box

Question: AM using 2 buttons in my Page. Add and Remove
If I press Add, a row of text box and a list box should be added.
Remove is used to Undo the Previous operation.
The code I have used is,
var cellRight = row.insertCell(5);

var el = document.createElement('input');

el.setAttribute('type', 'text');

el.setAttribute('name', 'txtRow');

el.setAttribute('size', '15');

cellRight.appendChild(el);

This works well if I use only text box. To add a List box
var cellRight = row.insertCell(6);

var el = document.createElement('input');

el.setAttribute('type', 'select');

el.setAttribute('size', '15');

el.setAttribute('method','onclick');

cellRight.appendChild(el);

I wrote this code, but when I press the "Add" button, only Text Boxes instead of list boxes.
Is my code correct?
Answer: There is no <input type="select">. You need to create a select element and add option sub-elements.
Something along these lines perhaps:
var el = document.createElement('select');
el.setAttribute('name', 'txtRow');
el.setAttribute('size', '15');

var label = document.createTextNode('item1label');
var opt = document.createElement('option');
opt.setAttribute('value', 'item1value');
opt.appendChild(label);
el.appendChild(opt);

cellRight.appendChild(el);

Beware, dry-coded, ymmv.
Comment: Also, worth mentioning that this would be simpler with a JS library, in case you've not come across one. For example, one of: jQuery, Prototype, MooTools, etc.

Adding a List Box


a problem in convergence of bounded of a series

Question: Let {$a_1, a_2,...$} be a sequence of real numbers with $a_i\ge0$. If $\sum_{1}^{\infty}\frac{1}{1+a_n} < \infty$, then show that $\sum_{1}^{\infty}\frac{1}{1+x_na_n} < \infty$  for each real
sequence $x_1, x_2,...$ with $x_i\ge 0$ and $\lim \inf _{n \to \infty} x_n > 0.$

I am stuck on this problem.Can I get some help?Thanks for your time.
Comment: Welcome to MSE! It helps to share what you tried so users can provide better guidance. Regards
Answer: Since $\liminf\limits_{n\to\infty}x_n>0$, we have some $\epsilon>0$ and $N\in\mathbb N$ such that $n\geq N\implies x_n>\epsilon$. We can take $\epsilon\leq 1$. Thus
$$\begin{align}
\sum_{n=1}^\infty\frac{1}{1+x_na_n} &=\sum_{n=1}^{N-1}\frac{1}{1+a_nx_n}+\sum_{n=N}^\infty \frac{1}{1+x_na_n}\\
&\leq \sum_{n=1}^{N-1}\frac{1}{1+a_nx_n}+\sum_{n=N}^\infty \frac{1}{\epsilon+\epsilon a_n}\\
&\leq \sum_{n=1}^{N-1}\frac{1}{1+a_nx_n}+\frac{1}{\epsilon}\sum_{n=N}^\infty \frac{1}{1+a_n}\\
\end{align}$$
and since both of these sums are finite, the result must be finite.


Is it true that $\bigcup_{a\in A}\{f(a)\}=f(A)$?

Question: Let $A$ and $B$ be arbitrary sets with arbitrary elements $a\in A$ and $b\in B$, and let $f:A\to B$ be a function. Further, let $f(A)=\{b\in B:b=f(a)\text{ for some }a\in A\}$ be the image of the function $f:A\to B$. Is the following statement true?
\begin{gather}
\bigcup_{a\in A}\{f(a)\}= f(A)
\end{gather}
[EDIT] ATTEMPT: I believe the answer to be 'yes' because:
\begin{align}
\bigcup_{a\in A}\{f(a)\}&=\{b\in B:b=f(a)\text{ for some }a\in A\}\\
&=\{f(a):a\in A\}\\
&=f(A)
\end{align}
Comment: what do you think ? what have you tried ?
Comment: Please, use $=$ and not $\equiv$; they are *sets*.
Comment: Usually, we have *equality* ($=$) between "objects", like sets, and equivalence ($\equiv$) between statements (see prop logic).
Comment: Re your last point in the comment below: $f(A)$ is a *set*: the set of values of function $f$ for "inputs" from set $A$, while $f(a)$ is a single element: the value of $f$ for input $a$. The operation $\bigcup$ is on sets; thus, we have to consider the sets $\{ f(a) \}$ and "collect" them all together for all $a$'s in set $A$ in order to have an "equation" (here why the equal sign) between sets.
Comment: @Héctor The initial statement is false, because $\bigcup f(a)$ is ill defined. It cannot be equal to what is on the RHS. Roughly speaking, two objects are equal only if they are the same kind of object. So if on one side you have a set, then you need to have a set on the other side of $=$.
Comment: @Surb Thank you for your comment. I thought the answer was yes, but apparently is no…
Comment: @MauroALLEGRANZA  Thank you for your comment. I have edited the question. Could you please give some guidance on when is the use of "$\equiv$" acceptable?
Comment: Thank you for your comment. It is my understanding from your comment and AlvinL's answer that despite the statement $\bigcup_{a\in A}\{f(a)\}=f(A)$ is correct, the statement $\bigcup_{a\in A}f(a)=f(A)$ is incorrect becase $f(a)$ is not a set but $\{f(a)\}$ is. Also, it is my understanding that if the function $f:A\to 2^B$ mapped to the power set of $B$ (i.e., $2^B$) rather than to $B$ itself, the expression $\bigcup_{a\in A}f(a)=f(A)$ would be true because $f(a)$ would be a subset of $B$ and therefore a set. Correct?
Answer: The initial statement $\bigcup _{a\in A}f(a) = f(A)$ is false. On the RHS is a subset of $B$. The LHS is some ill defined collection of symbols. You should, instead, try to prove the equality
$$ \bigcup _{a\in A}\{f(a)\} = f(A). $$

You might think that assuming $f(a)$ is a set for every $a\in A$ saves the day. Well now you have a new problem. Without getting too technical, I'll just give an example.
Put $A =\{a,b\}$ and $B = \{ \{1,2\}, \{3,4\}\}$. Let $f(a) = \{1,2\}$ and $f(b) = \{3,4\}$. Then
$$ \bigcup f(a) = \{1,2,3,4\} \quad\mbox{and}\quad f(A) = B.  $$
There is no equality.
Comment: Your post starts with "let $f : A \to B$ be a function". You cannot then change your mind and suppose instead that $f : A \to 2^B$ without abusing notation.
Comment: @Héctor Set theoretic operations can be done with , let's call them, cardboard boxes. If $f(a) = \textbf{"cat"}$, then it's not a cardboard box, is it? On the other hand, you could put it into a cardboard box (i.e $\{f(a)\}$). For now it suffices to understand this difference.
Comment: @Héctor union is defined for sets and only sets. $f(a)$ can be anything, a number, a matrix, and so on.
Comment: @Héctor The first half of your comment does not work.
Comment: @AlvinL: My comment was addressed to the immediately preceding comment by the OP.
Comment: @LeeMosher my mistake
Comment: Thank you for your comment. I have two questions: (1) could you please explain why your notation is right and mine is wrong (I don't see it)? Also, (2) is the statement you're suggesting me to prove true or false?
Comment: Thank you for your comment. Unfortunately, I don't see the relation between your comment and my question.
Comment: If we let $f(a)$ be a set, then the expression $\bigcup_{a\in A}f(a)=f(A)$ is true, whereas the expression $\bigcup_{a\in A}\{f(a)\}=f(A)$ is correct regardless of the nature of $f(a)$. Yes?
Comment: Why doesn't? Suppose that $f:A\to 2^B$, where $2^B$ is the power set of $B$. Then, $f(a)$ is a set, isn't it?
Comment: Thank you. Your edit made me understand your point.


I am getting an error while opening a .pickle file in itellij

Question: The file is in the same directory. The path is correct.
Answer: Try to remove "../Deep-Learning/" and use only "cnn_min_max.pickle" as path
Comment: Thank you for your reply. Still the same problem
Comment: Ah okay. Maybe the problem could be the "-" in the "Deep-Learning" path. If is not this try to use the absolute path but i think is not the best solution.


How to use hook_views_data_alter to display select list on user reference field?

Question: I want to allow administrator to edit user reference field value on the fly when browsing entities list (view as table). In every row select list with user to choose should appear.
Current code:
<code>function rpke_document_assign_views_data_alter(&$data) {
    $data['field_data_field_assignee']['applicant_chooser'] = array(
        'real field' => 'field_applicant_target_id',
        'field' => array(
            'title' => t('Applicant chooser'),
            'help' => t('Applicant chooser based on select list. Extends views_handler_field_user_name'),
            'handler' => 'rpke_field_handler_applicant_chooser',
        ),
    );
}
</code>
field_assignee is custom CCK field add to entity based on node.
When I try to add this field to a view I am getting error:

Invalid column name 'field_applicant_target_id'.
Answer: You could checkout Editable Views which let's you create Views where the fields are editable directly. It works with Field API fields which it looks like your field is.
Comment: I need this to be done without additional contribute module, so I created custom solution but without hook_views_data_alter. It's too much pain to work with standard way solution in my case. Views sometimes really sucks...


devstack nova boot does not have --file parameter option?

Question: I wish to pass a file through to my instance, but there is no
 file option?  Even though documentation says that this should be available?
stack@openstack:/tmp$ nova boot --config-drive true --flavor 8755fc00-4c24-418d-a505-592c809108d9 --image 2ca99129-4b09-4a2a-a43d-b22c76dc4efc --file license=FGVM080000109836.lic --user-data cloudinitfile test
usage: nova [--version] [--debug] [--os-cache] [--timings]
        [--os-region-name <region-name>] [--service-type <service-type>]
        [--service-name <service-name>]
        [--os-endpoint-type <endpoint-type>]
        [--os-compute-api-version <compute-api-ver>]
        [--endpoint-override <bypass-url>] [--profile HMAC_KEY]
        [--insecure] [--os-cacert <ca-certificate>]
        [--os-cert <certificate>] [--os-key <key>] [--timeout <seconds>]
        [--os-auth-type <name>] [--os-auth-url OS_AUTH_URL]
        [--os-system-scope OS_SYSTEM_SCOPE] [--os-domain-id OS_DOMAIN_ID]
        [--os-domain-name OS_DOMAIN_NAME] [--os-project-id OS_PROJECT_ID]
        [--os-project-name OS_PROJECT_NAME]
        [--os-project-domain-id OS_PROJECT_DOMAIN_ID]
        [--os-project-domain-name OS_PROJECT_DOMAIN_NAME]
        [--os-trust-id OS_TRUST_ID]
        [--os-default-domain-id OS_DEFAULT_DOMAIN_ID]
        [--os-default-domain-name OS_DEFAULT_DOMAIN_NAME]
        [--os-user-id OS_USER_ID] [--os-username OS_USERNAME]
        [--os-user-domain-id OS_USER_DOMAIN_ID]
        [--os-user-domain-name OS_USER_DOMAIN_NAME]
        [--os-password OS_PASSWORD]
        <subcommand> ...
error: unrecognized arguments: --file test
Try 'nova help ' for more information.

Answer: Please check with alternative command using OpenStack CLI:
***openstack server create --image 2ca99129-4b09-4a2a-a43d-b22c76dc4efc --flavor 8755fc00-4c24-418d-a505-592c809108d9 --config-drive True   --file license=FGVM080000109836.lic --user-data cloudinitfile test***
Note:
  1. Please also check once the injected files quota.

Answer: Yes, --file option is there by which you can pass a file to your instance. You can check available optional parameter using "nova help command".
e.g:
nova help boot
usage: nova boot [--flavor <flavor>] [--image <image>]
                 [--image-with <key=value>] [--boot-volume <volume_id>]
                 [--snapshot <snapshot_id>] [--min-count <number>]
                 [--max-count <number>] [--meta <key=value>]
                 **[--file <dst-path=src-path>]** [--key-name <key-name>]
                 [--user-data <user-data>]
                 [--availability-zone <availability-zone>]
                 [--security-groups <security-groups>]
                 [--block-device-mapping <dev-name=mapping>]
                 [--block-device key1=value1[,key2=value2...]]
                 [--swap <swap_size>]
                 [--ephemeral size=<size>[,format=<format>]]
                 [--hint <key=value>]
                 [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid>]
                 [--config-drive <value>] [--poll] [--admin-pass <value>]
                 [--access-ip-v4 <value>] [--access-ip-v6 <value>]
                 <name>

Boot a new server.


How to create add custom style to specific view in drupal

Question: Please check this site
I am trying to create rounded corner rectangle on right hand side where products are listed. This is currently working because I modified view-view-grid.tpl.php. Doing this has changed everywhere wherever I was using grid. I want to add this style only to a particular view. How can I achieve this in views.  I also want to modify style of each category displayed within the box eg. Product category should be bold or some different color.
I am beginner so please let me know steps or some good references.
Answer: This is actually really easy with views. I am going to assume you are using Drupal 7 with Views 3. But this works almost the same in previous versions of both as well.
First, go into your view. On the far right expand the "Advanced" fieldset if it isn't already expanded. Then click on the "Information" link next to Theme at bottom of the list.
This will popup a modal that will display how to name your template files to replace the default template. It specifically allows you to modify different levels of the template. Find the level you want to modify. Then, while reading the list from left to right (right being the most specific) pick the name that is specific enough for your uses.
Next, go into the views module and find a copy of the bolded template file and copy that into your theme folder into a templates folder or into a custom module. Then give it the name you found above and make your changes.
Finally save it and flush the Drupal cache. Now when you go back to that information page it should show your new template file highlighted. This may require a few refreshes.
Now on another note, if you use the built-in field controls you can add custom CSS classes to help target the specific view and thus a specific button underneath it. You can also add specific classes to the view in the advanced section.
Though keep in mind drupal already gives us a ton of classes to each element, so you shouldn't need any of this just to target that view and a specific button within it.


How to break up user roles checkboxes into groups?

Question: When editing a user in Drupal 7 (/user/NID/edit), I'd like to break up the roles checkbox options. By default, it is just one list of roles. Instead, I would like to group different roles together to make it easier to read for the admins.
Ideally, there would be a group name header, followed by a certain subset of roles and then another head followed by another subset of roles, etc.
There is no change to the functionality of the roles.  This is purely a theming exercise.
Answer: One way to do this would be to use some JS to add a header element in front of the role that starts the group.  Each role has a unique id, e.g. input#edit-roles-2.  You could use some jQuery like:
$("input#edit-roles-2").before("
My Group
");

You would have to order the roles the way you want and find the right ids.
Also, this will probably require using a custom admin theme or a module in order to inject the JS since user editing generally uses that theme and not the main theme.
Comment: Worked.  Simple enough.  Was hoping for some snazzy module to do the trick, but jQuery worked fine.


Netbeans IDE: java.lang.UnsatisfiedLinkError: OBIDISC4J.dll: Can't find dependent libraries

Question: I am trying to execute a program related to UHF reader integration. The programming SDK (ID_ISC.SDK.Java-V4.7.0) has been given by the reader manufacturer (in my case, the reader is ID ISC.MRU102-USB reader by FEIG Electronic). When I tried running a sample project from this SDK, I got the following error:
<code>Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\OBID\OBIDISC4J.dll: Can't find dependent libraries
       at java.lang.ClassLoader$NativeLibrary.load(Native Method)
       at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
       at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
       at java.lang.Runtime.loadLibrary0(Runtime.java:870)
       at java.lang.System.loadLibrary(System.java:1122)
       at de.feig.FedmIscReader.<init>(Unknown Source)
       at ISOHostSample.ISOHostSample.<init>(ISOHostSample.java:41)
       at ISOHostSample.ISOHostSample.main(ISOHostSample.java:865)
</code>
I followed the instructions given in the readme file in SDK:
I have placed the required .dll files along with a .jar file (OBIDISC4J.jar) in OBID folder under Program Files and I have entered this path in Path environment variable.
The program is navigating to this path at runtime, but unable to pick up the jar library file from it, thus throwing the above exception.
Any help on resolving this would be greatly appreciated. Thank you
Answer: I've had some luck with the "depends.exe" Dependency Walker tool to learn specifically which dependent libraries it can't find. In the end it's usually because they're not on your classpath.
The DLLs need to be on your application's CLASSPATH, and that's not the same thing as the Path environment variable. Since the "src" folder is already on the classpath, what I usually do is create a "native\windows" or "native/linux" folder inside "src" and put all my .DLL or .SO libraries in there.
If placing the libaries inside the project folder is not an option for some reason, you can specify the classpath on the command line to java.exe: "java -classpath  -jar MyJar.jar"
Comment: I tried to open OBIDISC4J.dll with the depends.exe tool, but couldn't get anything out of it. It was showing some errors like system couldn't find the path specified. I tried placing all .dll files under src/native/windows folder, no luck there as well. I can't find out where exactly the problem lies.
Answer: I faced the same problem. My solution is copy all FEIG dlls to java bin path.
Comment: Welcome to SO. Please be a bit more specific. What files is OP supposed to copy from where to where?


finding the shape of the higher order equations

Question: Is there any way to find the shape of the higher-order equation like this one? I am more interested in making an initial guess about the shape (fast prediction) and then the process to find it. Any process or tool would be helpful.
$f(x) = x^2z^3 + 9/80 * y^2z^3  - (x^2 + 9/4 * y^2 + z^2 - 1)^3 $
I tried to plot it using wolframalpha but I am not succeeded.
Answer: You have a function
$$f(x, y, z) = x^2 z^3 + \frac{9}{80} y^2 z^3 - (x^2 + \frac{9}{4} y^2 + z^2 - 1)^3$$
This describes an implicit surface $f(x, y, z) = 0$.  There are a number of applications that can plot implicit surfaces (or more generally, isosurfaces $f(x, y, z) = c$).
In this particular case,
$$\begin{aligned}
f(x,y,z) & = 0 \\
x^2 z^3 + \frac{9}{80} y^2 z^3 - (x^2 + \frac{9}{4} y^2 + z^2 - 1)^3 & = 0 \\
z^3 ( x^2 + \frac{9}{80} y^2 ) & = (x^2 + \frac{9}{4} y^2 + z^2 - 1)^3 \\
z ( x^2 + \frac{9}{80} y^2 )^{1/3} & = x^2 + \frac{9}{4} y^2 + z^2 - 1 \\
z^2 - z ( x^2 + \frac{9}{80} y^2 )^{1/3} + 1 - x^2 - \frac{9}{4} y^2 & = 0 \\
\end{aligned}$$
which is a quadratic function in $z$, whose solution is
$$\begin{aligned}
z & = \left(\frac{9 y^2 + 80 x^2}{640}\right)^\frac{1}{3} \pm \frac{1}{640^\frac{1}{3}}\sqrt{ (9 y^2 + 80 x^2)^\frac{2}{3} - 2160^\frac{2}{3} y^2 - 640^\frac{2}{3} x^2 + 640^\frac{2}{3} } \\
~ & = \frac{1}{640^\frac{1}{3}} \left( (9 y^2 + 80 x^2)^\frac{1}{3} \pm \sqrt{ (9 y^2 + 80 x^2)^\frac{2}{3} - 2160^\frac{2}{3} y^2 - 640^\frac{2}{3} x^2 + 640^\frac{2}{3} } \right) \\
\end{aligned}$$
The shape is a 3D heart. The $+$ side contains the two bumps on top, and the $-$ side the conical bottom part.
Personally, I would use GNU Octave for this.  It is free, and available for Windows, macOS, Linux, and BSDs.
<code>function value = f (x, y, z);
    value = x**2 * z**3 + y**2 * z**3 * 9/80 - ( x**2 + y**2 * 9/4 + z**2 - 1)**3;
endfunction;
xrange = linspace(-1.6, +1.6, 64);
yrange = linspace(-1.6, +1.6, 64);
zrange = linspace(-1.6, +1.6, 64);
[x, y, z] = meshgrid(xrange, yrange, zrange);
v = arrayfun(@f, x, y, z); isosurface(v, 0); pbaspect([1, 1, 1]);
</code>
Comment: Thank you very much. You gave me the direction to explore. Your answer is super helpful.


New Guitar Learning Flamenco Techniques

Question: I planing to buy Alvarez AD60CE Dreadnought Electro Acoustic Guitar - Pau Ferro/Indian Laurel Fretboard for learning finger style playing techniques, will this guitar will serve my purpose ?
Comment: Possible duplicate of [Is it possible to learn Flamenco guitar on a steel-string guitar?  Will it sound right?](https://music.stackexchange.com/questions/2861/is-it-possible-to-learn-flamenco-guitar-on-a-steel-string-guitar-will-it-sound) Specific product recommendations are off-topic, but no, you need a nylon strung guitar for flamenco.
Answer: Flamenco and classical guitar is usually played on nylon strings.  The tension is different and the material is quite different.  It depends on what you mean by "flamenco techniques".  If you mean finger style arpeggiating chords, a lot of acoustic guitar players finger pick.  Even some electric players play finger style (Joe Pass for example).  However, I think you will have a hard time developing tremolo techniques and some other strumming techniques on the steel string acoustic.  Using your nails on the steel strings with force and speed may cause breakage.  If you try to learn finger style on any guitar it will be a specific finger style modified for that guitar.  The touch is so much different that you cannot, in my experience, just transfer skills from one to another.  But you can try, it may work for you.
Comment: For me, the end result of "nails & steel strings", is always "no nails & steel strings". I don't think I've ever tried "nails, tremolo & steel strings", but my guess would be that the end result would be the same, but just very, very, very much quicker.
Comment: @WillemvanRumpt, I agree.  Also the flamenco technique of Rasgueado I would think would just pop them off quick.
Comment: I use tremolo and rasgueado on steel strings and still have all my nails.
Comment: @Tim: Congratulations, you have some strong nails going on. From a few time steel strings, I'm usually able to recover with filing down the nails to a usable state. After that, it's "wait for the nails to grow" time.
Comment: @Tim, good for you, what's your secret?  Diet, exercise.  Mine are weak, they break easy.
Comment: Really not sure. Heard of the phrase 'hard as nails'?..
Comment: That's not the nail they are referencing
Answer: You can learn finger style playing techniques in any guitar, but to sound the way you want and to execute the technique correctly you need at least a guitar with nylon strings.
In any case, transporting knowledge from one guitar to another won't be difficult, but the touch and the space between the strings is different.
Also keep in mind that you cannot change the type of strings for which the guitar is prepared.
Comment: That last statement is a little too sweeping. It can be done, but sometimes there are risks. Others, none.

New Guitar Learning Flamenco Techniques


MS Graph get all values of a field

Question: In my app, the user should be able to choose a company, in which his article gets published.
The Azure Active Directory has the Company name for that, which is maintained by our AAD Team. Is there any way to request all values from this field? Like a SELECT DISTINCT in SQL?
Comment: `"Is there any way to request all values from this field?"` Which value do you mean? Its not clear by `all value` what exactly you are refering to?
Comment: Is the question related to SharePoint? Which Graph API endpoint do you call?
Comment: @user2250152 no it's not SP-related. I want all distinct values of the attribute companyName
Answer: AFAIK, currently there is no way to request all distinct values using companyName attribute.
You can use filter parameter by looping through each companyName.

Please note that Distinct is not supported in Microsoft graph API.

You can raise Azure Support ticket or feature request for the same by visiting below link:
Azure Support Options | Microsoft Azure
References:
Is there a way to query distinct user profile attribute values from the Graph API? For example $select=Distinct(jobTitle)? The scenario would be to build a "refinement" experience for a People Search experience. - Microsoft Q&A
Distinct values in Microsoft Graph query - Stack Overflow

MS Graph get all values of a field


Programador de Tarefas Windows

Question: Tenho uma duvida em relação ao programador de tarefas Windows
Tenho tudo a correr normalmente.
Abre o Browser e executa o codigo php.
Mas depois existe a possibilidade de no fim fechar essa mesma pagina sozinho?
Comment: Que tal um `window.close();` em JS mesmo?
Comment: No final do php?
Comment: Depois do PHP, abrir `` e colocar ``. Mas isso seria uma gambiarra, melhor fazer como o @perdeu respondeu.
Answer: Se precisa rodar um script php de forma automatica, chame ele pela linha de ao invés de invocar IE com o pagina/script desejado, assim você não se preocupa em fechar o navegador, quando o processamento acabar a janela do cmd será fechada.
Na sua bat o chame o php dessa forma:
php -f "C:\caminho_completo\script_automatico.php"

Para o comando ser reconhecido no terminal do DOS é necessário adicionar o caminho do executável do php à variável PATH do windows.
Isso pode ser feito atraves do atalho win-key+break/pause ou botão direito em (meu)computador > propriedades > configurações avançadas do sistema, guia avançado > variáveis de ambiente. Crie uma nova chamada PHP_HOME seu valor é a pasta onde está o .exe do php. Feito isso adicione o PHP_HOME ao PATH no final coloque: ;%PHP_HOME%;.
Para testar abra um novo cmd e digite php -v caso tudo esteja certo ele deve exibir a versão do php.
Comment: já consegui por a funcionar. Muito obrigado
Comment: Coloquei apenas no path C:\wamp\bin\php\php5.4.16
Comment: mas ao abrir assim funciona nos ficheiro email.php? E consigo colocar isso a correr todos os dias as 12h?
Comment: @ChrisAdler funciona corretamente, crie um arquivo .bat, com o conteudo acima e agende ela. O seu script não precisa de nenhum interação/resposta do usuário certo?
Comment: Eu coloquei: php -f "C:\wamp\www\pasta\emailteste.php"
aparece a janela cmd e fecha e nao acontece mais nada.
Comment: @ChrisAdler, então aconteceu algum erro, na adicione uma linha com o seguinte comando `pause` assim da para ver o que foi escrito.
Comment: Obrigado. erro: 'php' não é reconhecido como comando interno...
Comment: @ChrisAdler sabe dizer se existe uma variável de ambiente como caminho do php(executavel)? ela deve ser adicionda ao `PATH` windows. Você pode ver isso, apertando a tecla `windows + break` > `configurações avandaçadas do sistema` aba `avançado`.
Comment: Encontrei nas variaveis do sistema o PATH e depois tenho de seguir o caminho que aparece lá e adicionar? ou faço editar ? Nunca mexi nesta parte
Comment: @ChrisAdler o ideal é criar duas delas o `PHP_BIN` o valor dela sera algo como `c:\xampp\php\php.exe` e o `PHP_HOME` com o valor: `c:\xampp\php`. Depois de criadas as duas você precisa alterar a variável `PATH` no fina coloque `;%PHP_HOME%;%PHP_BIN%;` Para verificar se funcionou abra um novo cmd e digite `php -v`.
Comment: Tentei de varias maneiras ontem e hoje e continua a não dar. Não utilizo o Xampp mas sim o Wamp mas deve dar na mesma correcto?
Comment: Vamos [continuar esta discussão no bate-papo](http://chat.stackexchange.com/rooms/18799/discussion-between-perdeu-and-chrisadler).
Comment: @ChrisAdler, como você deixou o `PHP_HOME` e coloque o final do `PATH`
Comment: C:\wamp\bin\php\php5.4.16\php.exe . path: C:\Program (...);%PHP_HOME%;%PHP_BIN%;
Comment: @ChrisAdler é para ser isso mesmo. o PHP_HOME e PHP_BIN foram criadas em variáveis do sistema ou variáveis do usuário?
Comment: ambas em variáveis do sistema
Comment: @ChrisAdler, o que estava errado? que bom que resolveu.
Answer: Você pode fazer um evento chamando um batch, nesse batch você controla o comportamento:
taskkill /f /im chrome.exe >nul 2>nul

start "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" http://localhost/

taskkill /f /im chrome.exe >nul 2>nul

Answer: Quando quiser fechar a janela você pode fazer o seguinte:
echo "";

Mas dependendo de sua aplicação, a resposta do @perdeu seria melhor chamando o PHP na sua bat dessa forma:
php -f "C:\caminho_completo\script_automatico.php"

Pra fazer as chamadas ao sistema o PHP possui a função system(), leia a documentação :
string system (string $command [,int &$return_var])

Comment: Será apenas para enviar email.Mas como fiz tinha de fechar manualmente a pagina

Programador de Tarefas Windows


Shorthand to check value in array

Question: Is there a short way of doing this?
if ((isset($a['key']) && ($a['key'] == 'value')) {
  echo 'equal';
  // more code
}
else {
  echo 'not equal';
  // more code
}

I need to test lots of values on an array that can or cannot exist. I feel that this method is too verbose.
I could remove the isset() and mute the notices... but then I feel dirty.
Edit:
Answering Jack's question: "Could you give an example how you would test lots of values in an array?"
example:
if (isset($_GET['action']) && $_GET['action'] == 'view') {
  //code
}
if (isset($_GET['filter']) && $_GET['filter'] == 'name') {
  //code
}
if (isset($_GET['sort']) && $_GET['sort'] == 'up') {
  //code
}
if (isset($_GET['tag']) && $_GET['tag'] == 'sometag') {
  //code
}
etc...

Comment: The only shorter expression is one without the redundant parentheses :)
Comment: Imagine that there's more code inside. What I want to make shorter is the part inside the "if ()".
Comment: it is not that long or unreadable. this micro optimisation will lead you no where.
Comment: As it stands now, you shouldn't receive warnings from the interpreter (provided you remove that stray `(`). Are you?
Comment: Could you give an example how you would test lots of values in an array?
Comment: The best approach is to use a function. I don't see a reason not to use a function like "function isEqual($array, $key, $value){ //your condition}" or better practice in OOP to have a class that contains the array and that way you don't have to pass the array each time
Comment: Thanks for the example, updated my answer with something else to consider.
Comment: You can do that by a foreach loop. Would you like to have an insight of that ? Let me know if you are. I will write a demo for you.
Answer: For anyone still stumbling upon this question...
You could use PHP's coalescing operator:
if (($a['key'] ?? '') === 'value') {
  echo 'equal';
  // more code
}
else {
  echo 'not equal';
  // more code
}

See this question: using PHP's null coalescing operator on an array
Answer: I don't like to answer my own questions but I feel that the best and cleaner way to do this kind of checkings is to write a "helper funcion" like:
function iskeyval(&$a, $k, $v) {
  return isset($a['key']) && ($a['key'] == 'value');
}

and then:
if (iskeyval($a, 'key', 'value')) {
  ...
}
else {
  ...
}

Comment: You can always write a function around something, but afaict the question was whether the expression could be made shorter and it can't :) btw, you can use `(array $a, $k, $v)` as the argument list instead to let PHP check the argument type for you.
Answer: I have added comments to explain the code. Here is the code :
//this array maps the function with the get parameters
$functions = array (
"action" => "do_actions" ,
"filter" => "do_filters"
);

foreach ($_GET as $key=>$value) {
    //check if this field is corresponding functions or not
    if ( array_key_exists($key , $functions) ) {
        call_user_func($functions[$key] , $key,$value);
    }
}

function do_actions ($key , $value) {
    //place your code here to play with this value
    echo 'do_actions is called with ' . $key . 'and' . $value . "
";
}

function do_filters ($key , $value) {
    //place your code here to play with this value
    echo 'do_filters is called with ' . $key . ' and ' . $value .  "
";
}

?>

Comment: I don't want to execute a function for *Every* GET varibale.
Comment: Ah,sure . This is just a way of achieving the same result. One of the benefits i got this approach is it increases readability IMO.
Answer: $list = array(
0 => 'one',
1 => 'two',
2 => 'one',
3 => 'three',
4 => 'one',
);

if( @$list['xxx'] !== 'three')
    echo 'Not ';

echo 'Equal';

Suppress the error reporting.
Comment: Do not try this at home kids.

Shorthand to check value in array


How to create new markers into a Google map with click?

Question: I want to add a marker on click event and add it into exact location where user clicked on map.
Can't use any of the official examples which eventually return nothing.
My current module specific js code is as follows (just trying to build it step by step):
<code>(function ($) {
  Drupal.behaviors.gmapPage = {
    attach: function(context, settings) {

      // Get map object / instance
      var map = Drupal.gmap.getMap($('.gmap-gmap').attr('id'));

      // Is this available in some other way?
      console.log(map); // Prints Drupal.gmap.map, but map != Drupal.gmap.map

      google.maps.event.addListener(map, 'click', function (e) {
        console.log(e.latLng);
      });

    }
  };
})(jQuery);
</code>
Everything else is fine but cannot create any functionality for the map.
Such an easy development task which seems so unbelievably challenging...
And this is purely for the front-end /ui - this question isn't about how to save location, load them into map etc. back-end related.
UPDATE:
I've added following script just for testing purposes:
<code>(function ($) {
    Drupal.behaviors.gmapPage = {
        attach: function(context, settings) {

          // Get map object / instance
          var map = Drupal.gmap.getMap(settings.gmap.auto2map.id);
          // Following works although e is undefined
          // if 'ready' is changed to 'click' nothing happens
          map.bind('ready', function (e){
                console.log(e, 'map is ready');
          });

       }
    };
})(jQuery);
</code>
Answer: This is working example at my side please check here Demo
<code>function initCentraDistrictmap()
{
var mapOptions = {
zoom: 12,
center: new google.maps.LatLng(1.3050618171691895, 103.8240737915039),
mapTypeId: 'roadmap'
 };
    map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

google.maps.event.addListener(map, "click", function (event) {

var myLatLng = new google.maps.LatLng(event.latLng.lat(),event.latLng.lng());
var image = 'data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2246%22%20height%3D%2244%22%3E%0A%3Ccircle%20cx%3D%2223%22%20cy%3D%2222%22%20r%3D%2220%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%20fill%3D%22%23ff3019%22/%3E%0A%3Ctext%20transform%3D%22translate%2823%2025%29%22%20fill%3D%22%23fff%22%20style%3D%22font-family%3A%20Arial%2C%20sans-serif%3Bfont-weight%3Abold%3Btext-align%3Acenter%3B%22%20font-size%3D%2212%22%20text-anchor%3D%22middle%22%3ETesting%3C/text%3E%0A%3C/svg%3E';
var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image// baseURL + 'assets/drawsvg.svg'
  });
});
}
 $(document).ready(function(){
  initCentraDistrictmap();
 })
</code>
Comment: Hi, where's the click?
Comment: wait I am upding the code..
Comment: I will remove this link after 1 hour. Please check it.
Answer: Well, after a one days work I figured it out. Perhaps this could have been explained by Google maps module developer in 5 minutes and/or with a clear documentation.
Following script solved it:
<code>(function ($) {
Drupal.behaviors.gmapPage = {
    attach: function(context, settings) {
         // Get "some" map object: Drupal.gmap.getMap(settings.gmap.[id/key provided by module you use].id)
         var map = Drupal.gmap.getMap(settings.gmap.auto2map.id);
         // Bind it with ready function; did not work without it
         map.bind('ready', function(){
            // Now you can have the real map instance
            gMapInit = Drupal.gmap.getMap(settings.gmap.auto2map.id).map;
            // And no - it doesn't work if you change it in the beginning
            // e.g. var map = Drupal.gmap.getMap(settings.gmap.auto2map.id).map;
         });
      }
    };
})(jQuery);
</code>
I've got to admit that this is rather pointless work to do since everything could be documented.
Especially this kind of starting point developer documentation should be available.
Comment: Don't forget Drupal is open source - if you think the documentation should have an example like this, you can submit it
Comment: True :) However, this was just my experiment and I do not have knowledge whether this is the correct method. It's works but maybe it could be done easier way. Maybe I'll make a request to module author and hope to get response.


ScheduledExecutorService not creating concurrent threads

Question: I am trying to understand how ScheduledExecutorService works. I wrote this simple test:
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
    executorService.scheduleAtFixedRate(() -> {
      try {
        System.out.println("Test " + Thread.currentThread().getId());
        Thread.sleep(10000);
        System.out.println("End  " + Thread.currentThread().getId());
      } catch (Exception ex) {

      }
    }, 0, 100, TimeUnit.MILLISECONDS);

I see following printed on console:
Test 19
End  19
Test 19
End  19
Test 21
End  21

And so on. Shouldn't the executor schedule and start a new thread even before first thread ends? Why are threads started one after the other if core pool size is 10. shouldn't 10 threads run together.
Answer: A recurring task is non-overlapping, so the first invocation would need to finish before the next can start:

Successive executions of a task scheduled via scheduleAtFixedRate or scheduleWithFixedDelay do not overlap. While different executions may be performed by different threads, the effects of prior executions happen-before those of subsequent ones.

If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.

https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html#scheduleAtFixedRate-java.lang.Runnable-long-long-java.util.concurrent.TimeUnit-
Comment: Different tasks can still run concurrently.
Comment: Thanks, but what's the purpose of core pool then? Would it have any effect? @IronMan


How to solve Assertion Fail in GCC Compiler, C++

Question: Hello dudes and dudettes!
When I compile my C++ program on Ubuntu (a VirtualMachine in VirtualBox), which previously ran without errors under Windows, I get a segmentation fault.
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.38 assertion fail ../../bfd/reloc.c:8580
/home/rafael/projects/Send06/lib/x86-64//libstar-api.a(dwzh.o):fake:(.idata$2+0x0): dangerous relocation: collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.
make: *** [Makefile:382: Send06] Error 1

I understand what a segmentation fault is, but I do not comprehend how this could happen in an external library. The source code of the library is not available.
Steps I took:

Compiled a "Hello World!" program. --> no errors.
Enlarged the virtual RAM. --> no changes.

Can you help me? Thanks in advance.

System: Windows 10
VM: Ubuntu 22.04.01 LTS
IDE: Qt Creator 8
Compiler: gcc 11.2.0
Comment: It is triggering [this assertion](https://github.com/bminor/binutils-gdb/blob/binutils-2_38-branch/bfd/reloc.c#L8580). You can see prior in the function that `error_message` is supposed to be set if this line is reached. You can also see in the definition of `BFD_ASSERT` and in the source for `ld` that the assertions are reported and generation of a binary suppressed, but the linker does not stop on the assertion failure. As a consequence it continues execution and then tries to print a warning about the dangerous relocation with `error_message` a null pointer, causing the segmentation fault.
Comment: I would recommend trying this with an up-to-date version of binutils and if it still fails reporting it as a bug if you can reduce it to a useful bug report.
Comment: Does the command "ld -v" work in a terminal?
Comment: Maybe this: https://stackoverflow.com/questions/57051568/collect2-fatal-error-ld-terminated-with-signal-11-segmentation-fault
Comment: Can you compile other programs?
Comment: See also https://stackoverflow.com/questions/19532826/what-does-a-dangerous-relocation-error-mean
Comment: @JarMan Yes, it is possible. @Barmar I already looked at these questions and performed suggested solutions. @Girspoon Yes, it works and says: ```GNU ld (GNU Binutils for Ubuntu) 2.38```
Comment: This looks like an assertion failure internal to the linker. It may be a bug in the linker or your linker is broken in some way.
Answer: I confused a Linux with a Windows library!
The answer is quite simple. I had a folder with libraries with the ending xyz.lib and xyz.a. So I thought, .lib for Windows and .a for Linux. However, there was seperate distribution of libraries for Linux. Now everything works.
Thank you for your input!