qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
31,347,739 | I am wondering how to access routes in nested resources in rails. I added categories and it as broken my application.
Routes:
```
resources :categories do
resources :posts do
resources :comments
end
end
```
It errors out in this:
```
<% @posts.each_with_index do |post, index| %>
<%= link_to post do ... | 2015/07/10 | [
"https://Stackoverflow.com/questions/31347739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3162553/"
] | You'd need to define another block that nests `posts` under `category` resource:
```
# Existing
resources :posts do
resources :comments
end
# Additional block
resources :categories do
resources :posts do
resources :comments
end
end
```
With the additional block, your existing routes remain unchanged so... | vee's answer is correct if you want to use the nested routes and still preserve the original URLs. This is recommend this if your site is live and changing the URLs would affect links to your indexed pages.
Otherwise, you should point your links to the nested resource, like this:
```
<%= link_to post.title, [post.ca... |
1,528,830 | Given $\lim\_{n\to\infty} a\_n = a \neq0$.
Need to prove that $\lim\limits\_{n\to\infty}\frac{a\_{n+1}}{a\_n}=1$.
So i know that if $\lim\_{n\to\infty} a\_n = a$ so $\lim\_{n\to\infty} a\_{n+1} = a$ for the getting $1$, but how do i prove it? | 2015/11/14 | [
"https://math.stackexchange.com/questions/1528830",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/290034/"
] | For any $k\in\mathbb{N}\setminus\{0,1\}$, $\lim\_{n\to +\infty} a\_n = a\neq 0$ implies that for any $n$ big enough we have:
$$ \left(1-\frac{1}{k}\right) a \leq a\_n \leq \left(1+\frac{1}{k}\right) a, $$
that implies:
$$ \frac{k-1}{k+1}\leq \frac{a\_{n+1}}{a\_n}\leq \frac{k+1}{k-1}.$$
By letting $k\to +\infty$ the cla... | We assume that $a>0$. Then, for any given $\epsilon>0$, there exists a positive integer $N$ such that whenever $n>N$,
$$a-a\epsilon/4 <a\_n<a+a\epsilon/4$$
and
$$a-a\epsilon/4 <a\_{n+1}<a+a\epsilon/4$$
Now, if we take $n$ so large that $a/2\le a\_n\le 3a/2$, we can write
$$\left|\frac{a\_{n+1}}{a\_n}-1\right|=\f... |
1,810,079 | What would you say if a developer wanted to implement a sql2008 dev environment, but we were still forced to use a sql2000 test and sql2000 production environment?
Would there be anything wrong with using sql2008 on a dev server? Of course you'd need to know what functionality you couldn't use, so you didn't have prob... | 2009/11/27 | [
"https://Stackoverflow.com/questions/1810079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9266/"
] | I'd strongly avoid developing on a different local version than the dev/qa/prod environments. Most of the time nothing will happen, but when it does it can take forever to track down the issue. ***Not only that, you may never be able to replicate it locally since you have a different environment.*** | Using Basic SQL features - you'll do OK.
I have no idea why you use this environment, but it is best to use as similar environment and DEV, QA and Production as possible, to avoid surprise when going on production.
I think that SQL 2000 uses OLEDB and SQL 2008 you can use ADO.NET provider, And there might be many mor... |
2,362,212 | >
> Prove that the second derivative of $x^{4/3}$ does not exist at zero?
>
>
>
a/ As $f(x)= x^{4/3}$ we have $f'(x)=\frac{4}{3} x^{\frac{1}{3}}$ and $f''(x)=\frac{4}{9} x^{-\frac{2}{3}}$
Both $f$ and $f'$ are defined at zero but $f''$ is not defined at zero. Therefore the second derivative does not exist at 0
W... | 2017/07/18 | [
"https://math.stackexchange.com/questions/2362212",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/430020/"
] | The reason I think is because the first two equations serve as "steps" for the third one. And so it is not as important how they got the equation, rather then the equation itself.
It's like: find $z$ such that $z = x + y$ where $x=5, y= 6$.
$$x=5$$
$$y = 6$$
$$z = x + y = 11\text{ (1.2)}$$
$z$ is the most importan... | From a LaTeX and physics point of view -- and this depends on the style imposed by the journal or other authority:
* Number (almost) all display maths.
The "almost" refers to the occasional separate equation often preceding a numbered equation (so you can refer to such steps as "in the derivation of Eq. 1.1").
* Us... |
20,420,429 | I would like to know what the difference is between
```
window.setTimeout(myFancyFunciton, 1000);
```
and
```
setTimeout(myFancyFunciton, 1000);
```
Both seem to do the exact same thing. When should you use one or the other? | 2013/12/06 | [
"https://Stackoverflow.com/questions/20420429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3073240/"
] | From <https://developer.mozilla.org/en-US/docs/Web/API/Window>
>
> The window object represents the window itself.
>
>
>
So, all variables and functions that you call are enclosed inside the object window. However you can omit the object reference every time you call a function or a variable.
Why this?
Think abo... | I faced an issue related to this topic. I tried to make some functionality of my SPA to be a part of server side rendering proccess. I used `setTimeout` to provide some deferred action on the UI. When it works on server side (NodeJS) it turns into deferred action on the server side with no relation to the client side. ... |
3,781,124 | I have used Eclipse in the past without problems over a year ago, but I downloaded Helios onto a new computer having Windows Vista and Java 1.6.13 currently. I extract the folder and try to run the Eclipse EXE and get an error stating "Java was started but returned exit code=13".
I did some digging and it appears that... | 2010/09/23 | [
"https://Stackoverflow.com/questions/3781124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456474/"
] | I had this same problem.
I'm on Windows Vista 64, with the 64-bit versions of both Helios and the JDK/JRE 1.6 update 14. I had been using Eclipse Galileo just fine.
Upgrading to the JDK/JRE 1.6 update 24 (the latest as of this date) fixed the problem. I didn't have to make any changes to the Helios eclipse.ini file. | I also had the same issue with Eclipse Indigo on 64-bit Windows 7. The error message was "Java was started but returned exit code=1".
Updating to latest JRE 1.6 update 29 fixed it. |
2,770,523 | I'm struggling with the following problem,
Let $g(z)=\sum^k\_1 m\_{\alpha}(z-z\_{\alpha})^{-1}$. Show that if $g(z)=0$, then $z\_1,\cdots,z\_k$ cannot all lie on the same sie of a straight line through $z$.
**What I did:**
The book says that I should use the fact that if $z\_1,\cdots,z\_k$ lie on one side of some st... | 2018/05/07 | [
"https://math.stackexchange.com/questions/2770523",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/474703/"
] | No - any two coprime odd numbers (e.g any two primes $\ne 2$) provide a counterexample. | Far from true. $3+5=8,\ 8+7=15{}{}{}{}$ |
3,179,513 | How can I append text to every cell in a column in Excel? I need to add a comma (",") to the end.
**Example:**
`email@address.com` turns into `email@address.com,`
**Data Sample:**
```
m2engineers@yahoo.co.in
satishmm_2sptc@yahoo.co.in
threed_precisions@rediffmail.com
workplace_solution@yahoo.co.in
threebworkplace@... | 2010/07/05 | [
"https://Stackoverflow.com/questions/3179513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/365614/"
] | It's a simple "&" function.
```
=cell&"yourtexthere"
```
Example - your cell says Mickey, and you want Mickey Mouse. Mickey is in A2. In B2, type
```
=A2&" Mouse"
```
Then, copy and "paste special" for values.
```
B2 now reads "Mickey Mouse"
``` | Pretty simple...you could put all of them in a cell using the concatenate function:
```
=CONCATENATE(A1, ", ", A2, ", ", and so on)
``` |
24,468,943 | I'm working on problem #3 on project euler, and I've run into a problem. It seems that the program is copying *all* the items from `factors` into `prime_factors`, instead of just the prime numbers. I assume this is because my `is_prime` function is not working properly. How can I make the function do what I want? Also,... | 2014/06/28 | [
"https://Stackoverflow.com/questions/24468943",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3784876/"
] | Yes, you need the commented line.
(It seems that on that case it's not necessary, but with other numbers the part of your code for getting factors would go wrong).
Check these references:
[Prime numbers](https://en.wikipedia.org/wiki/Prime_number)
[Integer factorization](https://en.wikipedia.org/wiki/Integer_factor... | Use the while loop. n%i simply means n%i!=0
```
i = 2
n = 600851475143
while i*i <= n:
if n%i:
i+=1
else:
n //= i
print n
``` |
22,624,879 | I'm still not sure how to do my migrations with knex. Here is what I have so far. It works on `up`, but `down` gives me FK constraint error even though foreign\_key\_checks = 0.
```js
exports.up = function(knex, Promise) {
return Promise.all([
knex.raw('SET foreign_key_checks = 0;'),
/* CREATE Member table ... | 2014/03/25 | [
"https://Stackoverflow.com/questions/22624879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2132307/"
] | Figured out that it wasn't working because of connection pooling. It would use a different connection to run each migration task which caused foreign key checks not to be set properly. setting
```
pool:{
max:1
}
```
in the migration config file fixed this. | Subjectively as the most clean way to do it I would suggest including in your migration file something like:
```
exports.up = function (knex) {
return Promise.all([
knex.schema.createTable('users', function (table) {
table.increments('id')
table.string('username').notNullable()
table.string('pa... |
7,242,354 | For example I have four classes like:
```
class A;
class B{
protected:
void check(const A &a);
};
class C : public A, public B;
class D : public B;
```
Now I would like to write check function that does nothing if the caller and parameter are the same:
```
void B::check(const A &a){
if(*this != a){
... | 2011/08/30 | [
"https://Stackoverflow.com/questions/7242354",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/365619/"
] | There's only one possible escape hatch here. If *both* A and B have a virtual function, then you can `dynamic_cast` both `this` and `&a`. And per 5.2.7/7 "If T is “pointer to cv void,” then the result is a pointer to the most derived object pointed to by v."
Therefore, this code works:
```
void B::check(const A &a){
... | You probably want to check whether the instances are the same:
```
void B::check(const A &a){
if(this != &a){
//do something
}
else{
//do nothing
}
}
```
Comparing the content of different classes doesn't make much sense to me. |
302,896 | The following command has been entered:
```
sleep 12h; nuke-russia
```
It was entered on one of the Debian's `tty`s. I would like to cancel the sleep without nuking anything. I don't want the nuke command to run for even for a single moment. I have the other five terminals available. What can I do? | 2011/06/27 | [
"https://superuser.com/questions/302896",
"https://superuser.com",
"https://superuser.com/users/81119/"
] | In future, try using `&&` instead of `;`
`sleep X && echo bla` pressing ctrl + C will stop sleep and will not echo bla
If it's feasible, you could rename the responsible binary . That way bash will not be able to execute `nuke-russia` since it will not exist.
Other solution would be to kill the responsible shell
... | Similar answer to Linker3000's - Log in as root from another terminal, and kill the tty process (On CentOS the process is named login, not sure about Debian). |
443,310 | I'd like for a subclass of a certain superclass with certain constructor parameters to load an XML file containing information that I'd then like to pass to the superconstructor. Is this impossible to achieve? | 2009/01/14 | [
"https://Stackoverflow.com/questions/443310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/50844/"
] | How about using a factory method instead? Maybe something like:
```
private MyObject(ComplexData data)
{
super(data);
}
public static MyObject createMyObject(String someParameter)
{
ComplexData data = XMLParser.createData(someParameter);
return new MyObject(data);
}
``` | You can call a static method in the super() call, e.g.
```
public Subclass(String filename)
{
super(loadFile(filename));
}
private static byte[] loadFile(String filename)
{
// ...
}
``` |
44,641,976 | I would like to add the L1 regularizer to the activations output from a ReLU.
More generally, how does one add a regularizer **only to a particular layer** in the network?
---
**Related material:**
* [This similar post](https://stackoverflow.com/questions/42704283/adding-l1-l2-regularization-in-pytorch) refers to ad... | 2017/06/20 | [
"https://Stackoverflow.com/questions/44641976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8126541/"
] | Here is how you do this:
* In your Module's forward return final output and layers' output for which you want to apply L1 regularization
* `loss` variable will be sum of cross entropy loss of output w.r.t. targets and L1 penalties.
Here's an example code
```
import torch
from torch.autograd import Variable
from torc... | I think the original post wants to regularize the output from ReLU, so the regularizer should be on the output, not the weights of the network. They are not the same!
* with l1-norm regularize the weights is training a neural network has sparse weights
* with l1-norm regularize the output of a layer is training a netw... |
634,608 | how can I get information on the state of a process (i.e. if it is a zombie) using C under Linux?
After reading the answers so far I want to narrow my question somewhat: I would prefer a pure C solution. After reading the ps source (which reads /proc/) I thought that there should be a better way and asked here :) | 2009/03/11 | [
"https://Stackoverflow.com/questions/634608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/76663/"
] | I know only two ways:
* Parsing output of the `ps` command
* Reading files in /proc/PID, where PID is the process identifier (that's what `ps` does internally) | Pseudo file system /proc is describing kernel internal data structures and gives to you opportunity to alter some values directly.
Obtaining state of particular process can be easily implemented with I/O C functions. The right file to parse is: */proc/{PID}/status*
Command below can be used to obtain processes in Zomb... |
1,194 | The awesome relationship movie [*Eternal Sunshine of the Spotless Mind (2004)*](http://www.imdb.com/title/tt0338013/) ends with a scene in which the two main characters are tempted to get back together but are not sure. The woman points out that they both know they will most likely just end up breaking up again. The ma... | 2012/02/04 | [
"https://movies.stackexchange.com/questions/1194",
"https://movies.stackexchange.com",
"https://movies.stackexchange.com/users/763/"
] | Joel and Clem seem to get back together at the end, and after that it shows a candid scene of them looping over and over until the final fade to black. The writer intentionally left the movie ambiguous in the first place, so there is no ending set in stone, but I've always thought that, although they rekindle their rel... | To me, the message of the film is that we are destined to have people in our lives that make us experience human nature. In this universe in the movie where you have the ability to simply erase someone from your memory, a play on the desires of many a heartbroken lover in reality, this erasure doesn't actually do anyon... |
321,167 | Trying to ssh into a computer I control, I'm getting the familiar message:
```
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someon... | 2011/10/13 | [
"https://serverfault.com/questions/321167",
"https://serverfault.com",
"https://serverfault.com/users/97740/"
] | Remove that the entry from known\_hosts using:
```
ssh-keygen -R *ip_address_or_hostname*
```
This will remove the problematic IP or hostname from *known\_hosts* file and try to connect again.
From the man pages:
>
> `-R hostname`
>
> Removes all keys belonging to hostname from a known\_hosts file. This optio... | So many answers, but so many that give up protection by turning off strict host checking totally, or destroying unrelated host info or just forcing the user to interactively accept keys, possibly at a later point, when it is unexpected.
Here's a simple technique to allow you to leave strict host checking on, but updat... |
45,258,500 | So I made up this code:
```
sed -n -e '0,/version/{s/.*: *//p}' "$path"
```
$path is actual path to this file:
```
name: CSaveBackupWorld
main: ru.centurion.savebackupworld.SBW
version: 3.6
author: ASTRO
load: STARTUP
```
I just wanna get version value, I mean that 3.6, but instead of that I am getting this outpu... | 2017/07/22 | [
"https://Stackoverflow.com/questions/45258500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7834288/"
] | You needlessly added `0,` to your command:
```
sed -n -e '/version/{s/.*: *//p}' "$path"
```
should work just fine. `0,` makes `sed` print everything from the start of the file up to the matched line.
Alternatively, `awk` might be more readable:
```
awk '/version/{print $2}' "$path"
``` | Just
```
sed -n -e '/version/ s/.*: *//p' "$path"
```
will do it |
7,879,737 | I have a mySQl. I have an inventory database. I would like to send an email to a person when the inventory is equal or less than a preset value.
Is this possible on client side or server side? using PHP?
Any examples?
Erik | 2011/10/24 | [
"https://Stackoverflow.com/questions/7879737",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/297791/"
] | If you have the height and you want to change a div , just do the following
```js
$("#myDiv").css("height", myHeight+"px");
```
Where "myDiv" is the "id" of the needed div.
Shai. | `$(function(){`
`var innerHeight = $('#cell').innerHeight();`
`$('#scrollable').height(innerHeight);`
});`
Example: <http://jsfiddle.net/annF4/> |
4,622,458 | I had tried to solve this integral; using the substitution $\tan(x/2) =t$, and $\cos x= \frac{1-t^2}{1+t^2}$. But after making terms in $t$, I am not able to integrate further as numerator contains quadratic and denominator contains biquadratic.
$\int\limits\_0^{\pi/2} \frac{1}{(3 + 5 \cos x)^2}\ dx$. | 2023/01/20 | [
"https://math.stackexchange.com/questions/4622458",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1065508/"
] | Well let's use Weierstrass and partial fractions ig and evaluate the definite with FTC II.
Using Weierstrass with the tangent half angle substitution, our integral becomes
$$\int \frac{1}{(3 + 5 \cos x)^2}\ dx = \int \frac{1}{\left(3+5\left(\frac{1-t^2}{1+t^2}\right)\right)^2}\cdot \frac{2dt}{1+t^2} = \frac12\int {t^2... | Let's take $\int\_0^{\pi/2} \frac{1}{\left(3+5 \cos\left(x\right)\right)^2}\text{d}x$ and substitute $u = \tan\left(\frac{x}{2}\right)$ and $\text{d}u = \frac{1}{2}\text{d}x\sec^2\left(\frac{x}{2}\right)$ which yields $\cos\left(x\right) = \frac{1 - u^2}{1 + u^2}$ and $\text{d}x = \frac{2\text{d}u}{1 + u^2}$:
$$
\begi... |
6,730 | Let us consider the case: there is an overall bounding rectangle (call this **Rb**) which contains a number of rectangles within it (call this set **SRo**). Now I would like to randomly position a new rectangle with known bounds (call this **Rn**) within the bounds of **Rb** without intersecting any of the rectangles i... | 2010/12/22 | [
"https://gamedev.stackexchange.com/questions/6730",
"https://gamedev.stackexchange.com",
"https://gamedev.stackexchange.com/users/1179/"
] | This sounds similar to a collision-detection problem. Look at "spacial partitioning" to sub-divide **Rb**, and find the set of open spaces in which **Rn** would fit. Randomly select one of those spaces, and place **Rn** randomly within it. | Depending on the layout of rectangles already inside, if you find that brute-force is taking too many iterations (i.e. that there are too few valid spaces to put a new rectangle after some point in time), an alternative might be to iterate through the entire bounding box, making a list of all valid positions where the ... |
3,789 | I've found a binary copy of a DOS freeware game I was fond of back in the day ([Firefighter](http://dosgamer.com/firefighter/), downloadable as `FIRE.COM`) but the source code is not available. I'd like to re-implement it in C or Python using Unix curses and while I'm fully competent to do that part, I know almost noth... | 2014/03/04 | [
"https://reverseengineering.stackexchange.com/questions/3789",
"https://reverseengineering.stackexchange.com",
"https://reverseengineering.stackexchange.com/users/4077/"
] | My answer is a little late; newcomer to this site. The Decompiler project was initiated in order to decompile MS-DOS EXE and COM binaries. The project has both a command-line and a GUI tool:
<https://sourceforge.net/projects/decompiler/>
Use the following command with the command-line tool to decompile COM programs:
... | no beast exist that will decompile 16 bit com program
if you prefer to debug it look for grdb from ladsoft
also have in hand a copy of ralf browns interrupt list for all the
int 21 / int 10 SetCursor / GetCursor calls
also make sure you rename the downloaded exe to be 8dot3 compatible
(name less than 8 ch... |
1,069,451 | As the title suggests, I am experiencing issues with my Display in Ubuntu 18.04.
I have seen somewhat related posts (like [this](https://askubuntu.com/questions/1053088/ubuntu-18-04-unknown-display) one), but those typically suggest they have several detected displays, where one of them is dubbed 'Unknown Display'.
We... | 2018/08/27 | [
"https://askubuntu.com/questions/1069451",
"https://askubuntu.com",
"https://askubuntu.com/users/864725/"
] | I had this problem and removing the monitors.xml config didn't work.
there was a problem w/ the nvidia driver. check to see by running
```
ubuntu-drivers devices
```
and if that looks good
```
sudo ubuntu-drivers autoinstall
```
should do the trick
<https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-u... | I just had this problem - all of a sudden, when I booted the computer this morning, my Samsung 40" TV had turned into "Unknown Display" and I have no idea why.
Then I found this question and tried to debug according to the first answer - so after `lspci` I ran `xrandr` and suddenly boom!, it worked!
I still have no i... |
30,019 | I'm a web developer, but I occasionally step over into doing some mobile app development here and there. A client recently asked me to help them develop a very simple app. The app is essentially just an HTML / jQuery form that the user fills out to reserve my clients service. Having heard a lot about phonegap, I decide... | 2013/01/31 | [
"https://security.stackexchange.com/questions/30019",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/20239/"
] | Sending credit card info via e-mail is very bad and likely a violation of their merchant service agreement. Credit card details must be protected in transit and e-mail leaves it flapping in the breeze.
The SSL connection to the server or not for transmitting form data is irrelevant unless the server is somehow encryp... | If that form is not embedded in the app and is delivered over an unencrypted channel then it is possible for an attacker to change it in transit to `action=https://evil-site.com/carding.php`.
Ensure that all communication is encrypted and user data is being validated thoroughly on the server.
To make sure the framewo... |
43,294,488 | I just started using MinGW for Windows. When trying to create executable using
`g++ a.cpp -o a.exe -std=c++14`
for the code below:
```
#include <string>
using namespace std;
int main()
{
string x = to_string(123);
return 0;
}
```
I'm getting following error:
```
C:/mingw/bin/../lib/gcc/mingw32/5.3.0/../... | 2017/04/08 | [
"https://Stackoverflow.com/questions/43294488",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7837095/"
] | Installing `MinGW` packages `mingw32-libmingwex-*` will link an appropriate version of `vsnprintf` and avoid the linker error. | There are multiple definitions of `vsnprintf` in both `stdio.h` and `libmingwex.a`. I am able to work this around by adding `#define __USE_MINGW_ANSI_STDIO 0` to the start of the code, before any includes, which disables the definition of `vsnprintf` in `stdio.h`. |
329,410 | I'm fitting poisson GLMM, and I'm quite confused about the need or not to log10 transform my main predictor.
Raw values of this main predictor was very spread, from 2e+03 to 6e+06, that's why I thought about log10 transformation. Linearity with response seem to me equal.
[ )
Call:
lm(formula = count ~ x1, data = mydf)
Residuals:
Min 1Q Median 3Q Max
-3.3201 -1.5073 -0.4093 0.6720 12.7067
Coefficien... | @Elvis thank so much for your interest. In the results I gave I used a individual random effect which in reality was not needed. So finally pvalue of the x1 partial slope is 0.000786, and the one of log10\_x1 removing the 4counts >10 is 0.15191. I agree that the magnitude remains different.
Another element given by a ... |
11,601,076 | I'm trying to create the search system with mutliple criteria fields.
My question is how to handle the empty criteria fields (omitted by user) when you search by EXACT word not just it's similars (LIKE).
**Code:**
```
$prva = mysql_real_escape_string($_POST["crit1"]);
$druga = mysql_real_escape_string($_POST["crit2"... | 2012/07/22 | [
"https://Stackoverflow.com/questions/11601076",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1318239/"
] | ```
$query="SELECT pointID FROM bpoint WHERE ";
if(isset($_POST['condition1']))
$condition[]="name='somename'";
if(isset($_POST['condition2']))
$condition[]="address='someaddress'";
//More condition here
if(!empty($condition))
$query .= implode(' AND ',$condition);
mysql_query($query)
``` | The suggestion is the same as writing the following query:
```
SELECT
pointID
FROM
bpoint
WHERE
(sName = '$prva' or sName is null)
AND (sAddr = '$druga' or aAdds is null)
AND (placeID = '$tretja' or placeID is null)
AND (sPhone = '$cetrta' or sPhone is null)
```
which is basically querying... |
54,827,163 | I'm trying to include a (.h) header file which is auto-generated by some compiler in my code. Below is the code snip from auto-generated header file.
```
typedef struct SequenceOfUint8 { // Line 69
struct SequenceOfUint8 *next;
Uint8 value;
} *SequenceOfUint8; // Line 72
`... | 2019/02/22 | [
"https://Stackoverflow.com/questions/54827163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7368517/"
] | You can't use it as is in C++ code. This is another instance where C and C++ being two *different* languages matters.
The tag namespace in C is separate, in C++ it isn't. It doesn't even exist in C++ to be precise.
Wrapping in `extern "C"` is also not going to make a C++ compiler treat the header as C code. That's no... | *Is more a remark than an answer, but not practical to do as a remark*
By pity if you are in C++ just replace it by
```
struct SequenceOfUint8 { // Line 69
SequenceOfUint8 *next;
Uint8 value;
};
```
else use *typedef* as usual in C but not to make a *typedef* for `SequenceOfUint8 *`, to make ... |
39,584 | While playing around with the Stack Overflow [data-dump](http://www.rdbhost.com/rdbadmin/main.html?r0000000767), I was getting a feel for the schema and data by looking at my own posts and comments, and I happened coincidentally to notice my comment on [this answer](https://stackoverflow.com/questions/1995113/strangest... | 2010/02/16 | [
"https://meta.stackexchange.com/questions/39584",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/140463/"
] | You pretty much answered the question yourself:
* Comments are lightweight; even as far as "they shouldn't contain information that you care about to persist".
* Comment voting even more so -- even though comments often get their votes for being witty, saying something funny, or including the words "freehand circles",... | I am able to see all my comments in activity tab's comment section .
 |
106,884 | I want to startup iexplore once an hour pointed at a specific url to kick off some processing.
It's a Windows 2003 server with Internet Explorer 7 running in enhanced security configuration.
The scheduled task is set to not require the user to be logged in to kick this task off.
When I am logged in I can see the iexp... | 2010/01/27 | [
"https://serverfault.com/questions/106884",
"https://serverfault.com",
"https://serverfault.com/users/20733/"
] | I'm wondering why would you want to launch such a behemoth just to access a URL?
Nevermind...
Here are some things that can help:
* [A set of command-line Windows website tools](http://johnmu.com/web-toolbox-1/)
* [WGET for Windows (win32)](http://users.ugent.be/~bpuype/wget/)
* [cURL](http://curl.haxx.se/)
Those a... | I'm looking for an even better way to do this than I'm using right now. Currently I'm using a simple .vbs script to achieve this.
```
url="http://www.mysite.com/updates.asp"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Call objHTTP.Open("GET", url, FALSE)
objHTTP.Send
```
In your scheduled task, call the "wscript.ex... |
35,228,125 | Let's say I have a C program that evaluates to either a zero or non zero integer; basically a program that evaluates to a boolean value.
I wish to write a shell script that can find out whether the C program evaluates to zero or not. I am currently trying to assign the return value of the C program to a variable in a ... | 2016/02/05 | [
"https://Stackoverflow.com/questions/35228125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4557453/"
] | This is very basic
```
#!/bin/sh
variable=`/path/to/executable input1`
```
or
```
#!/bin/sh
variable=$(/path/to/executable input1)
```
and to get the return code from the program use
```
echo $?
``` | You can assign with backticks or `$(...)` as shown in [iharob](https://stackoverflow.com/users/1983495/iharob)'s [answer](https://stackoverflow.com/a/35228138/3266847).
Another way is to interpret a zero return value as success and evaluate that directly (see [manual](https://www.gnu.org/software/bash/manual/bashref.h... |
34,670,679 | I don't quite know how to explain my problem simply
but I need to modify a `DataFrame` by inserting almost empty rows
for a software formatting compatibility problem.
Here an example:
I need to change this type of `Dataframe`:
```
df = pd.DataFrame({"line1": [200, 400, 800],
"line2": [400, 900, 7... | 2016/01/08 | [
"https://Stackoverflow.com/questions/34670679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3943196/"
] | Not sure this is exactly what you want. Based on the example dataframe given, you could try:
```
df = pd.DataFrame({"line1": [200, 400, 800], "line2": [400, 900, 700], "line3": [800, 700, 966], "name": ["bla", "bloo", "bloom"]})
dftemp=pd.DataFrame(columns=df.columns)
dftemp.loc[0]=(len(df.columns)-1)*['']+['ID']
dfte... | ```
df = pd.DataFrame({"line1": [200, 400, 800], "line2": [400, 900, 700], "line3": [800, 700, 966], "name": ["bla", "bloo", "bloom"]}) df.loc[-1] = [np.nan for i in range(df.shape[1] - 1) ] + ['name'] df.loc[-2] = [np.nan for i in range(df.shape[1] -1)] + ['ID'] df = df.fillna('') df=df.sort_index() df=df.reset_index(... |
1,795,649 | Maybe this is a stupid question but it's bugging me.
I have a bi-directional one to many relationship of Employee to Vehicles. When I persist an Employee in the database for the first time (i.e. it has no assigned ID) I also want its associated Vehicles to be persisted.
This works fine for me at the moment, except t... | 2009/11/25 | [
"https://Stackoverflow.com/questions/1795649",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/205971/"
] | You have to set the associatedEmployee on the Vehicle before persisting the Employee.
```
Employee newEmployee = new Employee("matt");
vehicle1.setAssociatedEmployee(newEmployee);
vehicles.add(vehicle1);
newEmployee.setVehicles(vehicles);
Employee savedEmployee = employeeDao.persistOrMerge(newEmployee);
``` | One way to do that is to set the cascade option on you "One" side of relationship:
```
class Employee {
//
@OneToMany(cascade = {CascadeType.PERSIST})
private Set<Vehicles> vehicles = new HashSet<Vehicles>();
//
}
```
by this, when you call
```
Employee savedEmployee = employeeDao.persistOrMerge(new... |
54,451,154 | I'm using react-router-dom v4, and had a hard time implementing routers in a way that params is passed.
```
const routing = (
<Router>
<div>
<Route exact path="/" component={App} />
<Route exact path="/login" component={Login} />
<Route exact path="/app" component={Mainpage} />
<Route exa... | 2019/01/30 | [
"https://Stackoverflow.com/questions/54451154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9977407/"
] | Remove return from QuizInterface
```
const QuizInterface = ({match}) => (
<div>
<Background />
<Interface status='quizzes' index={match.params.id}/>
</div>
)
``` | The problem is that everywhere in your App you have used the exact keyword which works alright when you don't have nested Routes but as soon as you have nested Routes it will cause problems.
In you case you have Quizzes Routes Configured as
```
<Route exact path="/app/quizzes" component={Quizzes} />
```
Now Quizze... |
15,313,412 | Say I've got this:
```
\item[1]\footnote{«footnote blah blah»}
footnote blah blah.
\item[2]\footnote{«blah blah footnote»}
random text
\item[3]\footnote{«this is not»}
more random text
```
I want to quickly delete \footnote{\*} (that includes \footnote{«footnote blah blah»} \footnote{«blah blah footnote»... | 2013/03/09 | [
"https://Stackoverflow.com/questions/15313412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I think the most accurate way would be to use:
```
:%s/\\footnote{.\{-}}//g
```
This will delete footnote and everything in between the braces. Using `{.*}` will delete everything up to the last brace even if it is outside of the footnote brace. | In escape mode
```
:1,$s/\\footnote{.*}//g
``` |
10,765,363 | Which is the best method.To open an link using button
```
<button type="button" onclick="location='permalink.php'">Permalink</button>
<button type="button" href="index.php">Permalink</button>
``` | 2012/05/26 | [
"https://Stackoverflow.com/questions/10765363",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1416553/"
] | The first one should work, but inline scripts are not recommended. You should read about how to attach events using [`addEventListener`](https://developer.mozilla.org/en/DOM/element.addEventListener) for standards compliant browsers and [`attachEvent`](http://msdn.microsoft.com/en-us/library/ie/ms536343%28v=vs.85%29.as... | Alternatively, you can do something like this, if the button 'style' is what you're after, and not specifically the `<button>` tag:
```
<form method="link" action="permalink.php">
<input type="submit" value="Permalink">
</form>
```
Another thought is that you could style an anchor to look like a button, then you... |
27,564,995 | Well, I'm building a app in both iOS and Android and both app needs to be syncronized with the cloud DB MySQL. Both the apps works offline so I need all the insert and update functionality. Delete is probably not going to be used but still I'd like to know.
Well, what I'm looking here is the solution or ideas or algo ... | 2014/12/19 | [
"https://Stackoverflow.com/questions/27564995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1417245/"
] | It's fairly straightforward once you get the hang of variadic template expansions.
this code builds a vector of each version of a function with 3 binary compile-time options. The index into the vector is the integer value of considering those options as binary bits:
```
#include <iostream>
#include <functional>
#incl... | Encode each boolean to a bit in a number, then use a switch statement. Something like this to set bits:
```
int i = 0;
i = i | ((1 << (N-1)) && boolN);
``` |
7,234,089 | In 2 parts of the C++/CLI code I'm working on, the program needs to run a different executable and have its STDOUT output redirected to a file. Its being attempted in 2 different ways, and only one of the 2 currently works. The program is being run on Windows XP.
The first section assembles a long char\* that ends up ... | 2011/08/29 | [
"https://Stackoverflow.com/questions/7234089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/867710/"
] | Check out [this](http://www.codeproject.com/KB/cs/ProcessStartDemo.aspx) article. Noteworthy:
```
/* Setup Redirect */
processStartInfo.RedirectStandardError = true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
/* Capture Output */
StreamWriter inputWriter = process.S... | The "pipe command" is not passed as a parameter to the program; the shell interprets it and the program itself has no idea that its output is being redirected to a file. So you don't want to pass stuff like that as an argument.
However, the `Program` class has `StandardOutput` and `StandardError` stream properties to ... |
68,159,185 | I really liked the toggle switch "Example 3" on this website and they provide the HTML/CSS code with it. Although, when I try it on my webpage it renders as a simple plain checkbox.
I have beginners knowledge of HTML/CSS but the code makes sense and I'm not sure what is wrong.
This is the code and the website attached... | 2021/06/28 | [
"https://Stackoverflow.com/questions/68159185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11305136/"
] | Not an answer to this question, but I think this is more important than the actual solution.
Solving interview questions is a great way to learn, but you should try to spend the time to understand why it doesn't work by yourself. As a programmer you'll spend most of your time reading and debugging code and this skill ... | As most list questions, you might need several "iterators" to solve it:
```
class LinkedList
{
private
// ...
std::optional<Node*> next(Node* n, std::size_t k)
{
for (std::size_t i = 0; i != k; ++i) {
if (n == nullptr) { return std::nullopt; }
node = node->next;
}
... |
59,198,428 | For example, I want to check if data contains list of well-formed dicts, and this list has length between 1 and 10.
```
from marshmallow import Schema, fields
class Record(Schema):
id = fields.Integer(required=True)
# more fields here, let's omit them
schema = Record(many=True)
# somehow define that we have... | 2019/12/05 | [
"https://Stackoverflow.com/questions/59198428",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10650942/"
] | **EDIT**
So it is possible to validate collections using just marshmallow. You can use the `pass_many` kwarg with `pre_load` or `post_load` methods. I did not have success with the `pre_load` but got to work with post. The `pass_many` kwarg will treat the input as a collection so then you can check the length of the c... | What I want to do may be achieved using this little library: <https://github.com/and-semakin/marshmallow-toplevel>.
```
pip install marshmallow-toplevel
```
Usage:
```
from marshmallow.validate import Length
from marshmallow_toplevel import TopLevelSchema
class BatchOfRecords(TopLevelSchema):
_toplevel = field... |
66,822,785 | I need to create 4 lists of random numbers containing 6 numbers each, these numbers can't overlap. How can I do it? The below only generates 1 list. I need 4.
```
import random
list_numbers = [random.randint(8,29) for x in range(6)]
print(list_numbers)
``` | 2021/03/26 | [
"https://Stackoverflow.com/questions/66822785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8237335/"
] | This answer doesn't meet the requirement of no imports, but it is worth mentioning anyway that it can be solved with a couple of imports at the top of main.qml.
<https://github.com/jh3010-qt-questions/qml_location/tree/import_solution>
```
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
i... | Another solution is to move main.qml into the qml folder. This allows main.qml to find MyDeepComponent because they are siblings. To find MyDeeperComponent, main.qml can import the "more" directory.
This solution in represented in the [all\_in\_one\_solution](https://github.com/jh3010-qt-questions/qml_location/tree/al... |
40,787,241 | I'va seen an **excersise** in a book, but I cannot figure out the answer:
>
> Is the following code legal or not? If not, how might you make it
> legal?
>
>
> `int null = 0, *p = null;`
>
>
>
Of course, the second one is not legal, you cannot convert int to int\*.
The theme was in the section the `constexpr`.... | 2016/11/24 | [
"https://Stackoverflow.com/questions/40787241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/417289/"
] | The other answer miss a very simple solution to make it legal: Make `null` a pointer:
```
int *null = 0, *p = null;
```
But as noted, the best solution is to not use the `null` variable at all, but to use the standard `nullptr`. | I think you can use `reinterpret_cast<int*>` over the int in order to make this valid. |
56,508,564 | I want to build a combination of numbers and letters separated by - (minus sign). i.e 1-R-3. The first number are in an array called $Points ,the letters are stored in a array called $Color and the last number is in a third array called $Points2;
```
$Points = [1,2,3,4];
$Color = [R,B,V,Y];
$Points = [1,2,3,4];
```
... | 2019/06/08 | [
"https://Stackoverflow.com/questions/56508564",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9860030/"
] | ```
$Points = [1,2,3,4];
$Color = ['R','B','V','Y'];
foreach ($Points as $point=>$value) {
echo $value . '-' . $Color[$point] . '-' . $value . PHP_EOL;
}
```
Note that the values in the `$Color` array need to be in quotes to avoid errors. | You can use php `join` function. For example:
```php
$results = [];
for ($i = 0; $i < count($Points); $i++) {
$results[] = join('-', [$Points[$i], $Colors[$i], $Points2[$i]]);
}
// Now you have your combined values in $results array
var_export($results);
``` |
40,921,128 | It seems that MathML works OK with my word with simple copy and paste for strings such as
```
<math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mn>1</mn><mn>2</mn></mfrac></math>
```
But when I try to use `sympy`'s mathml printer:
```
from sympy import S
from sympy.printing.mathml import mathml
my_eqn = S(1)... | 2016/12/01 | [
"https://Stackoverflow.com/questions/40921128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2203311/"
] | Looks like the MathML that works is [presentation MathML](https://en.wikipedia.org/wiki/MathML#Presentation_MathML), whereas SymPy outputs [content MathML](https://en.wikipedia.org/wiki/MathML#Content_MathML). Unsurprisingly, Word is unable to convert from content to presentation, as that requires some degree of mathem... | SymPy [supports presentation MathML now](https://github.com/sympy/sympy/pull/13794). For that you use the arg `printer="presentation"`
```py
mathml(expr, printer="presentation")
```
You should put the output inside the `<math>` tag:
```xml
<math xmlns = "http://www.w3.org/1998/Math/MathML">
</math>
``` |
41,360 | I am watching a lot of American and English movies on Netflix with the original sound and German subtitles. I've noticed that in the subtitles, when two people are talking, the formal pronouns are always used when the two characters address each other, regardless of their relationship.
For example, a conversation in [... | 2018/01/30 | [
"https://german.stackexchange.com/questions/41360",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/31744/"
] | In the German dubbed version Sherlock and John also use *Sie* when talking to each other.
One reason might be, that they still have a somehow professional relationship which maybe should be enforced by the use of *Sie*. Especially in a business context in a German speaking company it is still quite common to use *Sie*... | The form of address in German is part of the speech and vary in dependence of social relation. Further more it is different in parts of Germany how you address your counterpart by default. So it can be very subtle which address is suitable in which situation.
I don't know other series but for Sherlock in a modern sigh... |
9,662,458 | I'm integrating Symfony DIC in a zend framework application, that's going fine except for parent services.
In my DIC config I have a parent service PC\_Service which will be extended by all my services.
The problem is that the entity manager is not available (NULL) in the services that extend PC\_Service. When I injec... | 2012/03/12 | [
"https://Stackoverflow.com/questions/9662458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/80840/"
] | Don't know if it's a typo but it should be `doctrine.orm.default_entity_manager` or `doctrine.orm.entity_manager` (alias of the previuos):
```
<service id="pc.service" class="PC_Service" abstract="true">
<call method="setEntityManager">
<argument type="service" id="doctrine.orm.default_entity_manager" />
... | The solution is to compile the service container near the end of the ZF bootstrap. This process has a step called `ResolveDefinitionTemplatesPass` which patches in the calls from parent services.
This is typically done by the [Symfony Kernel](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKer... |
19,513,094 | Complete noob here.
Trying this in C++.
I am trying to create an array of numbers that are of any base.
That is I want to define a new base and have this array "count" in the new base.
For example: base 78.
I want to create an array of lets say 3 78-base numbers in such a way as when I add to the first "digit" it overf... | 2013/10/22 | [
"https://Stackoverflow.com/questions/19513094",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2527849/"
] | Basically: you can't do this with primitive types like long, int etc. in Java as they're allways passed by-value. Check out [Oracles Java tutorials](http://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html "Oracles Java tutorials") for some background
You could workaround this problem very simple if you use a... | Well, almost. If you want to be able to change the value and have it reflected in the calling code, you can do something like this:
```
class ValueHolder {
long value;
//getter, setters, etc
}
```
And pass this instead of your `long`.
Note that this isn't passing by reference, you are just passing the value... |
9,664,036 | I have this piece of code:
```
public static void main(String[] args) {
Downoader down = new Downoader();
Downoader down2 = new Downoader();
down.downloadFromConstructedUrl("http:xxxxx", new File("./references/word.txt"), new File("./references/words.txt"));
down2.downloadFromConstructe... | 2012/03/12 | [
"https://Stackoverflow.com/questions/9664036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1238134/"
] | Instead of using threads directly, you better use ExecutorService, and run all download tasks through this service. Something like:
```
ExecutorService service = Executors.newCachedThreadPool();
Downloader down = new Downloader("http:xxxxx", new File("./references/word.txt"), new File("./references/words.txt"));
Down... | That would be what [concurrency and threading](http://docs.oracle.com/javase/tutorial/essential/concurrency/) is for. |
18,560,060 | I'm learning C programming in a self-taught fashion. I know that numeric pointer addresses must always be initialized, either statically or dynamically.
However, I haven't read about the compulsory need of initializing char pointer addresses yet.
For example, would this code be correct, or is a pointer address initia... | 2013/09/01 | [
"https://Stackoverflow.com/questions/18560060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2718426/"
] | I'm not entirely sure what you mean by "numeric pointer" as opposed to "char pointer". In C, a `char` is an integer type, so it is an arithmetic type. In any case, initialization is not required for a pointer, regardless of whether or not it's a pointer to `char`.
Your code has the mistake of using `*p_message` inste... | Initialisation is not *needed*, regardless of what type the pointer points to. The only requirement is that you must not attempt to *use* an uninitialised pointer (that has never been assigned to) for anything.
However, for aesthetic and maintenance reasons, one should always initialise where possible (even if that's ... |
24,880,971 | Im getting this error:
```
D:\Users\JF150696\AppData\Local\Temp\ccrDYwyp.o Source2.cpp:(.text+0xdf): undefined reference to `cv::imread(std::string const&, int)'
D:\Users\JF150696\AppData\Local\Temp\ccrDYwyp.o Source2.cpp:(.text+0xdec): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
D:\Users\JF1... | 2014/07/22 | [
"https://Stackoverflow.com/questions/24880971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3804906/"
] | Two approaches spring to mind:
### Tread the four cases separately and then OR them together:
1. start and end are null: any date matches,
2. start is null, so need DoB <= end
3. send is null, so need DoB >= start
4. neither is null, so need between
This will lead to a long expression.
### Use [`IsNull`](https://st... | If you are using a nullable datetime type you could use
```
User.DateOfBirth BETWEEN isnull(@startDAte, CAST('1753-01-01' AS datetime)) AND isnull(@endDAte, CAST('9999-12-31' AS datetime))
```
for datetime2 use
```
User.DateOfBirth BETWEEN isnull(@startDAte, CAST('0001-01-01' AS datetime2)) AND isnull(@endDAte, CAS... |
162,845 | What physical evidence shows that subatomic particles pop in and out of existence? | 2015/02/01 | [
"https://physics.stackexchange.com/questions/162845",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/72173/"
] | My current understanding is that the physical reality of vacuum fluctuations, particle-antiparticle pairs being created and then annihilating, is disputed. [The Casimir effect](http://en.wikipedia.org/wiki/Casimir_effect) is often cited as physical evidence but there's a few authors which have come to dispute that the ... | This phenomenon is called Quantum Fluctuations or vacuum energy and it could be described theoretically by Heisenberg uncertainty relation with the energy term.
One of the physical evidences of such phenomenon is ''Casimir effect'' .
when two uncharged plates are put close to each other they exhibit a repulsive forc... |
15,539,029 | I have been working on an app and recently started making some pretty large changes to it. Basically, the app enables the user to keep track of the water they drink and apply that to the goal they set at registration.
One of the features would be a visual rep of their current progress, but I can't figure out how to do... | 2013/03/21 | [
"https://Stackoverflow.com/questions/15539029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/326544/"
] | Here's a fiddle I made doing exactly what you describe. You should be able to see what's going on!
<http://jsfiddle.net/mike_marcacci/XztTN/>
Basically, just nest a div.water inside div.glass, position the water to the bottom of the glass, and animate its height with query!
```
$(function(){
$('.water').animate(... | I do something very similar by absolutely positioning a semi-transparent white PNG over the top of the base image (in your case the glass), and moving it higher as the percentage increases.
```
<div style="z-index: 10; position: relative;"><img src="images/overlay.png" style="position: absolute; top: 75%; left: 0; wid... |
28,628,667 | I have file like below :
this is a sample file
this file will be used for testing
```
this is a sample file
this file will be used for testing
```
I want to count the words using AWK.
the expected output is
```
this 2
is 1
a 1
sample 1
file 2
will 1
be 1
used 1
for 1
```
the below AWK I have written but gettin... | 2015/02/20 | [
"https://Stackoverflow.com/questions/28628667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3090114/"
] | It works fine for me:
```
awk '{for(i=1;i<=NF;i++) a[$i]++} END {for(k in a) print k,a[k]}' testfile
used 1
this 2
be 1
a 1
for 1
testing 1
file 2
will 1
sample 1
is 1
```
PS you do not need to set `-F" "`, since its default any blank.
PS2, do not use `cat` with programs that can read data itself, like `awk`
You... | Here is Perl code which provides similar sorted output to Jotne's awk solution:
`perl -ne 'for (split /\s+/, $_){ $w{$_}++ }; END{ for $key (sort keys %w) { print "$key $w{$key}\n"}}' testfile`
`$_` is the current line, which is split based on whitespace `/\s+/`
Each word is then put into `$_`
The `%w` hash sto... |
475,611 | If I have 20 variables, should I do a pair-wise correlation check before building a classification model with Logistic Reg, Decision Tree or Random Forest ? Multicolinearity is a problem in regression. Is it a problem in classification as well ? Besides classifying, I also need to understand the influence of variables ... | 2020/07/05 | [
"https://stats.stackexchange.com/questions/475611",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/268655/"
] | Instead of focusing only on the distribution function, let's focus on equality in distribution.
A finite sequence of random variables $X\_1, \ldots, X\_n$ is exchangeable if for every permutation $\pi$ we have
$$
X\_1, \ldots, X\_N =\_d X\_{\pi(1)}, \ldots, X\_{\pi(n)}
$$
where $=\_d$ means equality in distribution.
... | Something that might be helpful in unifying these two views is the Hewitt-Savage(-de Finetti) representation theorem.
The theorem says that $X\_1,\dots,X\_n$ are exchangeable precisely when they are independent and identically distributed conditional on some additional information. This is important in Bayesian statis... |
73,086,940 | I have the working example for rotating an image on hover [here](https://codepen.io/krakruhahah/pen/zYWzpOW)
It uses scale(), rotate() and transition properties when hovering over the parent element to animate the image.
And overflow: hidden on the parent element to hide the excess from the image transformation.
When... | 2022/07/22 | [
"https://Stackoverflow.com/questions/73086940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You have to either change the hash method's return value to `hash(self.text)`, or, you can keep its return as `hash(str(self))` and add a `__str__` method whose return value is `self.text`. | You didn’t define a `__str__` or a `__repr__`, and the default repr includes the object’s id. |
2,080,347 | I have a model that uses a serialized column:
```
class Form < ActiveRecord::Base
serialize :options, Hash
end
```
Is there a way to make this serialization use JSON instead of YAML? | 2010/01/17 | [
"https://Stackoverflow.com/questions/2080347",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14971/"
] | My requirements didn't need a lot of code re-use at this stage, so my distilled code is a variation on the above answer:
```
require "json/ext"
before_save :json_serialize
after_save :json_deserialize
def json_serialize
self.options = self.options.to_json
end
def json_deserialize
self... | Aleran, have you used this method with Rails 3? I've somewhat got the same issue and I was heading towards serialized when I ran into this post by Michael Rykov, but commenting on his blog is not possible, or at least on that post. To my understanding he is saying that you do not need to define Settings class, however ... |
1,207,163 | When running a clean install of Ubuntu 17.04 on a fresh Dell XPS 9360 (3200x1800 display) I was soon shown the following screen after the initial boot:
[](https://i.stack.imgur.com/NZd1f.png)
Basically, the displayed image is corrupt and incomprehensible. What ca... | 2017/05/08 | [
"https://superuser.com/questions/1207163",
"https://superuser.com",
"https://superuser.com/users/69121/"
] | Basically, the allotted default amount of VRAM (video ram) in Virtualbox is not sufficient for the high-resolution display. Simply try increasing it. By increasing it from the default (19MB?) to 128MB the problem went away.
[](https://i.stack.imgur.com/iP76K.png)
Th... | While trying to install an old version of ubuntu (10.04) on my Ubuntu 19.04 (beta) on Lenovo X1 carbon - I had this issue.
I changed the "Graphics Controller" in machine settings to VBOXVGA and it fixed the issue. |
35,233,305 | I ran `rvm install ruby-2.2.4` and got the following error:
```
$ rvm reinstall ruby-2.2.4
ruby-2.2.4 - #removing src/ruby-2.2.4..
ruby-2.2.4 - #removing rubies/ruby-2.2.4..
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.9/x86_64/ruby-2.2.4.
Continuing with compilation. ... | 2016/02/05 | [
"https://Stackoverflow.com/questions/35233305",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1499260/"
] | Since [webpack-dev-server](https://github.com/webpack/webpack-dev-server) is just a tiny express server with compile on change and hot reload.
So, if you already got a express server for backend API, just merge the `compile on change and hot reload` into your express server.
Then after take a look at the `package.jso... | Just faced the same issue and came with another solution (found out more information about it later, but here it is).
Instead of using the webpack-dev-server, use the `webpack --watch` command so files are compiled again upon changes. Once the files are updated on the dist (or any other compiled files folder) you can ... |
35,456,815 | Suppose we have a text size of (1 GB) and let's assume the following text as a sample:
>
> Stack Overflow is a privately held website, the flagship site of the Stack Exchange Network, created in 2008 by Jeff Atwood and Joel Spolsky. It was created to be a more open alternative to earlier Q&A sites such as Experts-Exc... | 2016/02/17 | [
"https://Stackoverflow.com/questions/35456815",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3005903/"
] | You ask for the "best" algorithm. I can think of the following definitions of "best":
1. fastest to implement
2. fastest to run once (lowest run-time) given enough memory
3. lowest memory footprint
4. fastest to run for large numbers of queries, so that each additional query requires minimal time
5. a compromise betwe... | I really don't know anything about algorithms, but for a simple solution I'd use a StringTokenizer, delimited with a space, and if the stringTokenizer.nextToken() returns a string starting with the letter you're looking for, check the result of the next stringTokenizer.nextToken() call, and so on |
47,916,611 | I am working in an android app where user accept or reject video call which is working fine. but now i want to prevent app conflict with others if we have any other call like what's app or skype.
I have then read [self managed connectionservice](https://developer.android.com/guide/topics/connectivity/telecom/selfMana... | 2017/12/21 | [
"https://Stackoverflow.com/questions/47916611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2121089/"
] | You've already noticed that `unlist` gives you the values column-wise:
```
unlist(df[1:3], use.names = FALSE)
## [1] 1 4 7 10 2 5 8 11 3 6 9 12
```
To get the values row-wise, you can use the `c(t(...))` idiom:
```
c(t(df[1:3]))
## [1] 1 2 3 4 5 6 7 8 9 10 11 12
```
That would allow you to sol... | I was surprised that no one mentions `split.default`, which also works on data with more columns:
```
x <- split.default(df, ceiling(seq_along(df) / 3 ))
do.call(rbind, lapply(x, setNames, names(x[[1]])))
# V1 V2 V3
# 1.1 1 2 3
# 1.2 4 5 6
# 1.3 7 8 9
# 1.4 10 11 12
# 2.1 13 14 15
# 2.2 16 NA NA
# 2.3 19... |
30,559,602 | googled it, read millions of advices about how to generate google API key, how to use it but nothing works!
1. enabled google maps v2 API
2. created project with one activity with google map (default wizard in studio)
3. created key on google for debug project, assigned *SHA1;app package* of application to the project... | 2015/05/31 | [
"https://Stackoverflow.com/questions/30559602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4953224/"
] | i was tired of trying over and over again, it turns out that PlayStore has something called **App signing certificate**, and the map works after i copy that sha1 and paste it in the google console for the android map. | Make sure the map key you entered in google\_maps\_api.xml file is the same android key, generated by google console.
You can also try a new key. |
1,474,536 | I'm trying to retreive data from a massive form using Asp.net MVC. Its top object L1 contains properties which are Collections of other types L2. However the Type L2 contains some properties which collections of type L3, and so on. There are probably 5 levels of nested collections.
I've seen the approach of binding to... | 2009/09/24 | [
"https://Stackoverflow.com/questions/1474536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The default model binder that ships with ASP.NET MVC is what dictates the form element naming convention you are referring to. If there is another convention that you would like to use to name the form elements, go for it. Then you just have to write a custom model binder that can populate your nested objects based on ... | You may want to consider using LINQ to abstract the nitty gritty for you and allow you to perform joins and whatnot on the lists. |
6,478,414 | I have a button that apply filter to jquery datatable
```
$("#buttonFilter").button().click(function() {
if (lboxColor.val() != null) {
jqTable.fnFilter($("option:selected", lboxColor).text(), 1);
}
});
```
It shows me for example 47 rows from 60.
I tri... | 2011/06/25 | [
"https://Stackoverflow.com/questions/6478414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/815410/"
] | In current versions [selector-modifier](https://datatables.net/reference/type/selector-modifier) uses a slightly different set of properties.
```
var table = $('#example').DataTable();
var rows = table.rows({"search" : "applied"});
```
And you can iterate over the cell data like this:
```
table.rows({"search":"appl... | like if work for you
```
var data = []
table.rows({"search":"applied"}).every(()=>data.push(this.data()))
console.log(data)
``` |
50,000,756 | I have the following code:
```
final TransformerFactory factory = TransformerFactory.newInstance();
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
```
The second line works fine in modern JDKs (I tried 1.8) with a default `TransformerFactory`. But when I add `xalan` (version 2.7.2, the most recent one)... | 2018/04/24 | [
"https://Stackoverflow.com/questions/50000756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7637120/"
] | The only thing I could achieve here is to hardcode JDK default factory and use the normal discovery process as a fallback:
```
TransformerFactory factory;
try {
//the open jdk implementation allows the disabling of the feature used for XXE
factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.inter... | Another way to define which TransformerFactory implementation to load is by setting the `javax.xml.transform.TransformerFactory` system property ([docs](https://docs.oracle.com/javase/8/docs/api/javax/xml/transform/TransformerFactory.html#newInstance--)).
In Ant you would do something like this inside your target:
``... |
13,642,529 | The following works in windows:
```
mkdir('../my/folder/somewhere/on/the/server', 0777, true);
```
I am talking about [PHP mkdir](http://php.net/manual/en/function.mkdir.php).
It works perfectly, and creates the subfolders recursively. However, if I run the same command on a linux server, the folders aren't created... | 2012/11/30 | [
"https://Stackoverflow.com/questions/13642529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/146366/"
] | Sorry, but there must be some problem apart from the `mkdir` command itself.
This tiny example works as expected and recursively creates the directories for me when executed on Linux:
```
#!/usr/bin/php
<?php
mkdir ('testdir/testdir2/testdir3',0777,TRUE);
?>
``` | This are the thing have discovered
* Make sure the root path exists
* Make sure the root path is writable
* Don't use `..` always use real path ...
Example
```
$fixedRoot = __DIR__;
$recusivePath = 'my/folder/somewhere/on/the/server';
if (is_writable($fixedRoot) && is_dir($fixedRoot)) {
mkdir($fixedRoot . DIRE... |
9,169,517 | I cant get Spring's JSON support working. In my spring-servlet.xml file i have included following lines:
```
<mvc:annotation-driven/>
<context:component-scan base-package="my.packagename.here" />
<context:annotation-config />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceView... | 2012/02/07 | [
"https://Stackoverflow.com/questions/9169517",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1132633/"
] | For Jackson v2 jars, class to be used for bean should be
```
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
```
For older jackson version, org.springframework.http.converter.json.MappingJacksonHttpMessageConverter is ok. Make sure the jar files are added to the project ... | Just to complement anshul tiwari answer, the bean tag should go inside mvc:annotation-driver:
```
<mvc:annotation-driven>
<mvc:message-converters>
<bean
class="org.springframework.http.converter.ResourceHttpMessageConverter" />
<!-- <bean -->
<!-- class="org.springframework.http... |
23,491,088 | I have a string like
```
"<Canvas Background="#FF00FFFF" Name="Page_1" Width="1200" Height="900" ><TextBlock Name="PageTitle" /></Canvas><Canvas Background="#FF00FFFF" Name="Page_2" Width="1200" Height="900"><TextBlock Name="PageTitle" /></Canvas>"
```
I want to split this string into an array like
```
[< Canvas B... | 2014/05/06 | [
"https://Stackoverflow.com/questions/23491088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3351652/"
] | try this
```
string mailstring = "<Canvas Background='#FF00FFFF' Name='Page_1' Width='1200' Height='900' ><TextBlock Name='PageTitle' /></Canvas><Canvas Background='#FF00FFFF' Name='Page_2' Width='1200' Height='900'<TextBlock Name='PageTitle' /></Canvas>";
string splitor = "</Canvas>";
string[]... | Use `Split` as you did, after that iterate over the array and insert `"<Canvas"` to the beginning of all items besides the first, append `"/Canvas>"` to the end of all items besides the last.
```
contents = "<Canvas Background=\"#FF00FFFF\" Name=\"Page_1\" Width=\"1200\" Height=\"900\" ><TextBlock Name=\"PageTitle\" /... |
15,811,920 | Apologies if this has been asked, but the similar questions I found weren't answering my problem exactly.
I know how to take a single input and convert it into a string, and or anything hard coded. What I'm trying to do however is take multiple inputs and convert them into a single string.
Example:
```
Enter a lette... | 2013/04/04 | [
"https://Stackoverflow.com/questions/15811920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2093399/"
] | I realize this post is old, however, this is how I coded the solution in Python 3
```
mylist = []
results = ""
while True:
c = input("Enter a letter:")
if c == "s":
result = "\n".join(mylist)
print('Items entered: \n'+ result)
break
mylist.append(c)
``` | >
> How do I piece together a string from separate, potentially infinite inputs?
>
>
>
You can do this using
```
''.join(inputs)
```
where `inputs` is any [iterable](http://docs.python.org/2/glossary.html#term-iterable) of strings. |
17,070,740 | I need to call a COM function in C++ that returns a reference to a `SAFEARRAY(BSTR)`.
According to [this document](http://qt-project.org/doc/qt-4.8/qaxbase.html#details), it should be:
```
QAxObject object = new QAxObject(...);
QStringList list;
for(int i=0; i<goodSize; i++)
list << "10.0";
object->dynamicCall(... | 2013/06/12 | [
"https://Stackoverflow.com/questions/17070740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/902025/"
] | Here is how I solved this:
public WebDriver driver;
```
// Overrides the default driver
@Override
public WebDriver getDefaultDriver() {
System.setProperty("webdriver.chrome.driver", "C:/chromeDriver/chromedriver.exe"); // Set for ChromeDriver
driver = new ChromeDriver();
return driver;
}
``` | Have an abstract `createDriver()` function that is overridden by each type of driver. Each driver should return a correctly configured driver, which is then stored, and returned when you call `getDefaultDriver();` |
4,551 | If $A,B$ non empty, upper bounded sets and $A+B=\{a+b\mid a\in A, b\in B\}$, how can I prove that $\sup(A+B)=\sup A+\sup B$? | 2010/09/13 | [
"https://math.stackexchange.com/questions/4551",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1862/"
] | Show that $\sup(A+B)$ is less than or equal to $\sup(A)+\sup(B)$ by showing that the latter is an upper bound for $A+B$. Then show that $\sup(A)+\sup(B)$ is less than or equal to $\sup(A+B)$ by showing that $\sup(A+B)$ is an upper bound for $A+\sup(B)$ and that $\sup(A+\sup(B)) = \sup(A)+\sup(B)$. | Another proof for $\sup(A + B) \geq \sup A + \sup B$.
---
Proof when $\sup A + \sup B$ is finite:
---------------------------------------
Posit $e > 0.$ Then there exists $a \in A$ and $b \in B$ such that
$a > \sup A − \frac{e}{2}$ and $b > \sup B − \frac{e}{2}$. Then $a + b \in A + B$. Ergo, $$\color{seagreen}{\sup... |
61,546 | Computing power considerations aside, are there any reasons to believe that **increasing the number of folds** in cross-validation leads to better model selection/validation (i.e. that the higher the number of folds the better)?
Taking the argument to the extreme, does leave-one-out cross-validation necessarily lead t... | 2013/06/12 | [
"https://stats.stackexchange.com/questions/61546",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/2798/"
] | Leave-one-out cross-validation does not generally lead to better performance than K-fold, and is more likely to be *worse*, as it has a relatively high variance (i.e. its value changes more for different samples of data than the value for k-fold cross-validation). This is bad in a model selection criterion as it means ... | Choosing the number K folds by considering the learning curve
=============================================================
I would like to argue that choosing the appropriate number of $K$ folds depends a lot on the shape and position of the learning curve, mostly due to its impact on the **bias**. This argument, whi... |
1,284,804 | Isn't the tuple different structure from $m \times 1$ or $1 \times n$ matrix? Why can you mix them? | 2015/05/16 | [
"https://math.stackexchange.com/questions/1284804",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/114222/"
] | From [Wikipedia](http://en.wikipedia.org/wiki/Tuple), "A tuple is a finite ordered list of elements." So things like $(\clubsuit, \square, 57, \clubsuit)$ are perfectly valid tuples, and we can view this particular tuple as one function
$$f: [4] = \{1, 2, 3,4\} \to A,$$
where $A$ is just some set that includes $\{\sq... | There is a difference because of the definition of those objects (I take $\mathbb R$ as the underlying number system):
* A $m\times 1$ matrix represents a linear function $\mathbb R^m \rightarrow \mathbb R$.
* A $1\times m$ matrix represents a linear function $\mathbb R \rightarrow \mathbb R^m$.
* A $m$-tuple represen... |
259,053 | We all know that *to eat out* means “to eat away from home, esp in a restaurant” per the [Free Dictionary](http://www.thefreedictionary.com/eat+out).
However, I have not heard anyone say *to drink out*. The Internet doesn’t have any information about it.
Does
>
> *to drink out*: to drink away from home, esp. in co... | 2015/07/13 | [
"https://english.stackexchange.com/questions/259053",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/105551/"
] | No, such a term is not used.
To convey the meaning that you describe, people say: *let's go out for a drink.*
Consequently, simply saying *let's go out* has come to mean the same thing, and so *go out* is equivalent to *eat out*.
My answer is a British English perspective. | We all know English language just like every language is living. If the phrase is not yet recognized in English Language but is very convenient, I guess it is high time we used it even more often. By that it will surely get the recognition it needs. |
1,397,428 | >
> Find the number of real roots of $1+x/1!+x^2/2!+x^3/3! + \ldots + x^6/6! =0$.
>
>
>
*Attempts so far:*
Used Descartes signs stuff so possible number of real roots is $6,4,2,0$
tried differentiating the equation $4$ times and got an equation with no roots hence proving that above polynomial has $4$ real roots.... | 2015/08/14 | [
"https://math.stackexchange.com/questions/1397428",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/262120/"
] | We can compute the number of real roots using [Sturm's Theorem](https://en.wikipedia.org/wiki/Sturm%27s_theorem).
$$
\begin{array}{rll}
\text{Sturm Chain}&+\infty&-\infty\\\hline
x^6+6x^5+30x^4+120x^3+360x^2+720x+720&+\infty&+\infty\\
6x^5+30x^4+120x^3+360x^2+720x+720&+\infty&-\infty\\
-5x^4-40x^3-180x^2-480x-600&-\inf... | let $y = 1+x/1!+x^2/2!+x^3/3! + \cdots + x^6/6! .$
it is clear that $y \ge 1$ for all $x \ge 0.$ we will show that $y(a) > 0$ for $a < 0$ and that will prove that $y$ is never zero.
pick an $a < 0.$ we have $$y' = y - x^6/6!, \space y(0) = 1.\tag 1$$
rearranging $(1)$ and multiplying by $e^{-x}$ gives
$$ (ye^{-x})... |
8,143,750 | I would like to implement a basic rotation animation in iOS, where the view is continuously rotating around its center point.
However, for some reason, the rotation's anchor point is always the parent view's origin, and not the rotating view's center.
Therefore, the view is rotating around the upper left corner of ... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8143750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560496/"
] | I also encountered the same problem. Scaling and rotation seems to be using a top-left anchorPoint even after setting it manually to (0.5, 0.5). I fixed it on my code by manually setting the layer's frame or bounds property to have the same size as your path. | Here is how you can rotate around a particular point, without using anchorPoint. I'm not sure what anchorPoint is supposed to do for a rotation animation, but it doesn't seem to be doing what you want.
"First" translate so your center of rotation is at the origin. So apply a translation left and up.
Then rotate.
The... |
566,724 | I've a fresh installation of Ubuntu 14.10 desktop. I downloaded it yesterday. It has been installed correctly.
I've added a repository and now when I enter `sudo apt-get update` it gives following errors:
```
Ign cdrom://Ubuntu 14.10 _Utopic Unicorn_ - Release i386 (20141022.1) utopic InRelease
Ign cdrom://Ubuntu 1... | 2014/12/29 | [
"https://askubuntu.com/questions/566724",
"https://askubuntu.com",
"https://askubuntu.com/users/300619/"
] | I'm not sure if there should be a pipe character `|` in the middle of your ubuntu server name... that's not just how the error message looks is it?
Try checking your software repositories, try different mirrors perhaps. This help page should help <https://help.ubuntu.com/community/Repositories/Ubuntu>
And I tried con... | You are most possibly behind a physical / network firewall or some other network security device on which http/https proxy or few website categories are blocked or a rare chance but port 80/443/8080 are booked |
43,432,388 | Am trying to add a variable into a url, but the server gives me a 400 and i dont recive data
```
var x = "City"
$.getJSON('http://api.apixu.com/v1/current.json?key=' + x, function(jd) {
``` | 2017/04/16 | [
"https://Stackoverflow.com/questions/43432388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6637384/"
] | You need to get the value in the text field inside the click handler; otherwise, you're just going to have the same value every time the handler runs:
```
var clickBot = document.querySelector("#bot")
clickBot.addEventListener("click",function(){
var textValue = document.querySelector("#myText").value;
alert(... | The variable `textValue` is already initialized as `undefined` outside the event listener.
You need to reassign that value every time that button is clicked.
I would suggest using `textValue` to store the selector and then using `textValue.value` in the alert.
```
var textValue = document.querySelector("#myText");
va... |
59,275,009 | I'm using Android Navigation Component with bottom navigation, lint gives a warning about replacing the `<fragment>` tag with `<FragmentContainerView>` but when i replaced, `findNavController` is not working it gives me error about it does not have a NavController set on
Fragment
```
<androidx.fragment.app.FragmentCo... | 2019/12/10 | [
"https://Stackoverflow.com/questions/59275009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7160898/"
] | Replace this line:
```java
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
```
with
```java
NavController navController = getNavController();
```
Where `getNavController()` looks like this:
```java
// workaround for https://issuetracker.google.com/issues/142847973
... | Here is the simple answer -
```
val navHostFragment = supportFragmentManager.findFragmentById(R.id.fragmentContainerView)
```
as NavHostFragment
```
val navController = navHostFragment.navControllermenus.setupWithNavController(navController)
``` |
44,603,418 | I'm trying to make a simple app for some kids. I want to show a photo and to link that photo to a sound.
When the kid click on "Play Sound" it should play an audio that represents the image.
so far I've done only showing the images, that I've put in Assets.xcassets, but my question is..
How can I link those photos ... | 2017/06/17 | [
"https://Stackoverflow.com/questions/44603418",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8024141/"
] | Please comment this
```
compile 'com.daimajia.swipelayout:library:1.2.0@aar'
```
Try Rebuilding again. Since it's a third party library , there is a chance that it might be causing the trouble | It means you are using different version of support and all android libraries for example you are using support library version 25.0.1 in one module and version 22.2.1 in another and of course you should add just one of these library to your dependencies when you add one library in one module you should not add it to b... |
31,643,036 | When I try to call install\_github, I get the following error (not just for this package, but for all github packages):
```
> install_github('ramnathv/slidify')
Downloading github repo ramnathv/slidify@master
Error in curl::curl_fetch_memory(url, handle = handle) :
Problem with the SSL CA cert (path? access rights?)
... | 2015/07/26 | [
"https://Stackoverflow.com/questions/31643036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2727570/"
] | If `httr` lib is missing the same error appears
try:
>
> install.packages("httr")
>
>
> | I was getting the same error with swirl while submitting assignments for Coursera.
Uninstall and reinstall swirl itself, curl and htrr (which was also missing) did not address the issue. The only thing that actually worked was:
install.packages("openssl")
Also using Windows 10 and R 3.3.3. |
17,790,397 | I have some radiobuttons in an app that works with touch.
Because the end-user can have thick fingers, I want to make the circle and text int he radiobutton bigger.
Problem is, I can only make the text bigger, not the circle in the radiobutton.
```
<RadioButton VerticalAlignment="Center" x:Name="rbtnContainers" Cl... | 2013/07/22 | [
"https://Stackoverflow.com/questions/17790397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2515525/"
] | This should work for you.
```
<Viewbox Height="40">
<RadioButton></RadioButton>
</Viewbox>
```
another alternative is to write your own ControlTemplate for the RadioButton and change its appearance as you want. | To resize only the circle, one can use `RadioButton` template and change `Width` and `Height` of `BulletChrome`.
```
<ControlTemplate TargetType="RadioButton" x:Key="CustomRadioButtonStyle"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:s="clr-namespace:System;assembly=msc... |
13,236,719 | I'm trying to compare two days of NSDate objects, I used at the first time NSDateComponents to calculate difference between my two dates Objects, but it is working correctly.
```
NSString *dateStr =@"2012-11-05 15:00:00";
NSDate *date = [dateFormat dateFromString:dateStr];
NSDateComponents *datesDiff = [ca... | 2012/11/05 | [
"https://Stackoverflow.com/questions/13236719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1419681/"
] | I think you are looking for this (from the [Date and Time Programming Guide](https://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/DatesAndTimes/Articles/dtCalendricalCalculations.html)):
>
> Listing 13 Days between two dates, as the number of midnights between
>
>
>
```
@implementation NSCalend... | ```
func daysBetweenDates(startDate: NSDate, endDate: NSDate) -> Int
{
let calendar = NSCalendar.currentCalendar()
let components = calendar.components([.Day], fromDate: startDate, toDate: endDate, options: [])
return components.day
}
```
or
```
let calendar = NSCalendar.currentCalendar();
let compone... |
69,762,012 | I'm using OjbectBox for the first time in my Flutter project. After I wrote the basic code to read and right user data, I'm getting this error:
```
[!] CocoaPods could not find compatible versions for pod "ObjectBox":
In Podfile:
objectbox_flutter_libs (from `.symlinks/plugins/objectbox_flutter_libs/ios`) was re... | 2021/10/28 | [
"https://Stackoverflow.com/questions/69762012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9276925/"
] | This happened for me when I added `androidTestImplementation "androidx.compose.ui:ui-test-junit4:$version_compose"`.
Referring to the advice in [this posting](https://stackoverflow.com/a/29682960/1229936), I decided to use [`pickFirst`](https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api... | So the `exclude` and `pickFirst` already deprecated in kotlin DSL. put the following in your `build.gradle.kts`:
```
android {
packagingOptions {
resources.excludes.apply {
add("META-INF/LICENSE")
add("META-INF/*.properties")
add("META-INF/AL2.0")
add("MET... |
65,870,844 | I have a react component that renders the answers of a contact form and presents them in the page.
eg:
```
const Quote = ({fields}) => {
return (
<>
<div>
Business Type: {fields.businesstype.value}
</div>
....
</>
)
}
```
I need to send the rendered data to t... | 2021/01/24 | [
"https://Stackoverflow.com/questions/65870844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8091607/"
] | AnimatedSwitcher might help here. It animates between widgets automatically whenever the child changes. In your case, inside stream builder, wrap your widget with animated switcher. Check this for more information. [Animated Switcher](https://api.flutter.dev/flutter/widgets/AnimatedSwitcher-class.html)
There is a good... | When anything updates then StreamBuilder rebuilds the widget automatically. Internally, StreamBuilder calls `State.setState`. So, according to me, if you want to add an animation when the item is deleted, you have to add it on the Gesture detection. In your code snippet, you had added on GestureDetection that will remo... |
36,656 | I have had a theory for a long time that it is the blood in the deer which causes the gamey flavor. Hunters gut the deer soon after a kill, but they don't bleed it or chill it for hours or days. It takes time to haul it from the woods, then drive home and wait until the next day before visiting the processor. It seems ... | 2013/09/10 | [
"https://cooking.stackexchange.com/questions/36656",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/20120/"
] | According to the [University of Minnesota Extension](http://www1.extension.umn.edu/food/food-safety/preserving/meat-fish/gamey-flavor-and-cooking-venison/) (emphasis added):
>
> ### What causes the wild or gamey taste in venison?
>
>
> Venison refers to the
> meat of antlered animals such as deer, moose, elk and ca... | As a lifelong hunter I must comment on the debate on what causes the gamey taste in venison.It is actually the blood of the animal if not soaked properly that gives venison the gamey taste.I learned from my Mom as well as generations of hunters before me that soaking the meat for a few days in ice water only makes for ... |
22,827,278 | Based on [Efficiency of the search algorithm of KMP](http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm#Efficiency_of_the_search_algorithm),I really don't understand why the loop can execute at most 2n times.
The following is the pseudocode on wiki
```
algorithm kmp_search:
input:
a... | 2014/04/03 | [
"https://Stackoverflow.com/questions/22827278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2594180/"
] | `.` is used when accessing members of a struct using an object.
`->` is used when accessing members of a struct using a pointer.
so, `ptr->a = something;` is correct.
Also, you `free` something that you allocate. SO, instead of `free(ptr->a);` use `free(pt);`, since you allocated `ptr` not `ptr->a` | you have to use -> for both a and b
```
ptr->a = something;
ptr->b = 44;
```
To free you can use
```
free (ptr); /* since ptr is what we got from malloc() */
``` |
39,749,333 | I am using a ViewPager and have 3 Fragments in it.
I know that when the ViewPager loads for the first time it loads all the fragments by default ,
minimum is 3 fragments and viewpager executes all the lifecycle methods of fragments.
**Problems I noticed :**
* Whenever I swipe the viewpager the selected fragment doe... | 2016/09/28 | [
"https://Stackoverflow.com/questions/39749333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5201270/"
] | Use the following override method
```
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser && isResumed()) {
}
}
```
this will give you an option to call anything when the the user is currently viewing the... | This worked for me in my last project. I like this approach too because I don't have to do anything weird.
Essentially, in my adapter for the viewpager I added a method to keep track of the fragment tags & the associated position.
```
public class TabAdapter extends FragmentPagerAdapter {
private Map<Integer, Str... |
67,050,362 | I'm going back through Python Crash Course 2nd Edition for about the third time to cement my knowledge, & I've run into something interesting that I haven't actually accounted for in previous runs. When printing a lists length with the len() function, I realized I am not exactly sure how to perform this on a new line i... | 2021/04/11 | [
"https://Stackoverflow.com/questions/67050362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15191975/"
] | The `print()` function automatically ends with a newline character (`\n`).
Then
```
print("\n")
print(len(colleges))
```
Equals
```
\n\nlen(colleges)\n
```
To achieve what you need you can make use of the extra arguments of `print()`. Like so:
```
print('\n', len(colleges))
``` | You don't need the \n function. The len function automatically does this for you.
The reason why it does this is because all print statements automatically does this anyway. |
42,443,903 | I'm working on a small reusable Component which styles radio buttons and emits the selected values.
```
import { Component, OnInit, Input, Output, EventEmitter } from "@angular/core";
@Component({
moduleId: module.id,
selector: 'button-select',
template: `<div class="toggle-group">
<di... | 2017/02/24 | [
"https://Stackoverflow.com/questions/42443903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/114900/"
] | I think, you don't need this `[checked]="choice === defaultChoice"`. Try this :
```
<input type="radio"
id="{{ groupName + choice }}"
name="{{groupName}}"
[value]="choice"
[(ngModel)]="defaultChoice"
(ngModelChange)="choose($event)" />
```
When `[value] = [(ngModel)]` the radio is ... | ```js
export class ConfirmationmodalComponent implements OnInit {
client_notification: any = false;
candidate_notification: any = false;
cancel_associated_session: any = false;
constructor(
) {}
ngOnInit(): void {
}
}
```
```html
<div class="form-check form-check-inline">
<input
class="form-check... |
58,212,644 | I have a list of numbers (that will be changed weekly) and I also have a list of ranges (that also change weekly). I need to check whether each number falls between each range.
Eg. My list of numbers on the left and my list of ranges on the right.
```
4 1 3
10 67 99
54 ... | 2019/10/03 | [
"https://Stackoverflow.com/questions/58212644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12157182/"
] | If you want to appear full image use `:cover="true"` in `<v-img>`.
If you you want to appear the whole image, you can put follow CSS.
```
.v-image__image{
background-size:100% 100%;
}
```
This is not recommended way.Because image's ratio will be wrong. | Using pure HTML appears to even be simpler and better for me. The vuetify just complicate simple things sometimes. Use `v-col`, `div`, any block...
```
<v-row class="fill-height"
justify="center"
align="center"
style="background-image: url('card.imageUrlHiRes');
background-size: cover;" >
</v-ro... |
29,986,379 | I've been trying to figure-out how can i make the cell fill the width, as you can see in the picture the width between the cells is too big. i am using custom cell with only one imageView.

I tried to customize it from the storyboard but i guess ther... | 2015/05/01 | [
"https://Stackoverflow.com/questions/29986379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3989689/"
] | I have the same requirement, in my case below solution is worked. I set **UIImageView** top, left, bottom and right constraints to **0** inside **UICollectionviewCell**
```
@IBOutlet weak var imagesCollectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// flowlayout
let screen... | The best solution is to change the `itemSize` of your `UICollectionViewFlowLayout` in `viewDidLayoutSubviews`. That is where you can get the most accurate size of the `UICollectionView`. You don't need to call invalidate on your layout, that will be done for you already. |
34,952 | If you were going to write a chess game engine, what programming paradigm would you use (OOP, procedural, etc) and why whould you choose it ? By chess engine, I mean the portion of a program that evaluates the current board and decides the computer's next move.
I'm asking because I thought it might be fun to write a c... | 2011/01/08 | [
"https://softwareengineering.stackexchange.com/questions/34952",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/9830/"
] | Evaluation isn't a parallelizable problem as far as I know but evaluating different chains is , so I definitively would write it to make use of multiple cores and multithreading.
Whether you go functional or semi-functional is a matter of taste. Personally i'd go OOP and use the support for functional programming and ... | I ported a simple chess program as a means of learning the Forth language. It turned out to be a great fit to this very imperative problem, and I learned a lot. The open stack allowed me to implement alpha-beta search in a unique fashion which gave me greater insight into the algorithm.
One would think that functional... |
46,379,115 | ESLint: Line 403 exceeds the maximum line length of 120 (max-len)
I have a long string, which I built using ES6 template strings, but I want it to be without line breaks:
```
var string = `Let me be the 'throws Exception’ to your 'public static void
main (String[] args)’. I will accept whatever you giv... | 2017/09/23 | [
"https://Stackoverflow.com/questions/46379115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7707677/"
] | This is expected behaviour. One of the important problems that template literals solve is [multiline strings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Multi-line_strings):
>
> Any new line characters inserted in the source are part of the template literal.
>
>
>
If the s... | A good way of reaching your purpose is to to join an array of strings:
```
var string = [
`Let me be the 'throws Exception’ to your 'public static void`,
`main (String[] args)’. I will accept whatever you give me my ${love}.`
].join(' ');
``` |
24,341,589 | I am using python-docx with django to generate word documents.
Is there a way to use `add_picture` to add an image from the web rather then from the file system?
In word, when I select to add a picture, I can just give the URL.
I tried to simply so the same and write:
```
document.add_picture("http://icdn4.digitalt... | 2014/06/21 | [
"https://Stackoverflow.com/questions/24341589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1077102/"
] | Not very elegant, but i found a solution, based on the question in [here](https://stackoverflow.com/questions/22505922/python-elementtree-xml-ioerror-errno-22-invalid-mode-rb-or-filename)
my code now looks like that:
```
import urllib2, StringIO
image_from_url = urllib2.urlopen(url_value)
io_url = StringIO.StringIO()... | Below is a fresh implementation for Python 3:
```
from io import BytesIO
import requests
from docx import Document
from docx.shared import Inches
response = requests.get(your_image_url) # no need to add stream=True
# Access the response body as bytes
# then convert it to in-memory binary stream using `BytesIO` ... |
32,006,351 | I have a [Spring MVC](http://en.wikipedia.org/wiki/Spring_Framework#Model-view-controller_framework) project using [IntelliJ IDEA](http://en.wikipedia.org/wiki/IntelliJ_IDEA) 14 as my IDE (I'm new to IntelliJ IDEA; I used [Eclipse](http://en.wikipedia.org/wiki/Eclipse_%28software%29)).
My main Java code is in folder `... | 2015/08/14 | [
"https://Stackoverflow.com/questions/32006351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252933/"
] | In case you are using `Maven`, on the `View` > `Tool Windows` > `Maven Projects` click on the button shown below ( called `Skip Tests Mode`). Essentially it is taking the `test` phase out of the lifecycle when you say run `package`.
[](https://i.stack... | Even I faced this same issue as I have newly started using IntelliJ starting today. So I have trouble to find that logo in the screenshot shared in the post shared by `dimitrisli` and also accepted answer. Let me share my solution to this issue with latest IntelliJ version.
Open IntelliJ IDE, press `Ctrl + Alt + S`, t... |
7,991,303 | i have a disclaimer tick box on my login page and i want to make it so when its clicked it remains clicked the next time a person visits the site.
The site is javascript/jquery php based and onchange of the tick box is then written and stored in a database and can thus be retrieved, but i need to associate a user to t... | 2011/11/03 | [
"https://Stackoverflow.com/questions/7991303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/930584/"
] | The common and more basic way to do this is to write a cookie with the username and another with the hashed password. But i think you should write the cookies with PHP, JS is a client-side language so you can't hide your salt, for instance. | You need a cookie [plugin](http://plugins.jquery.com/project/Cookie) |
24,751,014 | When i am installing an extension in my magento admin,it shows `Connection string is empty`.
I don't know why this problem occurs. I cleared the cache also then also the problem is same.
If anyone knows how to do this,please help me out.
Thanks! | 2014/07/15 | [
"https://Stackoverflow.com/questions/24751014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3129737/"
] | There's a couple of suggestions to change the permissions to this:
>
> sudo chmod 777 -R /var/www/html
>
>
>
Which is a really really bad idea. Have a search for 'Magento permissions' and follow the guide instead. Unless you're seeking to get your site hacked wihin a few minutes. | Type the following command in your terminal.
`sudo chmod 777 -R /var/www/html/<magento folder name>`. Press Enter.
Then it will ask for password if exists for your username.
Once it is done, login and logout the admin and try to install extension which you want
Edited:
Try this for your files:
```
sudo chmod 7... |
74,150,425 | I have a list of data:
```
data = ['value', '"""', 'Comment 1st row', 'Comment 2nd row', 'Comment 3rd row', '"""', 'another value']
```
I would like to remove the whole comment from the list, including docstrings. Also not just once, but everytime a comment appears.
Could someone help? | 2022/10/21 | [
"https://Stackoverflow.com/questions/74150425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10155537/"
] | You can use a simple loop with a flag that alternates every time a `"""` is found:
```
data = ['value', '"""', 'Comment 1st row', 'Comment 2nd row',
'Comment 3rd row', '"""', 'another value']
flag = True
out = []
for v in data:
if v == '"""':
flag = not flag # invert the flag's boolean value
... | A counter-based approach. If the amount of `"""` is even then append (comments are balanced), instead increment the counter if odd (since comment hasn't finished).
```
res = []
c = 0
for char in data:
if char != '"""':
if not c % 2:
res.append(char)
else:
c += 1
print(res)
``` |
30,216,635 | What is happening:
------------------
1. I have a stacktrace from the appstore as below, problem i am facing
is that it dosen't show which class has caused this crash.
2. what i can understand is that its causing due to the assets that i
have used
3. Only place i am using assets is at the application level to set the
... | 2015/05/13 | [
"https://Stackoverflow.com/questions/30216635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1083093/"
] | Try to declare the font styles separately (not in the same line), as following,
change:
```
final Typeface bold = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Bold.ttf");
final Typeface italic = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Italic.ttf");
final Typeface boldItalic = Typeface.createFro... | Add context when calling,
It should be like this,-
```
final Typeface bold = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/OpenSans-Bold.ttf");
``` |
16,541,555 | I have two arrays as shown below. I need to merge the content of the arrays so that I can get the structure as shown in the third array at last. I have checked array\_merge but can't figure out the way this is possible. Any help appreciated. Thanks.
```
[
['gross_value' => '100', 'quantity' => '1'],
['gross_va... | 2013/05/14 | [
"https://Stackoverflow.com/questions/16541555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/324860/"
] | Use [array\_merge\_recursive](http://php.net/manual/en/function.array-merge-recursive.php) :
Convert all numeric key to strings, (make is associative array)
```
$result = array_merge_recursive($ar1, $ar2);
print_r($result);
```
See [live demo here](http://codepad.org/nBMErHku) | The problem with things like merge recursive is that they don't know when to stop.
In some scenarios you want to stop traversing down an array and simply take a given value if it exists.
For instance if you have to override a nested config array you might not want the default keys to stick around at a a specific leve... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.