What does /r mean in a score?

Question: Does anyone know what the "/r" in this score might mean?
Thank you so much...
Comment: Need to see more of the score.
Comment: @CarlWitthoft that would be `\r`.
Comment: it looks like tr not /r
Comment: It would certainly be useful to know who engraved and/or published the score (to compare other examples of theirs), and indeed what the piece is (to compare other editions of it).
Comment: @shoover  pedant  :-)
Comment: @theonlygusti: _I_ say it looks like an _h_ with some sort of weird tumour.
Answer: This is actually tr, the notation for "trill," an embellishment (or ornament) on a note where you rapidly alternate between the main pitch and an adjacent pitch.
There are many different types of trills; the style of music (and perhaps editorial notes) will clarify exactly which type is intended.
You can check out more in the Wikipedia article.
Comment: @AndrewLeach But it also seems to be missing the cross at the top, which is more significant in the orthography of 't'. If it's supposed to be just the right part of the cross, it's easily mistaken for a serif on the 'r'.
Comment: Not all t's have the tail at the bottom (or, they might have a tail which is more of a serif).
Comment: Mixing a sans-serif "t" with a serifed "r" does look odd, though. The method of printing could affect the appearance of the "t", too; are parts of the "t" missing from a piece of type, for instance?
Comment: Could be, but unconvinced the first letter is 't'.
Answer: Definitely a trill. A forward slash would be much taller, narrower and more slanted. Certain fonts leave the tail and the cross off the 't' almost entirely, especially when italic and bold. Below is a comparison of '/r' and 'tr' in a more standard, modern font (on the left) and an older, less common font (on the right).
Comment: Most likely accurate, but if other 'trills' are in the piece, it'd be good to be able to see them.
Comment: @Tim Yes, definitely!
Comment: Considering typography, I'd say the t should not go lower than the r, but that's what it looks like to me in the scan of OP.

What does /r mean in a score?


Programatically add module block to dashboard

Question: Is there a way in which from my .module file I can assign a block in a specific region from Dashboard?
Answer: It can be done in a simple way by mentioning a region key to the $blocks array in the HOOK_block_info(). Follow the code for reference,
<code>    /**
     * Implements hook_block_info()
     * @return array
     */
    function my_module_block_info() {
      $blocks = array();
      $blocks['leaderboard'] = array(
        'info' => t('Leaderboard'),
        'status' => 1,
        'region' => 'dashboard_main',
        'weight' => 99,
        'cache' => DRUPAL_CACHE_PER_ROLE,
      );

      return $blocks;
    }
</code>
Answer: In .install file you can add following sql (change the appropriate values)
<code>db_query("INSERT INTO {blocks} VALUES ('gjg', '0', 1, 0, 1, 0, 0, 1, 'my*', '')");
</code>
Answer: yes. see hook_block_info for region


How to preserve extensions in Firefox with VSCode and request Launch

Question: I'm attempting to debug a React app with React Dev Tools and Firefox Developer Edition. I can't install React Dev Tools to the profile Firefox is using when it is launched via VSCode. I have React Dev Tools installed when I launch Firefox myself via opening it in /Applications.
However, when I run the below launch.json profile, there are no extensions shown under Preferences -> Extensions & Themes -> Extensions in FireFox after it launches.
{
  "name": "Launch localhost",
  "type": "firefox",
  "request": "launch",
  "reAttach": true,
  "url": "http://localhost:3000",
  "webRoot": "${workspaceFolder}"
},

However, I can follow the directions here and launch Firefox with the terminal and attach my debugger to it. This Profile has React Dev Tools and it works fine running:
/Applications/Firefox\ Developer\ Edition.app/Contents/MacOS/firefox -start-debugger-server

launch.json:
{
  "name": "Attach",
  "type": "firefox",
  "request": "attach",
  "url": "http://localhost:3000",
  "webRoot": "${workspaceFolder}"
},

But how do I make the first one work with a launch request instead of attach? From reading it seems to have something to do with the profile
Answer: I had the same problem and was able to fix it by adding to my launch.json:
"profile": "my-firefox-profile"

Firefox can have miltiple profiles installed. You can check them by typing about:profiles in firefoxes adress bar.
It will show you a list of profiles. The one marked as Default profile: yes should be the one to choose.

My launch.json now looks like this:
    {
        "name": "Firefox",
        "type": "firefox",
        "request": "launch",
        "reAttach": true,
        "url": "http://localhost:4300",
        "webRoot": "${workspaceFolder}",
        "profile": "default-release-1"
    },

Background:
Firefox profiles hold settings like browsing history, bookmarks  - and most importantly - add-ons. By telling VSCode to use a specific profile it serves with the installed plugins.
This will also work if you have the same problem with Angular or Vue.
Answer: In addition to the accepted answer, I had to also add the following to launch.json to make Firefox launch with the specified profile.
"keepProfileChanges": true

I am using VSCode 1.52.1 and Firefox 84.0.2.
Comment: Why did you have to add this parameter? What happened without it?


whats an ideal candidate for asp.net mvc

Question: is there any particular website that would make sense to use MVC versus webforms.
what would be the decision process in deciding between these options?
Answer: There is a lot of enthusiasm around MVC right now, but if you are starting a new dev project right now I'd still recommend that you carefully consider before jumping on the MVC train just yet.
For most dev teams on any non-trivial project, there are some serious considerations. Here are the ones I find most relevant:

MVC requires much more skill from your developers. They will need significant expertise  in the inner workings of HTML/CSS as well as a good understanding of how HTTP works. For the client side code they will need strong javascript and JQuery skills, and on the server side an advanced grasp of OO principals. And if you plan to get the most from MVC, experience with unit testing and mocking frameworks too.
The MVC 1.x framework currently doesn't get much in the way of RAD features from Visual Studio. You get a text editor and intellisense, but that's about it. No wizards, no drag-n-drop components, no property editors, etc. While this isn't really that bad, it does often mean that building non-trivial UIs will take significantly longer, especially for less experienced developers.
MVC is very new, and so code samples, tutorials, and sample apps are very hard to come by and tend to be very limited in scope. Documentation is also a bit thin at present.
Perhaps the biggest drawback to the MVC framework is the lack of an established and mature 3rd party market around it. With web forms there are tons of very advanced UI suites and components on the market and tons of open source projects you can borrow from.
For many apps, especially business apps the lack of 3rd party reporting, charting, and advaned grid controls for the MVC framework alone should be a major concern.

MVC is fantastic, and I highly recommend it if you are in a position where you can use it. But there are real costs and risks for any significantly complex project that may keep you on web forms for a while longer.
I do expect that the next major version of MVC will probably address many of those issues,  especially with the lack of RAD features.  I also expect that the enthusiasm around MVC will bring a lot of 3rd party support to the platform too. But it will take some time for all that to get well established.
Comment: Good points, although without wishing to be a complete pedant, I guess you mean, "ASP.NET MVC is very new" - MVC itself originated ca. 1979 at PARC.
Answer: I wouldn't say a type of website would be better for either to but more or less the needs of a website.
If you need a website that's can be thrown together very quick without a large amount of code and you don't care about HTML markup.  Than WebForms is the way to go.
If you're a control freak and you want control over everything that's happening and the markup being generated.  Than MVC is probably for you.
MVC is less of an abstraction of the HTTP model meaning a lot less is done for you.  It doesn't hold state like WebForms' ViewState.
Answer: I spent the last 4 weeks reading the available material on MVC and doing the various videos and tutorials.  Today I started working on an actual application (with a client awaiting to see results some time soon).  I agree with the previous answers (an awful lot to learn, many many new concepts, little in lieu of 3rd party components).  Still I am glad I have spent the time learning mvc.
- You have to overcome your fear of row html/css/jscript which are hidden with webforms.  It takes time to get used to the html tags.  Once you do you will find out about the possibilities available. You will unlikely miss  tags.
- If you have no experience using unit tests, then I think that mvc provides for a great introduction into the possibilities that come with unit testing.
- OO is much more present and "obvious" within mvc.
- Separation of concerns is possible and natural.  You will not miss mixing gui and business logic in an aspx.cs file.
- No more page_load (and the n different stages).  If you never quite liked asp.net's databinding, you will love mvc.  I am happy not to have to do it ever again!
Cons:
- It is slow.  At the beginning it is very slow.  Things that take little time in webforms, can take a lot of time with mvc.
- Not having pages any longer is also a massive change.  But once you "internalize" this (time...), you will not miss the pages.
- An O/R Mappers is also needed.  One more thing to learn.
- There is a lot to learn and get used to, should you be interested in getting the most out of the framework.  MVC is only half-mvc without unit testing.  Unit testing without a mocking framework is not really possible, so you must learn that too. By the time you think you are half-way through with unit testing, you see the need to automate parts of your work, nant must be learned as well.  It is just endless....  But again, once you start using these technologies you will wonder how you ever managed without.
Answer: The decision process for me is pretty simple.  All new development will be done with ASP.NET MVC.  Existing sites that need minor modifications will continue to be WebForms.  Existing sites that need major modifications will be candidates to move to MVC.
The basic reason that I'm making the switch has to do with testability and design.  IMO MVC web sites are significantly more testable.  I can test everything but the view logic with unit tests and, by using and testing HtmlHelper extensions I can even test a fair amount of view logic.  With WebForms I had to jump through lots of hoops to test codebehind and as a result left a lot of the app for manual testing.
I also feel that the architecture is simply better from a design standpoint.  Because of the clear separation of concerns it's less tempting to insert business logic in the wrong place (e.g., the view).  It makes conceptualizing and understanding the application much easier.  I'm also able to reuse even view code with less effort because I don't have extraneous bits of logic from other layers hanging around to get in the way.
The only real downside I see at present is that it's not as mature and you don't already have as many reusable components built for it.  I expect that to change, though, over time.  Also, even though it is possible to intermix MVC with WebForms, I don't see retrofitting existing apps as a viable alternative unless there is significant other work to be done.  Again, just my opinion, but I would rather start from scratch with MVC than try and get an existing app to work with it.  I suppose it would depend on the size of the app, but anything with any significant number of pages is going to have a lot of routing exceptions.


Button under the current page getting clicked/tapped in sencha touch

