qid int64 10 74.7M | question stringlengths 15 26.2k | date stringlengths 10 10 | metadata list | response_j stringlengths 27 28.1k | response_k stringlengths 23 26.8k |
|---|---|---|---|---|---|
64,804,824 | I am learning HTML and I am trying to align different icons in a line but in a different positions. The first element should be aligned to the left and the others aligned to the right.
```
E1| |E2|E3|E4
```
I am not sure how to implement that. Should I use a `table`? Or a `div` with `<li>` elements?
I ... | 2020/11/12 | [
"https://Stackoverflow.com/questions/64804824",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14086404/"
] | Errors and lines beginning with `>>>` suggest you're still inside Python2 interpreter. You need to exit it before trying to run Python3. You can do that by pressing the `Ctrl` and `d` buttons on your keyboard at the same time, or typing `exit()`.
After exiting, you should be able to run `python3`. | looks like your python is linked to python2.7 instead of python3.
just type python3 on commandline, this should solve your problem. you can check the version by typing python3 --version on commandline.
the same should work for pip3 |
339,378 | Let $E$ and $F$ be Banach spaces, and let $\mathfrak L\_{co}(E,F)$ denote the space of bounded linear operators $E \to F$ equipped with the topology of uniform convergence on the absolutely convex compact subsets of $E$.
Defant and Floret [DF93, §5.5] point out that there is a natural linear map
$$ D\_F : F' \mathop{... | 2019/08/28 | [
"https://mathoverflow.net/questions/339378",
"https://mathoverflow.net",
"https://mathoverflow.net/users/120251/"
] | This question was settled in 2012 by Petr Hájek and Richard J. Smith [HS12]. They prove the following beautiful result (reformulated here to match the notation from the question).
>
> **Theorem** (cf. [HS12, Theorem 2.5])**.** Let $F$ be a Banach space with the AP. Then the following conditions are equivalent:
>
>
... | It follows from [this answer of Bill Johnson](https://mathoverflow.net/a/199260) that it can already fail if $E = F$, so the question has been settled in the negative. |
65,935,051 | I am building an application using docker-compose (file 1) and I was wondering how I could communicate the host IP address to the docker-compose file. The application is composed of a db, a frontend and a backend. The aim of it is that I want to access my application from other computers on the local network. It works ... | 2021/01/28 | [
"https://Stackoverflow.com/questions/65935051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11139767/"
] | What you want is called [shell command substitution](https://unix.stackexchange.com/questions/440088/what-is-command-substitution-in-a-shell).
Something like: `MYVAR=$(ip route get 1 | awk '{print $NF;exit}')`
Unfortunately, command substitution is NOT supported in compose.
Compose supports only "static" shell v... | You should add an environment variable to your frontend configuration which specifies the URL to the api endpoint and use the hostname of the backend container in the URL. The documentation for [Networking in Compose](https://docs.docker.com/compose/networking/) details default hostname and networks used for containers... |
435,591 | *За* -- довольно распространённый предлог, который употребляется с винительным или творительным падежом. В предложении:
>
> «Если бы вы знали, что это **был за чудный человек**, пани»
>
>
>
падеж явно именительный! Что нарушает вообще какую бы то ни было сколько-нибудь разумную синтаксическую трактовку данного пр... | 2017/11/30 | [
"https://rus.stackexchange.com/questions/435591",
"https://rus.stackexchange.com",
"https://rus.stackexchange.com/users/5032/"
] | *Что за* (в данном случае *за* не предлог, а часть сложной частицы) — это разговорная восклицательная частица, употребляющаяся в трех случаях:
1) при усилении вопроса;
2) при усилении качества или свойства;
**3) при выражении эмоциональной оценки (восхищения, возмущения, осуждения и т. п.)**.
В вашем примере т... | А я рассматривала бы это предложение по-другому. Здесь ЭТО - подлежащее в именительном падеже, его можно заменить местоимением ОН.
ЧЕЛОВЕК - дополнение в винительном падеже с предлогом ЗА. |
37,148 | Is there a word that can be used to mean two previous places? I want to reference something two paragraphs ago; *former* would work if it was only one before, and I cannot use *penultimate* because it may be confused with the second to last of the entire work. | 2011/08/08 | [
"https://english.stackexchange.com/questions/37148",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/11738/"
] | In the very [first comment of this blog,](http://blogs.nature.com/nwerneck/2011/01/18/relative-citation-impact-by-country---2009) someone stated:
>
> I edited the post including two paragraphs before the image, explaining with more details how it is created.
>
>
>
I believe that the one way to state "two paragrap... | Try *penprevious* (made up word, parallel with *penultimate*). |
28,035,688 | I have a class with a function that updates attributes of its objects. I'm trying to figure out which is more pythonic: should I explicitly return the object I'm updating, or simply update the `self` object?
For example:
```
class A(object):
def __init__(self):
self.value = 0
def explicit_value_upda... | 2015/01/20 | [
"https://Stackoverflow.com/questions/28035688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/362703/"
] | In my opinion, using `__new__` in such a way is really confusing for other people who might read your code. Also it requires somewhat hackish code to distinguish guessing file system from user input and creating `Nfs` and `LocalDrive` with their corresponding classes.
Why not make a separate function with this behavi... | **Edit [[BLUF]](https://en.wikipedia.org/wiki/BLUF_(communication)):** there is no problem with the answer provided by @martineau, this post is merely to follow up for completion to discuss a potential error encountered when using additional keywords in a class definition that are not managed by the metaclass.
I'd lik... |
69,718,039 | I am making this JS calculator project, which I want to make responsive. But it's not quite working properly.
I want to make the width of the .calculator slightly bigger when the screen becomes smaller because in the that way all the buttons can be shown properly(especially the operator ones).
Here is the codepen I... | 2021/10/26 | [
"https://Stackoverflow.com/questions/69718039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13689497/"
] | Use this code section in your CSS:
```
@media screen and (min-width: 320px) and (max-width: 630px) {
.calculator {
width: 60%;
}
button
{
padding:16px 0px;
}
}
```
`device-width` has been deprecated.
And to show all the `operator buttons` on all mobile device remove padding left and right from sel... | The device-width properties has been deprecated so use `min-width` instead. You can read on [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/device-width)
so change
* `min-device-width` to `min-width`
* `max-device-width` to `max-width`
```
@media screen and (min-width: 320px) and (max-width: 630px) {
... |
418,884 | I want to do something like:
```
command || log $error_from_last_command
```
Is there a way to use `||` and still access `stderr` like a pipe?
*My intention here is to process the error message from `command`, using `log`, but only if `command` fails.
I'm reading through the marked duplicate but I don't see how to ... | 2018/01/22 | [
"https://unix.stackexchange.com/questions/418884",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/16792/"
] | If you want to use the output of a program in another that only runs after the first command completed, it's probably easiest to store the output in a file.
```
errfile=$(mktemp)
if ! somecommand 2> "$errfile" ; then
log < "$errfile" # or log "$(cat "$errfile")" ?
fi
rm "$errfile"
```
Piping the output would... | If it would be sufficient for your purposes to know the *exit code* of the first element of the pipe (or any element of any pipe), you can avail yourself of the `bash` variable `PIPESTATUS`, which according to the `bash` man page is: "An array variable ... containing a list of exit status values from the processes in t... |
6,685,621 | So I got this error:
>
> Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\scanner\mine.php on line 112
>
>
>
On this line:
```
if(preg_match("inurl:", $text) {
```
Its part of a "Clean" function:
```
function Clean($text) {
if(preg_match("inurl:", $text) {
str_replace("inurl:... | 2011/07/13 | [
"https://Stackoverflow.com/questions/6685621",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/763725/"
] | Two problems, One closing ) and a missing semicolon after str\_replace, also you should know your str\_replace won't do anything in your code so i added $text = ... :)
```
function Clean($text) {
if(preg_match("inurl:", $text)) {
$text = str_replace("inurl:", "", $text);
return htmlsp... | The if clause is superfluous anyway. The following function is equivalent to the original version (sans the non-compiling regex pattern).
```
function Clean($text)
{
$text = str_replace("inurl:", "", $text);
return htmlspecialchars($text, ENT_QUOTES);
}
```
If the string you want to replace is not found in t... |
46,677,774 | I'm trying to use the `isNaN` global function inside an arrow function in a Node.js module but I'm getting this error:
`[eslint] Unexpected use of 'isNaN'. (no-restricted-globals)`
This is my code:
```
const isNumber = value => !isNaN(parseFloat(value));
module.exports = {
isNumber,
};
```
Any idea on what am I... | 2017/10/11 | [
"https://Stackoverflow.com/questions/46677774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4705426/"
] | In my case, I wanted to treat 5 (integer), 5.4(decimal), '5', '5.4' as numbers but nothing else for example.
If you have the similar requirements, below may work better:
```
const isNum = num => /^\d+$/.test(num) || /^\d+\.\d+$/.test(num);
//Check your variable if it is a number.
let myNum = 5;
console.log(isNum(myN... | For me this worked fine and didn't have any problem with ESlint
`window.isNaN()` |
50,227,596 | I went through the documentation to edit kubernetes resource using [`kubectl edit`](https://kubernetes-v1-4.github.io/docs/user-guide/kubectl/kubectl_edit/) command. Once I execute the command, the file in YAML-format is opened in the editor where I can change the values as per requirement and save it. I am trying to e... | 2018/05/08 | [
"https://Stackoverflow.com/questions/50227596",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1117320/"
] | Your command is missing a backtick. But even though you put it there, it won't work. The reason is because when you do `kubectl edit ...`, it edits the file on vim. I am not sure sed would work on vim though. Even though if it does, the output goes to a file, so you get the `Vim: Warning: Output is not to a terminal` e... | I just found a less convoluted way of doing this:
```
KUBE_EDITOR="sed -i s/SOMETHING TO CHANGE/CHANGED/g" kubectl edit resource -n your-ns
``` |
71,010 | I am looking for an AntiVirus for Ubuntu, and have researched potential products. I do not want a paid product, but i do want a user friendly interface.
**I do not want rants about how unnecessary it is on Ubuntu.**
My considerations are:
* [avast! Linux Home Edition](http://www.avast.com/linux-home-edition#tab4) (F... | 2011/10/23 | [
"https://askubuntu.com/questions/71010",
"https://askubuntu.com",
"https://askubuntu.com/users/24819/"
] | There is also BitDefender Antivirus Scanner which is a free download.
It keeps out of the way until you need it or you can set it to run in the background as in windows.
<http://www.bitdefender.co.uk/business/antivirus-for-unices.html>
Once on this page there is a link on the left hand side to 'Request a Free License... | Subjective question, but I would add ClamAV to plus ones. |
39,461,992 | I want set shadow with `UICollectionViewCell`, like this:

I write code in Custom Cell
```
override func awakeFromNib() {
super.awakeFromNib()
layer.shadowColor = UIColor(red: 0.7176470757, green: 0.7176470757, blue: 0.7176470757, alpha: 1.0000000000).CGColo... | 2016/09/13 | [
"https://Stackoverflow.com/questions/39461992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3977282/"
] | **Go to the collectionviewcell.m and add these manually.**
I did this to fix it.
```
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
//////// make shadow of total view
self.clipsToBounds = NO;
self.layer.masksToBounds = NO;
self.layer.shadow... | Add this line too:
```
layer.masksToBounds = false
```
By default it is `true` and limits the Cell within its frame size, by setting it to `false` allows cell's shadow to be visible outside its frame. |
22,158,154 | Every question I search for about the warning
>
> Warning: Null value is eliminated by an aggregate or other SET operation.
>
>
>
Typically people want to treat the NULL values as 0. I want the opposite, how do I modify the following stored procedure to make it return NULL instead of 1?
```
CREATE PROCEDURE Tes... | 2014/03/03 | [
"https://Stackoverflow.com/questions/22158154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/80274/"
] | The `sum()` function automatically ignores `NULL`. To do what you want, you need an explicit checK:
```
select (case when count(foo) = count(*) then sum(foo) end)
from #tmp;
```
If you want to be explicit, you could add `else NULL` to the `case` statement.
The logic behind this is that `count(foo)` counts the numbe... | Looking for a null value with `EXISTS` may be the fastest:
```
SELECT
CASE WHEN EXISTS(SELECT NULL FROM tmp WHERE foo IS NULL)
THEN NULL
ELSE (SELECT sum(foo) from tmp)
END
``` |
22,732,857 | So basically I have a class for a TicTacToe game and a derived class just to practice using inheritance. The class has several methods and all should work perfectly fine but in the main function, when I finally make three objects of the derived class I get three errors "use of unassigned local variable 'boardOne'" "use... | 2014/03/29 | [
"https://Stackoverflow.com/questions/22732857",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3471066/"
] | Yes, the compiler is *right*: you're trying to use *unassigned variables*:
```
static void Main(string[] args)
{
// It's just a declaration; no value assigned to boardOne; boardOne contains trash
ThreeD boardOne;
// It's just a declara... | your missing creating object instance
ThreeD boardOne = new ThreeD();
ThreeD boardTwo = new ThreeD();
ThreeD boardThree = new ThreeD(); |
148,542 | Let $A\_\bullet$ be a dg-algebra over a field $k$. Let $M\_\bullet$ (resp. $N\_\bullet$) be a right (resp. left) $A\_\bullet$-module. There is then a notion of the **derived tensor product**:
$$M\_\bullet\otimes^L\_{A\_\bullet}N\_\bullet=\bigoplus\_{p\geq 0}M\_\bullet\otimes(A\_\bullet)^{\otimes p}\otimes N\_\bullet$$
... | 2013/11/11 | [
"https://mathoverflow.net/questions/148542",
"https://mathoverflow.net",
"https://mathoverflow.net/users/35353/"
] | Omitting the stars, what you have written down is a two-sided bar construction $B(M,A,N)$,
unreduced since you have not assumed that $A$ is augmented. Note that in degree $n$ it
is the direct sum over $p+q=n$ of the elements of the $p$th term in degree $q$. One
conceptual way of thinking about it is that that we can ... | In the case when $M=N=A$, your question reduces to the comparison between the usual direct sum Hochschild chain complex versus the direct product chain complex. It is important to use the direct sum chain complex in proving that Hochschild homology is a homotopy invariant of $A$. To see this, observe that the Hochschil... |
218,181 | We all know some individuals who don’t express their opinions as:
>
> I *think* this is going to happen...
>
>
>
Instead, they express it as if it were fact or news, e.g.:
>
> Next month the price of (something) *is going to* increase by 10 percent.
>
>
>
What do you call such people? And are there any idi... | 2015/01/03 | [
"https://english.stackexchange.com/questions/218181",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/89324/"
] | The term I'd use is [**rumour-monger** (BrE) or **rumormonger** (AmE):](http://www.oxforddictionaries.com/us/definition/english/rumour-monger)
>
> NOUN
>
>
> *derogator*y
>
>
> A person who spreads rumours.
>
>
> EXAMPLE SENTENCES
>
>
> *A list of six names was compiled by the gossips and rumour-mongers of Be... | I'd call him **"an unreliable source"** Not an idiom, but it seems to translate what you are looking for.
"Forget what he said about us getting a bonus in December. He is a most unreliable source." |
22,398,987 | I'm doing an online course on "Programming, Data Structure & Algorithm". I've been given an assignment to "find the most frequent element in a sequence using arrays in C (with some constraints)". They've also provided some test-cases to verify the correctness of the program. But I think I'm wrong somewhere.
Here's the... | 2014/03/14 | [
"https://Stackoverflow.com/questions/22398987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Additionally to problem pointed out by Paul R is:
You are printing maximum occurrences of number, not the number itself.
You're going to need another variable, which will store the number with maximum occurences. Like :
```
maximum = count[0];
int number = -100;
for (i = 0; i < 201; i++) {
if (counter[i] > maxim... | I would prefer checking in one loop itself for the maximum value just so that the first number is returned if i have more than one element with maximum number of occurances.
FInd the code as:
```
#include<stdio.h>
int main()
{
int n,input;
scanf("%d",&n);
int count[201] ={0};
int max=0,found=-1;
f... |
67,327,244 | I have 3 dataframes with different columns with each row having diferent IDs (for all 3 DF).
I have appended all of those rows id in a Dataframe4 and sorted.
and I'm trying to read each line of the 3 dataframes in the right order, based on the dataframe4 sorted.
but i'm stuck here:
```py
df1 = pd.DataFrame({
'... | 2021/04/30 | [
"https://Stackoverflow.com/questions/67327244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10676834/"
] | 1. [Concat](https://pandas.pydata.org/docs/reference/api/pandas.concat.html#pandas-concat) df1, df2, df3 together.
2. Build a sorter to order based on the values in df4. (See. [sorting by a custom list in pandas](https://stackoverflow.com/q/23482668/15497888))
3. [Apply](https://pandas.pydata.org/docs/reference/api/pan... | I merged the dataframe then made rowid as index. Finally I sorted rowid in ascending.
Hope this would work
```
import pandas as pd
df1 = pd.DataFrame({
'rowid': ['1', '4'],
'Column2': ['1100', '1100']})
df2 = pd.DataFrame({
'rowid': ['2', '5', '7', '9', '11', '13'],
'Column3': ['xxr', 'xxv', 'xxw', 'x... |
4,073,303 | We filmed a spokesperson on a green screen and have the video files ready in multiple formats.
With Flash we could use the wmode transparent within the param and embed tags, but is there something similar to this with the video and source tags in HTML5? Is it even possible to properly save .m4v or .ogv videos so that... | 2010/11/01 | [
"https://Stackoverflow.com/questions/4073303",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/494100/"
] | While this isn't possible with the video itself, you could use a canvas to draw the frames of the video except for pixels in a color range or whatever. It would take some javascript and such of course. See [Video Puzzle](http://www.infinything.com/CanvasVidPuzzle.html) (apparently broken at the moment), [Exploding Vide... | webm format is the best solution for Chrome > 29, but it is not supported in Firefox IE and Safari, the best solution is using Flash (wmode="transparent"). but you have to forget "ios". |
10,575,558 | I'm reading more open source javascript frameworks and found more ways of how to create anonymous functions, but whats is different and best way?
```
(function() {
this.Lib = {};
}).call(this);
(function() {
var Lib = {}; window.Lib = Lib;
})();
(function(global) {
var Lib = {}; global.Lib = Lib;
})(glob... | 2012/05/13 | [
"https://Stackoverflow.com/questions/10575558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1366538/"
] | ```
(function() {
this.Lib = {};
}).call(this);
```
Defines the `Lib` property of the Object it's called on, and is immediately called on `this` which is typically the `window`. It may instead refer to the Object that owns the method in which it is called.
```
(function() {
var Lib = {}; window.Lib = Lib;
})... | All of them are effectively equivalent (but less efficient and more obfuscated) to:
```
var Lib = {};
```
Immediately invoked function expressions (IIFEs) are handy for contianing the scope of variables that don't need to be available more widely and conditionally creating objecs and methods, but they can be over us... |
28,407,342 | I have this table (say TABLE1):
```
ID1 | ID2 | NAME
```
where (ID1, ID2) is the composite PK.
And this another table (say TABLE2):
```
ID | COD1 | COD2 | DATA | INDEX
```
where ID is the PK.
I need to join this tables on `((TABLE1.ID1 = TABLE2.COD1) AND (TABLE1.ID2 = TABLE2.COD2))`
My problem is that, for e... | 2015/02/09 | [
"https://Stackoverflow.com/questions/28407342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3026283/"
] | A slightly different solution:
```
select t1.id1, t1.id2, t1."NAME", t3."DATA"
from table1 t1
left join
(
select max("INDEX") as maxindex, cod1, cod2
from table2
group by cod1, cod2
) tt on tt.cod1 = t1.id1 and tt.cod2 = t1.id2
left join table2 t2 on t2."INDEX" = tt.maxindex;
```
If all tuples have di... | try
```
SELECT ID1,ID2,NAME
FROM TABLE1
join
(select ID,DATA, max(Index) themax
FROM TABLE2
WHERE (your condition)
group by ID) temp on table1.Index = themax
WHERE (your condition)
``` |
10,700,179 | I am making a Device Discovery windows application in C#. Is this possible to know the device type if I have MAC address or IP address?
device type means either it is computer or router or mobile or any other device?
Note: HostName entry is not useful for it because Host Name is defined by User. for example i may ass... | 2012/05/22 | [
"https://Stackoverflow.com/questions/10700179",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1389475/"
] | You can get the manufacturer from the MAC address. In order to get any more information you'd need to do a port scan to do a 'fingerprint' of the device in question.
Application such as [NMAP](http://nmap.org/) use this approach. | IP Address: No. The Internet Protocol address can not help you figure out which device is being used
As for the MAC address: See [this](http://www.coffer.com/mac_find/) website.
Basicly, each vendor 'owns' a range of MAC addresses, this specific website can ever offer you the range used for each vendor. pretty neat. |
41,470,296 | Assume there is a function `doRequest(options)`, which is supposed to perform an HTTP request and uses `http.request()` for that.
If `doRequest()` is called in a loop, I want that the next request is made after the previous finished (serial execution, one after another). In order to not mess with callbacks and Promise... | 2017/01/04 | [
"https://Stackoverflow.com/questions/41470296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2044940/"
] | ```
https.get('https://example.com', options, async res => {
try {
let body = '';
res.setEncoding('utf-8');
for await (const chunk of res) {
body += chunk;
}
console.log('RESPONSE', body);
} catch (e) {
console.log('ERROR', e);
}
});
``` | I tried to make the second function from the accepted answer readable.
```
function actuallyDownloadFile( url ) {
return new Promise ( ( resolve, reject ) => {
const request = http.get( url );
request.on( 'response', ( response ) => {
console.log( 'Doing magic...' );
res... |
42,308,193 | I have a date column `CreateDate (datetime, not null)` in my table.
Using the following where clause:
```
Where
-- Code for 12 Months Back at a Time
CreateDate >= dateadd(month,datediff(month, 0, getdate())-12,0)
```
If I run my report say on March 1, 2017, I should get 12 months of data. I do.
I would li... | 2017/02/17 | [
"https://Stackoverflow.com/questions/42308193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2051440/"
] | I am guessing you are using `order by CreateDate desc` but you have aliased CreateDate in your query to be something like `format(CreateDate, 'MMM yyyy') as CreateDate`
So your `order by` will need to know you want it to use the original value instead of the new value that is being returned with the same name.
Try `... | Thanks all, I have resolved the issue by removing the Convert on the date field and fixing the format in SSRS.
Thanks, |
9,081,598 | I have the following code:
```
long[] conIds = GetIDs();
dc.ExecuteCommand("UPDATE Deliveries SET Invoiced = NULL WHERE ID IN {0}",conIds);
```
I'd expect that to work, but the executecommand statement throws an exception stating that
>
> A query parameter cannot be of type int64[].
>
>
>
Why is this? | 2012/01/31 | [
"https://Stackoverflow.com/questions/9081598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/460407/"
] | You are passing an array of longs into a placeholder where a string is expected. You need to convert the array into a concatenated string with comma delimiters. Then, pass that into the command text.
Depending on where else you are using the `GetIDs` method, you could simplify your code by having that method return an... | You can't do this. SQL parameters must be single values.
You can make this work by converting your array to a list of comma separated values.
See [here](https://stackoverflow.com/questions/182060/where-in-array-of-ids) for an example.
```
command.CommandText = command.CommandText.Replace(
"@conIDs",
string.Join... |
12,481,434 | I am using Jquery PrettyPhoto to have a slide show, however it does not let the users to download the images. Anyone know how can I add a link to it so users will be able to download the images?
Here is my code: (I am using prettyPhoto Widget in Yii, but any answer in general for prettyPhoto will be great)
```
<?php ... | 2012/09/18 | [
"https://Stackoverflow.com/questions/12481434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1353497/"
] | Easy!
HTML **(title is empty!)**
```
<a id="photo_link" href="http://link_to_image_or_video" rel="prettyPhoto" title="">
<img src="images/play-video.png" alt="" title="" width="380" height="147" />
</a>
```
JS (inside the document ready)
```
//do not show title on download link hover (download button)
$("#phot... | OK, I solved my problem, [here](http://www.catpin.com/prettyphoto.php) is an example that I found. They have added the link to download the photo like this:
```
<ul class='gallery clearfix'>
<li>
<a href='./uploads/1f.jpg' rel='prettyPhoto[gallery1]' title='Nature Photo One' >
<img src='./uploads/1t.jpg'... |
8,115,997 | I exported my matlab structs to text files so that I can read them in clojure.
I have a text file like:
```
name
Ali
age
33
friends-ages
30
31
25
47
```
know I can read this file, but what's the clojure way to convert it into something like:
```
(def person1
{:name "Ali"
:age 33
:friends-ages [30 31... | 2011/11/14 | [
"https://Stackoverflow.com/questions/8115997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/487855/"
] | Assuming each file has a single record,
```
(defn parse [f]
(let [[_ name _ age _ & friends] (.split (slurp f) "\n")]
{:name name :age age :friends (map read-string friends)}))
(parse "../../../Desktop/t.txt")
```
you get,
```
{:name "Ali", :age "33", :friends-ages (30 31 25 47)}
``` | I ended up writing an .m file to export my .mat files to text, then imported them by something like the following:
```
(use '[clojure.string :only (split join)])
(defn kv [[k v]]
[(keyword k) v])
(let [a (split (slurp (java.io.FileReader. fileName)) #"\n")]
(def testNeuron (into {} (map kv (partition 2 a)))... |
44,971 | I live in a town where fresh or whole milk is not readily available.
I was wondering if I could make cheese from UHT Milk.
If so, what kind of cheese and what method I should use?
Or rather, Should I? | 2014/06/19 | [
"https://cooking.stackexchange.com/questions/44971",
"https://cooking.stackexchange.com",
"https://cooking.stackexchange.com/users/25507/"
] | The self-appointed Cheese Queen, Ricky, recommends making mozzarella from dry-milk powder and added cream if you're in an area where you can only get UHT milk: [Mozzarella from Instant Nonfat Dry Milk and Cream](http://cheesemaking.com/store/pg/262-MozzarellaDryMilk.html).
That may be a better option that trying Mozza... | Yes, you can use UHT mik to make a rennet cheese.
You would need to use calcium chloride and the double amount of rennet.
Then the curds will be like rice.
You press it, and you have cheese. |
30,645,022 | I've read [here](https://stackoverflow.com/a/2530007/589192) about the difference between functions and methods in scala. It says that methods can be slightly faster than functions. But when passing a method `m` as an argument using `m _`, m is implicitly converted to a function.
1. Is the performance difference signi... | 2015/06/04 | [
"https://Stackoverflow.com/questions/30645022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/589192/"
] | 1. Kind of irrelevant to by **2**. But in general, forget about performance, methods are more readable than function declarations. They might be a little faster in some situations from compiler optimizations, but:
2. You cannot pass a method as an argument without converting it to a function. A method is a special lang... | 1. No.
2. No. In the extremely rare case where this kind of microperformance was important, you'd want to pass the object that the method is on, and either modify the receiving function to accept that, or make the object implement one of the `FunctionN` interfaces so that it can be used as a function. |
27,982,333 | I've got a query as below:
```
IF OBJECT_ID('tempdb..#Temp1') IS NOT NULL BEGIN
drop table #Temp1
end
SELECT * into #Temp1
from (
SELECT 1, NULL, NULL, NULL, NULL
UNION ALL SELECT 2, NULL, NULL, NULL, NULL
UNION ALL SELECT 3, NULL, NULL, NULL, NULL
UNION ALL SELECT 4, NULL, NULL, NULL, NULL
UNION ... | 2015/01/16 | [
"https://Stackoverflow.com/questions/27982333",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4418039/"
] | Two possible answers
1. **You Can't:** Because you can't pass objects from one activity to another (until and unless it is Parcelable) in android
2. **You Can:** You can use `shared preferences` to pass primitive data from one activity to another OR you can use single instance (singleton) class to set/get `objects` f... | You can create a class that extends Application class and create a singleton of that object inside it. This way you can access this object in all of your activity.
```
public class GlobalClass extends Application {
NetworkHandler nH = null;
public NetworkHandler getNetworkHandler() {
if (nH == nu... |
15,896,699 | I am trying to show the following in the ER diagram:
```
There are instructors and courses, a course is taught by only one instructor
whereas an instructor can give many courses.
```


I have attached the ER diagram for this in Chen notation and also using Crow Notation you can use either of them... | I don't think the other answer is fully correct.
I would say that one *should* use arrows, and one should use a notation that gives a meaningful name to *each direction* of the relationship. In this case it will be "teaches" in one direction, and "is taught by" in the other. Either use arrows next to the names or put... |
9,486,039 | I have many entities that have the `IsActive` property. For internal reasons, I need all those fields to be nullable. On the other hand, for every entity I may have to do a double test in tens of places in the application:
(null are treated as true)
```
if (language.IsActive == null || language.IsActive.value)
```
... | 2012/02/28 | [
"https://Stackoverflow.com/questions/9486039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/457500/"
] | If your property is `Nullable<>` and a `null` value means `true`, you could use this instead of an explicit null check:
```
language.IsActive.GetValueOrDefault(true);
``` | Why don't you just hide this implementation detail in the getter:
```
private bool? _IsActive;
public bool IsActive { get { return !_IsActive.HasValue ||_IsActive; } }
```
EDIT: After realizing the properties are generated and can't be modified
You could declare a new type, called ThreeValBool, which is essentially... |
54,238,142 | I have a dataframe that I would like to delete rows from, based on a value in a specific column.
As an example, the dataframe appears something like this:
```
a b c d
1 1 2 3 0
2 4 NA 1 NA
3 6 4 0 1
4 NA 5 0 0
```
I would like to remove all rows with a value greater than 0 in column d. I hav... | 2019/01/17 | [
"https://Stackoverflow.com/questions/54238142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10743287/"
] | We need to select the rows where `d` is not greater than 0 OR there is `NA` in `d`
```
df[with(df, !d > 0 | is.na(d)), ]
# a b c d
#1 1 2 3 0
#2 4 NA 1 NA
#4 NA 5 0 0
```
Or we can also use `subset`
```
subset(df, !d > 0 | is.na(d))
```
or `dplyr` `filter`
```
library(dplyr)
df %>% filter(!d > 0 | is... | If u add a `|`all rows that has a `NA` will match. The condition `!df$d > 0` will get executed for those in `d` that are not a `NA`. So I think you were looking for:
```
df[is.na(df$d) | !df$d > 0, ]
```
Wheras, the below wont include the rows that has a `NA` in column `d` and that does not match the condition `!df... |
12,574 | I need to delete one or multiple rows from my table with where condition.
Eg: 1. Delete from search where id=1 and customerid=2
EG: 2. Delete from search where customerid=2
After some browsing found this code and added to my model
```
public function deleteByCondition($id,$uid)
{
$table = $this->getMainTable()... | 2014/01/02 | [
"https://magento.stackexchange.com/questions/12574",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/2552/"
] | If we need to create an order then ask the user for payment, we will place the order using the Purchase Order method and send the customer a PayPal invoice. Once we receive the payment we send the order confirmation email. | The way that Magento would want you to do this is to prepare the order for them. In EE 1.12+ you can see and edit items in a customer's shopping cart. You can also edit their default billing and shipping addresses for them.
In essence, with no code or an extension required, you have the ability to prepare a customer's... |
11,488,988 | When I try to compile [this program](http://ideone.com/7KfWn), I get an "unreachable statement" error in line 21:
```
import java.util.*;
import java.io.*;
import java.nio.file.*;
import java.lang.StringBuilder;
class FilePrep {
public static void main(String args[]) {
}
public String getStringFromBuffer(... | 2012/07/15 | [
"https://Stackoverflow.com/questions/11488988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1267125/"
] | When the `return` statement is executed, the method relinquish control to its caller. That is why the `println` will not run; that's why the compiler complains.
Unreachable statements are certain and reliable indicators of a logical error in your program. It means that you put in statements that will not be executed, ... | The `return` statement always should be at the end or last line of the definition block. If you keep any statements after the `return` statement those statements are unreachable statements by the controller. By using `return` statement we are telling control should go back to its caller explicitly.
For example
```
pu... |
74,851 | the setting premises are explained in this other question [Survival of an Industrial Revolution city after being transported to a fantasy world](https://worldbuilding.stackexchange.com/questions/73534/survival-of-an-industrial-revolution-city-after-being-transported-to-a-fantasy-w)
What I had in mind today is this: on... | 2017/03/21 | [
"https://worldbuilding.stackexchange.com/questions/74851",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/34401/"
] | There's a problem here: unless gravity is very different in this world you're not going to feel much lighter. you don't just experience gravity from the things directly bellow you. You're also going to get pulled towards the rest of the planet. At best gravity would be a tiny tiny tiny bit different at the center of th... | Replace the area with some other fluid that is denser than normal air. This will increase buoyancy and create the illusion that things are much lighter than they are. |
13,826,351 | JQuery is kind of new to me and I set up a search suggestions system using ajax that works great but works pretty slow due to the onKeyUp limitation. After some reading I found that I can set a timer on the event. So what I am trying to do is set a timer on the 'prod-name-input' input field onKeyUp event, so that it is... | 2012/12/11 | [
"https://Stackoverflow.com/questions/13826351",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1316524/"
] | The fastest way would actually be to use the keydown event. (it acts on the key being down rather than being released which is always sooner.)
```
var timer;
$(".prod-name-input").keydown(function(){
var self = this;
clearTimeout(timer);
timer = setTimeout(function(){
$(".smart-suggestions").load('... | There is a throttle function in underscore.js that handles this scenario. You can see their [annotated source](http://underscorejs.org/docs/underscore.html#section-62) for exact code, or if you use underscore.js in your project, some usage documentation [here](http://underscorejs.org/#throttle) |
3,782,197 | I have been trying to set up a DatabaseConnectionPool for a web app for the last couple of days with no success. I have read the relevant sections of the Tomcat docs and a great deal around the subject and think I'm doing everything right, but obviously not because I keep on getting the following error:
```
Cannot cre... | 2010/09/23 | [
"https://Stackoverflow.com/questions/3782197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2106959/"
] | In your configuration context.xml for the webapp you have to change user="root" by username="root" | In my case (MySql v.5.7) I got this error due to creation of the user via GRANT command:
```
GRANT ALL PRIVILEGES ON *.* TO myuser@localhost IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
```
Using CREATE command instead, resolved the above error:
```
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRAN... |
19,982,113 | I have the following extension method to find an element within a sequence, and then return two `IEnumerable<T>`s: one containing all the elements before that element, and one containing the element and everything that follows. I would prefer if the method were lazy, but I haven't figured out a way to do that. Can anyo... | 2013/11/14 | [
"https://Stackoverflow.com/questions/19982113",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8368/"
] | You can use the `Lazy` object to ensure that the source sequence isn't converted to an array until one of the two partitions is iterated:
```
public static PartitionTuple<T> Partition<T>(
this IEnumerable<T> sequence, Func<T, bool> partition)
{
var lazy = new Lazy<IEnumerable<T>>(() => sequence.ToArray());
... | Generally, you just return some object of your custom class, which implements `IEnumerable<T>` but also provides the results on enumeration demand only.
You can also implement `IQueryable<T>` (inherits IEnumerable) instead of `IEnumerable<T>`, but it's rather needed for building reach functionality with queries like t... |
62,715,853 | I want to create specific version of redis to be used as a cache. Task:
* Pod must run in web namespace
* Pod name should be cache
* Image name is lfccncf/redis with the 4.0-alpine tag
* Expose port 6379
* The pods need to be running after complete
This are my steps:
* `k create ns web`
* `k -n web run cache --image... | 2020/07/03 | [
"https://Stackoverflow.com/questions/62715853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11568656/"
] | You should not use `sleep` to keep a redis pod running. As long as the redis process runs in the container the pod will be running. | The best way to go about it is to take a stable helm chart from <https://hub.helm.sh/charts/stable/redis-ha>. Do a helm pull and modify the values as you need.
Redis should be definde as a Statefulset for various reasons. You could also do a
```
mkdir my-redis
helm fetch --untar --untardir . 'stable/redis' #makes a di... |
341,551 | I think the approach can be with `adjustbox` but not sure.
Pseudocode:
* *If height overfull, turn the image 90 degree clockwise, apply all images the width constraint now*
* *Do not pass max width (= `\linewidth`) in any case*.
In other words, preudocode
* If the image is too high originally, rotate it 90 so the ... | 2016/11/29 | [
"https://tex.stackexchange.com/questions/341551",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/13173/"
] | Here is a general approach that you can follow:
```
\documentclass{article}
\usepackage{graphicx}
\newsavebox{\imgbox}
\begin{document}
\begin{figure}
\savebox{\imgbox}{% Store image in a box
\includegraphics[height=<h>,width=<w>,keepaspectratio]{example-image}}%
\ifdim\ht\imgbox > <H>
% Do something to... | Does the following do what you want? The first normal `\includegraphics` produces an overfull `\vbox` (visible by the empty first page since the image is shifted to the second one), whereas `\includegraphicsoptrotate` rotates the image (and shrinks it to `\textwidth`).
```
\documentclass{article}
\usepackage{graphicx... |
1,490,286 | Consider the infinite series $\; \displaystyle \sum\_{n=0}^{\infty} \left(\frac{1}{ 4}\right)^{\!n/2}.$
Find the sum of this series.
Formula for calculating sum of the series is:
$$\frac{a}{1 - r}$$
Where Riemann sum must either look as:
$\sum\_{n=0}^{\infty} a \cdot r^n\;\;$ or $\;\;\; \sum\_{n=1}^{\infty} a \cdo... | 2015/10/21 | [
"https://math.stackexchange.com/questions/1490286",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/250002/"
] | Alternately use index laws:
$$\sum\_{n=0}^{\infty} \left(\frac{1}{ 4}\right)^{\frac{n}{2}}=\sum\_{n=0}^{\infty} \left(\left(\frac{1}{ 4}\right)^{\frac{1}{2}}\right)^n$$
$$=\sum\_{n=0}^{\infty} \left(\frac{1}{2}\right)^n$$ | I think it is $$\sum (\frac{1}{4})^{\frac{n}{2}}=\sum (\frac{1}{4})^{\frac{2n}{2}}+\sum (\frac{1}{4})^{\frac{2n+1}{2}}=\sum (\frac{1}{4})^{\frac{2n}{2}}+\sum (\frac{1}{4})^{\frac{2n}{2}}\times \frac{1}{2}$$ |
10,434,686 | I am trying to insert a post with this code:
```
$my_post = array(
'post_type' => "essays",
'post_title' => 'TEST 3',
//'post_content' => $content,
'post_status' => 'draft',
'post_author' => 1,
//'post_category' ... | 2012/05/03 | [
"https://Stackoverflow.com/questions/10434686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1055503/"
] | Use the `wp_set_object_terms()` function:
<http://codex.wordpress.org/Function_Reference/wp_set_object_terms>
```
wp_set_object_terms($post_id , $arrayoftags, $name_of_tag_taxonomy, false);
```
Good luck | tags and post categories ought to be entered as an array, even if it's only one. So `'tags_input' => 'TQM,tag'` should be `'tags_input' => array('TQM,tag')` |
1,875,885 | I'm using Elixir in a project that connects to a postgres database. I want to run the following query on the database I'm connected to, but I'm not sure how to do it as I'm rather new to Elixir and SQLAlchemy. Anyone know how?
`VACUUM FULL ANALYZE table`
**Update**
The error is: "UnboundExecutionError: Could not loc... | 2009/12/09 | [
"https://Stackoverflow.com/questions/1875885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/183355/"
] | Dammit. I knew the answer was going to be right under my nose. Assuming you setup your connection like I did.
```
metadata.bind = 'postgres://user:pw@host/db'
```
The solution to this was as simple as
```
conn = metadata.bind.engine.connect()
old_lvl = conn.connection.isolation_level
conn.connection.set_isolation... | If you have access to SQLAlchemy session, you can execute arbitrary SQL statements via its `execute` method:
```
session.execute("VACUUM FULL ANALYZE table")
``` |
26,403,861 | I want to send simple email with no attachment using default email application.
I know it can be done using Process.Start, but I cannot get it to work. Here is what I have so far:
```
string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}", "to@user.com", "Subject of message", "This is a body of a message");
... | 2014/10/16 | [
"https://Stackoverflow.com/questions/26403861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1539189/"
] | You need to do this :
```
string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}", "to@user.com", "Subject of message", "This is a body of a message");
mailto = Uri.EscapeUriString(mailto);
System.Diagnostics.Process.Start(mailto);
``` | I'm not sure about `Process.Start()` this will probably always only open a mail message in the default Mail-App and not send it automatically.
But there may be two alternatives:
* Send directly via [SmtpClient](https://stackoverflow.com/questions/9201239/send-e-mail-via-smtp-using-c-sharp) Class
* using [Outlook.Int... |
46,161,918 | I noticed when in vi mode in bash (i.e. the mode enabled with "set -o vi"), that some commands, such as "diw", that work in vim but not in vi, don't work on the bash command line. Is there an easy way to configure bash so that its keybindings will support vim commands? I would like to be able to enter vim commands on t... | 2017/09/11 | [
"https://Stackoverflow.com/questions/46161918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3302997/"
] | The best way of doing this that I know of would be to use [athame](https://github.com/ardagnir/athame).
It can be a surprisingly powerful experience in some cases. I particularly like it for interacting with a repl.
>
> Athame patches your shell to add full Vim support by routing your keystrokes through an actual Vim... | Teach vi-command-mode `diw` to any software that uses readline (such as bash) by adding this to your ~/.inputrc:
```
set keymap vi-command
"diw": "bde"
``` |
827,326 | What's a good hex editor/viewer for the Mac? I've used xxd for viewing hexdumps, and I think it can be used in reverse to make edits. But what I really want is a real hex editor. | 2009/05/05 | [
"https://Stackoverflow.com/questions/827326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17188/"
] | To view the file, run:
```
xxd filename | less
```
To use Vim as a hex editor:
1. Open the file in Vim.
2. Run `:%!xxd` (transform buffer to hex)
3. Edit.
4. Run `:%!xxd -r` (reverse transformation)
5. Save. | 1. Open file with Xcode and press Command + Shift + J
2. Right click file name in
left pane
3. Open as -> Hex |
13,842,560 | I want an hist and a density on the same plot, I'm trying this:
```
myPlot <- plot(density(m[,1])), main="", xlab="", ylab="")
par(new=TRUE)
Oldxlim <- myPlot$xlim
Oldylim <- myPlot$ylim
hist(m[,3],xlim=Oldxlim,ylim=Oldylim,prob=TRUE)
```
but I can't access myPlot's xlim and ylim.
Is there a way to get them fro... | 2012/12/12 | [
"https://Stackoverflow.com/questions/13842560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/512225/"
] | Using `par(new=TRUE)` is rarely, if ever, the best solution. Many plotting functions have an option like `add=TRUE` that will add to the existing plot (including the plotting function for histograms as mentioned in the comments).
If you really need to do it this way then look at the `usr` argument to the `par` functio... | I think the best solution is to fix them when you plot your density.
Otherwise hacing in the code of plot.default (plot.R)
```
xlab=""
ylab=""
log =""
xy <- xy.coords(x, y, xlab, ylab, log)
xlim1 <- range(xy$x[is.finite(xy$x)])
ylim1 <- range(xy$y[is.finite(xy$y)])
```
or to use the code above to generate xlim and ... |
10,247,279 | I have latitude, longitude and a radius. Can you please help me in finding the another latitude and longitude from given points (latitude and longitude) and radius. | 2012/04/20 | [
"https://Stackoverflow.com/questions/10247279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1346155/"
] | %comspec% /k runs *another* command prompt, and then keeps cmd.exe around. Until that cmd.exe returns, your batch file won't continue.
Even if you replace /k with /c (which doesn't keep cmd.exe around), it won't work, because the environment variables from the new command prompt aren't preserved in this one.
You simp... | I solved it in another way. I used the full path of the tf.exe. And it works in the command prompt.
The call answer doens't worked for me. |
238,480 | In our solar system, Europa, a moon of Jupiter, has a large and warm ocean under the icy crust. However, due to it having a rocky core and the icy crust, there is no light in the ocean. I want to make writing life, society, and technology easier by making natural light sources on Europa exist long before life evolved.
... | 2022/11/23 | [
"https://worldbuilding.stackexchange.com/questions/238480",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/37911/"
] | **Cracks**
[](https://i.stack.imgur.com/sBkR4.jpg)
<https://www.nasa.gov/jpl/europas-stunning-surface>
<https://space.stackexchange.com/questions/2226/what-causes-the-cracks-on-europa-to-form>
The ice crust of Europa has cracks. Big old ones, small new ones. These crack... | I think it really depends on what kind of an atmosphere you want to create for your world
As previous comments have suggested, you could use bioluminescence to have life.
If you want to, you could use the fact that all materials emit light assuming they are above 0 Kelvin. This would create infrared light rather than v... |
455,191 | I know this question is asked but there is no solution for me. I tried unlocker, fileassassin, lockhunter and commnd prompt to delete file but it didn't work. | 2012/07/30 | [
"https://superuser.com/questions/455191",
"https://superuser.com",
"https://superuser.com/users/142420/"
] | Boot your system with a Linux live CD then you should be able to delete it.
If you don't have a CD burner you can try using a flash drive with [YUMI](http://www.pendrivelinux.com/yumi-multiboot-usb-creator/). | Or you can reboot the system to force delete a file, here are the steps:
Step1: Press Win logo key + R and then type: MSConfig.
Step2: Now, turn to Boot tab and then tick Safe Boot from Boot Options section.
Step3: Once you click on the OK button, the system will ask you to restart the system.
After successfully b... |
10,390 | G'day,
Why has the meaning of community-wiki shifted towards "[a way to stop your post being closed](https://meta.stackexchange.com/questions/11740/what-are-community-wiki-posts-on-stack-overflow)" from the original intent of allowing almost anyone to edit the question and provide answers so that the question itself b... | 2009/07/28 | [
"https://meta.stackexchange.com/questions/10390",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/2974/"
] | Here's a concrete example of why...
[Common-mistakes questions](https://stackoverflow.com/questions/tagged/common-mistakes)
There were a few of these asked yesterday. They're entertaining, and potentially even useful for programmers new to the target language.
They're also *huge* rep-farms. Sure, some people actuall... | Taking the existing points further; yes, this (the (ab)use of CW to mean "look the other way, please") is a major problem on SU. I'd be tempted to wonder whether a zero-tolerance approach on SU might help stabilise things (combined with a none-too-forgiving purge of the existing questions). i.e. if it isn't an actual s... |
4,321,456 | Is there a way to get `find` to execute a function I define in the shell?
For example:
```
dosomething () {
echo "Doing something with $1"
}
find . -exec dosomething {} \;
```
The result of that is:
```
find: dosomething: No such file or directory
```
Is there a way to get `find`'s `-exec` to see `dosomething`... | 2010/12/01 | [
"https://Stackoverflow.com/questions/4321456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/303896/"
] | To provide additions and clarifications to some of the other answers, if you are using the bulk option for `exec` or `execdir` (`-exec command {} +`), and want to retrieve all the positional arguments, you need to consider the handling of `$0` with `bash -c`.
More concretely, consider the command below, which uses `ba... | Not directly, no. Find is executing in a separate process, not in your shell.
Create a shell script that does the same job as your function and find can `-exec` that. |
2,586,530 | All,
I am using Zend Framework and Zend\_Session to do global session management for my application. I plan to clear all sessions on logout and hence am using the following code:
```
if($this->sessionExists())
{
$this->destroy();
}
```
But it seems like it's not doing a good job.. I am getting an error:
```
... | 2010/04/06 | [
"https://Stackoverflow.com/questions/2586530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/229853/"
] | [XmlPullParser](http://developer.android.com/intl/de/reference/org/xmlpull/v1/XmlPullParser.html) is a streaming pull XML parser and should be used when there is a need to process quickly and efficiently all input elements.
You can try something like this:
```
private void pullParserSample(FileInputStream xml) {
... | Look at implementing a org.xml.sax.ContentHandler and sending it to an org.xml.sax.XMLReader.
These classes are bundled with Android SDK. This is a 'forward parser' approach which involves your ContentHandler being shown each XML element (tag, attribute, text) as the document is processed from start to end. The forwar... |
59,362,344 | I am reading this function and not at all understanding how this can work.
```
() => console.log(i) || Promise.resolve(i++ > 3)
```
Can a kind soul explain how a console.log can participate in a conditional?
I can even trans-pile this in typescript. | 2019/12/16 | [
"https://Stackoverflow.com/questions/59362344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/496136/"
] | `console.log(...)` returns `undefined`, which is falsy; so the expression after the or `||` operator will always execute. This is just shorthand for:
```
() => {
console.log(i);
return Promise.resolve(i++ > 3);
}
``` | [`console.log(...)`](https://developer.mozilla.org/en-US/docs/Web/API/Console/log) returns `undefined`, which evaluates to a [falsy value](https://developer.mozilla.org/en-US/docs/Glossary/Falsy). |
35,307 | The following situation is probably familiar for many working people:
>
> * **Boss**: "We're gonna do this project like A, B, E, D"
> * **Everyone**: (stumped) "Uh, what about C? Why is E before D? That's not how the alphabet works?"
> * **Boss**: (realizing he might have made a mistake) "Well, yeah, we don't have th... | 2014/10/23 | [
"https://workplace.stackexchange.com/questions/35307",
"https://workplace.stackexchange.com",
"https://workplace.stackexchange.com/users/14442/"
] | There's a time for perfectionism and there's a time for doing what you're told.
You have a boss, part of that person's responsibility is to direct you in your duties. One of the aspects of this is the schedule. You can certainly continue doing the responsible thing by bringing up things you believe need to addressed.... | >
> The real problem is me not being able to do my job in a crappy way, even though that's what I'm being paid for
>
>
>
I'm not going to suggest a change of job, as the thing here is your feelings, not the current position.
You need to reconcile yourself that you work for a business, there is always a compromise... |
52,705,061 | In my React Native project, Gradle build gave me this error :
```
> Task :app:processDebugGoogleServices
Parsing json file: /Users/valentinmourot/ODE/Dev/mobile-app/android/app/google-services.json
/Users/valentinmourot/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/234563a256b75883624274d32dc30b63/res... | 2018/10/08 | [
"https://Stackoverflow.com/questions/52705061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6111343/"
] | Have you tried running `gradlew clean` in the `android/` dir?
Sometimes I get this error and doing this fixes it, although I don't know what causes it. | update to:
```
api "com.android.support:appcompat-v7:28.0.0"
```
while there are further outdated versions. |
69,108,369 | I have an array of floats and I need to return the index of the N smallest values. What I'm thinking (if there's a better way, please sing out) is to convert the array to an array of tuples where the [0] entry is the original float and the [1] entry is the index in the array.
Then I sort the array by the [0] entries a... | 2021/09/08 | [
"https://Stackoverflow.com/questions/69108369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/509627/"
] | If you would like to get the indices of the N smallest values you can use the argpartition funtion such as:
```
import numpy as np
N = 3
array = np.array([0.0, 0.1, 0.2, 3.0, 0.4, 0.5, 0.1])
smallest_indices = np.argpartition(array, N)[:N]
```
So for (say) N = 3 the output would be:
```
>>> print(smallest_indices)... | You could do it with enumerate and sorted w/a key. Or you can use numpy like in [this post.](https://stackoverflow.com/questions/6910641/how-do-i-get-indices-of-n-maximum-values-in-a-numpy-array)
```
n = 4
f = [2.0,1.0,3.0,4.0,5.0]
[n[0] for n in sorted([(c,x) for c,x in enumerate(f)], key=lambda x:x[1], reverse=True)... |
34,067,009 | I have a `UICollectionView` in my view controller. It has been setup and its working fine.
I am trying to zoom a cell when a button inside the cell itself has been pressed.
The code I have zooms the cell however, I cannot find the way to force the cell selected to go to the front of the other cells.
Right now the cel... | 2015/12/03 | [
"https://Stackoverflow.com/questions/34067009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2075848/"
] | It seems you have the order of things mixed up a little.
From the docs :
>
> Moves the specified subview so that it appears on top of its siblings.
>
>
> func bringSubviewToFront(\_ view: UIView)
>
>
> Parameters
>
>
> view - The subview to move to the front.
>
>
> This method moves the specified view to ... | To bring cell to the front. You can remove cell then after add again: `
`mCollectionView.reloadData()
mCollectionView.performBatchUpdates(nil, completion: {
(result) in
var indexPath = IndexPath(row: 0, section: 0)
var cell = mCollectionView.cellForItem(at: indexPath)
cell.removeFromSuperview()
mCollectionView.ad... |
3,105,258 | I'm currently using boost-python to wrap a small C++ library and make it usable from Python. However, I'd like to stop using boost (mainly due to reasons relating to building/linking). So what other options are there?
Is there something that's equally convenient to use? | 2010/06/23 | [
"https://Stackoverflow.com/questions/3105258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34996/"
] | Take a look at [SWIG](http://www.swig.org/). | [Cython](http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html)'s syntax is very Pythonic, breaking the rules only where necessary. |
19,246,258 | I have here my code. Data on the database are filtered by the title, how can i filter data by title or author? I think it is on these lines of codes on Catalogue.java:
```
dataAdapter.setFilterQueryProvider(new FilterQueryProvider() {
public Cursor runQuery(CharSequence constraint) {
return dbHe... | 2013/10/08 | [
"https://Stackoverflow.com/questions/19246258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2858096/"
] | ```
@Override
public Cursor runQuery(CharSequence constraint) {
Cursor cur = null;
database.openDataBase();
if(constraint!=null){
cur = database.selectDataWithConstrain(constraint.toString());
}
return cur;
}
```
using this c... | ```js
public Cursor fetchdatabyfilter(String inputText, String filtercolumn) throws SQLException {
Cursor row = null;
String query = "SELECT * FROM " + dbTable;
if (inputText == null || inputText.length() == 0 ) {
row = sqlDb.rawQuery(query, null);
} else {
... |
13,257,379 | How can I open `vi` editor from my java application?
I have already tried this
```
Process p = new ProcessBuilder("xterm","-e","vi /backup/xyz/test/abc.txt").start();
int exitVal = p.waitFor();
System.out.println("Exited with error code "+exitVal);
```
But this opens `vi` in a new terminal. **I want the vi edito... | 2012/11/06 | [
"https://Stackoverflow.com/questions/13257379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1803996/"
] | I was gonna give you the solution but I better explain you about the lookbehind modifier.
In regex each time you "match" a `h` for example, that `h` will add 1 to the pointer of where the regex is at the moment so you dont want to "add" nothing to the pointer. You just want to look if the `from` is preceded by a `;\s\... | There is a concept called (negative) lookbehind, which asserts that your current position is (not) preceded by certain things. I guess, in this case I would go with a positive lookbehind, and assert that `from` is preceded by a the start of the string, a line-break or a `;`:
```
preg_match('|(?<=^|;)from:(.*?);|m', $s... |
3,731,756 | Let $(\Omega,\mathcal{F},P)$ be a probability space and $\mathcal{H}\subset\mathcal{G}\subset\mathcal{F}$ two $\sigma$-algebras. We know from Jensen's inequality, that for $X\in L^2(\Omega,\mathcal{F},P)$
$$
\mathbb{E}[|\mathbb{E}[X|\mathcal{H}]|^2]\leq\mathbb{E}[|X|^2].
$$
Can this be generalized to an inequality lik... | 2020/06/23 | [
"https://math.stackexchange.com/questions/3731756",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/691199/"
] | The easiest way (in my opinion) to see that the matrix is positive definite is to check two things: is the matrix symmetric (yes and easily checkable) and are all the eigenvalues positive (yes, but less obvious).
You can quickly see that the eigenvalues are all positive using the Gershgorin circle theorem (<https://en... | Here is an expanded proof that the form is positive definite using Gaussian elimination. Using simultaneous row-and-column operations, we have
$$
\pmatrix{25 & 15 & -5 \\
15 & 18 & 0 \\
-5 & 0 & 11} \leadsto
\pmatrix{25&0&-5\\0&9&3\\-5 & 3 & 12
}
\leadsto
\pmatrix{25&0&0\\0&9&3\\0 & 3 & 12
}
\leadsto
\pmatrix{25&0&0\\0... |
3,282,103 | I have been trying to figure this out for quite sometime (reading online blogs and articlaes), but so far unsuccessful.
What are delegates? What are Lambda Expressions? Advantages and disadvantages of both? Possible best practice of when to use one or the other?
Thanks in advance. | 2010/07/19 | [
"https://Stackoverflow.com/questions/3282103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/279521/"
] | Delegates are methods that you can use as variables, like strings etc. For example you can declare a delegate method with one argument:
```
delegate void OneArgumentDelegate(string argument);
```
It doesn't do anything, much like an interface. If you have a method in any class with one argument like this:
```
void S... | **Delegate** is an object that hold a reference to a function. Several different delegates may point to the same function. A *delegate*'s type defines the footprint of a function it may point to.
**Lambda expression** is a function that doesn't have name. The only way to execute this function is to have a *delegate* p... |
3,826,600 | Does anyone know how to do a polymorphic association in `Mongoid` that is of the relational favor but not the embedding one.
For instance this is my `Assignment` model:
```
class Assignment
include Mongoid::Document
include Mongoid::Timestamps
field :user
field :due_at, :type => Time
referenced_in :assign... | 2010/09/29 | [
"https://Stackoverflow.com/questions/3826600",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/126749/"
] | From Mongoid Google Group it looks like this is not supported. Here's the [newest relevant post](http://groups.google.com/group/mongoid/browse_thread/thread/63acbea4780fedab/3393314de457a95a?lnk=gst&q=polymorphic#3393314de457a95a) I found.
Anyway, this is not to hard to implement manually. Here's my polymorphic link c... | Rails 4+
========
Here's how you would implement **Polymorphic Associations** in *Mongoid* for a `Comment` model that can belong to both a `Post` and `Event` model.
The `Comment` Model:
```rb
class Comment
include Mongoid::Document
belongs_to :commentable, polymorphic: true
# ...
end
```
`Post` / `Event` Mo... |
28,181,395 | I have the following regular expression:
```
>>> re.findall(r'\r\n\d+\r\n',contents)[-1]
'\r\n1621\r\n'
>>> re.findall(r'\r\n\d+\r\n',contents)[-1].replace('\r','').replace('\n','')
'1621'
```
How would I improve the regular expression such that I don't need to use the python `replace` methods?
Note that the digit ... | 2015/01/27 | [
"https://Stackoverflow.com/questions/28181395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/651174/"
] | Simply use parenthesis:
```
re.findall(r'\r\n(\d+)\r\n',contents)[-1]
```
That way you match the given pattern and only get the parenthesis content in `findall` result. | You could use look-ahead and look-back assertions:
```
re.findall(r'(?<=\r\n)\d+(?=\r\n)',contents)[-1]
``` |
12,294 | We all know the limits of a married person.We all know the definition of cheating in Buddhism.
But Buddhism existed in a time Porn did not exist.
So if a married person watch porn is it cheating? | 2015/10/31 | [
"https://buddhism.stackexchange.com/questions/12294",
"https://buddhism.stackexchange.com",
"https://buddhism.stackexchange.com/users/7141/"
] | Technically, watching porn doesn't break the 3rd precept, but it weakens it. In other words, it weakens the merits you gain by keeping to the precept apart from accumulating bad karma. | Donating porn/nude arts, women to men for evil purposes, bulls for cows to breed, alcohol and arranging dances(probably sexually arousing) are considered evil charity which are sinful. So clearly porn is not something good but sinful whether or not it falls under physically cheating. |
21,482,840 | Can somehow an invalid System.Guid object be created in .Net (Visual Basic or C#). I know about Guid.Empty method but it is not what I am searching for. For example with invalid symbols or spaces or being too short or longer than an valid one etc.
Thanks! | 2014/01/31 | [
"https://Stackoverflow.com/questions/21482840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1752845/"
] | >
> Can a Guid be created with invalid symbols or spaces or being too short or longer than an valid one etc?
>
>
>
No - a Guid is just a 128-bit number that can be *represented* in 5 groups of hexadecimal numbers. There's no way for the string representation of a `Guid` to contain anything other than 32 hex charac... | You should be able to do this using the [constructor](http://msdn.microsoft.com/en-us/library/96ff78dc%28v=vs.110%29.aspx) for Guid:
```
Guid badGuid = new Guid("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
```
If this throws an exception then it means the runtime will not allow you to construct an invalid Guid, and you don'... |
45,393,432 | In This Code When I Select the output text I see this:
[](https://i.stack.imgur.com/FKQsC.jpg)
How can I fix it?
```css
p {
font-family: 'Cairo', sans-serif;
line-height: 15px;
}
```
```html
<link href="https://fonts.googleapis.com/css?famil... | 2017/07/29 | [
"https://Stackoverflow.com/questions/45393432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8351459/"
] | I compared my code with this example <http://machinelearningmastery.com/text-generation-lstm-recurrent-neural-networks-python-keras/>
by carefully block out line-by-line and run again. After a whole day, finally, I found what was wrong.
When making char-int mapping, I used
```
# title_str_reduced is a string
chars =... | assume you have a code like this:
```
model = some_model_you_made(input_img) # you compiled your model in this
model.summary()
model_checkpoint = ModelCheckpoint('yours.h5', monitor='val_loss', verbose=1, save_best_only=True)
model_json = model.to_json()
with open("yours.json", "w") as json_file:
json_file.writ... |
59,616,212 | ```
namespace LEARNING
{
public class Human
{
public string nameOne;
public string nameTwo;
public int ageOne;
public bool hasagetwo;
public int ageTwo;
public bool isalive;
public void Info()
{
Console.WriteLine("Name =" + nameOne + "... | 2020/01/06 | [
"https://Stackoverflow.com/questions/59616212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12662959/"
] | You're trying to set object property values, but you are doing it through the class by mistake
```
Human humanOne = new Human();
Human.nameOne = "Adrian";
Human.hasagetwo = true;
// ....
Human.Info();
```
should be
```
Human humanOne = new Human();
humanOne... | Change
```
Human.nameOne = "Adrian";
Human.hasagetwo = true;
Console.WriteLine(humanOne.nameOne);
Human.Info();
```
to
```
humanOne.nameOne = "Adrian";
humanOne.hasagetwo = true;
Console.WriteLine(humanOne.nameOne);
humanOne.Info();
```
You are trying to assign instance variables... |
1,700,861 | Is there a closed form results for this integral
$$
\int\_{0}^{\pi}\frac{1}{a-cos\theta}d\theta
$$
where a > 1. | 2016/03/16 | [
"https://math.stackexchange.com/questions/1700861",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/288511/"
] | With residue calculus we can evaluate it without any difficulty.
Setting $z = e^{i\theta}$ we have
$$\cos\theta = \frac{1}{2}(z + z^{-1})$$
So
$$\frac{1}{2}\int\_0^{2\pi}\frac{-i}{z\left(a - \frac{1}{2}\left(z + \frac{1}{z}\right)\right)}\ \text{d}z$$
We denote
$$f(z) = \frac{-i}{z\left(a - \frac{1}{2}\left(z + \... | Two methods have already been given on paths to obtain the integral's value. It is fairly evident that the general integral can take on the form
$$\int \frac{d\theta}{a - \cos\theta} = - \frac{2}{\sqrt{1-a^2}} \, \tanh^{-1}\left(\frac{(a+1) \, \tan\left(\frac{\theta}{2}\right)}{\sqrt{1-a^2}} \right).$$
For the limits g... |
54,419,928 | I've got hundreds files that are named with the following scheme:
XX - YY Title.ext
However, they don't always sort properly because XX and YY can be 1 or 2 digit numbers. I would like to rename the files such that XX and YY are always 2 digits by adding a leading zero if necessary.
For example, I'm currently gettin... | 2019/01/29 | [
"https://Stackoverflow.com/questions/54419928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5321658/"
] | For completeness: this can also be solved directly on the (UNIX) shell with the `sort` from GNU coreutils:
```sh
$ cat dummy.txt
1 - 1 BillyBob.ext
1 - 10 Jimmy.ext
1 - 2 Stewy.ext
10 - 1 Cletus.ext
2 - 1 Homer.ext
$ sort --field-separator=- -k 1n -k 2n <dummy.txt
1 - 1 BillyBob.ext
1 - 2 Stewy.ext
1 - 10 Jimmy.ext
2... | Try this Perl one-liner
```
perl -lne ' s/(\d+)\s-\s(\d+)\s+(\S+)/sprintf("%02d-%02d %s",$1,$2,$3)/ge; $kv{$_}=1 ; END { print join("\n",sort keys %kv) } '
```
with inputs
```
$ cat notorious.txt
1 - 1 BillyBob.ext
1 - 10 Jimmy.ext
1 - 2 Stewy.ext
10 - 1 Cletus.ext
2 - 1 Homer.ext
$ perl -lne ' s/(\d+)\s-\s(\d+)\s... |
60,953,810 | I'm using `wp_enqueue_style` to enqueue [this Google Font file](https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,700;1,400&family=Neuton:ital,wght@0,300;0,400;0,700;1,400&display=swap). Here is my code:
`wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis.com/css2?family=Montserrat:i... | 2020/03/31 | [
"https://Stackoverflow.com/questions/60953810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4630362/"
] | This actually has to do with PHP and the way it parses query parameters.
<https://www.php.net/manual/en/function.parse-str.php>
In any case, the current workaround is to pass "null" to the version parameter to have WordPress not add a "ver" to the URL.
```
wp_enqueue_style( 'google-fonts', 'https://fonts.googleapis... | The same query parameter is defined twice (`family`) so WordPress removes one. This is a normal thing in a typical context: if there is a repeated query parameter, only the last one is used. WordPress makes use of this "rule" when enqueuing the URL.
I can't tell you why Google Fonts changed the syntax from the `|` sep... |
444,845 | An open disk with radius $r$ centered at $\mathbf{p}$ is $D(\mathbf{p}, r)=\{\mathbf{q} \mid d(\mathbf p, \mathbf q) < r\}$, and the Minkowski sum of two sets $A$ and $B$ is $A \oplus B=\{\mathbf p + \mathbf q \mid \mathbf p \in A, \mathbf q \in B \}$.
How can you show that $D(\mathbf{a}, r\_a) \oplus D(\mathbf{b}, r\... | 2013/07/16 | [
"https://math.stackexchange.com/questions/444845",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/31941/"
] | To show $A = B$ it is usually the easiest to split into two parts $A \subseteq B$ and $A \supseteq B$.
First, if $p \in D(a,r\_a)$ and $q \in D(b,r\_b)$ then $p + q \in D(a+b, r\_a+r\_b)$. This is simple using the triangle inequality: $$|(p+q)-(a+b)| < |p-a| + |q-b|.$$
Secondly, if $u \in D(a+b, r\_a + r\_b)$, then w... | I would take the following route. Hopefully it is more intuitive.
It is clear that $$D(b, r\_b)\oplus D(0, r\_0)=D(b, r\_b+r\_0)$$
and that
$$a+D(b, r)=D(a+b, r).$$
(Here $a+ \text{"some set"}$ denotes translation). So we write
$$D(a, r\_a)=a+D(0, r\_a).$$
Therefore
\begin{equation}\begin{split}
D(a, r\_a)\oplus D... |
13,077,241 | I am trying to merge multiple linux commands in one line to perform deployment operation.
For example
```
cd /my_folder
rm *.jar
svn co path to repo
mvn compile package install
``` | 2012/10/25 | [
"https://Stackoverflow.com/questions/13077241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/216431/"
] | I've found that using ; to separate commands only works in the foreground. eg :
`cmd1; cmd2; cmd3 &` - will only execute `cmd3` in the background, whereas
`cmd1 && cmd2 && cmd3 &` - will execute the entire chain in the background IF there are no errors.
To cater for unconditional execution, using parenthesis solves ... | FYI,
if you need to run multiple commands in one-line in if-else, you can group the commands with parenthesis. See this [page](https://www.gnu.org/software/bash/manual/html_node/Command-Grouping.html) for more details.
You can replace the semicolon (**;**) with **&&** or **||** depending on what you need. Please note ... |
4,960,211 | I asked a question regarding this yesterday, but it was muddled and didn't make sense, so I'm going to boil it down to the core issue.
I have an `entries` table. When a new record is saved, the `entries_controller` adds a time to the `date` column, which is recorded as a datetime. In the `new` method, I declare a new ... | 2011/02/10 | [
"https://Stackoverflow.com/questions/4960211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/142486/"
] | If you want to use input instead of raw\_input in python 2.x,then this trick will come handy
```
if hasattr(__builtins__, 'raw_input'):
input=raw_input
```
After which,
```
testVar = input("Ask user for something.")
```
will work just fine. | This is my work around to fail safe in case if i will need to move to python 3 in future.
```
def _input(msg):
return raw_input(msg)
``` |
6,470,059 | I overrode the Equals() of my class to compare ID values of type Guid.
Then Visual Studio warned:
>
> ... overrides Object.Equals(object o) but
> does not override Object.GetHashCode()
>
>
>
So I then also overrode its GetHashCode() like this:
```
public partial class SomeClass
{
public override bool Equal... | 2011/06/24 | [
"https://Stackoverflow.com/questions/6470059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/83/"
] | As others have said, the use of Reflection in Equals seems dodgy. Leaving that aside, let's concentrate on GetHashCode.
The primary rule for GetHashCode that you must not violate is **if two objects are equal then they must both have the same hash code**. Or, an equivalent way of saying that is **if two objects have ... | Traditionally `Equals` is implemented in such a way that two objects will only be "Equal" if they are exactly the same in every way. For example, if you have two objects that represent the same object in the database, but where one has a different `Name` property than the other, the objects aren't considered "Equal", a... |
83,747 | Can anyone share a knowledge how to
\_ secure LND node
\_ backup node with all Channels
I think only a seed will not be sufficient.
What is your plan B in case of disaster? How to do an Emergency restore, migration to other server, or set up high availability solution?
thanks | 2019/01/17 | [
"https://bitcoin.stackexchange.com/questions/83747",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/88332/"
] | You can secure an LND node in the same way how you would secure any host on the internet. You can for example use `ufw` to set up a firewall. You could also have a physical firewall in front of you node. Also a big step towards security would be to run no other software on the node.
As for backups it is a little bit ... | Newer versions (0.6) of LND support channel backups/restore without restarting. So doing a backup of the seed plus channels should help, but I think you need to to frequent backups, maybe with every channel transaction, to have always the latest state of the channels.
Also I secure my LND keeping it into a docker cont... |
611,883 | How do I write a regex to match any string that doesn't meet a particular pattern? I'm faced with a situation where I have to match an (A and ~B) pattern. | 2009/03/04 | [
"https://Stackoverflow.com/questions/611883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/65184/"
] | The complement of a regular language is also a regular language, but to construct it you have to build the [DFA](http://en.wikipedia.org/wiki/Deterministic_finite_automata) for the regular language, and make any valid state change into an error. See [this](http://nitsan.org/~maratb/cs164/lminus.html) for an example. Wh... | My answer here might solve your problem as well:
<https://stackoverflow.com/a/27967674/543814>
* Instead of Replace, you would use Match.
* Instead of group `$1`, you would read group `$2`.
* Group `$2` was made non-capturing there, which you would avoid.
Example:
`Regex.Match("50% of 50% is 25%", "(\d+\%)|(.+?)");... |
3,629,330 | I am using core plot in one of my iPhone projects. Is it possible to change the color for a selected slice in a pie chart (using CPPieChartDataSource, CPPieChartDelegate)? | 2010/09/02 | [
"https://Stackoverflow.com/questions/3629330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/193545/"
] | I added this to my .m file (which is the data source file for the pie chart). The colors are ugly -- just used them to test as they are really different than the defaults. And there are only three slices in my chart, hence the hard-coded 3 colors. I found the Core Plot documentation helpful for all this. [Here's the li... | Swift version:
```
func sliceFillForPieChart (pieChart: CPTPieChart, recordIndex: UInt) -> CPTFill {
switch (recordIndex+1) {
case 1:
return CPTFill(color:CPTColor.greenColor());
case 2:
return CPTFill(color:CPTColor.redColor());
default:
return CPTFill(color:CPTColor.orangeCol... |
14,828,199 | I have the following array:
```
my @anim = ('rn4,mm8,bosTau2,canFam2,dasNov1,echTel1',
'rn4,mm8,oryCun1,bosTau2,canFam2,dasNov1,echTel1');
```
It contain multiple strings, each string are comma separated.
What I want to do is to sort them based on the greatest members of the string.
Hence what I tried to do is ... | 2013/02/12 | [
"https://Stackoverflow.com/questions/14828199",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/67405/"
] | If you want to sort by the count of elements in each string, your code will do that. I am not getting any errors with your posted code in Perl 5.16. Do you have an older version of Perl? (I found [some evidence](https://stackoverflow.com/questions/2436160/why-does-perl-complain-use-of-implicit-split-to-is-deprecated) t... | Regexp could sole everything or you could remove the warnings with 'no warnings;' pragma locally.
```
my $comma_re = qr!,!;
my @animsort = sort{$b =~ s!$comma_re!!g <=> $a =~ s!$comma_re!!g} @anim;
print Dumper(\@anim,\@animsort);
``` |
286,072 | I've seen a few users with a gold badge in a tag answer a question, and then immediately close the question as duplicate.
[Here's an example](https://stackoverflow.com/questions/28509772) of a question which it happened on (**EDIT**: The answer has been removed, and is now only viewable to users with 10k+ reputation.... | 2015/02/14 | [
"https://meta.stackoverflow.com/questions/286072",
"https://meta.stackoverflow.com",
"https://meta.stackoverflow.com/users/2767207/"
] | I think it's bad form to answer a question then **immediately** close it as a duplicate. If it's a duplicate, just close it. By answering it then immediately closing it, it sends a signal that you're hoping for upvotes on your answer, while depriving others of the opportunity to answer as well. That's not a very level ... | I got linked here because [I did the exact same](https://stackoverflow.com/questions/50304062/append-to-list-in-python/50304080#50304080) - the questions is a variant of the "I added a list to a list in a loop and afterwards it contains the same list n times) - just with the twist of adding dicts to the list.
I voted... |
33,101,771 | When running an Oozie java action on a freshly installed Hadoop HDP 2.2.2.4, and for example tries to access hdfs it accesses the wrong filesystem:
`java.lang.IllegalArgumentException: Wrong FS: hdfs:/tmp/text.txt, expected: file:///`
It can be fixed by included the core-site.xml in the Oozie action:
```
<file>hdfs:/... | 2015/10/13 | [
"https://Stackoverflow.com/questions/33101771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/630269/"
] | Change it to this:
```
$scope.registerClick(e) {
if (e.target.classList.contains('parent')){
// The .parent div is clicked
} else if (e.target.parentNode.classList.contains('parent')){
// Some child of the .parent div is clicked
} else {
var elem = e.target;
while(elem.tagN... | You can do something like
```js
var app = angular.module('my-app', [], function() {})
app.controller('AppController', function($scope) {
$scope.registerClick = function($event) {
//if has jQuery
if ($($event.target).closest('.parent').length) {
console.log('clicked parent');
$scope.jQuery ... |
4,654,196 | I am trying to create an initialisation function that will call multiple functions in the class, a quick example of the end result is this:
```
$foo = new bar;
$foo->call('funca, do_taxes, initb');
```
This will work fine normally with call\_user\_func function, but what I really want to do is do that inside the cla... | 2011/01/11 | [
"https://Stackoverflow.com/questions/4654196",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/560900/"
] | It's actually a lot simpler than you think, since PHP allows things like [variable variables](http://php.net/manual/en/language.variables.variable.php) (and also variable object member names):
```
foreach($funcarray as $func) {
$this->$func();
}
``` | when we want to check whether a class function/method exists within the class,
then this could help
inside class...
```
$class_func = "foo";
if(method_exists($this , $class_func ) ){
$this->$class_func();
}
public function foo(){
echo " i am called ";
}
``` |
1,616,187 | Suppose I have a chain complex of chains $C\_n$. Then one can obtain the homology groups of this complex. Now if I choose any abelian group $G$ and I consider the cochain group $C\_n^\*=Hom(C\_n,G)$ then I can obtain the cohomology groups. Now the question is: If I form the cocohomology group by considering $C\_n^{\*\*... | 2016/01/17 | [
"https://math.stackexchange.com/questions/1616187",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/304440/"
] | Not in general.
Suppose that all of the $C\_n = \oplus\_{i = 0}^{\infty} \mathbb{k}$, with differentials $0$, and let $G = \mathbb{k}$. Then $Hom(C\_n, \mathbb{k}) = \Pi\_{i = 0}^{\infty} \mathbb{k}$. Taking the $\mathbb{k}$ dual again gives something containing as a subspace $\Pi\_{i = 0}^{\infty} \mathbb{k}$, with ... | If $G = \mathbb R$ (or any field), and $C$ is the simplical chain complex associated to a countably infinite discrete space (e.g., the integers), then $H\_0 = Z\_0$ will be an infinite direct sum of copies of the reals, but $Z^0$ will be the dual space of that, and the double dual will not be isomorphic to the original... |
35,710,619 | Say I have the following collection of `Student` objects which consist of Name(String), Age(int) and City(String).
I am trying to use Java's Stream API to achieve the following sql-like behavior:
```
SELECT MAX(age)
FROM Students
GROUP BY city
```
Now, I found two different ways to do so:
```
final List<Integer> v... | 2016/02/29 | [
"https://Stackoverflow.com/questions/35710619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1909995/"
] | Do not always stick with `groupingBy`. Sometimes `toMap` is the thing you need:
```
Collection<Integer> result = students.stream()
.collect(Collectors.toMap(Student::getCity, Student::getAge, Integer::max))
.values();
```
Here you just create a `Map` where keys are cities and values are ages. In case when se... | ```
Here is my implementation
public class MaxByTest {
static class Student {
private int age;
private int city;
public Student(int age, int city) {
this.age = age;
this.city = city;
}
public int getCity() {
return cit... |
20,814 | What are some good reference books for learning the subtleties of OSX? I found it fairly easy to pick up, but some things are kinda weird (like switching the default web browser, I had to get my friend who's a Mac expert to guide me through it).
Our library had 2 O'Reilly books on Mac OSX but a lot of the stuff mentio... | 2009/08/10 | [
"https://superuser.com/questions/20814",
"https://superuser.com",
"https://superuser.com/users/1162/"
] | While not a book, [Mac OS X Hints](http://www.macosxhints.com/) is a good place for tips and tricks. | MAX OS X for Unix geeks is a fab resource |
4,522,031 | Completely stuck on solving this question,
Any hints or ideas? I tried expanding but got nowhere with it, it seems to be more complicated than some $a^2\geq 0$. | 2022/08/31 | [
"https://math.stackexchange.com/questions/4522031",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/1090851/"
] | Picking up from your last step, assuming $ a, b \neq 0$, we have
\begin{align\*}
a - b = \sqrt{b} - \sqrt{a} & \iff (a - b)(\sqrt{b} + \sqrt{a}) = b - a \\
& \iff (a - b)(\sqrt{a} + \sqrt{b} + 1) = 0 \\
& \iff a - b = 0 \quad \text{or} \quad \sqrt{a} + \sqrt{b} + 1 = 0 \\
& \iff a = b \quad \text{(Since $ \sqrt{a} + \s... | I would approach this by showing the function is increasing. Once you know $f$ is increasing, then suppose $f(a)=f(b)$ and $a\lt b$. But then because $f$ is increasing, $f(a)\lt f(b)$, a contradiction.
And there is a similar contradiction when $f(a)=f(b)$ and $a\gt b$.
So the only conclusion is that when $f(a)=f(b)$,... |
54,729,678 | I am trying to display items in a shopping cart. I made a "BagItem" component to display the information about the item, which comes from an object which is in the cart array in state, in redux. I also made a "Bag" component, which is where I map over the cart information and return the "BagItem" component.
Everything... | 2019/02/17 | [
"https://Stackoverflow.com/questions/54729678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11073321/"
] | The condition in the while loop doesn't work the way you think.
```
while (inputFile.eof() || drinkMachine.totalDrinks == 20)
```
When doing input extraction in a loop you should *first* do the extraction, check if it succeeds, then continue. `eof()` checks if the eofbit (end-of-stream bit) in the stream is set, whi... | There are several errors in your code.
First, you need to access your `drinkMachine` object to get to `arrayDrink` here:
```
{
inputFile >> arrayDrink[i].name;
inputFile >> arrayDrink[i].price;
inputFile >> arrayDrink[i].NumDrinksOfSameType;
}
```
See what you do in the loop:
```
for (int i = 0; i < dr... |
2,522,603 | How can I call a webmethod of one application from another application, when both are developed in C#? | 2010/03/26 | [
"https://Stackoverflow.com/questions/2522603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/168414/"
] | All of the suggested solutions should be working. But I think that you need to prevent the anchor's default action.
Add this code within a <script> tag in the <head> section of your document.
```
$(document).ready(function(){
$("#contact").click(function(event){
event.preventDefault(); //stops the browser... | I have to admit defeat on this one. I don't believe there is a solution based on the above answers (although I know they work in test environments), they just don't work in my exact case.
The reason for this is that if you do a view source on <http://www.thebalancedbody.ca/> the DIV `#contactable`
Is not exposed in t... |
4,147,401 | I was thinking about a building a CMS, and I want to implement the wordpress-like permalink for my posts. How do I do that?
I mean, How do I define the custom url structure for my pages? | 2010/11/10 | [
"https://Stackoverflow.com/questions/4147401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/257944/"
] | I would say that anonymous functions show their beauty when there is good library classes/functions that use them. They are not that sexy by themselves. In the world of .net there is technology called LINQ that makes huge use of then in very idiomatic manner. Now back to PHP.
First example, sort:
```
uasort($array, f... | If you need to create a callback (to make a concrete example, lets say its a comparison function for usort) anonymous functions are usually a good way to go. Particularly if the definition of the function is dependent on a few inputs (by this i mean a closure, which is NOT synonymous with anon function)
```
function c... |
270,170 | I have a content type that has 2 fields on it:
* image (multiple values)
* image description (multiple values)
I have 6 images and 6 descriptions. I want to use a view to show each image with each description. I have tried playing around with the "Display all values in the same row" settings but just can't get this t... | 2018/09/30 | [
"https://drupal.stackexchange.com/questions/270170",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/20344/"
] | If you want the name of the term, use `[webform_submission:values:profil:entity:field_personnel_sexe:name]`.
If you have another field for the *personnel\_sexe*, for example you want to show the description, you can:
1. Change display for *Token*
[](http... | You can you **:htmldecode:striptags** at the end of your token.
Care of the security (seen on the token tree page) :
>
> This suffix has security implications.
> Use :htmldecode with :striptags.
> :striptags removes all HTML tags from returned value.
>
>
> |
9,767,391 | Given the following integers and calculation
```
from __future__ import division
a = 23
b = 45
c = 16
round((a/b)*0.9*c)
```
This results in:
```
TypeError: 'int' object is not callable.
```
How can I round the output to an integer? | 2012/03/19 | [
"https://Stackoverflow.com/questions/9767391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/695457/"
] | Somewhere else in your code you have something that looks like this:
```
round = 42
```
Then when you write
```
round((a/b)*0.9*c)
```
that is interpreted as meaning a function call on the object bound to `round`, which is an `int`. And that fails.
The problem is whatever code binds an `int` to the name `round`.... | Stop stomping on `round` somewhere else by binding an `int` to it. |
55,043 | I use Postgresql 8.4 and I wanted to know what type of RAID is mostly used for databases.
I read everywhere that RAID10 is the best suited and RAID5 not a good option.
ex: <http://www.revsys.com/writings/postgresql-performance.html>
My server is a Dell Poweredge 2950. Dell support told me that they dont have a lot of... | 2009/08/17 | [
"https://serverfault.com/questions/55043",
"https://serverfault.com",
"https://serverfault.com/users/16344/"
] | Please find [here](http://wiki.postgresql.org/wiki/HP_ProLiant_DL380_G5_Tuning_Guide) a performance and scaling reports, about HP Proliant DL380 G5.
the tests are based on various file systems (jfs, xfs, reiserfs, ext2 and ext3). | RAID5 is used because it's easier to setup and think about than RAID10. You don't require an even number of disks and more people are familiar with it.
In the past, we have always done RAID5 (Dell PowerEdge 2650-2950), but in our latest machine (running MS-SQL, not PostgreSQL) I tested both RAID10 and RAID5. I found ... |
167,114 | Do you know how can I set the width of a modal window opened by a lightning component action? In the edit options I can set only the height but is not enough because the content of my table is not completely shown.
Here is the code:
```
<aura:component access="GLOBAL" implements="force:hasRecordId,force:appHostable,fl... | 2017/04/03 | [
"https://salesforce.stackexchange.com/questions/167114",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/19222/"
] | Okay, So I had the same requirement where I needed to increase the pop-up size. So I have gone through various link also this. But none of them seems working for me. I tried to put the css suggested by @Amulyaranjan in style class but that also didn't work for me. it seems like component css load first and than the com... | 1) Create this static resource: QuickActionModalStyle
```
.slds-modal__container{
max-width:80rem !important;
width:80% !important;
}
```
Adjust width as per your requirements.
2) Use this new static resource with at the beginning of your component.
```
<ltng:require styles="{!$Resource.QuickActionModa... |
29,422,949 | So I'm working through this homework, and am totally stuck at putting Excel formulas in my code. This is the prompt:
>
> 3. Use Excel functions in the code (with Application.WorksheetFunction) to calculate
> the statistics and assign the corresponding values to variables of type double. Use the
> range name ScoresD... | 2015/04/02 | [
"https://Stackoverflow.com/questions/29422949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4735757/"
] | Since you're consuming multiple items, would suggest to use consumeAsync for multiple items method by passing your list of purchases. You can find it inside [TrivialDrive](http://developer.android.com/training/in-app-billing/preparing-iab-app.html) sample app for Iab ver 3
```
/**
* Same as {@link consumeAsync}, but ... | change your class to these
```
public class BankClass {
public int itemId;
public int quantity;
public String Price;
public BankClass(int _itemId,int _quantity,String _Price){
itemId = _itemId;
quantity = _quantity;
Price = _Price;
}
public int getItemId() {
r... |
178,925 | How to make the double lines to only one bold (thick) line ?
```
\documentclass[french]{beamer}
\usepackage{babel}
\usepackage{adjustbox}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\begin{document}
\begingroup
\defbeamertemplate{enumerate item}{image}{\small\includegraphics[height=1... | 2014/05/18 | [
"https://tex.stackexchange.com/questions/178925",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/49762/"
] | Two vertical rules separated by a space (of `\tabcolsep` in `tabular`) is given by `||` in the column specification. To remove the space between them, use `|@{}|`. If you want it thicker, you can use `|@{}|@{}|`, or add more `@{}|`'s.

```
\documentc... | I would recommend *not* using vertical rules, so the problem of thicker rules vanishes. But here's how you can do it.
```
\documentclass{beamer}
\usepackage{array}
\newcolumntype{I}{% I for a thick rule
!{\vline width 1pt}%
}
\newcolumntype{J}[1]{% variable thickness rule
!{\vline width #1}%
}
\begin{document}
\be... |
7,846,581 | I have a base class that depends on another class for some special caching. I also wrote the special caching class.
I can test it so special caching class is passed as a mock to make sure the base class works as expected or I can use a real class to make sure that the whole thing works as expected.
If I use the real ... | 2011/10/21 | [
"https://Stackoverflow.com/questions/7846581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/30453/"
] | Why should you mock the real class if it does the job?
My advice would be:
* test your class features in its test case, except caching,
* test caching in the cache test case
I wouldn't be confused by that, as long as the tests of your cache class are exhaustive: if caching leads to problems, caching tests should fai... | I've been in similar situations where I had a class in production code which was backed up by a couple of unit tests. These unit tests created mock objects to pass into the production code class. That meant I was able to run the unit tests without any dependencies.
Now, I also required to use that production class as ... |
44,213,176 | I suddenly started getting this error when trying to build. This was all working a few weeks ago with no changes that I know of. The issue seems to be related to `react-native-fbsdk`, but looking through its build.gradle it does not list `support.appcompat-v7.25.x`. Any advice?
```
A problem occurred configuring proje... | 2017/05/27 | [
"https://Stackoverflow.com/questions/44213176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1736601/"
] | I've had the same problem (*appcompat-v7:25.3.1*), on an android project, but not using react.
I first tried to clean the gradle cache (~/.gradle/caches), like explained [here](https://stackoverflow.com/questions/23025433/how-to-clear-gradle-cache), but it didn't help.
Then I looked at the SDK Manager.
Android Sup... | Since gradle doesn't support declaring repositories on a per-artifact basis yet.
I modified my build.gradle (not app/build.gradle) to force all dependency to react-native to specific version:
```
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails det... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.