Return Custom Response via Marketing cloud API

Question: I wish to expose a custom service API (Soap/Rest) from marketing cloud so that when an external entity invokes the same, I can have some logic to process the data from the request and then return the result to the external entity. Is there any way to do this in SFMC?
Comment: There are custom activities and entry points you are able to configure within installed packages.  These allow for some interaction between Marketing Cloud and an external application via Postmonger (Javascript) callbacks.  They could possibly give you what you are looking for.
Answer: I'd recommend creating a CloudPage 'Code Resource' with a JSON Content Type, then use an available server-side language (e.g AMPscript or SSJS) to parse the incoming request, action any events, then return a response.
I typically use AMPscript in my code resource pages and make an external POST request to the endpoint with key/value pairs as x-www-form-urlencoded data, then use the QueryParameter AMPscript function to parse them and return a response to the page (as a json object).
Note, as you are using a Code Resource, it won't be counted as a super message (from a billing perspective).


Could a terrestrial planet become a gas giant?

Question: I know that gas giants are much larger than terrestrial planets, but wouldn't several million or billion years allow for it to gain mass from collecting space debris and the like?
Comment: If Earth flew into Jupiter, is Earth considered a gas giant now?
Comment: @Trevor I mean, it would only add to Jupiter's mass, so no.
Answer: NO
First, gas giants are many times heavier than terrestrial (rocky) planets. The lightest gas giant in our solar system, Uranus, weighs in on 14.536 Earth masses (Neptune is smaller, but a bit heavier). Even if all the asteroids in the Asteroid Belt (total mass 3% of the mass of the Moon) and all the objects in the Kuiper Belt (total mass ~ 1/25 to 1/10 the mass of the Earth) were poured onto the Earth, it would not get appreciately heavier. Even the Oort Cloud - the teneous sphere of proto-cometary bodies surrounding the Solar System out to ca. 3 light years - only has an estimated total mass 10–100 times that of Earth.
Second, a gas giant isn't just a massive planet. It has to consist mainly of hydrogen and helium. Even if you could pile enough asteroids and comets onto the Earth to make it as heavy as a gas giant, it would be an extremely different beast. Almost all the hydrogen and helium in the solar system were caught up in the Sun and a few gas giants while the solar system was formed - there simply isn't enough gas floating around to slowly transform a terrestrial planet into a gas giant.
Third, it is believed that a gas giant couldn't form as close to the sun as the Earth is, since the solar wind would slowly strip the hydrogen atmosphere away. Kepler has discovered a few "hot Jupiters"; gas giants close to their suns, but it is believed they were formed further out and moved closer due to gravitational influence from other large bodies - and that they will shrink if they stay close to their suns.
The closest possibility I can think of is that a gas giant could absorb a terrestrial planet - but I doubt that this is what you're looking for.
Answer: You'd need a number of unlikely things to happen, chief amongst which is an incoming supply of material that doesn't deliver so much energy that it blasts stuff back out into space but exceeds the rate at which the atmosphere is depleted due to effects like the solar wind or Jeans escape.
If you want your world to become a gas giant, then you need to first increase its escape velocity to the point that it significantly exceeds the average drift velocities of light elements like hydrogen and helium at the temperature of that planet.

As you can see, Earth would need to increase its escape velocity to nearly 20km/s to hold on to hydrogen, and to do that its mass (assuming density stays about constant_ needs to increase by a factor of 5. This means you need four earth masses of earthlike stuff just sort of flying around, in trajectories which will cause it to fall in to the target planet instead of being catapulted out into space, and it all needs to accrete without blowing any of the rest of it away and only then can you start dropping in the multiple earth masses of water (or whatever other volatiles seem nice) onto your super-earth in order for it to form a gas world.
I don't know if there's a minimum acceptable mass to distinguish a gas giant from a mere superterrestrial, but it  probably lies somewhere between about 10 and 14.5 earth masses (the latter being the mass of Uranus). So you now need another 5+ earth-masses of volatiles that will fall into your proto-gas-world, gently enough that it doesn't all immediately boil off again.
(note that you could combine these steps, if you could gently land four+ earth masses of volatiles on earth, somehow, you could avoid the need for the rocky and metallic stuff in the mass-building phase)
So that's 9 earth-masses of spare matter. The mass of the Oort cloud is only just enough to push you over the 5-earth-masses threshold, so you'd have to crash a few of the rocky inner-system worlds to get enough stuff in one place. The same is likely to hold true for any other mature system. Obviously a system still developing has its protoplanetary disk, and some of that disk is probably going to form into a gas giant, which will start off as a rocky nucleus upon which more stuff and volatiles will accrete.
Answer: Not in a mature system, unless something weird happens.
The density of the cloud leading to a planetary system formation is way higher than the density of the space left after the system has formed.
Thus that additional mass has to come from somewhere else, like:

the planetary system crossing another cloud and capturing most of its mass
a crossing with another planetary system and subsequent gravitational havoc somehow resulting in mass gain
Answer: It certainly seems plausible that every gas giant looked like a small rocky planet at some stage of its development.
The reason that stars in general have a mixture of giant and small, gas and rocky planets is that at a certain stage in the original formation of the planetary system, pretty much all the gas and dust near the star has been swept up. There's no more space debris to collect because it's all in the planets.
After this point, all the planets are rather stuck at their current size and composition. Any body that is not already a gas giant is out of luck.


Looking for a refference that a cross-validation should be repeated

Question: I am looking for a reference (a citable paper) about repeating the cross-validation to decrease the variance of the results.
Answer: First of all, you may have a misconception: repeated/iterated cross validation will not lead to lower uncertainty on the cross validation results iff the models are stable.
If your models are unstable, evaluating more iterations/repetitions/runs of the cross validation allows you to characterize the instability of the predictions (variance in predictions of different surrogate models that were trained on slightly different/perturbed training data) - and the average over many such surrogate models will have lower variance from this source. Personally, I consider estimates of prediction stability as their own figure of merit (though it is good to be aware of the variance contribution to the cross validation error estimate).
The uncertainty (variance) due the limited number of actual cases tested which does not increase by repeating the cross validation is not affected.
Some of our paper could be relevant (but they each contribute only bits and pieces to this topic):

Beleites, C.; Baumgartner, R.; Bowman, C.; Somorjai, R.; Steiner, G.; Salzer, R. & Sowa, M. G. Variance reduction in estimating classification error using sparse datasets, Chemom Intell Lab Syst, 2005, 79, 91 - 100. We did observe some reduction in variance of 40 $\times$ 5-fold CV vs. only one run of the 5-fold CV. At that time we just realized that a bit of improvement may be gotten that way. Here'd like to draw your attention to the fact that even for the situations where we observed largest reductions, $s^2 (40 \times 5$-fold$) \approx 0.8 s^2 (1 \times 5$-fold$)$ - so the observed reduction is nowhere near e.g. $\frac{1}{\sqrt{40}} \approx 0.15$
Beleites, C. & Salzer, R. Assessing and improving the stability of chemometric models in small sample size situations, Anal Bioanal Chem, 2008, 390, 1261-1271 explains how to use iterated/repeated cross validation to characterize model stability.
I may say that we still hadn't realized that we're subject to multiple quite different sources of variance, so please disregard the paragraphs that try to estimate effective sample size.

Note that I argue from the perspective of an applied scientist who is interested in estimating the predictive performance of a model built on the data set at hand and at the same time is typically hampered by very small sample sizes (both absolute and relative to the number of variates).
The sources of error [of the CV results] I consequently focus on are quite different e.g. from the perspective of comparing training algorithms and from the perspective of having somewhat more comfortable sample sizes (in particular, absolute numbers of independent cases) at hand.
E.g. Vanwinckelen, G. & Blockeel, H. On estimating model accuracy with repeated cross-validation BeneLearn 2012: Proceedings of the 21st Belgian-Dutch Conference on Machine Learning, 2012, 39-44 argue that repeated cross validation is not worth while, because they find bias more important than the variance reduction. They have about 2 orders of magnitude the sample sizes I typically deal with and do not discuss model stability at all.
Comment: Thanks. The last paper is quite important for what I wanted to do. It shows that although the variance is decreased, the mean does not converge to a number one would get on independent test sample, which is what we are actually trying to estimate.
Comment: The pessimistic bias of resampling validation schemes (cross validation, out-of-bootstrap) is well known. Whether that bias or the finite absolute sample size model instability- (sample size relative to model complexity) is the dominating contributor to your validation uncertainty depends a lot on circumstances.


what relationships exists between the BER vs SNR graphs of QPSK and QAM modulation schemes on data throughput. which scheme does better?

Question: Using QAM and QPSK modulation schemes, RF field measurements like received signal power and pathloss were obtained from where the SNR values were estimated. Their BER values were also calculated and Matlab was used to plot the BER vs SNR graphs for QAM and QPSK. Now from these graphs, how can one tell how each modulation scheme is able to maximize data throughput.
Comment: You appear to have the results in front of you so what can you conclude? I don't see any graphs and unless someone has telepathic powers, nobody else can.
Comment: Really I wish i could, but i'm constrained... but in comparing QAM and QPSK from their BER performance (i.e from the BER vs SNR plots), QPSK modulation technique had lower errors compared to QAM. So I'd like to know if any relationship exist between the BER and the data throughput any modulation could offer. Does any relationship exist between these two variables?. This will help me know which one of QAM or QPSK modulation technique maximizes data throughput
Answer: Directly comparing QAM4 to QPSK4, these should behave identically in theory.
Both use the same constellation points, and the SNR and BER depend on how much noise is required to sort a symbol into the wrong bin on reception, and how often the noise in the channel exceeds the maximum in a way that actually causes an error.
Whether we use QAM or QPSK, the nearest constellation point for every symbol received would be the one that lies in the same quadrant. In principle we should arrive at the same result for each symbol, whether we decode it using cartesian or polar coordinates.
QAM4 is somewhat special, though: we do not really encode information in the amplitude, as that is the same for all constellation points. In the general case of QAM with more points, the receiver needs to calculate the channel gain in order to decode the signal properly, and normally bins for received symbols would not extend outward over the entire quadrant, but cover only a rectangular area centered around the nominal value.
So, if the constellation points are \$(-1,-1); (-1,1); (1,-1); (1,1)\$, and the received signal was \$(-2.5,0.3)\$, QPSK would place it in the same quadrant as \$(-1,1)\$, while QAM would reject it and register an invalid symbol.
This means that QPSK might recognize the symbol correctly in a case where QAM rejects it, but the noise here still exceeds the signal, so it is also possible that QPSK might recognize the wrong symbol here.
The received data stream would be exactly the same for both where symbols were recognized, but the QAM stream also has some symbols replaced by error markers, so an error correction algorithm on top of that would have more information to work with, since it doesn't have to decide which bits to discard.
For constellations with more points, QAM usually comes out ahead though, as the distance between two points on the unit circle is \$2\sin\frac{\phi}{2}\$, with \$\phi=\frac{\pi}{N}\$, so you can see that diminishing quickly for larger N, while the distance between QAM points is inversely proportional to \$\sqrt{N}\$ (assuming a quadratic constellation).
As said, QAM requires you to estimate channel gain, so you need a mechanism for that as well, like a pilot tone or symbol, or a preamble for intermittent transmissions.
Either of these can be combined with a channel-multiplexing method like OFDM, which helps against other common effects in wireless communication, such as specific notches in the frequency response of the channel.


Why do we use the same parameters for the joint, marginal and conditional distributions in VAEs?

Question: I've noticed in several resources on variational autoencoders (for example the Wikipedia article), we use the same parameters theta ($\theta$) for the prior, likelihood, posterior, etc distributions. For example the equation $p_\theta(x) = \int_z p_\theta(x|z)p_\theta(z)dz$. Aren't $p_\theta(x)$ and $p_\theta(z)$ two different distributions, so how can we parameterize them with the same $θ$ params. I might be misunderstanding something about what it means to parameterize a distribution with neural nets..
Answer: Of course, it is not the same parameters that are used to parametrize the likelihood or the posterior for example, but we keep the same letter (here $\theta$) to refer to the parameters of the true (original) distributions. On the other hand, in VAEs, $\phi$ is often used to refer to the parameters to the variational distributions. Indeedn, this can sometimes be unclear.
To address your second point, let us say $p_{\theta}(x|z)$ is a Gaussian distribution, classically it is parametrized by a scalar mean $m$ and scalar a variance $s^2$ : $p_{\theta}(x|z)=\mathcal{N}(x;m,s^2)$, here $\theta=\{m,s^2\}$. Now when we say that this distribution is parametrized by a neural network we mean that $m$ and $s^2$ will be the outputs of a neural network with input $z$. Let us denote this neural network $f_{\theta}$, $\theta$ is here the set of weights and biases of the neural network. We can write $p_{\theta}(x|z)=\mathcal{N}(x;f_{\theta}(z))$.


Error C1083: Cannot Open Include file. File included properly in code

Question: So I've looked into this issue, and nothing has helped me so far. I've read numerous topics, many people say the same things about it not actually being able to find the file. In my project, I can right click the header where it is including (and giving the fatal error) and it will open the header file, everything loads works perfectly fine in the editor, but Visual Studio still tells me that the file cannot be found while compiling. I've double checked the spelling, I've added the double quotation marks around the includes and additional libraries, and removed them, and nothing is working.
I'm trying to include the header files for MySQL. I added and tried the include and library directories as well as libmysql.lib to the proper locations (Additional include directories, additional library directories, and Additional dependencies) with (to my knowledge) most combinations of directory paths.
The folder structure has the mysqlcon folder in the solution directory, and the project in its own folder. When I include the mysqlcon\include and lib folders. I tried:

..\mysqlcon\include
"..\mysqlcon\include"
$(SolutionDir)\mysqlcon\include
$(SolutionDir)\\mysqlcon\\include

Nothing seems to be working. I'm at a total loss. I even rebuilt the entire project today, got all the dependencies, references, build order, files, vcprojs redone, and I'm back staring at the same problem.
Answer: Found a solution... I'm not sure why it worked before, but I changed
<code>#include "mysql.h"
</code>
to
<code>#include "..\mysqlcon\include\mysql.h"
</code>
and it worked perfectly.


O(n^2) algorithm to approximate the sum of the log of the singular values of a matrix

Question: Given an $M \times N$ matrix of rank $N$ ($M \ge N$) with $i^{th}$ singular value $\sigma_i$, does their exist an $O(M^2)$ algorithm for approximating the sum $ H =\sum_{i=1}^N \log(\sigma_i)$ with absolute error less than $M^{-\alpha}\log(\frac{\sigma_{max}}{\sigma_{min}})$ and $\alpha > 0$? Such an algorithm would be useful for fast computation of the entropy of normal distributions that arise in the probabilistic formulation of linear inverse problems.
Comment: I wish I could make some assumptions about the matrix. In reality there is just such a large diversity of applications that result in different kinds of matrices. I suppose I should try to identify a few of my favorite problems and see what can be done (although in light of the response below it seems apparent that O(M^2) might be a bit too naive).
Comment: Isn't this equivalent to finding the determinant of $A^*A$? (which doesn't have, yet, an $O(M^2)$ algorithm)
Comment: Do you expect your matrices to be sparse?
Answer: $O(M^2)$ is barely enough time to read the entire matrix, let alone to do any meaningful computations.  Suppose for instance that M=N was A was a permutation matrix except with the 1 coefficients replaced by coefficients between 1 and 2, so $\sigma_{max} / \sigma_{min} \sim 2$.  In order to compute H to the desired accuracy, one has to locate every last non-trivial entry of the permutation matrix, which can barely be done in $O(M^2)$ operations (and in fact one has to lose a log or two to do the required high precision arithmetic).
If one is willing to have a little less accuracy (or perhaps if one places some "incoherence"  assumptions on the matrix that spreads it out more than in the above permutation matrix-like example), then there is a chance that random sampling methods would work.  Under reasonable hypotheses on the matrix, the singular values of a randomly selected set of rows or columns (or a random minor) are approximately proportional to the singular values of the whole.  There is a certain amount of literature on this subject (see e.g. this paper).