Question: I'm using sencha touch 2.3.1
I have a button on a page and clicking it will open a new page (above the current page).
But when I click/tap on the new page in the region where the button is ( in the original page ) , the button is still getting clicked.
And a new view of the same page is being opened.
I'm facing this problem only in windows phone, it works fine in android, IOS and all browsers (including IE) through IIS. I'm using the tap event for this button.
Please help me resolve this.
Thank you.
Answer: Sounds like your issue is similar to this bug I've reported a while back:
http://www.sencha.com/forum/showthread.php?237550-2.1-Tap-event-is-passed-to-the-textfield-in-new-view
The workaround which has been working for me is adding e.stopEvent(); to the tap handler of the component the user is tapping on.
Comment: It's not working for me, my function looks something like this..
tap: function(e, dom) {
e.stopEvent();
var el = Ext.get(e.target),
     .
     .
     .
Comment: I guess I'm doing something wrong because it doesn't look like it'll work. Can you please tell me how to do it properly, I'm new to sencha, so it's difficult for me
Comment: Do you think you can add more code to your original question? The snippet above looks ok, not sure what is wrong in your code.
Comment: I'm sure that e.stopEvent() is not working.
Right now, I'm using the following code inside the tap event:
if(Ext.getCmp('center-report')){
return false;
}
Where 'center-report' is the id of the new view that is opened after clicking the button. This works for me.
Comment: Would need to see some code to comment on that, you might have put e.stopEvent() in the handler you don't expect to be called, instead of the handler you expect to be called. (e.stopEvent() stops to bubble the event up, it's not stopping the actual handler you're adding it to) Glad you found a workaround though.


Will 10GBASE-LR work if 10GBASE-LRM used to work on the same cable link?

Question: We have got some old 62.5um single-mode fiber links in our building. Network people told me, that Cisco 10GBASE-LRM with Cisco mode conditioning patch cables works fine on those cables and provides a stable 10GBit link.
Now we need to add a new direct link between servers over the same cable, and were considering Intel cards with Intel transceivers. Apparently 10GBASE-SR should not work over this cable (total link length is over 200m). Do I understand correctly that 10GBASE-LR transceivers should work just fine with these cable infrastructure? Which kind of patch cables should we use, single-mode patch cables, multi-mode patch cables, or mode conditioning patch cables?
Answer: LR connections are single mode.  You'll need mode conditioning patch cables on both sides but likely a different type than was in use for your LRM (which wants multimode, but with a smaller core).
Comment: Learn something new every day.  Mode conditioning cables have other uses, FYI - in particular they are useful with 10GBASE-LRM.  It's spec'd to work over 62.5 micron (old style) multimode; but it can go much longer distances over that fiber with the mode conditioning cable.
Comment: LR likely won't work at all over this fiber. Needs to be single mode end to end.
Comment: http://www.fiberoptics4sale.com/wordpress/mode-conditioning-cable-mode-conditioning-patch-cord-how-to-use-it/  - the application in question can use the cited conditioning cables... this is what they're for.


telnet unable to connect to remote host

Question: I have installed postfix and devcot on one of my live servers to send bulk mail (system messages on sign-up, wrong passwords etc). I use the php_imap function to check bounces and flag those email id's so that we don't keep sending emails to those address that have resulted in a bounce. I noticed that the php_imap function was not reading the bounces on the live servers it did read bounces on the test servers. But the live server is able to send mails! Both the servers have identical Centos 6.4 OS and have the same iptable configuration.
I compared the DNS entries of both "test" and "live" domains and they have the necessary SPF entries. The hosting provider has the necessary PTR records. But the bounces for some reason was not available to the php_imap program.
At this point I was not sure if the bounces were being delivered to the server and dovecot was unable to read them or if the bounces were not delivered at all.
So I compared the entries in /etc/postfix/main.cf and /etc/postfix/master.cf of both the "test" and "live" servers and found them to be the same except for the domain name.
To be sure I checked if postfix is running ps aux | grep postfix and it returned
LIVE SERVER
<code>[root@bw sridhar]# ps aux | grep postfix
root      1433  0.0  0.1  13476  2696 ?        Ss   09:32   0:00 /usr/libexec/postfix/master
postfix   1443  0.0  0.1  13720  2836 ?        S    09:32   0:00 qmgr -l -t fifo -u
postfix   4724  0.0  0.1  13552  2668 ?        S    12:00   0:00 pickup -l -t fifo -u
postfix   4850  0.0  0.1  13696  2776 ?        S    12:15   0:00 cleanup -z -t unix -u
postfix   4852  0.0  0.1  13748  2928 ?        S    12:15   0:00 smtp -t unix -u
postfix   4855  0.0  0.1  13748  2928 ?        S    12:15   0:00 smtp -t unix -u
postfix   4856  0.0  0.1  13588  2656 ?        S    12:15   0:00 bounce -z -n defer -t unix -u
root      4858  0.0  0.0   4360   736 pts/0    S+   12:15   0:00 grep postfix
</code>
TEST SERVER
<code>[root@bwStagingTesting sridhar]# ps aux | grep postfix
root      1258  0.0  0.2  12816  2480 ?        Ss   Feb17   0:13 /usr/libexec/postfix/master
postfix   1268  0.0  0.2  13228  2896 ?        S    Feb17   0:07 qmgr -l -t fifo -u
postfix   2158  0.0  0.2  12888  2468 ?        S    Feb17   0:00 tlsmgr -l -t unix -u
postfix   4860  0.0  0.2  12892  2496 ?        S    12:12   0:00 pickup -l -t fifo -u
postfix   4988  0.0  0.2  13036  2604 ?        S    12:15   0:00 cleanup -z -t unix -u
postfix   4990  0.0  0.3  13148  3096 ?        S    12:15   0:00 local -t unix
root      5334  0.0  0.0   4356   728 pts/5    S+   12:15   0:00 grep postfix
</code>
Seems OK to me. I then checked if I am able to telnet on the local host to port 25 and I got the following results
LIVE SERVER
<code>[root@bw sridhar]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
</code>
TEST SERVER
<code>[root@bwStagingTesting sridhar]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.st.biz ESMTP Postfix
ehlo localhost
250-mail.st.biz
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
</code>
I tried telnet to the ip addresses of the respective servers from my laptop. Telnet to the LIVE server resulted in
    telnet: Unable to connect to remote host: Connection refused
However I am able to telnet to the test server.
So I checked if someone is listening on port 25 on the two machines and on the live server I get the following
LIVE SERVER
<code>[root@bw sridhar]# netstat -lnp | grep 25
unix  2      [ ACC ]     STREAM     LISTENING     8125   1341/dovecot        /var/run/dovecot/login/pop3
unix  2      [ ACC ]     STREAM     LISTENING     8425   1433/master         public/cleanup
</code>
TEST SERVER
<code>tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      1258/master
tcp        0      0 :::25                       :::*                        LISTEN      1258/master
unix  2      [ ACC ]     STREAM     LISTENING     8270   1258/master         public/cleanup
unix  2      [ ACC ]     STREAM     LISTENING     8277   1258/master         private/tlsmgr
unix  2      [ ACC ]     STREAM     LISTENING     8281   1258/master         private/rewrite
unix  2      [ ACC ]     STREAM     LISTENING     8285   1258/master         private/bounce
unix  2      [ ACC ]     STREAM     LISTENING     8289   1258/master         private/defer
unix  2      [ ACC ]     STREAM     LISTENING     8293   1258/master         private/trace
unix  2      [ ACC ]     STREAM     LISTENING     8297   1258/master         private/verify
unix  2      [ ACC ]     STREAM     LISTENING     8301   1258/master         public/flush
unix  2      [ ACC ]     STREAM     LISTENING     8305   1258/master         private/proxymap
unix  2      [ ACC ]     STREAM     LISTENING     8309   1258/master         private/proxywrite
unix  2      [ ACC ]     STREAM     LISTENING     8313   1258/master         private/smtp
unix  2      [ ACC ]     STREAM     LISTENING     8317   1258/master         private/relay
unix  2      [ ACC ]     STREAM     LISTENING     8321   1258/master         public/showq
unix  2      [ ACC ]     STREAM     LISTENING     8325   1258/master         private/error
unix  2      [ ACC ]     STREAM     LISTENING     8329   1258/master         private/retry
unix  2      [ ACC ]     STREAM     LISTENING     8333   1258/master         private/discard
unix  2      [ ACC ]     STREAM     LISTENING     8337   1258/master         private/local
unix  2      [ ACC ]     STREAM     LISTENING     8341   1258/master         private/virtual
unix  2      [ ACC ]     STREAM     LISTENING     8345   1258/master         private/lmtp
unix  2      [ ACC ]     STREAM     LISTENING     8349   1258/master         private/anvil
unix  2      [ ACC ]     STREAM     LISTENING     8353   1258/master         private/scache
</code>
I see that the first two lines displayed for the TEST SERVER are missing in the entries for LIVE server. Which means that postfix is not listening on port 25 on the LIVE server This has got me wondering if this could be the reason that the bounces are not reaching the LIVE SERVER but are reaching the TEST server.
Been at it for two days and still haven't found a clue on how to fix this. Any ideas on how I can resolve this?
update : iptable entries
LIVE SERVER
<code>[root@bw sridhar]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
DROP       tcp  --  anywhere             anywhere            tcp flags:!FIN,SYN,RST,ACK/SYN state NEW
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:distinct
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:urd
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pop3
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pop3s
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:imap
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:imaps

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
</code>
TEST SERVER
<code>[root@bwStagingTesting sridhar]# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
DROP       tcp  --  anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
DROP       tcp  --  anywhere             anywhere            tcp flags:!FIN,SYN,RST,ACK/SYN state NEW
DROP       tcp  --  anywhere             anywhere            tcp     flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
ACCEPT     all  --  anywhere             anywhere
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:smtp
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:urd
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pop3
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:pop3s
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:imap
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:imaps
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:distinct
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:munin

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
</code>
update : Verbose iptable listing
<code>[root@bookingwire sridhar]# iptables -L --verbose
Chain INPUT (policy DROP 1662 packets, 103K bytes)
pkts bytes target     prot opt in     out     source               destination
184K  190M ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED
0     0 DROP       tcp  --  any    any     anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/NONE
7   400 DROP       tcp  --  any    any     anywhere             anywhere            tcp flags:!FIN,SYN,RST,ACK/SYN state NEW
0     0 DROP       tcp  --  any    any     anywhere             anywhere            tcp flags:FIN,SYN,RST,PSH,ACK,URG/FIN,SYN,RST,PSH,ACK,URG
2140  128K ACCEPT     all  --  lo     any     anywhere             anywhere
1176 67092 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:http
3   120 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:https
6   360 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:distinct
8   432 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:smtp
1    40 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:urd
2    88 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:pop3
38  2260 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:pop3s
1    40 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:imap
1    40 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:imaps

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 112K packets, 103M bytes)
pkts bytes target     prot opt in     out     source               destination
</code>
update : complete master.cf listing
<code>#
# Postfix master process configuration file.  For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
submission inet n   -   n   -   -   smtpd
   -o smtpd_tls_security_level=encrypt
   -o smtpd_sasl_auth_enable=yes
   -o smtpd_client_restrictions=permit_sasl_authenticated,reject
   -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n   -   n   -   -   smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#628      inet  n   -   n   -   -   qmqpd
pickup    fifo  n   -   n   60  1   pickup
cleanup   unix  n   -   n   -   0   cleanup
qmgr      fifo  n   -   n   300     1   qmgr
#qmgr     fifo  n   -   n   300     1   oqmgr
tlsmgr    unix  -   -   n   1000?   1   tlsmgr
rewrite   unix  -   -   n   -   -   trivial-rewrite
bounce    unix  -   -   n   -   0   bounce
defer     unix  -   -   n   -   0   bounce
trace     unix  -   -   n   -   0   bounce
verify    unix  -   -   n   -   1   verify
flush     unix  n   -   n   1000?   0   flush
proxymap  unix  -   -   n   -   -   proxymap
proxywrite unix -   -   n   -   1   proxymap
smtp      unix  -   -   n   -   -   smtp
# When relaying mail as backup MX, disable fallback_relay to avoid MX loops
relay     unix  -   -   n   -   -   smtp
        -o smtp_fallback_relay=
    #   -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n   -   n   -   -   showq
