INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Solving 4T(n/5) + log5(n * sqrt(n)) with the master theorem
I'm trying to solve the recursion 4T(n/5) + log5(n * sqrt(n)) with the master theorem but I've run into some difficulties.
I understand using the form T(n) = a T(n/b) + theta(n^k log^p n) would yield:
a = 4
b = 5
k = 0
but how would I deal with the n * sqrt n within the log? I cannot understand how to proceed. Thanks | `log(n * sqrt(n)) = log(n^{1.5}) = 1.5* log(n)`
thus your formula becomes `T(n) = 4T(n/5) + 1.5 * log5(n)` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "algorithm, math, recurrence, master theorem"
} |
how to sort varchar numeric columns by DESC or ASC?
I write ...
ORDER BY column ASC
but my column is `VARCHAR` and it sorts wrong like `1, 10, 2`, instead of `1, 2, 10`.
How can I do it to sort like `1, 2, 10`? | order by
cast(column as float)
Notes:
* Assumed you only have numbers in the columns. No "fish" or "bicycle"
* empty strings CAST to zero
Edit: For MySQL. You can not cast to float
order by
cast(column as decimal(38,10)) | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 2,
"tags": "mysql, sql order by, natural sort"
} |
создать из массива массив javascript
у меня get приходят данные; каждая данная data[i] выглядит вот так, а как получить например отдельно 30 или 28, то есть данные в данных после запятой?
[ 1517850000000,
'30',
'31',
'28',
'29',
'50',
1517853599999,
'5001',
400,
'40',
'20',
'0' ] | > data[i][1] === '30';
>
> data[i][3] === '28';
ты это имеешь ввиду? | stackexchange-ru_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js"
} |
KDB: select and round off each row
I created my own function of round off:
.q.rnd:{$[x < 0; -1; 1] * floor abs[x] + 0.5}
I have a table Test with a string column of COL
select "F"$(COL) from Test
24549.18741328
48939.50717263
-274853.33568872
-24549.18741328
298753.62574861
84822.70074144
-7468840.64371524
117944.21228603
-117944.21228603
7468840.64371524
-7468840.64371524
I want to derive a table that would round-off the records in Test
One would think that the statement below would work. But it does not.
select .q.rnd "F"$(COL) from Test
I get the error "type". So how do I round off the records? | The result if the if-else conditional must be an atomic boolean. When you run .q.rnd on a column, you are operating on a list and `x<0` is going to return a list of booleans, not an atom. The vector conditional is `?`
Nonetheless, it looks like you want a resulting integer/long anyway, so just use parse here
q)t:([]string (10?-1 1)*10?10000f)
q)select "F"$x from t
x
-------------------
4123.1701336801052
-9877.8444156050682
-3867.3530425876379
7267.8099689073861
4046.5459413826466
-8355.0649625249207
6427.3701561614871
-5830.2619284950197
1424.9352994374931
-9149.8820902779698
q)select "j"$"F"$x from t
x
-----
4123
-9878
-3867
7268
4047
-8355
6427
-5830
1425
-9150 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "kdb"
} |
Is there an way to load external swf into a sandbox in flash?
I'm loading flash ad-banners inside my all flash site with Loader. I have no control over the code inside the banners as they come from advertisers.
I'd like to load them so that there is no way they can mess up the mouse events on the site outside their limited area. Sloppy code on advertisers banner should not kill my site's functionality in any situation.
Bonus question, how can I solve the problems caused by the banners being a different frame rate than my main site? (Or is there an easy way to convert currently drawn animations into my frame rate while keeping the animation speed same as before?)
There must be people who have dealt with these issues before.
What's the best way to do this?
Thanks! | When you load the external swf, make sure it's loaded into a separate Security domain and into a child application domain. That way it won't be able to access stage Mouse and Keyboard events (and certain others), and there won't be any class definition conflicts.
Check out this document: Developing and loading subapplications | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "flash, actionscript 3, sandbox"
} |
What does a '&' stand for in a python bytearray
What does an ampersand `&` mean at the end of a python `bytearray`?
e.g.:
x_w = bytearray(b'\x00\x00\x04\x12\xaa\x12\x12&')
When converting this to an integer by
int.from_bytes(x_w, 'little')
Out[1]: 2743275644678045696
it gives a different result from the same bytearray without the '&':
x_wo = bytearray(b'\x00\x00\x04\x12\xaa\x12\x12')
int.from_bytes(x_wo, 'little')
Out[2]: 5087071236784128
I checked the documentation but haven't found an answer to this. Thanks! | It's simply the representation of the byte with value `26` (decimal 38), which is the `'&'` character in ASCII.
If you print the actual byte values of the bytes literal you used, you can see this clearly:
>>> print(' '.join('%02x' % b for b in b'\x00\x00\x04\x12\xaa\x12\x12&'))
00 00 04 12 aa 12 12 26
And the `repr` of the `bytearray` object prefers to represent bytes using ASCII characters rather than hex escapes whenever possible. So it will prefer the representation `'&'` rather than `'\x26'`, even though they are technically equivalent:
>>> bytearray([0x00, 0x00, 0x04, 0x12, 0xAA, 0x12, 0x12, 0x26])
bytearray(b'\x00\x00\x04\x12\xaa\x12\x12&')
>>> b'\x26' == b'&'
True | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "python, arrays, python 3.x"
} |
Why does Desura think it's already installed on my Mac?
When I go to Desura's site and click Download Desura, I get two options:
> Desura is installed
> Let's play!
>
> Install Desura
> For Windows
I've never been to the Desura site before. This machine is about 2 months old. I'm pretty certain Desura is not installed.
Clicking on "Let's play" does nothing. It's a link to `desura://refresh/`. I've tried running `open desura://refresh/` in the shell, and it appears that nothing on my machine recognizes the `desura:` URL scheme.
What makes Desura think that I have it installed already? How can I get the download URL? | Desura doesn't think you've installed it, it is offering you options how to proceed if it is installed or not - if you have the client installed you click the first button, if you don't you click the other button. There is no Desura client for OS X, but they do offer standalone OS X distributions through the site. | stackexchange-gaming | {
"answer_score": 0,
"question_score": 0,
"tags": "macos, desura"
} |
How should the "CDPATH" command be written in the .bashrc file?
I have a directory deep in folders (XAMPP) I'd like to `cd` into directly into.
I run this in the terminal: `CDPATH=/Applications/XAMPP/xamppfiles/htdocs/` And it works!
So if I want this to be permanent, I must add this same line to the `.bashrc` file. But adding the same line to my `.bashrc` file doesn't work.
My `.bashrc` file contains:
[ -n "$PS1" ] && source ~/.bash_profile
CDPATH=/Applications/XAMPP/xamppfiles/htdocs/
How should the line look like in the `.bashrc` file? Is mines wrong? I've tried putting `export` in front of `CDPATH` and also `$CDPATH:${HOME}/Applications/XAMPP/xamppfiles/htdocs` but neither works. | First be aware that CDPATH is considered first, hence you will not be able to easily change to a local directory if the other directory contains a directory with the same name. You will probably add an empty path in front, writing `CDPATH=:/Application/...`.
You should not need the `export` as this one is only relevant for you shell, not for commands run by your shell. The line as you wrote it should be fine.
Be aware that, depending how you start it, bash will read `~/.bashrc` or `~/.bash_profile`. Add an `echo` line in both to debug which file is evaluated in your context. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "bash, shell, command line, terminal, shortcut"
} |
"To be pound of something": Correct meaning and usage
I came across an email mentioning : "We are pound to announce that .. (some good announcement)". Initially I thought it was a spelling mistake and they meant "proud" and not "pound". However, when I Googled, I saw many webpages having similar usage of "pound".
I understand the meaning of "pound" as a verb is to strike or to hit. However, I don't understand what's the meaning to this phrase: "to be pound of something".
What does it mean exactly? (and whether it's a correct usage at all) | _Pound_ as a verb can also mean _to shut in, to trap_ , though the more common verb is _impound_.
However neither meaning of the verb _pound_ makes sense in this context. Looking at the first few results when I google "we are pound to", it is clear that the authors intended to write _proud_. As Rolf of Saxony says above,
> "perhaps there is some auto-text correction program that converts a misspelling of proud into the word pound and people don't notice".
There is also this interesting case, where it appears that automatic character recognition has misread "we are bound to receive" (i.e. we are obliged) in the original printed text as "we are pound to receive". | stackexchange-english | {
"answer_score": 2,
"question_score": 1,
"tags": "meaning in context, phrase usage"
} |
Can I install Ubuntu on my laptop?
I have a hp pavilion g6 laptop, it runs Windows 8.1. I was planning to use a free os for a while.
Which is the recommended Ubuntu version for me? I am totally a newbie to such OS.
I have only used windows till date. | The best you can do to find it out, it's to try it.
Download, burn and load from an ubuntu iso image. Instructions can be found here: How to create a bootable USB stick on Ubuntu
Also about installing it, you should read some little more documentation: Install Ubuntu 14.04.1 LTS and WindowsDualBoot manual
About the version, you definitely will want to go for ubuntu 14.04 64-bits. | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 1,
"tags": "windows, hp, hp pavilion"
} |
Did the Buddha die in absorption?
I thought I'd just ask here: did the Buddha die in absorption / any of the dhaynas? | From a Mahayana viewpoint, (1) a buddha constantly abides in a union of calm abiding and special insight on emptiness and varieties (2) Sakyamuni buddha was a supreme emanation body showing the aspect of dying. (3) a Buddha is not subject to death (hence he showed the aspect of dying).
Here, in a commentary to Maitreya’s Sublime Continuum, it says:
> While in meditative equipoise on emptiness with a nonconceptual mind the Buddha can also perform deeds in accordance with the needs, capacities, interests and merits of each disciple. The buddhas can teach each disciple in a specific way while remaining in meditative equipoise on emptiness. That is inconceivable for us. | stackexchange-buddhism | {
"answer_score": 1,
"question_score": 1,
"tags": "meditation, buddha"
} |
Push to an array from get:method
EDIT: Solved the question thanks to you. list() instead of list. Such a stupid question.
Why pushing to array in a factory like this doesn't work? It works only if I make a push function inside the factory.
var app = angular.module('app', []);
app.factory('registeredUsersService', function() {
var registeredUsers = [];
return {
list: function () {
return registeredUsers;
}
}
});
app.controller('registerController', function ($scope, registeredUsersService) {
registeredUsersService.list.push({username: 'a', password: 'b'});
}); | Try registeredUsersService.list() instead of registeredUsersService.list:
app.controller('registerController', function ($scope, registeredUsersService) {
registeredUsersService.list().push({username: 'a', password: 'b'});
});
BTW, i haven't test it. If not ok, please create a plnkr so i can help you | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "arrays, angularjs, push, factory"
} |
In Elasticsearch, why do I get an error message "Fielddata is disabled on text fields by default"
I'm trying to write a query to return unique cities. My code is:
GET /files/_doc/_search
{
"size":"0",
"aggs" : {
"uniq_cities" : {
"terms" : { "field" : "cities" }
}
}
}
I have an error message as follows:
> Fielddata is disabled on text fields by default. Set fielddata=true on [cities] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.
When I run
GET /files/_doc/_mapping
I get:
"cities" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
Based on the above, it seems that I already have a keyword field. How do I fix the error message? | The error says "Fielddata is disabled on text fields by default" because you are trying to apply aggregation on a text field `cities`. It also has a sub field `keyword` whose data type is `keyword`. Therefore, apply the aggregation on `cities.keyword` field as below:
GET /files/_doc/_search
{
"size":"0",
"aggs" : {
"uniq_cities" : {
"terms" : { "field" : "cities.keyword" }
}
}
} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "elasticsearch"
} |
Show all and only rows in table 1 not in table 2 (using multiple columns)
I have one table (Table1) that has several columns used in combination: Name, TestName, DevName, Dept. When each of these 4 columns have values, the record is inserted into Table2. I need to confirm that all of the records with existing values in each of these fields within Table1 were correctly copied into Table 2.
I have created a query for it:
SELECT DISTINCT wr.Name,wr.TestName, wr.DEVName ,wr.Dept
FROM table2 wr
where NOT EXISTS (
SELECT NULL
FROM TABLE1 ym
WHERE ym.Name = wr.Name
AND ym.TestName = wr. TestName
AND ym.DEVName = wr.DEVName
AND ym. Dept = wr. Dept
)
My counts are not adding up, so I believe that this is incorrect. Can you advise me on the best way to write this query for my needs? | You can use the `EXCEPT` set operator for this one if the table definitions are identical.
SELECT DISTINCT ym.Name, ym.TestName, ym.DEVName, ym.Dept
FROM table1 ym
EXCEPT
SELECT DISTINCT wr.Name, wr.TestName, wr.DEVName, wr.Dept
FROM table2 wr
This returns distinct rows from the first table where there is not a match in the second table. Read more about `EXCEPT` and `INTERSECT` here: < | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sql server"
} |
Where should code signing be placed in the build/publish process?
I've only recently come into the pleasure of being able to sign executables. Now I'm trying to establish a proper place in our build/publish process where assemblies should be signed.
My first instinct was to sign as early as possible (in a post-build event) to make sure what is being signed is what the builder intended it to be.
But this would (in our case) require every developer to have full access to the private key, which might be undesirable.
The other idea would be to only sign if we're publishing, so that signing is performed rarely and by a small amount of people. But is that _too late_?
Does a best practice exist? | Delay Signing an Assembly:
> An organization can have a closely guarded key pair that developers do not have access to on a daily basis. The public key is often available, but access to the private key is restricted to only a few individuals. When developing assemblies with strong names, each assembly that references the strong-named target assembly contains the token of the public key used to give the target assembly a strong name. This requires that the public key be available during the development process.
>
> You can use delayed or partial signing at build time to reserve space in the portable executable (PE) file for the strong name signature, but defer the actual signing until some later stage (typically just before shipping the assembly). | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "c#, visual studio 2010, build process, code signing, post build event"
} |
Does the battery last longer if you unplug it when on power?
> **Possible Duplicate:**
> Is it better to use a laptop on battery or on AC power?
Is this true (For Dell laptops) ? | For what I know the answer is **yes** , it's always good to unplug battery when your laptop has power cable attached on it | stackexchange-superuser | {
"answer_score": 0,
"question_score": 1,
"tags": "windows 7, laptop, power supply, battery"
} |
Form input type time clear event in jQuery
When I click the little "X" in an input form field of type "time" I want to fire an event.
I tried the click event but it does not work. It seems like the "X" is an element above the input field. It triggers when clicking inside it somewhere else.
.click(function() {
console.log( "Clear has been clicked" );
});
How can I fire an event on input "X" (clear)? | Try with `input` event:
$( "input" ).on('input', function() {
console.log( "Clear has been clicked" );
}); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "javascript, jquery, events, input, time"
} |
$L^2(a_1,b_1;H_0^1(a_2,b_2))\subset L^2(a_1,b_1;L^2(a_2,b_2))$ and Convergence
Let $[a_1,b_1]\times[a_2,b_2]\subset\mathbb{R}^2$. Suppose $$u_n\rightharpoonup u\,\,\,\text{ weakly in } L^2(a_1,b_1;L^2(a_2,b_2))$$ and $$\\{u_n\\}\text{ is bounded in }L^2(a_1,b_1;H_0^1(a_2,b_2)).$$ Can we conclude $$u_n\rightharpoonup u\,\,\,\text{ weakly in } L^2(a_1,b_1;H_0^1(a_2,b_2))$$ and why?
**Notation:**
$\bullet\,\,\, L^p(\Omega;X)=\left\\{u:x\in\Omega\to u(x)\in X\,\big|\,\displaystyle\int_\Omega\|u(x)\|^p_{X}\,dx<\infty\right\\}$
$\bullet\,\,\, f_n\rightharpoonup f$ weakly in $E$ if $\langle \phi,f_n\rangle_{E',E}\to\langle\phi,f\rangle_{E',E}$ for all $\phi\in E'$, where $E'$ denotes the dual of Banach space $E$ | Yes. We have that $u_n \rightharpoonup w$ in $L^2(H^1_0)$ for some $w$ since $u_n$ is bounded uniformly in that space. Now to identify $w$ as $u$ simply pass to the limit in the integration by parts identity equation $$(u_n, \partial_{x_i} \varphi)_{L^2(L^2)} = -(\partial_{x_i} u_n, \varphi)_{L^2(L^2)}$$ where $\varphi(x,t) = \psi(t) \phi(x)$ with $\psi \in C_c^\infty(a_1,b_1)$ and $\phi \in C_c^\infty(a_2,b_2)$, and then use the Reymond du-Bois lemma. | stackexchange-math | {
"answer_score": 0,
"question_score": 1,
"tags": "functional analysis, partial differential equations"
} |
On existence of analytic continuations
Suppose $f \in H(U)$ for some open disk $U.$ Let $V \subseteq\mathbb{C}$ be the set of all points $p$ for which there exists some curve $\gamma : [0,1]\rightarrow\mathbb{C}$ with $\gamma(0) \in U$ and $\gamma(1) = p,$ so that we can analytically continue $f$ along the curve $\gamma.$
It seems plausible to me that if $\rho : [0,1]\rightarrow\mathbb{C}$ is any curve whose image $\rho([0,1])$ is contained entirely inside $V,$ then I ought to be able to analytically continue $f$ along $\rho.$ This works in all the examples I can think of. However, I see no way to prove it in general and was wondering if it's still true. | It's false.
Let $U = \\{ z \in \mathbb{C} : \mathrm{Re}(z) > 0 \\}$ and consider $f : U \to \mathbb{C}$ defined as $f(z) = \sqrt{1+\sqrt{z}}$, where each $\sqrt{\cdot}$ means the principal square root. It's not hard to see that $V = \mathbb{C} \setminus \\{ 0 \\}$ as the only problem could be at $z = 1$ and this point already belongs to $U$. But it is impossible to analytically continue $f$ along $\gamma(t) = e^{2 \pi i t}$ because after the full turn $\sqrt{z}$ becomes $-1$ and $\sqrt{1+u}$ has no continuation through $u = -1$. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "complex analysis"
} |
php insert mysql_query get id
In PHP 4, how can I easily get the last `id` after an `insert` in db? For example:
$queryInsert = "INSERT INTO `table` (`id`, `info`) VALUES (NULL, '".$INFO_VAR."');";
mysql_query($queryInsert) or die (mysql_error()); | use `mysql_insert_id();`, you find the doc here | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, html, mysql"
} |
Launching a URL from an Eclipse plugin
I'd like to have my Eclipse plugin cause a URL to be opened by the users' default browser. This seems like pretty standard behavior, but I haven't been able to find any docs on how to do this.
Can anyone help? | You are looking for:
final IWebBrowser browser = PlatformUI.getWorkbench().getBrowserSupport().createBrowser( ... );
browser.openURL(url); | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 8,
"tags": "java, eclipse, eclipse plugin"
} |
DBMSs’ ACIDity in POSIX or UNIX-Like OSs
How can DBMSs guarantee ACIDity in UNIX-Like OSs when locks on files, which are the means of data persistence, are only advisory? How do they achieve immunity to uncooperative processes that can temper the files freely? | The ACID properties are guaranteed only when you access the RDBMS through its proper API. If you do something to the data behind the back of the DB engine, all bets are off. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "database, unix, file io, locking, posix"
} |
Ignore backspace key from stdin
I want to make a program that forces it's user to input text but doesn't allow him to erase any of it, what's a simple way of doing it in C?
The only thing I've got is `(c = getchar()) != EOF && c != '\b'` which doesn't work. Any ideas? | POSIX - unix version
#include <sys/types.h>
#include <termios.h>
#include <stdio.h>
#include <string.h>
int
main()
{
int fd=fileno(stdin);
struct termios oldtio,newtio;
tcgetattr(fd,&oldtio); /* save current settings */
memcpy(&newtio, &oldtio, sizeof(oldtio));
newtio.c_lflag = ICANON;
newtio.c_cc[VERASE] = 0; /* turn off del */
tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&newtio);
/* process user input here */
tcsetattr(fd,TCSANOW,&oldtio); /* restore setting */
return 0;
} | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 5,
"tags": "c, stdin, backspace"
} |
How to run celery workers by superuser?
When I run celery workers with sudo, i get the following error:
Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=0 euid=0 gid=0 egid=0
also my **C_FORCE_ROOT** environment variable is **true** :
echo $C_FORCE_ROOT
true
More information:
Python --> 2.7.6
celery --> 3.1.23 (Cipater)
OS --> Linux(Ubuntu 14.04)
How should I run celery with sudo? I know it's not secure but for some reasons I really need to do it! | OK I found the solution!
In celery 3.1 and above, workers with pickle serialization will crash as mentioned in documentation:
> Worker will now crash if running as the root user with pickle enabled.
So to use sudo, you need to disable pickle serialization in celery configs.I did it by using json:
app.conf.update(
CELERY_ACCEPT_CONTENT = ['json'],
CELERY_TASK_SERIALIZER = 'json',
CELERY_RESULT_SERIALIZER = 'json',
)
and then if you run using sudo, it will work! | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 2,
"tags": "python, linux, celery"
} |
How to use Java 7+ 'Objects.hash()' with arrays?
I really like Java 7+ style of writing `hashCode()` method:
@Override
public int hashCode() {
Objects.hash(field1, field2);
}
It doesn't work correctly with arrays though. The following code:
@Override
public int hashCode() {
Objects.hash(field1, field2, array1, array2);
}
will not work, as for `array1` and `array2` regular `hashCode()` instead of `Arrays.hashCode()` would be invoked.
How can I use `Objects.hash()` with arrays in a proper way? | You could try:
Objects.hash(field1, field2, Arrays.hashCode(array1), Arrays.hashCode(array2));
This is the same as creating one array that contains `field1`, `field2`, the contents of `array1` and the contents of `array2`. Then computing `Arrays.hashCode` on this array. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 13,
"tags": "java, arrays, java 7, hashcode"
} |
Possible value for $f(\frac{1}{2})$ for some function $f:\mathbb{D}\to\mathbb{D}$
> **Q.20.**source) Let $\mathbb{D} = \\{z \in \mathbb{C} : \left| z \right| < 1\\}$ be the open unit disc and let $f : \mathbb{D} \to \mathbb{D}$ be a holomorphic function. Suppose that $f(0) = 0$ and $f^\prime(0) = 0$. Which of the followings are possible values of $f\left(\frac{1}{2}\right)$?
>
> 1. $1/4$
> 2. $-1/4$
> 3. $1/3$
> 4. $-1/3$
>
Here I know that 1, 2 are correct if we choose $f(z)=z^2$ and $f(z)=-z^2$. Please give some hint for options 3 and 4. | The answers $3$ and $4$ are not correct.
Since $\;f(0)=f^\prime(0)=0\;,\;$ there exists a holomorphic function $\;g:\mathbb{D}\to\mathbb{C}\;$ such that
$f(z)=z^2g(z)\quad\forall\;z\in\mathbb{D}\;.$
If $\;|z|=r<1\;,\;$ then $\;|g(z)|=\dfrac{|f(z)|}{|z|^2}<\dfrac{1}{r^2}\;,$
and, by the maximum modulus principle, it follows that
$|g(z)|<\dfrac{1}{r^2}\quad$ for all $\;z\in\mathbb{C}\;$ such that $\;|z|\le r<1\;.$
As $\;r\to1\;,\;$ we get that
$|g(z)|\le1\;$ for all $\;z\in\mathbb{C}\;$ such that $\;|z|<1\;,$
hence,
$|f(z)|=|z|^2|g(z)|\le|z|^2\;$ for all $\;z\in\mathbb{C}\land|z|<1\;,$
consequently,
$\left|f\left(\frac12\right)\right|\le\frac14\;.$ | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "complex analysis"
} |
disable the window function in jsf/primefaces
<p:commandButton id="cmdCancel" value="#{label.cancel}" action="cancel"/>
<p:hotkey bind="Alt+C" action="cancel" />
Hi , I have one button cancel and i binded it to short cut key "Alt+C" (refer above code) in prime faces.
And when i use press short cut key "Alt+C", it perform the cancel action and but it also open the browser favorites menu on pressing the "Alt+C".
How can i stop this opening browser operation?Please suggest me any solution,....... | I guess that you simply can not override some of the browser's hardwired default hotkeys. Think of pressing Alt+F4 to close the browser window etc.
Even the normal HTML hotkey attribute is not guaranteed to work if the browser already does something else when pressing the hotkey combination.
My answer is thus; Do not rely on hotkeys in a website to work at all. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jsf, primefaces"
} |
Write a query to display the student names and the maximum mark scored by them in any subject
I have tried using group by and getting an error message of single row function cannot return multiple values.
It has three tables to be selected student, subject and mark.
!enter image description here | If you only required student_id and MAX number, you can use only tables Student and Marks as below-
SELECT A.stident_id,MAX(B.Value) max_marks
FROM Student A
INNER JOIN Mark B ON A.Student_id = B.Student_id
GROUP BY A.stident_id
But if you need subject name as well, you can try this below logic-
SELECT AA.stident_id,AA.stident_name,
D.Subject_name,AA.max_marks
FROM
(
SELECT A.stident_id,A.stident_name,MAX(B.Value) max_marks
FROM Student A
INNER JOIN Mark B ON A.Student_id = B.Student_id
GROUP BY A.stident_id
)AA
INNER JOIN Marks C ON AA.stident_id = C.stident_id
AND AA.max_marks = C.Value
INNER JOIN Subject D ON C.subject_id = D.subject_id | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "sql, inner join"
} |
Replace a regex pattern in a string with a replacement string dependant on the match
I have a special string which contains variables. Any word that begins with an "@" symbol is a variable in this string.
Example _foostring_ :
> This is my string and this is a @variable in it. Example, @hello is another variable
I want to carry out an operation that replaces any general variable **@-variable-** in such special strings with **%-variable-%**.
So the Example _foostring_ string above will become so (after this operation):
> This is my string and this is a %variable% in it. Example, %hello% is another variable
Question: How to carry out this operation using Regular expressions? | In Javascript:
var repl = str.replace(/@(\w+)/g, '%$1%');
In Java:
String repl = str.replaceAll("@(\\w+)", "%$1%");
In python, for completeness' sake
import re
repl = re.sub(r'@(\w+)', r'%\1%', strng) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "java, javascript, python, regex"
} |
Assign Raster band to variable name in Loop - "can't assign" error
I want to write two nested loops that iterate over the RGB bands of a series of eight JPG images. Later on these images shall be combined into one array channel by channel, so each array of the channels first has to have a proper name:
for ColorBand in [1, 2, 3]:
for eighth in range(0,8):
rastername="20140525-16-20-00_full_"+str(eighth)+"_0.jpg"
raster =gdal.Open(rastername)
band = raster.GetRasterBand(ColorBand)
"eighth_"+str(eighth)+"_"+ColorBand = band.ReadAsArray()
Unfortunately, this returns a "can't assign to function call" error. I couldn't really find a proper answer how to solve this in other questions. Can anyone help? | The error is in the line:
"eighth_"+str(eighth)+"_"+ColorBand = band.ReadAsArray()
It appears that you are trying to create a variable name and assign to it the result of `band.ReadAsArray()`.
You could create a dictionary, say `color_dict` and make `"eighth_"+str(eighth)+"_"+ColorBand` as the key and use it to assign the value of `band.ReadAsArray()`. i.e.,
color_dict = {}
color_dict["eighth_"+str(eighth)+"_"+ColorBand] = band.ReadAsArray()
Later in your code you can access this data as `color_dict["eighth_"+str(eighth)+"_"+ColorBand]` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, function, loops"
} |
Asp.Net Mvc - does onactionexecuted get called before or after ActionResult.Execute?
Does `Controller.OnActionExecuted` get called before or after `ActionResult.Execute`?
Is there a timeline somewhere of the order in which events occur? I can't find anything with google-fu alone. | The Controller.OnActionExecuted gets called first.
See this post on MSDN, it covers the controller pipeline for MVC.
> 1. Receive first request for the application
> 2. Perform routing
> 3. Create MVC request handler
> 4. Create controller
> 5. Execute controller
> 6. Invoke action
> 7. Execute result
> | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 8,
"tags": "asp.net mvc"
} |
Center of mass for 2d surface
This is a rather simple problem, yet i had a hard time understanding the results (if they are correct).
The problem: calculate mass of a quarter of a circle in the positive quadrant in $\mathbb{R}^2$ with radius $a$, where the density is given by $\rho(x,y)=y$, and find the center of mass.
I calculated the required mass using double integral and using polar coordinates ($0\leq r \leq a, 0 \leq \theta \leq \frac{\pi}{4}$), and got:
Mass = $\frac{a^3}{3}$
Center = $(1,\frac{\pi}{4})$ **(i.e, constant and independent of the radius)**
It didn't made sense to me that the center stays the same.
Thanks | $$x=r\cos\theta$$
$$y=r\sin\theta$$
$$\bar{x}=\frac{1}{m}\iint x\rho(x,y)dA=\frac{1}{m}\int_0^{\pi/2}\int_0^ar^3\cos\theta\sin\theta drd\theta$$
Likewise
$$\bar{y}=\frac{1}{m}\iint y\rho(x,y)dA=\frac{1}{m}\int_0^{\pi/2}\int_0^a r^3\sin^2\theta drd\theta$$
So the $a$ terms do not cancel in the center of mass because the $r$ term is already cubed before integration. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "integration, multivariable calculus"
} |
is there a command line equivalent to git mergetool.--keepBackup global config
Rather than having to set it up in the global config (which is an issue when it comes to developers sharing repositories) it'd be nice to do this automatically in our scripts, but `git mergetool --help` doesn't come up with anything. | You can pass any configuration variable to `git` using the `-c` option, e.g.:
git -c mergetool.keepBackup=false mergetool
should run `git mergetool` with `mergetool.keepBackup` set to `false`.
That's a bit long, so you may want to alias this, e.g.
alias.mt '!git -c mergetool.keepBackup=false mergetool'
alias.mtk '!git -c mergetool.keepBackup=true mergetool'
in the appropriate config file. Then `git mt` and `git mtk` should run `git mergetool` with `keepBackup` set to `false` and `true` respectively. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "git, git merge"
} |
SOAP version in Envelope from code generated by WSDL
I'm working on a solution with a service generated by WSDL. When I call the service I get a Bad Request-Error. I've enabled tracing and the message sent has the following envelope:
<s:Envelope xmlns:a=" xmlns:s="
When I try to use cURL I get an error saying "InputStream does not represent a valid SOAP 1.1 Message" and of course works perfectly fine when I change xmlns:s to use SOAP version 1.1.
In the WSDL the binding is:
<soap:binding transport=" />
which as, from what I've found, SOAP 1.1.
How can I modify the WSDL or the generated code to send the message with correct SOAP version? | All there was to it was to add textMessageEncoding in the binding
<customBinding>
<binding name="wsHttpEndpointBinding">
<textMessageEncoding messageVersion="Soap11" /> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, web services, soap, wsdl"
} |
How do you know that $\frac{dE( x) }{dp}=0$?
I have the following problem:
> Suppose that two teams play a series of games that end when one of them has won $i$ games. Suppose that each game played is, independently, won by team $A$ with probability $p$. Find the expected number of games that are played when $i=2$. Also show that this number is maximized when $p=\frac12$.
Here is the solution:
 }{dp}=0$? | Usually you find critical point x of a differentiable function when you set the derivative equal to zero. You want to find the maximum of $\mathbb E(X)$. When you solve the equation $\frac{d \mathbb E(X)}{dp}=0$ you get the $p$-value of a critical point ( _saddle point, relative maximum, relative minimum_ ). Let´s call it $p^*$. Now you have to evaluate if this is a relative maximum.