Get the value of one attribute from the reference key of another table?

Question: I have two tables named as ps_order_detail and ps_product_lang in MySQL. I want to get the product name from one table whose reference key is in another table. I have two tables. First the ps_order_detail database table is like this
CREATE TABLE IF NOT EXISTS `ps_order_detail` (
  `id_order_detail` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `product_id` int(10) unsigned NOT NULL,
  `product_attribute_id` int(10) unsigned DEFAULT NULL,
  `product_name` varchar(255) NOT NULL,
  PRIMARY KEY (`id_order_detail`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

--
-- Dumping data for table `ps_order_detail`
--

INSERT INTO `ps_order_detail` (`id_order_detail`, `product_id`, `product_attribute_id`, `product_name`) VALUES
(1, 5, 11, 'iPod touch - Capacité: 32Go'),
(2, 2, 2, 'iPod shuffle - Color : Green'),
(3, 5, 9, 'iPod touch - Disk space : 8GB');

and another table for ps_product_lang is like this
CREATE TABLE IF NOT EXISTS `ps_product_lang` (
  `id_product` int(10) unsigned NOT NULL,
  `id_shop` int(11) unsigned NOT NULL DEFAULT '1',
  `id_lang` int(10) unsigned NOT NULL,
  `name` varchar(128) NOT NULL,
  PRIMARY KEY (`id_product`,`id_shop`,`id_lang`),
  KEY `id_lang` (`id_lang`),
  KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `ps_product_lang`
--

INSERT INTO `ps_product_lang` (`id_product`, `id_shop`, `id_lang`,  `name`) VALUES
(1, 1, 1, 'iPod Nano', 'In stock'),
(2, 1, 1,  'iPod shuffle'),
(3, 1, 1,  'MacBook Air'),
(4, 1, 1, 'MacBook'),
(5, 1, 1, 'iPod touch'),
(6, 1, 1, 'Belkin Leather Folio for iPod nano - Black / Chocolate'),
(7, 1, 1, 'Shure SE210 Sound-Isolating Earphones for iPod and iPhone'),
(8, 1, 1, 'Lappy');

Now you can see that in the table  ps_order_detailthere is one column named as product_id and in the table ps_product_lang there is one column for name . so my question is how can I get the name of product by combining both ps_product_lang and ps_order_detail table.
I want to get the product name from ps_order_detail product_ida attribute? So any help and suggestions will be really appreciable. Thanks.
Answer: Try this:
SELECT DISTINCT a.product_name
FROM `ps_order_detail` a
JOIN ps_product_lang b
    ON a.product_id=b.id_product

Comment: how to get the distinct name values from it?
Comment: updated the answer.


how to design switching regulator in battery operated device?

Question: My device consists of ATMega, GPRS modem and sensors. Modem occasionally hangs and I need to reset it from mcu. The whole system is powered from li-ion battery. I can't find any switching DC-DC converter that would be controlled from the microcontroller, is capable of delivering 3 A current and eats no battery in on-state.
Comment: A switching regulator that "eats no battery" is not possible. The best efficiency you'll find for these circuits is in the neighborhood of 95%. To get more help on choosing or designing a regulator circuit, it would help to know what are the input and output voltages you need.
Comment: "eats no battery in..." standby, maybe?
Comment: I made some corrections (you should have more care about formulating the question) but what do you mean with the last statement?
Answer: The TPS63020 comes close to doing what you want, regardless of what you want :-).
Datasheet here .
 Expensiveish at $7 or so in 1's and has charming 3mm x 4mm DSJ package and variants, but is super marvellous.
Buck boost across single LiIon range +.
 3A out in most cases.
 Variable output version or fixed.
 Synchronous input and output switches.
In power save mode it's 60%-70% efficient at 100 uA load meaning if you don't need it it at worst is "wasting" 40 uA compared to your 3A load = 0.0013% power loss. Chance are you can disable it in that mode.
If you can provide a better description of what you want to achieve under what conditions we can provide an even better solution.

Example: Low quiescent current supply idling in background to protect against occasional battery dropout.
I made a SMPS for a product that had 4 C alkaline cells providing 5V (yeah right) and 3V3 rails in an electrically noisy environment. I made a basic boost converter using a 74C14 CMOS gate package as the sole smps controller [!!!] driving two LDO regulators for the electronics. When battery voltage was as high as it should be the LDOs were fed via Schottky's from battery.
 If ~= zero drop when on battery had been required a MOSFET could have been used in place of Schottky diodes.*
 The smps ran at all times, usually under no load,  and When needed the smps seamlessly stepped in to take up the load. Total running standby current including Iq for one LDO was under 100 uA.
These and its various brothers and sisters and many of these .
Almost gratuitous picture of one of the products using this arrangement (as far as I know). :

Example 2 :  Minimisation of loss when backup protection system is not needed but a "diode" is needed in the battery feed.
 * This product uses a forward biased MOSFET for reverse battery protection. The usual battery box terminal style protection was not deemed feasible and a Schottky drops too much voltage when using 3 x NimH cells.   When the batteries are correctly inserted the MOSFET is forward biased and is turned on - an inder 20 milliohm Rdson FET is used. When batteries are reversed the MOSFET is reverse biased and never conducts. [MOSFET D & S connections are reversed from usual so FET operates in 2nd quadrant so body diode is reverse biased when batteries are incorrectly connected.
Comment: ... must... resist... +1... for photo only... argghhh
Comment: @tyblu -  You like the photo of my rowing machine then ? :-). I only did the power supply :-).


How to create a read-only flag that can only be used by an admin to actually flag nodes?

Question: Long story short, I installed Flag because Best Answer was not working properly.  Is it possible to configure flags so that only the admin can flag something (aka an answer as being approved) but everyone can view the flag?
Answer: Try setup Flag as "global flag" and then in "Flag access" setup "Roles that may use this flag" check-boxes only for Admin.
If in this case flag will not be shown for other users - you need create script that get flag value for each node and display this info.
$flag = flag_get_flag(FLAG_NAME);
$node->flag_value = $flag->get_count($node->nid);

Answer: You can use the Rules module for this, especially by using the not commonly known/used Rules Action "Trim a flag", which looks like so:

Here is a rule (in Rules export format) that you could use to trim a flag, say with machine name best_answer:
{ "rules_limit_access_to_best_answer_flag" : {
    "LABEL" : "Limit access to best answer flag",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "flag" ],
    "ON" : { "flag_flagged_best_answer" : [] },
    "IF" : [
      { "NOT user_has_role" : { "account" : [ "flagging-user" ], "roles" : { "value" : { "3" : "3" } } } }
    ],
    "DO" : [
      { "flag_trim" : {
          "flag" : "best_answer",
          "flagging_user" : [ "flagging_user" ],
          "cutoff_size" : "0",
          "trim_newest" : "1",
          "permission_check" : "1"
        }
      },
      { "drupal_message" : {
          "message" : "Be aware: since you do not have the administrator role, your flagging-attempt has been ignored.",
          "type" : "warning"
        }
      }
    ]
  }
}