error     unix  -   -   n   -   -   error
retry     unix  -   -   n   -   -   error
discard   unix  -   -   n   -   -   discard
local     unix  -   n   n   -   -   local
virtual   unix  -   n   n   -   -   virtual
lmtp      unix  -   -   n   -   -   lmtp
anvil     unix  -   -   n   -   1   anvil
scache    unix  -   -   n   -   1   scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
#maildrop  unix  -   n   n   -   -   pipe
#  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# The Cyrus deliver program has changed incompatibly, multiple times.
#
#old-cyrus unix  -   n   n   -   -   pipe
#  flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus     unix  -   n   n   -   -   pipe
#  user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
#uucp      unix  -   n   n   -   -   pipe
#  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# ====================================================================
#
# Other external delivery methods.
#
#ifmail    unix  -   n   n   -   -   pipe
#  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
#
#bsmtp     unix  -   n   n   -   -   pipe
#  flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient
#
#scalemail-backend unix -   n   n   -   2   pipe
#  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store
#  ${nexthop} ${user} ${extension}
#
#mailman   unix  -   n   n   -   -   pipe
#  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
#  ${nexthop} ${user}
</code>
update:postfix listening on 587
<code>[root@bw sridhar]# netstat -lnp | grep master
tcp        0      0 0.0.0.0:587                 0.0.0.0:*                   LISTEN      16536/master
tcp        0      0 :::587                      :::*                        LISTEN      16536/master
unix  2      [ ACC ]     STREAM     LISTENING     152749 16536/master        public/cleanup
unix  2      [ ACC ]     STREAM     LISTENING     152756 16536/master        private/tlsmgr
unix  2      [ ACC ]     STREAM     LISTENING     152760 16536/master        private/rewrite
unix  2      [ ACC ]     STREAM     LISTENING     152764 16536/master        private/bounce
unix  2      [ ACC ]     STREAM     LISTENING     152768 16536/master        private/defer
unix  2      [ ACC ]     STREAM     LISTENING     152772 16536/master        private/trace
unix  2      [ ACC ]     STREAM     LISTENING     152776 16536/master        private/verify
unix  2      [ ACC ]     STREAM     LISTENING     152780 16536/master        public/flush
unix  2      [ ACC ]     STREAM     LISTENING     152784 16536/master        private/proxymap
unix  2      [ ACC ]     STREAM     LISTENING     152788 16536/master        private/proxywrite
unix  2      [ ACC ]     STREAM     LISTENING     152792 16536/master        private/smtp
unix  2      [ ACC ]     STREAM     LISTENING     152796 16536/master        private/relay
unix  2      [ ACC ]     STREAM     LISTENING     152800 16536/master        public/showq
unix  2      [ ACC ]     STREAM     LISTENING     152804 16536/master        private/error
unix  2      [ ACC ]     STREAM     LISTENING     152808 16536/master        private/retry
unix  2      [ ACC ]     STREAM     LISTENING     152812 16536/master        private/discard
unix  2      [ ACC ]     STREAM     LISTENING     152816 16536/master        private/local
unix  2      [ ACC ]     STREAM     LISTENING     152820 16536/master        private/virtual
unix  2      [ ACC ]     STREAM     LISTENING     152824 16536/master        private/lmtp
unix  2      [ ACC ]     STREAM     LISTENING     152828 16536/master        private/anvil
unix  2      [ ACC ]     STREAM     LISTENING     152832 16536/master        private/scache
unix  2      [ ACC ]     STREAM     LISTENING     149905 16103/dovecot       /var/run/dovecot/auth-master

[root@bw sridhar]# telnet localhost 587
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 mail.bookingwire.co.uk ESMTP Postfix
ehlo localhost
250-mail.bookingwire.co.uk
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
</code>
Since Postfix runs as "master" I did grep's for master in netstat. Notice the first two lines its obvious that postfix is listening on port 587. I then telnet to port 587 and verified that my assumption was right. Now what I don't understand is why would it listen on port 587 and how do I change it to listen on port 25
Comment: @MichaelHampton I restarted postfix on the test server and now it doesn't bind to port 25. (Not sure if this info helps in locating the cause). BTW I have also posted a supported query to my hosting services provider to check if they are blocking anything on the firewall. In the meantime will reinstall postfix and dovecot on the test server to see if it miraculously starts working
Comment: You can see that there is nothing listening on port 25 from netstat output. What inet_interfaces do you use on live server? Is there localhost?
Comment: +1 for taking the time to include details and troubleshooting steps
Comment: @stderr my entry in /etc/postfix/main.cf
    inet_interfaces = all
Comment: @stderr Changed the inet_interfaces to localhost restarted postfix and tried telnet from my laptop to the LIVE server. Connection was refused. Changed inet_interfaces to 127.0.0.1. Connection was refused.
Comment: Please post the postfix `master.cf`, also a _complete_ copy of your firewall (you have to use `-v` with iptables).
Answer: Your <code>master.cf</code> doesn't have a configuration line to handle SMTP on port 25. A single line is missing:
<code>smtp      inet  n       -       n       -       -       smtpd
</code>
In my file, this is the first line after the initial comment block.
Comment: Holy S***, I looked at the file atleast 10 times in a day. Didn't notice the missing line. Thanks a ton.
Comment: If you have another question, please ask a new question.
Comment: I am able to telnet to the LIVE servers and connect on port 25 from within the server and from my laptop. However the bounces are still not reaching the LIVE server.

telnet unable to connect to remote host


If $z = f(x, y)$, then why are $\partial_x z$ and $\partial_y z$ functions of x and y also?

Question: Source: Stewart, James. Calculus: Early Transcendentals (6 edn 2007). p. 905.
Stewart doesn't explain the tree diagram beneath. Please explain intuitively and informally.
Comment: If $y = f(x)$, then why is $\partial_x y = f'$ a function of $x$ also? Same question, same answer.
Comment: Please remember that the question title is not part of the question text. Don't assume that anyone reads the title of the question when they look at a question; any information needed to understand the question should be in the text of the question.
Answer: Simply put, the function is defined on a domain, so the derivatives, where they exist, should be defined on that domain as well.
Now, it may be that a function has partial derivatives that are not functions of $x$ and $y$, for instance:
$$f(x,y) = x^2+y^2.$$
However, when we're talking about $\frac{\partial f}{\partial x}$, we want to ensure that we're talking about the same domain as $f$. So if $f : \mathbb{R}\times \mathbb{R} \to \mathbb{R}$, it could be somewhat awkward if we talk about features of the function that aren't also mapping from $\mathbb{R}\times\mathbb{R}$, as well. Now, with the example of the function above, it turns out that one of the co-ordinates in the domain doesn't matter, but in general we don't want to start from that assumption.


Documentation of google docs viewer

Question: Its look weird but i am not getting where is the documentation of google docs viewer to embed in my website. https://docs.google.com/viewer here is link where I can only generate links. Actually i want to increase or remove the timeout check because i cant view files with big sizes. Here is what i am doing right now

and with big files getting following error.
Sorry, it took too long to find the document at the original source. Please try again later.
You can also try to download the original document by clicking here.

Answer: Here is a page with a form that generate a link to the document viewer : https://docs.google.com/gview
[EDIT]  Google may have deprecated this functionnality.
In this page, there is a very minimal documentation that you may already have seen, but I didn't find any other documentation about it, and the search "gview" gave 0 result in developers.google.com.
There are also other similar issues about Joomla or Wordpress plugins using this viewer.
As an alternative to this viewer, if you host these files in Google Drive, you can use the google drive's built-in preview functionnality :

You can easily access to this from any previewed document from Google Drive by clicking on ⋮ then  integrate element.
Comment: Google may have removed this functionallity.  I will edit the comment.  Otherwise, this may be a working example: ``.  Paste this in your URL bar to see if it works for you: `data:text/html,`.
Comment: Sept 2023 - this works.

Documentation of google docs viewer


The columns of AB are linearly dependent. Are the columns of B linearly dependent? show why or why not this would be true.

Question: The columns of AB are linearly dependent. Are the columns of B linearly dependent? show why or why not this would be true or provide an example.
Comment: Let $B$ be the identity matrix, and let $A$ be the $0$ matrix.
Answer: Assuming $A$ and $B$ are matrices, no because if $A$ is the zero matrix, and $B$ is any invertible matrix, $AB=0$ and therefore has linearly dependent columns but $B$ has linearly independent columns by Invertible Matrix Theorem.


How do I watch for VidoeView onStop() action?

Question: I would like to trigger an event when my VideoView is done playing?  How woudl I do this? can you show me an example or direct my to some resources?
Im thinking something like this.
if(!videoView.isplaying()){
//trigger event
}

or

public void onStop(){

//trigger event

}

Answer: If you want to know when play has completed, you would use VideoView.setOnCompletionListener().
myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){

    @Override
    public void onCompletion(MediaPlayer mp){

       // do on completion stuff.
    }
});

If you want to detect error cases, you would use VideoView.setOnErrorListener() instead.


Need gameover activity

Question: I'm new to android, and I'm trying my best to create a game. I'm trying to create a gameover screen for my game, and I though the best way to do that was to create an activity for a gameover screen. However, I'm not sure how to go about doing this.The problem seems to be that I cannot create an intent anywhere other than the activity class. So I can't see when the game should end, and then create a new activity without it being in the activity class. So I'm having trouble connecting my game model to my activity class, so that when the player dies, it would trigger a gameover activity. Where in my activity class should I put this information?
Answer: You would place code such as (assuming your activity is GameOverScreen extends Activity):
Intent gameOverScreen = new Intent(this, GameOverScreen.class);
startActivity(gameOverScreen);

To do so from outside the activity (since startActivity() is a public method of the Activity class), you'd just do like this, using the instance of your game activity that I call gameScreen in this example:
Intent gameOverScreen = new Intent(gameScreen, GameOverScreen.class);
gameScreen.startActivity(gameOverScreen);

You should probably have a reference to the instance of your game activity stored to the model as a Context object at least for resources.
Answer:   </activity>
             <activity android:name=".gameoveractivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="name-of-activity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

Add this in your Manifest.xml...
Then from the code invoke this activity like this
  Intent i = new Intent("name-of-activity-you-declared-in-the-manifest");
          this.startActivity(i);

I guess you should put this after reaching conditions for game over. Let's say after loosing 3 lives, you get game over activity.
If you are doing game over with something like TRY AGAIN. Then you should use this.startActivityForResult(i, result). And then, override the onActivityResult() method in the class from where you call the game over activity.
Comment: But where do I call that though? That would have to be in the gameModel, and I cannot make intents in the game model, only in the game activity.
Comment: How are you structuring your game? The game should, in some way or another, be inside an activity: not a model.
Comment: Call it from the current activity. Or switch to activity where you think game over should be called and call it.
Comment: I have a class called gameCall which has an MVC framework. GameCall is the gameactivity. The model the view, the gamecontroller, and the gameloop, are all done in the gameCall.
Comment: Paste the code where you have stated conditions for game over. :)
Comment:  public void gameOver(long t){
  if(levelLose){

   entities.clear();
   entityDraw.clear();
   background=new Backgrounds(2,context.getResources());

   updateLevel();

  }else{
   entities.clear();
   entityDraw.clear();
   background=new Backgrounds(3,context.getResources());
   updateLevel();
  }

 }
Comment: `public void gameOver(long t){
  if(levelLose){

   entities.clear();
   entityDraw.clear();
   background=new Backgrounds(2,context.getResources());

   updateLevel();

  }else{
   entities.clear();
   entityDraw.clear();
   background=new Backgrounds(3,context.getResources());
   updateLevel();
  }

 }`

Need gameover activity


Let $a+b+c=3,$ then prove$\sqrt[3]{\frac{a+b}{5ab+4}}+\sqrt[3]{\frac{c+b}{5cb+4}}+\sqrt[3]{\frac{a+c}{5ac+4}}\ge \sqrt[3]{6}$