If $\frac{d \mathbb E^2(X)}{dp^2}(p^*)<0$ you have found the relative maximum. Since $\lim\limits_{p \to \infty} \mathbb E(X)=\lim\limits_{p \to -\infty} \mathbb E(X)=-\infty$ the relative maximum is an absolute maximum. | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "probability, expected value"
} |
Can I read Pdf file without downloading it on Local Machine with Selenium or other C# Libraries
I want to read pdf data in String or in stream object without downloading it on local machine through some C# library. Currently I am working on a Automation project where I am using Selenium-chromewebdriver Please suggest a C# Library from which I can achieve this task. | In order to use this solution in your projects, you need to do the following steps:
Add references to itextsharp.dll and SharpZiplib.dll
Add the PDFParser.cs class to your project
Then you can use the newly added class in the following way:
// create an instance of the pdfparser class
PDFParser pdfParser = new PDFParser();
// extract the text
String result = pdfParser.ExtractText(pdfFile);
Using iTextSharp's PdfReader class to extract the deflated content of every page, I use a simple function ExtractTextFromPDFBytes to extract the text contents from the deflated page. | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": -1,
"tags": "c#, selenium, pdf, automation, selenium chromedriver"
} |
How to add images webservice?
I have a web-service which accepts image data.Anyone guide me how do I sent image file which I have captured from my phone to the services on a button click?. I searched the smartface docs and also the website I got an idea of uploading to a Web-client but didn't find anything of how to upload data to SOAP services.
Thanks. | I don't know what kind of data does your webservice except.
If you are using capture function of camare, you will be able to reach the path of photo. <
Also, you can save the captured photo, and use it by the name you gived. <
If these documents don't help, can you share the url of service in order for me to check it? | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -4,
"tags": "smartface.io"
} |
What is the 'd' in the literal 12d called?
I feel like I should know the answer to this, but I don't.
What is the type character on a numeric literal called?
double myDouble = 12d;
float myFloat = 10f;
I wanted to find a complete list of them today, but couldn't come up with what to ask Google to search for.
## EDIT
Found a decent list if anyone is interested
< | I don't know if there is an official term but the C# language spec commonly refers to them as type suffixes. | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 10,
"tags": "c#, terminology, numbers, literals"
} |
Could accessing array element outside boundary corrupt it
Is it possible that accessing an array outside its boundary corrupt its existing elements
MyObject* array[10];
for(int i=0; i<10; i++)
{
array[i] = nullptr;
}
array[1] = new MyObject();
array[8] = new MyObject();
array[15] = new MyObject();
could accessing array[15] result in the corruption of the elements between 0-10? | > could accessing `array[15]` result in the corruption of the elements between 0-10?
Yes. This is undefined behavior, and the nature of UB is that _anything_ can happen. In particular, it usually doesn't make much sense to reason about what _could_ happen or what is more likely to happen. It can be anything, including the corruption of some array elements that were intact before UB. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 5,
"tags": "c++, arrays, undefined behavior"
} |
The package is of bad quality - google chrome
> **Possible Duplicate:**
> What is a “bad quality” package?
I'm doing a fresh install of 12.10 and am trying to install Google Chrome. I've downloaded the deb from < and am installing it through the Ubuntu Software Centre.
I'm getting a message:
The package is of bad quality
(same as What is a "bad quality" package?)
In the expanded section, the "error" states:
E: google-chrome-stable: file-in-etc-not-marked-as-conffile etc/cron.daily/google-chrome
Is it safe to click on the "Ignore and Install" button? | You get such kind of errors when Ubuntu doesn't trust the package your are installing. This was a known bug and fix has been released for the same.
You can safely click on **Ignore and install** (Do this only when you trust the package) and the other alternate way is to install the package via command line using
sudo dpkg -i deb_package_name.deb
But make sure you have the dependencies installed for a clean installation. | stackexchange-askubuntu | {
"answer_score": 7,
"question_score": 11,
"tags": "installation, google chrome"
} |
How to get the files within a directory using a date range?
The possible solution I've thought of is like this:
var dateFiles = Directory.GetFiles(filesPath)
.Where(x => new FileInfo(x).CreationTime.Date >= startDate &&
new FileInfo(x).CreationTime.Date <= endDate);
I'm new to the `=>` syntax and I'm not sure how to put `new FileInfo(x).CreationTime.Date` into a _variable_ so I don't have to initialize it _twice_. Also, let me know if there's a more optimal solution. Thanks a lot. | Let's add `Select` where we turn `fileName` into an _anonymous type_ instance in which we can store _both_ `name` and `date`:
var dateFiles = Directory
.EnumerateFiles(filesPath)
.Select(fileName => new { // given fileName
name = fileName, // store name
date = new FileInfo(fileName).CreationTime.Date // ... and date
})
.Where(file => file.date >= startDate && // filter by date
file.date <= endDate)
.Select(file => file.name); // finally, we want name only
Please, notice `EnumerateFiles`: we don't want to wait whne all the files be collected but ready to process file after file. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "c#"
} |
How can I count the number of occurrences of a range of values in one column, against all unique values in another, in MySQL?
I have a table with any number of duplicates in the brand column, with a limited number of options in the size column:
Item Brand Size
1 BiGNRG AA
2 LongLife AAA
3 LongLife AAA
4 BiGNRG AA
5 LongLife D
6 EcoBatt C
7 BiGNRG AAA
8 BiGNRG AA
9 EcoBatt C
I need an SQL query to convert that information to this:
Brand AA AAA C D
BiGNRG 3 1 0 0
EcoBatt 0 0 2 0
LongLife 0 2 0 1
I cannot figure out how to convert this data into this format. | if the number of the option is limited you could try using an group by un select union all
select brand, count(AA) AA, count(AAA) AAA, count(C) C, count(D) D
from (
select Brand, 'AA' AA , NULL AAA, NULL C , NULL D
from my_table
where size ='AA'
union ALL
select Brand, null , 'AAA' , NULL , NULL
from my_table
where size ='AAA'
union ALL
select Brand, null , null , 'C' , NULL
from my_table
where size ='C'
union ALL
select Brand, null , null , null, 'D'
from my_table
where size ='D'
) T
group by brand | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "mysql, count, multiple columns"
} |
Using typedefs appropriately to avoid "typedef contamination"
I'm developing certain features for a larger encompassing project and the "features" I'm working on are some classes put together from which certain functions might be used globally in the main project.
For readability, I've typedef some common (and lengthy) types at my side to be used across my classes. Since most of these types are relatively common and likely used with other meanings, I don't want my typedefs to spill into the main project where different typedefs might be used.
What is then the best approach to ensure my typedefs are "cleanly" defined and not "contaminating" (I'm not sure if this term is used for typedefs too) the project's general typedef pool?
I've so far only had idea of making the typedefs private for each class and essentially redefining typedefs across my classes. Doesn't sound too good I suppose? | * You can limit related `typedef`'s in namespaces.
* You can put the `typedef`'s being used in just 1 class into that class.
* If a typedef is used in just few files, add the typedef in `.cpp` file. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "c++, typedef"
} |
How to correctly do maths with higher numbers in PHP
I am trying to display the total amount which is product price times quantity.
This works perfectly for numbers under 1000, but above that a dot is added and my script breaks. How can I fix that?
I have these numbers:
150,00
1.200,00
They are looped with variable `$price`.
I then replace all commas for dots like this:
$subtotalreken = str_replace(',','.',$price);
`$subtotalreken then contains`:
150.00
1.200.00
I then multiply this with the quantity amount like this:
$totalfinal = $subtotalreken * $cart['quantity'];
The quantity is 2 for both products, and if I echo `$totalfinal`, this is my result:
300
2.4
Why is it 2.4? And not 2.400?
I need the european/dutch format, so dots for every three numbers and cents after the comma. How can I do that? | Before calculations remove any formatting from your number (just make sure you always have 2 decimal places number):
$number = preg_replace('/[^\d]/', '', $input);
Then do your calculations (number is in cents) and show to user formatted number:
echo number_format($number * $qunatity / 100, '.', ',', 2); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "php, math"
} |
Passing Complex JavaScript Object to WCF using JQuery
I have a FireFox browser plugin that is devloped in C++, that connects to a Scanner and retrievs data
When a user clicks on a button on a Web Page (Developed in ASP.net AJAX 3.5) it retrieves data from the scanner by JavaScript and sends to the WCF service (RESTful WCF and accepts JSON message format)
Question is C++ Object that passed backto the browser using JQuery (when button is clicked) object is complex and does not match remove WCF service (which only accepts a custom object as input; one parameter only)
Question
Do I need to reconstruct (tore it apart in JQuery and match its structure to remote WCF service and use JSON.Stringfy() with JQuery AJAX in order to pass) object that was passed from C++ browser plugin to the WCF?
Can object be passed between JQuery and remote WCF if both have different properties? | You can't pass the object if it has different properties. You have to transform it (in javascript) to match the format WCF expects. If it's an array or property names must be changed, jquery's `$.map` could help you.
But, you don't need JSON.stringify, cause jquery's `$.ajax` encodes objects for you. For example in:
$.ajax({
url: "url_of_wcf_service",
data: your_object
});
`your object` will be automatically encoded. The only case you'd use JSON.stringify is if your WCF explicitly receives a json string (but i don't think it's the case), so you'd do:
$.ajax({
url: "url_of_wcf_service",
data: JSON.stringify(your_object)
});
Hope this helps. Cheers | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery"
} |
Can we start from the restriction, and continue with the normal function?
Suppose that we have the field automorphism $\phi :C\rightarrow C$ with $\phi (a)=b$.
When we consider the restriction $\phi|_K :K\rightarrow C$, and we have that $a^n\in K$, do we have the following? $$\phi|_K (a^n)=\phi|_K (a\cdot a \cdot \ldots \cdot a)=\phi (a)\cdot \phi (a)\cdot \ldots \cdot \phi (a)=b\cdot b\cdot \ldots \cdot b=b^n\in K$$
Or can we not start from the restriction at K, and continue with the normal function $\phi$ ? | All of the equalities that you wrote are true except the last one. We do not necessarily have $b^n\in K$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "abstract algebra, functions, field theory"
} |
PHP remove quotes around DOMText
I'm trying to append some HTML to the end of the body with PHP. I'm using a DOMText object and appending it like so:
$js = new DOMText("<script type='text/javascript'>\njson='".$response."';alert(json);</script>");
$bodyTags = $indexDOM->getElementsByTagName('body');
$bodyTags->item(0)->appendChild($js);
The problem is that the HTML I'm appending is being surrounded by quotation marks. Is there any way to remove those quotation marks or an alternative way that doesn't surround the text with quotes? | I guess you should be using
`DOMNode` < or
`DOMElement` <
to get the job done.
**EDIT**
Example:
$bodyTags = $doc->getElementsByTagName('body');
$newEl = $doc->createElement('script');
$newEl->setAttribute('type', 'text/javascript');
$response = "{'fname':'stackoverflow'}";
$js = new DOMText("json=\"".$response."\";alert(json);");
$newEl->appendChild($js);
$bodyTags->item(0)->appendChild($newEl);
There are several ways of achieving this. this is just an example. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, html"
} |
Does the phrase "$y$ depends on $x$" usually mean $y=f(x)$ for some function $f$?
While I have asked my colleagues this question I came up with while writing a paper, I wanted to ask here as well:
Given two variables $x$ and $y$, can we assume that the phrase "$y$ depends on $x$" usually means $y=f(x)$ for some function $f$?
Any feedback is welcome, thank you for your time. | Thank you to all who contributed in the comments, here is an answer - consisting of those comments - to close this question:
In conclusion, I wouldn't write "$y$ depends on $x$" and assume the reader knows I mean $y = f(x)$ without already writing $y=f(x)$ first. Additionally, if you say "$y$ depends on $x$" first without further context a few things should be accounted for:
1. (as lulu states): "Writing it that way suggests an _explicit_ form, though of course you might only have an _implicit_ dependence..."
2. (as Thomas Andrews states): "...of course, it could mean that $x$ is but one of many, $y = f(x,u,v,w)$."
Note for point 2): Given $y = f(x,u,v,w)$ one could say "$y$ depends on $x$" to emphasize this particular dependence in a situation without having to state each variable $y$ depends on. However, in situations where it might be misleading we could elaborate and say something like "$y$ depends on $x$, _among other factors_ " (lulu). | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "calculus, algebra precalculus, terminology"
} |
How to treat region between conflict markers as comment?
While resolving complex conflicts manually, I usually want emacs to treat conflict markers and region between them as comment, since it breaks major-mode's syntactic analysis (fontification, electric-indent, etc) :
<<<<<<< HEAD <- comment
aaa
bbb
======= <- comment
ccc <- comment
>>>>>>> brabrabrabra <- comment
It seems possible to visually highlight them as comment with search-based fontification, but is it possible to treat them as comment not just visually but also syntactically ? | Yes, it's possible, but AFAIK noone has written the corresponding code. This would need to be done via the `syntax-propertize-function`, to place appropriate `syntax-table` properties at the appropriate places.
It might be somewhat tricky to handle all cases, tho, such as when the conflict markers are within strings or comments. But it's definitely worth a try and I'd welcome a patch to `smerge-mode` to provide that functionality. | stackexchange-emacs | {
"answer_score": 1,
"question_score": 3,
"tags": "comment, syntax"
} |
How does Dreamhost Restrict User Accounts?
Browsing around my shared hosting account on Dreamhost, I noticed that I could not create users if the name is already taken. I can cd /home/username if I created the username, but I can't cd /home/username if the username is not one I created. I can't even begin to explain what is going on with the enhanced security box enabled.
Can anyone possibly explain what Dreamhost does to get this level of security?
Thanks! | Most likely, all the users you create are in the same group. Every other user is in a different group then you. With some trivial filesystem permissions, you would get exactly the behavior indicated. I'm actually rather surprised they let you create users in the first place. | stackexchange-serverfault | {
"answer_score": 0,
"question_score": 0,
"tags": "security, hosting, users, dreamhost"
} |
There are three red and two yellow balls inside an urn. Players A and B select balls from the urn without replacement until a yellow ball is selected.
There are three red and two yellow balls inside an urn. Players A and B select balls from the urn without replacement until a yellow ball is selected. Assume that player A selects first. Find the probability that the final selection is made by player B.
The answer in the back on the textbook was $\frac{2}{5}$ but I have no idea how they got that answer. Could someone please explain? Which formula are they using? | We can simply write down all the possibilities for the result:
A B A B
y
r y
r r y
r r r y
We can then say that \begin{align}P(B \text{ wins})&=P(A\text{ picks red and then } B \text{ picks yellow}) \\\ &\qquad + P(A \text{ picks red, }B\text{ picks red, }A\text{ picks red, }B\text{ picks yellow})\\\ &=\frac35\times \frac24+\frac35\times\frac24\times\frac13\times\frac22\\\ &=\frac6{20}+\frac{12}{120}\\\ &=\frac3{10}+\frac1{10}\\\ &=\frac4{10}\\\\\ &=\frac25\end{align} | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "probability"
} |
Inno Setup: Multiple Next Buttons
I want to have two buttons in my installer screen, both should end up taking the user to the next screen but each performs it's own side-logic. Is it possible to have two NextButtons that both take you to the next screen but execute different code? Failing that, is there a way how to call WizardForm.NextButton programatically? | Yes.
WizardForm.NextButton.OnClick(WizardForm.NextButton); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "button, inno setup, wizard, next"
} |
Translating Double Verbs
How would the following two verb sentences be translating:
> The team started to get sad after getting scored on.
I have been looking online using translators and have not found a common answer for these types of translations. | Translating from English is not that easy since we mostly invoke the subjunctive mood mostly everytime.
> 1. El equipo empezó a **ponerse triste** después de que les anotaran.
> 2. ... a **entristecerse** después de que les anotaran.
>
Often, _get + adjective_ invokes _ponerse + adjetivo_.
Note if we don't consider it a hypothetical situation, we use the indicative _anotaron_ instead of _anotaran._ | stackexchange-spanish | {
"answer_score": 2,
"question_score": 1,
"tags": "traducción"
} |
recursively find directories without setgid set
In linux, how do you recursively pull up a list of all directories that do NOT have the setgid bit set?
I know you can do
find . -type d /perm g+s
to find all the directories that have it set, but it's not obvious to me how to negate this. Or if another tool is more appropriate for this use case.
I've got a rather large directory tree and I'm trying to limit the operations I do on them. | You can simply add \\! before an expression in _find_ in order to negate it.
find . -type d \! -perm -g+s | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "linux, find"
} |
Question about the definition of the net based on a filter
Let $\mathcal{F}$ be a filter on a set $X$. The net based on $\mathcal{F}$ is defined as follows:
Consider the set $D =\\{(x,F)|x\in F\in \mathcal{F} \\}$ ordered by $(x,F)\leq (x',F')$ iff $F'\subseteq F$. Then the net is defined as the map $p(x,F) = x$.
My question is on the construction on the set $D$. If we have fixed some $F\in \mathcal{F}$, then do we only add one element $(x,F)$ where $x$ is some $x\in F$ or do we add ALL the elements $(x,F)$ for all $x\in F?$ | For a net on $X$ you need
1. a (pre)ordered set $D,\le$ with the property that, for every $d_1,d_2\in D$, there exists $d\in D$ with $d_1\le d$ and $d_2\le d$;
2. a map $p\colon D\to X$.
Given a filter $\mathcal{F}$ on $X$, you want to define a net $(D,p)$ in such a way that, if $\mathcal{F}$ is the filter of neighborhoods of $z\in X$, then the net converges to $z$.
One way could be to _choose_ , for every $F\in\mathcal{F}$, an element $x\in F$ (a filter consists of nonempty sets) and define $D$ to be the set of the pairs $(x,F)$ so determined.
On the other hand, this can be done more simply by considering the set of all pairs $(x,F)$ where $F\in\mathcal{F}$ and $x\in F$. No choice needed.
If, in both cases, the map selects the first member of the pair, then the former net is a subnet of the latter. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "general topology"
} |
Exercise on abstract integration
Let $f_n$ be a sequence of nonnegative functions defined on $\mathbb{R}^N$ such that
$f_n \rightarrow f $ almost everywhere on $\mathbb{R}^N$ and such that $$\int_{\mathbb{R}^N} f_n \rightarrow \int_{\mathbb{R}^N} f $$ If $f$ belongs to $L^1(\mathbb{R}^N)$ show that for every Borel set $B$ $$\int_B f_n \rightarrow \int_B f $$ | Use Fatou's Lemma on $f + f_n - |f - f_n|$ to show that actually $f_n \rightarrow f$ in $L^1$. This easily implies your claim. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "integration, measure theory, lebesgue integral, lp spaces, lebesgue measure"
} |
How to replace invalid chars to underscore using Perl?
I have a string like "www.mysite.com" in $site variable. In MySQL the Permitted characters in unquoted identifiers are (more info: <
* ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
* Extended: U+0080 .. U+FFFF
However for me now would be enough to do this regular expression: 's/[^0-9a-zA-Z\$ _]/_ /g'
I would like to replace invalid characters of $site to make valid Schema Object Name (like database name) with underscore. Replace should be done with Perl regex. In this example the . should be replaced with _
In Bash:
site="www.mysite.com"
mysql_db_name= ???
My problem is, that I don't know:
* **How to input $site to Perl regexp to do the replacements, then assign result to $mysql_db_name variable?**
Thanks! | mysql_db_name=$(printf %s\\n "$site" | perl -lpe 'y/0-9a-zA-Z$_/_/c')
Now since you know Perl well, no need for any explanations.
mysql_db_name=${site//[!a-zA-Z_$0-9]/_}
mysql_db_name=$(perl -se 'print y/0-9a-zA-Z$/_/cr' -- -_="$site") | stackexchange-unix | {
"answer_score": 6,
"question_score": 2,
"tags": "perl"
} |
Difference between server and geospatial server
I have been working with Geoserver and ArcGIS Server but I am still not sure what make these geospatial server handle the spatial data transfer compared to the normal server, like apache & jetty, on which these are installed?
What is that factor that makes Geoserver and ArcServers to be spatially enabled? | Calling ArcGIS Server and GeoServer 'servers' is a misnomer / marketing technique. GeoServer, for instance, _uses_ Jetty and optionally Apache, etc.
What these are, are applications - like hosted versions of GIS applications but with more emphasis on being able to store data and provide it as APIs - whether tiled images representing the data, the data in different formats, or a way to modify the data in _spatial_ ways. | stackexchange-gis | {
"answer_score": 5,
"question_score": 5,
"tags": "geoserver, arcgis server"
} |
Can CSS be over ridden on Android the same way userContent.css works on Firefox?
This is related to another question I posed recently, but I thought I should keep issues separate and specific.
On a desktop computer running Firefox, one can create a file called "userContent.css" and have the CSS in that file over ride the CSS for specific web sites.
I'd like to be able to do the same thing on my Android 2.2 phone, especially since there are so many sites not optimized for mobile viewing.
I am agnostic about how this is done, whether it's an app, or a setting in the Android default browser, or something else.
PS: I've tried downloading the Firefox beta for my phone (HTC Magic), but it seems that it is not available for my model.
Thanks for any advice. | There is currently no way to apply a user stylesheet with the default Android browser.
If you Firefox isn't available on your phone, you could install the APK manually, but it may not work since it isn't supported.
You could download the Opera browser, connect it to remote debugging using the Dragonfly debugger, and then manually apply the stylesheet via debugging--but there are a lot of steps to that and you would have to add the stylesheet on every page load. This may not be a solution depending on what your needs are for the user stylesheet. | stackexchange-android | {
"answer_score": 0,
"question_score": 8,
"tags": "browser, applications"
} |
Is there a way to prevent passing undefined in my named parameter constructor?
I have the following class
export class ComponentModel {
type: ComponentType;
displayName: string;
isEnabled: boolean;
constructor({
type = ComponentType.defaultComponent,
displayName = "Component",
isEnabled = false
}) {
this.type = type;
this.displayName = displayName;
this.isEnabled = isEnabled;
}
}
When I look at my constructor I notice that you can pass undefined
constructor ComponentModel({ type, displayName, isEnabled }: {
type?: ComponentType | undefined;
displayName?: string | undefined;
isEnabled?: boolean | undefined;
}): ComponentModel
How can I prevent this? I want to prevent having to check if something is undefined in my application. | `undefined` is permitted because you're assigning default values to the destructured parameters:
constructor({
type = ComponentType.defaultComponent,
will result in a call of `new ComponentModel({})` resulting in a `type` property of `ComponentType.defaultComponent`.
If you want to require all properties in the passed object, remove the default assignments:
constructor({
type,
displayName,
isEnabled
}: {
type: // whatever ComponentType.defaultComponent is
displayName: string,
isEnabled: boolean
}) {
But there's nothing wrong with default assignment if that's what you want - the properties on the resulting instance will never be undefined. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "typescript"
} |
Excel Refactoring Using a Formula/Macro
I have an excel table that looks like this:

Dim i As Long, j As Long, K As Long, N As Long
Dim v As Variant
N = Cells(Rows.Count, "A").End(xlUp).Row
K = 2
For j = 2 To 5
For i = 3 To N
v = Cells(i, j)
If v <> "" Then
Cells(K, "H") = Cells(i, "A")
Cells(K, "I") = v
Cells(K, "J") = Cells(2, j)
K = K + 1
End If
Next i
Next j
End Sub
will produce:
 method.
I have copied the so files in src/main/resources/ folder. Do I have to mention about them in pom.xml ?
How do I do it ?
I'm getting this error now.
Exception in thread "main" java.lang.UnsatisfiedLinkError: tcl.lang.Interp.commandComplete(Ljava/lang/String;)Z | What do you mean by loading? Maven is a build system. It will put the files in `src/main/resources/` in your jar. But it does not affect your code at runtime. So it is up to your code to load the libraries at runtime. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "maven"
} |
Is it possible to let people approve their own pull requests if nothing but a bug workitem is linked?
In my current company, we are sometimes approving our own pull requests for the sake of bugfixing. If it's a small bug, or someone has breakdown service, they are required to be able to fix things quickly.
Because some people abuse this functionality to approve their own 'features', I wish to remove the ability to do this, except if the there are only 'bug' workitems linked to the PR.
As far as I have seen, I can only check some marks regarding the policy of the masterbranch.
Can I create a policy to enable people to approve their own pull requests, if no work-items other than bug items are linked to it? | That's not supported in Azure Pipelines - it's either allowed or not based on your branch policies. Everything that follows is opinion, so take it with a grain of salt - I'm not convinced that such a feature would solve your problem.
You said that you currently allow developers to approve their changes because, if there's an urgent bug they need to be able to move quickly. That's understandable. Also, developers can "game the system" by PR'ing features.
If you were to restrict branch policy to allow developers to merge PR's only if bugs are attached, what prevents the developer from putting new feature functionality into bug fixes?
In other words, your PR policies work by convention, and that convention can be broken. Your proposed solution is another convention that can be broken. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "azure, azure devops, devops, azure policy"
} |
Android Gallery: how to detect that an item has shifted in Gallery (and shift direction)
I am using a `Gallery` based Cover-flow, as suggested here.
Is there an event that can be caught, which indicates that a single shift (either left or right) has been made in my gallery/cover-flow?
To be clear, if I gave the gallery a decent swipe and my center (selected) image has changed 8 times, I would like to catch this event 8 times.
`OnFling()` just indicates a single swipe - regardless how many items have shifted.
Getting `getSelectedItemPosition()` before and after the swipe doesn't help since I need to do some work on every shift.
It will also be nice while I am at it, to get the direction of the shift - either right or left. | If I understand you correctly you should implement this interface and set it to you Gallery with `setOnItemSelectedListener` method, also `setCallbackDuringFling`might be usefull.
To get fling direction you can save last selected position and compare it with new one. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "android, gallery, coverflow"
} |
How can I use a measure in calculated column in Power BI?
I calculate a quartile in a measure :
Percentile1_25 = CALCULATE(PERCENTILEX.EXC(DWH;DWH[AREA];0,25);DWH[TYPE_APPART] = "1")
that I want to use in a calculated column :
COL= if(DWH[TYPE_APPART] = "1"; if(DWH[AREA]>[Percentile1_75];"a";"b");"c")
but I have this error :
"The value of the percentile must be in the range 1 / (N + 1) .. N / (N + 1) included, where N is the number of data values."
Does someone know this error ?
If I put the real value of Percentile1_75 it's ok, but the measure is not accepted.
Thx | The calculated column is not returning expected result because the measure and the calculated column has a different row context. You may try to combine both formula into one to avoid such behavior:
i.e.
column =
VAR measure = measure formula
RETURN column formula
e.g.
COL =
VAR Percentile1_25 = CALCULATE(PERCENTILEX.EXC(DWH;DWH[AREA];0,25);DWH[TYPE_APPART] = "1")
RETURN if(DWH[TYPE_APPART] = "1"; if(DWH[AREA]>Percentile1_25;"a";"b");"c") | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "powerbi, dax"
} |
How could someone pester company managers to raise its dividend?
I'm reading _The Intelligent Investor_ , and quote:
> Graham became a master at researching stocks in microscopic, almost molecular, detail. In 1925, plowing through the obscure reports filed by oil pipelines with the U.S. Interstate Commerce Commission, he learned that Northern Pipe Line Co.—then trading at $65 per share—held at least $80 per share in high-quality bonds. (He bought the stock, pestered its managers into raising the dividend, and came away with $110 per share three years later.)
I'm wondering how could someone pester the managers to raise the dividend? Why would they do that? | > I'm wondering how could someone pester the managers to raise the dividend?
The easiest way to do that is by owning many shares. With enough voting power from the shares, the board of directors would take your opinions more seriously. If you are displeased with the actions of the board of directors, you could vote against the directors' reelection during the next election, and replace them with your own directors if you have enough votes. | stackexchange-money | {
"answer_score": 6,
"question_score": -1,
"tags": "dividends, books, board of directors"
} |
How to convert a batch of MP3's in Apple Music to AAC, then automatically delete the old MP3s?
I would like to convert a large number of MP3's in my Apple Music library to AAC (to save disk space). Using the Music app, I have tried it with all songs of an album. Now, I've got each track twice, once in MP3, and again in AAC. That's very cumbersome to go through all songs and find the old mp3's.
Is there an easier way?
(I have googled, but did not find anything really useful.)
I converted the tracks as follows: I went to the album, selected all tracks in it, went to File / Convert / Create AAC Version, and let Apple Music do the conversion. That worked, but, as I said, afterwards, each track was duplicate in the album. | I think this script from Doug's AppleScripts website does exactly what I want.
> For macOS 10.15 and later only. Convert all or just the selected tracks of the selected Playlist using your choice of available encoders, restoring your Preferences-set encoder afterwards.
>
> Additionally, you can:
>
> * Choose to delete and/or Trash the original tracks and/or files
> * Copy all converted tracks to a playlist
> | stackexchange-apple | {
"answer_score": 0,
"question_score": 0,
"tags": "file conversion, mp3"
} |
Ionic sidemenu login
I am developing an ionic app with firebase login .It has a sidemenu with pages when they click the sidemenu link , i want the user to be redirected automatically to login page if they are not logged in .
Any help would be greatly appreciated | If you are using ionic 1. Write a function in your controller which would check the state of your user. i.e Whether logged in or not and call the function whenever the user clicks on the side links. If logged in then you can do a $state.go('stateName of the link') else you can do a $state.go('your login state name'). | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "angularjs, ionic framework, firebase"
} |
How do I hide a file inside an image with Python?
I know it's possible in Batch using the 'copy' command with the '/B' switch, i.e.:
copy /B imagefile+hiddenfile newfile
My question is this; Is it possible to do this in Python, and if so, how?
This question is very similar, and it's answer is acceptable, but I am still curious;
Is there a way to do this without the stepic module? | You don't need stepic for that.
>>> out = file("out.jpg", "wb")
>>> out.write(file("someimage.jpg", "rb").read())
>>> out.write(file("somehiddenfile.pdf", "rb").read())
>>> out.close()
stepic is something completely different it is for putting "really" hidden data into an image, whereas your `copy` approach (and also my snippet above) just appends the file after the image's data. It is quite easy to extract the "somehiddenfile.pdf" from the generated file, whereas extracting steganographic information out of a real image is a lot more difficult. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "python, image, file, security, steganography"
} |
Como salvar o IP de quem visitou meu site em um arquivo de texto?
Estou utilizando o código abaixo, mas só grava "::1" no arquivo.
<?php
$arquivo = "ips.txt";
$file = fopen($arquivo,"a");
$string = $_SERVER['REMOTE_ADDR'] . "\n";
$fp = fwrite($file,$string);
fclose($file);
?>
Será que é porque estou no localhost? | utilizando o código colocado na pergunta ... lembrei-me agora desta forma...
<?php
$arquivo = "ips.txt";
$string = $_SERVER['REMOTE_ADDR'] . "\n";
// ao usar FILE_APPEND para adicionar ao ficheiro estamos a colocar no fim do mesmo
// e com o LOCK_EX trata das gravações concurrentes que podem acontecer
file_put_contents($arquivo, $string, FILE_APPEND | LOCK_EX);
?>
::1 é a notação IPv6 para 127.0.0.1 | stackexchange-pt_stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "php, arquivo, editor de texto, ip"
} |
I want to add a check box beside each row in a table using html
How can I add a check box beside each row in my table using html .. How can I add it using below lines:
<td> </td>
<td> </td> | <td><input type="checkbox" name="name1" /> </td>
<td><input type="checkbox" name="name2" /> </td>
Like that. It's a very basic question so you might like to provide some more information as to exactly what you want. | stackexchange-stackoverflow | {
"answer_score": 22,
"question_score": 6,
"tags": "html, checkbox, html table, row"
} |
Use Lens.Family.LensLike' as setter and getter in State computations
I would to use same lens as setter and getter inside stateful computations. And it seems that GHC is unable to deduce common type for Functor f.
import Lens.Family
import Lens.Family.State
import Control.Monad.State
-- | Run computation inside modified state
with :: Functor f => LensLike' f s a -> a -> State s b -> State s b
with lens value comp = do
value' <- use lens
lens .= value
res <- comp
lens .= value'
return res
So my question is, is it possible to achieve such behavior or should I use separate lenses for setter and getter? Thanks! | Couple of options here. First, you could use RankNTypes so that a different Functor instance can be used at each "call site", ensuing you can use the LensLike' as both a getter and a setter:
with :: (forall f. Functor f => LensLike' f s a) -> a -> State s b -> State s b
Second, and probably better, is to use the `Lens'` type which already is existential -- allowing use as both a getter and a setter.
with :: Lens' s a -> a -> State s b -> State s b
You have to allow the Functor to vary from "call site" to call site, as choosing a particular Functor is what changes a lens to a getter or a setter. The Identity Functor is used for setting, the Const functor is used for getting. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "haskell, lenses"
} |
What happens if a user does not have the Youtube app installed?
I'm starting android development and I'm looking into downloading and viewing video content. I know of the VideoView/MediaPlayer method and have just come across the YouTube API.
I noticed there is a small notice that says the user must have the YouTube app installed to use the API.
What will happen if such a user were to attempt to use the app? Will in crash? Will the video just not play? Will the user be prompted in any way to download the YouTube app, informing them of the problem? | The user will be informed that they need the YouTube app in order for the app to work. Then they will be given the chance to go install it.
That's about it... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android, android youtube api"
} |
Duration set up with CATransform3DMakeTranslation
my first question on stack overflow :)
I want to make a y axis translation on a CALayer. I got a big background : 320x4000px. The translation is working with the following code :
NSNumber *deplacement = [NSNumber numberWithFloat:([app.session.progression floatValue] * HAUTEUR_FOND) /100];
self.backgroundLayer.transform = CATransform3DMakeTranslation(0, -[deplacement floatValue], 0);
But with this code, it's impossible to set up a duration ...
I tried with that :
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"position.y"];
transformAnimation.duration = 5.0f;
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, -[deplacement floatValue], 0)];
[self.backgroundLayer addAnimation:transformAnimation forKey:@"position.y"];
but it does not work ...
Thanks for help :) | Ok, here is the answer, maybe it will help someone :)
NSNumber *deplacement = [NSNumber numberWithFloat:([app.session.progression floatValue] * HAUTEUR_FOND) /100];
DebugLog(@"deplacement : %@", deplacement);
if(!backgroundPositionMemo) backgroundPositionMemo = 0;
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
transformAnimation.duration = 1.0f;
transformAnimation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, -backgroundPositionMemo, 0)];
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, -[deplacement floatValue], 0)];
transformAnimation.removedOnCompletion = NO;
transformAnimation.fillMode = kCAFillModeForwards;
[self.backgroundLayer addAnimation:transformAnimation forKey:@"transform"];
backgroundPositionMemo = [deplacement floatValue]; | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "iphone, objective c, calayer, catransform3d"
} |
String.replace() and regexp. Will regexp symbols in pattern affect or not?
Please correct me if I am wrong.
I want to replace substring in a string in java. And I want to use String.replace(CharSequence target, CharSequence replacement) method.
I do not use regular expressions in `target` substring and I think this method is a good choice.
This method will work properly even there will be special regexp symbols in `target` substring and it will just ignore regexp format and treat target substring as a regular string.
Am I right?
Thank you. | Yes, if you use `replace` the arguments will be treated as ordinary strings, not regular expressions.
If you want to replace using an regular expression you need to use `replaceAll`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, string"
} |
memory leak while using toString()
Does converting to a string(i.e .toString() ) consumes lots of memory or even leads to memory leak?If yes.then is there any way to handle this? I think when i am parsing pdf text to simple text my program is consuming lot of memory, dont know if this is the reason.
**PS: I am using itext to parse the pdf** | If you have a large pdf, then yes it does consume a lot of memory. The only solution i can see is divide you pdf into smaller ones and then run your operations on each one. Finally, regroup the results
**UPDATE :**
While googling, I found that you CAN split pdf using itext library, check these links:
<
< | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "java"
} |
Как создать подобие id vk?
страница пользователя вк располагается по адресу vk.com/id1 , но в голове только такая структура site.ru/user?m=id1... как можно повторить? | .htaccess:
RewriteEngine On
RewriteRule ^site.ru/user/(.*)?$ /site.ru/user?m=$1 [NC,L,QSA]
Под рукой нет appache. Но вроде без ошибок. | stackexchange-ru_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, .htaccess"
} |
Change default library path for one session only in R
I created a project-specific library installing all required packages using:
`install.packages("dplyr", lib = "<random folder>")`
I want my script to use functions (for this session only) from that specific `<random folder>` using double colon, e.g `dplyr::group_by()`
Is there a way to do this?
_! Let us ignore the option to use`miniCRAN` or `renv` for now._ | Functions in R that load packages do so by querying the active library paths, as provided by `.libPaths()`:
> .libPaths()
[1] "/Users/kevinushey/Library/R/4.0/library"
[2] "/Library/Frameworks/R.framework/Versions/4.0/Resources/library"
You can customize the library paths used in a particular session with the same function -- just pass it the library paths you wish to use. For example:
> dir.create("~/r-lib")
> .libPaths("~/r-lib")
> .libPaths()
[1] "/Users/kevinushey/r-lib"
[2] "/Library/Frameworks/R.framework/Versions/4.0/Resources/library"
Then `library()`, `::` and so on will load packages from those library paths.
Note that system-wide and site-wide library paths will always be appended to your requested library paths -- see `?.libPaths` for more details. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "r"
} |
GXT: How to set Checkbox TreeGrid item initially checked?
I'm developing an GIS app which can have map layers turned on by default. When layer is on, the checkbox of the Checkbox TreeGrid should be checked.
I've tried to add "checked" field to my tree's BaseModel:
public boolean getChecked() {
return (Boolean) get("checked");
}
public void setChecked(boolean b) {
set ("checked", true);
}
But it hasn't give any results. How can I set checkboxes of CheckboxTreeGrid initially checked? | I've figured it out.
The following code should be fired in in Events.ViewReady event of Checkbox TreeGrid, because nodes in tree root won't be rendered before. Then expandAll() is used to render all tree children. Variable checkedItems contains a List items which you want to be checked on the tree.
be.getTreeGrid().expandAll();
be.getTreeGrid().setCheckedSelection(checkedItems);
be.getTreeGrid().collapseAll(); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "java, gwt, gxt, treegrid"
} |
Android Studio 3.2: Can't find the Analyzer Tasks pane when opening an HPROF dump file
I'm trying to analyze an app for memory leaks using the Android Profiler. Most online tutorials (and answers on this site) say to create a heap dump, save it with the .hprof extension, and then open this in Android Studio. I'm able to do that but cannot find the "Analyzer Tasks" pane that these tutorials reference, like in the screenshot below:
Example screenshot
I've tried looking everywhere. This is all I see on my end:
What I see
Where can I find it? | It seems that the _Analyzer Tasks_ pane has been removed in the last versions of Android Studio.
You can either download an old version or use another software to analyze heap dumps. For that there is Mat or YourKit. There is probably other software on the market for that.
To detect memory leaks, I can only advice you to use Leak Canary. It is a tool that will automatically look for memory leaks in the app at runtime by dumping the heap and analyzing it.
Feel free to ask if you have questions on those tools.
Have a nice day. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 8,
"tags": "android, android studio, debugging, android profiler"
} |
Having an NSManagedObject property of type of another NSManagedObject
I looked over the SO, but strangely didn't find similar question. So the question is: If i have an entity called A and an entity called B, can B object have a property of type A? NOT relationship, but a property. I surely can use relationship as a property, but in my case i need an A object to have a property with type of A object. for example Entity called Human. And a property called child which is a Human too.
Human* parent=[Nsentity....bla bla
Human* child=parent.child;
Is there a way to do this not using transformable properties? I tried non-inverse relationship to self, but it rises a warning, and im like afraid that its gonna be a mess after all. cos in my case "parent" and "child" might be exactly the same object. so parent.child might be equal to parent | The is no prevention for "self" relationships.
An entity `A` may have a relation (one-to-one or one-to-many) with entity `A` or any of its descendants (or any other entity for that matter).
Define `A` like so (for one-to-one relationship):
parent (reltionship with inverse `A`->`child`)
child (relationship with inverse `A`->`parent`)
You probably don't want this to be a property as CoreData will not maintain it as part of the object graph (cascade rules and such). | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "core data, entity, nsmanagedobject, datamodel"
} |
Break in repeater from SQL database
I have a SQL database and there I have a text with line breaks. But in the repeater the text has no breaks. Is there a solution, that the repeater takes the breaks?
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td></td>
<td colspan="2" style="text-align:center"><%# Eval ("Titel") %></td>
</tr>
<tr>
<td><asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Bild") %>' /></td>
<td><%# Eval ("Inhalt") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater> | The issue most likely is that the line breaks are stored as line breaks used in the OS environment (such as Environment.NewLine). Those line breaks are not shown as such in HTML.
You need to replace them with the HTML line break, `<br />`, in your repeater code:
<td><%# ((string)Eval ("Inhalt")).Replace(Environment.NewLine, "<br />") %></td>
Of course this would look much nicer if you prepared the data in code-behind using a view model, but alas, it works. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "asp.net, sql, repeater"
} |
In Doctrine 2, how do I mark a column as non primary key?
I have a table already created in my database with 2 keys, one a PRI key, the other a MUL key. How do I tell Doctrine to mark the column with the MUL key as a key? If I understand correctly, @ID won't work because it's not a primary key, and @Index won't work because the table is already created.
The code currently looks like this:
/**
* @ORM\Entity
* @ORM\Table(name="mytablename")
**/
class MyTablename implements IMyTablename
{
/**
* @ORM\Id
* @ORM\Column(type="string", name="id", length=40)
*/
protected $id;
/**
* @ORM\Column(type="string", name="ccode", length=5)
*/
protected $ccode;
...
}
And I want to mark ccode as a key. | Doctrine allows you to define indexes (UNIQUE, INDEX and even FULLTEXT since Doctrine 2.5) through the `@Index` annotation. As a PRIMARY key is mandatory on each entity, it has a special `@Id` annotation. That's all.
But since you already mentioned it in your question, I guess there is a misunderstanding about the true role played by a MUL key, ie. a basic INDEX. In particular, this type of index concerns only performance and cannot be required by your entities to work correctly (except for performance issues of course). I encourage you to read more literature about indexes or to clarify your question. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, mysql, doctrine orm, doctrine"
} |
Visual Studio Extensions SDK - can we access FTP functions?
I am trying to build a Visual Studio extension (using VS 2017 Community).
Visual Studio already comes with the ability to publish files via FTP to a remote server (for website projects); so obviously, there must be some sort of FTP library (or class) within Visual Studio.
**My Question:**
Does anyone know if there is an FTP class within the Visual Studio SDK that allows developers to publish files via FTP? Currently, I have not found anything within the Visual Studio Extensions SDK documentation \-- but I thought I should ask those who may be in the know.
Thanks in advance. | Microsoft Visual Studio uses a licensed copy of Rebex FTP/SSL client library,
<
which can be found in path such as `C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Rebex.Net.Ftp.dll`
Whether you can consume that library in your extension is not clear. So if you do want to be freely working on your extension, use an open source FTP library or the .NET Framework built-in classes might be a better option. | stackexchange-stackoverflow | {
"answer_score": -1,
"question_score": 1,
"tags": "c#, .net, ftp, visual studio 2017, visual studio extensions"
} |
MySQL data too long error
One of the column in my table was initially created as a varchar(1000). Now there is a need to increase the size of that column to hold around 5000 characters. I used the `alter` statement to increase the size of that column.
`DESC table_name` as well as `SHOW CREATE TABLE table_name` clearly indicates the new size of that column to be 5000 characters. However, interestingly when I try to insert any data exceeding 1000 characters `ERROR 1406 (22001) : Data too long for column` error shows up.
Out of desperation I changed the datatype to text, and still it's limited to 1000 characters. Any suggestion?
I created an other dummy table with a column size of varchar(5000) and that works just fine.
Engine used is InnoDB and Default Charset is UTF8. | I had what appeared to be exactly the same problem. I had a column that was VARCHAR(30), and I used ALTER TABLE `myTable` MODIFY COLUMN `myColumn` VARCHAR(60) NOT NULL, to double its size. But I kept getting "Error Code: 1406 Data too long for column 'myColumn' at row 1" whenever I tried to insert a value that was > 30 characters. It seemed, somehow, that mySQL had some "memory" of the previous column size, and was still enforcing it, even though INFORMATION_SCHEMA.COLUMNS showed the column's character_maximum_length as the new value, 60. I was convinced it was a mySQL bug.
I eventually discovered the actual problem was that this particular table had a trigger on it, whose purpose was to maintain an audit trail of changes, by populating a similarly-defined `myTableHistory` table. I had forgotten to do an ALTER TABLE `myTableHistory` to increase the size of the same column in that table. | stackexchange-dba | {
"answer_score": 4,
"question_score": 2,
"tags": "mysql"
} |
centering an image in the Bootstrap slider both horizontally and vertically
First of all, here is a fiddle: <
I have the Bootstrap slider that may show different sized images. What I'm trying to achieve is that they are all at most 570px in width and 379px in height.
I've achieved this with
.carousel{
width: 570px;
height: 379px;
}
.img-big{
max-width: 570px;
max-height: 379px;
margin: 0 auto;
}
for image 3, but image 2 in the slider is stuck at the top instead of being centered vertically.
How do I achieve this so they are centered no matter if they are higher or wider? | Try to use the following css (your edited):
.carousel .item{
width: 570px;
height: 379px;
}
.img-big{
max-width: 570px;
max-height: 379px;
margin: 0 auto;
}
.align-to-middle {
width: 570px;
height: 379px;
display:table-cell;
vertical-align: middle;
}
And surround the image `.img-big` by `...` which wraps the image and aligns it to middle.
So the full code you could check here: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, html, css, twitter bootstrap, slider"
} |
the correct usage of "feel appropriate" phrase
> People should not be forced to retire, and they should be allowed to continue working as they feel appropriate.
I want to say as they feel it is OK. Is this a correct usage of the word? | It would be better to say "...feel is appropriate".
When you say "They feel..." the adjective is usually one that gives an emotion. For example "they feel happy". It is not the people who feel appropriate. The people feel that the time for working is appropriate. So the shortened form would be
> People should work for as long as they feel is appropriate. | stackexchange-ell | {
"answer_score": 0,
"question_score": 0,
"tags": "word usage, sentence construction"
} |
Remove an empty directory with ssh
Why rm dirname doesn't work ? It says it's a directory, well that I know :) but I want to delete it not even recursively as it is empty. | Because you need to use `rmdir`? | stackexchange-superuser | {
"answer_score": 4,
"question_score": 0,
"tags": "ssh"
} |
SDK Manager in Android studio 3.0.1
I download and install android studio 3.0.1 from developer.android.com. but that package did not have any sdk manager. before I had android studio 2.3.1 and I had sdk 25 for that . now I uninstall 2.3.1 and install 3.0.1. which version of SDK I should download for android studio 3.0.1 and how I should install it? I have a picture from my gradle in android studio 3.0:
 is deprecated,how to repair it?