After you adapt best_answer to the machine name of the flag you're using, simply use the Rules UI to import the above rule in your own site (and enable the rule afterwards).
Some more details to explain the magic in the above rule:

Rules Event = A node has been flagged (using the best_answer flag).
Rules Condition = The flagging user does not have role "administrator".
Rules Actions =

Trim the best_answer flag, with cut_off value equal to zero (which is the same as saying "Ignore any flags from the flagging user").
Set an appropriate warning message.

So with this approach, any user who has permission for the flag, will actually see the flag. But if they try to use the flag, it will be ignored unless they are an administrator.
Happy flagging with Rules!


Testing my system, I need a script that will use as much ram and swap as possible

Question: I'm testing my system with zram, I need a script that will use as much ram as possible. This script should fill up my ram with random stuff not just zeros.
Answer: Just run :
echo {1..1000000000}

Explanation :
The Shell, Before giving the command to the kernel, Expands all the regular expressions and short-hands. The expanded command is temporarily stored in RAM. The above command expands to a very large command and hence it will completely fill the RAM (tested on 8GB).
WARNING : This is not a controlled way of filling RAM. You might get stuck after running this command. I advice you to keep your system monitor open (for watching RAM usage) and try with smaller numbers.
Comment: This does not seem to work with a busybox echo (no regular expression support). I found this solution: `tail /dev/zero`
Comment: @falstaff `tail /dev/zero` is brilliant although it seems to crash firefox. Where did you learn about it? Your comment was linked [here](https://askubuntu.com/questions/1188024/how-to-test-oom-killer-from-command-line?noredirect=1#comment1985993_1188024)
Comment: I guess its the OOM which kills firefox? Probably just because it uses quite some memory so that OOM feels its "the best" target... I do not remember where I learned about it or whether I came up with it myself.
Comment: Helped a lot while analyzing some JVM memory consumption issue. This memory was not claimed back after the process execution completed. Could claim it back only after killing the bash process (terminal) from where this command was executed.
Answer: memtester is a user space program designed to allocate memory (any amount you specify) and test it with random patterns. It will avoid swap usage though. But if you take all memory away with memtester first (check with free -m) and then start anything else that uses a lot of memory (gimp, firefox, ...), that should get the swap going.
Another alternative would be something like openssl rand -base64 $((1024*1024*1024)) | less and in less use > to jump to the last line; this will cause 1GB of base64 encoded random data to be loaded in memory (but it's slow).
If you're looking for something more efficient, a small script in any scripting language (e.g. Python) might do.
#!/usr/bin/python2
import numpy
result = [numpy.random.bytes(1024*1024) for x in xrange(1024)]
print len(result)

That would allocate 1G of memory with random data and print the number of MB allocated before terminating. If you want more than 1024M, adapt the xrange value accordingly.
Comment: Super, just what I was looking for. Thank you for the quick answer.
Answer: As prophecy201 suggested, stress is a great tool to use up your system's memory. Adding more workers will use up more RAM, but it will also use up more CPU, which is pretty ineffecient if all you want is to test RAM. Not to mention that the CPU will be needed by zram for compression.
Instead, you should increase the amount of RAM that is used with the --vm-bytes flag. For example, to use up 4 GB of RAM with one worker:
stress -m 1 --vm-bytes 4G

You may also find the --vm-keep flag helpful as it will hold the memory allocation instead of continually reallocating, so the memory usage will be constant instead of fluctuating:
stress -m 1 --vm-bytes 4G --vm-keep

Lastly, take a look here to make sure zram is what you really want; since you do have swap, zswap may be a better solution: zram vs zswap vs zcache Ultimate guide: when to use which one
Comment: I find it easy to use. I used this to test if my Swap is working. `sudo swapon -a`
Answer: I would suggest to use the program stress, installable from the repositories with sudo apt-get install stress.
To test your RAM use stress -m x where x is the number of workers which will fill up the ram. Choose more workers to use more RAM.
Answer: Expect zswap to work extremely badly---make performance much worse---if you fill memory with random bytes, especially if you randomly touch lots of memory in a hurry.
zram compresses the contents of pages of memory, and compression only works if the data are not random.  Real data (especially in-memory data) is usually fairly compressible.
zram also only helps if you have "locality of reference", like most programs have---they tend to touch the same pages repeatedly before touching some other subset of pages.  (This is why normal virtual memory works, too.  Compressed caching is just adding a new level of memory between normal uncompressed pages and disk storage.)
If you know this, and are intentionally trying to test zswap under worst-case conditions, maybe to find bugs, go for it.
But if not, you should probably read Paul R. Wilson et al's paper "The Case for Compressed Caching in Virtual Memory systems," which explains when RAM compression helps, when it hurts, and how an adaptive algorithm can use in when it helps and not when it doesn't.  (The paper is online in html on some USENIX site, and in pdf form somewhere else.  Google it.)
Unfortunately, as far as I know zram does not do the kind of general automatic adaptation they describe, so you have to set the compressed cache size at some reasonable usual value for your workload.
One case where that will work well is if you have more RAM than any one of your programs uses, but tend to have idle applications using up memory too, and switch between apps.  Idle apps' pages will tend to get compressed, and when you switch back to them, they only need to be uncompressed rather than loaded from disk.


Is a current signal more robust than voltage signal from noise? Why?

Question: I am trying to transmit a 3.3V digital signal over 20 cm distance. The problem is the environment might be noisy because of high current wire near it. I read that current signal is more robust than voltage signal. Does that apply to my case? and why?
Comment: The only way to change current is to inject or extract either charges or time, versus voltage which only needs a change in energy.
Answer: It's not whether the signal is coded as voltage or as current what makes it more or less robust, it's the power involved.
Receiver of voltage signals (e.g. CMOS gate input) have extremely high impedance. So a noise voltage source does not need to provide much power to disturb the signal. That's why you shouldn't use it for "long" (some 0.1m) distances, because changing magnetic fields through the area circumscribed by the signal and GND line can easily induce some volts; although not much power (BTW: that's why twisted pairs are used; it causes the noise voltages of each twist to roughly cancel out each other).
Current signals (e.g. 4-20mA) are working against some resistors at the receiver side that require quite a voltage to generate the current. That means noise (voltage or current) source need to provide considerable power to have an effect. This is what makes it more robust.
But as thobie mentioned there are other good ways of reducing noise interference than just by requiring more power:
E.g. using differential signaling. That way you can still use voltage signals with high impedance receivers (but need as second signal line).
That's what is used e.g. for USB.
Comment: So if i use a termination resistor at receiver side for my case, for example 1kohm resistor to gnd, it would help my circuit?
Comment: Yes, because then a noise signal needs much more power to create the same noise voltage (compared to a high impedance receiver). Of course the transmitter side needs to be able to drive required power too. This increases signal to noise ratio (which is measured as ratio of **power** values).
Answer: LVDS uses low impedance termination at the receiving end so the robustness comes also from the "current signal" + many other thing related to the design of the interface.
Comment: Welcome to EE.SE. Your answer is short, uses an unexplained acronym and has no links to reference material and so is unlikely to be of any use. Consider improving it. Have a look at the quality of answers given to other questions on the site - particularly ones with high votes.


Refractive index and color

Question: Does the color of an object have anything to do with its refractive index, and if so, what is the relation?
I tried googling this and searching through the questions on stack exchange, but I haven't been able to find anything addressing this exact question.
Comment: Color is related to many many many different things, so you should constrain things a bit: do you mean a thick transparent solid plain object made of a pure mono-material with a smooth air/material interface ?
Comment: [Cauchy's Equation](https://en.m.wikipedia.org/wiki/Cauchy%27s_equation#:~:text=In%20optics%2C%20Cauchy's%20transmission%20equation,who%20defined%20it%20in%201836.): $n = a + \dfrac{b}{λ^2}$ (where $a$ and $b$ are constants)
Answer: The color of an object is completely determined by the refractive index and the geometry of the object. The reason why it is not obvious is that one has to takes the imaginary part of the refractive index into account. The real part determines the wavelength of light in matter and the imaginary part describes absorption of light in matter.
When you ask what color has an object the physics question you ask is what light is reflected or transmitted by the object to your eye. Transmission and reflection are well described by the fresnel equations. They only depend on the the geometry of the problem, the refractive index of the object and the wavelength of the light. For the object to have color the refractive index has to change with wavelength, which we call dispersion.
There are now certain possibilities for the refractive index:

Refractive index is purely real in the wavelength region of interest => no absorption (e.g. diamond, glass, air):
Light is mainly transmitted. Few percent are typically reflected. Dispersion is only visible in certain geometries for example prism or rainbow.
Refractive index has a low imaginary part (e.g. Rust, coal...): As in 1. few percent are reflected but in contrast to 1. the light transmitted into the substance is absorbed. Dispersion of the imaginary part determines the color. Rust has an absorption peak around 400 nm (blue) and therefore looks reddish.
Refractive index has a high imaginary part (e.g. metals): Most light is reflected. Higher absorption of a color now means that it looks more like that color because higher imaginary part means higher reflectivity. For example copper has a high absorption in the red and low one in blue resulting in a reddish color.
Comment: Well, not entirely. Many things, including the famous blue jay feather, have an apparent color due to interference effects alone.  The color of nontransmissive objects is due to absorption and reflection, and for all practical purposes there is no real part of the index of refraction.  Even for transmissive objects, dispersion & prism can lead to the apparent color depending on the view angle.
Comment: I don't see the contradiction to my answer. I stated prism as an example in 1. and i wrote "determined by refractive index and shape of the object" (maybe I should have written geometry). For interference clearly the geometry and refractive index matter. In 2. and 3. I explained the situation for nontransmittive objects. What I wanted to make clear is that the refractive index is the only material property you need to know to calculate optical response (i.e. apparent color), at least in the realm on linear optics.
Comment: Ive always seen Fresnel equations applied to transparent media and metals. Would they explain the color of wood, plastic, etc?
Comment: Yes they would in principle but maybe not quantitatively. The fresnel equations are strictly true only for a flat surface. For plastic the predicted reflectence should still be a very good approximation. The reflection is however diffuse because of surface roughness of the plastic. If you polish it you should see a clear reflection. For wood I think a flat surface is too much of an approximation. Still you only need the refractive index of wood to calculate the color but instead of the fresnel equations you now need to solve the maxwell equations directly (e.g. with a FDTD solver)
Comment: @Jannick The contradiction is to the first sentence, "The color [...] is **completely** determined by the refractive index and the geometry". Instead of "completely", it's more like "mainly" determined by these.

Refractive index and color


Wireless printing from Android phone

Question: I have a samsung galaxy prevail through boost mobile what kind of printer do I need and how do I print from my smartphone wirelessly?
Comment: You can use pretty much any printer – and chose from a large set of [Printing apps](http://android.izzysoft.de/applists/category/named/office_print) – basically 3 groups: [Vendor specific Printing apps](http://android.izzysoft.de/applists/category/named/office_print#group_52), [Vendor overlapping Printing apps](http://android.izzysoft.de/applists/category/named/office_print#group_53), and [Cloud Printing](http://android.izzysoft.de/applists/category/named/office_print#group_54). With the latter group, keep your "privacy wishes" in front of you – everything you print goes to the cloud then.
Answer: Google Cloud Print
Generally, you'd want to use Google Cloud Print compatible printers. The full list of Cloud Print ready printers is available here.
If you're stuck without one of these printers (i.e. a classic printer), you've still got options:

Before connecting your classic printer, confirm if you have:

Google Chrome
Windows or Mac computer

And if you're using Windows XP, the Windows XP Service Pack 3 (SP3).
  Then, follow the steps below to enable the Google Cloud Print connector:

Open Google Chrome.
  In a new tab, open chrome://devices
  You'll see a list of devices already registered with Google Cloud Print, and new devices available on the network.
Under "Classic printers," click Add printers.
  You'll see a confirmation that Google Cloud Print has been enabled.
To learn more, click Manage your printers.

To connect classic printers in a business or school environment, use the Cloud Print Connector service on Windows or Linux.
After adding your Cloud Print ready printer, use the Google Cloud Print app to start printing
In versions of Android newer than 4.4, the app isn't necessary:

Open the page you want to print in its app (Photos, Chrome, etc).
On the app, click Options.
Select Print.

Wireless printing from Android phone


No opposition filed within time limit

Question: what do think about patents no. EP0529765A1 and no. EP0529766A1 ? The status both is: "No opposition filed within time limit" (Status updated on 18.07.1997). Does it means the patents expired ? Thanks again.
Answer: When a European patent application is in order for grant, it may be opposed within 9 months by any person (EPC art 99). This is initiated by another person filing a notice of opposition.
Consequently, if no notice of opposition is filed within the 9 months, the event "no opposition filed within time limit" occurs.
It does not mean that the patents have expired. They may or may not have expired, but that's separate from whether an opposition is filed.

No opposition filed within time limit


Why is my world not unlimited?

Question: Strangely I can see all my world with its very limited resouces. I can't get past the edge. I bought it only last night (23/4/15) so isn't it supposed to be unlimited? It's mostly water with some various biome islands... spruce trees on most, one with oak & beech. How can I play in such a tiny world? I've made about 5 different worlds, & all are like that, some more watery than others. All small in area. A couple of sheep, maybe a cow, no chickens or pigs so far. Does it improve with time?
Answer: Since version 0.9.0, Minecraft: Pocket Edition allows infinite worlds, but classic 256 by 256 worlds are still supported as a separate world type.
While creating a world, look for an Advanced button, and select Infinite world type in Advanced options.
Answer: In the latest version of minecraft you can edit your worlds and make them infinite.
Just press the edit button next to the world, and Press the "make infinite" button.
Comment: Is there such a button?
Comment: Yes in version 11.1, when you edit a world, there should be such a button
Comment: Ok then. Need to update minecraft soon.

Why is my world not unlimited?


Achieve continuous predictions in linear regression with all categorical independent variables

Question: I am working my way for the first time through predicting a continuous dependent variable in a problem where all independent variables are categorical. Say I need to predict a continuous variable starting from a single categorical independent variable that can take 4 values. After dummy-encoding the categorical variable, a simple linear regression would find the coefficients, and predict discrete values (in my case, predictions would be four values). Is there any way to smooth my predictions?
Comment: Can you give more detail on what you mean by "smoothing" & its purpose? After all, with only four possible predictor patterns it seems natural enough that there should only be four possible predictions - would you really want to make different predictions for individuals with identical predictor patterns?
Comment: What's continuous is the *distribution* at any combination of the covariates. If you only predict the mean of that distribution (a single point) at such a combination, then naturally that's not continuous when you have discrete predictors.
Comment: Can you say why you want to make predictions?
Answer: Not in a meaningful way, unless you have additional information to add to your model.
If all you know is the values of these categorical predictors, then any data belonging to the same category (or combination of categories) will obviously be predicted by your regression model to have the exact same value. To change that, you'd need to have some way of additionally distinguishing points within the same category. Barring that, I don't see how you could say something like "actually this point should be a bit higher than the others" (other than choosing randomly).
Smoothing already implies some additional dimension of interest in the data. That is, there has to be something to "smooth over". E.g. if you had time series data you might have reason to smooth your predictions over time, taking a weighted average of data from adjoining time points. (Although I'd say it generally makes more sense to add this dimension to your model explicitly at the fitting stage, rather than smooth predictions from a model without it.)
Update: Also, it's not necessarily a problem if your predictions are discrete. As Glen_b touched upon as well, a linear regression assumes the data follow a continuous (Normal) distribution around some mean (that is a function of your regressors), but that mean can be discrete, and in fact have any arbitrary distribution you fancy. So if you think your categorical regressors are a good (enough) model for your data, there's no reason to be concerned.


Ubuntu only shows music files on Andrioid Device

Question: I am having trouble browsing my documents on my Android device through my Ubuntu 12.04 Laptop. It's a Samsung Galaxy Mega and my laptop is a Lenovo Z580. I am able to connect and browse my phone but it only shows music or video files. However on Windows they show up and I'm able to browse and view them.
And yes it's Android 4.2.2 and uses MTP for transferring files.
Is there any way I can view these files? (I don't want to use FTP if possible)
Cheers,
sid
Answer: Install MTP support on Ubuntu:
Open Terminal and execute the command:

sudo apt-get install mtp-tools mtpfs

After installing reboot your computer.
Then set your phone to use MTP when connected to the PC.
Once connected, you will see the device in your file manager:
Answer: After struggling to transfer photos from my android sero 7 tablet to ubuntu 14.04, I changed my tablet from mtp(media device) to ptp camera by going to tablet settings, then usb connection, then connect as camera (ptp).  After connecting tablet to computer via usb I clicked on the device folder on the left which still showed as audio but I was able to find my photos through the dcim file and copying them to pictures folder in ubuntu. I tried it twice and e-mailed one photo so far it seems to be working.


Derivation of quantum virial theorem

Question: The quantum virial thoerem is derived by arguing that the left-hand-side of the following expression is zero for stationary/bound states:
$$
\frac{d}{dt}\langle{\bf{r} \cdot \bf{p}}\rangle = \bigg\langle\frac{\bf{p}^2}{m}\bigg\rangle - \langle \bf{r} \cdot \nabla{V} \rangle
$$
In the classical case this follows from a consideration of the time average of this expression, which tends to $0$. Why is the same true, intuitively, in the quantum case?
Comment: [WP](https://en.wikipedia.org/wiki/Virial_theorem#In_quantum_mechanics). Hint: go to the Heisenberg picture.
Answer: For any operator $O$, the expectation value in a stationary (eigen-) state $|\psi(t) \rangle $ is constant,
$$
\langle O \rangle = \langle \psi(t) | O | \psi(t) \rangle = \langle \psi(0) | e^{i E t} O e^{-i E t} | \psi(0) \rangle = e^{(i E - i E)t} \langle \psi(0) | O |  \psi(0) \rangle  =  \langle \psi(0) | O |  \psi(0) \rangle
$$
where $E$ is the energy of that state.  Since this expectation value doesn't depend on time, the time derivative is identically 0.

Derivation of quantum virial theorem


edit grub to have multi boot option to have more than 2 OS boot option

Question: How do we edit grub in a UEFI HDD to have multi boot option having more than just one linux one Windows OS, readily being selected and run at PC startup
Comment: What's is your current configuration? What Operating System are you currently using?
Comment: All installs must be UEFI, grub can only boot other installs in same boot mode or other UEFI installs. I like to turn off os-prober in grub and add my own entries to 40_custom. But to learn I originally copied stanza's from the grub.cfg os_prober created, before backing it up & creating new without os_prober. https://help.ubuntu.com/community/Grub2/CustomMenus & https://askubuntu.com/questions/659528/grub-menu-with-windows-10-and-ubuntu-14-04/659910#659910 &
Answer: If at least one of your Linux distributions includes the os-prober package and integrates it with the GRUB configuration tools (like Debian/Ubuntu does, for example), then it might be capable of automatically finding a number of Linux versions and adding them to the boot menu for you.
If you choose this approach, you might have to use that distribution as the "primary bootloader maintainer", and might need to run sudo update-grub on that distribution before any kernel update in the other Linux distributions gets actually used at boot time.
Alternatively, you could allow each Linux OS maintain their own GRUB instances, and have one of them (the one selected as the first one in the BIOS boot order) augmented with custom menuitems like these in the /etc/grub.d/40_custom file:
menuentry 'Some other Linux distribution' {
    search --no-floppy --fs-uuid --set=root <UUID of filesystem containing /boot/grub of the other Linux distribution>
    set prefix=$(root)'/grub'
    configfile $prefix/grub.cfg
}

menuentry 'Windows 7 or newer' {
    search --no-floppy --fs-uuid --set=root <UUID of the EFI System Partition of the Windows installation>
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

In other words, for Linux distributions, the idea is to just let GRUB read the configuration file maintained by the other Linux distribution when its boot entry is selected. Assuming that the versions of GRUB are not incompatible, it should just display the boot menu of that distribution effectively as a "sub-menu" of the boot menu of the "primary" installation. If the versions of GRUB are not compatible, it should be possible to chainload into the other Linux distribution's version of GRUB, similar to what is done with the Windows UEFI bootloaders.


How can I make sure my UV-purificator kills bacteria?

Question: I'm going to show a UV-purificator for water on science fair. How can I easily check if purificator kills most of the bacteria? I need a quick and possibly easy method.
Comment: How did you use to test for whether your UV-purificator works? Did you just assume it works?
Comment: Well... I will also check if it works using this method. It's a student project so we can just follow the descriptions on the internet and hope that it will kill bacteria. And even if it won't work with 100% efficacy, we just want to show killing effect of UV.
Comment: There are not many quick inexpensive methods that can show the number of dead/viable cells. Staining+microscopy is a quick method but I am not sure if you can obtain a microscope and the stain (whether the school will fund you for that). Moreover counting bacterial cells directly would require some patience and expertise. Colony based methods (plating) are convenient but would take time.
Answer: Not having the equipment needed to actually count bacteria, you can use things you know bacteria does to find out how much they were affected.
My approach would be thus:

Select a model bacteria. There are a few candidates, but probably the most readily available is lactobacilli, which can be found in yogurt and (loosely translating terms of art) is a Gram-stainable fermentor-sometimes-breather.
Infect the water with a known quantity of bacteria and a food source (lactobacilli eat lactose - ie from milk) and equally divide it into a control and experimental group...
You'll need to find an alternative way to estimate the bacterial content in the volume of water used compared to a control colony. Since lactobacilli produce lactic acid, you could use the pH value of the water (either with an indicator or a meter) to detect bacterial metabolism, compare that to the control's pH value.
Record the UV exposure time from the experimental group, and isolate the control group from any potential UV light source, such as the sun.

Even if you find that, for example, your particular strain of lactobacilli is not sensitive to your UV light source, that's a perfectly scientific result! How did you obtain it? The source likely knows what kind of bacteria it is. Perhaps the UV light merely interferes with bacterial metabolism, and doesn't kill it. Unanswered questions are wonderful, you may have provided a place for further research to take place. You could then use the two groups to infect a food source (ie milk) and compare post-exposure growth, depending on how much time is available.
Comment: OP is looking to "check if purificator kills _most_ of the bacteria" - viable cell count is probably overkill for that. I suggest a simple comparative approach. Dead bacteria don't behave like live bacteria, so one only need compare the chemical content of the water containing "possibly dead" and "known live." Say there's no difference - it wouldn't make sense to do a cell count at all. You would expect the known live bacteria to _do more_ than a dead one, thereby changing the chemistry of the water.
Comment: OP asked whether most bacteria are killed. So you count the live ones remaining to determine that. That's how it is usually done. The dead ones can also possibly cause harm because of endotoxins. Even in that case an explanation of an existing methodology to quantify the "chemical content" is, IMO, essential.
Comment: I think the main point that is left unaddressed is regarding the technique that can be used to quantify viable cells in the sample after treatment. Your answer as of now focusses only on how to set up the experiment properly.


Fingering for right hand thirds in Bluebird by Alexis Ffrench

Question:
Hi, I'm trying to figure out how to play this part of the song (Bluebird by Alexis Ffrench). It seems impossible (for an amateur) to play it with proper rhythm. Could anyone please show me the fingering for right hand? Thank you.
Comment: Hand shape and size affects fingerings for thirds a great deal. Can you manage 42 51 42 31 | 42 31 42 51 42 54 | 42 for the first phrase?
Comment: Thank you for response. Here you go: http://bit.ly/2Yo1Fls
Comment: Thank you for your time and help. I will try your option and get back here to confirm :)
Comment: OK, i got it :) The only problem for now is 54 but I'll manage. Thank you very much for your help. You saved me couple of hours of frustration ;)
Comment: Note that since the pedal is down, you don't need gluey legato and can jump to a more comfortable fingering on that last third if 54 doesn't suit you. It will still sound legato so long as you're light with the hand.
Comment: Pedalling through it all isn't the best idea - is it?
Comment: @Tim I don't know the piece but it looks like it would sound gruesome if you did. I just meant that the last two thirds in the bar are on the same harmony so the pedal can help out.
Comment: @replete - not a criticism of your answer, just a comment about the pedal mark being 8 bars minimum, with different harmonies all 'blending' into one mush.
Comment: Incidentally, a similar run of fast thirds occurs in piano adaptations of Pachelbel's Canon, which might provide a nice familiar comparison if someone wants to write up an answer.
Answer: I think your notation is for the part starting at...

Except for this passage all the rest of the RH is single notes not double notes. I'm a little suspicious that the recording was multi-tracked so that the accompaniment part is one track and the treble part is another track. When the treble part track gets to the part in thirds it may be performed with two hands.
Playing the passage with one hand presents a fingering problem, because it moves around points where the hand changes position and the fingers must cross over each other.
I think one approach to playing it is focus the fingering around the 'shake' parts, the parts where two notes are alternated rapidly. I put those two passages in boxes...

...both are centered around tones C5 Eb5 but the first shake involves the tones below and the second the tones above.
The first shake, in Eb major RH C Eb to Bb D normally is a position change 13 35. That's a really inconvenient place to perform a shake so I tried alternate fingering 24 13.
The second shake, C Eb up to D F fall on the usual Eb major fingering 13 24.
After managing the shakes the trick is to get up in position for Eb G to G Bb. There doesn't seem to be a good way to do that other than just a quick hand shift. I opted for placing the thumb on the Eb for 13 35, but it seems like 24 45 could be used too.
That my attempt at a fingering.
I tried watching the pianist's hands in the video, but his hands are obscured by his back during this passage!
I would really love to know how it was executed on the recording.
Answer: There are a couple things to take into consideration when looking for fingering with thirds. Always use finger combinations that where there is a finger in-between like 53, 42, and 31. The other finger combination you can use is 21. Place your hand with 53 at the highest note. In this case I would put 53 on the G and E flat and then use my other fingers. You'll have to shift hand placement to reach the G and B flat at the end of the phrase. To make this hand shift you should use 13 and 12 to move up. This can be done by using 13 and 12 instead of 13 and 24. On the fourth measure I would use 35 for E flat and C. Then 12 for B flat and D then 13 for C and E flat, then 12 for DF and then position your hand for the other notes.


CNNs: Why do the filters identify more complex features as the model goes on?

Question: I have a feeling that it's related to how different output layers are stacked up against one another? However, there's a missing link in that argument that I can't completely get to.
Answer: In a convolution neural network, every neuron in layer $i+1$ depends on few neurons in layer $i$. It thus aggregated local information for layer $i$. As you go through the layers, the subset of input that the neuron sees grows, and so the features depend on a larger part of the input. Eventually, neurons depend, in directly, on all inputs.


How did the Precursors know to invade earth? (Pacific Rim)

Question: The Pacific Rim wiki explains that the Precursors became interested in Earth during the Triassic period, or some pre-history time, but it wasn't suitable for them. Millions of years later, the pollution of humans renders Earth sustainable for the Precursors and cue invasion. But how did the Precursors know the time was right? There is no indication that they could watch the Earth, and the only hint we have that they glean any new information about Earth is the development of different Kaiju to fight the Jaegers, and the drift with the Kaiju brain. So if those are their only eyes into our world, as hinted, what told them that Earth was now ripe for colonization?
Answer: Presumably small kaiju were sent from time to time to test. The Pacific ocean is huge, and if those arrivals occurred in early history, there would be no record of it. If any accounts did survive, they'd simply be today's myths of dragons or sea monsters. There exist enough weird legends from both East Asia and the sea-faring explorations of Europeans for this to be plausible.
Answer: If in Pacific Rim's universe, the dinosaurs were indeed creations of the Precursors as the scientists states, then it's possible that the Precursors are still capable of watching Earth through the dinosaurs' fossils and skeletons who are preserved in museums and therefore can very much look on the outside world and its atmosphere. Of course it would be odd that paleontologists and other people who analyzed those skeletons for years never noticed some kind of "communication device" inside those bones but it's alien technology so it could work and look different enough than what we expect. After all, even a dead Kaiju's brain still had some form of telepathic connection to his creators, so maybe even dinosaurs skeletons could have some form of connection to them.
Comment: Answers are meant to provide some kind of evidence from within the story.  They are not supposed to be wild speculations.
Comment: If you have a better answer write one yourself. Besides, I don't see anyone being capable of writing a better kind of answers unless it works on the movie.


Sex and Family Life on the Death Star?

Question: The Death Star is SO MASSIVE and has so many troops on it that I was wondering: Do they have troopers' or officers' families at all on the station? Is their any lore the suggests that families may reside in some manner on the station? Or are they not allowed to have families? Also  is their any information on rules between female troops and male troops getting you know close to one another? it seems unlikely that this is something that is unavoidable in some manner and is their any lore that hints at this in any way? or are all the Troops pretty much like the unsullied from GOT?
Comment: Children? With so many chasms wihout any handrails?
Comment: That's what shoreleave is all about. _What happens on Alderaan definitely stays on Alderaan_
Comment: @n_b - Until it literally can't.
Comment: see this is why Luke has always been on the darkSide, all the innocent people killed
Comment: Somehow I don't think an evil galactic empire would mind much about fraternization...
Comment: The whole thing with families on the Death Star was answered here. https://www.youtube.com/watch?v=M-_o_lGUFxQ Not a pretty sight.
Comment: Flagged to migrate to Workplace.SE
Comment: @n_b they look for love in Alderaan places?
Comment: I'd guess it operates similarly to an air craft carrier. No families on board because it's a military vessel. There may be personal connections but probably not following the books perfectly, so to say. Just from the military perspective, it would be a PR nightmare to disclose how many innocents died when the carrier was blown up in combat. Thusly, why would the death star be much different?
Answer: Non-canon answer:
Death Star novel  by Michael Reaves and Steve Perry, which now belongs to the Legends continuity (and has some contradictions with the current canon, namely Rogue One), can give you an idea of personal relationships onboard the Death Star. Yes, there were female members of the crew (e.g. waitresses, medical workers, other non-combat personnel), and they did have relationships. The commanding officers had a relaxed view on these, as long as their combat officers were in good shape.
Regarding families: there is no mention of them. Probably not, as having a bunch of kids running free onboard a secret battle station could prove a disaster.
As for the new canon sources, I have no idea. Maybe someone else posts a new answer with updates on that.
Comment: I would note that in current continuity, it's all but certain that many of the stormtroopers on the Death Star were female. They weren't just servers and nurses!
Answer: Canon speculation:
In rogue one, we definitely see at least science officers have families, though we never see for sure if any are actually brought aboard the Death Star. However, it seemed like Krennic's intention was to bring Galen Erso's family along for the ride when he showed up at the Erso home. In the past, they worked closely enough for Krennic to be familiar with Galen's family, as in the flashback when they are having drinks together.
Now, consider this: If a warship capable of destroying planets was operated by soldiers, engineers, technicians, and officers that had family on planets that would be potential targets, how likely are they to cooperate with the Empire? I'm going to say not very, and the Empire would definitely need to worry about sabotage (cough Galen Erso cough). Given the secrecy of the project, its size, and mobility, I think it's likely that the families lived on-board somewhere, if only to keep an eye on them and prevent insurrections. Who knows how the crew would interact with the families, but it would probably be similar to a modern military base where there are civilian and non-civilian areas.
If there were civilians on the Death Star, though, the Rebels have some serious ethical questions to answer...
Comment: I'm not a legal expert, and Earth law may not be the final word on ethics, but by Earth international law, adult civilians on a Death Star vessel who were there voluntarily (and therefore acting as voluntary human shields), might not be considered protected -- see [Article 51(3) of Additional Protocol I of the Geneva Conventions](https://ihl-databases.icrc.org/applic/ihl/ihl.nsf/WebART/470-750065?OpenDocument). Deliberately putting themselves in harms way on a battlestation might be construed as taking "a direct part in hostilities". Also relevant: https://www.youtube.com/watch?v=iQdDRrcAOjA
Comment: They are not 'innocent bystanders', but military contractors, who are at all times a valid military target in case of war.
Comment: Also, for the Rebels, it was a 'kill or be killed situation'. They clearly had no time to evacuate the base.
Comment: I personally view as though it were an aircraft carrier. Aircraft Carriers are literally floating cities. You don't have civies on an aircraft carrier.
Comment: Garret Gang - The US navy offers occasional "tiger cruises" in which family members of sailors can make trips on naval vessels, including submarines and aircraft carriers.   I think that a better comparison might be to an army base which does have civilians and family members.
Answer: Somewhat off topic, I once wrote an unpublished story in which an involuntary space/time traveler got involved with a situation similar to that in Star Wars and becomes the  equivalent of one of the characters; I planned that in other stories in the series he would sometimes revisit the setting and become the equivalent of some other Star Wars characters.
In this story the Galactic Empire equivalent took over a giant space habitat with a population equal to that of a planet and forced the natives to work on the project of adding Faster-than-Light engines and a giant planet destroying weapon to turn the space habitat into the Death Star equivalent.  Thus the Death Star equivalent in this story had a planet-sized population of civilian slave workers and their children.
Since I have never heard that something similar happened in Star Wars, that probably can't be used as an explanation or justification for the presence of civilian workers, families of military personnel, or children on the Death Star(s) in Star Wars.   As far as I can tell there is no mention of a civilized native species on the planet that was made into Starkiller Base in The Force Awakens, but possibly there could have been a species of intelligent beings that was not recognized as such, rough equivalents of apes or dolphins on Earth.
Someone writing a Star Wars fan fiction would have considerable leeway to interpret the information given in the movies, TV shows, etc. to depict between zero and many thousands of civilian workers, and/or families of military personnel, and/or children on each of the Death Stars.
I should point out that for hundreds or thousands of years at least a small proportion of many military, paramilitary, and warrior forces consisted of kids under 18 - teenagers or even preteen kids.  In the 19th and 20th centuries most European and European type armed forces phased out the enlistment of kids and became 100 percent adult forces. The minimum age to enlist in the US armed forces is seventeen and the minimum age to enlist in UK armed forces is sixteen.
But about the time of World War II lighter rifles and automatic weapons were invented, guns light enough to be carried by persons much smaller than the typical man, persons including women, teenagers, and even preteen children.  So ever since then many groups of guerrillas, terrorists, rebels, paramilitaries, etc., etc., have included women, teenagers, and preteen kids among their fighters and support personnel.  In any given year there are tens and even hundreds of thousands of child soldiers under 18 worldwide.
In ancient, medieval, and early modern times when tribes migrated the warriors usually brought their women and children and other dependents along.  And more professional armies of city states, kingdoms, nations, etc. also were accompanied by many "camp followers", families of the soldiers, civilian merchants and employees and their families, prostitutes and their children, etc. etc. etc.
Indian armies were often accompanied by several times their numbers of camp followers, a practice followed by the British in India.  690 British and 3,810 native soldiers were accompanied by about 12,000 civilians in the 1842 Retreat from Kabul - almost all were massacred.
In the US Army's darkest day, November 4, 1791, about a thousand soldiers were defeated by the Western Confederacy of American Indians.  264 soldiers and 13 civilian workers were wounded, and 632 soldiers and 24 civilian workers were killed or captured for later burning at the stake.  It seems quite possible to me that a few of the solders who were wounded, killed, or captured for burning at the stake could have been young drummer boys.
After hours of fighting Major General Arthur St. Clair led a bayonet charge though the Indian lines and down the road toward the nearest fort.  Everyone left in the camp was killed by the hostiles, including almost all of the 200 to 250 camp followers (wives, children, laundresses and prostitutes).
In the modern US armed forces, you won't find civilians, families, or children on fighter or bomber planes or on warships (except that families of sailors sometimes go on short "tiger cruises").  Considering the vast sizes of the Death Stars and their crews, it might make more sense to compare them to US military bases, where you can find civilian workers, families, and children.
Some US bases have firepower somewhat analogous to the Death Stars or Starkiller Base, basing bombers and missiles capable of delivering nuclear bombs to devastate foreign lands.  Thus those bases would be most likely to be targeted and destroyed in an atomic war.  But I suppose that those bases are just as likely to house civilian workers, families, and children as other US military bases.
So someone writing a fan fiction could suppose that the Death Star policy is:
1) Only male military personnel aboard and they only get to socialize with the opposite sex when on shore leave.
2) Only male military personnel aboard plus female prostitutes and the men can also socialize with the opposite sex on shore leave.
3) Both male and female military personnel aboard but they are prohibited from socializing and can only socialize with the opposite sex when on shore leave.
4) Both male and female military personnel aboard and also male and female prostitutes.  Military personnel are forbidden to socialize with opposite sex military but can socialize with prostitutes and when on shore leave.
5) Only male military personnel aboard who can socialize with opposite sex prostitutes and with spouses aboard, and socialize on shore leave.  No children in the families allowed aboard.
7) Both male and female military personnel aboard who can socialize with opposite sex prostitutes and with spouses aboard, and socialize on shore leave.  No children in the families allowed aboard.
8) Only male military personnel aboard who can socialize with opposite sex prostitutes and with spouses aboard, and socialize on shore leave.  Children in the families are allowed aboard.
9) Both male and female military personnel aboard who can socialize with opposite sex prostitutes and with spouses aboard, and socialize on shore leave.  Children in the families are allowed aboard.
TBear's answer suggested that the Empire might want to go with with only single personnel or else my 8) or 9).  Certainly if the personnel of a Death Star have their families aboard they will fight as hard as they can to block all attacks on the Death Star.  And if the personnel on a Death Star have families on other planets Rebels could kidnap them and keep them on Rebel planets to deter Death Star attacks.
The above possibilities are for writers of Star Wars fan fiction.  Writers of canon Star Wars works may be restricted in what they can depict aboard the Death Stars and Starkiller Base for various reasons, though it is always possible that a really good story idea could cause those restrictions to be ignored.