Question: Problem
If $a,b,c\ge 0: a+b+c=3,$ then $$\sqrt[3]{\frac{a+b}{5ab+4}}+\sqrt[3]{\frac{c+b}{5cb+4}}+\sqrt[3]{\frac{a+c}{5ac+4}}\ge \sqrt[3]{6}.\tag{1}$$
I came up with when trying to prove $$\frac{a+b}{5ab+4}+\frac{c+b}{5cb+4}+\frac{a+c}{5ac+4}\ge \frac{2}{3},$$which is not hard by $uvw$ method.
I'm looking for a nice proof $(1).$ It might be useful if the solver give motivate path.
Thank you for helping.
Comment: What is uvw method ?
Comment: Where is this problem coming from? Math Olympiad?
Comment: @Tuong Nguyen Minh See here: https://artofproblemsolving.com/community/c6h278791 If you know Russian, so I am ready to give a link to my paper about it.
Answer: Some thought.
We use the isolated fudging.
It suffices to prove that
$$\sqrt[3]{\frac{a + b}{6(5ab + 4)}}
\ge \frac{55(a^2 + b^2) + 254ab + 385c(a + b)}{110(a^2 + b^2 + c^2) + 1024(ab + bc + ca)}.\tag{1}$$
(Note: Taking cyclic sum on (1), we get the desired inequality.)
(1) is true which is verified by Mathematica.
Comment: I agree. Some problem with equality $(0,t,t)$ is even harder to find.
Comment: For example: Let $a,b,c > 0 : a+b+c=3.$ Prove $$\sqrt{\dfrac{a+1}{a+b}}+\sqrt{\dfrac{b+1}{b+c}}+\sqrt{\dfrac{c+1}{c+a}} \ge 3.$$
Fact: For all $x,y,z>0$ satisfying $$xyz\ge \dfrac{5\sqrt{3}}{9}; x^2+y^2+z^2+\frac{33}{12}xyz\ge \frac{69}{12},$$then $x+y+z\ge 3.$
By denoting $$x=\sqrt{\dfrac{a+1}{a+b}};y=\sqrt{\dfrac{b+1}{b+c}};z=\sqrt{\dfrac{c+1}{c+a}},$$which the Fact gives the desired result.
Comment: @TATAbox Your trick is helpful. Actually, I also think of similar things, but it is not easy to create appropriate form.
Comment: @TATAbox Yes, beauty in the inequalities.
Comment: It is nice as usual ! +1
Comment: @TATAbox Thanks.
Comment: I found a proof using CY3 method
Comment: @TATAbox Nice. Is it simple?
Comment: It is calculus proof with contradiction method, uvw. You can see it: https://math.stackexchange.com/questions/2745991/prove-this-inequality-%ce%a3-cyc-sqrt-fracab3c-ge-frac32-with-abc?noredirect=1
Comment: By the relatives between 3 yields: $x^2y^2+y^2z^2+z^2x^2; (xyz)^2; x+y+z$ we just need to prove a inequality without radicals. The last is the useful uvw.
Comment: @TATAbox It is nice.
Comment: sometimes It helps to attained a proof which we can kill easily by uvw. I am writing it as a demo of this method: Contradiction on three yields.
Comment: @TATAbox It is a common trick.
Comment: yes, contradiction is a common method. For example, https://math.stackexchange.com/questions/4740147/prove-frac1-sqrt5a4-frac1-sqrt5b4-frac1-sqrt5c4-geq1-f?rq=1
Michael Rozenberg gave a proof by using contradiction method. We can use it in a "immediate" way without contradicting directly to the original condition.
Comment: @TATAbox I mean the method of letting $x = ..., y = ..., z = ...$ and finding the relation among $x, y, z$ in your answer here. I used some times.
Comment: @TATAbox For example, Let $a, b, c > 0$ with $a + b + c = 3$. Prove that
$$\left(\frac{a+1}{a+b} \right)^{\frac25}+\left(\frac{b+1}{b+c} \right)^{\frac25}+\left(\frac{c+1}{c+a} \right)^{\frac25} \ge 3.$$

**Fact 1**: Let $x, y, z \ge 0$ such that $xyz \ge \frac{25}{27}$
and $3xyz - 2(xy + yz + zx) + 2(x + y + z) = 3$. Then
$$x^{2/5} + y^{2/5} + z^{2/5} \ge 3.$$

Let
$$x = \frac{a+1}{a+b}, y = \frac{b+1}{b+c}, z = \frac{c+1}{c+a}.$$
Then
$$xyz \ge \frac{25}{27}$$
and
$$3xyz - 2(xy + yz + zx) + 2(x + y + z) - 3 = 0.$$

By Fact 1, the desired result follows.
Comment: It is nice, indeed. I also use this way to prove Quykhtn's problem (where $2/5$ is replaced $1/2$)
Comment: @TATAbox Nice. In my example, $xyz \ge \frac{25}{27}$ is necessary. It is the interesting point. If we solve the system $x = \frac{a+1}{a+b}, y = \frac{b+1}{b+c}, z = \frac{c+1}{c+a}$, we get $3xyz - 2(xy + yz + zx) + 2(x + y + z) = 3$. However, $x^{2/5} + y^{2/5} + z^{2/5} \ge 3$ is not true without additional constraint $xyz \ge \frac{25}{27}$. In some problems, we don't need this additional constraint.
Comment: Yes, it makes inequality becomes more interesting!
Answer: A full TATA box's solution.

Lemma.Let $x$, $y$ and $z$ be non-negative numbers such that:
$$x^3y^3+x^3y^3+y^3z^3+\frac{537}{64}x^3y^3z^3\geq\frac{729}{64}.$$
Prove that:
$$x+y+z\geq3.$$