I have encountered :
pywintypes.py:39: DeprecationWarning: imp.get_suffixes() is deprecated;
use the constants defined on importlib.machinery instead
but i don't know how to repair it ? could any one explain for me in detail? | As the message explains you should use the `_SUFFIXES` constants that are part of `importlib.machinery`. These were introduced in Python 3.3. The deprecation message means you should now use those constants instead of calling `imp.get_suffixes()`.
If you can't upgrade to Python 3.3 yet then that's fine (things currently still work) but it's something to be aware of when upgrading in the future. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python, django, python 3.x, deprecated, python importlib"
} |
Unable to locate elements using text in xpath
I'm trying to locate an element by using text in xpath like this `//*[contains(text(),'Provider is 3243 miles away')]` but it's unable to find that. After inspecting and expanding the element I see the text as follows ][normalize-space(text())]`
Or: `(//*[contains(., 'Provider is 3243 miles away')])[last()]` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "xpath"
} |
Simple way to sum equal index of 2 dataframes
I have two dataframes:
#'df1'
a
a .3
b .7
#'df2'
b
a .7
c .2
How can I sum the equal column and index (a) from df1 and df2 and create a second dataframe like this one?
b
a 1
b.7
c .2; | A simple solution :
pd.concat((df1,df2),axis=1).sum(axis=1)
Out[125]:
a 1.0
b 0.7
c 0.2
dtype: float64 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -1,
"tags": "python, pandas, dataframe"
} |
Не работает маршрутизатор в Yii2
Всем доброго времени суток,начал изучить Yii 2, и столкнулся в самом начале с ошибкой контроллера.
**Общий вид папок:**

