How to do a get and post in php with restful web service server side

Question: Hi can anyone past some code how to do a restful web service get and post method.  This would be server side so I would be able to invoke the two services from a client.
Thanks!
Answer: Assume you have a script index.php.  You might have two functions inside of it, showForm() and handleForm().
Assume a request comes in to index.php.
if (! empty($_SERVER['REQUEST_METHOD'])) {
    if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')
    {
        doSomething();
    }
    else
    {
        showSomething();
    }
}

There you have it.  REST.  If you send a GET request to index.php, you'll show some output, and if you send a POST request to index.php, you'll perform some data manipulation.  You can take if from there for the other RESTful HTTP request types, such as DELETE, etc.
Obviously this is a very simple example, and I wouldn't want to create an entire site in this manner.  It's best to go about creating a RESTful site in an architecturally sound way.  Many frameworks can assist with this.
REST is a hot topic right now, it seems everyone wants their apps to be RESTful.  There's a lot of articles and guides out there on Google, you'd probably do well to spend some time researching various approaches.
Note about URLs:  URIs don't have to be pretty to be RESTful.  However, a key point of REST is that all URIs should represent a single resource.  As query parameters are not part of a URI, "/index.php?show=2" is not considered RESTful.  You'll find that a lot of applications use URL rewriting to convert query parameters into something like "/index/2" instead.
That being said, there's nothing wrong with having "/index.php" as a URI, just as long as it only represents a single state.
Answer: POST:
<?
// Helloworld_post.php
echo "Hello world
"
print_r($_POST['data'];
?>

GET
<?
//helloworld_get.php
echo "Hello world
"
print_r($_GET['data'];
?>

What exactly are you trying to do?
You need to use mod_rewrite or its equivalent to make pretty /helloworld/ urls. The beauty of REST is it is just a standard http request. It doesn't specify json encoding or xml encoding or "wtf I am the 1337" encoding.


Can depreciation be offset against rent of a UK income property?

Question: In the U.S., an income property investor is allowed to depreciate a residential income property over a period of 29.5 years.  Does a similar concept exist in the UK?  Can a UK citizen deduct the depreciation of a UK income property, and if so, what are the terms (time period, straight-line vs. accelerated, ratio of improvement value vs. land value, etc.)?
Answer: Residential property let to a single household cannot be depreciated  (when letting to many households, items like lifts may be able to be depreciated), but repair costs can sometimes be offset against tax.  For detailed information search http://www.accountingweb.co.uk/ and/or read  How to Avoid Property Tax
(Property in the UK is after all mostly built to last a very long time unlike the USA)
Answer: No; in fact, there's an implicit assumption that property is likely to increase in value over time, based on:

Property is used as an investment for, say, pensions.
If you sell a property that has been let to tenants, you must pay capital gains tax on any gain above the current threshold.

As Ian mentions in his answer, repairs (as opposed to improvements) can be deducted.
There is also a wear & tear allowance for furnished properties, which permits a deduction to account for depreciation of furniture and the like; however, it looks like this is likely to be removed in the near future.


Will satisfying the OLS Assumptions matter if the only thing i care about is the value of y that is predicted from the output?

Question: If i dont care about the individual effects of each variable onto y, and building confidence intervals and stuff, but only that i get accurate predictions of my y values. Will satisfying them matter? If they do matter, then why are they not taken into consideration when we do linear regression in machine learning? The coeffs of the input variables that are produced remain the same, and if we get bad results when we do not satisfy them, we should surely take them into consideration, right?
Comment: Have a look at the [Gauss-Markov theorem](https://en.wikipedia.org/wiki/Gauss%E2%80%93Markov_theorem).
Answer: Yes, but the strength of my Yes varies by the assumption. For instance, one of the assumptions of OLS is that the model is linear: $y=X\beta+\varepsilon$, You should agree with me that if this assumption is broken, then predicting becomes problematic. Also think about autocorrelation: if $E[X\varepsilon]>0$ then larger $X$ would tend to underestimate and predict with bias. etc.
Machine learning is almost entirely an interpolation exercise. You make the network weights remember a lot of combinations of inputs then interpolate between them when you get a new input. Although the formulae can be exactly the same, there is a difference in application. In a typical OLS setup you get some data X, then try to come up with a few coefficients $\beta$, typically much smaller set of them compared to the umber of observations. In ML you often devise much larger set of weights, even larger than the number of observations often. In this case the weights effectively "memorize" the mapping of $y$ to combinations of $X$. The OLS machinery is simple used as a way to memorize this mapping. The trouble comes when new $X'$ comes that is completely out of the field of previous $X$ that the algorithm has seen so far. In this case it's easy to get a nonsensical result.
Comment: Ok, so you mean to say that i would get bad y values with large errors, right?
Comment: @divyamsureka, I'm saying that you can't simply ignore assumptions even when predicting. Some of them may not be important in certain cases, but you have to look examine them closer each time.
Answer: It depends. You can measure prediction quality by cross-validation and the like, and this doesn't require some assumptions such as normality and linearity. If the assumptions are fulfilled, you are in a better position for achieving a good prediction result, however this is not a theorem and applies sometimes but not always (for example a truly linear system with large variance will yield worse OLS predictions than a slightly nonlinear one with a small variance, at least if the nonlinearity is suitable for linear approximation).
However, you may be interested in future prediction in regions in which you currently don't have test data, and then "slight nonlinearity" may play out much worse than you can assess from the data you have.
Furthermore, standard estimation of the prediction error with test and training sets still requires independence and identical distribution (given explanatory variables $x$) of test and training set, and of both regarding any future observations that you actually want to predict. If this is violated and you don't know how exactly, you cannot assess the prediction error in any reliable way.
PS: "If they do matter, then why are they not taken into consideration when we do linear regression in machine learning?" Well, everybody who ignores these things does so at their own peril...
Comment: If *what* have independence and identical distributions?
Comment: What precisely is required depends on what precisely you do for prediction quality assessment, and what your modeling approach is (particularly, do you treat $x$ as random or fixed?). Roughly, if you have test, training, and unobserved future data, all three of these need to be independent (unless you know how exactly they depend on each other) and generated in a manner that allows generalisation from one to another. Under standard linear regression model assumptions all this will hold.
Comment: And what needs to be identical?
Comment: Didn't I say this already? The relevant distribution in test set, training set, and future observations.


import from oracle to mysql by using CTL

Question: how can i import data from an oracle database to a mysql database by using CTL file (generate with Toad for oracle)?
Thank in advance
Andrea
Answer: A CTL file would seem to imply that you were trying to use SQLLoader to load the data.  SQLLoader, though, is an Oracle-specific tool.  It only supports loading data into Oracle, it does not have functionality to load data into MySQL.  So I doubt that the control file that Toad generated would be useful.
If you have a control file, though, that would imply that you had a flat file of data to load (i.e. a comma-separated or tab-separated flat file of data for each table in the database).  Is that the case?  If so, just about every database out there has utilities for importing flat files.  I'm no MySQL expert, but I assume MySQL has such a utility.  Of course, you could also relatively easily write a small application to do the load in whatever language you're familiar with.


Is there a term for "the one that got away"?

Question: I'm thinking of something like 失恋対象 or 失恋相手, except 1) I just made those up off the top of my head, and 2) on the off-chance they're real words, they don't really capture the essence of "the one that got away".
Comment: I was thinking of 逃してしまった人 before researching your question, and my confirmation bias led me here: https://ejje.weblio.jp/content/the+one+that+got+away , which says 「惜しくも逃した物 / 人」. I'll leave it to someone more qualified to answer though.
Answer: The most versatile (and thus the most often-used) terms would be:

「逃{に}がした魚{さかな}」 and 「逃げた魚」

both of which practically mean the same thing though they take different grammatical forms.
「魚」 in these expressions can refer to a prospective love partner, business opportunity, etc.  It can refer to anything you once almost had.
「魚」 does not need to refer to a fish unless you actualy are talking about fishing.  People do tend to brag about the size of the fish they almost caught in fishing, which is why we often say the whole sentence:

「逃がした魚は大きい。」

Again, this sentence is often used about things/people that are completely non-fish-related.  "The one I let go was huge."
IMHO, 「失恋対象{しつれんたいしょう}」 and 「失恋相手{しつれんあいて}」 look/sound pretty stiff and overly-serious.
Comment: Hmm, I saw this expression in several dictionaries, but none of them mentioned that 魚 could be used metaphorically.  Thank you.


back up fully Customized WordPress theme

Question: How to back up fully Customized WordPress theme and its page, post, full setting, contact form 7 data? So that we can install it directly on any other WordPress website.
Comment: the simplest to do is to copy the whole website. read this : https://codex.wordpress.org/Moving_WordPress
Answer: Best practice to backup whole theme and data, first you need to export the XML file.
Login to WordPress Dashboard > Tools > Export

Every theme save their options differently, You can use third party plugin which favors your theme to export the settings.


Are packages downloaded from multiple mirror sites?

Question: I'm running F17 and inside of yum.repos.d. I see multiple repos listed like adobe-linux-1386.repo, fedora.repo, google-chrome.repo, etc. When I yum install are some files being downloaded from multiple different repos or all from one?
Answer: Most of the repositories specify a mirrorlist in their configuration file. When present, yum will select one or more of the mirrors provided by the list. Repos that don't have mirrors will have baseurl instead of mirrorlist.
When downloading multiple packages, yum can download from multiple sites in parallel, though this isn't always obvious in the terminal unless you watch very carefully.
Answer: Most packages would be downloaded from fedora.repo.  Adobe packages would be downloaded from adobe-linux-i386.repo.  Google Chrome packages would be downloaded from google-chrome.repo
Comment: Can I add repos to this directory?
Comment: If you have root privileges, you can add repos to `/etc/yum.repos.d`
Answer: Also depends on whether a repo is disabled or enabled.
Comment: What determines whether a repo is disabled or enabled?
Comment: 2 things that determine whether a repos is enabled or disabled.  (1) the enabled=? line in the repo file (in `/etc/yum.repos.d` (2) Using the `--enablerepo` or `--disablerepo` tag in the yum command.  For example, you could add `enable=0` to your google-chrome.repo.  Then in ordinary operation, yum would ignore google-chrome-repo.  On those occasions when you want google-chrome-repo, do `yum --enable-repo google-chrome.repo ...`
Answer: Normally the contents of repository do not have the same rpms (like in your example). If you had "conflicting" rpms you can use yum_priorities to choose which one to use first.
But in the end a single rpm will be downloaded from a single (mirror)-server that is mentioned in a single repository (directly or via mirror-list).


How to change internet login information using a remote connection

Question: I have this problem. I have a computer at my university. In order to connect to the internet inside the university, one needs to go to the login webpage and enter his user/pass. Currently, I am connected to my computer at university from home using a remote desktop software (anydesk). However, I wish to log in to the internet from the university with a different account. To do so, I need to sign out of my account, then log in with the other account. But if I log out the remote connection will go offline. Is there a script or tool which can help me with this task?
Answer: However, when you log out of that current account, your connection to the home will be disconnected, but you may be able to execute a scheduling task that is able to execute a trigger by logging into the Internet login page and then entering the second password. Your problem may be resolved.


Autobiographer Badge

Question: To get this badge we have to complete all user profile fields. I have completed all profile. Why I'm not getting it? What all fields are their to to filled? Am I missing something?
Answer: Autobiographer Badge - they say you need the website field also filled in (which I don't see on your bio). Try "n/a" if you don't have one (or if that doesn't work, microsoft.com. :)

Autobiographer Badge


Google Query from Java

Question: I am using this code to do a query over list of words using google and extract number of search results from google. It worked fine, but since last night it keeps giving me this error after doing 200 queries (I guess google flagged me!):
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.google.com/sorry/?continue=http://www.google.com/...
the "red" is just an example.
public class Google {
public static void main(String[] args) throws IOException {
        String query = "red";
        String urlName = "http://www.google.com/search?q=\""+query+"\"";
        URL url = new URL(urlName);
        URLConnection conn = url.openConnection();
        conn.setRequestProperty("User-Agent",
                "Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:126.96.36.199) Gecko/20070723 Iceweasel/126.96.36.199 (Debian-188.8.131.52-0etch1)");
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        Pattern pattern = Pattern.compile("
About (.*?) results
"); //
About 1,620,000 results

        String line;
        while ((line = in.readLine()) != null) {
            Matcher m = pattern.matcher(line);
            if (m.find()) {
                System.out.println(m.group(1)); // m.group(1) coresponds to results number: i.e.: 1,620,000
            }
        }
        in.close();
    }

}
any solution, suggestion?
Comment: I found and easy and yet not the best solution. just add Thread.sleep(15000); between each queries. this way it would delay 15 seconds between each queries and google will not take it as a robot!
Answer: You've been flagged as a bot, probably due to the frequency of your query.  Try running this from a different IP (before that one is flagged as a bot).
Regardless, you should probably use the Google search API.  From the site
https://developers.google.com/custom-search/v1/overview:
Pricing
Free quota
Usage is free for all users, up to 100 queries per day.
Paid Usage
Any usage beyond the free usage quota will fail if you are not signed up for billing. Once you have enabled billing, you will continue to receive 100 free queries per day. However, you will be billed for all additional requests at the rate of $5 per 1000 queries, for up to 10,000 queries per day. If you need additional quota, please request additional quota from the console.
Comment: I did 42,000 queries and it worked fine. I need to cover another 110,000 queries! and With 100, I will need 1100 day! any way, I will need to fine another way!
Answer: From the error page specifically:
"Our systems have detected unusual traffic from your computer network. This page checks to see if it's really you sending the requests, and not a robot."
Since you obviously are a robot hitting their page they've put in certain measures to circumvent the traffic you're costing them an do not wish for you to continue such a practice.
Having said that you'll need to verify your identity with Google at some point. The way this page recommends doing so it to present the author (yourself) with the image, manually bypass the captcha and then save the cookie for use by your program.
Comment: I'd wager that actually goes against their ToS, especially since you are explicitly circumventing their abuse service.

Google Query from Java


Complex integral over a circle

Question: In an exercise, I'm supposed to assume that $|a| < r < |b|$ and prove that $\displaystyle\int_{\gamma} \frac{1}{(z - a)(z - b)} dz = \frac{2 \pi i}{a - b}$, where $\gamma$ is a circle of radius $r$ centered at the origin with positive orientation. So I had the idea to express this integral as $\frac{1}{a - b} \displaystyle\int_{\gamma} \frac{1}{z - a} - \frac{1}{z - b} dz$. Then I tried to evaluate each of these separately, but I don't really know what to do. I get $\displaystyle\int_{0}^{2 \pi} \frac{i r e^{it}}{r e^{it} - a} dt$ for the first term. How am I supposed to integrate this? I can't substitute $u = re^{it}$, can I?
Answer: Use the Cauchy integral formula. Also, note that although this function has 2 poles, $a$ and $b$, only $a$ is inside the contour.
If you don't yet know the Cauchy integral formula, I think that $\frac{1}{a-b}\int_\gamma \frac{1}{z-a}-\frac{1}{z-b}\ dz$ is a good start.
$\frac{1}{a-b}\int_\gamma \frac{1}{z-a}\ dz$ is $\frac{2\pi i}{a-b}$ (use the substitution $w=z-a$). The second integral is zero, since the function is holomorphic everywhere. In other words, if we use the definitions to write it out as a real integral plus $i$ times a real integral, we will have conservative vector fields and so the integral around a closed contour is $0$.
Comment: It is valid. All you're doing is translating the complex plane by $a$. Substituting with the other integral doesn't get you anywhere, but you can find a complex anti-derivative and then use the fundamental theorem of calculus to conclude that you get $0$. If you don't see it, it's unfortunately a bit much to explain here. I recommend looking at the first 2 chapters Greene & Krantz (Function Theory of One Complex Variable) for a really good treatment of complex analysis as an outgrowth of multivariable calculus.
Comment: I'm not sure how to use substitution on complex integrals though. This seems to work: $\displaystyle\int_{\gamma} \frac{1}{z - a} dz = \displaystyle\int_{\gamma} \frac{1}{w} dw = \displaystyle\int_{0}^{2 \pi} \frac{i r e^{it}}{r e^{it}} dt = 2 \pi i$, but is that valid? And if it is, I don't see how it can't be used to conclude the same for the other integral.
Comment: I just don't see what would be the harm in doing the exact same thing with $b$ in place of $a$.
Comment: Give it a shot. If you do it right, you should get $0$.
Comment: When you did your change of variables, you changed the contour. That doesn't matter so long as the old contour is deformable to the new one. But to deform a loop centered at $0$ to a loop centered at $b$, you would need to go through the singularity, which changes the value of the integral.
Answer: Hint: Use Cauchy integral formula.
Answer: you could let $u=re^{it}-a$ and $du=rie^{it}$

Complex integral over a circle


What is the "blockchain"?

Question: What is the blockchain? I keep hearing about other "blockchain technologies", does this mean other cryptocurrencies or what?
Comment: By simply searching for 'what is blockchain' on Youtube you will find a decent amount of videos explaining it in simple terms. This is one of the better ones https://www.youtube.com/watch?v=KP_hGPQVLpA
Answer: The bitcoin block chain is the record of every bitcoin ever generated and every transfer of bitcoins from one party to another. Each crypto-currency that is based on the same type of technology as bitcoins has its own block chain. When people talk about other blockchains, they mean other currencies based on the same distributed currency / published transaction model (namecoin, Ixcoin, and so on).
The phrase "blockchain technology" is a reference to this model of published transactions to implement currencies with no central authority.
Answer: The Bitcoin "blockchain" is in effect the general ledger of Bitcoin. It is a recording of all transactions grouped into blocks. Each block represents approximately 10 minutes of transactions, and chaining them together has the effect of adding layer upon layer of transaction history.
Chaining blocks of transactions together by requiring a new block to reference the most recent prior block makes it harder to alter blocks in the past, since all subsequent blocks up to the current one would also have to be altered. In the Bitcoin blockchain, this is combined with a 'proof of work' that each block must include (a very large amount of work at this point), to create an unalterable history of transactions that is definitive.
New transactions can be evaluated against this general ledger with complete confidence that it is current, complete, and unalterable. With the entire blockchain publicly available, anyone can do this evaluation and prove that a transaction is valid or not.
It is likely that someone referring to "blockchain technology" is talking about any system that has this type of public general ledger.
Answer: I would suggest you to stop getting boggled by technical terms like 'decentralized distributed ledger'.Blockchain is nothing but a long chain of blocks with transactions details recorded and new blocks added after each transaction is validated and approved.
Blockchain allows transactions to take place in a secured, transparent and decentralized manner.
When a sender transfers the information, he/she uses their private key and at the same time announces the transaction information over the network. This is when a new block is created that contains information like a digital signature, timestamp along with the receiver's public key.
This helps all transactions over blockchain technology highly secured.

What is the "blockchain"?


Is it possible to create a temporary file that will autodelete after a specific time that it's not read by any other program?

Question: I'd like to create a temporary file that will be read by multiple scripts after its creation, but I don't have an easy way of monitoring when the last script finishes reading this temporary file to delete it (it may be a different script each time). I'd like to know if there's a standard way of solving this problem with command-line tools that will autodelete this file when it passes a specific interval of time without being read by any program, is it possible? Or the only way to solve this problem would be to figure out a way of knowing when the last script finishes reading this file for deleting it?
Comment: The `stat` command will give you the information you need, but there's no auto-delete mechanism that I know of.
Comment: The `stat` command gives you the last access time of a file in seconds-since-epoch. That could go in a script initiated as a job using `at`. Depending on the outcome of the `stat` and `date +%s`, it will either decide to remove the file, or re-issue an `at` command to re-run itself after a delay based on the last access time plus required delay.
Comment: Thanks @ajgringo619 and @Paul_Pedant... I've checked the `stat` command as well but the problem I faced with it is that I don't have the time that the file was last closed using `stat`... `inotifywait` worked better because it gives me that information. As an example, for testing the `stat` command I've created a small script that reads my file line by line and sleeps 5 seconds in each line, in my case, the `stat` knows that the file was accessed but it doesn't know when it was closed. That's a problem because there may still have some outside program reading the file when it's deleted.
Comment: `stat` is frequently no use at all. The Linux default (set by the `relatime` mount option) does not update `atime` unless (a) an access is made that is newer than the mtime or ctime of the file (essentially shows that a file has been read since changed, but not other recent accesses). And (b) previous access time is more than 24 hours out of date.
Answer: Using inotifywait, you can add the following to your scripts that access the file.
if ! inotifywait $FILE -t $SECONDS >/dev/null 2>&1
then rm $FILE
fi &

The script will spawn a process that waits until something accesses $FILE.
if something does, it does nothing and exits.
if the timeout is reached after $SECONDS, it will remove the file
alternatively using a seperate script, that you run at creation of the file
while inotifywait $FILE -t $SECONDS >/dev/null 2>&1
do sleep 1
done
rm $FILE

it will loop whenever the file is accessed,
if nothing accesses it within the timeout, it breaks and removes the file.
Comment: Thanks, your answer gave me the basis for solving this problem... The only problem with this answer is that if a script stays with the file open for an undetermined period of time without closing the file your solutions will timeout before the time. I tried to create a bash solution but I didn't manage to do it... Although with node.js using inotifywait it was simpler... I'll post my solution as well.
Answer: Based on taiyu's answer using inotifywait I've created a node.js solution to this problem... It required more details than I expected when I asked it. Sorry if that's not the right place for posting node.js code but the asynchronous nature of the language made things simpler for me... My solution is the following:
const fs = require('fs');
const spawn = require("child_process").spawn;

const file='/home/user/hugefile.csv';
let counter = 0; // counter used for identifying how many times the file was opened and closed by a different program

const child = spawn('/bin/bash', [ '-c', `inotifywait --format=%e -q -m -e access,close ${file}` ])

child.stdout.on('data', (data) => {
    let line = data.toString().split('\n').filter(item => item); // get events inside a javascript array and filter empty values
    // loop through the inotify events
    line.forEach(function(event) {
        if ( event === "ACCESS" )
            counter++;
        else if ( event === "CLOSE_NOWRITE,CLOSE" )
            counter--;

        // asynchronous function that checks the value of counter after 10 seconds
        async function timer() {
            await sleep(10000);
            console.log(counter);
            if ( counter === 0 ){
                fs.unlinkSync(file); // erase file
                console.log("tmpfile erased!")
                process.exit();
            }
        }
        timer();
    });
});

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

Basically, I used inotifywait as a basis for solving the problem... I just need to execute this script after creating the temporary file and it will erase the file after all other programs finish reading the file (after 10 seconds).

OBS: My problem trying to solve it with bash is that when I make a function run as a process with & I lose control of the new values of global variables inside that function. So I couldn't get the counter state using the same logic that I've used on node.js...  If someone knows a workaround for this, feel free to write in the comments here. :)


Printing directly from Finder with Print Dialog?

Question: Looking for a way to start printing a PDF directly from the macos Finder with a keyboard shortcut (e.g. Cmd + P), but instead of sending it directly to the printer, opening the Print Dialog.
Can I change these settings in macOS 10.12 somewhere?
Thank you for any help!
Comment: What about a service menu item (right click and click "Open Print Dialog")?
Comment: I'm looking for a keyboard shortcut, not for clicking …
Answer: Printing "directly from finder" does not happen.
Print Dialogs are always app-specific:
Even if you seemingly don't notice it, MacOS opens at least "Preview", prints the document/graphic and closes the app afterwards.
Your best bet would be an app like Karabiner Elements (free) that's able to sequentially open a file and execute the print command (typically with a print dialogue), using just one user-defined shortcut.
Since a sequence of keys pressed is a "Complex Modification" you'd have to edit KE's ~/.config/karabiner/karabiner.json and add this kind of code (after: "rules": [ ):
{ "description": "Finder: open file in app, open print dialog",
  "manipulators": [
      { "conditions": [ { "bundle_identifiers": ["^com.apple.finder"],
                          "type": "frontmost_application_if"
                      } ],
              "from": { "key_code": "p",
                        "modifiers": { "mandatory": ["right_command"] }
                      },
        "parameters": { "basic.to_if_held_down_threshold_milliseconds": 5 },
   "to_if_held_down": [ { "key_code": "o",
                          "modifiers": ["right_command"]
                      } ],
   "to_after_key_up": [ { "key_code": "p",
                          "modifiers": ["right_command"]}
                      ],
      "type": "basic"
      }
                  ]
}

As opening an app takes some time the different commands (open / print) are "separated" through "held_down" and "key_up" definitions.
Be aware that a "comma" (,) may be necessary either in front of the first or behind the last bracket, IF there are other rules in the json-file.
(If you prefer the left command key on your keyboard the "from"-part would say: ["left_command"].)


Synology logs SMB "Read" event false positives

Question: We recently switched to a Synology enterprise setup at work and we're hoping to benefit from the additional logging that comes with Synology software. In response to a security incident, I found log entries that suggested a user accessed a file over SMB they may not have accessed.
To prove the theory, I mounted a SMB share, and navigated to a directory. From both Windows and Mac, I found that Synology generated "Read" events for files in the directory (image files, csv files, pdf files, etc) even though none of the files were read.
The problem with that is a user could easily be accused of accessing files they didn't access. Simply navigating to a directory could result in a user "Read" event log. On the surface it may seem like the solution is simple: never restrict access by files, always restrict by directory. But my concern is more about not being able to trust the logs and not knowing what options exist where a user can connect to an SMB share and the security team have reliable event logs.
How do you deal with this type of problem when doing security audits?
Answer: Your file manager probably reads the files to find metadata - such as Office document tags, EXIF thumbnails and so forth. You have no way of differentiating such automated reads from a user opening the file on this level.
To me it sounds like a X-Y problem. What do you want to achieve? An audit trail whenever a user opens a file?


Microsoft 365 Rest API returns Operation is not valid due to the current state of the object when getting versions of a large(8GB) file

Question: I am using the endpoint _api/web/GetFileById('" + fileUniqueId + "')/Versions('versionId') and _api/web/GetFileByServerRelativePath(path)/Versions('versionId') to get FileVersion based on fileId/path and version id. Both works on small files, but it return Operation is not valid due to the current state of the object when file is large, in my case it is 8GB. Is this an existing issue in SharePoint or is there a fix for this?
Answer: Per my test, I could reproduce this issue on my end. And I find a same issue here: https://stackoverflow.com/questions/55835984/o365-rest-api-error-response-for-version-method
It seems that this is an existing issue that large files in Microsoft Office 365 SharePoint do not support Versions request.


Scrolling a div containing a table

Question: Here is a partial table that I am creating in a PHP script.
Date      Description                             Month
Sun 3  -  14th Sunday of the year                - July
Mon 4  -  Week 14 of the year                    - July
          or Saint Elizabeth of Portugal
Tue 5  -  Week 14 of the year                    - July
          or Saint Antony Mary Zaccaria, Priest
Wed 6  -  Week 14 of the year                    - July
          or Saint Maria Goretti, Virgin, Martyr
Thu 7  -

Fri 8  -

Sat 9  -  Week 14 of the year                     - July
          or Saint Augustine Zhao Rong and
          his Companions, Martyrs
Sun 10 -  15th Sunday of the year                 - July

Mon 11 -  Saint Benedict, Abbot                   - July

Tue 12 -  Week 15 of the year                     - July

Wed 13 -  Week 15 of the year, Saint Henry        - July

Thu 14 -  Week 15 of the year                     - July
          or Saint Camillus of Lellis, Priest
Fri 15 -  Saint Bonaventure, Bishop, Doctor       - July

The HTML will look like this.

Sun 3

 -  14th Sunday of the year

- July

    .
    .
    .
    .

The name for the div with class="lcday" will be an anchor tag. I'd like to be able to scroll the scrollBoxYe div to the row that matches the current day.  Should the name anchor be in the div or in the tr element?
Is the onload event useful for the div element?  I want to be able to scroll the div automatically without any click event.  If the onload event isn't available what is the best way to load the div automatically.  I prefer to avoid doing this with the page body onload because there are different views loaded on the same page.
Once I find the right event to load the div automatically, I want to call a function like this one.
function scrolltoanchor(row){
document.getElementById("scrollBoxYe").scrollTop = document.getElementById(row).offsetTop
}

The function parameter is the anchor name.
The most important questions are:

how to define the anchor to be able to scroll to the right row.
the right event to call the scrolling function (body onload not an option).
Comment: Is it possible to scroll the page based on the  element name?  Or should this only be done with a  in the ?
Answer: I do not know whether the use of jquery can be an option, but i think it's much more easier. This fiddle should work.

Scrolling a div containing a table


Align child div to bottom of parent div with dynamic height and width

Question: I don't know how to move ".buttons-box" to bottom of ".blog-item". I can set {position: relative;} for ".blog-item" and {position: absolute; bottom :0; right:0} for ".buttons-box", but it does not solve my problem, because change me width for ".buttons-box" and I need his width exactly as has ".content-box" and then I can't set width to 100%, because take width from relative parent, what is in this case "blog-item". I can't set specific width in pixels for "div.buttons-box" because is dynamic as ".content-box" and ".text". They have width according to image and this image can have different size in every single "blog-item".
What i need:

moved div ".buttons-box" to bottom of ".blog-item"
".buttons-box" must have same width as ".content.box"
".buttons-box" must be under ".text" and must have placeholder for
self, because if text will be too long, and if he had position
abolute will be over text

Thank you!
Image Sample: ttp://i.stack.imgur.com/6WfUm.jpg
JSFIDDLE Sample and Demonstration: http://jsfiddle.net/yjdEk/
Edit:
My idea on JSFIDDLE: http://jsfiddle.net/RhShT/

I created placeholder "buttons-box-placeholder" for buttons-box
I set position relative for ".content-box" and postion absolute for
".buttons-box"

I need now some script for set width and height, but only from his parrents not global, becouse every single .blog-item can be different:

.buttons-box width = .content-box width
.content-box heigh = .blog-item height
Answer: There is a CSS width property value called "inherit" which should make child's width equal to parent's.
Comment: yes you're right, but my parent div not have specific width in px, but has dynamic width.


Do I compile Ubuntu Source code on Red Hat System?

Question: If we install the Red Hat System then can we compile the other distros of linux on the Red Hat server system? If so, please provide me the tutorials and links.
Comment: Please [edit] your question and explain what you want to do. Do you want to install multiple distros on one computer? What does compiling have to do with it? If all you need is multiple operating systems on the same machine, try searching google for "dual boot".
Comment: What do you mean by compile? debian packages come in `.deb` format and fedora packages come in `.rpm` format. From what I understand, your question is more like can we use `.exe` file for installation in a red hat system, which obviously is not possible.
Answer: The simplest and the most proper variant today is to install a target system as a virtual guest, using any kind of virtualization (from a simple chroot through LXC and up to VirtualBox, VMWare, etc.) and then use distro-specific native tools.
You should think of some cross compilation without virtualization under very extreme circumstances.
Answer: First If by that you mean creating a custom Ubuntu or other distros yes you can and this action is not entirely distro-specific (i.e in your case Redhat).
For that you could use two diffrerent approaches. Either use automation tools such as linuxcoe and other different tools or go native and start by LFS (Linux From Scratch). Either way you have three things to consider:

Your kernel
Your GUI
You distribution system

Build your own distro
For the third option you could use other distros tools also (or write your own)
Or you meant to compile codes for other platforms which is something else and has more to do with your make and build environment and coding skills (writing config files for example). you code do it in Jail env. or Virtual machine if you like.
Or perhaps you meant to access other distros inside a running RedHat.
In this case what you should consider the most is the arch of the Host and target system.
This could be done by chrooting.
Consider that you have the live image of some distro in /mnt/distro.
first you should mount your /proc , /dev and /sys
Then chroot to /mnt/distro.
mount -t proc proc /mnt/distro/proc
mount --rbind /sys /mnt/distro/sys
mount --rbind /dev /mnt/distro/dev

Then for chrooting part you need to specify your environment completely to avoid problems in future.
chroot /mnt/distro /bin/env -i TERM=$TERM /bin/bash

Note: It is the base idea and the path and env would be different in your case


Use results from query SP list as a paremeters to query another lists

Question: I need some advice. Because of asynchronous nature of querying SP lists (I use executeQueryAsync) I have no idea if it is possible to do something like that:
I'd like to query first list and get some data from different columns, next using this data as a query parameters I'd like to query another lists to build up final table to display on site.
Any advice will be helpful. Thanks in advance.
Answer: the problem of querying async is not being capable of of controlling the moment where you get the data and the script status.
i've tried to implement event listeners to make the async handle like a "sync" function, but it won't always work as expected and is not considered a best practice.
the best approach is to add a function to your success callback
<code>clientContextFirst.executeQueryAsync(Function.createDelegate(this, SuccessFirst), Function.createDelegate(this, Failed));

function successFirst()
{

//new spClinetContextsecond after extracting your values
clientContext.executeQueryAsync(Function.createDelegate(this, SuccessSecond), Function.createDelegate(this, Failed));
}
function failed()
{

}
function successSecond()
{
 extract results

}
</code>
consider making your client context or loaded variables global
Comment: I used this approach but the problem is that I have to use result from one query as a parameters another. Finally I have to run 3 times executeQueryAsync but you never know the sequence. At this moment I decided to use synchronous method by setting parameter async:false


External tensor product of sheaves

Question: Suppose $\mathcal{A}$ is a quasi coherent sheaf of algebras over a group scheme $\mathcal{G}$. Suppose it is generated by global section. Then , what can we say about the external tensor product $\mathcal{A}\boxtimes\mathcal{A}$? Will this sheaf also be generated by the tensor product of the global section with itself? Or is it bigger than this?
Answer: What do you mean by $A\boxtimes A$? If this is the sheaf $p_1^*A\otimes p_2^*A$ on $G\times G$ then certainly it is globally generated by the tensor square of global sections. It follows easily from right-exactness of the pullback and of the tensor product --- let $V$ be the space of global sections, then $V\otimes O_G \to A$ is surjective, hence $V\otimes O_{G\times G} \to p_i^*A$ is surjective, hence $V\otimes V\otimes O_{G\times G} \to A\boxtimes A$ is surjective.
Comment: Thanks Sasha for the answer. Yes, $A\boxtimes A$ is the sheaf given by $p_1^∗A⊗p_2^∗A$ on $G\times G$.
Can you please tell me if $V\otimes O_G\to A$ is surjective, then how and why should $V\otimes O_{G\times G}\to p_{i}^{∗} A$ be surjective? And finally how will we get the last step i.e. why would this map become $V\otimes V\otimes O_{G\times G}\to A\boxtimes A$ is surjective? I am sure it is trivial for you, but I am not able to figure out the correct reason, so please help.
Comment: The first step is the application of a pullback --- $p_i^*(V \otimes O_G) = V\otimes p_i^*O_G = V\otimes O_{G\times G}$. The last step can be obtained as follows. First we tensor surjection $V \otimes O_{G\times G} \to p_1^*A$ by $p_2^*A$. We get a surjection $V\otimes p_2^*A \to p_1^*A\otimes p_2^*A = A\boxtimes A$. After that we tensor surjection $V \otimes O_{G\times G} \to p_2^*A$ by $V$. We get $V\otimes V\otimes O_{G\times G} \to V \otimes p_2^*A$. Composing it with the surjection obtained earlier we get the required surjection $V\otimes V\otimes O_{G\times G} \to A\boxtimes A$.
Comment: Then in such a case, when $A$ is generated by global sections, will the following diagram commute(why/why not)?

\[
\xymatrix

{
   A\boxtimes A(U\times U) \ar@{.>}[rrd]^{\exists !}\\

   A(G) \boxtimes A(G) \ar@{^{(}->}[u] \ar@{^{(}->}[rr]^-{} && A(U) \otimes A(U).
}
\]

for any open set $U\in G$, Please suggest. Thanks.

External tensor product of sheaves


Need Apache commons-lang3 as dependency of an Eclipse plugin built with Tycho

Question: I'm having one of those nights...
I'm developing an Eclipse plugin using Tycho (the Maven extension), and at some point I wanted simply to use the class StringUtils from org.apache.commons. After some research, the only way that I could find is the following code in my pom.xml parent file:
  <dependencies>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3.2</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>tycho-maven-plugin</artifactId>
        <version>${tycho.version}</version>
        <extensions>true</extensions>
      </plugin>

      <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho.version}</version>
        <configuration>
            <pomDependencies>consider</pomDependencies>
          <environments>
            <environment>
              ...

This didn't work, and any other solution that I tried didn't work either.
I'm using Maven for the first time, so maybe I'm missing something (or a lot of things)...
Does anyone have an idea? I'd be very thankful :o)
Comment: Are you able to make changes to the parent POM?
Comment: yes I am. I have full control on the project
Answer: It sounds like you need to "upgrade" to using a target platform to define your target.
How are you achieving this dependency in your development environment? If you are not using a target platform, you are inheriting whatever plug-ins are installed in your development (that is the default target platform).
Create Target Platform
First create a target platform. I recommend using the Target Platform Definition DSL and Generator to create and edit the target platform.
The tpd file will look something like this for orbit
target "name"

with source requirements

location "http://download.eclipse.org/tools/orbit/downloads/drops/R20150519210750/repository/" mars-orbit {
    org.apache.commons.lang3
}

location "http://download.eclipse.org/releases/mars" mars-release {
    org.eclipse.platform.feature.group
    org.eclipse.equinox.executable.feature.group
    org.eclipse.e4.rcp.feature.group
    org.eclipse.ui.trace
    org.eclipse.pde.feature.group
}

This example uses the already created OSGi bundles for third-parties. You can choose which release of orbit and browse all the available packages on the Orbit Site. You can also use auto-completion in the tpd editor.
Tycho Using Target Platform
Place the target file in a new plug-in. Name the target file the same as the plug-in. (e.g. com.example.releng.targetplatform.target is the name of the target file in this example.)
In this project, a pom that looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>com.example.releng.targetplatform</artifactId>
  <packaging>eclipse-target-definition</packaging>
  <parent>
    <groupId>com.example</groupId>
    <artifactId>com.example.releng</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <relativePath>../com.example.releng</relativePath>
  </parent>
</project>

You can configure (in your releng pom.xml) the target configuration like this:
<plugin>
    <groupId>org.eclipse.tycho</groupId>
    <artifactId>target-platform-configuration</artifactId>
    <version>${tycho-version}</version>
    <configuration>
        <target>
            <artifact>
                <groupId>eGui</groupId>
                <artifactId>com.example.releng.targetplatform</artifactId>
                <version>1.0.0-SNAPSHOT</version>
            </artifact>
        </target>
    </configuration>
</plugin>

Tutorial
Have a look at Code & Me's excellent tutorial on Tycho, it goes into more detail and over many steps goes from new project to a complete Tycho.
Comment: thank you for your answer. actually, all I needed to do is to add this line to my MANIFEST file: Require-Bundle: org.apache.commons.lang3 . thanks anyway
Comment: Hi again Jonah, I tried to solve my problem using a target platfom by doing exactly what's described on the **Code & Me**'s Tutorial, but I get this Error : [ERROR] Internal error: java.lang.RuntimeException: Could not resolve target platform specification artifact test:com.codeandme.tycho.releng.targetplatform:target:1.0.0-SNAPSHOT -> [Help 1].... any idea what might cause that?
Comment: @Cambiasso Please post as a *new* question and with the full trace (questions are more readable and then someone else may also know the answer better/sooner than me).
Answer: Your configuration looks correct. So if it doesn't work, you are probably missing the dependency declaration in the MANIFEST.MF. To do this, e.g. add Require-Bundle: org.apache.commons.lang3 in that file.
Background: A dependency in the POM doesn't automatically mean for Tycho that your bundle also automatically has this dependency. It only means that the artifact will be added to the target platform (given that pomDependencies=consider is configured and the artifact is an OSGi bundle - both is true in your case). Once it is in the target platform, it can be used to resolve the dependencies declared in your bundle's MANIFEST.MF.


How to delete iPad calendar events when no edit option appears

Question: How can I delete iPad calendar events when no edit button appears? Clicking on events only results in "details" button.
Comment: It sounds like you are subscribed to a calendar that you cannot edit. Check and see if the events where no edit button appears are all in one calendar.
Answer:
Go to  Settings app → Passwords and Accounts and scroll down.
The subscribed calendars should be there and click it and click delete account and you should be good.
Comment: Kari, welcome to Ask Different. When answering a question like this it is important to explain the reason why your steps are important, in this case because you suspect the issue is with a subscribed calendar. Also it's helpful to break down steps into bullet points.
Comment: Thank you! This worked perfectly. A malicious site created a calendar on my iPad and kept showing me alerts. There was even their server ip, so some interaction is possible. iOS should display a system message before approving such actions. Can't trust their Calendar app after this so will delete it.
Answer: If you don't have the ability to delete the event (it's a shared calendar) then the Edit button will not appear.
For such events, you should remove the shared calendar through Calendars at the bottom of the app, then choose ⓘ on the shared calendar and select Delete Calendar.
Answer: Go to the month calendar and double-click on the event.  It does not give you the option to delete but you can decline the invite.
Answer: Ok, I guess there's no answer for this yet, this is how I did it

Add a new calendar

on the Calendar app, select Calendars, Add Calendar

On the event you're trying to delete, select the newly added calendar in the Calendar option
Go back out to your calendars, and delete the Calendar you added on the first step
Your event is gone gone
Answer: At the bottom of iCal tap Calendar and it will show you list of all events automatically put into your iCal that has no Edit option.  Select item and adjust here.


I need clarification about the usage of the preposition "of" and "for"

Question: In schools at the time of assembly a good thought is shared with the students. Now my question how it should be announced... "THOUGHT FOR THE DAY" or "THOUGHT OF THE DAY".
Answer: The answer depends on your intended meaning. "Thought of the day" is one of a daily series. "Thought for the day" is a thought which is specifically for today. For example, if there is something that happens every Tuesday, your "thought for the day" might be specific to that day.
In your specific example (daily school assembly), I would use "of". Either word, however, would be appropriate here.


Can Pi 3b+ be killed by wire under ethernet port

Question: Can raspberry pi be killed by cable under ethernet port? I had moved pi on desk and placed it over a cable in area shown on picture (cable has only 5mm exposed wire), after that pi freezed and din´t boot again (red diode flash but not green one), i think a bus would be killed if shortcut ocured in this area?
sorry for poor english
Comment: Hi there - welcome.

I'm not clear about the cable. Mains power? Telephone? LAN? Is that your Pi in the photo, it has no SD card fitted...
Comment: If by "cable" you mean a bare metal wire, of course that could cause a problem.  If you mean something sheathed in plastic or something else non-conductive, then it should be okay.
Answer: Short answer is yes it could. Those pin leads sticking through the PC board are very sharp and will puncture through insulation. As long as the wires were connected to anything it could cause damage, including zero volts (ground). Without knowing exactly which pins touched, and tracing all paths (including ground paths) you'll never know for sure. 3.3v logic is a pretty wimpy.
For example, most modern AC adapter are isolated from earth ground, and in fact have voltage between the "-" side and earth ground (I've measured between 4 volts and 42 volts on various adapters. It's due the the voltage regulation circuit). It's usually a very low current, but enough to zap a Pi.
This topic could be debated forever because there are so many variables that can't be answered.


Getting sum of all the values of a choice column in a list

Question: I have a choice column with choices as numbers in a list. I want to sum all the values in the column and display it,
Is there any easy way of doing it?
Comment: Can you elaborate your question, please? Where would you want to store the sum of the values? One option in doing it is iterating the choice list and calculating the sum using CSOM and javascript.
Answer: As we don't get the sum option in the total section of modify list,we can do it by

Adding a number column and filling it using workflow with choice's number
Then for this number column we will be getting the sum option in the total section of modify list.

And it's done..


iPod nano Bluetooth problems with AirPods

Question: My iPod nano 7th generation gets connected to my AirPods 2nd generation. But when I play songs no sound comes out of it? I tried to reset and run diagnostics but it didn't work out for me.
Answer: AirPods 2nd generation require the device to be on iOS 12.2 or later, therefore they aren't compatible with the iPod Nano. The only iPod they are compatible with is the iPod Touch 6th generation.
AirPods 1st generation should work with the iPod Nano though as they don't have such a system requirement.
The technical specifications state:

System Requirements

iPhone, iPad, and iPod touch models with iOS 12.2 or later

Further down the page the compatible iPod models are:

iPod Models

iPod touch (6th Generation)


Major revise with three reviewers. What will editor consider after sending revision?

Question: Our paper recently got a "major revision", with comments from three reviewers. Two of them were actually ok, just answers for a few questions and rephrasing of some parts. The third reviewer showed harsh prejudice about our work and their comments  were are all marked with and exclamation mark ("!").
I want to know if at the end two reviewers accept and one does not, what will be the editor's decision, specifically for open access journals?
Comment: The third reviewer's comment does not sound that harsh.  Many reviewers, including me, are very pedantic about symbols and notations.     Preciseness and consistency are super important when it comes to clarity!
Answer: You can't predict what the result of your paper's peer review process will be. Anything can happen, because it's possible the reviewers will say accept and the editor rejects anyway, or the reviewers will say reject but the editor accepts anyway.
See questions:
Why does editor reject when reviewers recommend acceptance?
Why do editors sometimes accept a paper even if a reviewer recommends rejection?
Answer: Your job now is to use the reviews to make the paper better.
Carefully read and respond to all the comments. Pay particular attention to what you claim is a harsh reviewer. Set aside your perception of the tone and deal with the substance. When they are right, make the change. When you think they are wrong, explain why you reject that particular suggestion.
Then the editor will do what they decide. That is their decision, not merely a tally of the reviewers' votes.


Switched receptacle to fully powered receptacle withuot losing light function

Question: I have a bathroom receptacle that is controlled by the light switch. How do i PROPERLY separate the switch from the receptacle so as the light still works from the switch but the receptacle stays fully powered instead of shutting off when the lights go off
Comment: Can you post photos of the inside of the light, switch, and receptacle boxes please?
Comment: Are both receptacles controlled by the switch or just one of them?   If just one it's easy peasy, if both it might not be possible without running additional cabling.
Answer: You move the hot supplying the receptacle from the downstream connection FROM the switch to the upstream connection SUPPLYING the switch.
However the word "bathroom" should be a huge red flag here.  Do NOT touch a bathroom wiring project involving an outlet unless your intent is to replace said outlet with a GFI.  They do make GFI's with an outlet on one side and a switch on the other.
Comment: The outlet doesn't need to be a GFCI type if GFCI protection is being supplied from elsewhere.
Comment: What @Harper-ReinstateMonica said, but the first sentence is spot on.


Highest and Lowest $SU(3)_F$ states

Question: For the finite dimensional $(p,q)$-irreducible representation of $SU(3)_F$, we can label the states as $\mid T_3,Y\rangle$. Where $T_3$ is the third component of isospin and $Y$ is the hypercharge. How can I obtain the highest and Lowest weight states? I mean what are the $T_3$ and $Y$ values?
Comment: All finite dimensional representations can be built by taking tensor products of the fundamental and its conjugate..
Answer: You'd best read up on the classic texts by Gasiorowicz Elementary particle physics ISBN-13: 978-0471292876, Ch 17; or Greiner & Mueller QM Symmetries Ch 7, etc, or else WP  and also.
The rep D(p,q) built out of p triplets and q anti triplets will have a (provably unique!) maximum $T_3$ state $|M\rangle$ s.t. $T_+|M\rangle=0$ with obvious maximum eigenvalue $$T_3=(p+q)/2$$
given the triplet D(1,0)  on the $T_3$ , Y plane

and the antitriplet being its reflection around the origin. The iso-axis should be 1/3 below the isodoublet and 2/3 above the (strange) isosinglet here, so Y=1/3 for $|M\rangle$ and -2/3 for its minimum. We now exploit triplet and antitriplet additivity.
So, on this plane, $|M\rangle$ is the easternmost state. It can be shown its hypercharge is
$$
Y=(p-q)/3 ,
$$
so,
$$
|M\rangle= | T_3=(p+q)/2,Y=(p-q)/3   \rangle.
$$
To get to the lowest Y state, apply the V-spin southwestward shift $V_- ^p$, so that $V_-^{p+1}| M\rangle=0$.
The resulting minimum Y expression in p,q is messier,
$$
Y_{min}= -(q+2p)/2 .
$$
So you may work out how the baryon decuplet D(3,0) has minimum Y=-2,   the $\Omega^-$, and maximum $T_3=3/2$.  For the pseudoscalar or baryon octet D(1,1),  minimum   Y=-1,  and maximum $T_3=1$. For their paradigmatic D(7,3), below,  maximum $T_3=5$ and minimum Y=-5-2/3= -17/3, etc.

You can get the maximum Y in complete analogy, by taking q steps to the northwest, via U-spin, so $U_+^q$. These states are not unique, i.e. there is no guarantee they are an isosinglet.
Recall all multiplets are east west symmetric, (maximum and minimum isospin equal in magnitude), but not necessarily north-south symmetric!

Highest and Lowest $SU(3)_F$ states


Can't hibernate my Windows 8 system (Dell n5520 laptop)

Question: I'm using Windows 8 on my Dell 5520 laptop, with a problem that has been happening for the past few days I can't hibernate my Laptop. When ever I do it, sometimes it shuts down my system and sometimes it restarted to login screen.
Answer: You should check the power options first. May be there is an incompatibilities with Hybrid boot. You can access power options via the "Control Panel".

Carefully examine boot options.
For the selected power plan, click "Change plan settings". Then examine options.
Make sure "Show hibernate" is selected.
Try deselecting the "Hybrid Boot" option. Restart the computer and check again.
Access "Device Manager" and check ACPI options. Make sure no issues indicated.
If you suspect any problem with battery, before going to advanced troubleshooting, remove the battery and connect to AC power and check whether the problem exist.
Open "Event Viewer" and check "Administrative events" and "Windows logs \ System". Examine the logs. You can check individual operational logs.
Application and Service Logs > Microsoft > Windows. Check "Kernal Power" logs to check whether there are illegal operations.
I assume your machine is auto updating and is patched (drivers and Windows updates).

You can also boot to a Diagnostic Startup from msconfig (just search for msconfig using the search box located in the Start Menu).

In the "General" tab, make sure "Diagnostic Startup" is selected. Before confirming, not the "Startup settings" (Tab) that already exist.
You will be able to start with minimal services and devices. This will ensure no external problem that caused by a service or a device driver.
If the problem does not occur, you should go back to a normal startup with a custom selection of "Startup" settings. Examine.
Comment: thanx, but i checked almost everything u said n find ok,,, there is some windows related error and a message is show in start of windows to send some files to microsoft. cant understand the Xact problem but it is so irritating.
Comment: Yes there are errors in "Microsoft-Windows-Kernel-EventTracing/Admin" 1 error is "Session "" failed to start with the following error: 0xC000000D". one error is "The computer has rebooted from a bugcheck.  The bugcheck was: 0x0000009f (0x0000000000000003, 0xfffffa8008cee060, 0xfffff8800181b7e0, 0xfffffa800c683010). A dump was saved in: C:\Windows\MEMORY.DMP. Report Id: 021813-20625-01."
Comment: error: Windows failed to resume from hibernate with error status 0xC0000001.
Comment: Sorry for the delayed reply:
If you still need help please try a diagnostic boot:
Click Start > Type MSCONFIG > Press Enter (you could also run it as amin).
In the General Tab select Diagnostic Start > click APPLY and OK >  REBOOT.

It is better if you could send a dump file (uploaded to a sharing site and the link).

You could also adjust power options in order to stop hybrid boot if you have not already configured general hibernation.
Thanks!


This is a probability question which will require an expert mathematician's expertise. Below is the criteria

Question:
Eight handed Texas Hold-em game using a 52 card deck.
This is a 3 1/2 hour session in which there were 105 hands of poker played.
One Individual achieved the following four poker hands.
A. Quad Eights
B. Quad Jacks
C. Quad Kings
D. Club Royal Flush
Caveat - This man is blind in one eye, has one arm and was wearing a short-sleeved shirt - no chance of cheating.
I know this sounds like a ridiculous fallacy, but I was playing and witnessed this amazing occurrence.  I have given this problem to a few, expert mathematician friends to calculate the odds and am interested to see their answer.  Please include equations/formulas and process used.
Comment: Not exactly an answer to your question, but if this happened to me I would be very suspicious of cheating, especially if the cards are being handled by the players and not a dealer in a casino. There are many ways of cheating besides an ace up your sleeve, for example the legally blind card mechanic Richard Turner can do some amazing things.
Comment: The problem is that whilst this exact scenario is incredibly unlikely, there are many other very similar scenarios (e.g. two straight flushes, or four quads, or six full houses). Any one of those scenarios would have led to your asking a similar question. The chance of _one_ of those scenarios occurring is (whilst still unlikely!) much less unlikely. So it's hard to give a meaningful answer without being more precise about what probability you're actually asking for.
Answer: Shouldn't take an expert mathematician.
See image:

Quad Odds = .2%
Royal Odds = .00015%
Total Odds of Hitting Either are .20015% in any hand.
Total Odds of Hitting Either is 21.015% over 105 hands
Same calculation for 104,103,and 102 hands and you come up with a cumulative .1841% chance that over 105 hands you will hit any combination of 4 quads or Royals.
Exactly 3 Quads and 1 Royal multiplies the 21%,20.8%, and 20.6% from the quads by the .02% from royal and you get .0001417% chance that this exact run would occur.
Another way of stating would be that you would need to play 70,561,791 x 105 hands or 7.41 Billion hands to achieve this outcome within any set of 105 hands.
Lmk what you think.
Comment: This maths is way off beam. First, you appear to have taken the royal flush odds (0.00015%) from the 'Poker Probability' page on Wikipedia. This is the chance of making a royal flush  _with five random cards_, not two hole cards and the board. Your odds for quads are something different again. And the rest of the calculations also make no sense.
Comment: Also, I hope this guy took full advantage. Would be interested to hear how much he was up ;)
Comment: How do you go from  0.000141% to 7+ billion hands? 1/0.000001417 is about 700k, not 70 million
Answer: The probability of getting quads on a particular had is 1/407. For a royal flush, it's 1/30,940. The probability of getting three quads and one flush in a particular order (e.g. first three hands are quads, fourth is a flush) is (1/30,940)(1/407)^3*(1-1/407-1/30,940)^101. There are 105*(104 choose 3) ways to choose the order. If we take (1/30,940)(1/407)^3*(1-1/407-1/30,940)^101*105*(104 choose 3), we get 0.00000712652, which is about 1/14,0321.
If you literally want the probability of those exact quads, and specifically a club royal flush, then it's (1/30,940)(1/(13*407))^3*(1-1/(13*407)-1/30,940)^101*(105 permute 4) = 2.44803379e-8 or about 1/40,849,109.
The first number is the probability for getting exactly three quads and exactly one royal flush. The probability of getting at least three quads and at least one royal flush is slightly higher. The second number is for getting exactly one quad 8, one quad jacks, and one quad kings, ignoring all other quads.


parallel make that is aware of memory

Question: I use "make -j" (along with a makefile) to generate thumbnails and compute various statistics on a large collection of movie files. Depending on the movie, some of the statistics I compute require taking up most of my machine's memory. Is there a way to tell make not to run two such jobs at the same time? Or to kill jobs when memory gets scarce?
Answer: Make does not know how much memory is being used by some other process it invokes.  The only way you can do this is to encode it yourself into your makefile, by ensuring (through prerequisites) that make will never run two of these jobs at the same time.  You can use order-only prerequisites to ensure ordering without forcing "rebuild if changed" semantics, if these jobs do not have a natural ordering.

parallel make that is aware of memory


Which non-parametric test should I run on ordinal data from a small sample?

Question: I have one group of six raters who scored recordings of two separate six-person groups of participants, each group under separate conditions.  While the participants were divided into two independent groups, the ordinal data came from the same group of raters.  Due to the small sample size (i.e. 12 ordinal scores to compare both participants), which test could I run.  I've read that I'd need at least 20 scores to run a Wilcoxon...  Thank you for your time and consideration in answering this question!
Answer: It is not true that 20 scores are necessary for a Wilcoxon signed rank test. Significance by conventional standards is even achievable given your sample size. Consider a simple example in r:
Given x=1:6;y=2:7, wilcox.test(y,x,paired=T) results in V = 21, p = .02. Hence the test you have in mind may be suitable enough. You could also consider resampling methods like permutation or bootstrap tests, but there's not a lot of statistical power in a sample of 12 regardless of the test.
Comment: Thank you for the answer!  I'm a little confused, though, as another member posted that it wouldn't be wise to use the Wilcoxon signed rank test to test pair differences with ordinal data: @Scortchi (http://stats.stackexchange.com/a/47230/49494).  Anyway, there's no statistician I can speak to in person about my (unnecessarily complicated) study that is familiar with non-parametric statistics in SPSS, so I appreciate the feedback!
Comment: @sb415: interesting point. I don't usually advocate this, but you could make the explicit assumption that your rating options are spaced equally (more or less) along a latent, continuous dimension that they represent. This is how people usually gloss over Scortchi's point when averaging Likert ratings across several items of a questionnaire; it's called [classical test theory](https://en.wikipedia.org/wiki/Classical_test_theory). Evidently the [sign test](https://en.wikipedia.org/wiki/Sign_test) is the alternative, but given the size of your sample, I doubt it is powerful enough.


What's the difference between a SRAM cell and a D-Latch?

Question: They both seem identical - they both have an "enable" and a single input. When enable is high, the value stored in the element is set to the input. Are they functionally different in any way? (I know they are implemented differently, but I want to know if there is a difference in functionality)
Answer: An SRAM cell is functionally equivalent to a D latch (but not to a D-type master-slave flip-flop).
As you say, the implementation details are different: An SRAM cell is typically built so that it is written and read using the same pair of wires ("bit lines") — the difference is whether or not the bit lines are being driven by the control circuitry. On the other hand, a D latch normally uses separate wires for input and output, and the "write enable" logic is built right into it.
Answer: A typical D latch will have a single data input along with an enable; internal logic will combine those so as to yield "write-zero" and "write-one" behaviors.  An SRAM cell will have one or two bidirectional data wires and one or two enable signals (if two, one will control each data wire; if one, it will control both.  To read a memory cell, drive an enable signal while "floating" the data wire; the memory cell will drive the wire with its current state.  To write a memory cell, drive the data wire which should be low with a transistor that is stronger than the P-transistors in the memory cell and drive its enable.
Making an SRAM array can support two simultaneous independent reads requires only adding the additional wire necessary to give each cell two independent enables.  The extra wire often isn't "free" (it may require spacing things out a little wider than would otherwise be necessary) but it's still a cheap way of allowing dual-read capability.  Performing a write, however, generally requires using both data wires, since one of them can only be used to turn zeroes to ones, and the other can only be used to turn ones to zeroes.  It would probably be possible to design a memory system which could write ones to selected bits of location XX while reading YY, or read location XX while writing zeroes to selected bits of location YY, or write ones to selected bits of location XX while writing zeroes to an independent set of bits of location YY, but I'm unaware of such designs being used in practice even though there are many situations where they could be useful.


How do I choose a cable /cord, connected to mains part, that is compliant with IEC 60601-1 3rd ed.?

Question: IEC 60601-1 is a standard for medical devices. It describes which are the requirements for the Means of Operator Protection and Means of Patient Protection, the current leakages and so on. I don't understand which are the standard cables/cords that can be considered having 2 x MOPP up to 250Vac.
Comment: By reading the standard and checking your cable if it complies to every point mentioned
Comment: I think it has to do with selection of proper PSU (isolation and fuses) rather than a cable/cord.
Comment: The electrical requirements for an electrical protection, for being considered a 2xMOPP are the following: creepage 6mm or clearance 3.2mm and 4kVrms for solid insulation. It seems strange that I need a cable so big due to the creepage if the cable can be touched from the patient.
Answer: I can't speak for medical but to pass regulatory you need to make sure each part of the AC mains system has a certification. The power supply has to have the IEC60601-1 Certification (XP power has some good medical grade supplies with medical certifications.) The line filter\fuse box will need to be certified. Any of your own harnessing will need to follow creepage and clearance distances AND have a sufficient wire size and insulation. Your application may require isolation, so then your power supply will have to be isolated and you will have to incorporate this into you design.
Usually with the IEC standard they will tell you one thing and it applies to another section, they are really difficult to read and even the regulatory companies don't know all of the standard. (I had a regulatory tester try and certify an industrial product under a residential testing process, we had to convince them that ours was industrial)
The goal is to pass regulatory, they will check your design. You will probably want to start working with them now, they might charge you to answer questions, but it's better to change your design now than have it fail regulatory. Find some help for your specific type of device either from a consultant or somebody who has been through the process before. Either that or buy all of the certification documents (they are expensive, and can be a few hundred a piece.) then read them 10x through. Usually you need to make sure all the components you buy have the appropriate certifications.
Edit: I was looking through a power supply guide for an unrelated reason and I found this  (Power Supply
Technical Guide 2010/11).
From page 84:

Currently the standard is available in both 2nd edition and 3rd edition. The 2nd edition is IEC60601-
1:2003 and 3rd edition is IEC60601-1:2005. The 3rd edition was published in 2005 after 10 years of
development. Its purpose is to harmonize the terminology contained in the 2nd edition with other
standards such as IEC60950.
The 3rd edition differs from the 2nd edition putting emphasis on the OEM implementing a risk management system compliant with ISO14971. It also introduces new concepts such as essential performance of equipment and distinguishes between the operator and the patient with MOOP
(Means Of Operator Protection) and MOPP (Means of Patient Protection).
The concept of MOPP and MOOP allows the manufacturer relaxation in terms of creepage & clearance distances for MOOP if it is proven through risk management that the equipment will not come into contact with the patient in normal operation or under a single fault condition. The requirements for MOOP follow IEC60950 and for MOPP follow those required in IEC60601-1 2nd edition.
The structure of the base standard is hazard specific and provides requirements for evaluating the common hazards associated with electro-medical products. Its scope is to protect both patients and operators by reducing the likelihood of electric shock, mechanical, radiation, ignition of flammable anaesthetics, fire and excessive output energy hazards. The basic concept of the standard requires that two means of protection (MOP) or two levels of protection (LOP) under IEC60601-1 2nd edition are employed in various areas of the product so that
if one fails the product will retain another means of protection to contain any electrical shock hazard from either the patient or the operator.
To achieve these two means of protection, 60601-1 permits the use of three building blocks used in different combinations. These building blocks are insulation, protective earth and protection impedance. For example protective earth (1 x MOP) used in conjunction with basic insulation (1 x
MOP) provides the two means of protection required. The table below lists the permitted building blocks and the means of protection they provide.
Before the design can start the insulation class of the equipment must be determined; whether the equipment will be class I (reliant on protective earth) or class II (not reliant on protective earth) as must the classification of the applied part if applicable.
Comment: Thank you laptop2d for your answer. So do you confirm that creepage is also related to cables? And if it is so, how can I choose a cable from its creepage? Should I follow further standards?
Comment: You have to follow creepage and clearance requirements in IEC61010-1, and you should really get a copy of the standard to have for yourself. There is a table that dictates these requirements and it is dependent on what the material is and what kind of operating environment you have. The document actually provides this table, you double the creepage distances to provide 2x MOPP
Comment: The problem is that I already have the standard. I just want to have a check. But I think is better to find a specific consultant. This standard needs to be interpreted...


how can we find the CSRF vulnerability in a website?

Question: I heard that there are no specific tools available to test and find out the CSRF vulnerability of a website. So from a security testers point of view, how to test for the CSRF vulnerability?
Answer: I would probably take the following steps:

Identify a URL on your site where a CSRF attack could have a negative effect on your site.  For this example lets say a GET request to http://mysite.com/account/del will delete the account you are logged in as
Next create a basic HTML page that is totally separate from the site you are testing.  On this HTML page include the following
Next create a dummy account on the site you want to test, and log into that account.
With the session still active open the basic HTML page you created in the same browser.
If the account gets deleted, you have a CSRF vulnerability

This is a deliberately simple example, but it should give you the idea of how you can test for CSRF.
You can find resources on preventing CSRF attacks here.  Good luck!
Comment: Rats, you beat me to an answer! Here's a +1 and another link: https://www.owasp.org/index.php/Testing_for_CSRF_(OTG-SESS-005)#How_to_Test
Comment: @AnanduMDas if you want to test properly you should read the complete OWASP guide.
Answer: Make a simple Python app, that goes to, for our purposes, http://www.example.com/logout, and import the requests module (code below) and then run it. If you get logged out, you have a CSRF vulnerability.
Python 3.x.x:
import requests as r
r.get("http://www.example.com/logout")

Comment: There needs to be a little more than just an arbitrary request to a logout function. If an arbitrary system can issue a request to this function and some *other* client gets logged out, you have far more than a CSRF problem.


Can a simulacrum "regain" HP by being True Polymorphed into a creature that can do so normally?

Question: If a simulacrum is polymorphed through True Polymorph into a creature that can regain hit points normally, can the simulacrum regain hit points while polymorphed in that way?
Comment: @Someone_Evil AL tag might be relevant if there are, or ever woll be, specific limitations about that matter in organized play. And if there are none, saying it explicitly would help, too. Thus, I believe that al tag might be useful, or at least not harmful.
Comment: Related: [Simulacrum with regeneration](https://rpg.stackexchange.com/q/121755/28591)
Comment: The question doesn't mention AL organized play, and tags aren't used to add restrictions to a question (they're for categorization and attracting expert opinion), so I've removed the AL tag.
Comment: As to the content of the question: Your first paragraph is a very clear question, but I'm not sure what the second paragraph means. It looks to me like the question in the first paragraph is what you really care about. I would remove the second paragraph and focus on the first question. Then, depending on the answer to that question, you can address any other concerns by posting a follow-up question separately.
Answer: Yes, and no.
The simulacrum's statistics are replaced. This means you take whatever form of record sheet you're using for the simulacrum, put it aside, and grab the stat block of the creature you've polymorphed it into and use that while the polymorph effect persists.

The target's game statistics, including mental ability scores, are replaced by the statistics of the chosen beast. It retains its alignment and personality.

While polymorphed, the creature is a tyrannosaur, a giant ape, or what have you. For the duration of the polymorph effect, the simulacrum effectively does not exist, so none of it's restrictions apply to the new replacement.
A true polymorphed creature can regain hit points through resting (polymorph doesn't last long enough to complete a short rest to use hit dice, let alone a long rest). Using true polymorph also lets you potentially pick something with regeneration, a feature not found on any beast I'm aware of.

The target assumes the hit points of its new form. When it reverts to its normal form, the creature returns to the number of hit points it had before it transformed.

When the polymorph effect expires and the creature resumes being a simulacrum, it has however many hit points it had before the polymorph. Of course, that's how it works for any other creature, too.
Answer: I'd say no.
True Polymorph must target a creature or non-magical object. Simulacrum is an illusion. It is not a creature, and it certainly isn't non-magical.
Comment: You might want to quote and cite the *simulacrum* spell with regards to it not being a creature, that isn't quite obvious to me and your answer hinges on it.
Comment: **"Simulacrum:** [...] The duplicate is a creature [...] and [can] be affected as a normal creature."
So, yeah, True Polymorph *can* affect Simulacrum.
Comment: Oh, and Welcome to RPG.SE! Take the [tour] if you haven't already and see the [help] or ask us here in the comments (use @ to ping someone) if you need more guidance. Good Luck and Happy Gaming!


Has the possibility of Higgs boson being a composite particle excluded already?

Question: I heard some theory, such as technicolor, predicts the Higgs-like particle discovered at LHC should be a composite particle (correct me if I am wrong). Has this possible been completely excluded already?
Answer: In this article of January 17, 2013, Matt Strassler quotes Riccardo Rattazzi as follows:

we can't rule out the possibility completely,
there's some amount of circumstantial evidence against this new  particle being a composite Higgs
if it is a composite Higgs, there are some indirect near-term measurements that could well reveal it; completely direct measurements are many years off

Strassler summarizes that

...the new particle is probably not a generic composite Higgs particle; it behaves too much like an elementary Higgs is expected to behave.
But the jury is still out, because there are some classes of composite Higgs particles that do specifically resemble elementary ones.
Comment: Thanks. Seems Strassler's webpage is not available to me, unless I remove "/quotes".
Answer: The Higgs is a composite particle. It's just a combination of more elementary fields than quarks and leptons. There simply is no coupling of massless particles to a supposed condensate of a Higgs field (with a 246GeV VEV). The assigning of a finite VEV is completely arbitrary and constructed to fit the facts. Mass is a property coming about by massless particles interacting vectorially with one another and not by interacting with a virtual scalar field. I haven't seen one good explanation of how mass arises from this. I mean, as Einstein suggested, an understandable explanation that could be given to a six year old child. The math points out that mass comes about, yes. But how in practice? Mass is just put in by hand. In a way though ghat maintains gauge invariancy, which was the reason it couldn't be added manually in the first place. So it's thrown in by means of Higgs. But still by hand, not as a property of particles. While it is. Indeed by interaction, as per Higgs, but not with Higgs, as per Higgs. But with themselves.


How to change size of Android ScrollView

Question: I have a layout like this (abstracted):
Scrollview - fill_parent
LinearLayout - wrap_content
ImageView 1 - wrap_content
ImageView 2 - ...
ImageView 3
...
In the course of user interaction some images are replaced by larger or smaller ones, shortening or lenghtening the area to be scrolled.
And that is the problem. The Scrollview (SV) does not know about the change, so either it scrolls over a lot of empty space at the bottom, or cuts off a picture or two at the bottom.
Question 1: Can I somehow make the SV readapt to the changed hight of the LiearLayout (LL)?
Question 2: I can obtain the current size through getHight on the LL. But supplyong it to the SV via changed LayoutParams does not work - of course, that would only change the height of the SV on the screen. Is there a way to put the changed height of the LL into the SV in the code, somehow?
Question 3: I havn't tried it yet. Would creating the SV, LL and its children in code and then adding/removing children of changed size as required, make the SV adapt to the changes?
And last question: Is there a better aüpproach, except using ListViews?
Answer: Have you tried calling requestLayout() when images change?


List of visa access for each country

Question: Is there any website where you can choose "I am from Country XYZ" and then it shows you a list of countries you can e.g. go to without a visa and the allowed duration of stay.
I know I could go to the Ministry of Foreign Affairs website of my country, but I want to see the passport status of other countries as well.
Comment: Note: you are asking the impossible (if we read literally). I assume you mean just visa free for "tourism", right? (so edit the question). Is visa on arrival not allowed?  What about Wikipedia? It has good summary, and usually updated (and link to relevant embassy). good for planing, but never trust a non official website. Before travel you should check embassy about changes and exact rules. [e.g. https://en.wikipedia.org/wiki/Visa_requirements_for_German_citizens ]
Answer: There are many. Wikipedia for example Visa requirements by nationality, and Passport Index. As stated in a comment by @Michael Hampton, always confirm the data found via such sources with an official source to check it's not out of date.
You can also usually find this information via the Immigration / travel advice pages of many countries eg

for US passport holders it's International travel country information

for the UK it's Foreign travel advice

Canada is Travel advisories

These advisories typically include links to the destination country's Immigration pages, so they are a good way to find an official source of information about the target country.
Finally, there is Timatic, the system used by airlines, which provides comprehensive information and allows you to search using a variety of criteria eg transit point(s), residency Timatic and the IATA Travel Centre
Comment: Wikipedia is the go-to source for such lists, but they can be out of date, so one should always confirm the data found there with official sources before relying on it.
Comment: A problem with the wikipedia lists is they don't sufficiently highlight countries with advance authorisation programs that the politicians refuse to call visas.
Comment: @PeterGreen do you mean all the ETA/ESTA/eVisitor etc? Those are usually well indicated on the Wikipedia pages. If you meant something else, can you give an example?
Comment: They are indicated in the text, but the coloring on the maps makes no distinction between countries that are truely free of visa's and visa-like things and countries that require some kind of advance authorisation.
Comment: @PeterGreen Not sure what you mean, eg for Argentina the map distinguishes between ID card travel, Visa not required / ESTA / eTA / eVisitor, Visa available both on arrival or online, Visa on arrival, eVisa, Visa required. Covers all bases as far as I can see.

List of visa access for each country


Average Reward (On policy control) Reinforcement Learning

Question: In Sutton and Barto Book, under section 10.3. Average Reward: A New Problem Setting for Continuing Tasks, what is the use of subtracting reward and the average reward? What are they trying to solve here, I understood what an average reward is, but failed to understand why it is being subtracted from the reward at each time step. (shown in the images below)
where average reward is given by
Answer: Section 10.3 presents a nondiscounted continual learning setting.
If we use the rewards as is (without subtracting the empirical mean reward at time step t), then the return and value function can grow without bound.
On the other hand, the differential return $G_t$ as you screenshotted above converges to zero in the limit of $t$.


2D Magnet-like repelling behavior

Question: If somebody wanted to develop a system between two intersecting rectangles so that the rectangles would, in a gradual process, push eachother away from one another until no longer intersecting, with the repelling force being stronger depending upon how deep the intersection is... what would the math look like?
Comment: Should they accelerate until not intersecting? And should they slow down gradually to stop just when they stop intersecting?
Comment: Yes, they should accelerate until not intersecting- as far as slowing down once they stop intersecting, the world's friction would take care of that once acceleration is no longer applied to the rectangles from their intersection.
Answer: a:Object;
b:Object;

dx:Number = a.x - b.x; //distance by x
dy:Number = a.y - b.y;
distance:Number = Math.sqrt ( dx*dx + dy*dy );

If you want to simulate magnet behavior, you want to base forces on distance between them. Physics say so:

But you will be fine with:
force = Math.floor ( MAX_FORCE / distance );

And then you need to use trigonometry to apply force as velocity change:
var angle:Number = Math.Atan2 ( dy, dx );
var x_speed:Number = force * Math.cos ( angle );
var y_speed:Number = force * Math.sin ( angle );

a.vx += x_speed;
a.vy += y_speed;
b.vx -= x_speed;
b.vy -= y_speed;

//and of course a.x += a.vx etc.

Comment: Never mind, thank you again for your help and willingness to have a look at my code. My aforementioned problem was due to my own faulty handling of friction, I debugged and located it and handled it. Everything works great, thanks again! :)
Comment: After implementing this to my game, it -almost- works, but I am experiencing an issue: Object1 is a player character and object2 is a dummy box that does nothing other than sit in place unless outside forces are applied to it; when object1 is moved into object2, and presses too far into object2, first it stops moving (desirable considering its intersection has gone too far, and is being repelled too hard to continue pushing any further) but then when object1 stops accelerating into object2, object1 is repelled out of object2, but then object2 sort of 'sticks' to object1, and they both scoot
Comment: and they both scoot away in the direction opposite what object1 was originally pushing from to begin with. I have no idea what would cause this behavior?
Comment: I need to see your code.

2D Magnet-like repelling behavior


Background image reversed on pages after home page

Question: I was wondering if anyone could provide a solution in regards to the reversing of a background image which flips on every page after the home page.
My website is www.michaelabetchley.com
Comment: This is something the theme is doing deliberately, as a design decision. You need to take it up with them.
Answer: It looks like your theme is dictating that presentation in it's stylesheet.  You can override this using the WordPress Customizer, and going to the Additional CSS section to ensure that you don't lose your custom styles when you update your theme.
Glancing at the page, this CSS should help the other pages have the same presentation as the home page by overriding the properties set on the custom header image:
<code>body.has-intro:not(.home) .intro-media img {
    max-width: 100%;
    margin: 0;
    -webkit-filter: none;
    filter: none;
    -webkit-transform: none;
    -ms-transform: scaleX(1);
    transform: scaleX(1);
}
</code>
You can read more about this feature, and get more familiar with how to use CSS in WordPress in the codex: https://codex.wordpress.org/CSS


Geometric Series and Sum to infinity

Question: Given the first two terms of a geometric progression is twice the value of the fifth term, I want to find the least value of n such that $S_n=a(1-r^n)/(1-r)$ is within 5% of $S$. So if we let the first term be $a$ and common ratio be $r$, equating $a + ar = 2/(1-r)$ we can solve for $r= 0.684$ approximately. But how to find $S_n$ within 5% of $S$? Does within means less than or equals to because when I tried to simplify that inequality, I eventually failed to take ln on both sides to solve for n due to getting a negative number..
Comment: There is no such geometric progression. Since $a+ar+ar^2+ar^3+\cdots=\frac a{1-r}\text,$ you know that $a+ar=\frac{2a}{1-r}$. But this is the same thing as saying that $1+r=\frac2{1-r}$, which is equivalent to $2=1-r^2$.
Comment: Did you mean the sum of the remaining terms (i.e. from the third term) to infinity?
Comment: How did you arrive at $0.684$?
Comment: You are right twice the value of the sum of the remaining terms to infinity!
Comment: Thank You for the clarification. Does that make sense to solve now?
Comment: Nice to be right sometimes :)
Comment: So you should rework your attempted solution.
Answer: Here we assume $|r|<1$ as it involes $S_\infty$.
$$a+ar=2\left(\frac{ar^2}{1-r}\right)\\
(1+r)(1-r)=2r^2\\
r=\pm \frac 1{\sqrt{3}}$$
Now we want
$$S_n>0.95\ S_\infty\\
\frac {a(1-r^n)}{1-r}>0.95 \ \frac a{1-r}\\
r^n<0.05\\
n>\frac {\log(0.05)}{\log(1/\sqrt{3})}=5.453\qquad (\text{for r>0})\\
n=6\qquad $$
Comment: Observe that $|1-S_n/S_{\infty}|=|r^n|=3^{-n/2}.$ And that $3^{-n/2}<0.05$ iff $3^n>400$ iff $n\geq 6.$
Comment: I realised the qns actually meant the sum of first two terms is twice the fifth term. When I solved for common ratio r, I got -0.648. But now the expression (-0.648)^n < 0.05 doesn't really make sense for me to solve..
Comment: That's quite a different question altogether.
Comment: You can use the absolute value of $r$ for the calculation. This gives $n=7$, which also applies to the case for negative $r$.
Answer: Given ${ar^n}$ its sum is $S=\dfrac{a}{1-r}$
To satisfy the condition that the first two terms are twice the remaining sum we have the equation
$$a r+a=2 \left(\frac{a}{1-r}-a-ar\right)$$
which gives (positive) solution $r=\dfrac{1}{\sqrt 3}$
To get the $5\%$ of the sum we solve the equation
$$\frac{a(1-r^n)}{1-r}=\frac{5}{100}\frac{a}{1-r}$$
which simplifies to
$$r^n=0.05\rightarrow \left(\frac{1}{\sqrt 3}\right)^n<0.05$$
apply logarithm to both sides we get $n\geq 6$
Indeed the sum is $S=\dfrac{3}{3-\sqrt{3}}\approx 2.366$ while $\sum _{n=6}^{\infty } \left(\dfrac{1}{\sqrt{3}}\right)^n\approx 0.08763$ and this value is $3.7\%$ of the whole sum
Hope this helps
PS
$n=6$ is valid also if you take the negative ratio $$r=-\dfrac{1}{\sqrt 3}$$
In this case the sum is $S=\dfrac{3}{3+\sqrt{3}}\approx 0.634$ and its $5\%$ is $0.0317$.
Remembering that in alternating series the residue sum when stopping at $n$ is less than $|a_{n+1}|$ we can solve $\left(\dfrac{1}{\sqrt 3}\right)^{n+1}<0.0317$ which gives $n\geq 6$ like before
Comment: To get 5% of the sum, solve 5/100 or 95/100 in your eqn?
Comment: I realised the qns actually meant the sum of first two terms is twice the fifth term. When I solved for common ratio r, I got -0.648. But now the expression (-0.648)^n < 0.05 doesn't really make sense for me to solve..

Geometric Series and Sum to infinity