Let $x+y+z<3,$ $x=kp$, $y=kq$ and $z=kr$, where $k>0$ and $p+q+r=3$.
Thus, $$kp+kq+kr<3=p+q+r,$$ which gives $k<1$ and we obtain:
$$\frac{729}{64}\leq x^3y^3+x^3y^3+y^3z^3+\frac{537}{64}x^3y^3z^3<k^6(p^3q^3+p^3r^3+q^3r^3)+k^9\frac{537}{64}p^3q^3r^3<$$
$$<p^3q^3+p^3r^3+q^3r^3+\frac{537}{64}p^3q^3r^3,$$ which is a contradiction because we'll prove now that:
$$p^3q^3+p^3r^3+q^3r^3+\frac{537}{64}p^3q^3r^3\leq\frac{729}{64}$$ for any non-negatives $p$, $q$ and $r$ such that $p+q+r=3$.
Indeed, let $p+q+r=3u$, $pw+pr+qr=3v^2$ and $pqr=w^3$.
Thus, $u=1$ and we need to prove that:
$$27v^6-27uv^2w^3+3w^6+\frac{537}{64}w^9\leq\frac{729}{64}$$ or $f(w^3)\geq0,$ where
$$f(w^3)=243u^9-179w^9-u^3(9v^6-9uv^2w^3+w^6).$$
Easy to see that $f$ is a concave function.  But the concave function gets a minimal value for an extremal value of $w^3$,which by $uvw$ (https://artofproblemsolving.com/community/c6h278791) happens in the following cases.

$w^3=0$.

Let $r=0$.
Thus, by AM-GM  $$p^3q^3+p^3r^3+q^3r^3+\frac{537}{64}p^3q^3r^3=p^3q^3\leq\left(\frac{p+q}{2}\right)^6=\frac{729}{64}.$$

Two variables are equal.

Let $q=p$ and $r=3-2p$, where $0\leq p\leq\frac{3}{2}.$
Thus, it remains to prove that:
$$p^6+2p^3(3-2p)^3+\frac{537}{64}p^6(3-2p)^3\leq\frac{729}{64}$$ or
$$(p-1)^2(3-2p)(81+216p+387p^2+198p^3+537p^4+716p^5-716p^6)\geq0,$$ which is true for $0\leq p\leq \frac{3}{2}.$
Id est, by using lemma, it's enough to prove that:
$$128\sum_{cyc}\frac{(a+b)(a+c)}{(5ab+4)(5ac+4)}+4833\prod_{cyc}\frac{a+b}{5ab+4}\geq72.$$
Now, let $a+b+c=3u$, $ab+ac+bc=3v^2$ and $abc=w^3$.
Thus, we need to prove that
$$128\sum_{cyc}(a+b)(a+c)(5bc+4)+4833\prod_{cyc}(a+b)\geq72\prod_{cyc}(5ab+4)$$ and we see again that we need to prove $g(w^3)\geq0,$ where $g$ is a concave function(the LHS is a linear of $w^3$ and a coefficient before $w^6$ in the RHS is equal to $72\cdot5^3>0$.
Thus, it's enough to check two following cases.

$c=0$.

We need to prove here $$128(3a\cdot4+3b\cdot4+ab(5ab+4))+4833\cdot3ab\geq72\cdot4\cdot4(5ab+4)$$ or
$$128ab(5ab+4)+4833\cdot3ab\geq72\cdot4\cdot4\cdot5ab,$$ which is obvious.

$b=a$ and $c=3-2a,$ where $0\leq a\leq1.5$.

Here we obtain:
$$(a-1)^2a(9251+5460a+6000a^2-6000a^3)\geq0,$$ which is true for $0\leq a\leq1.5$.
Answer: Let $\;f(x,y)=\sqrt[\Large 3]{\dfrac{x+y}{4+5x y}},\;$ then
$$F(a, b, c)=f(a,b)+f(b,c)+f(c,a),$$
$$\dfrac{\partial}{\partial x}\,f(x,y) =\dfrac13 \dfrac{}{}\sqrt[\Large3]{\dfrac{5xy+4}{x+y}}^2\, \dfrac{4+5xy-5y(x+y)}{(4+5xy)^2}
=\dfrac13\dfrac{4-5y^2}{\sqrt[\Large 3\,]{(4+5xy)^4(x+y)^2}\mathstrut}
=g(x,y),$$
$$\dfrac{\partial}{\partial y}\,f(x,y) = g(y,x),$$
$\color{brown}{\textbf{The inner stationary points.}}$
The inner stationary points can be found from the system
$$\begin{cases}
\dfrac{\partial}{\partial a}\,(F(a,b,c)+\lambda(3-a-b-c))=g(a,b)+g(a,c)-\lambda=0\\[4pt]
\dfrac{\partial}{\partial b}\,(F(a,b,c)+\lambda(3-a-b-c))=g(b,a)+g(b,c)-\lambda=0\\[4pt]
\dfrac{\partial}{\partial c}\,(F(a,b,c)+\lambda(3-a-b-c))=g(c,b)+g(c,a)-\lambda=0\\[4pt]
\dfrac{\partial}{\partial \lambda}\,(F(a,b,c)+\lambda(3-a-b-c))=3-a-b-c=0.
\end{cases}$$
or
$$\begin{cases}
\dfrac{4-5b^2}{\sqrt[\Large 3\,]{(4+5ab)^4(a+b)^2}\mathstrut}
+\dfrac{4-5c^2}{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}=\lambda\\[4pt]
\dfrac{4-5a^2}{\sqrt[\Large 3\,]{(4+5ab)^4(a+b)^2}\mathstrut}
+\dfrac{4-5c^2}{\sqrt[\Large 3\,]{(4+5bc)^4(b+c)^2}\mathstrut}=\lambda\\[4pt]
\dfrac{4-5b^2}{\sqrt[\Large 3\,]{(4+5bc)^4(b+c)^2}\mathstrut}
+\dfrac{4-5a^2}{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}=\lambda\\[4pt]
a+b+c=3
\end{cases}$$
After eliminating of $\lambda$ we get the overdefined system
$$\begin{cases}
\dfrac{5(a^2-b^2)}{\sqrt[\Large 3\,]{(4+5ab)^4(a+b)^2}\mathstrut}
+(4-5c^2)\left(\dfrac1{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}
-\dfrac1{\sqrt[\Large 3\,]{(4+5bc)^4(b+c)^2}\mathstrut}\right)=0\\[4pt]
\dfrac{5(b^2-c^2)}{\sqrt[\Large 3\,]{(4+5bc)^4(b+c)^2}\mathstrut}
+(4-5a^2)\left(\dfrac1{\sqrt[\Large 3\,]{(4+5ab)^4(a+b)^2}\mathstrut}
-\dfrac1{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}\right)=0\\[4pt]
\dfrac{5(c^2-a^2)}{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}
+(4-5b^2)\left(\dfrac1{\sqrt[\Large 3\,]{(4+5bc)^4(b+c)^2}\mathstrut}
-\dfrac1{\sqrt[\Large 3\,]{(4+5ab)^4(a+b)^2}\mathstrut}\right)=0\\[4pt]
a+b+c=3,
\end{cases}$$
If $\;a>b>c>0,\;$ then

$\;(4+5ca)^4(c+a)^2 > (4+5bc)^4(b+c)^2\;$ and $\;4-5c^2>0.$
$\;(4+5ab)^4(a+b)^2 > (4+5ca)^4(c+a)^2\;$ and $\;4-5a^2>0.$
$\;(4+5ab)^4(a+b)^2 > (4+5ca)^4(c+a)^2\;$ and $\;4-5b^2>0.$

If $\;0<a<b<c,\;$ then

$\;(4+5ca)^4(c+a)^2 < (4+5bc)^4(b+c)^2\;$ and $\;4-5c^2>0.$
$\;(4+5ab)^4(a+b)^2 < (4+5ca)^4(c+a)^2\;$ and $\;4-5a^2>0.$
$\;(4+5ab)^4(a+b)^2 < (4+5ca)^4(c+a)^2\;$ and $\;4-5b^2>0.$

Both of the variants mean that $\;a<1,b<1,c<1,\;$ i.e. $a+b+c<3,$ in contradiction with the last equation of the system.
If WLOG $\;a=b,\;$ then
$$\begin{cases}
\dfrac{5(a^2-c^2)}{\sqrt[\Large 3\,]{(4+5ac)^4(a+c)^2}\mathstrut}
+(4-5a^2)\left(\dfrac1{\sqrt[\Large 3\,]{(4+5a^2)^4(2a)^2}\mathstrut}
-\dfrac1{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}\right)=0\\[4pt]
\dfrac{5(c^2-a^2)}{\sqrt[\Large 3\,]{(4+5ca)^4(c+a)^2}\mathstrut}
+(4-5a^2)\left(\dfrac1{\sqrt[\Large 3\,]{(4+5ac)^4(a+c)^2}\mathstrut}
-\dfrac1{\sqrt[\Large 3\,]{(4+5a^2)^4(2a)^2}\mathstrut}\right)=0\\[4pt]
2a+c=3,
\end{cases}$$
$$\begin{cases}
\dfrac{10a^2-5c^2-4}{\sqrt[\Large 3\,]{(4+5ac)^4(a+c)^2}\mathstrut}
+\dfrac{4-5a^2}{\sqrt[\Large 3\,]{(4+5a^2)^4(2a)^2}\mathstrut}=0\\[4pt]
2a+c=3,
\end{cases}$$
$$(10a^2-5c^2-4)^3(4+5a^2)^4(2a)^2=(5a^2-4)^3(4+5ac)^4(a+c)^2,$$
$$(10a^2-5(3-2a)^2-4)^3(4+5a^2)^4(2a)^2=(5a^2-4)^3(4+5a(3-2a))^4(3-a)^2,$$
$$(-10a^2+60a-49)^3(4+5a^2)^4(2a)^2=(5a^2-4)^3(-10a^2+15a+4)^4(3-a)^2,$$
with the roots in $(0,3)$
$$\dbinom{a}{F(a,a,3-2a)}\in\left\{\approx\dbinom{0.05342847}{2.00156},\dbinom{1}{\sqrt[\Large3]6}\right\}.$$
Therefore, the least inner value of $F$ is $\sqrt[\Large 3]6.$
$\color{brown}{\textbf{The edges.}}$
Since
$$\;F(3,0,0)=2\,\sqrt[\Large3]{\dfrac34}=\sqrt[\Large3]6$$
and
$$\;F\left(\dfrac32,\dfrac32,0\right)=\sqrt[\Large3\,]{\dfrac3{4+\dfrac{45}4}}
+2\sqrt[\Large3]{\dfrac38}=\sqrt[\Large3]{\dfrac{12}{61}}+\sqrt[\Large3]3 >\sqrt[\Large3]6,$$
then
$$\color{green}{\mathbf{F(a,b,c)\ge \sqrt[\Large3]6}}$$
at the task constraints.
Answer: Some thoughts.

Firstly, we'll prove the following inequality as a lemma.
Lemma. For all non-negative real numbers $x,y,z$ satisfying$$x^3y^3+y^3z^3+z^3x^3+\frac{537}{64}(xyz)^3\ge \frac{729}{64},$$then $$x+y+z\ge 3.$$
Equality holds at $(x,y,z)=(1,1,1);\left(0,\dfrac{3}{2},\dfrac{3}{2}\right)$ and permutations.

Now, let $$x=\sqrt[3]{\frac{9}{2}}.\sqrt[3]{\frac{a+b}{5ab+4}};y=\sqrt[3]{\frac{9}{2}}.\sqrt[3]{\frac{c+b}{5cb+4}};z=\sqrt[3]{\frac{9}{2}}.\sqrt[3]{\frac{a+c}{5ac+4}}.$$The original problem is rewritten according to $x,y,z$ $$x+y+z\ge 3,$$which the lemma says that it's enough to prove $$\frac{81}{4}\sum_{cyc}\frac{(a+b)(b+c)}{(5ab+4)(5bc+4)}+\frac{391473}{512}\frac{(a+b)(b+c)(c+a)}{(5ab+4)(5bc+4)(5ca+4)}\ge \frac{729}{64}.$$
From now, we can use $uvw.$
About $uvw,$ see here.
Answer: Calling $f(a,b) = \sqrt[3]{\frac{a+b}{5ab+4}}$ and $F(a,b,c) = f(a,b)+f(b,c)+f(c,a)$ we have
$$
\cases{
f(a,b)\le F(a,b,c)\\
f(b,c)\le F(a,b,c)\\
f(c,a)\le F(a,b,c)
}
$$
so the minimum will be found amongst the problems
$$
\cases{
\min_{a,b}F(a,b,0),\ \text{s.t.}\ \ a+b=3,a \ge 0,b\ge 0\\
\min_{b,c}F(0,b,c),\ \text{s.t.}\ \ b+c=3,b \ge 0,c\ge 0\\
\min_{a,c}F(a,0,c),\ \text{s.t.}\ \ a+c=3,a \ge 0,c\ge 0\\
}
$$
as the problem has nice symmetry we can follow with
$$
\min_{a,b}\sqrt[3]{\frac{a+b}{5ab+4}}+\sqrt[3]{\frac{b}{4}}+\sqrt[3]{\frac{a}{4}}\ \ \text{s.t.}\ \ \ a+b=3, a\ge 0, b\ge 0
$$
or
$$
\min_a\sqrt[3]{\frac{3}{5a(3-a)+4}}+\sqrt[3]{\frac{3-a}{4}}+\sqrt[3]{\frac{a}{4}}\ \ \text{s.t.}\ \ a \ge 0
$$
We have solutions at
$$
\cases{
a = 3, b = c = 0\\
a = 0, b = 3, c= 0\\
a = 0, b= 0, c=3\\
a = b = c = 1\\
}
$$
with value $\sqrt[3]{6}$. The last solution cannot be detected by this procedure.


Swift 2: why elapsed var is said being left immutable value?

Question: In the following code snippet I've got this compiler error which I don't understand: "Left side of mutating operator has immutable type 'CGFloat'"
func getElapsed(now now: CGFloat, start: CGFloat) -> String {

    var elapsed = now - start

    let day  = Int(elapsed / (24 * 60 * 60 * 1000));    elapsed -=  day * 24 * 60 * 60 * 1000
    let hour = Int(elapsed / (     60 * 60 * 1000));    elapsed -=      hour * 60 * 60 * 1000
    let min  = Int(elapsed / (          60 * 1000));    elapsed -=            min * 60 * 1000
    let sec  = Int(elapsed /                 1000);     elapsed -=                 sec * 1000

    return "\(day) days, \(hour) hours, \(min) mins, \(sec) secs, \(elapsed) millis"
}

Comment: since day is in int and inferred type to elapsed will be on Float...so you are getting the error...try casting the day into CGFloat
Comment: Lol. True! The error message did misled me. Add in the answer so that I can valid it.
Comment: It's more efficient to declare `elapsed` as `Int` with `Int(now - start)` and remove all other `Int` conversions.
Answer: I wouldn't give up on the Ints so fast. Note that this is what gives you the net days in Integer, so then you can deduct them from the overall accumulated elapsed and get a remainder that holds the hours, mins, and so on.
If you let the Int of and everything will be in float you'll miss the point (also in cases of high elapsed value you might get negatives)
You should keep the Ints. On the minus operation - just cast the "day" / "hour"... into CGFloat
see code :
func getElapsed(now now: CGFloat, start: CGFloat) -> String
{
    var elapsed = now - start

    let day : Int = Int(elapsed  / (24 * 60 * 60 * 1000)); elapsed -=  CGFloat(day)  * 24 * 60 * 60 * 1000
    let hour: Int = Int(elapsed  / (     60 * 60 * 1000)); elapsed -=  CGFloat(hour) * 60 * 60 * 1000
    let min : Int  = Int(elapsed / (          60 * 1000)); elapsed -=  CGFloat(min)  * 60 * 1000
    let sec : Int  = Int(elapsed /                 1000);  elapsed -=  CGFloat(sec)  * 1000

    return "\(day) days, \(hour) hours, \(min) mins, \(sec) secs, \(elapsed) millis"
}

Usage Example:
getElapsed(now: 5000000000, start:100);  // = 57d, 20h, 53min, 19sec, 900ml
Tested successfully on Playground 7.2


C++, does absolute address of an object always remain constant until released?

Question: Object1 * test= new Object1();

does "test" have absolute address on RAM or an absolute address in a virtual memory which has a relative starting point to RAM's zero adress?
An example could be, in a very fragmented memory I started many applications each allocating and deallocating many times for 10 hours, and one of the applications is a RAM error checking and benchmarking one. Could it test all RAM addresses or it just runs on a limited area? If it reaches all RAM, then how is OS is able to protect an app from other apps besides moving its objects? Especially when streaming non-pinned array from pci-e and to pci-e.
Comment: No, the object will not be automatically relocated even if the application runs out of memory.
Comment: @CaptainObvlious then when I delete object, could release whole page and another app can acquire that info with a "new"?
Comment: Once you delete the object it no longer exists so there is no object to relocate.
Answer: Most OSes use virtual addressing, so the address seen by your program is largely independent from the physical address of the RAM itself.
Some do, however, have special functions available to allocate physical memory that has a fixed physical address. For example, on Windows you can use AllocateUserPhysicalPages to allocate some physical pages (which you can then map to/unmap from virtual addresses).
This will still only let you test a limited area though. It'll try to allocate a number of physical pages, and succeed if possible--but there are also (for example) parts of the kernel that get mapped to particular memory locations at boot, and stay there until shut down (and no method is provided to ask them to move).
Comment: I don't know of any BIOS that would let you disable virtualization (it's part of the CPU, so it's mostly not under BIOS control), but if you could it would prevent most OSes from booting.
Comment: You mean there are unusable-forever parts that serves hardware components? So ram-tester software doesn't test those parts?
Comment: Not necessarily serving hardware components. Just for one obvious example, things wouldn't work so well if the code that handled page faults had itself been paged out to disk. Some RAM testers run without any OS present, specifically to give them access to all the hardware.
Comment: What if I disable virtualization from bios settings?
Answer: It remains the same address in the virtual memory space. Which is different than the physical memory space - remember, that's what paging file is for, to be able to allocate more memory in total than the total available physical memory. Also, two different applications can get the same (virtual) memory address by calling new/malloc at the same time (but they will be indeed different addresses in the physical memory, if both are paged in at the same time).
That also means, that actually implementing an application, which tests physical memory is not trivial in system which virtualizes memory (basically all modern systems like windows, Linux etc.). And that is why many memory checking applications (like Memtest etc.) run from a bootable drive, to be able to access and utilize the physical memory directly.
Btw. note that Linux has a feature called "over-committing" (usually enabled by default), which means, that new/malloc can return a "valid" object address, but which does not correspond to any physical location at all (i.e. not yet "truly" allocated). And the memory is only allocated when something is actually written to that memory area.


Is RealPath safe?

Question: <?php
if (preg_match('/^[a-z0-9]+$/', $_GET['p'])) {
$page = realpath('pages/'.$_GET['p'].'.php');
$tpl = realpath('templates/'.$_GET['p'].'.html');
if ($page && $tpl) {
    include $page;
    include $tpl;
} else {
    include('error.php');
}
}
?>

How safe would you say this is?
Comment: \w matches alphanumerics and _, using it would make a different pattern to the one intended
Comment: Are you paranoid? http://stackoverflow.com/questions/524908/dynamic-include-safety http://stackoverflow.com/questions/536688/include-safety
Answer: I use this for a template file, so it can include "pages" instead of having to clutter a single file with tons of functions/strings/switch-cases/elseifs (take your pick) or create tons of files with the same layout.
It checks the realpath of the directory includes should be in and realpath of the file that is to be included, if the realpath of the file starts with the include directory, it is allowed to be included.
<?
#If you're worried about funky characters messing with stuff, use this
#preg_replace("/[^A-Za-z0-9_\-]+/","",$str);

if (isset($_REQUEST['page'])) {
    $path=realpath("../inc/page").DIRECTORY_SEPARATOR;
    $full_page=realpath($path.$_REQUEST['page'].".php");
    if (file_exists($full_page)&&(strpos($full_page,$path)===0)) {
        include($full_page);
    } else {
        echo "FAILED";
    }
}
?>

Answer: Well, actually it realpath in this case doesn't provide any security. Actually it that case it serves no purpose at all, as include internally will expand the path. Your security here actually depends on preg_match. Note however, that regex you're using won't allow you to use an any page with upper case letter, with underscore or dash.
Anyhow, I don't think that including files based on parameters passed in request is good idea. There is something wrong with your design if you need that.
Comment: AllowEncodedSlashes is only about path parts ($_SERVER['PATH_INFO']); encoded slashes will still come though fine in the query string and hence $_GET[].
Answer: realpath doesn't help you at in this instance, as include can resolve the page path to the same file, no matter whether it is realpath'd or the original relative. It 'seems' to be valid, but I wouldn't trust that piece of code personally. I'm sure someone figures a neat way to inject a null-character to the input, wreaking havoc to the string termination.
What you need to do instead, to be safe, is keep a whitelist (or blacklist, if it happens to suit better, but prefer whitelists) of all allowed inputs/pages.
Answer: It seems to be safe....
But not efficient.
In MVC you have the controller and view dirs preset and pre known. No point in doing a stat to check if view/controller exists.
Answer: realpath() will actually have some effect in this case as it'll return FALSE if the target file does not exits. But as the other posters already said - this will not add any security to the code.
It's rather a way of error-handling in case the designated files  do not exist.
Answer: Better run basename() on $_GET['p']. No directory traversal attacks for sure.
Answer: I cannot comment on the PHP realpath, but if it's just a wrapper for the system's realpath function then one thing to be aware of: on some systems (eg, Solaris), if the process receives a signal while realpath is executing it'll return the empty string ... in which case, you'd have to ensure your code is setup to handle that type of situation (unless the PHP implementation resolves that particular dilemma for you)

Is RealPath safe?


Help with a definite integral of the type $\sqrt{1-A \tan^2 x}$

Question: I am at a loss to evaluate the following integral:
$$
I=\frac{1}{\pi}\displaystyle\int_{q_1}^{q_2} dq\,\sqrt{2m(E-V(q))}
$$
where $V(q)=U\tan^2(\alpha q)$, $U>0$ and $V(q_1)=V(q_2)=E$.  (Thus the integrand vanishes at the endpoints.)
This integral is the action for the potential $V(q)$ in the action-angle formalism of classical mechanics.  The answer is given as
$$
I=\frac{1}{\alpha}\left(\sqrt{2m(E+U)}-\sqrt{2mU}\right)\, .
$$
Mathematica will spit out an answer for the indefinite integral in terms of $\arcsin$ and $\hbox{arctanh}$ but it seems so far from what the answer is that I get no insight into the solution.
The usual tricks - including trig substitutions and various Euler substitutions - do not seem to work.  Since the integrand contains a square, I looked at breaking the integrand to the form $\sqrt{(A-B\tan(\alpha q))(A+B\tan(\alpha q))}$ but this doesn't seem to improve the situation.
I tried using a complex substitution since Mma tells the antiderivative is expressible as an arctanh but that got me nowhere.
I thought about trying some version of Leibnitz's rule for definite integrals whose limits are functions of differential variables and take advantage of the property that the integral vanishes at the endpoint, but to no avail.
I suspect there might be a very specific trick which is not very well known.  More probably it's a multistep process with several sequential substitutions which are not immediately obvious.
I'm stuck and I'll take any serious hint towards the solution.
Comment: I suspect the arctanh is a bit of a red herring: it's really an arctan, but with the complex constant $\sqrt{-A}$.
Comment: yes I suspected Mma "ran home to Mamma" and tried to go with $\sqrt{1+\tilde A \tan^2(x)}$ by "inserting an i" in the argument, since the form with the $+$ sign is much more common.
Comment: Yes, Mathematica does need massaging occasionally to get the *useful*, as opposed to just *right* answer. Can't rely on just computers to distinguish between seismic anomalies and Russian submarines, after all. You *could* use a complex substitution $z=e^{2iu}$ after getting rid of the square root to compute the $\cos^2{u}/(A+\sin^2{u})$ integral using residues, but by that point it just introduces yet more nasty algebra.
Comment: @Chappers : yes this was one of the fruitless avenues I initially tried.
Answer: I'm just going to focus on the form you give in the title, since you can clearly reduce to this form by linear substitution, factorisation and defining $A=U/E$.
Quick and dirty answer
The substitution you want is
$$ x = \arctan{\left( \frac{v}{\sqrt{A(1+v^2)}} \right)}, $$
which changes the integral to
$$ I = \int_{-\arctan{(A^{-1/2})}}^{\arctan{(A^{-1/2})}} \sqrt{1-A\tan^2{x}} \, dx = \int_{-\infty}^{\infty} \frac{\sqrt{A}}{(1+v^2)(A+(1+A)v^2)} \, dv, $$
which easily expands into partial fractions and gives the answer you want, i.e.
$$ I = \pi(\sqrt{1+A}-\sqrt{A}). $$
More helpful answer
The limits on the original form of $I$ given above should be clear: they are, modulo $2\pi$, the only places we can take so that the integrand vanishes while the area enclosed is positive and finite. The obvious thing to do is get rid of the tangent function, so put $x=\arctan{(y/\sqrt{A})}$, to deal with the factor of $A$. Then $dx=\sqrt{A}/(A+y^2) \, dy$, and the integral becomes
$$ I=\sqrt{A}\int_{-1}^1 \frac{\sqrt{1-y^2}}{A+y^2} \, dy. $$
We still can't really do this, but at least the square root now looks familiar: to get rid of it, take $y=\sin{u}$, $dy=\cos{u} \, du$,
$$ I=\sqrt{A}\int_{-\pi/2}^{\pi/2} \frac{\cos^2{u}}{A+\sin^2{u}} \, du, $$
with no ambiguity in taking the square root since cosine is positive on the interval of integration. We instinctively want to use the double-angle formula here, but it is actually better to just go straight for a $u=\arctan{v}$ substitution: we have by Pythagoras
$$ du = \frac{dv}{1+v^2}, \quad \sin^2{u} = \frac{v^2}{1+v^2}, \quad \cos^2{u} = \frac{1-v^2}{1+v^2}, $$
and so the integral reduces to the form given above.
Edit: The antiderivative
Unwinding the substitution gives $x=\sqrt{A}\tan{x}/\sqrt{1-A\tan^2{x}}$, which we can reinsert into the antiderivative
$$ \sqrt{A+1}\arctan{\frac{\sqrt{A+1}}{\sqrt{A}}v} - \sqrt{A}\arctan{v} $$
to find the extremely memorable (!) antiderivative
$$ \int \sqrt{1-A\tan^2{x}} \, dx = \sqrt{A+1}\arctan{\left( \frac{\sqrt{A+1}\tan{x}}{\sqrt{1-A\tan^2{x}}} \right)} - \sqrt{A}\arctan{\left( \frac{\sqrt{A}\tan{x}}{\sqrt{1-A\tan^2{x}}} \right)}. $$
Joy of joys, we notice that taking $\sqrt{1-A\tan^2{x}} \downarrow 0$ for $\tan{x} \lessgtr 0$ also gives the right answer (remembering to include both positive and negative endpoints).
Comment: Nicely done and many thanks!
Comment: extremely memorable: I like it!!!


Minimum value of $\sum_{1\le i \lt j \le 2022} a_ia_j $

Question: Hello how can I find the minimum value of $$\sum_{1\le i \lt j \le 2022} a_ia_j $$ Where $ a_i $ and$  a_j $  are -1 or 1?
My thought was that the number of -1 and 1 (so 1011 -1's and 1011 1's) should be same but I'm not sure if that is right.
Comment: Hello, welcome to Math.SE. Your question is phrased as an isolated problem, without any further information or context. This does not match [many users' quality standards](http://goo.gl/mLWc8), so it may attract downvotes, or be closed. To prevent that, please [edit] the question. [This](http://goo.gl/PlJyVQ) will help you recognise and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
Comment: Expand the product $\left(\sum a_i\right)^2$.
Comment: @anomaly I solved the problem thank you
Comment: Where is this from? The presence of $2022$ (or $2021$ in the title) makes me think that this is a contest problem.
Comment: @anomaly Sorry my mistake. I changed the question a little (The orginal being from a book). The original question stated the least non negative value (which I know the answer for that) but I was wondering if I could find the minimum even if it is negative.
Comment: Wouldn't the answer simply be when all the terms are $-1$?
Comment: @Lorago Won't that be maximum since all terms are 1?
Comment: Nevermind, I think I just misread the question
Answer: $$ (\sum_{i=1}^{2022} a_i)^2 = \sum_{i=1}^{2022}a_i^2 \; + 2\sum_{1\le i<j \le 2022} a_ia_j $$
Since $a_i^2$ is always $1$,
$$ \sum_{1\le i<j \le 2022} a_ia_j = \frac{(\sum_{i=1}^{2022} a_i)^2 -2022}{2}$$
The minimun of $(\sum_{i=1}^{2022} a_i)^2$ is $0$, therefore the minimum of $\sum_{1\le i<j \le 2022} a_ia_j$ is $-1011$.
Answer: Let the sum be $x$. Then $2x+\sum a_i^2=(\sum a_i)^2$. Since $\sum a_i^2=2022$, you need to minimize $|\sum_{i=1}^{2022} a_i|$. The minimum is $0$ and is achieved iff $1011$ of $a_i$ are $1$ and the other $a_i$ are $-1$. Hence the minimum of $x$ is $(0-2022)/2=-1011$.


How to inflate another xml on clicking a button

Question: I have one Activity in that there are no Buttons but I have coded it in such a way that another Activity comes, now in this second Activity there are three Buttons, on which when I click all inflating different respective activities.
In this second Activity there I have added one more Button, on clicking this 4th Button I don't want another Activity to come in foreground instead i just want another layout to be inflated(I don't wanna change the Activity)
In that layout(which i need to inflate) I have a ListView which has a list of certain sites, when this layout is inflated the list of sites should be shown and as i click on there sites its should take me to that webpage.
PROBLEM 1:
How to inflate just the xml on click of the 4th Button without changing the Activity.
PROBLEM 2:
When the xml is inflated and if I click on BackButton the Activity containing all the 4 Buttons should be displayed.
Here is the code that I'm using to inflate another xml:
fourthButton.setOnClickListener(new OnClickListener(){
    @Override
    public void onClick(View v) {
        callingMore();
    }
});
private void callingMore() {
    LayoutInflater inflater = getLayoutInflater();
    View layout = inflater.inflate(R.layout.web_site_list_xml, (ViewGroup)findViewById(R.id.site_list));
}

BUT this code gives a force close and no xml is being inflated and if I use setContentView( R.layout.web_site_list_xml) inside  callingMore() method
the xml is inflated but that xml doesn't show anything and then if I hit BackButton, the Activity that has all 4 Buttons isn't shown.
Comment: Add your LogCat stacktrace so we can see what the ForceClose error is.
Answer: I tried this code..hope helps to you..
1.layout_existed.xml
  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/existedlayout"
    >
   <Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Clicck to inflate view"
    android:id="@+id/button"
    />
</LinearLayout>

2.layout_toinfliate.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">
  <TextView
  android:id="@+id/mytext"
  android:text="You inflated me..i added to u r layout"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  />
</LinearLayout>

3.LayoutInflateDemo.java
  public class LayoutInflateDemo extends Activity {

    private LinearLayout layoutToAdd;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_existed);
        layoutToAdd = (LinearLayout) findViewById(R.id.existedlayout);

        Button button = (Button) findViewById(R.id.button);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                LayoutInflater inflater = LayoutInflater
                        .from(getApplicationContext());
                View view = inflater.inflate(R.layout.layout_toinfliate, null);
                layoutToAdd.addView(view);

            }
        });
    }
}