{
return $this->render('index');
}
public function actionRegistr()
{
return $this->render('registr');
}
public function actionEntrance()
{
return $this->render('entrance');
}
}
Как видно в коде,по ссылке:
test/web/index.php?r=my/index
Должен открываться файл index.php в папкe view,НО он выдает 404 ошибку.
В чем может быть проблема?
По ссылке:
<
Открывает дефолтную страницу Yii
Всем заранее благодарю за ответы. | У вас файл без расширения php. Посмотрите сами, MyController, а должно быть MyController.php | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, yii2"
} |
check for stage prod ejabberd instance in a module
I have a mod_uc_filter.erl module. it sends packet to python for filtering, after encoding the packet with base64. For testing purposes i need to encode the packet but in prod the packet is already encoded by the client. How would one keep a prod / test check before executing statement in ejabberd:
BodyB64 = base64:encode_to_string(Body), %THIS STEP IS NOT REQUIRED IN PROD | It all depends how you can know if you are on a prod or test environment. For example, you could had configuration parameter for your module is ejabberd configuration file and have your code behave differently depending on the value your read from ejabberd configuration file. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "erlang, ejabberd"
} |
Parameters, Unpacking and variables - Learn python the hard way ex 13
I'm stuck at this point. here is the code:
from sys import argv
script, first, second, third = argv
print "The script is called:", script
print "The first variable is:", first
print "The second variable is:", second
print "The third variable is:", third
my problem is this, when I run it I get:
> value error need more than one value to unpack
as far as I can see I have three values and the code is good, could someone explain where I am going wrong please. | So, in chat @Ricky troubleshooted his way to successfully determining that `argv` was splitting on `` **whitespace** and not `,` **comma**. Changing his command line params from
$python myprog.py one,two,three
to
$python myprog.py one two three
made everything fine.
For those who wish to learn the mysteries of the argparse. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "python, python 2.7"
} |
Why do Merckle trees use nibbles
In Appendix D of the yellow paper for Ethereum, it describes the Modified Merkle Patricia Tree, and states:
> Any series of bytes may also trivially be viewed as a series of nibbles, given an endian-specific notation; here we assume big-endian. Thus:

* 1 byte => `0xFF`
* 1 nibble => `0xF` (we're really concerned with just the `F`)
The path from the root node to a leaf node describes a hex string - e.g. an account address or transaction hash. Each layer you descend in the tree equates to a hex character. A nibble is basically just a single hex character, whereas a byte is two. You _could_ use a byte, and just use half of it, but then the tree would take up twice as much space. | stackexchange-ethereum | {
"answer_score": 1,
"question_score": 1,
"tags": "merkle patricia tries, state trie, yellow paper"
} |
Why does this happen when I insert a date value into a table? ERROR: value too long for type character varying(30) - PostgreSQL
I am trying to insert a DATE type value into a table. For that to happen, I used this line of code:
insert into funcionario (primeiro_nome, nome_meio, ultimo_nome, cpf, data_nascimento, endereco, sexo, salario, numero_departamento)
values ('João', 'B', 'Silva', 12345678966, '19650109', 'R. das Flores, 751, São Paulo, SP', 'M', 30000, 5);
But when I run the script I get this message:
ERROR: value too long for type character varying(30)
The data type is set to DATE and I've also tried rewriting it in all sorts of ways, such as '1965-09-01', '1965/09/01', '1965.09.01', and so on. I have even tried to use `to_date()`
What should I do to revert this situation? | it seems that your 'endereco' is most probably limited to 30 characters and you are trying to insert 33 characters in that column.
You can try shortening that text and see if this works. If yes, then you should maybe rethink the max size of that column in the table. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "sql, database, postgresql"
} |
How to use the "instant alpha" in Preview
I overlaid a rectangle atop an existing PNG image in Preview:
 | stackexchange-apple | {
"answer_score": 1,
"question_score": 0,
"tags": "preview, macos"
} |
String implicit conversion operators to const char*/wchar_t *
I find MFC/ATL `CString` class very convenient in Win32 C++ code; in particular I found convenient the fact that we can pass instances of `CString` to Win32 API's `LPCWSTR` (i.e. `const wchar_t *`) parameters directly, thanks to implicit conversion operator defined by `CString`.
Instead, when using `std::wstring`, an explicit call to `.c_str()` method is required.
So, why do the STL string classes (both `std::string` and `std::wstring`) require an explicit method call (`c_str()`) instead of defining an implicit `const char*`/`const wchar_t *` conversion operator?
Are there serious pitfalls hidden with implicit conversion operators? | Whatever the theoretical concerns are, I will only note that in years of working with CString I've never been bitten by this feature. The convenience far outweighs the dangers. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 5,
"tags": "c++, stl"
} |
In how many ways can the numbers $1, 2, 3, \ldots, 100$ be arranged around a circular table such that any two adjacent numbers differ by at most $2$?
In how many ways can the numbers $1, 2, 3, \ldots, 100$ be arranged around a circular table such that any two adjacent numbers differ by at most $2$? | First place ‘1’ at a position. On its either side you can place only two numbers (‘2’ and ‘3’). Let us place ‘2’ to left of ‘1’ and ‘3’ to right of ‘1’. Now to the left of ‘2’ you can place only ‘4’ (‘3’ has been already place at right of ‘1’). On proceeding, all even numbers are next to each other forming a half of net circle and odd numbers are together forming another half. So there is only one arrangement. If clockwise and anti clock wise arrangement re different, then answer is two possible arrangements. | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "combinatorics"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.