INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
$17!=3556xy428096000,$then $(x+y)$ equals?(without using a calculator)
$17!=3556xy428096000,$then **$(x+y)$** equals?
a)$15$ b)$6$ c)$12$ d)$13$
With help of calculator $(x+y)$ can be easily calculated as **$15$**.But without a calculator,I can only conclude that the sum of digits $(3+5+5+6+x+y+4+2+8+9+6)$ is a **multiple of $3$** , & excluding $(x+y)$ the sum of the digits $(3+5+5+6+4+2+8+9+6) =48$.Thus excluding option d) the ans can be any of a),b) or c).
Please help me to find the exact answer.
**Thank you** | First use the fact that the factorial is divisible by $9$, and therefore the digit sum is divisible by $9$.
Then use the fact that the number with decimal representation $abcdefg\dots$ is divisible by $11$ if and only if $a-b+c-d+e-f+\cdots$ is divisible by $11$. | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "numerical methods"
} |
Common antonyms to "happy ending"?
I know you may specify to something like _tragic, open end_ to describe actually what the end is like.
But do English critics/reviewer in movie magazines use a common term for movies with _bad/evil endings_ or simply refer to them as _no happy ending_ (as most movies have to have a happy ending) to classify such films? I mainly ask as I need some proper keywords to find those rare films. | There are some good answers here, but nothing quite on the nose, so I'll make my own humble contribution:
> Does it at least have a happy ending?
>
> Nope...it's pretty much a **downer ending**.
This is obviously much less formal than these other answers, but it's what I would use in normal American English speech. | stackexchange-english | {
"answer_score": 1,
"question_score": 3,
"tags": "phrase requests, antonyms, expressions"
} |
System.Data Doesn't Exist in Visual Studio 2010
I have a red line under System.Data saying that "The type or namespace 'Data' does not exist in the namespace 'System' (are you missing an assembly reference?)."
Thought I needed 4.5 .Net Framework, but I have another project that can use the namespace, so it is something with this project that I am using.
I have seen other threads similar to mine, such as this, but it isn't directly related to just system.data. It's trying to add a namespace beyond data, so there system.data namespace isn't the problem. Haven't seen any threads only related to just the system.data namespace. Any help would be appreciated. | did you try to add the assembly reference in your project? right click on your project > add reference then select assemblies tab and finally System.Data and check it, then press ok. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "c#, visual studio 2010"
} |
What does でポン mean?
There are several manga, games, websites etc in Japan with the in the title, such as , , , .
I think I can infer it is some sort of onomatopoeia but I don't understand the meaning. | This is an onomatopoeia which represents a tiny explosive sound, like "Pop!" or "Pong!". is technically a method/means/situation marker here (e.g., "With , something pops").
What represents depends on the title.
* : describes how a phone number "pops" up.
* : describes how the matched panels "pop".
* : (I don't know the story, but is a common sound of a magic spell.)
* : ( Maybe just a parody of other , or this may describe the book is like a toy box from which random contents pop up.) | stackexchange-japanese | {
"answer_score": 5,
"question_score": 3,
"tags": "meaning, onomatopoeia"
} |
How do I close a command prompt after opening it?
I want to open a command prompt and then close it, it opens the command prompt but it doesn't close it, the error I get is:
> FileNotFoundError: [WinError 2] The system cannot find the file specified
import sys
import random
import subprocess
import os
def x():
subprocess.call('start',shell=True)
os.system('taskkill /fi r"C:\Windows\system32\cmd.exe"')
#subprocess.run("exit")
x() | Maybe this SO question might help. I believe it is better practice to get the process ID, and call an `exit` or `kill` on that PID rather than calling it on the application itself. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "python 3.x"
} |
Swift - UINavigationBar is disappearing - Storyboard reference
I'm havig this navigaton bar at the very beginning of my project, I'm hidding it at connection and then displaying it later on. My sotryboard began to get huge so I've decided to put the parameters views of my app in a second storyboard. The second storyboard begins with a view (that I'm displaying using "Presentr" library) which has already no access to the navigation bar from the first storyboard.
I think that the storyboard reference is somehow destroying my navigationController. What am I doing wrong, and what should I do to correct it ? | My issue was because of library "presentr". Somehow when I'm using this library to dsplay a VC (no matter how it's linked into the storyboard), the VC loses the hierarchy with the navigation controller.
Hope it'll help | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, swift, xcode, uinavigationcontroller, storyboard"
} |
WordPress: Get Yoast SEO title for custom taxonomy
I'm trying to get the SEO title from a custom taxonomy.
Here's my current code for it:
$my_yoast_wpseo_title = get_term_meta( $term_id, '_wpseo_title', true );
if( $my_yoast_wpseo_title ){
echo $my_yoast_wpseo_title;
} else {
echo 'No title';
}
It doesn't work.
So I tried different meta keys like `_yoast_wpseo_title` and everything I could find in their docs and other snippets.
Nothing works.
So I checked the complete output of `get_term_meta`. Like this:
$my_yoast_wpseo_title = get_term_meta( $term_id );
print_r($my_yoast_wpseo_title);
It shows a lot of meta fields. But the Yoast meta isn't stored there?! Is their any other place?
The taxonomy has a custom SEO title and shows it in the frontend. | The Yoast SEO Titles for Terms are stored in the `options` table.
This will at least give you the idea you're after.
$options = get_option( 'wpseo_taxonomy_meta' );
// $options will be an array of taxonomies where the taxonomy name is the array key.
$term_id = get_queried_object_id();
foreach ( $options['your_term_here'] as $id => $option ) {
if ( $term_id === $id ) {
/* This returns an array with the following keys
'wpseo_title'
'wpseo_focuskw'
'wpseo_linkdex'
*/
echo ( ! empty( $option['wpseo_title'] ) ) ? $option['wpseo_title'] : 'no title';
}
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, wordpress, custom taxonomy, yoast"
} |
How do I approach showing that integral $\int^{\infty}_0\sin^3(x^2+2x)$ converges absolutely/conditionally?
How do I approach showing that integral $$\int^{\infty}_0\sin^3(x^2+2x)\,\mathrm dx$$ converges absolutely/conditionally? I have calculated via software that $\int^{\infty}_0\sin^3(x^2+2x)\,\mathrm dx$ is indeed convergent, but how is it done exactly?
What I tried:
Let $U = x^2+2x, N\in \mathbb{N}, N>1$, then
$$\int^{2\pi N}_0|\sin^3(u)|\,\mathrm dx=\sum^{N-1}_{n=0}\int^{2\pi (n+1)}_{2\pi n}|\sin^3(u)|\,\mathrm du\leq \cdots$$
I am not sure what I even did is correct. I would appreciate a hint :) | By making the substitution $u=(x+1)^2$, we find that $\sqrt{u}=x+1$ and $\frac{du}{2\sqrt{u}}=dx$. Then $$\int^{\infty}_0\sin^3(x^2+2x)\,dx=\int_1^{\infty}\frac{\sin^3(u-1)}{2\sqrt{u}}\,du.$$ Now, by recalling that $4\sin^3(t)=3\sin(t)-\sin(3t)$, show that the last integral is convergent by using Dirichlet's test for convergence of improper integrals
Can you take it from here? | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "improper integrals"
} |
Sql where statement with = works but LIKE does not
Sql where statement with = works but LIKE does not Is there a fix for this?
Here is the exact code:
create table zSyn (xField nvarchar(255));
insert into zSyn(xField)
select 'DEVCON 5 Minute Epoxy amber [1:1]';
--Works and returns 1 row:
select * from zSyn
where xField = 'DEVCON 5 Minute Epoxy amber [1:1]';
--Does NOT return any rows:
select * from zSyn
where xField like '%' + 'DEVCON 5 Minute Epoxy amber [1:1]' + '%' | You need to escape `[]`:
select * from zSyn
where xField like ('%' + 'DEVCON 5 Minute Epoxy amber ![1:1!]' + '%') ESCAPE '!';
**db<>fiddle demo** | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 1,
"tags": "sql, sql server"
} |
Объединение двух таблиц по общему столбцу в MS SQL
Имеется две таблицы, столбцы первой: `Уникальный_номер, Атрибут1`, столбцы второй: `Уникальный_номер, Атрибут2`. В таблицах разное число строк, некоторые значения столбцов `Уникальный_номер` совпадают, но не все. Необходимо создать запрос `SELECT`, который выдаст таблицу следующего вида: `Уникальный_номер, Атрибут1, Атрибут2`, в которую войдут как полные строки, так и строки с номером, имеющимся хотя бы в одной таблице. В таком случае, для отсутствующего атрибута нужно проставить `0`.
Помогите, пожалуйста, сформировать соответствующий запрос с использованием MS SQL. | SELECT COALESCE(a.Уникальный_номер,b.Уникальный_номер,0), Атрибут1, Атрибут2
FROM table1 a
FULL OUTER JOIN table2 b
ON a.Уникальный_номер=b.t.Уникальный_номер
думаю поможет | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sql, sql server, select"
} |
Eclipse Throws Weird ClassNotFoundException
Apparently, Eclipse can't find a class from within said class. Here is my error (for some reason, Stack Overflow doesn't like the formatting on here): <
Here is my main method: <
It was fine for a long time, but all of a sudden, it broke. | Maybe you have the EscapeComponent lib in your build path you don't export it in runtime.
Go to project properties, "Java Build Path" option, "Order and Export" tab and make sure that the lib that holds EscapeComponent is selected. Otherwise it won't be available in runtime and so NoClassFoundException happens. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java"
} |
Extracting multiple strings, according to a pattern, in a bash script
I'm writing a shell script to generate a directory listing.
as an input a receive a long html string :
link to post","url":"
article","$type":"com.traver.voyager.feed.actions.Action"},{"actionType":"SHARE_VIA","text":"Copy link to post","url":"
To make the output easily customizable, the script just display a url-table :
the pattern to search is : begins by "< then XXXXX letters (dynamic size) then finishes with " (quote not to extract)
My current solution was based on cut -f but the total input size is dynamic, so it is not possible to find the pattern. | Your sample data looks like a broken fragment of json, so you really should use `jq` to extract what you need from it **before** doing whatever it is you did to the original input that caused it to look like that.
However, to extract URLs beginning with ` and not containing a double-quote character from what you have, you can use `grep`:
$ grep -o ' input.txt
| stackexchange-unix | {
"answer_score": 0,
"question_score": 0,
"tags": "shell, awk, sed, string, replace"
} |
Is it possible to style a href widget differently in UiApp?
In UiApp, the default style for href widgets is the classical blue underlined aspect. Is it possible to define a new style for this like one can do with css style sheets and html ?
For example : link in normal black, getting grey when hovering ?
here is how I did it in css :
h1 a:link, h1 a:active, h1 a:visited {
color: #111;
text-decoration: none;
}
h1 span {
color: #111;
}
h1 a:hover, h1 a:focus {
color: #777;
} | You can set the primary style via `setStyleAttributes` but you cannot set pseudo-selector styles like hover and focus. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "google apps script"
} |
$\mathcal {L}(\operatorname e^{-6t}\cos(5t))=?$
Find the laplace transform of the following equation $f(t) =\operatorname e^{-6t}\cos (5t)$ | **Hint** : By one of the shift theorems, you have $\mathcal{L}\\{e^{at}f(t)\\} =F(s-a)$. In your problem, we would then take $f(t)= \cos(5t)$. Thus, $$\mathcal{L}\\{e^{-6t}\cos(5t)\\} = \left.\mathcal{L}\\{\cos(5t)\\}\right|_{s\to s+6}=\ldots$$
> In the end, you should get $\mathcal{L}\\{e^{-6t}\cos(5t)\\} = \dfrac{s+6}{(s+6)^2+25}$. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "laplace transform"
} |
Twitter bootstrap datetime picker
I'm trying to use < with twitter bootstrap but it doesn't work. I don't know how it could not be working because I just followed the example, no customization.
P.S. There is the following error:
Uncaught TypeError: Object [object Object] has no method 'datepicker'.
I'm not sure if I do it right, so here's the code for the input:
<input type="text" class="data-datepicker-format" data-datepicker-format="dd/mm/yyyy" />
Any ideas how to fix it? Thanks in advance. | Per our discussion in the comments to another answer, the issue seems to be that you're loading both Bootstrap DatePicker and jqueryUI DatePicker libraries.
If you really do need to use jqueryUI, you'll need to build a jqueryUI package without the DatePicker. You can do that on the jqueryUI download site.
_**EDIT_** : To be clear, you can leave jquery in place. Only jquery- **UI** needs to be either removed, or you need a custom jqueryUI package that excludes the DatePicker. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails 3, twitter bootstrap, datetimepicker"
} |
While submitting a form IE8 won't add attributes to the request other than those from inputs
All other browsers (including IE9, exluding ancient ones) send correct requests for the following form:
<form class="form-submitter form-horizontal" enctype="multipart/form-data" name="Uploader" id="Uploader" action="MainServlet?module=general&action=add&Name=test">
<input class="input-file" name="testFormName" id="UploaderInput" type="file">
</form>
That is:
while in IE8 all I get is:
I'm using jQuery's submit, that is:
$("#Uploader").submit()
I'd love to get any suggestions, or tips which could lead to me to solution. Did anyone has this problem already with IE8?
Thx | Use hidden inputs :
<form class="form-submitter form-horizontal"
enctype="multipart/form-data" name="Uploader" id="Uploader"
action="MainServlet">
<input type=hidden name=module value="general">
<input type=hidden name=action value="add">
<input type=hidden name=Name value="test">
<input class="input-file" name="testFormName" id="UploaderInput" type="file">
</form>
That's the right solution. You'll even avoid encoding problems. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, jquery, forms, internet explorer 8, submit"
} |
I can't find the error, so who can tell me, thanks
/Users/mac/page/node_modules/mongodb/lib/mongodb/connection/base.js:246
throw message;
^
TypeError: undefined is not a function | It's right there... Where it says `TypeError: undefined is not a function`.
That's the error. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -6,
"tags": "node.js"
} |
Checking quadratic programming solution
I want to check if $(0,1,2)$ is the solution to a following problem: $$x_3\to \min,$$ $$x_1^2+2x_1x_2+2x^2_2-2x_1-x_2-x_3+1\geq 0,$$ $$x_1^2+x_2^2-x_1+x_2-x_3\leq 0,$$ $$x_1^2+x_1-4x_2-x_3+6\leq 0,$$ $$x_1,x_2,x_3\geq 0.$$ Any ideas on how to approach this problem? | I assume that you are only looking for integer solutions. Then it is enough to show that no solution with $x_3\in \\{0,1\\}$ is possible.
Assume $x_3=1$, then the third and fourth displayed formulae become $$x_1 \geq x_1^2 +x_2^2 +x_2 -1,$$ and $$4x_2 \geq x_1^2 + x_1 +5.$$
Put together they imply $$4x_2 \geq x_1^2 +x_2^2+x_2+4,$$ therefore $$3x_2 \geq 4 +x_2^2.$$
And it is easy to see that the latter inequality has not integer solution. The case $x_3=0$ proceeds along the same lines.\
If you are not only looking at integer solutions, this method implies $$x_3 \geq \frac{15}{8}.$$ | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "optimization"
} |
What does >+ and >- mean in C#
I had accidentally tried this, which compiles! So I was wondering what could this possibly mean.. google didnt help..
if (3 >+ 4)
dothis() //this is never hit btw..
if (3 >- 4)
dothis() //this is hit.
Both the code compile btw.. | It parses as
3 > +4
and
3 > -4
So into the unary `+` and unary `-` operators.
If you want an interesting way to explore this, write
Expression<Func<int, int, bool>> func = (x, y) => x >+ y;
and then explore the resulting expression tree `func` in the debugger. You'll see the unary operator in the tree. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": -1,
"tags": "c#, .net, operators"
} |
Using "who" for not living characters
Although it has been already discussed:
> The word “who” only refers to living beings. For non-living beings, “which” is used instead.
I just wonder if "who" could be used for not living characters in a story, to put emphasis on their role:
> This is the story of a wooden puppet who had a friend
I'd be glad to hear your opinion on that,
Thanks | If the puppet is actually a "character" with a "friend", as you say, then the story will normally treat it as animate, including by using animate pronouns: "he" or "she" rather than "it", "who(m)" rather than "which", etc. | stackexchange-english | {
"answer_score": 24,
"question_score": 9,
"tags": "american english, british english"
} |
retrieve columns from sqlite3
I have two tables in sqlite:
CREATE TABLE fruit ('fid' integer, 'name' text);
CREATE TABLE basket ('fid1' integer, 'fid2' integer, 'c1' integer, 'c2' integer);
basket is supposed to have count c1 of fruit fid1 and c2 of fruit fid2
I created a view fruitbasket;
create view fruitbasket as select * from basket inner join fruit a on a.fid=basket.fid1 inner join fruit b on b.fid=basket.fid2;
it works (almost) as expected.
When I type
pragma table_info(fruitbasket);
I get the following output
0|fid1|integer|0||0
1|fid2|integer|0||0
2|c1|integer|0||0
3|c2|integer|0||0
4|fid|integer|0||0
5|name|text|0||0
6|fid:1|integer|0||0
7|name:1|text|0||0
The problem is that I cannot seem to SELECT name:1. How can I do it other than going back and re-aliasing the columns? | Use double-quotes to indicate column names:
select "name:1" from fruitbasket;
Here's an example:
sqlite> insert into fruit values (1,'apple');
sqlite> insert into fruit values (2,'pear');
sqlite> insert into basket values(1,2,3,4);
sqlite> select "name:1" from fruitbasket;
pear
sqlite> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "sql, sqlite"
} |
Validation of iOS App failing from -568h launch which is there
I have an app that 2 binaries; a full game and a Lite one. I have successfully validated and submitted the full game but the Lite one keeps insisting that I do not have the iPhone 5 launch image when Validating it, which I do (named [email protected] following on from the Launch Image name in the Info.plist). The image is set in exactly the same way as the full game, which validated fine.
(It also keeps trying to rename it to ~iphone.png when I add it to the Launch Images and then have to rename it in the file list).
This is pretty much the last hurdle that is being thrown at me; I am not sure how to upload a screenshot to this question as images only seem to work from web links.
Can anyone suggest what I may be missing? The image dimensions are correct at 640x1136. | Just move all your images to the images.xcassets file. See the details here | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ios, validation"
} |
How do I install Realplayer to download FLV files?
I need to be able to download .flv (flash video), and I know that the program "Real Player" can easily do that. How can I install it? I cant find the installer anywhere. | You can easily do that installing an add-on in firefox. Don't need to install any program for that. Open firefox, go to the website with the flash video and click in download.
Here is the link to the add-on. | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 1,
"tags": "video, flash, downloads, video player"
} |
Is this string instrument making a trill sound?
8:50~8:53 is this sound a trill? what bowing technique is it? | This is not a trill, but a tremolo or "trembling sound". It has the effect of a single sustained note, but it is caused by bowing back and forth very rapidly, and with very small motions. | stackexchange-musicfans | {
"answer_score": 4,
"question_score": 3,
"tags": "instrumental, technique"
} |
GPU accelerated neural networks
I am looking for gratis software that is GPU accelerated that can work with neural networks. I have seen many pieces of software that I can use for neural networks but many of them do not have GPU acceleration. Here are my requirements
Support for the backpropagation algorithm.
I would like support for a genetic algorithm such as NEAT but it is not required
A good nice to use interface
I would like it to work on windows but I could also use it on Linux
That is it for my requirements. In case you are wondering what GPUs I use I use Nvidia GPUs. So the application would have to support CUDA | You can use Caffe:
* open source (BSD 2-Clause license)
* gratis
* Easy to compile on Linux/OS X, harder on Windows
* GPU support for Nvidia
* on CPU, makes use of multithreading
* use the backpropagation algorithm
* allows the user to define neural network using config files
* MLP, CNN but no RNN yet
* written in C++ but Python and Matlab binds available
FYI:
* Script to install Caffe and pycaffe on Ubuntu.
* How to train a caffe model? | stackexchange-softwarerecs | {
"answer_score": 3,
"question_score": 5,
"tags": "windows, gratis, linux, gpu, neural network"
} |
Is the class of group-embeddable monoids an axiomatizable class?
Is the class of monoids which can be embedded in a group a first-order axiomatizable class? And if it is, is it finitely axiomatizable? | See < and When a semigroup can be embedded into a group. A commutative monoid (or more generally a semigroup) can be embedded in a group if and only if it satisfies a cancellation property, which is expressible by a single first-order sentence.
On the other hand, for non-commutative semigroups, the situation is vastly more complicated. It appears (via Wiki) that in 1939 Mal'cev (< found an infinite family of first-order sentences characterizing the semigroups which are so embeddable, and then in 1940 (< showed that no finite set would suffice. However, I can't get access to these papers, so I'm not sure that's accurate. | stackexchange-math | {
"answer_score": 4,
"question_score": 3,
"tags": "model theory"
} |
Is there a simpler way to preform projection on a ListItemCollection?
G'day all, Is there a way to preform projection on the contents of a list box. Specifically I'd like to be able to do it without having to clear and add back the contents of my listbox This is what I currently have.
public static void SetSelectedWhere(this ListBox listbox, Func<ListItem,bool> condition)
{
var queryableList = listbox.Items.Cast<ListItem>();
queryableList.Select(x=>condition(x)?x.Selected:x.Selected=false);
listbox.Items.Clear();
listbox.Items.AddRange(queryableList.ToArray<ListItem>());
}
and it seems silly to have to clear out my existing collection and add the contents back.
Any thoughts | What about plain old iteration?
foreach (ListItem item in listbox.Items)
{
item.Selected = condition(item);
}
LINQ is not the answer to life the universe and everything. Particularly that part of the universe that involves setting properties on existing objects. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "c#, linq, optimization, webforms, projection"
} |
Getting custom annotations (Ti.Map) pixelated
I've tried with different images in several resolutions (50x30, 70x50, 100x70). All of them are good enough out of titanium app, but I cannot get custom pins without pixel effect into the app.
I'm using Titatnium 3.0.
How can I make my custom images to obtain a best visual result?
Images source: <
Code: `
var annot = Titanium.Map.createAnnotation({
longitude : franchise.direction.loc[0],
latitude : franchise.direction.loc[1],
title : franchise.name,
subtitle : franchise.direction.address,
image : "testing_pin.png",
animate : false,
draggable : false
});
$.mapView.addAnnotation(annot);
` | These are the Pin icon sizes I use, and they look sharp on my maps.
[email protected]: 80px x 80px @72 dpi
pin.png: 40px x 40px | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "titanium, appcelerator mobile"
} |
Swift 3 - Binary operator '==' cannot be applied to two 'MyStruct' operands
I have a custom struct...
struct MyStruct {
let viewController: UIViewController
let view:UIView
init(viewController:UIViewController) {
self.viewController = viewController
}
}
I have an array of them, and then I want to check if this array contains a specific struct...
let aStruct = someStruct
if structArray.filter { $0 == aStruct } {
print("do stuff")
}
but I'm getting the error _Binary operator '==' cannot be applied to two 'MyStruct' operands_ ... first, why can't I filter structs in this way... second how should I search the array if not this way...
Thanks in advance | You need the struct to conform to the `Equatable` protocol to allow it to determine what is considered 'equal'.
Assuming you consider them equal if they have the same `viewController` property, you could do something like this:
extension MyStruct: Equatable{}
func ==(lhs: MyStruct, rhs: MyStruct) -> Bool {
return lhs.viewController == rhs.viewController;
} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "arrays, swift, filtering"
} |
Prove: $\limsup_{n\to\infty} (a_n)\leq \sup(a_n)_{n=1}^\infty$
Proposition: Let $(a_n)_{n=1}^\infty$ be a sequence of real numbers. Show that $\limsup_{n\to\infty} (a_n)\leq \sup(a_n)_{n=1}^\infty$.
Any hints on how to prove it will be appreciated. | It's pretty clear: $\,\,\limsup_{n\to\infty}a_n$ is the limit of the `nonincreasing` sequence in $\overline{\mathbf R} $: $\sup_{k\geq1}a_k,\,\,\sup_{k\geq 2}a_k, \dots,\,\,\sup_{k\geq n} a_k, \dots $
So, fot all $n$, we have $\sup_{k\geq n} a_k\le \sup_{k\geq1}a_k$. There remains to pass to the limit. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "real analysis, limsup and liminf"
} |
Taking forever to connect to the Windows Phone emulator
For some reason in the last month or so it's taking FOREVER to connect to my Windows Phone 7 emulator. This used to take around 15-30 seconds but now it takes around 3 minutes. When I press F5 in VS 2010 it just seems to stop on the message "Connecting to Windows Phone 7 Emulator...". But i can see the emulator started and ready in about 10 seconds. I'm on the same machine, same solution, same everything.
Is just me or has this started happening to everyone? | Try using WPConnect.exe instead and see if there are any changes:
< | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "windows phone 7"
} |
Is there a way to access an ITypeDescriptorContext or an IServiceProvider object from a custom TypeDescriptionProvider?
It seems like an odd gap in the `TypeDescriptor` dynamic metadata architecture. All of the `TypeConverter`, `UITypeEditor` and other dynamic designers, editors and converter classes provide access to an `IServiceProvider` object which allows for design context to be passed to implementing classes.
For some reason this is absolutely missing from `TypeDescriptionProvider`, `CustomTypeDescriptor` and associated interfaces. Is there any way to have access to the editor design context while dynamically extending the metadata/properties of a class? | After thinking more about it, I concluded that this can be solved by creating a dynamic `TypeDescriptionProvider` implementation which is provided by the designer itself. This implementation can receive a context directly via some domain-specific property.
It is then possible to associate dynamic type description providers using the `TypeDescriptor.AddProvider` method, passing in the custom provider and the target type. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, system.componentmodel"
} |
SAPUI5 FileUploader: Cannot find and append file to FormData()
How do I access the file that I select with my fileuploader?
Any solutions are welcome.
var oInput = new sap.m.Input();
var oFileUploader = new sap.ui.unified.FileUploader();
var oButton = new sap.m.Button({
text: "Send data",
press: function(){
var oFormData = new FormData();
oFormData.append("myTitle", oInput.getValue());
oFormData.append("myFile", ****This is where I want to insert my file****);
var xhr = new XMLHttpRequest;
xhr.open('POST', 'www.myUrl.com/foo/bar', true);
xhr.send(oFormData);
}
}); | Found the answer myself:
oFileUploader.setUploadOnChange(true);
var oFormData = new FormData();
oFormData.append("title", "I am the title");
jQuery.sap.domById(oFileUploader.getId() + "-fu").setAttribute("type", "file");
oFormData.append("document", jQuery.sap.domById(oFileUploader.getId() + "-fu").files[0]);
jQuery.ajax( {
url: "www.myWebsite.com/path",
data: oFormData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(data) {
},
error: function() {
}
}); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "javascript, file upload, sapui5, form data"
} |
Switching limits: $n \rightarrow \infty$ for $n\rightarrow 0$
I feel like this question may have already been asked, but despite my searches, I could not find it.
I am looking to prove that $\lim\limits_{\epsilon \rightarrow 0} \int_{[b, b+\epsilon]} g=0$ for an integrable function $g$. To do so, I would like to use the Dominated Convergence Theorem, as $g$ is my integrable dominating function. However, I realize that the DCT is defined for the limit as $n$ goes to infinity. I am looking to somehow switch this $\epsilon$ for $\frac{1}{k}$ and then take $k$ to infinity and use DCT. However, I feel that it cannot be so simple. How do I go about applying DCT to limits which are not going to infinity?
Any hints would be appreciated. | Just write
$$\lim_{\epsilon\to0}\int_{[b,b+\epsilon]}g=\lim_{n\to\infty}\int_b^{b+\frac1n}g=\lim_{n\to\infty}\int_b^{b+1}g(t)\chi_{[b,b+\frac1n]}(t)dt$$ so with $$\vert g_n(t)\vert=\vert g(t)\chi_{[b,b+\frac1n]}(t)\vert\le |g(t)|$$ you get the result using dominated convergence theorem. | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "real analysis, limits"
} |
Set windows service account in config
I need to set the serviceaccount for a windows service in the config file. But I cannot access the config values in the installer. I read this question but I do not want to use install parameters. Is there any way to do this?
**EDIT:** And I also tried some solutions in this but I can't access Configuration or ConfigurationManager inside the installer class... Am I supposed to add some reference? | After a lot of research, I found my own solution...
First add a reference to System.Configuration
and then add the following code in the installer class
Assembly service = Assembly.GetAssembly(typeof(ProjectInstaller));
string assemblyPath = service.Location;
Configuration config = ConfigurationManager.OpenExeConfiguration(assemblyPath);
KeyValueConfigurationCollection mySettings = config.AppSettings.Settings;
processInstaller.Account = (ServiceAccount)Enum.Parse(typeof(ServiceAccount), mySettings["Account"].Value);
I am just so happy right now!! :) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, configuration, windows services, service accounts, service installer"
} |
How can i adjust height using screenheight?
I want to adjust height of an image using screen.height.I tried this but i dont get any change in the size of the image.the size of the image is the size of the browser.
var screenHeight = screen.height;
$('.image').css('height',(screenHeight*0.9/100)); | You must use
$(window).height();
Check out below snippet:
var screenHeight = $(window).height();
$('.image').css('height',(screenHeight*0.9/100));
I have changed only screen height to window height. That will resize your image as per window size. You can consider your own expression in setting image height. You just need to put window height only.!
Mark as answer if you find your solution.! | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "jquery"
} |
Social login in flutter
I'm trying to implement social login in my application, the front-end is built with Flutter and my backend with Django and Django rest framework.
In flutter i'm using Google_sign_in package to connect users when i get access token i send it to the backend. after this i request informations of my user from google with the access token if the user exits in Django database i return authentication token if not i create new user and i return authentication token.
My question is: is it safe or are there better ways to do it? | Yes, It is completely safe, I used `django-allauth` library to social login and when i used it, i didnt relay on any other libs.
With the save `lib`, It supports all the leading social media and website for `auth` login.
Here you go for the docs: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "django, flutter, authentication, django rest framework"
} |
WinRT FlipView like control in WP8
In my app I need to display a collection of Images exactly like in the Windows Phone 8 Photo App where you can swipe right and left between the images.
I've tried both the Panorama and Pivot control but both controls don't behave like WinRTs FlipView.
Panorama fits quite well but appears to have the "Right-Peek" Amount hardwired into the control. (please correct me if I'm wrong)
Pivot in turn shows blackness during swipes (finger still down) and only displays the next image when you release your finger and the control scrolls the next item into place.
Any suggestions? | There is no direct equivalent to the FlipView in Windows Phone. The Panorama and Pivot controls have very different functionalities and are designed fro different purposes.
Telerik have a SlideView control which is very similar to the native control used by the photos app.
You can also get the Telerik controls free as part of the Nokia Premium Developer Program. (Worth investigating if you don't have a Dev Center subscription.) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "windows phone 8, windows phone"
} |
How to send mail?
I'm trying to send mail from shell(GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)) using;
mail [email protected]
After I complete the command, the mail won't show up in the mailbox. What could be wrong, how can I check is my configuration is correct. Thanks. | Like every unix program that occasionally has cause to send email notifications, `mail` assumes that there is a functioning MTA on localhost that is 1) capable of accepting mail and 2) knows how to pass it on.
To find out what mail server you're running, try `telnet localhost 25` and look at the identifier string.
The command `mailq`, if it exists for you, will show you what messages are currently in the local mail server's queue, possibly with an explanation as to why it hasn't been passed on to its destination yet.
In addition, most distributions by default configure MTAs and syslog to report mail log messages to either `/var/log/mail.log` or similar. Look in `/var/log/` for any file that looks viable, and grep it for 'bar.com'
Without more information as to what's going on it's hard to offer better advice than this, sorry. | stackexchange-unix | {
"answer_score": 1,
"question_score": 5,
"tags": "configuration, email"
} |
Calculate $\int_A e^{x^2+y^2-z^2-w^2} \, dx\,dy\,dz\,dw$
Calculate $\int_A e^{(x^2+y^2-z^2-w^2)}\,dx\,dy\,dz\,dw$ where $A=\\{x, y, z, w \in \mathbb{R} \mid x^2+y^2+z^2+w^2\leq1\\}$
attempt:
$$\int_A e^{x^2+y^2-z^2-w^2} \,dx\,dy\,dz\,dw = \int_0^1 \int_{\mathbb{S}^3_r} e^{x^2+y^2-z^2-w^2} \;\mathrm{d}S \;\mathrm{d}r \\\= \int_0^1 \int_{\mathbb{S}^3_r} e^{2x^2+2y^2-r} \;\mathrm{d}S \;\mathrm{d}r = \int_0^1 \int_0^{2\pi} \int_0^{\pi} e^{2r^2 \sin^2\phi - r} r^2 \sin\phi \;\mathrm{d}\phi \;\mathrm{d}\theta \;\mathrm{d}r $$
I got stuck here. Any help please? | Note that $$A=\\{x^2+y^2\leq1, z^2+w^2\leq1-(x^2+y^2)\\}$$ So the integral becomes
$$I=\int_{\\{x^2+y^2\leq1\\}}e^{x^2+y^2}\int_{\\{z^2+w^2\leq1-(x^2+y^2)\\}}e^{-(z^2+w^2)}$$
Where the inner integral is by Fubini again:
$$(*) = \int_{-\pi}^{\pi}\int_0^cre^{-r^2}drd\theta$$
where $c=\sqrt{1-(x^2+y^2)}$.
Now, this equals $\pi(1-e^{-c^2})$, so we got
$$I = \pi\int_{\\{x^2+y^2\leq1\\}}e^{x^2+y^2} \cdot(1-e^{-(1-(x^2+y^2))})$$
Where from here, it is easier to continue by polar coordinates and similar integral as in $(*)$ | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "calculus, integration, manifolds"
} |
What value is there in supporting Android version 2.2 and lower?
Currently if I want to support fragments on older versions of Android such as 2.2 and lower I have to extend to FragmentActivity instead of Activity. Which means I have to add the FragmentActivity library to my Project. I'm just curious of the value in this, is it worth supporting lower than 2.2? | This depends on your target audience. For example I looked at my stats for the oldest app on the market I have and it shows that I still have old installs but these are about 1.6% of all my users (v 2.2 and older). Based on that I would simply go with multiple APK builds so my old customers can still download old version if they want to their ancient devices but I would do all my new development for newer version. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "android, android fragments"
} |
Is it possible for a Android application to extract the SQLite databse from another application?
I'm interested in getting the SQLite database containing browsing history from the built in browser exporting it to an SD card. I want to application to do this rather than using ADB. | No, you cannot. This would be a huge security risk. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "android, sqlite"
} |
How to know which are the highest PageRanked pages in my site?
I have a large site where I would like to know which are the internal pages with higher PageRank for optimization purpouses. How can I generate a pagerank list of all my website pages? | I basically agree with Osvaldo [*], anyway if you want to see PR value for each page, you can use Firefox and install SEOQuake plugin. It reports for each page the Google PR.
Once there was the Google Toolbar that was showing the PR of each page, but I think they removed that feature lately.
* * *
[*] I never understood why Google removed the PR in its toolbar, it was the only reason why I was using their toolbar. Even if it was just a number, I liked to see the PR of each page of my sites. It was like reading the vote given by Google to my site. | stackexchange-webmasters | {
"answer_score": 1,
"question_score": 0,
"tags": "seo, pagerank"
} |
Raising a “warning” status during SDL Tridion 2011 publishing
We would like to implement some functionality so that when for some reason an error occurs during publishing or resolving, and we skip over it using a try/catch block, but would still like to notify the user that something was skipped.
The SDL Tridion 2011 Publishing Queue can filter by status. One of these statuses is “Warning”. Is it possible to trigger a publish transaction to have a “Warning” status using the API in either template code or a custom resolver? | I'm afraid this isn't possible, but the answers above might help you find an alternative solution to this. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 3,
"tags": "tridion, tridion 2011"
} |
Using CHARINDEX and SUBSTRING in a CASE statement
I need to evaluate a field with a CASE statement. The field name is Commodity and is a varchar(255). The values differ and I need to extract a specific portion from it after a specific character. The character is a '>'. I was able to come up with the value I want returned after the > by using the following code:
SUBSTRING(Commodity, CHARINDEX('>', Commodity) + 2, LEN(Commodity))
I am however unsure of how to work this into my CASE statement. I need to test for Is Null and then just assign it a value of 'No Commodity'. Then I need to test for the presence of a > and then implement the code above to return the value. Then I need to test for when there is no > but it is not null and just return the value of the Commodity field. | You just need to have these three conditions in `when` clauses. You can use `charindex` to make sure the `>` character exists in the string:
CASE
WHEN commodity IS NULL THEN 'No Comodity'
WHEN CHARINDEX('>', Commodity) > 0 THEN
SUBSTRING(commodity, CHARINDEX('>', commodity) + 2, LEN(commodity))
ELSE comodity
END | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 4,
"tags": "sql server, sql server 2012, substring, case, charindex"
} |
How can i get all elements with a selector attribute with VanillaJS?
I'd like to get all elements with a specific `data-` attribute, but I need to manipulate they individually. Check my code:
**HTML**
<div data-something></div>
<div data-something></div>
**JavaScript**
document.querySelectorAll("[data-something]").onclick = function() {
...
} | Below is how you can get all elements with a selector attribute and create an onclick listener for each element.
Run the snippet, and click the "click me -- A" or "click me -- B" links for a demo:
var elements = document.querySelectorAll('[data-something]');
Array.prototype.forEach.call(elements, function (element) {
element.onclick = function () {
alert(element.innerHTML);
};
});
<div data-something>click me -- A</div>
<div data-something>click me -- B</div>
You can also use `.addEventListener('click', someFunction)` instead of `.onclick = someFunction`. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "javascript"
} |
"一目ぼれから長持ちする関係は望めません。" この表現のニュアンスを説明して頂けませんか?
>
>
> Falling in love at first sight won't bring you a lasting relationship.
I found this sentence and translation without any other context, and have a few questions about the expressions used here.
First off, after studying the sentence, I came up with two alternate translations:
> You can't hope for a long-lasting relationship from falling in love at first sight.
>
> You cant expect a long-lasting relationship from falling in love at first sight.
Which translation of do you think is more accurate (if accurate at all)?
Secondly, if is a verb meaning "to be long-lasting" or "to be durable", is ever used by itself, perhaps as a noun? | As for your second question, []{} can mean the fact that something lasts long (). For example, the title of this page is []{} (the secret of taste and long life (of the food products)).
also means a container with a lid to store cloths and other goods, usually made of wood.
As for your first question, I still have trouble understanding the difference among the three English expressions in the question. My understanding is that their meanings are the same (although the meanings are different _on surface_ ), and I think that they are equally correct translations. Probably my understanding of English is insufficient for me to answer this part of your question. | stackexchange-japanese | {
"answer_score": 3,
"question_score": 3,
"tags": "grammar, vocabulary, nuances, verbs"
} |
Is there a way to find out how many times an image is covered?
suppose for instance the curve:
$$\begin{bmatrix} x = f(t) \\\ y=g(t) \end{bmatrix}$$
which is parametrized as above. I want to understand how many times the image of this curve in the $(x,y)$ plane is covered.
For instance If this is a 1-to-1 map then the whole image is covered only once. but if there exists $t_1, t_2 \in R$ such that $$(x_1,y_1)=(f(t_1),g(t_1))=(f(t_2),g(t_2))$$
Then I say that the point $(x_1,y_1)$ is covered twice. I want to know whether there exists a method for understanding the number of coverings of each subset of the image set. Does such a method exist? | There is no general method which would not depend on what $f$ and $g$ are ; indeed, given any number of finite points $P_1,...,P_n \in \mathbb{R}^2$, together with integers $k_1,...,k_n$ greater than $1$, you can find two polynomial functions $x,y$ such that the curve $(x(t),y(t))$ will go through $P_i$ exactly $k_i$ times for all $i \in \\{1,...,n\\}$. To see that, you just need to use Lagrange interpolation on the coordinates $(x_i,y_i)$ of each $P_i$.
EDIT : I did not precise it before, but you can also decide on which time $t$ you will have $(x(t),y(t)) = P_i$ | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "calculus, differential geometry"
} |
cudaGetLastError returned (0xb)
I am trying to resolve a CUDA runtime error. Debug information reported by cuda-gdb (with cuda-memcheck on):
warning: Cuda API error detected: cudaLaunch returned (0xb)
warning: Cuda API error detected: cudaGetLastError returned (0xb)
[Thread 0x7fa1a28c5700 (LWP 43041) exited]
[Thread 0x7fa1a16a5700 (LWP 43042) exited]
[Thread 0x7fa18df0e700 (LWP 43056) exited]
I have checked the block, grid dimensions, and the size of the dynamic shared memory being used, they are well below the limit. Please tell me what (0xb) error type stands for, I didn't find it in the cuda documentation. Also, please tell me any suggestion on how to solve this issue?
Device : Kepler K20 (CC=3.5) and CUDA 5.5
Code is too big to paste here. | If you do proper cuda error checking in your code, you can retrieve that 0xb error that is being reported from a `cudaGetLastError` call, and pass it to a decoder (`cudaGetErrorString`) that will tell you something more meaningful.
CUDA runtime API error codes are enumerated in `driver_types.h`, which on a standard linux install will be in `/usr/local/cuda/include` Search on `cudaSuccess` which will be the first enumerated type (i.e. 0) then continue on until you find your error number.
In this case `0xb` (= 11) refers to `cudaErrorInvalidValue`:
/**
* This indicates that one or more of the parameters passed to the API call
* is not within an acceptable range of values.
*/
cudaErrorInvalidValue = 11, | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 4,
"tags": "cuda, cuda gdb"
} |
How to examine processes in OS X's Terminal?
I’d like to view information for processes running in OS X. Running `ps` in the terminal just lists the open Terminal windows. How can I see all processes that are running?
Say I’m running a web browser, terminal and text editor. I’d like to see information for the text editor and web browser. | You can just use `top` It will display everything running on your OSX | stackexchange-stackoverflow | {
"answer_score": 52,
"question_score": 68,
"tags": "macos, process, terminal, ps"
} |
Calculate a limit $\lim_{n\to \infty} \frac{1}{n} \sum_{k=1}^n \Big\{\frac{k}{\sqrt{3}}\Big\} $
The problem is to calculate a limit $$ \lim_{n\to \infty} \frac{1}{n} \sum_{k=1}^n \Big\\{\frac{k}{\sqrt{3}}\Big\\} $$ where {$\cdot$} is a fractional part. I believe that this limit is equal to $\frac{1}{2}$, but I do not have a rigorous proof. The only idea that comes to my mind is the following one. It can be shown that the set $$ A=\bigg\\{ \Big\\{\frac{k}{\sqrt{3}}\Big\\} : k\in \mathbb{N}\bigg\\} \subset [0,1] $$ is dense and equidistributed. That's why the mean value represented by the limit is equal to the mean value of the uniform distribution $U(0,1)$ which is equal to $1/2$. How can I make the proof rigorous?
Any other approaches are appreciated. Probably one can apply law of big numbers to calculate this limit. | You may use a rescaled version of Khinchin's equidistribution theorem:
$$ \lim_{n\to +\infty}\frac{1}{n \sqrt{3}}\sum_{k=1}^{\left\lfloor n\sqrt{3}\right\rfloor} f\left((x+ka)\\!\\!\\!\\!\pmod{\sqrt{3}}\right) = \frac{1}{\sqrt{3}}\int_{0}^{\sqrt{3}}f(y)\,dy. $$ We have $\left\\{\frac{k}{\sqrt{3}}\right\\}=\frac{1}{\sqrt{3}}\left(k\\!\\!\pmod{\sqrt{3}}\right)$, hence the limit is given by: $$ \frac{1}{3}\int_{0}^{\sqrt{3}}y\,dy=\color{red}{\frac{1}{2}}$$ as expected (pun intended, now).
Anyway, since we are dealing with a trivial case of Khinchin's theorem, we may just expand $\\{x\\}-\frac{1}{2}$ as a Fourier sine series and use termwise integration to prove just the same. | stackexchange-math | {
"answer_score": 5,
"question_score": 4,
"tags": "calculus, real analysis, sequences and series, probability distributions, fractional part"
} |
How to have 3 divs aligned up next to each other so that they are in between a bottom and top div?
I want 3 divs to be aligned up next to each other so that they are in between a bottom and top div. When floating all 3 divs to the left they are pushed to the bottom of the surrounding divs. If I float all the other divs it leaves a huge gap up top.
There is another lot of divs to the left of these divs which have css `clear:left`. When this is removed all the divs are the floated next too each other up the top of the page.
Is there an alternate route around aligning divs? or am I just doing something wrong? | My guess is you need to give the bottom div `clear: left` so that it doesn't move above your three floating divs.
See The One True Layout for an example of this done successfully. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, html, css"
} |
Javascript communicate with C++
I have a desktop application that has a C++ backend and a HTML5/JS front end. We are currently having to use Google V8 or Mac Webview and Objective-C to allow Javascript and C++ to communicate. Is there any way to have them directly talk to each other without the middleware?
Trying to accomplish:
1. Share variables.
2. Call Functions from C++ to JS.
3. Call Functions from JS to C++.
I have tried googling this and everything points to the above solutions. | You could try using Google's Protocol Buffers which allows you to create data objects that get compiled to C++ objects. You could then use one of the following projects from their wiki to use protobuffers with javascript:
* <
* < | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 12,
"tags": "javascript, c++"
} |
Getting and extra size on my page
as you can see in this links
<
and the end of the page I getting a white line and I don't understand why.
Could you help me to resolve this issues.
Thanks in advance for your help. | Remove the `padding-bottom` line in `body` of the CSS; that makes that "white line" appear.
body {
padding-bottom: 40px;
color: #5a5a5a;
}
to
body {
color: #5a5a5a;
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "html, css"
} |
Is there a way to convert to a type from multiple other types in Rust?
I'm in a situation where I'm frequently composing a struct from two other types:
struct Foo {
a: usize,
b: usize,
}
enum Bar {
X,
Y,
Z,
}
struct Baz {
bar: Bar,
a: usize,
b: usize,
}
impl Baz {
fn new(bar: Bar, a: usize, b: usize) -> Self {
Baz { bar, a, b }
}
}
fn main() {
let foo = Foo { a: 1, b: 2 };
let bar = Bar::X;
let baz = Baz::new(bar, foo.a, foo.b);
}
I would love to use something like the `From` trait here, but given that I'm pulling from two different types, I don't think it's possible. Is there a cleaner or more idiomatic way to accomplish this or should I just use a macro? | As EvilTak proposed:
impl From<(Foo, Bar)> for Baz {
fn from((Foo { a, b }, bar): (Foo, Bar)) -> Self {
Baz { bar, a, b }
}
}
Then, you can use it like:
let baz = Baz::from((foo, bar)); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "rust"
} |
Using Mojo.Environment.DeviceInfo frameWork
How can i get Device information using **Mojo.Environment.DeviceInfo** , Pleasae help me. | `this.HEIGHT = Mojo.Environment.DeviceInfo.screenHeight;`
Just swap out screenHeight with what ever you're looking to use
| stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "webos, palm"
} |
How do I redirect an .aspx url to a php page?
How do I redirect an .aspx url to a php page? I have links from my old site being domain.com/song.aspx?SongID=1 which I'd like to redirect to a domain.com/song.php?SongID=2 file. Can you someone tell me how to do this? I'm open to either using htaccess or a plugin. If I use a plugin, I need to be able to have the song.php also get the querystring after song.aspx. | Htaccess is probably the best way to go. This rule is pretty general, but should do the trick.
RewriteRule ^song\.aspx$ song.php [R=301,QSA,L]
QSA stands for "Query String Append" and will append the query string from the old URL to the new URL. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "redirect, .htaccess"
} |
Rails: before_save variable contents
I'm reading a guide about Rails and I came across this line in a Model class:
before_save { |user| user.email = email.downcase }
This is to make sure that the email address is lowercase before it hits the database (but you already know that, because you guys and gals are smart!).
However, why not just have this:
before_save { |user| user.email.downcase! }
Wouldn't that be simpler to execute, or am I missing something? | Both do the same.. it just comes down to taste. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "ruby on rails, before save"
} |
DrawerLayout open slowly
I'm working on an app designed to use a DrawerLayout that contains a ListView, and i got an issue whit it . I'm using an ALCATEL IDOL MINI , API 17 to debug.On that phone , the drawer slide normally , even if the content is populated by views and information , also the scroll speed of the ListView is normal.but when i tested my app on another phone (Samsung Galaxy S3 API 19 and Nexus 5 API 21),the drawer slide very slowly with some lags and also the speed of scrolling the ListView inside is slow ,just when the content is populated by views and information. It doesn't make any sense because the S3 and Nexus 5 are more powerful . | I Finally resolved the problem , it was a background image issue , i used a HD image as background of the **drawerlayout** and also the **ListView** , now after i changed the background , the Drawer slide smoothly and items of the List are scrolled smoothly as well. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "android, navigation drawer"
} |
What is the difference between string.c_str() and &string[0]?
What are the differences between `string.c_str()` and `&string[0]`?
Regarding performance my guess is that `&string[0]` is a little faster than string.c_str() as it doesn't require a function call.
Regarding safety and stability common sense tells me that `string.c_str()` should have some checks implemented, but I don't know, that's why I'm asking. | In C++98 there is no guarantee that the internal array is null terminated; in other words `string.data()[string.size()]` results in undefined behavior. The implementation will then reallocate the array with the null termination when `c_str()` is called but can leave the null terminator off when it isn't.
This also means that `&string[0]` is not guaranteed to be null terminated (it is essentially a detour to `data()`)
In C++11 the null termination guarantee is specified so `string.data()==string.c_str()` is always valid. | stackexchange-softwareengineering | {
"answer_score": 8,
"question_score": 5,
"tags": "c++, c"
} |
Disable C# 6.0 Support in ReSharper
While using ReSharper, it suggested "Enable C# 6.0 support for this project". I foolishly clicked on it, and now as advertised it's giving me suggestions for C# 6.0 - which then give me errors as I am not using C# 6.0 in this project.
How can I disable C# 6.0 support, returning it to how it was before? (Preferably without having to individually ignore specific suggestions) | Click the project node in the Solution Explorer. Then look in the Property Grid (F4). You'll see a property named "C# Language Level". Set that to "Default" or your desired language level.
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 165,
"question_score": 140,
"tags": "c#, resharper"
} |
How can I get rid of the diagonal wires in wireframe boxes?
I create a box with a material and set that material to be wire framed.
Box b1 = new Box(new Vector3f(1.0f, -2.0f, 1.0f), 1.0f, 1.0f, 1.0f);
Geometry geom1 = new Geometry("Box", b1);
Material mat1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat1.getAdditionalRenderState().setWireframe(true);
mat1.setColor("Color", ColorRGBA.Blue);
geom1.setMaterial(mat1);
However, because the box is drawn using triangles there are diagonal wires visible:
!Screenshot
How can I get rid of these diagonal wires (not draw them)? | As said in the comments. Wireframe rendering is used to show what polygons are being drawn, and is generally only used when debugging.
To solve you problem...
What you want is to only draw lines around the edge of the cube. And there are many ways you can acheive this...
1. Render a texture on to the cube, which has alpha everywhere but the edges.
2. Use a pixel shader to turn all pixels that are not at the edge of the cube to alpha. <\- This is recommended by me, as you will be able to set the line length around the cube. | stackexchange-gamedev | {
"answer_score": 9,
"question_score": 4,
"tags": "java, jmonkeyengine"
} |
SVG graphics fully black when opening it as SVG Marker in QGIS
I have an SVG graphic that should be placed in certain locations on my map in QGIS 2.18.
 from the SVG graphics for instance with Notepad++ solved my issue. See the image below.
<defs> #delete this tag
<style>
.cls-1{fill:url(#Unbenannter_Verlauf_20);}
.cls-2{fill:#80ba27;}
</style>
<linearGradient id="Unbenannter_Verlauf_20" x1="25.35" y1="50" x2="25.35" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#004a99"/>
<stop offset="0.36" stop-color="#024d99"/>
<stop offset="0.63" stop-color="#075699"/>
<stop offset="0.86" stop-color="#106699"/>
<stop offset="0.91" stop-color="#136b99"/>
</linearGradient>
</defs> #delete this tag
;
temp = [Object: null prototype] {
__typename: 'ItemConnection',
aggregate:
[Object: null prototype] { __typename: 'AggregateItem', count: 3 } }
When I attempt to do:
const a = JSON.parse(JSON.stringify(temp));
console.log(a);
I get the above mentioned error message, `SyntaxError: Unexpected token u in JSON at position 0`.
How do I resolve this? | `Unexpected token u in JSON at position 0` is a pretty good indicator that you tried `JSON.parse("undefined")`. Which means `temp` must be undefined.
Most likely, your `readField` function does not return a value or expects a callback instead. Make the function return a proper value and you won't get this error. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "javascript, prisma"
} |
Why can't I use https to access the stackexchange sites?
In order to be more secure in my external transmissions, I tried to use < and found that I could not login.
Actually I get a 403/HTTP Authentication request, but its not like going to < site.
Is there a reason https browsing is not enabled for ServerFault and the other Stack Exchange sites? | But everything on StackExchange is publicly searchable and the actual OpenID authentication is secured over TLS - so there would be no point handling regular site traffic securely. | stackexchange-meta_serverfault | {
"answer_score": 5,
"question_score": 12,
"tags": "discussion, stackexchange, https"
} |
express-flash messages are empty after refresh
The express-flash module does not work correctly. When I add a message, it's empty on the next page refresh.
This is a part of my app.js:
var flash = require('express-flash');
var session = require('express-session');
app.use(session({
secret: 'keyboard ctrl',
resave: false,
saveUninitialized: true,
cookie: { maxAge: 60000 }
}))
app.use(flash());
app.get( '/', login);
And this is in my login module
exports.login = function(req, res){
console.log(req.flash('error'));
req.flash('error','Test errors!');
res.render('user_login');
};
The log output is always an empty array when I refresh the page multiple times. | `express-flash` extends `connect-flash` so you don't require a redirect (or a new page load) before the flash messages are available.
It does so by patching `res.render()` to retrieve all flash messages, so they become available as `messages` inside your templates.
However, after retrieving all flash messages, the list of messages will be emptied, because it is assumed that when they are retrieved, they are used. That's how `connect-flash` works.
So after calling `res.render` in your login handler, the list of messages will be empty.
Having a list of flash messages persist across page reloads isn't trivial to implement, because you have to determine if something is a reload or a "normal" page load. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, node.js, express, session, flash message"
} |
Setting radio buttons from MySQL database
I'm trying to adopt this code taken from w3school.com but cannot see how I can preset the buttons by PHP based on the value stored in a Boolean MySQL column.
<form>
What color do you prefer?<br>
<input type="radio" name="colors" id="yes" value="1" >Yes<br>
<input type="radio" name="colors" id="no" value="0" >No
</form>
<button onclick="check()">Check "Yes"</button>
<button onclick="uncheck()">Uncheck "Yes"</button>
<script>
function check() {
document.getElementById("yes").checked = true;
}
function uncheck() {
document.getElementById("yes").checked = false;
}
</script> | You can use `checked` attribute with `echo`. I don't know how you get your data but for exemple :
<form>
What color do you prefer?<br>
<input type="radio" name="colors" id="yes" value="1" >Yes<br>
<input type="radio" name="colors" id="no" value="0" <?php echo $variableOnMyDatabase ? "checked": "" ?> >No
</form> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, html, mysql"
} |
In pandas, how do I create columns out of unique values in one column, and then fill it based on values in another column?
I have an n x n column where two of columns as follows:
height cost item_x cost2 item_y weight
15 10 bat 45 mitt 2
19 12 ball 30 ball 4
24 13 gloves 25 gloves 6
22 14 bat 20 mitt 8
I want to create unique columns for unique values of item_x and item_y, and fill them with appropriate values from cost and cost2 columns. So the expected output would be:
height bat_x ball_x gloves_x mitt_y ball_y gloves_y weight
15 10 0 0 45 0 0 2
19 0 12 0 0 30 0 4
24 0 0 13 0 0 25 6
22 14 0 0 20 30 0 8
Any help would be much appreciated! | I would do a `concat` on a `pd.get_dummies`:
# extract the suffixes `_x, _y`
suffixes = df.columns.str.extract('(_.*)$')[0]
# output
pd.concat([pd.get_dummies(df.iloc[:,i+1])
.add_suffix(suffixes[i+1])
.mul(df.iloc[:,i],axis=0)
for i in range(0,df.shape[1], 2)],
axis=1
)
Output:
ball_x bat_x gloves_x ball_y gloves_y mitt_y
0 0 10 0 0 0 45
1 12 0 0 30 0 0
2 0 0 13 0 25 0
3 0 14 0 0 0 20 | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, pandas, dataframe, data science, data cleaning"
} |
Overwriting variable in Unity C#
I'm making a script in Unity using C#. I'm trying to use the Update() method to detect once the Camera position is past a certain point and then Instantiate an object into the scene and overwrite the variable "x" to something else so this only happens once. The problem is I cant overwrite this "x" variable.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour{
public GameObject GroundSprite;
public int x = 1;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (((Camera.main.transform.position.x) < -4) && ( x == 1))
{
Instantiate(GroundSprite, transform.position, Quaternion.identity);
int x = 2;
}
}
} | Please remove int from below code, your value will be overwritten.
// Update is called once per frame
void Update()
{
if (((Camera.main.transform.position.x) < -4) && ( x == 1))
{
Instantiate(GroundSprite, transform.position, Quaternion.identity);
//int x = 2;
x=2;
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "c#, unity3d, variables, void, overwrite"
} |
What is the best way to code up a Month and Year drop down list for ASP.NET?
I have an internal application that I needs to have a drop down list for two date type elements: **Month** and **Year**. These values are not in a database or other repository of information.
I know I could just setup a list with the values I need by adding them to a dictionary like object (I need to correlate the Month to the numerical representation, January => 01):
var months = new Dictionary<String,String>();
months.Add("01", "January");
...
The drop down list for the year will be a bit easier as I can just choose a starting year and iterate up to the current or current+1 year in a generic list.
Is there a better way to handle these data elements? Something built in, or a good design pattern that I should be implementing? | You could use this to get a list of all the Month names and loop through it.
CultureInfo.CurrentCulture.DateTimeFormat.MonthNames
You can use it like this...using the index of the Month as the value for your dropdown
var months = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames;
for (int i = 0; i < months.Length; i++)
{
ddl.Items.Add(new ListItem(months[i], i.ToString()));
} | stackexchange-stackoverflow | {
"answer_score": 31,
"question_score": 12,
"tags": "c#, asp.net, vb.net, webforms"
} |
Is there a way for an NSView to know when its window is closed?
I'm working on an NSView subclass and I'd like to know when its window is closed so I can do certain housekeeping tasks. What is the standard way to do this? If possible, I'd like to do this within the NSView subclass since I'd like to be able to use this subclass elsewhere without other dependencies. | You can override `-viewDidMoveToWindow` and, if `self.window` is not `nil`, have the view start observing the `NSWindowWillCloseNotification` notification from the window.
Likewise, override `-viewWillMoveToWindow:` and, if `self.window` is not `nil`, stop observing that notification for that window. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "macos, cocoa, nsview, nswindow"
} |
Why does a foreach loop which iterates more than 10,000 times run out of memory?
I'm developing a PHP script that loops/iterates more that 10,000 times:
foreach ($array_with_items as $item) {
// Instantiate the object
$obj_car = new CarAds($puk, 'ENG', '5');
$obj_car->detail1 = "Info about detail1";
$obj_car->detail2 = "Info about detail2";
$obj_car->detail3 = "Info about detail3";
$obj_car->detail4 = "Info about detail4";
// Saves to the database
$obk_car->save;
}
When I run this code my machine runs out of memory. What can I do to clean the memory in this foreach cycle? | You are instantiating as CarAds objects as your $array_with_items item count. Each one allocate memory.
After the save() method you should deallocate the object with the unset() function:
// Saves to the database
$obj_car->save;
// Unset unneeded object
unset($obj_car);
You can check your memory consumption with the memory_get_usage() (see < | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 6,
"tags": "php, out of memory"
} |
DOM/PDF error - Non-static method Barryvdh\DomPDF\PDF::download() should not be called statically
My Controller is this:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Barryvdh\DomPDF\Facade as PDF;
class PrintPDF extends Controller
{
public function print(){
$details =['title' => 'test'];
$pdf = PDF::loadView('textDoc', $details);
return $pdf::download('this.pdf');
}
}
My routes
Route::get('/print', 'PrintPDF@print');
when accessing localhost/print I get an error
> Non-static method Barryvdh\DomPDF\PDF::download() should not be called statically
I followed the install instructions on their site. I have tried to change my controller adding use PDF, instead of use Barryvdh\DomPDF\Facade as PDF; Yet the error persists | make the function call like this
return $pdf->download('invoice.pdf'); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 3,
"tags": "laravel, dompdf"
} |
Getting PDF color in PHP
I am trying to make project of a web app that will check the colour of the PDF document. My preferred language is PHP.
At the begining I've been thinking about GD, but this only refer to images (jpg, png, gif). Nothing for PDF. For images I am going to use some method similar to this: Get image color.
So does anyone know some method, library (opensource), or something else to make such app? I can't find any examples on the web. | You'll probably be best off converting the PDF into an image, and then using the same method you're using for images. In addition to being easy to do, that will also guarantee consistent results.
However, converting a PDF file to an image is not something that PHP alone is well-equipped to do. The best way to go is the ImageMagick based approach as described in this question. It gives a number of alternatives, too. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "php, pdf, colors, fpdf"
} |
ASP.NET Is there a simple way to store data in a tree other than treeview?
So I have a menu system that uses a tree to hold its values, but its currently in a treeview and I don't want to display the tree so the "view" part is unnecessary. I'm sure this is an inefficient way to organize a tree, so I was wondering if theirs a tree data structure in c# or if I'd have to make a simple one from scratch or even if the treeview saps enough effiiency from a web app to bother with?
thanks | There is no built-in tree data structure in C#, but you can create your own as described in the answer to this previous question Build a simple, high performance Tree Data Structure in c#. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "asp.net"
} |
MySQLi Escape String
Every time I try mysql(i)_real_escape_string the value put into the MySQL table cell is empty. Always. Anyone help? I use the object orientated version of it and I tried the exactly same code with that function and without it, and it worked perfectly when it was not there. | Three rules to get it right:
1. do not use this function in the application code
2. do not put your variables directly into query but use **prepared statements**
3. do not use raw mysqli in the application code but use some higher level abstraction, at least PDO | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "mysqli, mysql real escape string"
} |
Error on executing Javascript, works by clicking anchor
I have a web page I need to manipulate using either DOM or JavaScript, in a Cocoa app.
There's a link on that web page that triggers a Javascript event.
That link has only a href that points to `javascript:doThis('onThat')`
When I click that link using my browser, that works just fine, /though/ an error appears on the browser console saying that the variable `doThis` wasn't found. The Javascript, however, runs.
When I try to execute `javascript:doThis('onThat')` on the web page, by using either the evaluate Javascript command of Cocoa or on the browser's console, it doesn't work, with the error that the variable `doThis` isn't nowhere to be seen... Though, I repeat, it works just fine when I click on the anchor, and the anchor only points to that Javascript code.
Any help would be appreciated. | If you are trying to execute JavaScript code on the Console, you should not be using `javascript:`, instead you just try running it by invoking the function `doThis('onThat')`. When you put a piece of JS code in the `href` attribute of an anchor element, then it signals the browser what to do, in this case the browser tries to evaluate that piece of code, and if it finds the function in that webpage it executes it else it just throws up the error.
Just try running your code without `javascript:` in the Console. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, cocoa, dom, dom events"
} |
Disable Puppet agent runinterval
I am using the following Puppet version on CentOS Linux release 7.2:
# puppetserver -v
puppetserver version: 2016.5.0.11
I have a Win agent node and i might have few more later. Agent version on Win node:
C:\Windows\system32>puppet --version
4.8.1
I would like to disable the agent `runinterval` _permanently_ so i can _only_ push from my Puppet server when required. I saw few links and tried putting the following line in Puppet server's `/etc/puppetlabs/puppet/puppet.conf` file. I also restarted the server but still the agent is fetching the catalog.
[agent]
daemonize=false
I would also like to know whether it's possible to disable `runinterval` only on specific nodes. If yes, how? | What you are basically looking at doing is stopping the Puppet service. This is accomplished most easily with a puppet `service` resource:
service { 'puppet':
ensure => stopped,
enable => false,
}
To do this only on certain nodes, merely supply it for the corresponding node definitions in your classifier or main site manifest:
node /ones_to_disable/ {
service { 'puppet':
ensure => stopped,
enable => false,
}
}
This is the easy and common method for accomplishing push-style Puppet and disabling pull-style. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "puppet, puppet enterprise"
} |
The difference in image resolution (ppi) between C# and Photoshop
For example, C # says that the selected image contains 96 ppi, while that same image in Photoshop contains 72 ppi.
**Why is there a difference?**
I’m inclined to trust Photoshop in this case, and how to test image resolution if C# returns false results?
We need to build some sort of validator control that rejects all images with ppi != 300.
Control should support the following formats: jpg, jpeg, gif, png, bmp.
Code is listed below:
Image i = Image.FromFile(FileName);
Console.Write(i.VerticalResolution);
Console.Write(i.HorizontalResolution); | DPI means dots (pixels) per inch. The physical size in inches is subjective, based on the current monitor's size and resolution. Unless you're relying on metadata (which gif and bmp don't contain) you cannot reliably calculate this.
Photoshop simply has a prescribed value for DPI, which it uses when translating images for print. This value is stored in the PSD file and may be copied to JPEG metadata, but if you save the image in a format without DPI metadata, the information is not stored.
**Update:**
The reason your code gets a different value is that C# fetches its `VerticalResolution` and `HorizontalResolution` values from the current DPI setting on the computer. Photoshop's DPI is for use with print, so it knows the physical dimensions if you want to send your image to a printer. It has a default value of 72dpi, but you can change this. The value has no meaning on a screen, though, since screens deal in pixels only. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 3,
"tags": "c#, image, photoshop, ppi"
} |
How to dismiss Java security warning
How to avoid this message on Windows XP, please?
I have tried to create the exception for my domain (with trusted SSL certificate) in Java settings, put all the security levels to the lovest values but this warning still occurs.
It is really annoying when I have to click on this 3 times a minute (Zebra printer printing applet).
!enter image description here
Thanks | 'Trusted SSL certificate' is irrelevant. You need to sign the applet with a trusted _signing_ certificate. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, security, ssl, applet"
} |
What is the difference between the states of matter and the phases of matter?
What is the difference between the states of matter and the phases of matter? Should solid, liquid and gases be called states of matter or phases? How many states and phases are there? Different sources quote different things. Please help | States are more the gas/liquid/solid thing, describing the qualitative behavior of some matter.
Phases describe a collection of matter (often a region) as opposed to that collection's state. This can be confusing because we often refer to phases by their state for convenience.
For example, multiphasic liquid systems have several phases but only 1 state (liquid). A common example is oil and water when the two don't mix; then, there's an " _oil phase_ " and an " _aqueous phase_ ".
This might be confusing since some simple examples have one phase per state. For example, when we talk about water boiling, there's a " _liquid phase_ " and " _gas phase_ ". Here the regions are the phases and the gas/liquid qualifiers describe the state of matter in them. | stackexchange-physics | {
"answer_score": 4,
"question_score": 5,
"tags": "thermodynamics, condensed matter, solid state physics, phase transition, states of matter"
} |
Can someone break into a Leomund's Tiny Hut via the Ethereal Plane?
I've got players who rely heavily on Leomund's Tiny hut for a "safe" night time rest. I'm alright with them using it to help, but it gets irritating having a wrench thrown into my nighttime attacks. I have found some ways to deal such as Dispel Magic or having something camp them. One time, I even attacked and killed their horses which were outside the hut. I was going to try a burrowing creature but SageAdvice put forward that there IS a floor in the hut. That's when I came across the Phase Spider. So the question:
Could something move into the Ethereal Plane, get to an area that would be inside Leomund's Tiny Hut, and then move back to the Material Plane? | ## No, Leomund's Tiny Hut is made of magical force which blocks passage in the Ethereal Plane
In the description of the Border Ethereal on DMG p. 48:
> A traveler on the Ethereal Plane is invisible and utterly silent to someone on the overlapped plane, and solid objects on the overlapped plane don’t hamper the movement of a creature in the Border Ethereal. **The exceptions are certain magical effects (including anything made of magical force)** and living beings.
So, objects made of magical force will block passage on the Ethereal Plane just as they do on the Material plane.
The description for Leomund's Tiny Hut (PHB, p. 255) says:
> A 10-foot radius immobile **dome of force** springs into existence around and above you and remains stationary for the duration.
So, since Leomund's Tiny Hut is a dome of magical force, it should protect your party from intruders on the Ethereal Plane as well. | stackexchange-rpg | {
"answer_score": 39,
"question_score": 24,
"tags": "dnd 5e, spells, wizard, ethereal plane"
} |
Using functions issue
can somebody explain me this, if I have a method which returns boolean, like this
public boolean APlusB(int a,b,c){
if((a+b)==c){
return true;
}else {
return false;
}
}
and then I code something like this
ArrayList<Boolean> arrayList = new ArrayList<>();
arrayList.add(APlusB(1,2,3));
if(APlusB(1,2,3)){
Log.e(tag,"Success");
}else{
Log.e(tag,"Fail");
}
So, in this part I used APlusB function 2 times or that part with if isn't counted?
Thank you. | Yes, You are calling it twice. Doesn't matter how many times u pass the same parameters either for checking or getting value, U are calling that function.
1. `arrayList.add(APlusB(1,2,3));`
2. `if(APlusB(1,2,3)){ .. }`
3. `APlusB(1,2,3)`
4. `arrayList.add(APlusB(1,2,3));`
5. `APlusB(1,2,4)` and so on.
*above example I am calling APlusB 5 times. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "android"
} |
Optimization of quadratic forms
Suppose $\mathcal{A}$ and $\mathcal{B}$ are finite collections of symmetric idempotent matrices, and that $x$ is a fixed vector. If
$$ A^* \in \underset{A \in \mathcal{A}}{\operatorname{argmin}} x^T A x, \qquad B^* \in \underset{B \in \mathcal{B}}{\operatorname{argmin}} x^T B x $$
is the following true?
$$(A^* , B^*) \in \underset{A \in \mathcal{A}, B \in \mathcal{B}}{\operatorname{argmin}} x^T AB x $$
Any insights would be much appreciated! | Here's a simple counterexample: take $x = (1,1,1,1,1)^T$, $\mathcal A = \\{A,M\\}$, $\mathcal B = \\{B,M\\}$, where
$$ A = \pmatrix{1\\\&1\\\&&0\\\&&&0\\\&&&&0}, M = \pmatrix{0\\\&0\\\&&1\\\&&&0\\\&&&&0}, B = \pmatrix{0\\\&0\\\&&0\\\&&&1\\\&&&&1}. $$ We have minimizers $A^* = B^* = M$, but $x^TA^*B^*x = 1$, which is greater than $x^TABx = 0$.
If you want a counterexample with disjoint sets, you can replace the element $M$ of $B$ with $\epsilon I + (1 - \epsilon)M$ for some sufficiently small $\epsilon > 0$. | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "linear algebra, matrices, optimization, quadratic forms"
} |
VS cant browse SSAS cube
When I try to browse a cube in VS2012 it will crash my VS instance even though it deployed perfectly fine. I have tried different combinations of uninstalling and re-installing software. I am wondering what could possibly be missing.
I have analysis services running as a service
I have SQL server Data tools installed
I have Office Dev Tools for VS2012 installed
I have SQL Server Management studio installed
I have Office installed
I am able to browse the cube fine in excel | My team was unable to pinpoint the problem. Reformatting the machine and installing everything fresh fixed the problem quickly. No way to fully know what went wrong but there were some strange registry entries that may or may not have contributed to the problem even if the logs didn't show that. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, sql server, visual studio 2012, olap cube, sql server 2012 datatools"
} |
Concatenation string with variable in emblem.js
I need in Emblem.js to transmit to i18n helper concatenated string constant with variable value, How can i do it?
each item in model.items
div
t "dict.{{item}}"
returns error
Missing translation for key "dict.{{item}}" | If you're using Handlebars 1.3+, you can use a subexpression. First, write a string concatenation helper:
Ember.Handlebars.helper('concat', function (a, b) {
return a + b;
});
Then use it like this (sorry, I don't know Emblem so I'm going to use the normal stache syntax):
{{t (concat 'dict.' item)}} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "ember.js, handlebars.js, emblem.js"
} |
Server-side paging but at the cost of losing sorting
I have implemented server-side paging at 10 items per page for 1000 item result set, so that it pages 10 items per page. When I had it client side, I could page 10 at a time and if I sorted, it would sort against the entire 1000 items, but only show 10 items per page. However, using server-side paging where my REST call only returns 10 items at a time, my sorting is only within 1 page at a time since it can't compare against the other 990 items that are not called yet.
Given this, how is it possible to have server side paging and sorting across the entire total items? This assumes I am using REST/JSON presented using AngularJS.
What is interesting is that in my REST call using a tool like Postman, it properly maintains the overall order even with skips, but with the pagination calls in my Angular app, it only orders within the items (ex. 10). | I found the issue, where I had some extra code for sorting still on the page that was conflicting with the orderby within my REST call. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, rest, pagination"
} |
How to use DataTable in jqwidgets datasource
I have a Data stored in DataTable in code behind, How to use that datatabe to bind in JQWidgets. Please provide if any link available for refrence
DataTable tb=new DataTable();
tb = rp.GetRelaasePlan(); // Datatable
This need to used in front end jqxgrid. | Its fully a Client Side Grid So,
First you have to convert `Datatable` to `json` data, Using `json` data you can pass the values to `jqxgrid`
1.For converting DataTable to Json try this LINK
2.For assigning json values to gird try this LINK) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, asp.net, jqwidget"
} |
Weird transparency bug that happens with fullscreen or maximized applications
CPU: i9-10980HK
GPU 0 (Integrated): Intel UHD Graphics
GPU 1 (Discrete): RTX 3070 Laptop
I have no clue what I'm looking at. I had updated Chrome, Zoom, Nvidia Drivers and I tried restoring all of those but to no avail. When I click a screenshot, it shows up fine, but on the actual screen it's very bright and transparent.
Another thing that is kind of weird and I wouldn't expect, is that task manager is using the integrated GPU instead of the discrete GPU for dwm (window manager).
I ran DISM to check the health and everything, but nothing was corrupted.
Note: Youtube was doing some weird stuff like this, I fixed it by changing the ANGLE backend in chrome to OpenGL. No clue, but that seemed to fix it.
Edit: Forgot to mention, I disabled the Intel UHD graphics driver and it worked fine after that, but the machine was super laggy and slow.
Images | Interesting.
For those who want to know how I instantly fixed this, (TL;DR) I reinstalled the Intel iGPU drivers, which you can find here.
Long story here: So I kept reinstalling NVIDIA drivers thinking that it's my discrete GPU at fault, but to a slight surprise, it's actually not, and it's instead of my iGPU. Turns out the drivers were actually kinda old, and I hadn't updated them since I got this laptop. I think I updated drivers that were 2.5 years old, so no wonder.
Anyways, the moral of the story, keep your drivers updated. **All of them because Windows is bad**. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "windows, video, graphics card, gpu, transparency"
} |
Why are there two web.config files in my MVC application
There is one in the Views folder.
And there is another in the root of the app.
I want to register a custom handler and i cant understand where the code should go. I'm running IIS7 in Integrated Mode so I have to add a `<handlers>` tag to the `<system.webServer>` but when I'm looking at the web.config at the Views folder I see that it uses a `<httpHandlers>` under `<system.web>` tag.
So two questions: 1\. why are there two web.config files in an mvc application? 2\. where and in what way I should register my custom HTTP Handler? | You should register it in root config. Views config is for configure views, for example: add namespace for all views and etc.
* ASP.NET MVC and two Web.config files
* why are there 2 web.config files | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 4,
"tags": "asp.net mvc, model view controller, iis 7, httphandler"
} |
Trying to show $\mathcal S(\Bbb R)\subset L^p(\Bbb R)\ \forall 1\leq p\leq\infty$
$$\mathcal S(\Bbb R):=\big\\{f:\Bbb R\mapsto\Bbb R\ :\ \forall k,l\in\Bbb N \ \sup\limits_{x\in\Bbb R}\\{|x^k|\cdot|f^{(l)}(x)|\\}<\infty\big\\}$$
I am trying to show that $\mathcal S(\Bbb R)\subset L^p(\Bbb R)$ for any $p\in[1,\infty]$
First if $p=\infty$ then $\|f\|_{\infty}=\sup\limits_{t\in\Bbb R}|f(t)|<\infty$ by taking $k=0,\ l=0$ in the definition.
If $p\in[1,\infty)$
I would like to prove something pretty strong: If $f\in\mathcal S(\Bbb R)$ then for any $\epsilon>0\ \exists q\in\Bbb R$ s.t. $$\int\limits_{-\infty}^{-q}|f(x)|dx+\int\limits_{q}^{+\infty}|f(x)|dx<\epsilon$$ that will be stronger than what's necessary but I think it is true for functions in $\mathcal S(\Bbb R)$. In fact those function go to zero really fast as $|x|\rightarrow\infty$, faster than any polynomial (I'm pretty sure). | Hint: choose for a fixed $p$ an integer $k$ such that the function $t\mapsto \left(1+\left\lvert t\right\vert^k\right)^{-1}$ belongs to $\mathbb L^p$ and observe that $$\left\lvert f(t)\right\rvert^{p}\leqslant\left(1+\left\lvert t\right\vert^k\right)^{-p}\left( \sup_{x\in\mathbb R}\left(1+\left\lvert x\right\vert^k\right)\left\lvert f(x)\right\rvert\right)^{p}.$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 1,
"tags": "real analysis, lebesgue integral, lp spaces, schwartz space"
} |
How to read a c# server side value in jquery
I've a JArray response value like below
{[
{
"id": "90b254dc-3fcd-4e7c-9943-59bce366ccdc",
"invoice_number": "510002500007368"
}
]}
i'm getting this value from c# class ..when I try to read in jQuery like below ways
var tmp = '@Model.Transactions';
var tmp = Model.Transactions;
var tmp = @Model.Transactions;
from that I'm getting the values like below image ... i need a structured values. let me know if any idea.. thanks
.
This is shortcut for `@Html.Raw(myJson);` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, c#, jquery, asp.net, json"
} |
Turn template path hints off from command line
For whatever reason, I just did a mysqldump of our magento database, imported it into a new database, and suddenly template path hints are on, how can I turn these off from the command line? Or what table/column do I need to change in the database to turn these off?
Thank you! | You can turn them off by running the following query:
UPDATE core_config_data SET value = '0' WHERE path LIKE '%template_hints%';
After running the query make sure you clean the var/cache directory too when you are in the Magento root. (`rm -rf var/cache/*`)
Enjoy ;) | stackexchange-magento | {
"answer_score": 5,
"question_score": 4,
"tags": "template, theme, template hints"
} |
Openssl does not read default values from openssl.cnf
I am using the following command to create a certificate request:
openssl req -config openssl.cnf -new -out [filename].csr -passout pass:[password]
The `openssl.cnf` file is in the directory that I run the command from.
The problem is that I am still prompted to submit the values for country, state, locality, etc.
I want to do this programmatically, without someone having to step in and type these values. Shouldn't `openssl.cnf` provide the default values to be used? Am I missing an argument or something? | In your case the correct syntax would be:
openssl req -batch -config openssl.cnf -new -out [filename].csr -passout pass:[password]
A 2048b RSA private key will be generated at the same time in 'privkey.pem'.
If you prefer creating a request for a pre-existing key, add option :
-key [keyfile] | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "openssl, ssl certificate, configuration files"
} |
Objective C - Pick random NIB file?
Hello I would like to have my app pick a randome XIB file to choose from, and exclude 3 of them.
HowToPlay *LetsPlay = [[HowToPlay alloc] initWithNibName:@"HowToPlay" bundle:nil];
LetsPlay.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:LetsPlay animated:YES];
[LetsPlay release];
So i know how to load from a nib file by doing the above, but i would like it to be able to pick a random one and then exclude certain ones.
The ones i want excluded: MainViewController, FlipSideViewController, HowToPlay
Ones i want: Question 1, Question 2, and so on....
Any ideas of how i can do this?
Thanks!. Have a great day | You could put the nib names you want (represented as `NSString`) in a `NSArray`, then generate a random number and pick up one nib name from the array. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "objective c, ios, xib, nib"
} |
I am confused about a constexpr function?
In C++ Primer, Fifth Edition, §6.5.2:
> A `constexpr` function is defined like any other function but must meet certain restrictions: **The return type and the type of each parameter in must be a literal type** (§2.4.4, p. 66), and the function body must contain exactly one return statement
but another sentence in this chapter (page 239):
> A constexpr function is permitted to **return a value that is not a constant**
>
>
> // scale(arg) is a constant expression if arg is a constant expression
> constexpr size_t scale(size_t cnt) { return new_sz() * cnt; }
>
Is it a contradictory summary? I am confused about it.
The return type of `scale` is literal type?
update: what's the difference between literal type and constant ? | It's not contradictory. As well as mandating that the return type must be of "literal type", the draft standard states that a call to a `constexpr` function does not have to appear in a constant expression. From the C++11 draft standard:
> §7.1.5/7 A call to a `constexpr` function produces the same result as a call to a equivalent non-`constexpr` function in all respects except that a call to a `constexpr` function can appear in a constant expression. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 5,
"tags": "c++, c++11, constexpr"
} |
Adding a separator between found results by sed
I have a text file like this for example:
test.txt:
Hello my name is test
Well my name will be test
Hello Hello test
Hello my name already is test
Now I want to get everything between every 'Hello' and 'test'. This works for me:
`cat test.txt | sed --quiet '/Hello/,/test/p'`
It gives the following output:
Hello my name is test
Hello Hello test
Hello my name already is test
Would it be possible to separate my findings like this:
Hello my name is test;
Hello Hello test;
Hello my name already is test;
The delimiter does not have to be ';' any other character will work just fine. | Your question is unclear, but, assuming you want lines that start with `Hello` and to add a semi colon at the end, you can try;
$ sed -n '/^Hello/{s/$/;/p}' input_file
Hello my name is test;
Hello Hello test;
Hello my name already is test; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "shell, sed"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.