Sex and Family Life on the Death Star?


get the parent url of iframe in PHP

Question: I am creating a widget that would load in a IFrame and users will be able to place the widget on their own website. How would I get the URL of the website that is using the IFrame in javascript and/or PHP? The IFrame loads a php file.
I have tried "parent.top.location.href" and "parent.document.referrer" in the IFrame page but that is undefined.
I have also tried to echo "$_Server[referrer]" in the IFrame page and that did return the IFrame parent URL, but how easy is it for someone to manipulate the referrer variable? I dont want to get misleading information.
The Goal: I created a widget and want to allow registered users to use that widget on their site. I want to be able to find out who is using the widget and if a un-registered user is using it on their site, then the widget would not display
Answer:
I have also tried to echo
  "$_Server[referrer]" in the IFrame
  page and that did return the IFrame
  parent URL, but how easy is it for
  someone to manipulate the referrer
  variable?

Pretty easy, but so is disabling JavaScript! However, if a web site uses your  it will be a little difficult for them to fake the referrer in their visitor's UA. (They could also proxy your content if they really insist on hiding the fact that they're using your content. In that case your only choice is not to publish it in the first place.)
In order to present content for "partners" only you could consider providing them with a token (like Twitter/Google/... APIs). If no (or an invalid) token is used, present an error. If a valid token is used but the referrer is suspicious you should investigate further.
Comment: "... you should investigate further." - And revoke the token if they are still not cooperating :)
Answer: Try with:
parent.location.href;