Comment: in problem 1 ,you asked without changing the activity to inflate just the xml.if yo done that..problem 2 do not rise..
Comment: Thanks a lot sir its working but the older layout still exists i want the older layout to get to the background and this new layout that i inflated should be the only layout on which i can work... like clicking on the website links and all... kindly help
Comment: in this case what u have show its actually showing both the xml at a time but i want only one xml(layout_toinfliate.xml) on my UI and the older xml(layout_existed.xml) should not be shown.... is this possible?
Comment: what ever view(i.e,listview, textview..etc..)we have method like.. setVisibility(View.VISIBLE);setVisibility(View.GONE);use in appropriate place...ex: tv.setVisibility(View.VISIBLE);
Answer: Try using v.findViewByID()..
Pass View v to callingMore()
Comment: sorry sir,but i am not able to understand i am a little new to android kindly elaborate.


How to avoid calling a module from main script requiring change in submodule imports in the module

Question: Here is a project structure just for demonstrating the actual problem
Project/
   +---Scripts/
          +-----module.py
          +-----submodule.py
   +---main.py

submodule.py contains
def a():
    return "Hello World"

module.py contained originally
from submodule import a

def f():
    return a()

if __name__ == "__main__":
    print(f())

You can see this module.py can also be run as a script(which is important for my project)
But if I write main.py as
from Scripts.module import f

