Convertion Error

Question: I am trying to call a web service from Android client on the Magento Store.
I have good success till now but have little problem.
I want this array to be converted in to appropriate java Object.
$arrProducts = array(
array(
    "product_id" => "1",
    "qty" => 2
),
array(
    "sku" => "testSKU",
    "quantity" => 4
)
);
$resultCartProductAdd = $proxy->call($sessionId, "cart_product.add",
                                        array($shoppingCartId, $arrProducts));

The Above php code has been taken from here
What I have tried.
Object []addtocart=null;
Log.i("Product Id ", Utils.product_list.get(rowid).getp_Id());
Object[] productdetails1=new Object[]{Utils.product_list.get(rowid).getp_Id(),2};
//Object[] productdetails2=new Object[]{productdetails1};
Object param1[]=new Object[]{Utils.shoppingCartId,productdetails1};
Object param[]=new Object[]{Utils.sessionId,"cart_product.add",param1};
try {
    addtocart=(Object[])client.callEx("call", param);
} catch (XMLRPCException e) {
    e.printStackTrace();
}

But it results into error like the :
org.cws.magentoAnd.xmlrpc.XMLRPCFault: XMLRPC Fault: One item of products do not have identifier or sku [code 1022]
at org.cws.magentoAnd.xmlrpc.XMLRPCClient.callEx(XMLRPCClient.java:228)
at org.cws.magentoAnd.ProductModule.productdetails$CartFunctions.doInBackground(productdetails.java:245)
at org.cws.magentoAnd.ProductModule.productdetails$CartFunctions.doInBackground(productdetails.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
at java.lang.Thread.run(Thread.java:1019)

I would be happy if someone having dual knowledge of php and Java would help me to solve this Issue.
Comment: Can you share your wsdl, it will be helpful.
Comment: @sharadendusinha :View this. http://www.magentocommerce.com/wiki/doc/webservices-api/api/cart#cart_product.add
Actually i have not generated the wsdl,i am using the Magento's inbuilt methods.
Answer: If you check the stack trace you will see
>
 One item of products do not have identifier or sku
So the mapping for sku is not getting found. it is also obvious as to why the mapping is not getting found. As the php object is an associative array. The java counterpart for the same is Map.
Now if I was making RPC (WebService based) call using a library like ksoap I would use somthing like PropertyInfo(http://ksoap2.sourceforge.net/doc/api/org/ksoap2/serialization/PropertyInfo.html) to do the mapping between property name and its value. So it depends on the client side library that you are using.
In your code you are using
addtocart=(Object[])client.callEx("call", param);

It is not eveident from the code snippent as to what is the type of client, so I was not able to guess as to what is the library that you are using, but what ever the library try and look out for some utility classes on the lines PropertyInfo
Comment: Hey,,i am using XMLRPC library.Can you please help me to  sort it out the mapping for XMLRPC library?
Comment: Is there any way to associate the properties and its value ?
Comment: could you please give the name of the *.jar file that you are using there are number of libraries that are currently available now.
Comment: +1 for your help,,it was from there I got the idea..thanks..See the correct answer that I have posted here.Thanks once again.
Answer: Ok,getting some Ideas from @ sharadendu sinha's Answer, I have made a Associative Array like thing in Java that would get the required result.
The code is as below.
Map map = new HashMap();
map.put("product_id", 1);
map.put("quantity", 1);
Object[] productdetails1=new Object [] {map};
Object param1[]=new Object[]{Utils.shoppingCartId,productdetails1};
Object param[]=new Object[]{Utils.sessionId,"cart_product.add",param1};
try {
    Object addtocart=client.callEx("call", param);
    Log.i("Out Put of Adding", addtocart.toString());
} catch (XMLRPCException e) {
    e.printStackTrace();
}

Convertion Error


How can this triad from the song "Believe" be analyzed?

Question:
I heard this song "Believe" recently, and the Eb major chord stood out to me. The song is in E major, so I'm wondering how that Eb triad can be looked at. Even if it was spelt as a D# major triad, it still doesn't fit with the key of E or any of its modes.
Anyone have thoughts on how to analyze it? I know it's a doubly chromatic mediant (if considered a D# triad), but I don't know how else to look at it.
Comment: Sounds like it could be another tts - this time in place of A7 (IV7).
Comment: "corda con picante" (not a real term)
Answer: A curiously simple music effect.
Yes, I agree with you that thinking of it as a chromatic mediant gives it the most function. It should not be labeled as "Eb" but as you suggested, "D#". In context of E major, this would then make it a non-diatonic leading tone chord, but leaving it at that overlooks the chord's function:
The first line oscillates between "E" and "G#m". The latter chord is a iii and is diatonic to the key. Here's where the music gets interesting:
The 2nd line of music moves to "F#m". In context of E major, this chord is a ii and would normally serve as a predominant. However, its predominant function is delayed by an intervening chromatic mediant ("D#"). The move between these two chords is a mirror image from the first line. It is this relationship that makes the move functionally cohesive. Add to that that this non-sequitur chord happens on the line "dreams are calling", adding to the ethereal intent, making this chord move not only interesting but cohesive as well.


sftp server throws Permission denied (publickey)

Question: I'm setting up WordPress site on Apache server with SFTP enabled.
After configuring all the necessary in /etc/vsftpd.conf
I generated ssh keys with ssh-keygen -t rsa which produced private and public keys.
I can confirm sftp server is running by running systemctl status vsftpd:
● vsftpd.service - vsftpd FTP server
     Loaded: loaded (/lib/systemd/system/vsftpd.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-06-03 11:10:44 UTC; 1h 22min ago
   Main PID: 605 (vsftpd)
      Tasks: 1 (limit: 4713)
     Memory: 1.3M
     CGroup: /system.slice/vsftpd.service
             └─605 /usr/sbin/vsftpd /etc/vsftpd.conf

Jun 03 11:10:44 blog systemd[1]: Starting vsftpd FTP server...
Jun 03 11:10:44 blog systemd[1]: Started vsftpd FTP server.

sftp -vvv email@example.com returns:
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 19: Including file /etc/ssh/ssh_config.d/50-cloudimg-settings.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/50-cloudimg-settings.conf
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 127.0.0.1 is address
debug2: ssh_connect_direct
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 22.
debug1: Connection established.
debug1: identity file /home/mark/.ssh/id_rsa type 0
debug1: identity file /home/mark/.ssh/id_rsa-cert type -1
debug1: identity file /home/mark/.ssh/id_dsa type -1
debug1: identity file /home/mark/.ssh/id_dsa-cert type -1
debug1: identity file /home/mark/.ssh/id_ecdsa type -1
debug1: identity file /home/mark/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/mark/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/mark/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/mark/.ssh/id_ed25519 type -1
debug1: identity file /home/mark/.ssh/id_ed25519-cert type -1
debug1: identity file /home/mark/.ssh/id_ed25519_sk type -1
debug1: identity file /home/mark/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/mark/.ssh/id_xmss type -1
debug1: identity file /home/mark/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.2
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 127.0.0.1:22 as 'newftpuser'
debug3: hostkeys_foreach: reading file "/home/mark/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/mark/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 127.0.0.1
debug3: order_hostkeyalgs: prefer hostkeyalgs: email@example.com,firstname.lastname@example.com,firstname.lastname@example.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,email@example.com,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: firstname.lastname@example.com,email@example.com,email@example.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,email@example.com,firstname.lastname@example.com,firstname.lastname@example.com,email@example.com,firstname.lastname@example.com,firstname.lastname@example.com,firstname.lastname@example.com,ssh-ed25519,email@example.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: firstname.lastname@example.com,aes128-ctr,aes192-ctr,aes256-ctr,firstname.lastname@example.com,firstname.lastname@example.com
debug2: ciphers stoc: email@example.com,aes128-ctr,aes192-ctr,aes256-ctr,email@example.com,email@example.com
debug2: MACs ctos: firstname.lastname@example.com,email@example.com,email@example.com,email@example.com,email@example.com,firstname.lastname@example.com,firstname.lastname@example.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: firstname.lastname@example.com,firstname.lastname@example.com,email@example.com,firstname.lastname@example.com,firstname.lastname@example.com,email@example.com,email@example.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,email@example.com,zlib
debug2: compression stoc: none,email@example.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,firstname.lastname@example.com,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256
debug2: host key algorithms: rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: firstname.lastname@example.com,aes128-ctr,aes192-ctr,aes256-ctr,email@example.com,firstname.lastname@example.com
debug2: ciphers stoc: email@example.com,aes128-ctr,aes192-ctr,aes256-ctr,email@example.com,email@example.com
debug2: MACs ctos: firstname.lastname@example.com,firstname.lastname@example.com,email@example.com,email@example.com,email@example.com,firstname.lastname@example.com,email@example.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: email@example.com,email@example.com,firstname.lastname@example.com,firstname.lastname@example.com,email@example.com,email@example.com,email@example.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,email@example.com
debug2: compression stoc: none,email@example.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: email@example.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: email@example.com MAC: <implicit> compression: none
debug3: send packet: type 30
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug3: receive packet: type 31
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:VoKLp0efIZDYddCrvaGWGxEwjOm/lY8zmZP+7qvBmG0
debug3: hostkeys_foreach: reading file "/home/mark/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/mark/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from 127.0.0.1
debug1: Host '127.0.0.1' is known and matches the ECDSA host key.
debug1: Found key in /home/mark/.ssh/known_hosts:1
debug3: send packet: type 21
debug2: set_newkeys: mode 1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: receive packet: type 21
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/mark/.ssh/id_rsa RSA SHA256:QUf6bnT6YZ4Q5EWKbfGIo4iTVkb1yMb4MsuDqYe1nos
debug1: Will attempt key: /home/mark/.ssh/id_dsa
debug1: Will attempt key: /home/mark/.ssh/id_ecdsa
debug1: Will attempt key: /home/mark/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/mark/.ssh/id_ed25519
debug1: Will attempt key: /home/mark/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/mark/.ssh/id_xmss
debug2: pubkey_prepare: done
debug3: send packet: type 5
debug3: receive packet: type 7
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,firstname.lastname@example.com,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,firstname.lastname@example.com>
debug3: receive packet: type 6
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug3: send packet: type 50
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/mark/.ssh/id_rsa RSA SHA256:QUf6bnT6YZ4Q5EWKbfGIo4iTVkb1yMb4MsuDqYe1nos
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/mark/.ssh/id_dsa
debug3: no such identity: /home/mark/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/mark/.ssh/id_ecdsa
debug3: no such identity: /home/mark/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/mark/.ssh/id_ecdsa_sk
debug3: no such identity: /home/mark/.ssh/id_ecdsa_sk: No such file or directory
debug1: Trying private key: /home/mark/.ssh/id_ed25519
debug3: no such identity: /home/mark/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: /home/mark/.ssh/id_ed25519_sk
debug3: no such identity: /home/mark/.ssh/id_ed25519_sk: No such file or directory
debug1: Trying private key: /home/mark/.ssh/id_xmss
debug3: no such identity: /home/mark/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
firstname.lastname@example.com: Permission denied (publickey).
Connection closed.

ls .ssh:
authorized_keys  id_rsa  id_rsa.pub  known_hosts

I can tell from the output that it finds the ssh key OK but it can't work it.
It is the first time I'm experiencing this issue so I would be thankful
for any pointers.
output from /var/log/auth.log:
Jun  3 12:10:36 blog sudo:     mark : TTY=pts/0 ; PWD=/home/mark ; USER=root ; COMMAND=/usr/bin/systemctl status vsftpd
Jun  3 12:10:36 blog sudo: pam_unix(sudo:session): session opened for user root by mark(uid=0)
Jun  3 12:10:36 blog sudo: pam_unix(sudo:session): session closed for user root
Jun  3 12:17:01 blog CRON[2039]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun  3 12:17:01 blog CRON[2039]: pam_unix(cron:session): session closed for user root
Jun  3 12:20:58 blog sshd[2057]: Connection closed by authenticating user newftpuser 127.0.0.1 port 53342 [preauth]
Jun  3 12:21:06 blog sshd[2061]: Connection closed by authenticating user newftpuser 127.0.0.1 port 53344 [preauth]
Jun  3 12:32:06 blog sshd[2067]: error: kex_exchange_identification: read: Connection reset by peer
Jun  3 12:33:40 blog sudo:     mark : TTY=pts/0 ; PWD=/home/mark ; USER=root ; COMMAND=/usr/bin/systemctl status vsftpd
Jun  3 12:33:40 blog sudo: pam_unix(sudo:session): session opened for user root by mark(uid=0)
Jun  3 12:33:40 blog sudo: pam_unix(sudo:session): session closed for user root
Jun  3 12:39:01 blog CRON[2074]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun  3 12:39:01 blog CRON[2074]: pam_unix(cron:session): session closed for user root
Jun  3 12:55:31 blog sshd[2188]: error: kex_exchange_identification: Connection closed by remote host
Jun  3 12:55:31 blog sshd[2187]: error: kex_exchange_identification: Connection closed by remote host
Jun  3 12:55:31 blog sshd[2189]: error: kex_exchange_identification: Connection closed by remote host
Jun  3 12:55:38 blog sshd[2190]: error: kex_exchange_identification: Connection closed by remote host
Jun  3 13:00:35 blog sudo:     mark : TTY=pts/0 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/systemctl status sftp
Jun  3 13:00:35 blog sudo: pam_unix(sudo:session): session opened for user root by mark(uid=0)
Jun  3 13:00:35 blog sudo: pam_unix(sudo:session): session closed for user root
Jun  3 13:00:39 blog sudo:     mark : TTY=pts/0 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/systemctl status sftp-server
Jun  3 13:00:39 blog sudo: pam_unix(sudo:session): session opened for user root by mark(uid=0)
Jun  3 13:00:39 blog sudo: pam_unix(sudo:session): session closed for user root
Jun  3 13:00:47 blog sudo:     mark : TTY=pts/0 ; PWD=/etc ; USER=root ; COMMAND=/usr/bin/systemctl status vsftpd
Jun  3 13:00:47 blog sudo: pam_unix(sudo:session): session opened for user root by mark(uid=0)
Jun  3 13:00:47 blog sudo: pam_unix(sudo:session): session closed for user root
Jun  3 13:09:01 blog CRON[2300]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun  3 13:09:01 blog CRON[2300]: pam_unix(cron:session): session closed for user root
Jun  3 13:17:01 blog CRON[2310]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun  3 13:17:01 blog CRON[2310]: pam_unix(cron:session): session closed for user root
Jun  3 13:25:33 blog sshd[2315]: Invalid user deploy1 from 188.8.131.52 port 54748
Jun  3 13:25:33 blog sshd[2315]: Received disconnect from 22.214.171.124 port 54748:11: Bye Bye [preauth]
Jun  3 13:25:33 blog sshd[2315]: Disconnected from invalid user deploy1 126.96.36.199 port 54748 [preauth]
Jun  3 13:39:01 blog CRON[2371]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun  3 13:39:01 blog CRON[2371]: pam_unix(cron:session): session closed for user root
Jun  3 13:40:08 blog sshd[2466]: Invalid user db2inst from 188.8.131.52 port 54260
Jun  3 13:40:09 blog sshd[2466]: Received disconnect from 188.8.131.52 port 54260:11: Bye Bye [preauth]
Jun  3 13:40:09 blog sshd[2466]: Disconnected from invalid user db2inst 22.214.171.124 port 54260 [preauth]
Jun  3 13:45:07 blog sshd[2470]: Invalid user 6 from 188.8.131.52 port 46130
Jun  3 13:45:07 blog sshd[2470]: Received disconnect from 18.104.22.168 port 46130:11: Bye Bye [preauth]
Jun  3 13:45:07 blog sshd[2470]: Disconnected from invalid user 6 22.214.171.124 port 46130 [preauth]
Jun  3 13:48:40 blog sshd[2473]: Invalid user x-man from 220.127.116.11 port 56358
Jun  3 13:48:41 blog sshd[2473]: Received disconnect from 18.104.22.168 port 56358:11: Bye Bye [preauth]
Jun  3 13:48:41 blog sshd[2473]: Disconnected from invalid user x-man 188.8.131.52 port 56358 [preauth]
Jun  3 13:51:20 blog sshd[2476]: Invalid user gmod from 22.214.171.124 port 40424
Jun  3 13:51:20 blog sshd[2476]: Received disconnect from 18.104.22.168 port 40424:11: Bye Bye [preauth]
Jun  3 13:51:20 blog sshd[2476]: Disconnected from invalid user gmod 18.104.22.168 port 40424 [preauth]

Comment: Your user tried and failed to authenticate, and then disconnected. Check that user is actually allowed to log in with the key you are trying to use.
Comment: Why do you keep bringing up vsftpd? What does that have to do with anything?
Comment: You need to check the logs on the _server_.
Comment: If you mean the vsftpd server then there are no logs in `/var/log/` nor in `/etc`. Apache logs are clean.
Comment: You're trying to ssh, vsftpd is not involved in this. Check the system logs.
Comment: The most relevant error output I've found in `/var/log/auth.log`. It's added to the question. The output isn't hinting what is wrong though.
Comment: I figured it's not a bad idea to just explicitly tell `sftp` which key to use for authentication. There's a pem file in `/etc/ssl/private/vsftpd.pem` so I ran:
`sftp -i /etc/ssl/private/vsftpd.pem email@example.com` which gave me the same error. There's only one user stated in `/etc/vsftpd.user_list` and that is `newftpuser`
Answer: So, if your SFTP server is like mine you have to generate the key pair in Linux:
ssh-keygen -t rsa
and then convert the PUB key to PEM format with this:
ssh-keygen -e -f id_rsa.pub > id_rsa_pem.pub
and then import the PEM key on the SFTP server and attach to the account.


How do I set an OS X application bundle's working directory?

Question: Is there a key I can set in my application bundle to set what the working directory will be for the executable? It needs to be the <code>$BUNDLE</code>/Contents/MacOS directory (because of some library dependencies that do runtime loading that I can't easily modify).
I'm aware this can be done by wrapping with a script instead but I'd rather not.
Answer: No, there is not. However, you can just add an appropriate chdir() in your main() function before calling NSApplicationMain.


Criar banco e tabela com PHP PDO Mysql

Question: Boa tarde a todos, sou inciante em programação e estou com um problema, estou criando um sistema de cadastro web de lojas, criei uma pagina administrativa para cadastrar as lojas, nessa eu cadastro os dados da loja com nome tipo responsável e usuário e senha para acesso pois cada loja terá um acesso a sua área, agora o problema está sendo que quando crio a loja eu já crio um banco de dados para ela, até isso está ok porem eu quero criar a tabela de produtos ao criar o banco e não consigo, gostaria de saber se é possível criar a tabela logo depois de criar o banco?
estou usando PHP PDO e Mysql.
Desde já agradeço.
Comment: Pode ser que o banco ainda não esteja pronto, talvez você não consiga criar um logo após o outro.
Comment: o banco cria, mas a tabela não.
Comment: Karlos Fist bem-vindo!! Um post interessante e que irá lhe ajudar nas suas próximas perguntas. Exemplo minimo https://pt.stackoverflow.com/help/mcve  Como não fazer perguntas https://pt.meta.stackoverflow.com/questions/5483/manual-de-como-n%C3%83o-fazer-perguntas e esse também é interessante https://pt.meta.stackoverflow.com/questions/1078/como-e-por-que-aceitar-uma-resposta/1079#1079
Answer: Consegui resolver, o problema estava que quando eu criava o banco não tinha nenhum banco selecionado na conexão, então fiz um query selecionando o nome do banco que foi criado e ai ele cria a tabela dentro do banco novo.
Obrigado gente
Answer:
A sua resposta não responde a sua própria pergunta!!!

Sim é possível criar a tabela logo depois de criar o banco
try {
    $conn = new PDO("mysql:host=$servername", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "CREATE DATABASE IF NOT EXISTS lojaDB";
    $conn->exec($sql);
    $sql = "use lojaDB";
    $conn->exec($sql);
    $sql = "CREATE TABLE IF NOT EXISTS PRODUTOS (
                ID int(11) AUTO_INCREMENT PRIMARY KEY,
                produto varchar(30) NOT NULL)";
    $conn->exec($sql);
    echo "DB criado com sucesso";
}
catch(PDOException $e)
{
    echo $sql . "
" . $e->getMessage();
}

Criar banco e tabela com PHP PDO Mysql


Daily cron job send email Webform submissions file

Question: create an automatic excel extract of all requests and send it a specific email address every day.
How would I do this? Is there any existing Module to do this in Drupal 7?
Comment: I'm voting to close this question because it's asking for recommendations or suggestions on books, tools, modules, themes, distributions, tutorials, or other off-site resources.
Answer: You could create a view that shows the days submissions, use the data export module to convert it to excel, filter it by day (currrent day). Use rules module to send an email (not sure how to attach it, may need to send link). Not sure if this would work exactly how you need it.
Answer: There is a module for this: Webform Scheduled Export
From the project page:

Allows you to schedule a webform submission export to run at a set
  point in time and repeat on a daily, weekly or monthly basis. The
  exports use all the options available to Webform's "Download" tab and
  they're attached to the email sent to the configured users.


GetStream and activity feeds

Question: I have an existing notification feed, but I'm looking at possibly migrating over to GetStream.
Currently, I'm using Laravel Notifications, to notify users and other objects.
I currently have something like the following:
1) Users
2) Groups
3) Group Members
So, when I CRUD a group, I simply notify all members of the group and also the group ($group->notifications returns a collection), which works fine.
Looking through the GetStream docs though, it seems there is a concept of 'followers'.
Does this mean, that all members of a group need to be followers of each other to see all notifications?
What about other objects, like, retrieving a feed for a Group? Do i need another Group Type in the dashboard to save activities to?
So, If I Person A and Person B are members of Group 1, When Person A saves Group 1, I'd like Person A, to see something like:
You saved Group 1
and Person B will see:
Person A saved Group 1
When I view the Group page, I'd like to pull in the activities that have happened to that Group.
Is this possible?
Thanks
Answer:
Does this mean, that all members of a group need to be followers of each other to see all notifications?

Probably not. Stream allows you setup feed groups, following relationships, and use "targeting" to send activities to different feeds.
Based on the use case you described, you're probably best off with two Feed Groups, e.g. group and user_timeline. You can give each user their own user timeline feed and set it to follow other group feeds as appropriate.
When a user does something involving the group, an activity can be added to the group feed. This activity then propagates out to all users who follow the group.

What about other objects, like, retrieving a feed for a Group? Do i need another Group Type in the dashboard to save activities to?

You can always create multiple feed groups for a given app. The example with two groups is probably sufficient for your use case but you could go further with 3 groups...

user: User events posted to this feed. This feed will handle specific and non-group specific activities. If the activity relates to a group, the "to" field can be populated with the group feed name and this will cause the activities to be copied to that feed (and in turn propagated to it's followers).
user_timeline: Retrieved by users. Follows group feeds. User's may also follow another user's user_timeline feed in order to receive all events by that user (e.g. an asymmetrical follow like Twitter / or symmetrical follow like Facebook)
group: Receives user generated activities via the 'to' targetting. System/admin generated activities may also be add directly to the feed.

GetStream and activity feeds


What is the meaning of these BIND log messages?

Question: Please clarify for me the meaning of the following BIND messages in syslog, these are from a DNS resolver. Whilst I think I understand them, I don't know what all four mean, so I think it's best if someone will clarify for me:
<code>1.
Oct 14 18:36:34 resolver1 named[14958]: lame server resolving 'arrivatn.co.uk' (in 'arrivatn.co.uk'?): 22.214.171.124#53

2.
Oct 14 18:36:36 resolver1 named[14958]: unexpected RCODE (SERVFAIL) resolving '184.108.40.206.in-addr.arpa/PTR/IN': 126.96.36.199#53

3.
Oct 14 18:38:49 resolver1 named[14958]: unexpected RCODE (REFUSED) resolving 'internal-server.ournetwork.com/AAAA/IN': auth.dns.server.ip#53

4.
Oct 14 18:39:05 resolver1 named[14958]: client 188.8.131.52#42034: query (cache) 'image.sinajs.cn/A/IN' denied
</code>
Thank you.
Answer:
The nameserver it contacted was expected to be authoritative but isn't.
The nameserver responded with a SERVFAIL error code.
The nameserver responded with a REFUSED error code.
The client was denied access to read the cached response for that domain.

1-3 are issues with the configuration of the nameserver for the domains/zones in question, #4 is caused by your local security configuration restricting the (probably remote, unauthorized) from reading from your local query cache. (Reading said cache remotely may allow certain kinds of attacks, so generally speaking you don't allow this unless you're providing a recursive resolver.)
All of these errors are fairly normal, however, if your resolver is just for local use, and not also providing authoritative replies for a zone, you might consider changing the nameserver to only listen on localhost, or firewalling it from remote access. (This will prevent #4, and reduce your attack surface area.)
Comment: Whoops, I put 3 and 4 the wrong way round. Did you write your answers against the numbers so they are still in the correct order?
Comment: The answer here still matches up, I wrote based on the order, not the numbers.


Does the List-A matches include One day internationals

Question: I saw the profiles of Sachin, Ponting, Pietersen and some other international players.
All that stats shows that no. of their List-A matches are greater than no of their Odis,this only raised me the question,
"Does the List-A matches include One day internationals"
None of the players had their stats in list-A matches less than their ODI's stats.
The no. of their First-class matches and Twenty20 matches are greater than no of their Tests and T20I stats respectively.
Why?
Answer: To answer this in a simple way:

Tests -> 5 day games that a player plays for his/her national team.
ODIs -> 50 over games that a player plays for his/her national team.
T20Is -> 20 over games that a player plays for his/her national team.
First-class -> International test matches + Test matches in domestic leagues.
List A -> ODIs + 50 over games played in domestic leagues.
T20 -> T20Is + 20 over games played in domestic leagues.
Comment: +1,any references? then I'll accept it
Comment: "A player's first-class statistics include his performances in Test matches." http://en.wikipedia.org/wiki/First-class_cricket. Similarly, List A includes ODI stats and T20 includes T20I.
Comment: This is a bit overly simplistic. For example, [Canada vs Netherlands](http://www.espncricinfo.com/world-cricket-league-div2-2015/engine/match/812777.html) from January 2015 is not counted as a one-day international despite being a 50 over match between national teams.


jquery, button that sets a radio field before submitting

Question: I was trying to have a submitting button to set a radio input field before submitting the form. It sets correctly the check on the radio btn, but when it submits the form, it doesn't take the value of the radio field.
Here is some code I am using:
    $('.groupAttributeBtn').click(function(){
$(this).closest('.radioContainer').find('.attribute_radio').prop("checked", true);
    getProductAttribute();

    });

And the HTML is made of rows of a table with N buttons

Package 2 kg
<input type="radio" class="attribute_radio" name="weight" value="2" />

23

<button type="submit" name="Submit" class="exclusive btn btn-outline-inverse groupAttributeBtn">
Add to cart
</button>

Any suggestion? How can I have the radio correctly set and then the button submit THAT value?
It now takes the previously selected one.

I should probably mention that I am operating on the product.tpl template page of a Prestashop installation.
Comment: What is error ? Please see console of browser if there is any error ?
Comment: No error in console. It just performs the radio setting, but it doesn't submit the right value. It takes the previously selected one.
Comment: Where is submit code ?
Answer: <button type="button" name="Submit" class="exclusive btn btn-outline-inverse groupAttributeBtn">

use button type instead of submit
Comment: I have followed your suggestion and then put a $("#myform").submit(); but it still doesn't take the right value. Any idea?
Comment: submit refreshes the entire page so value of controls get lost.


Qt Create Qquickwindow with Qquickrendercontrol in another thread

Question: I'm developing an application based on qt quick that has 2 windows. One is the Gui and the other one is a non interactive window that receives data from Gui window and runs its own render loop.
The goal is for the non interactive window to not be interrupted by the main thread.
My main thread Gui is a Qquickwindow which loads qml.
My non interactive window is a Qquickwindow that has a rendertarget and a Qquickrendercontrol. According to the documentation there will be no native window created and I will have a render thread that will handle all the graphics commands and swap buffers to another window that does not receive any input (can't be interacted with)
My issue is that still needs to communicate with the Gui main thread and if the main thread is busy for some reason then there will be no updates to my render thread.
How can I create a Qquickwindow in another thread. Qquickwindow seems to set up some connects that fail if created in another thread, but there should be a way since there is no actual window being created that needs loop handler.
Comment: I'm thinking of doing a multiprocess architecture seems I don't think I cant do what I'm trying to do.
Comment: An alternative to multi-threading would be to have two separate processes and use inter-process communication - https://doc.qt.io/qt-6/ipc.html Edit: Just seen that's what you've just put. I think you could spin off a separate thread from the main window every time you want to process some data that may take a while to respond which would allow a single event loop to avoid locking up, but it somewhat complicates things.
Answer: I ended up doing a multiprocess. With QLocalSocket and QQLocalServer for communication. I also was able to share the texture created in the non interactive application ( D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX | D3D11_RESOURCE_MISC_SHARED_NTHANDLE) And opening in the interactive window to display a preview as well.


Altura de div utilizando float

Question: Preciso de ajuda a concluir uma parte da minha PAP, talvez uma das partes mais importantes, álbum fotográfico, só que ando com um grande problema em relação a divisões, opá, ando á roda devolta do erro e nada.
Eu tenho aqui um exemplo do meu código, mas o problema está explicito.
Eu não consigo fazer com que a div exterior aumente ao adicionar outras divs dentro.

div.gallery {
  margin: 5px;
  border: 1px solid #ccc;
  float: left;
  width: 180px;
}

div.gallery:hover {
  border: 1px solid #777;
}

div.gallery img {
  width: 100%;
  height: auto;
  /*Background color just for example*/
  background-color: yellow;
}

div.desc {
  padding: 15px;
  text-align: center;
  /*Background color just for example*/
  background-color: yellow;
}

ALBUM

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Comment: Possível duplicata de [Problema com float](https://pt.stackoverflow.com/questions/102274/problema-com-float)
Answer: Resolvido, basta adicionar float na div principal.

div.gallery {
  margin: 5px;
  border: 1px solid #ccc;
  float: left;
  width: 180px;
}

div.gallery:hover {
  border: 1px solid #777;
}

div.gallery img {
  width: 100%;
  height: auto;
  /*Background color just for example*/
  background-color: yellow;
}

div.desc {
  padding: 15px;
  text-align: center;
  /*Background color just for example*/
  background-color: yellow;
}

ALBUM

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Answer: Você pode resolver com o float: left;, como bem indicado pelo @MateusVeloso, ou,  se não quiser/puder fazer desta forma, com um overflow: auto;.

div.gallery {
  margin: 5px;
  border: 1px solid #ccc;
  float: left;
  width: 180px;
}

div.gallery:hover {
  border: 1px solid #777;
}

div.gallery img {
  width: 100%;
  height: auto;
  /*Background color just for example*/
  background-color: yellow;
}

div.desc {
  padding: 15px;
  text-align: center;
  /*Background color just for example*/
  background-color: yellow;
}

ALBUM

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Add a description of the image here

Altura de div utilizando float


After one semester piano course, continuing piano as a self-learner, but the music is unmotivating me. Any advice?

Question: Context:
I'm a second year physics & mathematics student, and I took a piano course last summer semester, and I loved it.
During the course, the instructor first introduced us the basic theory of music, and then directly gave us 31 different music and asked us to study them (of course, first she played each of them to us).
Before this course, the only experience with piano that I had was watching a couple tutorials, and trying to play some of those exercises.
Although the last a couple of them, particularly the 31th one, was relatively complex to us, they were really elegant, and I really want to play them. For example my favourite the last one

While taking this course, I was taking other courses and studying other things and I did not have much time to practice, but I still was able to play this music in 2 weeks (It was due in 5 weeks), and I really enjoyed.
Situation:
Right now, I can't take another piano course, and I still want to improve myself on piano, so I have talked with an experienced player in university, and she advised my to start with Beyer's piano books.
However, the problem is, in order to go and practice skills, I need to play child's song, or song that I really don't want to hear, which sucks the wish of playing piano out of me.
Question:
First of all, do you have any suggestion about what can I do about this ? I mean as long as I want to play and learn, the complexity is something that I can overcome (at least try) without killing my motivation, but I do not have a instructor to pick me those musics one by one, so what can I do in such situation ?
Note that, although the very reason I want to learn piano is for personal pleasure, I still want to learn the theory, and the concepts as a student who is trying to be a professional in this.
Comment: Note that anyone who really does want to be a professional would be a bit foolish to not take lessons from a qualified teacher.
Answer: Answer 1: When you go to the library to select a novel to take home and read, you browse the shelves, grab a volume that looks like a candidate, and read a bit of the beginning, or jump to a random page, to decide if you want to check it out to read at home.  Well, you can do this at a music shop.  Music shops have method books, collections, and sheet music arranged for easy browsing, and they sell electric keyboards, which are set up for people to try out.  Wander through the piano section.  Pick up various books that look interesting, and then sit down at one of the keyboards to play a bit from each book, to see what appeals to you.  Many of the books will have some sort of level number on the cover, so after you try a few, you'll have more of an idea which level to aim for in the browsing phase.
It might take several trips to the shop to find pieces or collections you fall in love with, but that's okay, music shops are very tolerant of this selection process.
Just make sure you don't always go at a time when someone is having a saxophone lesson just on the other side of a thin wall.  Then it would not be so much fun.
Answer 2: What if there are no music shops where you live?  Then you'll have to use the internet.  There are free scores and there are scores to buy which show you the first page as a preview.
If you find beginner books for children annoying, then you might google adult beginner.  Or try the word "intermediate."  Also, a lot depends on the style of music you like best.  Some people really enjoy Bartok Microcosmos.  Some people find it incredibly annoying.
(Bonus suggestion: I personally have never come across a Faber piano book I didn't like.)
Comment: This is great advice. I'm sure there will be some good specific recommendations made in this thread, but it's definitely worth pointing out that most music stores will have a sheet music section and will be very happy to let you try it out at a piano. I personally used to take great pleasure in going to a music store, spending a while playing very very expensive pianos, and then leaving buying a pennywhistle, a kazoo, a plectrum, a cleaning cloth etc. (something cheap anyway) The music store knew my game but never minded
Comment: Unfortunately, those kind of music shops are not around in Turkey, but thanks, it is a good advice.
Answer: Being a band member has always motivated me to practice more. It might work for you too!
You can start playing with a band and discover other genres. At first you might find yourself playing the same chords or progressions over and over again but it would introduce you to other aspects of making music. Such as harmony with other insturments and improvisation.
Considering your location, I can suggest you to use garaj.org to find other musicians.
Answer: I agree with the advice about getting a teacher - but do make sure that they have the same taste and values you do. You can only go so far by yourself on most instruments until late intermediate/advanced and until you have the theory and techniques. Just playing anything you can get your hands on is  well and good for awhile but eventually it will get very very frustrating.
Answer: If you truly wish to improve, you will have to find time for lessons - even if only once a month or some such schedule.  A teacher will be (one hopes!) aware of your capabilities and give you studies and tunes compatible with your level.
I'm a bit concerned that you find your interest lagging already.  In my experience, and the experience of most musicians I know, playing darn near anything is uplifting and motivating.  You may want to self-investigate just how strong or deep your commitment to piano really is.
Comment: I'm downvoting, and I don't do this very often.  I can remember as a teenager going laboriously through some piano music I found lying around.  It was above my level.  I enjoyed it nevertheless and it certainly didn't do me any harm.  Now, piano is not my primary instrument but I can get through simple piano accompaniments when my children are practicing, so they can hear what their solo sounds like with accompaniment.
Comment: This may have been downvoted on your premise that the OP is a musician. Taking a short course in music doesn't presume the student  is, or will become a musician. True, most of us agree that a teacher is the way to go, but that's not an option, as quoted. That apart, it doesn't address the OP's question.
Comment: @CarlWitthoft - Sorry I wasn't clear.  I've never had piano lessons.  I'm a big proponent of lessons in general, but I don't think they're *always* **essential**.  Also, lessons work best when the student is really interested and motivated.  Here's an analogy: most students learn calculus best as part of a course, with a teacher, homework, interaction with fellow students, etc.  But some people do fine, or even better, with self-study!  (Autodidact.)  Also: let's let OP's commitment grow over time in a natural way.  (If it were a string instrument, I would be more concerned about bad habits.)
Comment: Also note, there is PLENTY of music I would be extremely happy never to have to play again in my life -- and music I would be happy never to have to listen to.  Example: Ravel's Bolero.  Some people love that piece, I'm sure, but I emphatically do NOT find it uplifting.
Comment: @aparente001 so why are you downvoting when you apparently agree with my statements?
Comment: @aparente001  lessons are absolutely essential.  WIthout them, you are guaranteed to develop incorrect habits, poor body position, and other stuff that's incredibly difficult to "unlearn."  Without the live feedback you get from a teacher, you might never even learn that your meter is uneven, for example.
Comment: @CarlWitthoft - I absolutely agree with you for strings.  For piano I disagree.  And note that not everybody wants to become a concert pianist.  Sometimes people enjoy just exploring music for a little while every day for stress reduction.  Or accompanying a friend who likes to sing.  Perfect form is not needed on piano to be able to get this level of enjoyment.  Also, there is nothing to prevent OP from seeking lessons later on, as his or her interest grows.


Simple Recurrence Questions

Question: $r$ is a real number, define a recurrence relationship for $A_n$
$$A_0 = 1\\
A_n = r\cdot A_{n-1}$$
Question: What is the value of $A_4$

$4(A{n-1})$
$r^4$
$1$
$4r$

I've pretty much eliminated answer choice #4
Answer: For the first question:
You know that $a_0=1$ and that $a_n = ra_{n-1}$. Plugging in $n=1$ means that $a_1 = ra_{1-1}$. Can you now calculate $a_1$? You say that $A_4 = 4(A_n-1)$, but this is a bad answer. What, here, is the value of $n$? See, If you ask me "how old are you", and I answer $24 x + 23$, why is this answer wrong? Because I haven't told you what $x$ is, right? Same with this answer, you cannot say $A_4=4(A_n-1)$ if you don't tell me what $n$ is.
Comment: Okay so for #1 I think its just 1. For #2 I'm getting Tn=Tn−1+Tn−2. Does that look right?
Comment: Does $T_n = T_{n-1} + T_{n-2}$ hold for $n=6$? For #1, how can it just be $1$ if $a_1 = r\cdot a_0$? What is $a_0$, and if you plug in $a_0$, what is $a_1$?
Comment: I'm sorry I'm not following how to solve these... I don't understand this stuff at all. Mind showing a step by step
Comment: I *am* showing you step by step. Look, if I say that $x = 5 \cdot a$ and $a=10$, what is the value of $x$? You MUST know that. Once you have that, now you have the same problem: $a_1 = x = r\cdot a_{1-1}$, and $a_{1-1} = a_0 = 1$. What is the value of $x$ (and, therefore, the value of $a_1$?
Comment: I understood x = 5*a that was 50 obviously. lol :P I have no idea what your talking about though when your writing the next line.
Comment: OK, so, if $x = r\cdot y$ and $y = 1$, what is the value of $x$?
Comment: The value is: r
Comment: I think I get this, is the answer for #1: 4(An−1) and the answer for #2 1+Tn−2
Comment: You don't get it yet. Yes, the value is $r$. Now, if from $x=r\cdot y$ and $y=1$, you can know that $x=r$, look at this: $a_1 = r\cdot a_{1-1}$, and $a_0 = 1$. What is the value of $a_1$?
Comment: The value is: r
Comment: OK, now you know the value of $a_1$. Now, knowing that $a_n = r\cdot a_{n-1}$, what is the formula for $a_2$ and what is the value of $a_2$?
Comment: Maybe I should write out what I'm thinking. If A0 = 1 then A1 = r * 0 = 0 + r * 1 + r * 2 + r * 3 = 6r which isn't an option.
Comment: The value is: a2 = 2r
Comment: I'm not trolling this is an online homework assignment that is due tomorrow at 11pm and I don't understand what's going on at all.
Comment: No, the value of $a_2$ is not $2r$. See, the value of $a_1$ is $r$, as you already said. Now, what is the formula for $a_2$, if you know that $a_n = r\cdot a_{n-1}$?
Comment: Is it just r^4?
Comment: Can you justify why it would be $r^4$?
Comment: No, I can't. My only justification is because we've gone through the other 3 answers and you told me they were wrong. lol
Comment: OK, then answer my previous question. Knowing that $a_n=r\cdot a_{n-1}$, what is the formula for $a_2$? You asked me to guide you step by step, so that is what I am doing.
Comment: I don't understand how we even got a1... -facepalm-
Comment: OK, now do this: you know that $a_n = r\cdot a_{n-1}$. What do you get when you set $n=1$?
Comment: A1 = r*0 = 0...
Comment: ^That doesn't equal r...
Comment: Aaa, now I see your problem. No, $n-1$ is a SUBSCRIPT! $a_{0}$ does not mean $a\cdot 0$, it means $a_0$ as in "the 0-th" value of the sequence! This means that you have a sequence $a_0,a_1,a_2,a_3$ and so on. $a_n$ for $n=1$ is $a_1$, for example.
Comment: A0 = r * 1 = r (Okay I get that) Now what do I do with A1?
Comment: No, $a_0=1$, by definition.
Comment: I give up.. Math makes no sense.
Comment: The equation $a_n=r\cdot a_{n-1}$ means: "the $n$-th element of the sequence is equal to $r$ times the $n-1$-th element of the sequence." Do you understand that?
Comment: This question has gone on too long and we're getting nowhere... I edited out the other two question and I'm just gonna make a new thread for the remaining 2 questions...
Comment: I advise you to try and stick with me here, I think we may still get somewhere. Now: do you understand what $A_n = r\cdot A_{n-1}$ means? That it means that "the value of $A_n$, the $n$-th element of the sequence, is equal to $r$ times $A_{n-1}$, the $n-1$-th element"?
Comment: Yes I get that. Now what do I plugin for A1?
Comment: Well, $A_1$ is the first element of the sequence. This means it equals to $r$ times the zero-th element of the sequence. This means it equals to $r$ times $A_0$. You already know what $A_0$ is, right?
Comment: So An never increments? It's just the same thing 4 times in a row?
Comment: $A_n$ is a "general" expression. $A_n$ means "the $n$-th" value. It is like saying "the $n$-th largest country in the world". For $n=1$, this means "the largest country in the world", so Russia. For $n=2$, it means "the second largest", I presume that is Canada, and so on.
Comment: I believe you are mistaken. America is the largest country in the world sir.
Comment: Dude I'm giving up. I'm now resorting to trolling.
Comment: Try not to. Now, do you understand that from $A_n = r\cdot A_{n-1}$, if I insert $n=1$, I get the equation $A_1 = r\cdot A_0$?
Comment: If you give up, then delete your question. I will delete my answer, for the sake of clarity on the site.

Simple Recurrence Questions


fortran 2003 and pointers

Question: I am writing a Fortran program. The program implements some numerical methods. Program speed is very important. I decided to get rid of dynamic arrays (whether it speeds up the program?), and faced with the following problem. I have 3d arrays (NXxNYxNZ = MAX elements) where I know MAX, but I dont know NX/NY/NZ ratio. It can be like this : 1x1xNZ or like this 2xNYx1 , etc.
The solution I see - use pointers. Simplified 2D case:
program ptrtest
   parameter ( MAX = 50 )    ! I know this number on compile time.
   integer :: NX,NY          ! I will find this numbers on run time.
   real, target :: a(MAX)    ! Static Array
   real, pointer :: b(:,:)
   a = 5
   read(*,*) NX, NY          ! I get NX, NY (NX*NY == MAX)
   b (1:NX, 1:NY) => a       ! I can use b(:,:) <- this is my goal.
end program ptrtest

This example works, but i am afraid that such update slow down the real program where I am using even 5d arrays. Is it possible?
Comment: You don't show enough program to really comment (Are you working with a and b at the same time?  Are you immediately passing b to a subroutine?), but in general performance will be worse when working with variables that have the TARGET or POINTER attribute because certain optimisations may be prevented.  It will depend on specifics, but allocating an allocatable array of size (nx,ny) once is not likely to be that significant a performance hit relative to to something like the READ statement that populates nx and ny.
Comment: If you need an array with run-time determined dimensions, I recommend using an allocatable array rather than a pointer array, unless you also need an additional feature of pointer.  allocatables are safer.  Also, its best to solve your problem, then identify slow portions, rather than guess at the start.  Micro-optimizations rarely make much difference.  Selecting an efficient algorithm is important.
Comment: FWIW I concur with the other commentators.  But if you know `MAX` at compile-time but not, until run-time, `nx`,`ny`, and `nz` you can always use the tried-and-tested (for which understand 'old-fashioned') approach of using a 1D array (of `MAX` elements) and roll-your-own index arithmetic. If considering this approach give careful thought to @M.S.B.'s observations on optimisation.
Answer: You say that program speed is important, so old-style Fortran will give you the best:

allocate a 1D array of size MAX
pass is to a subroutine as well as NX,NY,and NZ. This will avoid the pointer
indirection that will give you a loss of performance (unlike C, the Fortran standard
assumes that subroutine array arguments don't overlap, see this post).

For example:

program noptrtest
   implicit none
   integer, parameter :: MAX = 50     ! I know this number on compile time.
   integer :: NX,NY          ! I will find this numbers on run time.
   real    :: a(MAX)         ! Static Array

   read(*,*) NX, NY          ! I get NX, NY (NX*NY == MAX)

   if (NX*NY /= MAX) then
     stop 'NX*NY /= MAX'
   endif
   call run(a,NX,NY)
end program noptrtest

subroutine run(b,NX,NY)
  integer :: NX,NY
  real    :: b(NX,NY)
  integer :: i,j

  do j=1,NY
    do i=1,NX
      ! use b(i,j) here
    enddo
  enddo
end

If performance really matters here are some other useful tricks:

Tell your compiler to align the arrays on a 32-byte boundary (with ifort, use the !DIR$ ATTRIBUTES ALIGN : 32 directive
Dimension physically your 2D array such that the size of leading dimension is a multiple of 32-bytes. For real*4, you need a multiple of 8 elements.
Tell the compiler that each column is properly aligned using the !DIR$ VECTOR ALIGNED directive

For example:
program noptrtest
   implicit none
   integer, parameter :: real_kind = 4
   integer, parameter :: MAX = 50               ! I know this number on compile time.
   integer, parameter :: MAXDIM = MAX*(32/real_kind)    ! Max possible dimension required
   integer            :: NX,NY, NX_MOD         ! I will find this numbers on run time.
   real(real_kind)    :: a(MAXDIM)             ! Static Array

   !DIR$ ATTRIBUTES ALIGN : 32 :: a

   read(*,*) NX, NY          ! I get NX, NY (NX*NY == MAX)

   if (NX*NY /= MAX) then
     stop 'NX*NY /= MAX'
   endif

   if (mod(NX,real_kind) == 0) then
     NX_MOD = NX
   else
     NX_MOD = ((NX/real_kind)+1)*real_kind
   endif

   call run(a,NX_MOD,NX,NY)
end program noptrtest

subroutine run(b,NX_MOD,NX,NY)
  integer :: NX_MOD,NX,NY
  real    :: b(NX_MOD,NY)
  integer :: i,j

  do j=1,NY
    !DIR$ VECTOR ALIGNED
    do i=1,NX
    ! use b(i,j) here
    enddo
  enddo
end

Edit
This old-style Fortran trick avoids pointer aliasing.
References on pointer aliasing:

http://en.wikipedia.org/wiki/Aliasing_(computing) , section "Conflicts with optimization"
gcc C/C++ assume no pointer aliasing
Performance impact of -fno-strict-aliasing
http://scc.qibebt.cas.cn/docs/compiler/intel/11.1/Intel%20C++%20Compiler%20for%20Linux/main_cls/optaps/common/optaps_perf_run.htm
Comment: *so old-style Fortran will give you the best*  Show us the numbers; without data this 'answer' is an opinion.
Comment: It's not an opinion.Look at the -fno-alias option of C compilers for more explanations. As I said : "(unlike C, the Fortran standard assumes that subroutine array arguments don't overlap)". Pointer aliasing is a well known problem for compilers, and it was not present in Fortran before they introduced pointers. See
Comment: I too would like to see some actual numbers.

fortran 2003 and pointers


How do I use absolute URLs?

Question: I created a view for node titles only. I have inserted this view in simplenews newsletter using the Insert view module. The node title in newsletter emails are relative and broken. How do I configure my view so that absolute URls are used?
Answer: 1. Add Content: Link to Content field to your View . Your view fields will look as shown below.

2. Make sure that your Title field is outputted as plain text. In the Content:Title field settings uncheck the checkbox "Link to the Content". This is done because you'll use plain title text as a token for the link text. Exclude Title field from display, as it will be displayed later as an absolute link text.

3. Create settings for the absolute link output in Content: Link to Content field settings.
Open REWRITE RESULTS fieldset in Content: Link to Content field settings and check the following boxes:
✓ Override the output of this field with custom text (set {{ title }} as text)
✓ Output this field as a custom link
✓ Use absolute path

How do I use absolute URLs?


4-dimensional object with 5 vertices enclosing the origin

Question: A triangle is a 2-dimensional shape with 3 vertices that may be positioned to enclose the origin.
A triangular pyramid is a 3-dimensional shape with 4 vertices that may be positioned to enclose the origin.
What convex regular shape do we get in the 4-dimensional case?
What four points $(a, b, c, d) \in \Bbb R^4$ could serve along with $(1, 0, 0, 0)$ as vertices for this shape so that its center is the origin?
Thanks very much for your help!
Answer: It's called a simplex. A triangle with vertices $(1,0)$ $(0,1)$ and $(-1, -1)$ would work. A tetrahedron with $(1,0,0)$ $(0,1,0)$ $(0,0,1)$ and $(-1,-1,-1)$ would work. By extension, what coordinates could you choose in 4-space?
Update:
Let's construct a regular simplex with side length 1 and centroid at the origin, $O_n$. The subscript on $O$ will denote how many dimensions we are working in. We'll be a bit pedantic at the beginning, but this will prove useful when we extend into higher dimensions.
In 1 dimension, we have the points $(\pm\frac12)$, call them $A$ and $B$. Note that $AO_1:AB=1:2$.
To extend this into a triangle in 2 dimensions, let's shift these points down a bit on the $y$-axis and add a third point $C$ on the positive $y$-axis. It is a property of equilateral triangles that $AO_2:AB=2:3$, where $O_2$ is the centroid. So we need to shift our existing points (including $O_1$) down $\frac13$ the height of the triangle, and add our third point $\frac23$ the height of the triangle up the $y$-axis.
To find the height of the triangle, we look at right triangle $AO_1C$, and by Pythagoras, $O_1C=\sqrt{1^2-(\frac12)^2}=\frac{\sqrt3}2$. Dividing this by 3 gives $\frac{\sqrt3}6=\frac1{2\sqrt3}$, and multiplying by 2 gives $\frac{\sqrt3}3=\frac1{\sqrt3}$. So our triangle $ABC$ has the points $(\pm\frac12,-\frac1{2\sqrt3})$, $(0,\frac1{\sqrt3})$.
Continuing, we find the height of the corresponding tetrahedron by using right triangle $AO_2D$. $O_2D=\sqrt{1-(\frac1{\sqrt3})^2}=\sqrt\frac23$. We will have $AO_3:AD=3:4$, so we shift our triangle down on the $z$-axis by $\frac{\sqrt\frac23}4=\frac1{2\sqrt6}$, and add the new point $D$ at $\frac3{2\sqrt6}=\frac{\sqrt3}{2\sqrt2}$ on the $z$-axis. The points are now $(\pm\frac12,-\frac1{2\sqrt3},-\frac1{2\sqrt6})$, $(0, \frac1{\sqrt3},-\frac1{2\sqrt6})$, $(0,0,\frac{\sqrt3}{2\sqrt2})$.
The same pattern extends into 4 dimensions. We find the height of the 4-simplex by using right triangle $AO_3E$. The same technique gives $O_3E=\sqrt{1-(\frac{\sqrt3}{2\sqrt2})^2}=\sqrt\frac58$. We will have $AO_4:AB=4:5$. We shift the tetrahedron down on the $4^{th}$ axis by $\frac{\sqrt\frac58}5=\frac1{\sqrt{40}}=\frac1{2\sqrt{10}}$, and add the new point $E$ at $\frac4{2\sqrt{10}}=\sqrt\frac25$.
This gives our 5 points as:
$$(\pm\frac12,-\frac1{2\sqrt3},-\frac1{2\sqrt6},-\frac1{2\sqrt{10}})$$ $$(\hspace{8pt}0\hspace{8pt},\hspace{8pt}\frac1{\sqrt3}\hspace{6pt},-\frac1{2\sqrt6},-\frac1{2\sqrt{10}})$$ $$(\hspace{8pt}0\hspace{8pt},\hspace{13pt}0\hspace{14pt},\hspace{5pt}\frac{\sqrt3}{2\sqrt2}\hspace{5pt},-\frac1{2\sqrt{10}})$$ $$(\hspace{8pt}0\hspace{8pt},\hspace{13pt}0\hspace{14pt},\hspace{14pt}0\hspace{14pt},\hspace{9pt}\sqrt\frac25\hspace{9pt})$$
This is with fully reduced fractions everywhere, and we see patterns everywhere except on the diagonal. However, if we rationalize the denominators on the diagonal...
$$(\pm\frac12,-\frac1{2\sqrt3},-\frac1{2\sqrt6},-\frac1{2\sqrt{10}})$$ $$(\hspace{8pt}0\hspace{8pt},\hspace{8pt}\frac{\sqrt3}3\hspace{6pt},-\frac1{2\sqrt6},-\frac1{2\sqrt{10}})$$ $$(\hspace{8pt}0\hspace{8pt},\hspace{13pt}0\hspace{14pt},\hspace{7pt}\frac{\sqrt6}4\hspace{7pt},-\frac1{2\sqrt{10}})$$ $$(\hspace{8pt}0\hspace{8pt},\hspace{13pt}0\hspace{14pt},\hspace{14pt}0\hspace{14pt},\hspace{7pt}\frac{\sqrt{10}}5\hspace{8pt})$$
Triangular numbers everywhere! In 5 dimensions, the $5^{th}$ coordinate for these points will be $-\frac1{2\sqrt{15}}$, and point $F$ will be at $(0,0,0,0,\frac{\sqrt{15}}6)$. Note also how $\pm\frac12$ fits both patterns.
Comment: I'll try and figure it out intuitively using your method, Zook, and if that fails, I'll use the formulaic method provided by Ross.
Comment: Thanks, I see the pattern.  Do you know how to construct a regular shape satisfying these properties?
Comment: That is trickier, but let's try it the same way. Can you do it for the triangle case?
Comment: Yes.  Consider $\Bbb C = \Bbb R^2$ and take the third roots of unity.
Comment: Sure, can you extend it to a tetrahedron?
Comment: You can see [Wikipedia](http://en.wikipedia.org/wiki/Simplex#Cartesian_coordinates_for_regular_n-dimensional_simplex_in_Rn) to get the vertices of a regular simplex.  Now if you average all the corners you find a point within it, so translate that to the origin
Comment: Come on Ross, let him solve it, he's close.
Comment: I had a peek at the answer Ross gave.  That's what I was looking for!  Thank you both.
Comment: You will learn more and get more enjoyment out of it if you try to derive an answer on your own, by figuring the tetrahedron case and extending it. Hint: the ratio of the height of a regular triangle to the distance from a vertex to its centroid is 3:2.
Comment: @Zook:  Sorry, I hadn't seen you were working on that.  It isn't so obvious to me how to easily get a regular one in higher dimensions.  I wanted to put the $n$ simplex into the all positive corner of $n+1$ space, but that becomes a mess quickly.
Comment: All good, if he actually cares about it he will continue to try. I would drop the triangle he just constructed down a bit on the $z$-axis and stick another point on the positive $z$-axis, knowing that the same ratio given in my last comment is 4:3 for the tetrahedron case, and scale accordingly.
Comment: Roots of unity are a good start, however I would scale it so your side length is 1, that way you don't have to keep changing coordinates in higher dimensions. You'll want to use Pythagoras to find the heights
Comment: Alright so I've just solved this, and there is a really cool pattern in the coordinates. How's it coming on your end?
Comment: I have an answer.  It involves a lot of square roots and it'll take a while to type out in TeX.
Comment: Check out my update :)
Comment: Very nice @Zook!
Answer: $$\left({1, 0, 0, 0}\right)$$
$$\left( {-\frac{1}{4}, \sqrt{\frac{15}{16}}, 0, 0} \right)$$
$$\left({-\frac{1}{4}, -\sqrt{\frac{5}{48}}, \sqrt{\frac{5}{6}}, 0}\right)$$
$$\left({-\frac{1}{4}, -\sqrt{\frac{5}{48}}, -\sqrt{\frac{5}{24}},-\sqrt{\frac{5}{8}}}\right)$$
$$\left({-\frac{1}{4}, -\sqrt{\frac{5}{48}}, -\sqrt{\frac{5}{24}},\sqrt{\frac{5}{8}}}\right)$$
Comment: That's good, Wolfram alpha confirms the distance between all points is $\sqrt\frac52$. I'll write mine up tomorrow and show you the pattern I found.


Print statement with for loop and if statement

Question: I need to determine whether or not a user input is numeric. I need to loop over each characters and check if all are digits, if not printf() Error message, or else Successful. I used a for loop to loop over each characters and an if statement with isdigit() function to check the digit. But my problem is I am printing for each characters. For example, if I enter 22A, I get 2 Successful messages for 2 and 2, and then I get Error message for A. But I need just print the error message since 22A is not entirely numeric.
    int n = strlen(argv[1]);
    for (int i=0; i<n; i++){
        if (isdigit((int)argv[1][i]) == 0){
            printf("Error\n");
            return 1;
        }
        else{
            printf("Success\n");
            printf("%i\n", atoi(argv[1]));
        }
    }

Comment: @bruno: (a) `atol` will not do the job of determining whether a string is numeric. It accepts an initial numeric portion and provides no indication of whether that is the entire string or not. (b) Even if it did, it fails to meet a stated requirement: "I need to loop over each…" The goal is not merely to convert a string to a number but to perform an exercise, likely for a class in which in the OP is a student. Calling a library routine fails to teach how to use the control structures being taught.
Comment: You are printing "Success" inside the loop, so it is still just a partial success.
Comment: @EricPostpischil I wanted to say **strtol**, is not the first time I do that error damned
Comment: You don't want to print "Success" until after you've examined *all* the characters in the string, meaning you want to want until *after* the loop has finished.
Comment: When you say *numeric* are you restricting this to just digits, or are you allowed a prefixed `-`, a decimal separator, and possibly even thousands separators? Then there's scientific notation to worry about. Do please clarify, then it's answerable.
Comment: @Bathsheba: "I need to loop over each characters and check if all are digits".
Comment: @EricPostpischil: But on the other hand "I need to determine whether or not a user input is numeric." I read the second sentence as an implementation technique.
Answer: If you could use another way, you could use strspn() from string.h.
size_t n = strlen(argv[1]);
if(strspn(argv[1], "0123456789")==n)
{
    printf("Success\n");
}
else
{
    printf("Error\n");
}

strspn() returns the number of bytes in the initial segment of the first argument string which consist only of bytes f
rom the second argument string, which in this case are the numbers.
So, if the value returned by strspn() is same as the length of the string, the string has no non-digit characters.

strlen() returns not exactly an int. It is a size_t. It is better to use the latter instead. See strlen to return size_t?.


appassembler-maven-plugin JSW - How to set wrapper-java-mainclass

Question: i try to use the appassembler-maven-plugin to ease the use of the Java-Service-Wrapper
My Setup is as follows:

implemented a class MyServiceWrapper which extends WrapperListner from JSW to have full access to the start/stop/controlEvent-methods
added the appassembler-maven-plugin to my pom.xml and configured JSW

MyServiceWrapper:
package aaa.bbb.ccc;
import org.tanukisoftware.wrapper.WrapperListener;
import org.tanukisoftware.wrapper.WrapperManager;

public class MyServiceWrapper implements WrapperListener {

    @Override
    public void controlEvent(int arg0) {
    }

    @Override
    public Integer start(String[] arg0) {
        return null;
    }

    @Override
    public int stop(int exitCode) {
        return exitCode;
    }

    public static void main(String[] args) {
        WrapperManager.start(new MyServiceWrapper(), args);
    }
}

appassembler-maven-plugin in my pom.xml:
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>appassembler-maven-plugin</artifactId>
    <version>1.3.1</version>
    <executions>
      <execution>
        <id>generate-jsw-scripts</id>
        <phase>package</phase>
        <goals>
          <goal>generate-daemons</goal>
        </goals>
        <configuration>

          <daemons>
            <daemon>
              <id>MyServiceWrapper</id>
              <mainClass>aaa.bbb.ccc.MyServiceWrapper</mainClass>
              <platforms>
                <platform>jsw</platform>
              </platforms>
            </daemon>
          </daemons>
          <target>${project.build.directory}/appassembler</target>
        </configuration>
      </execution>
    </executions>
  </plugin>

This generates the wrapper.conf and a lot of other files! But there is one line which is wrong and i don't know how to generate it correctly.
The wrong line is:
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

and it should be:
wrapper.java.mainclass=aaa.bbb.ccc.MyServiceWrapper

If i manually set this line to the correct mentioned line it works!
So: is there any way to generate this line correctly?
PS:
Is it possible to set the log-level of the JSW from inside the pom.xml?
Answer: appassembler is by default using integration method #1, where the (i.e. your) 'main class' is actually the first parameter to the WrapperSimpleApp class. That's why your mainclass is getting mapped to wrapper.app.parameter.1, and not wrapper.java.mainclass...
In most cases you don't need to generate your own implementation of WrapperListener interface and sticking to integration method#1 will be working most of the time....
If you really want to use integration method#3, i.e. provide your own WrapperListener implementation, you have to add the following into your pom.xml:
                 <property>
                  <name>wrapper.java.mainclass</name>
                  <value>my.WrapperListenerImpl</value>
                </property>
                <property>
                  <name>wrapper.logfile.loglevel</name>
                  <value>DEBUG</value>
                </property>

Full example can be found >here<
This will add or overwrite existing configuration properties... you can use that also for the loglevel ;)


Let $a_1/b_1,...,a_n/b_n\in (\alpha,\beta)\subset\mathbb{R}$ and $b_1,...,b_n>0$. Prove that $\dfrac{(a_1+...+a_n)}{(b_1+...+b_n)}\in (\alpha,\beta)$

Question: I tried to prove that $\frac{a_1+a_2}{b_1+b_2}$ is limited by some $(a,b)\subset(\alpha,\beta)$ but i can't conclude.
Answer:
Proposition. Let $\frac{a_i}{b_i} \in (\alpha,\beta)$ and $t_i,b_i>0$ ($i=1,...,n$), then
$$\frac{t_1a_1 + \cdots + t_na_n}{t_1b_1 + \cdots + t_nb_n} \in (\alpha,\beta).$$

Sketch of the proof. For each $i$,
$$\alpha < \frac{t_ia_i}{t_ib_i} < \beta.$$
Since $t_ib_i > 0$, we get
$$\alpha t_ib_i < t_ia_i < \beta t_ib_i.$$
Now apply the $\sum_1^n$ on the previous inequality. Then I think you can conclude by taking $t_i = 1$.
Answer: I think what you meant to ask is to show that the ratio of the sums belongs to $(\alpha,\beta)$ as well. And this is true, since you can write the ratio of the sums as a convex linear combination of the individual ratios.
Comment: Yeah, it's in $(\alpha,\beta)$, i make a mistake and put $\mathbb{R}$ instead $(\alpha,\beta)$ in the end of question.
Comment: Do you understand my answer? (See here https://en.wikipedia.org/wiki/Convex_combination)
Comment: Yes, thanks for the help, i had not thought on that way to prove this proposition.


Closed balls in metric space with trivial metric

Question: The problem is this: let two balls closed be in the metric space $(\Bbb{R},d)$ with the trivial metric, show that if the two balls intersect, then one is included in the other.
I conclude that both balls are equal, and therefore one is included in the other, but I'm not sure how to show it.
Comment: What is a trivial metric? And is $IR$ a notation for irrationals?
Comment: I think $IR $ stands for $\Bbb R$
Answer: In the trivial metric, the ball $B_r (x) $ of radius $r $ centered at $x $ is  $$B_r (x)=\begin{cases}\{x\},&\ r <1\\ \ \\ \mathbb R,&\ r\geq1\end {cases} $$ If you now consider the nonempty  intersection $B_r (x) $ and $B_s (y) $:  either at least one of them is $\mathbb R $, in which case the inclusion is obvious, or they are $\{x\}$ and $\{y\}$, so equal.
Answer: Hint: Show there are two types of balls, the space itself and sets containing exactly one element.


Basic Schubert calculus intuition

Question: I'm thinking about the famous problem from classical algebraic geometry of how many lines in $\mathbb{P}^3$ meet four given general lines. According to some lecture notes on intersection theory that I was reading, Schubert had the intuition that it's general enough to consider the case where the four lines are in fact two pairs of intersecting lines - a highly nongeneric setup. (And then of course, in this case the answer is easily seen to be two.)
My question is, can someone give a basic explanation of this intuition, and perhaps some explanation of which other scenarios admit this sort of logic (i.e. looking at non-generic-but-still-kind-of-generic cases)? I have a vague picture in my head of continuously varying one of the four lines and how a line meeting all four should vary continuously, but I'm not entirely convinced by it yet.
Thanks! (Also thanks to Michael Joyce for pointing me to this sort of problem in a previous answer.)
Comment: What are you familiar with? My intuition behind this is that this corresponds to intersection theory on the Grassmannian, which is projective, and the dimension of the Grassmannian is 4, so as long as the setup ends with a finite number of lines satisfying the given conditions, that will be "the correct number".

More concretely, this corresponds to some kind of "moving lemma": If you move a line to intersect another line in a way so that the setup never degenerates, there is a kind of "continuity" that keeps the number the same. But this is unclear to me without Grassmannians.
Comment: So you seem to be saying that in (projective) intersection theory problems, shifting around the setup may change the dimension of the space we're looking at (in this case, lines meeting the four given lines), but should never change the number of irreducible components? This sounds somewhat plausible. (And I hope someone weighs in on this philosophy.) But in this example, it's not clear (to me) that the number of lines that meet a generic set of 4 lines is nonempty. (I assume when you say "a finite number of lines" above, you mean nonzero.) Though I suppose I could perhaps just check that?
Comment: You can create an intersection theory on Grassmannians. What this means here is that if you pass to rational equivalence, you can define the "intersection" of two rational equivalence classes in a way so that the intersection number is always of the proper dimension. (For example, you can intersect a curve on a surface with itself and get a "finite number of points", or rather, a dimension 0 rational equivalence class). Under rational equivalence on Grassmannians, which are projective, the number of points always stays the same. (continued in next comment)
Comment: So what's really happening is that whenever your intersection is actually a finite set of points, the number will coincide with the formal intersection number. When the intersection is not a finite set of points, the data from the intersection number is harder to use.

If you accept the existence of such an intersection theory, then the specific example given proves the intersection number is 2, and proves that whenever you have an intersection consisting of a finite number of points, it will be 2 points. (to be continued)
Comment: The objects you are intersecting are in this context sections of line bundles. Any two sections are rationally equivalent, so you can pass to rational equivalence. To prove that the intersection is generically finite, I'm fairly sure there is some sheaf which will give you that after invoking the fact that ranks of sheaves are semicontinuous functions.

On a sidenote, I realized that I never mentioned that "the number of points in the intersection" is with multiplicity.
Answer: (expanding on the above -- can't figure out how to edit, please delete earlier)
There's some nice discussion of this in Harris's book "3264 and all that", a (legitimately available) draft of which may be found on Google.  Section 4.2 works out the Chow ring of $G(1,3)$.  In particular, "A Specialization Argument" in Section 4.2.3 seems to be just the example you're after about degenerating to two intersecting lines.  I gather that there is a generalization of this argument by Coskun and Vakil that might be of interest; the reference is in 3264.
To elaborate, let $\sigma_1$ be the cycle consisting of lines which meet a given line.  What you're trying to do is compute $\sigma_1^4$, which will be the number of lines that meet four given lines.  A sensible first step is to compute $\sigma_1^2$.  This turns out to be $\sigma_{1,1} + \sigma_2$, where $\sigma_{1,1}$ is the set of lines in a given plane and $\sigma_2$ is the lines through a particular point.  Here's the idea of how to get that answer via degeneration.  Fix a line $L$ and a family of lines $M_t$ such that $L$ and $M_t$ do not meet, except when $t=0$ they intersection at a point.  You're interested in the class of $\sigma_1(L) \cap \sigma_1(M_t)$, and it's sensible to look for the flat limit of this intersection as $t \to 0$.  If $\ell$ meets both $L$ and $M_0$, either it is contained in the plane with both of them in it (there's the $\sigma_{1,1}$), or it goes through the point where they intersect (there's the $\sigma_2$).
Degenerating to two pairs of intersecting lines as you suggest lets you write $\sigma_1^4 = (\sigma_{1,1}+\sigma_2) \cdot (\sigma_{1,1} + \sigma_2) = 2$.
To see why the above degeneration argument (I use the term loosely!) is actually legitimate, check out the referenced book.
Comment: Look ^^ there. You should see `share` `edit` `flag` buttons. It's possible that you may not have enough reputation, yet, for all of those buttons, but you should have the first two. The `edit` button is (of course) the one you want.
Comment: I merged your accounts. That was probably the reason you couldn't delete the other post.

Basic Schubert calculus intuition


Using GNU C Libraries and other Data structure libraries on Mac/Windows/Linux.?

Question: I want to know if the C libraries system/string/data structure/data base etc are platform dependent.?
what are the things of these libraries that are dependent on a specific platform.?
like how a regular expression/string manipulation/sql connectivity etc libraries are dependent on a platform.?
can I use them on any platform for File I/O/Paths etc
just like we do things in python using the sys/os etc modules.?
I want to build a program which deals with strings,database(sqlite3,mysql,Oracle),data structures,File I/O and System paths. and can run on Windows,Linux and Mac when re compiled on that platform.
and I want it to be console based.
Please don't recommend me to do it in other programming languages, I want the C folks to answer please.
Thanks
Answer: Well, as long as you use the standard C library, all is well. The GNU C Library (glibc) is one implementation of the C standard, and for example Microsoft has their own implementation of it.
From a user's (your) perspective, the impelementation doesn't matter. If you for example
#include <stdio.h>

then you can, on any standards-compliant platform, call the fopen() and then use fread() for file i/o. Or any other standard C function.
Linux, Mac and Windows are all standards compliant (i.e. have implemented the ISO C) and thus the standard functions do the same thing on all platforms. The filepaths that you pass to fopen() are the same, too. The fact that Windows uses backslash ( \ ) in the filepath instead of the Unix way (forward slash, / ) doesn't matter: on Windows, in your C program, you use the Unix-style notation.
Answer: For C library functions, I suggest you ensure that you use functions within the POSIX standard. This will (at least in theory) guarantee compatibility with other POSIX platforms.
If you are programming on linux using glibc (i.e. the normal C library), the documentation thereof is reasonably good at pointing out what are GNU extensions, but the POSIX standard (referenced above) is the gold standard.
For other libraries, you'll have to look to the library in question.
Remember that if there are specific areas of incompatibility, you can use #ifdef's etc around those bits, and keep the machine specific elements in specific files.
To the specific points you mentioned:
* The POSIX regexp functions (regcomp, regexec, regerror, regfree) are part of the POSIX standard.
* Most of the string manipulation functions (e.g. strstr) are part of the POSIX standard. Some (e.g. asprintf) are GNU extensions.
* SQL connectivity is not provided by the C library. You will need a specific C library to deal with your SQL connection, or to use something like libdbi. You'll need to look at the specific library to see what support there is on other platforms.
In particular, be careful with path manipulation on windows (think about slashes vs backslashes, and drive letters), specifically dealing with how they are input by the user and what is passed to the function.


How to compare predictive results of MARS and OLS with each other?

Question: I fitted a MARS model and an OLS model to my data. The main goal is prediction. How can I compare the result and decide which is better? Since I don't have  much records I did not split the data in Training and testing data...
Until now I only considered R^2- fit for the fitted data. Can I do some cross-validation?
Comment: Cross validation is done by splitting the data into training and testing sets. So you basically contradict yourself in sentence 4 against sentence 6.
Answer: The standard approach to picking the model with the best predictive generalization is to do cross-validation and measure some appropriate out-of-sample metric. I don't know what might be the most appropriate for your context and problem, but one standard choice would be to pick the model that minimizes out-of-sample squared error.
Comment: But how to implement CV for the MARS model? And what about outliers. These could have huge effect in the CV?
Comment: I'm not sure I understand your question -- what would make implementing CV in MARS different than any other algorithm? Outliers probably won't be predicted well, so... that's the cost of trying to make any model.
Comment: Problem is I used the Salford Software for Mars model and also build a Cart model there. I think both use during the model buildung a Cv. For better fit I averaged Mars and Cart. Now I don't know how CV works for this averaged model...
Comment: @fabian92 I'm not familiar with that software suite, and software questions are not within the scope of CV. To understand how the software works, you'll have to contact the manufacturer, or some sort of forum with that dedicated purpose.
Comment: @fabian92, if your data is cross-sectional, CV is trivial: just make different splits of the original sample into estimation set and test set, run your model on each estimation set and test its performance on the corresponding test set. If your data is time series, you could use rolling windows instead of random splits.
Answer: R^2- fit for the fitted data is a valid measure, but ...
Both models might have a different bias/ variance trade off. This is a separate subject all together. What you are looking for is the model that has the best R^2 under generalization.
A good staring point is: Question about bias-variance tradeoff
Cross-validation is indeed one of the ways to assess this trade-off.
HTH.


How can I download YouTube audio with Python?

Question: How can I download the audio from a YouTube video with Windows, using Python 2.7? I have seen many results that work with Linux but I haven't been able to get anything to work with Windows.
Comment: http://stackoverflow.com/questions/2884588/streaming-audio-youtube
Answer: Have a look at youtube-dl. It should work on Linux, windows and OS X.
Comment: thanks, ill check it out and probably give you the Check mark when I have more of a battery life left


Como abrir uma página HTML no browser com o VScode

Question: Eu preciso abrir uma página no browser com os meus códigos HTML, usando o VSCode.
Entretanto, quando eu faço o F1+tasks: Configure Tasks, não abre o tasks.json.
Answer: Vc pode instalar alguma extensão como por exemplo Live HTML Previewer
Link da extensão: https://marketplace.visualstudio.com/items?itemName=hdg.live-html-previewer
Com ela instalada vc pode configurar um atalho para Open inBrowser, assim vc vai  poder abrir seu arquivo HTML direto no Browser. No meu caso configurei o atalho conforme imagem Ctrl + Q + W

OBS: É preciso que vc esteja em um arquivo HTML, vc tb pode clicar com o botão da direito e mandar abrir no browser

Opção 2
Instalar o Live Server, com ele vc pode clicar em Go Live, ou clicar com o btn da direita e mandar abrir no Browser
Link da extensão: https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer
OBS: Para funcionar vc deve colocar a pasta inteira do projeto dentro  do VS Code, se vc estiver com um arquivo insolado sozinho no VS Code o GO Live não vai funcionar!


Coordinates of vectors in bases

Question: Two vectors from the standard basis are $a = (1,0,1)$ and $b = (1,1,1)$. What are the coordinates of these vectors in the basis $\{(1,2,3),(2,3,1),(3,0,1)\}$.
I am not even sure how to answer this question. I have tried looking up how to find coordinates for vectors in basis and I haven't found anything useful yet. Any help would be greatly appreciated.
Comment: Write (1, 0, 1) = a(1, 2, 3)+b(2, 3, 1) + c(3, 0, 1) then find a, b, c and you are done.
Comment: @Paul, only half-done, as there's still $b$ to do (by the same method, of course).
Answer: Create a matrix with the columns being the vectors given in the basis (to understand where this matrix comes from, see Paul's comment):
$$A=
\left[ \begin{array}{ccc}
1 & 2 & 3 \\
2 & 3 & 0 \\
3 & 1 & 1 \end{array} \right] $$
This is a transformation matrix and can be used to change the basis of a vector (which is essentially a linear transformation). So if we're given a vector $\vec{x}$ from the non-standard basis, we have;
$$\vec{y}=A\vec{x}$$
where $\vec{y}$ is the vector constructed from the standard basis. In this particular problem, we're given the vectors from the standard basis, so we need the inverse of the transformation matrix. Simply find $A^{-1}\vec{a}$ and $A^{-1}\vec{b}$, and the elements of the resulting vectors correspond to the coordinates of the vectors $\vec{a}$ and $\vec{b}$ in the non-standard basis.

Coordinates of vectors in bases


Compute $\lim\limits_{x \to +\infty}\frac{\ln x}{ \int_0^x \frac{|\sin t|}{t}{\rm d}t}$

Question: Problem
Compute
$$\lim\limits_{x \to +\infty}\dfrac{\ln x}{\displaystyle \int_0^x \dfrac{|\sin t|}{t}{\rm d}t}.$$
Comment
Maybe, we can solve it by L'Hospital's rule, but there still exists a difficulty here. Though $x \to +\infty$ implies $\ln x \to +\infty$,  we do not know the limit of the denominator. How to solve it?
Comment: @mathworker21 The L'Hopital's rule says that if the limit for $\frac{f'}{g'}$ exists then it is equal to the original limit. It does not say anything about case when the limit does not exist.
Comment: Hint: we can write the denominator as $\int_0^1 \frac{|\sin t|}{t}dt+\int_1^x \frac{|\sin t|-\frac{2}{\pi}}{t}dt +\frac{2\ln x}{\pi}.$ Show that $\int_1^x \frac{|\sin t|-\frac{2}{\pi}}{t}dt$ is bounded in $x$ using the fact that $\int_a^{a+\pi}|\sin t|-\frac{2}{\pi} dt =0$ for all $a$.
Comment: the limit of the denominator is $+\infty$.
Comment: @mathworker21 how you know that?
Comment: The set of $t$ for which $|\sin t| \ge 1/2$ (say) is some positive proportion of all $t$, so the integral of $1/t$ over that set is infinite.
Comment: @Guy Fsone: The limit does exist (and is finite).
Comment: @Song why doesn't Lhopital's work. it seems lhopital would give $\lim_x \frac{1/x}{|\sin x| / x}$ which would mean the limit doesnt exist
Answer: It helps to visualise the functions involved. A cartoonish picture of the integrand is a sequence of bumps of smaller and smaller amplitude. Specifically, for $t$ between $n\pi$ and $(n+1)\pi$, you have $\frac{|\sin t|}{(n+1)\pi}\leq \frac{|\sin t|}{t} \leq \frac{|\sin t|}{n\pi}$. For the first bump, i.e. when $n=0$, we need to take some care: let us replace the upper bound by $\sin t$ in that case.
The integral of $|\sin t|$ over each such interval is $2$ (just integrate $\sin t$ from $0$ to $\pi$, and note that $|\sin t|$ is periodic with period $\pi$ – as always, pictures help), so if we write $f(x)$ for your denominator, then $\sum_{1\leq n\leq x-1}\frac{2}{n\pi}\leq f(x) \leq 2+\sum_{1\leq n\leq x}\frac{2}{n\pi}$. The harmonic sum converges to $\ln x$, so the whole limit is $\pi/2$.
Comment: THX! But could you please elaborate the last few steps?
Comment: What specifically would you like me to elaborate on?
Comment: please check the solution I write.
Answer: Thanks to @Alex B.'s hint , I complete the solution. Please correct me if I'm wrong.
For any $x>0$, we can choose some $n \in \mathbb{N}$ such that $n \pi\leq x<(n+1)\pi$. Thus, we obtain
$$\int_0^{n\pi}\frac{|\sin t|}{t}{\rm d}t \leq \int_0^x \frac{|\sin t|}{t}{\rm d}t<\int_0^{(n+1)\pi}\frac{|\sin t|}{t}{\rm d}t.$$
On one hand, notice that
\begin{align*}
\int_0^{n \pi} \frac{|\sin t|}{t}{\rm d}t&=\int_0^\pi \frac{|\sin t|}{t}{\rm d}t+\sum_{k=1}^{n-1}\int_{k\pi}^{(k+1) \pi} \frac{|\sin t|}{t}{\rm d}t\\
&> \sum_{k=1}^{n-1}\int_{k\pi}^{(k+1) \pi} \frac{|\sin t|}{t}{\rm d}t\\
& > \sum_{k=1}^{n-1}\int_{k\pi}^{(k+1) \pi} \frac{|\sin t|}{(k+1)\pi}{\rm d}t\\
&=\sum_{k=1}^{n-1}\frac{\int_{k\pi}^{(k+1)\pi}|\sin t|{\rm d}t}{(k+1)\pi}\\
&=\frac{2}{\pi}\sum_{k=2}^{n}\frac{1}{k}.
\end{align*}
On the other hand, likewise,
\begin{align*}
\int_0^{(n+1) \pi} \frac{|\sin t|}{t}{\rm d}t&=\int_0^\pi \frac{|\sin t|}{t}{\rm d}t+\sum_{k=1}^{n}\int_{k\pi}^{(k+1) \pi} \frac{|\sin t|}{t}{\rm d}t\\
&< \int_0^\pi {\rm d}t+\sum_{k=1}^{n}\int_{k\pi}^{(k+1) \pi} \frac{|\sin t|}{k\pi}{\rm d}t\\
&=\pi+\sum_{k=1}^{n}\frac{\int_{k\pi}^{(k+1)\pi}|\sin t|{\rm d}t}{k\pi}\\
&=\pi+\frac{2}{\pi}\sum_{k=1}^{n}\frac{1}{k}.
\end{align*}
Therefore
$$\frac{2}{\pi}\sum_{k=2}^{n}\frac{1}{k} <\int_0^x \frac{|\sin t|}{t}{\rm d}t<2+\frac{2}{\pi}\sum_{k=1}^{n}\frac{1}{k}.$$
Since
$$\ln n\pi\leq \ln x<\ln(n+1)\pi,$$
we have
$$\dfrac{\ln n\pi}{\pi+\dfrac{2}{\pi}\sum\limits_{k=1}^{n}\dfrac{1}{k}}<\dfrac{\ln x}{\int_0^x \dfrac{|\sin t|}{t}{\rm d}t}<\dfrac{\ln(n+1)\pi}{\dfrac{2}{\pi}\sum\limits_{k=2}^{n}\dfrac{1}{k}}.$$
Applying the subsitution as follows
$$\sum_{k=1}^n \frac{1}{k}=\ln n+\gamma+\varepsilon_n,$$
(in fact, we only need to recall that $\sum\limits_{k=1}^n \dfrac{1}{k}$ and $\ln n$ are equivalent infinities), we can readily infer that the limits of the both sides in the last expression are both equal to $\dfrac{\pi}{2}$ under the process $n \to \infty$(i.e. $x \to +\infty$). Hence, according to the squeeze theorem, we can conclude that
$$\frac{\ln x}{\int_0^x \frac{|\sin t|}{t}{\rm d}t} \to \frac{\pi}{2}(x \to +\infty),$$which is what we want to evaluate.
Answer: The denominator can be compared to the harmonic sum $1+1/2+1/3+\dots$ (How?), which is divergent.
Surely the nominator also diverges.
A moment's reflection shows that it suffices to consider $(M_1, M_2)$ where $M_1=m_1\pi,M_2=m_2 \pi$ for any $0 < m_1 <m_2, m_1, m_2 \in \mathbb{N}$.
Set $k=m_2-m_1$.
$$
I
:=\lim_{x \to \infty} \frac {\ln x} {\int^x_0 |\sin t| /t}
=\lim_{x \to \infty} \frac {\int^x_{1} (1/t) dt} {\int^x_{1} (|\sin t| /t) dt}
=\lim_{x \to \infty} \frac {\int^x_{M_1} (1/t) dt} {\int^x_{M_1} (|\sin t| /t) dt}
$$
Set
$$
N(M) =\int_{M}^{M+\pi} \frac{1}{t} dt \\
D(M) =\int_{M}^{M+\pi} \frac{|\sin t|}{t} dt
$$
We see that
$$
I
=\lim_{m_2 \to \infty}
\frac{\sum_{m'=m_1}^{m_2} N(\pi m')}{\sum_{m'=m_1}^{m_2} D(\pi m')}
$$
Since
$$
\left| M N(M) -M \frac{\pi}{M} \right| \leq \frac{\pi}{M+1} \\
\left| M D(M) -M \frac{2}{M} \right| \leq \frac{2}{M+1}
$$
Cesaro summation tells us
$$
I
=\lim_{k \in \mathbb{N}:\; k \to \infty}
\frac{(1/k)\sum_{M'=M_1}^{M_2} M' N(M')}{(1/k)\sum_{M'=M_1}^{M_2} M' D(M')}
=\frac{\pi}{2}
$$
Answer: Note that L'Hopital is not helpful here:
We have $|\sin t| \le \frac12$ if and only if $\left(k+\frac16\right)\pi \le t \le \left(k+\frac56\right)\pi$ for some $k \in \mathbb{N}$. Therefore
$$\int_0^\infty \frac{|\sin t|}{t}\,dt \ge \frac12 \sum_{k=1}^\infty \int_{\left(k+\frac16\right)\pi}^{\left(k+\frac56\right)\pi} \frac{dt}{t} = \frac12\sum_{k=1}^\infty \ln\left(\frac{k+\frac56}{k+\frac16}\right) = +\infty $$
since $\ln\left(\frac{k+\frac56}{k+\frac16}\right) \xrightarrow{k\to\infty} 1$.
Hence we can apply L'Hopital to obtain
$$\lim_{x\to\infty} \frac{\frac{1}{x}}{\frac{|\sin x|}{x}} = \lim_{x\to\infty} \frac1{|\sin x|}$$
but this limit doesn't exist, e.g. consider $x_n = \frac{n\pi}2$ and $x_n = n\pi$. This doesn't tell us anything about whether the original limit exists.
Answer: As for the denominator, note that $\int_0^x dt\,\frac{|\sin(t)|}{t}=\int_0^{x/\pi}dt\,\frac{|\sin(\pi t)|}{t}=\int_0^{y}dt\,\frac{|\sin(\pi t)|}{t}$ (we introduced $y:=x/\pi$).
The integrand $t \mapsto \frac{|\sin(\pi t)|}{t}$ is squeezed between $h(t):=\sum_{k=1}^{\infty}\chi_{[k,k+1)}(t)\frac{1}{k+1}|\sin(t)|$ below and $j(t):=\chi_{[0,1)}(t)\pi+\sum_{k=1}^{\infty}\chi_{[k,k+1)}(t)\frac{1}{k}|\sin(t)|$ above. Hence
$$\frac{2}{\pi}\sum_{k=1}^{\lfloor y \rfloor-1} \frac{1}{k+1}=\int_0^{\lfloor y \rfloor}dt\,h(t)\leq \int_0^ydt\,\frac{|\sin(\pi t)|}{t} \leq \int_0^{\lceil y\rceil}dt\,j(t) =\pi+\frac{2}{\pi}\sum_{k=1}^{\lceil y\rceil-1}\frac{1}{k}$$
Concerning the numerator, note that $\ln(x)=\ln(x/\pi)+\ln(\pi)=\int_1^y \frac{dt}{t}+\ln(\pi)$. The integrand function $t \mapsto \frac{1}{t}\chi_{(1,y)}(t)$ is squeezed between the step function $f(t):=\sum_{k=1}^{\infty}\chi_{[k,k+1)}(t)\frac{1}{k+1}$ below and the step function $g(t):=\sum_{k=1}^{\infty}\chi_{[k,k+1)}(t)\frac{1}{k}$ above. Hence
$$\sum_{k=1}^{\lfloor y \rfloor-1} \frac{1}{k+1}=\int_1^{\lfloor y \rfloor}dt\,f(t)\leq \int_1^y\frac{dt}{t} \leq \int_1^{\lceil y\rceil}dt\,g(t) =\sum_{k=1}^{\lceil y\rceil-1}\frac{1}{k}$$
Gathering all our results, we find (recall that y=x/\pi)
$$\frac{\left(\sum_{k=1}^{\lceil y\rceil-1}\frac{1}{k}\right)-1+\ln(\pi)}{\frac{2}{\pi}\sum_{k=1}^{\lceil y \rceil-1} \frac{1}{k}}=\frac{\left(\sum_{k=1}^{\lfloor y\rfloor-1}\frac{1}{k+1}\right)+\ln(\pi)}{\frac{2}{\pi}\sum_{k=1}^{\lceil y \rceil-1} \frac{1}{k}}\leq \frac{\ln(x)}{\int_0^xdt\,\frac{|\sin(t)|}{t}}\leq \frac{\left(\sum_{k=1}^{\lceil y\rceil-1}\frac{1}{k}\right)+\ln(\pi)}{\frac{2}{\pi}\sum_{k=1}^{\lfloor y \rfloor-1} \frac{1}{k+1}}=\frac{\left(\sum_{k=1}^{\lceil y\rceil-1}\frac{1}{k}\right)+\ln(\pi)}{\frac{2}{\pi}\left(\sum_{k=1}^{\lceil y \rceil-1} \frac{1}{k}\right)-\frac{2}{\pi}}$$
since the expression on the left and on the right converge to $\pi/2$ as we let $y=x/\pi\to \infty$, so does the middle expression.


Como remover todos os caracteres ilegíveis de transformar uma String em um nome de variável para Firebase?

Question: Estou com um problema de cadastro. Eu cadastro em um formulário onde a pessoa coloca o nome do alimento, algo como isso:

      Alimento
      <input autocomplete="off" type="text" id="food" placeholder="Alimento...">

E quando o meu formulário é feito o submit, isso acontece em meu script:
$('form').submit(async event => {
     event.preventDefault();
     $('#save').prop('disabled', true);

     let food = $('#food').val();
     let id = food.replace(/\s/g, '').replace(/\./g, '').replace(/[\])}[{(]/g, '').toLowerCase() + '&&' + food;

     // Serialize the form and add opening date
     let formData = $('form').serializeJSON();
     formData = Object.assign(formData, {
           "food": id
     });
});

Eu crio esse corpo pro meu formulário, colocando o "food" com o valor que vem do meu input só que tentei colocar um replace para que não viesse espaços em branco e nem viesse pontos ou parênteses. Alguém consegue me ajudar a incrementar esse replace para que ele renomeie todos as letras que vierem com acento? como por exemplo a palavra "Feijão" ficar como apenas "feijao".
Comment: Vi que vc mudou de "acentos" para "caracteres ilegíveis", mas creio que agora a solução abaixo não sirva mais - por exemplo, ela não remove hífens, que é um dos caracteres citados no título. Na verdade tem vários caracteres que ela não remove, [veja aqui um exemplo](https://ideone.com/0bVca0) - e nesse link também tem uma sugestão de solução (como a definição de "ilegível" ficou meio vaga, eu assumi que é "tudo que não seja letra", mas sugiro editar a pergunta deixando mais claro o que é considerado "ilegível").
Comment: Além do link já indicado acima no box azul, ver também: https://pt.stackoverflow.com/q/124754/112052 | https://pt.stackoverflow.com/q/148180/112052
Answer: Adicionei o código
normalize('NFD').replace(/[\u0300-\u036f]/g, "")

E deu tudo certo, muito prático e rápido, no fim ficou assim:
let id = food.normalize('NFD').replace(/[\u0300-\u036f]/g, "").replace(/\s/g, '').replace(/\./g, '').replace(/[\])}[{(]/g, '').toLowerCase() + '&&' + food;