or
parent.document.URL

Comment: This will seemingly only work if the iframe and its parent are both on the same domain. See: http://stackoverflow.com/questions/815409/is-it-possible-to-find-a-cross-domain-iframes-new-url-after-a-redirect
Answer: You can use the following PHP code to have the parent window URL get values in an array:
  <?php
       //Getting the parent window parameters
        $getURLVar = str_replace("?","",strrchr($_SERVER['HTTP_REFERER'],"?"));
        $getURLVar = str_replace("&","=",$getURLVar);
        $getURLVar = str_getcsv($getURLVar,"=");
        $i=0;
        foreach ($getURLVar as $value)
          {
            if ($i % 2)
                $value1[$i]=$value;
            else
                $value2[$i]=$value;

            $i++;
          }
        $getURLVar =array_combine($value2,$value1);

        print_r($getURLVar);
    ?>

Answer: A small piece of JavaScript in the iframe-d page can 'un-frame' the page:
if (top != self) {top.location.replace(self.location.href);}

Otherwise, as @mck89 says: the iframe can access the URL of the parent page using the top.location.href.
Further reading on the question How to prevent my site page to be loaded via 3rd party site frame of iframe.
Answer: Assuming your widget's URL doesn't do any redirects, etc., you should be able to use:
document.referrer