print(f())

I am getting an error as
ModuleNotFoundError: No module named 'submodule'
This error generated at module.py, and it is due to the fact that running main.py (instead of module.py changed the import path)
I know, There are two ways to solve it
Option A:
Change the import in module.py as
from Scripts.submodule import a
Now, if I run main.py there are no issues. But if I now run module.py directly I obviously get error as
ModuleNotFoundError: No module named 'Scripts.submodule'
Even though it temporarily solves the problem in main.py, if is still messy, and also both main.py and module.py cannot be run in this method
Option B:
Use relative import in module.py
from .submodule import a
Now also if I run main.py there are no issues. But again if I run module.py directly I get error as
ImportError: attempted relative import with no known parent package
I don't understand what am I doing wrong here. I want to be able to run both main.py and module.py without any code change, so that developers who writes the modules can follow the same convention when importing submodules.
I also tried to make a __init__.py both in Project root folder and also in Scripts folder, but still getting the same error when running module.py individually.
Any help is appreciated.
Comment: The question looks similar to https://stackoverflow.com/q/14132789/407651 (and many other questions too).
Comment: Making a module also be a script is fundamentally broken (because then it's `__main__` rather than the module it is otherwise).  It's not an answer to your question, but it's not worth fixing this (in the long term).
Comment: In Option B, it works if you run `python -m Scripts.module` (instead of `python Scripts/module.py`).
Answer: I assumed submodule.py to be like this (because it is not true in the current state!):
# submodule.py

def a():
    return 'hello'

Then I changed module.py like this:
# module.py

from Scripts.submodule import a

   ...

It works properly!
Comment: I already mentioned that in Option A. If in module.py I write "from Scripts.submodule import a" then I cannot run module.py as a script. I want to be able to run main.py as well as module.py as a script without any code change.


finding checked radio button in asp.net mvc 3 controller action

Question: I have an asp.net MVC 3 razor view which generates checkboxes like this:
 @foreach (LoanQuestionIncludesStatement statement in item.Statements)
                {
                    _question = statement.Question;
                    @Html.RadioButton("_Q_" + counter.ToString("0#") + _question.ToString(), false, new { @class = "answer " + qOrderedClass, id = "_Q_" + questionOrderedNumber }) @statement.Statement
                    @Html.Hidden("_S_" + counter.ToString("0#") + _question.ToString(), statement.KeyOrStatement)

                    counter++;
                }

Here is the html generated:

    Please check the correct answer to each of the following questions.
<form method="post" id="frmLoanAuth" action="/CreditRegistry/Verify/VerifyByAccountInfo">

            Your other obligor's name is

<input type="radio" value="False" name="_Q_002" id="_Q_0" class="answer _QO0">Ann Fillmore<input type="hidden" value="Ann Fillmore" name="_S_002">

<input type="radio" value="False" name="_Q_012" id="_Q_0" class="answer _QO0">Alexander Cleveland<input type="hidden" value="Alexander Cleveland" name="_S_012">

<input type="radio" value="False" name="_Q_022" id="_Q_0" class="answer _QO0">Abraham Reagan<input type="hidden" value="Abraham Reagan" name="_S_022">

                <input type="radio" value="False" name="_N_002" id="_Q_0" class="noneabove _QO0">None of above

            Your guarantor or co-signer's name is

<input type="radio" value="False" name="_Q_035" id="_Q_1" class="answer _QO1">Jude Taylor plc<input type="hidden" value="733824657071694816" name="_S_035">

<input type="radio" value="False" name="_Q_045" id="_Q_1" class="answer _QO1">Felix Cleveland plc<input type="hidden" value="733824657071861723" name="_S_045">

<input type="radio" value="False" name="_Q_055" id="_Q_1" class="answer _QO1">Eve Cameron plc<input type="hidden" value="733824657071409055" name="_S_055">

                <input type="radio" value="False" name="_N_005" id="_Q_1" class="noneabove _QO1">None of above

            Your account balance in a history is in between

<input type="radio" value="False" name="_Q_0610" id="_Q_2" class="answer _QO2">$288,518.79 - $362,585.72<input type="hidden" value="$288,518.79 - $362,585.72" name="_S_0610">

<input type="radio" value="False" name="_Q_0710" id="_Q_2" class="answer _QO2">$439,500.00 - $886,344.32<input type="hidden" value="$439,500.00 - $886,344.32" name="_S_0710">

<input type="radio" value="False" name="_Q_0810" id="_Q_2" class="answer _QO2">$-51,500.00 - $1,050,052.31<input type="hidden" value="$-51,500.00 - $1,050,052.31" name="_S_0810">

                <input type="radio" value="False" name="_N_0010" id="_Q_2" class="noneabove _QO2">None of above

<input type="hidden" value="3" name="_accountInfoQoNumber" id="_accountInfoQoNumber"><input type="hidden" value="GJMgySz1thj6chtAmRJGr/MaT0YdCY24DZfD1OKju9o5byr/sRPw86gKdEOjjmWGUmSfZ+RJ6AcVVnplGRSiNgFshxaqeRSS/7xAOz3T+q1lEek5whYUL7ggW+PXTX+wVfsNMUrMdeVVVHFjJYYYntxjwt8USjxzY2K0cnDsFqK2vxwa" name="__RequestVerificationToken">
<input type="submit" class="readon button" value="Verify">

</form>

I want to make sure that only one radiobutton is checked in one group which is not happening
I want to check in controller action which radiobutton is checked, how can i do this?

I am using this code in controller action:
  var questionRequests = from x in Request.Form.AllKeys
                                   where x.StartsWith("_Q_")

Answer: If you want to make sure that only one radiobutton is checked in one group you must give same name to all those radiobuttons in that group.
Comment: you can get all the values in the controller by taking formobj["your_radio_name"].It will be on if selected and off if unselected
Comment: @ G.R. How to get selected one ?
Comment: Give Formcollection formobj as one of the parameter of the post Action and iterate through all radiobuttons and check if value is on or off.
Comment: @DotnetSparrow Only checked value you will get with POST in action, so value must contain `id` or something else.
Comment: But after your post they will have same name for group, am I right?
Answer: id must be unique and name attribute the same for grouping
Look at this url: html radio button


applay style in all element except special element

Question: HTML

            <input type="checkbox" /> Level 1 - 1

            <input type="checkbox" /> Level 1 - 2

                    <input type="checkbox" /> Level 2 - 1

                            <input type="checkbox" /> Level 3 - 1

                            <input type="checkbox" /> Level 3 - 2

                                    <input type="checkbox" /> Level 4 - 1

                <input type="checkbox" /> Level 1 - 3

                <input type="checkbox" /> Level 1 - 4

CSS
* :not(#tree){padding:0px}

i want set padding zero fro all element except #tree but this code * :not(#tree){padding:0px} set padding zero for li,lable,input?
how can except child element of #tree from padding zero?
this jsfiddle
 and i want look like this
Comment: http://jsfiddle.net/arunpjohny/fed3sg8m/3/ ?
Comment: http://jsfiddle.net/6kdj4zv6/3/ ?
Comment: or http://jsfiddle.net/6kdj4zv6/5/ ?
Answer: Try this:
:not(#tree)
{
    padding:0px;
}

This code means that set padding: 0px for all the elements but not the elements present in #tree
Also, visit this page to have a better understanding of how :not command works
http://www.w3schools.com/cssref/sel_not.asp


Scripting with bcdedit

Question: After rebuilding a HDD using ImageX and a WIM, the BCD sometimes gets corrupted. I therefor need to rebuid the BCD from a script running unattended in a command prompt.
The below code does the job, when entered manually. I need help to automate it (see further below code example):
bootrec.exe /fixmbr
bootsect.exe /nt60 all /force
attrib -h -s C:\boot\BCD
del C:\boot\BCD
bcdedit.exe /createstore c:\boot\bcd.temp
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager"
bcdedit.exe /import c:\boot\bcd.temp
bcdedit.exe /set {bootmgr} device partition=C:
bcdedit.exe /timeout 10
attrib -h -s C:\boot\bcd.temp
del c:\boot\bcd.temp
bcdedit.exe /create /d "Microsoft Windows" /application osloader
bcdedit.exe /set {GUID} device partition=C:
bcdedit.exe /set {GUID} osdevice partition=C:
bcdedit.exe /set {GUID} path \Windows\system32\winload.exe
bcdedit.exe /set {GUID} systemroot \Windows
bcdedit.exe /displayorder {GUID}

As started above, I need to run this in a unattended command prompt. The output from the 6th last statement "bcdedit.exe /create /d "Microsoft Windows" /application osloader" is a newly creates GUID. This ID is needed in the following commands.
How do I load this new GUID from bcdedit to a variable I can call in the following code?
Best Regards
Henrik V. Nielsen
Comment: Hello. I forgot to mentions that the OS is Win7 Embedded 32bit. I am running the script from a WinPE USB disk.
Answer: If other should face the same problem, I solved it by adding the following line.
For /F "tokens=2 delims={}" %%i in ('bcdedit.exe') do (set _NEWGUID=%%i)

This works because there is only one GUID in the file.
Answer: there is an easier way.
When creating a new entry BCD accepts all GUIDs in the Form aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee (number of digits 8-4-4-4-12)
This means you can define an GUID an don´t have to search the GUID with the For-Loop.
It´s working for me.
Comment: Hello mr netlord,

Sounds interesting. I will try to implement next time I need to update the script.
Comment: How do you specify your own GUID? That's what I came here looking for.
Answer: This is a solution based on Henrik's code
This takes the GUID created from BCD into a text file and the for loop gets the GUID from the file
bootrec.exe /fixmbr
bootsect.exe /nt60 all /force
attrib -h -s C:\boot\BCD
del C:\boot\BCD
bcdedit.exe /createstore c:\boot\bcd.temp
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager"
bcdedit.exe /import c:\boot\bcd.temp
bcdedit.exe /set {bootmgr} device partition=C:
bcdedit.exe /timeout 10
attrib -h -s C:\boot\bcd.temp
del c:\boot\bcd.temp
bcdedit.exe /create /d "Microsoft Windows" /application osloader>GUID.txt
For /F "tokens=2 delims={}" %%i in (GUID.txt) do (set _NEWGUID=%%i)
bcdedit.exe /set %_NEWGUID% device partition=C:
bcdedit.exe /set %_NEWGUID% osdevice partition=C:
bcdedit.exe /set %_NEWGUID% path \Windows\system32\winload.exe
bcdedit.exe /set %_NEWGUID% systemroot \Windows
bcdedit.exe /displayorder %_NEWGUID%

Answer: Dylan Grasha
Your answer has some errors and I have added some enhancements to make it more complete.
@Echo Off
bootrec.exe /fixmbr
bootsect.exe /nt60 C: /force
attrib -h -s C:\boot\BCD
del C:\boot\BCD
attrib -h -s C:\boot\bcd.temp >nul
del C:\boot\bcd.temp >nul
bcdedit /createstore c:\boot\bcd.temp
bcdedit.exe /store c:\boot\bcd.temp /create {bootmgr} /d "Windows Boot Manager"
bcdedit.exe /import c:\boot\bcd.temp
bcdedit.exe /set {bootmgr} device partition=C:
bcdedit.exe /timeout 10
attrib -h -s C:\boot\bcd.temp
del c:\boot\bcd.temp
bcdedit.exe /create /d "Microsoft Windows" /application osloader>GUID.txt
For /F "tokens=2 delims={}" %%i in (GUID.txt) do (set _NEWGUID=%%i)
bcdedit.exe /set {%_NEWGUID%} device partition=C:
bcdedit.exe /set {%_NEWGUID%} osdevice partition=C:
bcdedit.exe /set {%_NEWGUID%} path \Windows\system32\winload.exe
bcdedit.exe /set {%_NEWGUID%} systemroot \Windows
bcdedit.exe /displayorder {%_NEWGUID%}
del guid.txt
cmd

Answer: There is an easier way for fixing BCD.
bcdboot c:\windows

for example replaces all bcdedit commands from question.
See explanations for using bcdboot to fix BCD.
The utilities bcdboot and bootsect can fix all boot problems (regarding initial boot sequence).
sfc.exe can fix corrupted system files.

Scripting with bcdedit


Factorial lower bound: $n! \ge {\left(\frac n2\right)}^{\frac n2}$

Question: A professor in class gave the following lower bound for the factorial
$$
n! \ge {\left(\frac n2\right)}^{\frac n2}
$$
but I don't know how he came up with this formula. The upper bound of $n^n$ was quite easy to understand. It makes sense. Can anyone explain why the formula above is the lower bound?
Any help is appreciated.
Comment: Can you prove it by induction?
Answer: Suppose first that $n$ is even, say $n=2m$. Then
$$n!=\underbrace{(2m)(2m-1)\ldots(m+1)}_{m\text{ factors}}m!\ge(2m)(2m-1)\ldots(m+1)>m^m=\left(\frac{n}2\right)^{n/2}\;.$$
Now suppose that $n=2m+1$. Then
$$n!=\underbrace{(2m+1)(2m)\ldots(m+1)}_{m+1\text{ factors}}m!\ge(m+1)^{m+1}>\left(\frac{n}2\right)^{n/2}\;.$$
Answer: Hint: For a positive integers $a$, we have $a(n-a)\ge \frac{n}{2}$.  This is because for $0\le x\le n$,  the function $x(n-x)$ is increasing up to $x=\frac{n}{2}$, and then decreasing.
Pair the numbers $a$ and $n-a$ in the factorial.
Comment: Can you please prove the inequality in the hint? I don't see how $x(n-x)$ having a maxima at $x=n/2$ explain the inequality.
Comment: @ShivTavker You can assume x is a real number and diferentiate the equation and equal it to 0: -x^2 +xn = 0 -> -2x + n = 0 -> x = n / 2.


Finding best fit curve with unknown power

Question: If I was to build a program to estimate the best curve fit of type $a * x^b$ where a and b are the parameters I'm optimizing, what would be my go to methods?
I know I can use ordinary least squares when b is known. Is there a similar closed form-method for this type of problem, or would I be left with only iterative methods like gradient descent?
Comment: You haven't described the properties of the error term. For example is the error term additive or multiplicative. Are you assuming any particular distributional for for the error term (e.g. normal distribution with mean=0 & constant variance)? What is your optimization criteria? By that I mean what properties should the parameter estimates have? Also if the error term is multiplicative you might be able to apply a log transformation. Without these specifications there is no clear answer.
Comment: What are you assuming about the error term? (or alternatively, but in some cases equivalently, what do you want to optimize?)
Comment: Given that realistically $b$ is discrete and unlikely to be huge you may as well try a standard grid search and pick the best results.
Comment: I realized I limited the problem by calling it a polynomial, so I have edited the title. I meant to imply that b can be any value in $R$
Comment: No problem, happens. :) In that case, yes, our best best is to use an iterative method. Do note though that using gradient descent is probably unnecessarily "simple". As we will have access to the derivatives ($\frac{d}{db}ax^b = ax^b \log(x)$) we can use them directly and get a faster solution with an algorithm like L-BFGS-B.
Comment: And to state the obvious: I hope that $x$ is non-negative. Non-integer exponents of negative numbers can result in complex numbers. :)
Comment: I can provide a graphical Python non-liner fitter as an example, if that might be useful.
Answer: Fitting $\quad y=ax^b$
Since you don't specify the criteria of fitting they are an infinity of different solutions. For example, the solution will not be the same if you are looking for the least mean square error, or the least mean absolute error, or the least mean relative error, or etc.
So if any one of them is sufficient for you, the simplest way is to fit the related logarithmic function. Change of variables :
$$\begin{cases} Y=\ln(y)\\ X=\ln(x) \end{cases}$$
The function to fit is linear :
$$Y=bX+c$$
Proceed to a linear regression which will give you $b$ and $c$, then $a= e^c$.
If a criteria of fitting is specified, you need to proceed to a non-linear regression : http://mathworld.wolfram.com/NonlinearLeastSquaresFitting.html
NOTE :
The problem is slightly more complicated if the function to fit includes three parameters instead of two :
$$y=ax^b+c$$
The above change of variables doesn't transform the function to a linear function. A non-linear regression (such as described in the above reference and link) is necessary.
Again if no criteria of fitting is specified, a much simpler method (not iterative, no initial guess) is shown page 17 in https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales .


Converting rational equations into polynomial equations.

Question: A question on my practice exam asks to solve the equation:
$$
\frac{1}{x^4} - \frac{1}{x^2} = 12
$$
In the answers section it says to first convert the equation to the equivalent equation:$$
12x^4 + x^2 - 1 = 0
$$
However, we have not yet learned how to do this and I am unable to contact my teacher before the exam next week.
So, my question is how does one convert an equation like this into a polynomial like has been achieved in this example?
Any help would be much appreciated!
Jack.
Comment: You don't have to sign your question with your name at the end, we can see who you are at the bottom right. Also, even if you have not been taught how to do this, its always good/better to at least tell is what you have tried to solve. A lot of times, it takes some of your creativity to solve problems, in maths and the real world. What have you tried? Why has it failed? Lets see if we can fix your math intuition so that you become a better self sufficient math solver.
Answer: To eliminate all the fractions in a single step, just multiply each term in the equation by the LCM of all the denominators. In this case, $\text{lcm}(x^4, x^2) = x^4$, so we obtain:
\begin{align*}
\frac{1}{x^4} - \frac{1}{x^2} &= 12 \\
x^4 \cdot \frac{1}{x^4} - x^4 \cdot \frac{1}{x^2} &= x^4 \cdot 12 \\
1 - x^2 &= 12x^4 \\
0 &= 12x^4 + x^2 - 1
\end{align*}
Comment: Thanks a heap! That makes a lot of sense now. We have been studying the laws of indices and I was trying to apply the negative power law to not much avail, but now I can see I was looking at it the wrong way.