from within the javascript inside your iframe and it should contain the URL of the parent page.  This seems to be what YouTube does for tracking in their iframe embed codes.
Answer: I would use:
$qStr = explode('?', $_SERVER['HTTP_REFERER']);
$t= explode('&', $qStr[1]);
foreach ($t as $val)
{
    $a = explode('=', $val);
    $args[$a[0]]=$a[1];
}
// to check the arguments
print_r($args);
// to check the url
echo $qStr[0];

$args would contain my security token which would be checked by some hashing against the url

get the parent url of iframe in PHP


What size frame is right for me?

Question: I have an inseam of around 26 1/2 inches (without shoes). Would a 47cm frame fit me? If not what would the correct frame size be? I'm looking for a hybrid (or road) bike.
Comment: This is impossible to answer without knowing the type of the bike and what you are going to use it for, its frame geometry and your body proportions. There are several bike fit calculators and size tables on the internet, perhaps some of them could help.
Answer: Really, the only way to make sure you get a good fit is to sit on and test ride some bikes. There are many variables that sizing guides can't take into account, such as proportions of the rider's arms legs and torsos, and preferred riding position. Additionally, the common seat tube measurement isn't very standardized across manufacturers and frame styles
Getting the right size bike is worth putting some effort into. Presumably you want an bike you can enjoy riding, You won't enjoy riding an incorrectly sized bike. Even if you can manage one visit to a good bike shop to try a couple bikes would probably be worth it.
All of that said, if you really need to buy online, you definitely need at least a 'small' size. Look for manufacturer's size guides of bikes you are considering and for good return policies in case your estimate is off.
Answer: For children you need 1" clearance between groin and bar for male.
For me it's about not raising the seat a mile to have my knee slightly bent when, ball of foot is on pedal and, pedal is down (proper seat adjustment). If you raise the seat high, the bars seem low. That is what matters to me. I don't like leaning forward. You need to test sizes in person and not by measurement. Does it feel comfortable? that is how to size.
Comment: I would love to be able to take the time to try before I buy, but my work schedule won't allow it. I'm left with the option of buying online.
Comment: Sorry I can't help then. It sounds like you would be a 21" bike. 26" would be big. Don't know cm's though.
Comment: @Elchanan Buying online is great for saving time and money.  But you run the significant risk of buying the wrong size.  You don't even know for sure if you want a road bike or a hybrid.  Try a decent bike shop and get your leg over a couple of sizes/styles/brands.
Comment: @Elchanan I don't understand. If you don't have time to shop for a bike, how will you have time to ride one?
Comment: @DavidRicherby Really?! To and from work.

What size frame is right for me?


with good grip or with a good grip?

Question: I'm talking about a pair of boots. "You need to buy boots with good grip" or "You need to buy boots with a good grip."
Answer: You will find the expression both with and without the article a.
But the alternatives tend to be used in different contexts.
We would say that: The government has a (good) grip on things, meaning that it is in control of the situation. Here it is necessary to use the indefinite article.
But with reference to shoes, tyres and the like, the use of the article is optional.
These are shoes/boots/tyres/wheels with good grip or with a good grip.
You can suit yourself.
https://books.google.com/ngrams/graph?content=with+a+good+grip%2Cwith+good+grip
Comment: Thank you so much!

with good grip or with a good grip?


How to mount sdcard1 (external SD) as internal storage?

Question: I understand that there are many tutorials and the like on this very subject, but none ever really matched my exact situation...
   I have a rooted moto g in which I have a 200gb micro sd card (laptop is down right now, I download all my media with my moto) and a mere 5gb of internal storage.   Now it becomes confusing for me... my storage folders are named 0 and 1, internal and external... and my "internal" storage is labeled as"emulated" sdcard0.  If I enter the sdcard shortcut from my phone's root directory I'm taken to this emulated SD.
   So, okay, I'm assuming that my internal storage is partitioned in two, perhaps the first partition is dynamically allocated so I have a place to store my pics and downloads at the same time maintaining the files in /data...so now I'm stuck constantly moving files from internal to external every time I download something because I get  insufficient storage warnings.  So how would I go about dedicating the 5gb totally to my /data and having the phone then make my 15gb sd take the place of emulated sdcard 0?
Comment: I'm sorry ...I forgot to mention I'm rooted.  Editing
Comment: Since Lollipop this has been impossible because of the permissions built into Android... Older versions such as JB 4.2 could be modified to do this, and many ROM developers often set this as the default condition, but do to how Android handles the SD card now this is not possible. You may want to look into rooting and applications like Link2SD or possibly upgrading to Marshmallow (Android 6.x) and using the Adopted Storage feature.
Answer: Due to how Android handles SD card permissions, it is no longer possible to "swap" the internal and external storage of the device and trick it to use the SD card as "internal" storage any more.
Since you are rooted, I would look into any of several Android 6 based ROMs that are available for the Moto G, after installing one of those you can adopt the the SD card as internal storage. Be aware that this will make the card unreadable in other devices without reformatting it and it can only be seen via a USB connection since it will be formatted as ext4 and encrypted. I would recommend using XDA's Moto G forum area for more information regarding specific ROMs and how to flash them.
The other option would be to use an application like Link2SD, which would require you to partition and reformat your SD card, and it uses symbolic links to the partition on the SD card. This still requires the app be installed on the device first and moved, but it can free up significant space and using the paid version can move even more data to the SD card. See the application linked above for more information.


Find the minimum length of a line segment with endpoints on the coordinate axes that passes through the point $(1, 1)$

Question: A line passes through the point $P=(1,1)$ and through the $x$ and $y$-axes at points $A$ and $B$ respectively. Find the minimum length of the line segment $AB$.
Comment: Intuitively, the line is length $2*sqrt(2)$.
Comment: Intuitively you are right. The problem would be nicer if the $x$ and $y$ coordinates would be different.
Comment: How about non-intuitively?
Answer: $\frac{y-1}{x-1}=m$ defines the line.
$A$ is the $x$ intercept which is $(1-\frac{1}{m}, 0)$ and $B$ is the $y$ intercept which is $(0,1-m)$.
By minimizing the distance between these two points we can calculate $m$ which will then give us the distance. To make the algebra simple we will actually minimize the distance squared, call it d.
Then $d=(\frac{1}{m}-1)^2+(1-m)^2$ and taking the derivative with respect to $m$ gives $\frac{dd}{dm}=-\frac{2}{m^2}(\frac{1}{m}-1)-2(1-m)=\frac{-2+2m}{m^3}-\frac{2m^3(1-m)}{m^3}=\frac{-2+2m-2m^3+2m^4}{m^3}$
Setting this equal to $0$ gives $-2+2m-2m^3+2m^4=0\implies -1+m-m^3+m^4\implies m = 1$ or $m=-1$.
If $m=1$ then both the $x$ and $y$ intercepts will be $0$ so $A=B$ and the distance is $0$.
If $m=-1$ then $A=(2,0)$ and $B=(0, 2)$ so the distance is $\sqrt{2^2+2^2}=\sqrt{8}=2\sqrt{2}$
Therefore, the minimum distance is $0$ when $A=B$. If we change the problem to say that $A$ and $B$ are distinct then the minimum distance is $2\sqrt{2}$.
Answer: HINT: For a non-intuitive answer, I'm thinking on two possibilities:
1) An algorithm (computer program) to calculate the distance of y-intercept to x-intercept of all line equations that cross (1,1), with slope dependent on line angle to x axis and make a table of angle vs length AB.
2) I don't know an equation which by differentiation to zero, you can find the minimum, but by using the 45º as the intuitive minimum length, demonstrate that two other lines crossing (1,1) with a +/-delta angle $(\Delta a)$, the AB length increases length to both change in angle $({45º+\Delta a})$ and $({45º-\Delta a})$.
Answer: Let the equation of $AB$
$$\dfrac xa+\dfrac yb=1$$
As it passes through $P(1,1),$
$$\dfrac1a+\dfrac1b=1$$
Clearly, $a,b$ both can not be $<0$
Case$\#1:$ If $a,b>0$  WLOG $a=\sec^2t,b=\csc^2t$
We need to minimize $\sqrt{\sec^4t+\csc^4t}$ i.e.,  $\sec^4t+\csc^4t$
Now $F(t)=\sec^4t+\csc^4t=(\sec^2t+\csc^2t)^2-2\sec^2t\csc^2t$
$=\sec^2t\csc^2t(\sec^2t\csc^2t-2)$ as $\sec^2x+\csc^2x=\dfrac{\sin^2x+\cos^2x}{\sin^2x\cos^2x}=\sec^2x\csc^2x$
Now $u=\sec^2t\csc^2t=\dfrac4{\sin^22t}\ge4$
$\implies F(t)\ge4(4-2)$
Case$\#2:$ If $a\ge0,b\le0$  WLOG $a=\sin^2t,b=-\tan^2t$
We need to minimize $\sqrt{\sin^4t+\tan^4t}$ i.e.,  $\sin^4t+\tan^4t$ whose minimum value is clearly $0$
Can you take it from here?


Cascading drop down fields

Question: I have created a SharePoint list which includes multiple drop down columns. What I need to do is when I select a item from the first drop down column (which is a look up column) the second drop down column should show options only related to the value in the first column. I am using SharePoint 2013 online version. Is there a possible way I can do this?
Answer: You can use SPServices Cascaded Dropdowns, thanks to Mark.
SharePoint 2013: Cascade Dropdown List using SPServices
SPCascadeDropdowns
Comment: Hi thank you so much for response. I tried both links and did the examples the exact way. But still it does not work as in the filters do not work. I tried using online libraries for jquery and SP services too. Anyways Thanks again :)
Comment: Hi, Quick question. How can I know that the embedded script is linked to the code? As in how does the filtration trigger according to the above mentioned examples?
Comment: You can debug it using Chrome Developer Tools (F12), you can put alerts in the JS code to check if the code is actually been called etc.
Answer: There is another option to use InfoPath to customize the form.
You can follow the similar post below:
Auto populate a field from another list based on the filter
Comment: We can also use PowerApps in SharePoint Online to create cascading drop down list. check the blog: https://powerusers.microsoft.com/t5/PowerApps-Community-Blog/SharePoint-Cascading-Dropdowns-in-4-Easy-Steps/ba-p/16248
Comment: Thank you for the kind response. I'm unable to use Infopath because I think it is not compatible with the version I use. I get an error message when I try to use InfoPath. Any other solution I could use? Thanks again :)
Comment: Hi! Many thanks to this solution. It worked just fine. But when I enter data through powerapps and save, the data I entered is not saved in the list. this happens with the  datafields I modified using powerapps. Any idea why?

Cascading drop down fields


what's the best way to test GWT widget's view's implementation

Question: There have been a lot of talk on MVP and how it seperate the presentation logic from the view's implementation. These designs are good but I still have a question unsolved regarding to widget.
To develop a widget, (or possibly many small widgets included in a typical website), specially those designed with UIBinder, I found it very difficult to test (or just simple display) a widget's view implementation. The obviously way is to add it manually to an entry point class and display the widget only, which works but seems very tedious if the widgets are getting more and more.
So the question is: what's the best way to just simply display a widget when it's being developed? and possibly to interact with it?
Answer: Since you need to display the Widget and interact with it in order to test it you need a functional testing tool.
One such tool is Selenium.


How can I assassinate someone and make it look like an accident?

Question: I was recruited by an Assassin's guild when my party of five was out of town, and now I have to assassinate someone and make it look like an accident. The problem is that my party has to contact my target for another mission that I am also involved in, and they don't know I have to kill the guy. How can I murder him in secrecy?
You see, the guild master said that nobody could know what I do inside the guild. I think that means that everything i do should be in absolute secret. My character is very good at sneaking, perception, acrobacy and athletics, but the target seems to be very difficult to kill, as he is a drow. My concern is that the town is guarded by some sorcerers and a giant Ogre, so I don't really know how to perform the assassination, because the target is in the same Inn as my party is and we have to get some items from him
Comment: Hi, welcome to the site... This is quite borderline for our site rules; we require that questions be focused and directed, and to provide enough requirements to enable voters to recognize which answers are better than others. See the [Tour] for more details. So while I'm not *quite* ready to close this question, I'm not sure it'll get great answers, either. Posting more information about the town, the guild, the target, your own character, both as a character and mechanically, will help a lot to give answerers ideas and ensure that their suggestions are actually useful to you.
Comment: Plot twist: OP is planning to do this in real life.
Not a plot twist: very interesting question. What setting are you playing in?
Comment: Does it have to look like an accident to *everyone*, or is it OK if the other PCs learn what is going on?
Comment: @GAX those kinds of details definitely belong *in the question*, add a few sentences along those lines to an edit. Might also help if the *DM* gave you any specifics beyond the in character stuff.
Comment: There you go hahaa. I'm sorry, this is the first time i use this site, should have read the tour first =D
Comment: Anyway, his words were exactly these: And make it look like an accident. He didn't say anything about the target
Comment: The DM said I can't ask him anything about the target nor how to perform the assassination, because he got some things planned for me. "You have to do it from what you already know"
Comment: I think waxeagle's answer sums it up as best as possible but what you are trying to do is outside the mechanics of 4e (except if the GM makes it a skill challenge) as such there needs to be an agreement made with the GM about expectations and other players as players should know what is occurring.
Comment: Aaah, forgot to tell earlier that the target is a drow
Answer: With stealth, GM buy in, and probably not without the knowledge of your fellow players (though their characters don't have to know).
Here's the first thing. Take the GM aside and ask him about the expectations for this mission.  He gave it to you, he certainly has and idea about how he thinks it's supposed to go down. He can help you, especially where the mechanics are concerned (the mechanics for killing a monster/NPC outright aren't particularly useful for an assassination, he may have something else in mind).
Second, let's hope your character's strong in bluff and stealth, he's going to need both of them to slip away unnoticed and pretend like he doesn't know what happened.
Lastly, it does not behoove you for your fellow players to be in the dark on this. Talk to them, this is an important plot point and while their characters shouldn't necessarily know what happened their players can, and should. Especially if they need to talk to him for something else plot wise.
From a mechanics perspective, to kill someone outright (if they have monster stats, or PC stats for that matter), the way to kill them outright is to either fight them one on one (if they are an equal level foe, you will have a big chance of losing), OR to sneak into their bedroom at night and coup de grace them. Though to be clear, a coup de grace in 4e is only an outright kill if you deal at least their bloodied value in damage (it's an auto crit though, so that should help). Again, it's important to talk to your DM about whether he is planning to use a separate rules set (Specifically something along the lines of a skill challenge perhaps) to accomplish this rather than using the combat rules since they break down in situations like this.


How to deal with extended testing times?

Question: I often find myself writing programs that operate on fairly large datasets and complex problem formulations, which usually take on the order of 30 minutes to 2 days of running to identify a bug. The psychological effect of these long testing iterations can be very taxing, and I find it very difficult to change focus and move my mind off of one program and on to another for the 30-ish minutes that a test is running. What strategies can I employ to ease my mind between tests, and change focus more quickly, to achieve a higher productivity?
Comment: Which brings me back to my question: if you have smaller, faster tests that prove functionality is correct, why can't you work on a project for a day, while running your faster tests to prove correctness, and run these long tests at night and while working on a second program? Your context switching between programs is reduced if you simply don't run your long-running tests in the day time.
Comment: Can you create smaller, shorter tests to give you enough confidence in your work to continue development through a course of a day and run these longer tests overnight? It may not do much for tests that are longer than 14 hours, unless you can work on projects on alternating days.
Comment: I'm voting to close as there are really 2 questions here as I see it: 1) How to retain focus when switching tasks and 2) How to reduce the test time for large datasets.
Comment: Sometimes it is reasonable to be satisfied with smaller tests, however oftentimes it is the very scaling ability which needs to be tested- for these kinds of tests, it is often far from obvious how to reduce them.
Comment: You're doing ETL aren't you?
Comment: @RubberDuck What would make you think that?
Comment: @RobbieDee *experience*
Comment: @RubberDuck Large datasets doesn't necessarily mean ETL...
Comment: @RobbieDee, I'm not convinced that it's two questions... seems like "which approach to take: shorten tests (and how?) or tough it out (and how?)"... there's just one problem here, which is the long tests.
Answer: What I would suggest is to keep your daily or compile/build tests as short as possible.  Builds and subsequent unit tests should run as quickly as possible.  A day to run tests isn't reasonable, even builds running for more than 15 minutes indicate too much code/too big a project/too many time consuming tests being run.
However, I would not abandon those long running tests.  Instead I would schedule them to be weekly or monthly as part of larger regression suite of tests.  Kick them off on a Friday or Saturday and examine the results on Monday.  If weekly isn't a good interval, go every few days.
Comment: *" What strategies can I employ to ease my mind between tests, and change focus more quickly, to achieve a higher productivity?"* I don't believe you have answered this question at all but there is certainly mileage in reviewing what to test, how and when.
Comment: @Robbie - I guess my answer would be, automate everything.  While tests are running, I am doing other things, and they run many times throughout the day (during and after every build).  All the tests are automated as part of build and/or post deployment activities.  Result collection is also automated as well as we get emails and have dashboards up on monitors review test results.  The only time I spend on times is maybe fixing a broken on or writing a new one(s). They are part of my day, but are not taxing me mentally.


Store image in database using rails paperclip plugin

Question: I have an application that uses the Paperclip plugin for image upload. Now that app should get deployed to an host(heroku) which has a read-only file system. Can I somehow tell paperclip to store the images in the database?
Answer: Check out this sample app
http://patshaughnessy.net/2009/5/29/paperclip-sample-app-part-3-saving-file-attachments-in-a-database-blob-column
I guess this is exactly what you need.
HTH
PS: storing images in db is usually a bad idea, I am sure you can use paperclip with S3 / cloudfront ( as mentioned in the answers below )
Answer: Heroku recommends storing file uploads on s3, and provides instructions on how to do so for several Rails file plugins.
Answer: Rethink what you're doing. Storing images in the db is generally a bad idea. For more info, see here.
ry is right to point you towards S3. If nothing else, think of the cost: 500 MB of database space on Heroku is $50/month. On S3, it'll be 15 cents.
Answer: Image serving from S3 is slow. Latencies of 0.5s to 2s are common, which means it should only be used for media assets.