INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Which of the outer planets could you see with the naked eye if you were in close proximity?
My question is which of the outer planets you could see with the naked eye if you were in close proximity to them. It's pretty obvious the human eye can see the inner planets through to Mars, but I know that space probes to the outer planets need sensors designed for extremely low light conditions, and the pictures we see are often enhanced to make them brighter than they would actually appear. So:
* Could you tell if a planet was there against the blackness of space?
* Could you see details?
|
You can try for yourself how bright it is on Pluto. High noon on Pluto is as bright as a certain point during dusk/dawn on Earth. I tried this, at that point it's bright enough to make out details. My conclusion is that you can see the daylight side of every planet incl. Pluto with the naked eye if you're close enough.
This does depend on the planet's albedo. At 14.5%, Pluto isn't very bright, but some bodies have lower albedos (comets like 99P Chury are around 5%) so you might not be able to see some of the smaller bodies in the solar system.
|
stackexchange-space
|
{
"answer_score": 17,
"question_score": 12,
"tags": "planet, sensors, naked eye, outer planets"
}
|
Using Nature of Roots to find range of values
Find the range of values of $k$ for which $3x^2-4(k-x)+2$ is always positive for all real values of $x$.
I've tried simplifying, until I got to: $3x^2-4k+4x+2$.
Since it must always be positive, the discriminant, $b^2-4ac$ must be negative, ie $b^2-4ac<0$.
$b^2-4ac<0$
$(4)^2-4(3)(2-4k)<0$
$16-24+48k<0$
$48k<8$
$k<\frac 16$
I got stuck here. Is anyone able to help me continue?
EDIT: Realised that there was a typo, the discriminant should be negative, thank you Deepak.
|
You seem to have already got the answer (which is simply $k < \frac 16$). There is only one additional modification I would make to your answer. That is to assert that the coefficient of $x^2$ is positive (in this case $3$). If it were negative, you would never be able to satisfy the required condition since for high enough values of $x$, the quadratic expression would always be negative.
EDIT: just noticed you wrote that the discriminant must be positive. I hope that's just a typo, and not a conceptual error. It seems to have been just a typo because you set up the inequality correctly. Anyway, remember that you need complex roots for a quadratic curve to lie wholly on one side of the $x$-axis or the other (which side depends on the sign of the leading coefficient). Complex roots means the discriminant is _negative_ ).
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "quadratics"
}
|
Aligning elements left and right inline in td for html email
 but found these will cause issues with certain clients.
Can anyone suggest another solution?
<tr height="40px" bgcolor="#00a2c5">
<td>
<span style="padding-left:20px;color:#ffffff;display: inline-block;width: calc(50% - 40px);"><a href="#">Call 13 63 93</a></span>
<span style="padding-right:0px;color:#ffffff;text-align:right;display:inline-block;width: calc(50% - 0px);"><a href="#">Clarendon.com.au</a></span>
</td>
</tr>
|
**please use this HTML - no need to cal or other HTML, table have different CSS so use table parameter or attribute for email.**
<table width="100%" border="0" cellpadding="10" cellspacing="0">
<tr bgcolor="#00a2c5">
<td align="left" width="50%" height="40px"><a href="#" style="color:#ffffff;">Call 13 63 93</a></td>
<td align="right" width="50%"><a href="#" style="color:#ffffff;">Clarendon.com.au</a></td>
</tr>
</table>
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 2,
"tags": "html"
}
|
How can I get the number of bytes read in an asynchronous read?
Using C#, how can I return the number of bytes read from the function where I call EndRead?
ie:
x.BeginRead (...ReadProc..);
// how can I get the number of bytes read here?
ReadProc (IAsyncResult ar)
{
int numBytesRead = EndRead ();
// how can I return numBytesRead?
}
|
It sounds like you don't really want to use the Async code? With asynchronous calls there is no way to know how many bytes were read until the async call is done which will be in a different thread of execution.
You can block after calling BeginRead and use a mutex of some sort to wait until the EndRead is done and then get the value, but then there's no point in doing it asynchronously.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": ".net, asynchronous"
}
|
Any advice on customising this twitter feed?
I'm really having trouble locating the documentation for the Recent Tweets widget anywhere. It's not a plugin and appears to be native. All I want to do is to be able to move the `tweet_time` underneath the `tweet_text`.
If you take a look at the website, you'll be able to see the time of the tweet is on top of the actual tweet text, and I want to reverse the order.
|
It's part of the Webzine theme \- if you take a look at the source, near the bottom, there's a rather hefty chunk of JS that queries Twitter & renders the tweets.
Now whether that code is sat there waiting for you in `footer.php`, or called in from somewhere else, I don't know - if the latter, you'll have to root around the theme folder to find it!
It's worth mentioning that the Twitter user status API is loaded _again_ (along with Twitter's own `blogger.js` for the callback) at the very bottom of your site, but it's not actually utilised - you could save yourself some processing (& headaches for that matter) by removing it.
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "widgets, twitter"
}
|
Video not covering the whole screen
I want my video to cover the entire screen but it seems to cover only half of the screen as follows .width,
}}
resizeMode="cover"
repeat={true}
/>
Could anyone tell me how to achieve this behavior and where am I going wrong? Any help would be useful.
|
Somehow giving a height has solved the mentioned issue like follows:
<Video
source={{uri: this.state.video}}
style={{
position: 'absolute',
top: 0,
left: 0,
alignItems: 'stretch',
bottom: 0,
right: 0,
height: "90%",
}}
resizeMode="cover"
repeat={true}
/>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "reactjs, react native, react native ios, react native video"
}
|
Object Serialization on different platform
Hi guys I'm creating a very simple socket server that lets its clients save its own object state based on Keys by sending it over the wire. I'm using a very simple protocol encoding the serialized object to base64 string and will be sent out as part of my custom xml format. I wanted to know if the serialization will still be the same if the client app runs on 32-bit and 64-bit Windows and using .net Framework? will this also be the same if all client apps are created using c++ but runs on different platforms?
|
Serialization between 32 and 64-bit CLRs shouldn't be a problem, but if you want to be able to serialize on non-.NET platforms, you shouldn't use the default binary serialization. Personally I wouldn't use that anyway, as it can be tricky to handle in terms of versioning etc.
There are plenty of other serialization options available:
* XML serialization (either the built-in or hand-rolled)
* Thrift
* YAML
* JSON
* Protocol Buffers (I declare an interest: I've written one of the ports of Protocol Buffers to C#)
All of these are likely to work better across multiple platforms. Some are human readable as well, which can sometimes be useful. (Protocol Buffers aren't human readable, but it's easy to dump a text version of a protocol buffer message.)
Some effectively build their own object model via a separate schema, whereas others will cope (to a greater or lesser degree) with your existing object model.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c#, .net, serialization"
}
|
../node_modules/axios/lib/helpers/cookies.js [1] Error: EPERM: operation not permitted, read
As soon as I try to fetch data using `axios.get(url)` an error saying so is thrown. I have tried doing everything. But nothing works. I have been stuck on this for a long time. If someone can help, it will be greatly valued.
Failed to compile.
> ../node_modules/axios/lib/helpers/cookies.js Error: EPERM: operation not permitted, read
|
_**UPDATE**_ : THE PROBLEM IS FIXED.THE ONLY WAY THIS HAPPENED IS BY RESETTING MY MACHINE AND UPGRADING TO WINDOWS 7 ULTIMATE. PREVIOUSLY IT WAS WINDOWS 7 ENTERPRISE
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js, reactjs, axios"
}
|
Colors in bash after piping through less?
When I have dircolors defined life is full of... color.
When I pipe `ls` through `less` to scroll around I lose the colors.
Any suggestions?
|
Most likely your `ls` is aliased to `ls --color=auto`, which tells `ls` to only use colors when its output is a tty. If you do `ls --color` (which is morally equivalent to `ls --color=always`), that will force it to turn on colors.
You could also change your alias to do that, but I wouldn't really call that a good idea. Better to make a different alias with `--color`.
`less` needs `-R` too, which causes it to output the raw control characters.
|
stackexchange-serverfault
|
{
"answer_score": 122,
"question_score": 127,
"tags": "linux, bash, shell, less, ls"
}
|
What's wrong with the following definition of $\lim$ and derivative for the surreal numbers?
I am reading about surreal numbers, and was asking myself, what is wrong with the following definition of limit and derivative for surreal functions: Let $x,p$ are surreal numbers and $f$ is a function from the surreal numbers to itself.
$$\lim_{x \rightarrow p} f(x) := \\{f(p-\frac{1}{2^k})|f(p+\frac{1}{2^k})\\}$$ where $k$ ranges over the natural numbers $1,2,3,\ldots$, iff the right hand side defines a surreal number.
$$f'(x) := \lim_{\delta \rightarrow 0 } \frac{f(x+\delta)-f(x)}{\delta}$$
Is it possbile to prove some properties of the "usual limit" and the "usual derivative"?
Thanks for your help!
|
Two immediate issues with your definition:
1. A form must follow the rule that every member of the LHS is smaller than every member of the RHS. This is only ensured if $f$ is increasing.
2. If $f$ is an arbitrary "function" on Surreal numbers (can't be a function since surreal numbers don't form a set), you are only sampling countably many points on either side of $p$, which is not enough to determine the behavior of $f$ around $p$. Since no countable set is dense in the Surreal numbers, this is essentially analogous to asserting that you know $\displaystyle\lim_{t \to 0} g(t)$ from only knowing $g(-1)$ and $g(1)$ for a real function $g: \mathbb R \to \mathbb R$, which is absurd.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 1,
"tags": "limits, analysis, derivatives, surreal numbers"
}
|
Creating a vector with specified order
I have to create a vector in R with a specified order. I need 30 0s, then 30 1's, then 30 2's, and so on until 9. I was thinking I could create an empty vector and then create a loop that would add in my numbers but I'm not sure how to go about it. The code below is something along the lines of what I was thinking could possibly work.
labels <- c()
i = 0
for(i in 0:30){
append(labels,0)
i += 1
}
|
rep(0:9, each = 30)
#> [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1
#> [38] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2
#> [75] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
#> [112] 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
#> [149] 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6
#> [186] 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7 7 7
#> [223] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
#> [260] 8 8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
#> [297] 9 9 9 9
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "r, function, vector"
}
|
Database Table Normalization
Table 1
id Student
1 Ali
2 Akram
3 Aamir
4 Adeel
5 Aun
Table 2
id Course
1 English
2 Urdu
3 Maths
4 Physics
5 Chemistry
Table 3
id stu_id course_id
1 1 1
2 1 2
3 2 1
4 2 5
5 5 1
Q1: Are these tables normalized ?
Q2: Help me to remove duplicates from table 3, suppose if table 2 have 1000 courses, and student id 1 and 2 are enrolled in all courses, table 3 will be very large because of 2000 entries , is there any way to reduce these ?
|
1. It is normalized with a many-to-many relation;
2. Yes max cardinality of a many-to-many relation like that is max students x max courses, nothing terrible;
3. In many-to-many relationships use the multiple columns key of the ids couple, you do not need another id;
4. If by duplicates you mean the fact you have many equal fields in the columns, that are not duplicates at all. They mean that a student has many courses and viceversa. What has to be unique is the couple stu_id-course_id.
Regards
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "php, mysql"
}
|
Can ibid. be used under the Harvard referencing style?
In other words, **not** the other styles (e.g. APA, Chicago, Oxford) that uses the author-date format but the plain (Australian?) Harvard style.
|
From the examples at the University of the West of England:
> Generally ibid. and op.cit. tend to be used more in the body text for the Harvard system, and more in the reference list for the numeric system, as you can see.
They also note:
> There is no single authority that defines the 'Harvard' referencing style. Please seek guidance on the preferred scheme of referencing from your home institution or the journal in which your study will appear.
So I'm going to say yes, there is no reason as to why you couldn't use _ibid_ with the Harvard citation style.
|
stackexchange-academia
|
{
"answer_score": 7,
"question_score": 1,
"tags": "citations, citation style"
}
|
Hidden files and Folders in Chrome Extension zip files
`Chrome Store` requires to upload `ZIP` folder of `chrome` `extension`. But when I use compress utility of `Mac OS X`, some hidden files and folders are .DS_Store included in `ZIP` file.
Does `Chrome Store` delete this files when uploaded to the site or do I need to find a compression solution that will not pack hidden files and folders in `ZIP` files
|
Your zip is unpacked and analyzed by the web store then becomes a crx file, however, since there is no way to know which files are going to be used at run time, **all files** are included back in the bundle.
There's an issue related to this, so you'd better to remove these files before creating your zip:
cd my_extension_folder
find . -type f -name '.DS_Store' -delete
zip -r my_extension.zip my_extension_folder
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "google chrome"
}
|
Does ABPerson in iOS have kABModificationDateProperty?
Does ABPerson in iOS have kABModificationDateProperty? Thanks for your help :)
|
No, but it does have kABPersonModificationDateProperty.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "iphone, objective c, ios"
}
|
Does Root folders are created automatically for a document library
I am going through a code which is trying to make URL for a document within a document library,
string mydocumentpath = " + spSite.HostName +
MyDocumentlibrary.RootFolder.ServerRelativeUrl;
string mySecretEncodedPath = HttpUtility.UrlPathEncode(mydocumentpath ) + "/";
I am bit confused with where this root folder came from and what does "ServerRelativeUrl" is doing here, I already read this microsoft.sharepoint.splist.rootfolder.aspx but couldn't get answer I want.
Also is it alright to change root folder name ?
if it is then what would be the best way of doing it.
|
The url that you are generating with that code is in the form
http:// + spSite.hostname can be replaced with spSite.Url to get the same effect.
ServerRelativeUrl is the part of the url after MySite so in this case it is just MyLibrary. MySite is the server or root.
The root folder of a library is the folder that is located at
any other folder you create in the library would have the url
You can rename the root folder by renaming the library because they are one and the same thing. Think of the library itself as a folder with certain properties that an ordinary folder doesn't have.
|
stackexchange-sharepoint
|
{
"answer_score": 1,
"question_score": 1,
"tags": "2007, document library"
}
|
C++/CLI Compilation Error (Fields)
I have a C++/CLI class that looks like this:
#include "Stdafx.h"
#include "CLRIncludes.h"
#using <mscorlib.dll>
#pragma managed
namespace Ophidian {
public ref class EngineConfigParams {
private:
public:
Int32 AdapterNumber;
Int32 DisplayNumber;
Boolean Fullscreen;
UInt32 ResolutionX;
UInt32 ResolutionY;
};
}
Defined in "EngineConfigParams.h".
However, compilation fails with the following errors, repeated for each field:
> error C2146: syntax error : missing ';' before identifier 'AdapterNumber' error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I get the feeling this is a configuration error more than a syntax one... But I can't be sure. Any help greatly appreciated.
Thanks
|
The answer was to import the System namespace:
using namespace System;
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": ".net, c++ cli"
}
|
Magento Rest API - multiple product list in one call
I want to access specified multiple product list in one call. for example access all the products in category id 14 and 15.
This provide the product list id 14:
/V1/products?searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=14
This provide the product list id 15:
/V1/products?searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=15
But if I want to get both in one call: is possible to make somenthing like this ?:
/V1/products?searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=14,15
Any help?
|
You can use the in condition type
GET <host>/rest/<store_code>/V1/products?
searchCriteria[filter_groups][0][filters][0][field]=entity_id&
searchCriteria[filter_groups][0][filters][0][value]=1,2,3,4,5&
searchCriteria[filter_groups][0][filters][0][condition_type]=in
This example can be extended to work with category etc as you require, see examples
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "api, rest, magento, magento2"
}
|
How to put a uint8_t in a char array?
I'm trying to send some data to a device using serial comunication:
void VcpBridge::write_speed(char address, int spd) {
uint8_t speed = (uint8_t)(127);
ROS_ERROR("VCP BRIDGE: Sending %u to %u", speed, address);
char msg[8];
char command = 0x55, size = 0x02, csum;
csum = speed + 0x64 + address;
sprintf(msg, "%c%c%c%c%c%c", command, address, speed, size, 0x64, csum);
ROS_ERROR(msg);
write(fd_, msg, 6);
}
`ROS_ERROR` here does the same as `printf`.
Everything works fine except when the value of `speed` is over 127. Then it always prints a `?` in it's position and the device doesn't recive the right info. Do you know any way to cast it correctly? I've tried `%u` but then the program crashes.
|
There is no good reason to use `sprintf` in your example. Try this:
void VcpBridge::write_speed(char address, int spd) {
uint8_t speed = (uint8_t)(127);
ROS_ERROR("VCP BRIDGE: Sending %u to %u", speed, address);
char command = 0x55, size = 0x02, csum;
csum = speed + 0x64 + address;
ROS_ERROR(msg);
char msg[] = { command, address, speed, size, 0x64, csum};
write(fd_, msg, sizeof msg);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c++, types, casting, printf"
}
|
Why am I having problems installing Adobe Air on Linux Mint 14 and what is the solution?
I am attempting to install Adobe Air 2.6 on Linux Mint 14 in order to install an application that is dependent upon it.
I was instructed to install the getlibs-all package which I did and was able to get slightly further in the installation process. However, I am now stuck scratching my head over the following error message:
Adobe AIR could not be installed.
Install either Gnome Keyring or KDE KWallet before installing Adobe AIR.
I already installed gnome-keyring through the Synaptic Package Manager, so I'm not sure why the installer is complaining. I have also installed python-keyring, kwalletmanager, and kwalletcli with no difference in outcome.
|
If everything works, all should be installed. If you run into problems with adobe Air about missing gnome-keyring or KDE Wallet, run the commands below to fix it.
sudo ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0 /usr/lib/libgnome-keyring.so.0
sudo ln -s /usr/lib/i386-linux-gnu/libgnome-keyring.so.0.2.0 /usr/lib/libgnome-keyring.so.0.2.0
Now, try again.
* * *
Credits: <
|
stackexchange-unix
|
{
"answer_score": 3,
"question_score": 1,
"tags": "linux mint, software installation, gnome keyring"
}
|
Convergence in probability of this sum
> Consider $\\{0,1\\}$-valued random variables $X_1,X_2,\ldots$ with $P(X_k=1)=1/k^{1/2}$ and the sequence $$ Z_n=\frac{1}{n}\sum_{k=1}^n X_k. $$
>
> _Question:_ Does it hold that $Z_n\to0$ in probability, as $n\to\infty$?
My intuition says yes because $Z_n$ appears to be "of the same order" as $$ \frac{1}{n}\sum_{k=1}^n \frac{1}{k^{1/2}} = \frac{1}{n^{1/3}}\sum_{k=1}^n \frac{1}{n^{2/3}k^{1/2}} \le \frac{1}{n^{1/3}}\sum_{k=1}^n \frac{1}{k^{7/6}}\to0,\text{ as $n\to\infty$,} $$ where the latter convergence follows since $\sum_{k=1}^\infty 1/k^{7/6}<\infty$ (Riemann-Zeta function).
So far a proof eludes me, is my intuition perhaps wrong?
Edit: Note that the $X_i$ are not necessarily uncorrelated.
|
Using MArkov's inequality, \begin{align} P(Z_n > \epsilon) \le \frac{1}{\epsilon} E[Z_n] = \frac{1}{n \epsilon}\sum_{k=1}^n \frac{1}{k^{1/2}} \end{align} So the RHS is the sum you wrote in the question and therefore it converges to zero, for any $\epsilon>0$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "real analysis, probability, sequences and series, analysis, convergence divergence"
}
|
Proving identity $\frac{1}{x+iy}=\frac{x}{x^2+y^2}-i\frac{y}{x^2+y^2}$
Below are some of the identities provided early in Needhams "Visual Complex analysis"
I want to verify the identity in my title. From the identities given before it, I could only write
$$\frac{1}{x+iy}=\frac{1}{x^2+y^2}\big(-\arctan\frac{y}{x}\big)$$
Not sure how to derive that $\big(-\arctan\frac{y}{x}\big)=x-iy$
thanks
(x-iy)} = \frac{x-iy}{x^2-i^2y^2} = \frac{x-iy}{x^2+y^2} = \frac{x}{x^2+y^2} - i\frac{y}{x^2+y^2}$$ as required
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 1,
"tags": "complex analysis, proof writing"
}
|
Redirecting /sites/all/files
I am using Drupal 7. Is it possible to to redirect the "/sites/all/files" directory to just "/files". Also, would it be better to just create a new directory /files and copy the files over. But, I would have to change a lot of links in my content that access those files.
|
With Drupal 7, you do not need to do so! Drupal file paths are stored using stream wrappers so you can simply change the folder path in Admin > Configuration > Media File System and move the existing files to new folder and you are ready to go!
You will see `public://images/my.png` like paths in files table and many other locations. These are the stream wrappers used in Drupal 7.
However if your content has links hardcoded, they will not change. Try adding the following line right below the
RewriteEngine on
RewriteBase /
lines.
RewriteRule ^sites/default/files/(.*)$ [R=301,L]
|
stackexchange-drupal
|
{
"answer_score": 5,
"question_score": 2,
"tags": "redirection"
}
|
Which of these MySQL query approach is faster?
Which of these query would be faster?
1) Complicated query with subqueries
2) Simple query without subqueries but leave the extra processing work to application
I am deciding on which approach to take. I do not have real code to test against at the moment. Can those with more experience provide the answer?
|
It depends on the rows in the table and the sub queries you are using. Check the manual for query optimizing.
visit <
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "mysql, subquery"
}
|
CSS Gradient not working IE10+
I have a `box` that I'm trying to add some gradient to and it works in Chrome and other browsers except for IE10+ Below is my `CSS` code:
.box-gradient {
position:absolute;
width:100%;
height:100%;
border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:5px;
background: -moz-linear-gradient(left, #CCCCCC 0%, #EEEEEE 50%, #EEEEEE 50%, #CCCCCC 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#CCCCCC),color-stop(50%,#EEEEEE), color-stop(50%,#EEEEEE), color-stop(100%,#CCCCCC));
}
Thanks in advance!!
|
You have to include a line for IE10+
background: -ms-linear-gradient(to left, #CCCCCC 0%, #EEEEEE 50%, #EEEEEE 50%, #CCCCCC 100%);
I have had this issue before. Adding compatibility for gradients can be a very strenuous job. I think you'd prefer using **gradient generator**
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "html, css, internet explorer"
}
|
How to Turn an Integer Into Separate R,G,B Colors
I have been attempting to solve this for a while now, basically I want an integer, such as white (16777215) to be converted back into RGB (255,255,255), but I have no idea how.
I know R+(G*256)+(B*65536) = Integer but I want Integer = R,G,B.
Thanks for any help you can give!
|
int R = (i & 0x000000FF);
int G = (i & 0x0000FF00) >> 8;
int B = (i & 0x00FF0000) >> 16;
int A = (i & 0xFF000000) >> 24;
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -2,
"tags": "colors, integer, rgb, equation"
}
|
Force Language Path Prefix For Default Language
I have a multilingual site configured to use `path prefix` for URL language detection.
When no prefix is used in the URL, the default language is assumed. How can I change this behavior?
I want the site to return content only when a language prefix is set in the URL, otherwise return a "page not found" error.
**Reasoning behind this functionality:**
* Preventing duplicate content in search engines
* Keeping everything well organized (under language prefixes)
* Avoiding users to be able to view content without a language prefix and thus potentially link to it (loosing link juice)
_Edit: added reasoning._
|
The solution I found was using the Global Redirect module with the default options. It redirects all URLs without a language prefix to the correct URL with the default language prefix contained.
|
stackexchange-drupal
|
{
"answer_score": 2,
"question_score": 6,
"tags": "7, i18n l10n"
}
|
How generate url in angular ui-router and put it to location
View has controls for selecting cities and selecting params. And this view show selected objects for the selected cities. When view is loaded I parse the url and do request to the server. Url for the view are some as: My questions:
1. how can I put that url in location?
2. how can I handle changed url in location?
3. in which event I must hang the handler?
|
Url generating automatically by $state.go('cities', {/* params */}, {location: true}).
In controller I put handler in $scope.$on('$stateChangeSuccess'..
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "angularjs, angular ui router"
}
|
PHP Query to Insert Variables into MySQL not working
The query below is not inserting the variables into MySQL. I know that the function `valid_email2` works because I put a non-email address into `$inviteeemail` and it redirected per the code below.
I know that I have the right MySQL connection string.
Any idea why nothing is being put into MySQL?
$invitorname = $_POST['invitorname'];
$inviteename = $_POST['inviteename'];
$inviteeemail = $_POST['inviteeemail'];
$uid = $_POST['uid'];
$subcheck = (isset($_POST['subcheckinvite'])) ? 1 : 0;
if ( ! valid_email2($inviteeemail))
{
session_write_close();
header("Location:
exit;
}
else
{
mysql_query("INSERT INTO invites VALUES (NULL, '$uid', '$inviteeemail', '$invitorname', '$inviteename', NULL, '$subcheckinvite', NULL)");
}
|
Does the fields that you insert NULL for, can be null?
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, mysql"
}
|
Javascript open a new browser window (not tab) with address bar disabled
Is it possible to open a new browser window (not tab) with the help of javascript. additionally i want to disable or hide address bar.
|
Yes, you can open a new popup window with address bar disabled (url can't be changed)
**HTML:**
<input type="button" value="Open Window" onclick="return popitup(' />
**JS**
function popitup(url) {
newwindow=window.open(url,'name','height=300,width=300, location=0');
if (window.focus) {newwindow.focus()}
return false;
}
See the `location=0` but not consistent in all browsers. **DEMO.**
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "javascript"
}
|
Python Postgres - How to create arrays for single columns?
I have a Postgres Table with 72 Columns, each of them has 300 rows in it (most of them are decimal numbers) Example: Sensor1|Sensor2|Sensor3.....Sensor72 1... 2... 3... . . . 300
How I am able to put single columns in different arrays? What I am going to do with it is to do math. operations and plot them after.
Do you have any ideas? Thank you for your time!
|
You can load the table into a pandas dataframe:
import pandas
from sqlalchemy import create_engine
engine = create_engine('postgresql://user@localhost:5432/mydb')
df = pd.read_sql_query('select * from "My_Table"', con=engine)
and then use pandas to do data analysis and manipulation.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, postgresql"
}
|
Android -How to run services in background when certain criteria meets how to display the notification
How can I run services in the background of a battery manager Android application?
How would I display or receive a notification when the battery is low or when certain criteria are met?
For example, for an alarm, when the current time equals the alarm time the alarm rings.
|
You have 3 options:
1. You create a long running Service. It spawns off a thread that checks the things you mentioned periodically. I wouldn't advise this tho, these services tend to be killed on the long run by the os. Also, you'd have to use Wake Locks to prevent the system to put the cpu on idle when the phone goes idle after some minutes of inactivity - also stopping you service.
2. Check out the available system events for which you can register Broadcast Receivers. If you find suitable ones (I think there's one for indicating low battery levels), write receivers for them.
3. Use the timing service to register intents to be fired off on regular intervals. These intents would start a service (a short running one) that would do your thing.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, notifications, power management"
}
|
Minix3 process table (proc.h)
Anyone know why certain fields in proc.h in Minix are char, when I thought they'd be int?
37 char p_ticks_left; /* number of scheduling ticks left */
38 char p_quantum_size; /* quantum size in ticks */
So, if we want to add a new "int" field should we make it a char?
|
If `char` is big enough to hold all the necessary values, why not use it? Of course, `int` may be somewhat more performant, but at the same time `char` is usually smaller.
I believe you can use any type that makes sense.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "c, operating system, int, minix"
}
|
Show 'submitted by' date in a language different from English
I want to change the "submitted by" field. I want to show the date in another language. When I use views to display dates, the date shown is in the correct language.
When I add this to node.tpl.php, the date is in English.
echo date("j F Y", $node->created);
What is the correct way in Drupal to show the date like "17 december 1978" when the language set in Drupal is Dutch?
|
You need to format the date correctly using Drupals format_date() function.
print format_date(time(), 'custom', 'l j F Y');
<
format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL)
The $langcode argument is the language code to translate to. Defaults to the language used to display the page.
|
stackexchange-drupal
|
{
"answer_score": 0,
"question_score": 2,
"tags": "7, nodes, datetime"
}
|
Помощь в понимании JS
function f(c) {
c--;
document.write("<p>" + c);
if (c != 0) {
f(c);
}
document.write("<p>" + c);
}
f(3);
**Output: 2 1 0 0 1 2**
**Вопрос, почему функция не заканчивается после второго нуля ("0") а продолжает печатать 1 и 2 ?**
|
Давайте заменим переменные их реальными значениями и посмотрим, что получится.
Итак, вызов `f(3);` разворачивается в такое
3--;
document.write("<p>" + 2);
if (2 != 0) {
2--;
document.write("<p>" + 1);
if (1 != 0) {
1--;
document.write("<p>" + 0);
if (0 != 0) {
}
document.write("<p>" + 0);
}
document.write("<p>" + 1);
}
document.write("<p>" + 2);
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, рекурсия"
}
|
iPad to iPhone image size/layout confusion
I've written an application for the iPad that I'd now like to get working on the iPhone (a universal application).
At the moment it runs in the iPhone simulator, but the UIKit elements are positioned using pixel positions - so a lot of them are offscreen. Additionally my UIImages are too big, and need to be scaled to fit the iPhone. **How do I go about doing this?**
Thanks in advance.
Some more information: If I position a UIImageView using UIBuilder, the image displayed takes up the same ratio of the screen if displayed on the iPad or iPhone. Which is what I want, however I need to do it programatically.
If I create a UIImageView programmatically it will take up a much larger ratio of the screen on the iPhone compared to the iPad.
Edit: My nib is actually empty apart from a OpenGL view. The OpenGL view is scaling fine. I do create a few UIKit controls programmatically and this is where the problem is happening.
|
Probably the easiest way: make two separate xibs (1 for iPad, 1 for iPhone). Start a new universal project and migrate the curent one into it, it'll take some time, but it'll save you a lot of headaches.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, ipad, uiimage"
}
|
React native , open a url in webview
Im not familiar with ios app development , but is there a simple way to open a url in myApp's webview , in a simple way ?
Im looking for the same behaviour of facebook's app. once you click on http link , a webview is opened by the app.
clickHndlr: function() {
someNativeOrNonNativeModule.openUrl('
}
<Text onClick={this.clickHndlr}>google</Text>
Thanks.
|
Hi You can use WebView component in reactnative.
var {
....,
WebView,
} = React;
and in initial state give a default url or no url
getInitialState: function() {
return {
url: '', // or default url
yourInitialStates: 'value',
};
},
and then at inside render add component
<WebView ....your styles, properties
url={this.state.url}
/>
Now add your code
clickHndlr: function() {
this.setState({url:'
}
This will give the result
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "react native"
}
|
C++ override inherited methods
I have the following two classes. Since `Child` inherits from `Father`, I think that `Child::init()` overrides `Father::init()`. Why, when I run the program, I get "I'm the Father" and not "I'm the Child"? How to execute `Child::init()`?
You can test it here: <
#include <iostream>
using namespace std;
class Father {
public:
void start () {
this->init();
};
void init () {
cout << "I'm the father" << endl;
};
};
class Child: public Father {
void init () {
cout << "I'm the child" << endl;
};
};
int main (int argc, char** argv) {
Child child;
child.start();
}
|
Currently `Child::init` is _hiding_ `Father::init`, not overriding it. Your `init` member function needs to be `virtual` in order to get dynamic dispatch:
virtual void init () {
cout << "I'm the father" << endl;
};
Optionally, you could mark `Child::init` as `override` to be explicit that you want to override a virtual function (requires C++11):
void init () override {
cout << "I'm the child" << endl;
};
|
stackexchange-stackoverflow
|
{
"answer_score": 33,
"question_score": 25,
"tags": "c++, oop, c++11, inheritance"
}
|
Using R to open grib files
I am using R to work with meteorological data. I proceed in two steps:
1. convert grib to netcdf using the command line function ncl_convert2nc from ncar command language
2. use package ncdf in R to import the netcdf data.
**I still have one problem:**
2- For some particular grib files, the conversion with ncar tool does not work. Is there other ways or trick (other than transcription into netcdf) to **read grib files in R** ?
Problem Answered by Dirk: 1- I would like to do automatic treatment of many files within R. Can I call ncl_convert2nc within R ? (answered by Dirk Eddelbuettel below )
|
Regarding question 1, the answer is 'Yes' -- see `help(system)` and the `internal=TRUE` option if you want to capture results.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "r, data structures, netcdf, grib"
}
|
c# dataset to SQL Server table where datasource originates from CSV
I wanted to know what would be the easiest / best way to get a dataset contained within a datagridview into a SQL Server database.
Points to note:
The data comes from a `.CSV` file that is imported into the application. The user then has the option to modify cell data
They then press a button and hopefully upload to SQL Server table.
It is given that the column names will all match and the datatypes should match too.
Commands will only be insert. no delete or update.
LINQ is ok too.
|
You can use SQLBulkcopy. It can take a Datatable and then upload the content to to a SQL Server database.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "c#, sql, csv, insert, dataset"
}
|
Using windows exported ".rdp" file from Ubuntu
I got this ".rdp" remoteAPP file from work which enables me to run a specific application from the terminal server, I can open it easily using windows with a double click, are there any ways to open this kind of files from Ubuntu ?
|
You can use Remmina, which is default application for remote desktop in Ubuntu from version 11.04.
From Remmina main menu select Tools -> Import and select your .rdp file. It will be imported and added to your saved connections in Remmina and you can use it anytime you start Remmina.
|
stackexchange-askubuntu
|
{
"answer_score": 30,
"question_score": 23,
"tags": "remote desktop, rdp, remmina"
}
|
Does $\sum_{j = 1}^{\infty} \sqrt{\frac{j!}{j^j}}$ converge?
I need to solve
$$\sum_{j = 1}^{\infty} \sqrt{\frac{j!}{j^j}}$$
Does this converge or diverge and why?
|
You can use d'Alembert's ratio test
$\sqrt{\frac{(j+1)!}{(j+1)^{j+1}}}\sqrt{\frac{j^j}{j!}} = \sqrt{\frac{(j+1)!}{j!}\frac{j^j}{(j+1)^{j+1}}} = \sqrt{\frac{j^{j+1}+j^j}{(j+1)^{j+1}}}$
You can now show that this quantity converges to some real number smaller than one in order to conclude.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 0,
"tags": "calculus, sequences and series, analysis"
}
|
Does Destiny 2 have a free trial?
I expected the game to have a limited trial version like the other paid Blizzard games* (barring Overwatch) Diablo III, World of Warcraft and Starcraft 2 (before switching to free-to-play). Installation option was missing in the Battle.net client, but I assumed that this is a bug as so was reported on the forum. I had to use an alternative method to install the game. I get SAXOPHONE error code briefly after launching.
*Activision, the publisher of Destiny 2, is a subsidiary of Activision Blizzard
Is there a permanent trial of Destiny 2 or has the game only been playable during special events such as "free weekends"?
|
Bungie has announced a free-to-play version of Destiny 2:
> Destiny 2: New Light launches October 1, 2019 and is free to play on every supported platform.
|
stackexchange-gaming
|
{
"answer_score": 2,
"question_score": -5,
"tags": "destiny 2"
}
|
Flow of App or program in Android
hi I am a newbie to android programming and I learnt many basic programs and now when I started studying some of the sample programs. I am getting confused about the flow of the program in the areas like one method calling another and so on,
Also I tried DEBUGGING but it didn't work fine as many of the apps need input from user for understanding the complete flow of the program
So is there a way such that newbies like me can first understand the flow of program then dig into the code written over there.
|
Look at the Android Activity Life cycle on the android developer site.
<
Let me know if you have any questions,I will be happy to help where I can.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -4,
"tags": "android"
}
|
Why does Colaboratory Google take much longer than Pycharm?
Are there any factors in the python code that could justify the delay in generating the results? I plotted a gif of orbits in Pycharm and the result took about 5 seconds. On Google Collaboration it took 3 minutes. Can I do anything to improve this?
|
` against Col2 (the `somestring` part) and Col3 (the `someotherstring` part). Col2 is always 10 characters long. Col1 has NULL values.
This is what I have right now:
select * from MyTable
where
substring(Col1,1,10) != Col2
OR substring(Col1,13,LEN(Col1)-13) != Col3
I'm getting the error:
`Invalid length parameter passed to the LEFT or SUBSTRING function.`
I'm guessing the null values in Col1 are my problem. I've tried ISNULL and COALESCE but it's still not working. I must be doing something wrong. How do I fix this?
|
I think your problem is `LEN(Col1) - 13` return a negative number
Try using this :
select * from MyTable
where
substring(Col1,1,10) != Col2
OR substring(Col1,13,case when LEN(Col1)-13 >= 0 then LEN(Col1)-13 else 0 end) != Col3
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "sql, sql server 2008, substring"
}
|
#each loop over multiple documents from a collection in a single iteration
I have a Meteor collection called `Tasks`
I would like to display them on the template with a div wrapped around every 2.
So something like this
<div>
{{task 1}}
{{ task 2 }}
</div>
<div>
{{task 3}}
{{ task 4 }}
</div>
How would I got about doing this in Meteor?
|
Use a helper to define what you want to iterate over -- in this case, you could do something like return an array of objects that contain the first and second tasks you want to display:
<template name='whatever'>
{{#each getTasksToIterate}}
<div>
{{> task firstTask}}
{{> task secondTask}}
</div>
{{/each}}
Then, in your helpers, define the function `getTasksToIterate`:
Template.whatever.helpers({
getTasksToIterate: function() {
var tasks = [];
_.each(this.tasks, function(task, index) {
if (index % 2 === 0) { // Pick the odd ones
tasks.push({firstTask: elem, secondTask: this.tasks[index + 1]});
}
return tasks;
}
});
Note that this assumes you have an even number of tasks; if you occasionally have an odd number you'd need to deal with that with appropriate if statements, etc.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "arrays, mongodb, meteor"
}
|
Object of object as function parameter
As you can see from my code sample, I am wondering why the following thing doesn't work. I have an object with an object as a property (will call it prop in the text below). When I assign the values to the prop in the function, those values are there, because obviously it is passed by reference, but I don't understand why the prop can be referenced to point to another object.
In the case of setting the prop to another object, I just get the empty object, as it is in start. What am I missing here?
const person = {
basic: {}
}
function initPersonBasics(b) {
// doesn't work
b = {
firstName: 'John',
lastName: 'Doe'
}
// works
// b.firstName = 'John';
// b.lastName = 'Doe';
}
initPersonBasics(person.basic);
console.log(person);
|
const person = {
basic: {}
}
function initPersonBasics(b) {
b = {
firstName: 'John',
lastName: 'Doe'
};
console.log(b);
}
initPersonBasics(person.basic);
console.log(person);
The reason is that you are re-assigning `b` to point to another object inside `initPersonBasics`. But that doesn't change where `person.basic` points to.
What you are doing is similar to this simple code:
function foo(i) {
i = 42;
}
let j = 10;
foo(j);
You wouldn't expect `j` to be 42 after the call to `foo`, would you?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript"
}
|
Exercise 1.12 - Mark H. Holmes Introduction to Numerical Methods in Differential Equations
I'd like to prove that the order of the two-steps Backward Differentiation Formula is $O(k^2)$. For this, I write $$y'_i\approx \dfrac{y_{i}-{\tfrac {4}{3}}y_{i-1}+{\tfrac {1}{3}}y_{i-2}}{2k/3}=\dfrac{1}{k}\left(\dfrac{3}{2}-2E^{-1}+\dfrac{1}{2}E^{-2}\right)=\dfrac{1}{k}\left(\nabla+\dfrac{\nabla^2}{2}\right).$$
So, the approximation is $$D= \dfrac{1}{k}\left(\nabla+\dfrac{\nabla^2}{2}+\dfrac{\nabla^3}{3}+\dfrac{\nabla^4}{4}+\cdots\right)\approx \dfrac{1}{k}\left(\nabla+\dfrac{\nabla^2}{2}\right)$$ and the error $$ \dfrac{1}{k}\left(\dfrac{\nabla^3}{3}+\dfrac{\nabla^4}{4}+\cdots\right)$$
How could I proceed?
Thank you in advance!
|
You need to notice that the higher powers of the difference operator come with a like power of $k$, $$ \Delta^m=(1-e^{-kD})^m=(kD-\tfrac12(kD)^2+...)^m =(kD)^m+\tfrac{m}2(kD)^{m+1}+... \\\~\text{or}~\\\ [\Delta^my]_i= k^my^{(m)}(x_i)+O(k^{m+1}). $$ This then implies that the remainder terms start with $O(k^2)$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "numerical methods"
}
|
Determining if two numbers are relatively prime.
Let n be a positive integer. Then prove the relation of congruence mod n is an equivalence relation on $\Bbb{Z}$.
for the symmetric part of the proof, I have
Let $a,b \in \Bbb{Z}$ and $n \in \Bbb{Z^+}$
Suppose $n | (a-b)$
Since if two numbers are relatively prime $\exists x,y(ax+by=1)$
& if x and y are relatively prime and $x | yq$ then $x|q$
From the two above theormes I get
Then $n | -1(b-a)$
The logic is that $b-a = q$ and that, $nx+(-1)y=1$ holds true for when $x=0$ and $y=-1$
Does this all seem correct?
|
In order to apply the boxed result you need two relatively prime numbers, which we do not have in this problem.
Instead, use the definition of "divides". Because $n|(a-b)$, there is some integer $k$ such that $nk=a-b$. Now, $n(-k)=b-a$. $-k$ is an integer because $k$ is, so $n|(b-a)$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "abstract algebra, proof verification"
}
|
Extract json informations
I'am using **Facebook sdk** for android and I want to know if there is json library included, this is my returned json string, how can I extract UID ?
{
"id": "111513307",
"name": "kevin Zhioua",
"first_name": "kevin",
"last_name": "Zhioua",
"link": "
"username": "kevin.zhioua",
"gender": "male",
"email": "[email protected]",
"timezone": 1,
"locale": "fr_FR",
"verified": true,
"updated_time": "2011-11-14T17:42:27+0000"
}
|
There is an available library in Android to handle JSON, you may use it like this:
JSONObject jobj = new JSONObject(theStringFromFacebook);
String uid = jobj.getString("id");
P.S - don't forget to `import org.json.JSONObject;`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "java, android, json, facebook"
}
|
Plot a 3D graph while changing the range of the parameter
I wish to plot the graph of a surface while being able to change a parameter.
My current code is
ContourPlot3D[(Cos[Pi/4]+x Cos[0]Sin[Pi/4]+y Sin[0]Sin[Pi/4])^2 ==
(1+x^2+y^2)Cos[a]^2, {x, -10, 10}, {y, -10, 10}, {z, -10, 10},
{a = 0 .. Pi}, AxesLabel -> {x, y, z}]
I don't want to do it with `Manipulate[]`, since I don't a the graph of the surface of a given "a" between 0 and Pi, but the graph of the surface with "a" from 0 to Pi.
|
Your syntax is wrong, as you probably know. Maybe you want something like this:
ContourPlot3D[
Evaluate@Table[
(Cos[Pi/4] + x*Cos[0] Sin[Pi/4] + y*Sin[0] Sin[Pi/4])^2 == (1 +
x^2 + y^2) Cos[a]^2, {a, 0, \[Pi], .2}], {x, -10, 10}, {y, -10,
10}, {z, -10, 10}, AxesLabel -> {x, y, z}]
!Mathematica graphics
Or
Show@Table[
ContourPlot3D[
(Cos[Pi/4] + x*Cos[0] Sin[Pi/4] + y*Sin[0] Sin[Pi/4])^2 == (1 +
x^2 + y^2) Cos[a]^2, {x, -10, 10}, {y, -10, 10}, {z, -10, 10},
Mesh \[Rule] None, AxesLabel -> {x, y, z},
ContourStyle \[Rule] FaceForm[{Pink, Opacity[0.8]}]
],
{a, 0, \[Pi], .5}
]
!Mathematica graphics
|
stackexchange-mathematica
|
{
"answer_score": 2,
"question_score": 1,
"tags": "plotting"
}
|
How to delete a row depending on values from another sheet
In my sheet called "Data" i have about 200 rows. Column A has a ID number and the rest of the columns are just data. In my other sheet called "Check" in column A i have list of ID numbers as well. What i want is to delete all rows in my data sheet that has a customer ID that's in my check sheet.
So my thought process was if i do a vlookup and it returns a value then delete that row, else move to the next for some reason this is just deleting all the rows.
Sub EraseDups()
Dim N As Long, i As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
For i = N To 1 Step -1
If Application.WorksheetFunction.VLookup(Cells(i, "A"), Sheet1.Range("A:A"), 1, False) > 1 Then
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub
|
Another approach to do it....
Instead of using Vlookup or Match, use Countif, that will not produce an error so no error handling is required.
Sub EraseDups()
Dim wsData As Worksheet, wsCheck As Worksheet
Dim N As Long, i As Long
Application.ScreenUpdating = False
Set wsData = Sheets("Data")
Set wsCheck = Sheets("Check")
With wsData 'Change this to the specific sheet if wanted
N = .Cells(Rows.Count, "A").End(xlUp).Row
For i = N To 1 Step -1
If Application.CountIf(wsCheck.Range("A:A"), .Cells(i, "A")) > 0 Then
.Rows(i).Delete
End If
Next i
End With
Application.ScreenUpdating = True
End Sub
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "vba, excel"
}
|
How I can set a date string from twitter to a NSDATE
The date you get back from twitter is in this format `Fri Aug 07 12:40:04 +0000 2009`. I am able to assign the value to a NSDate without issue. However, when I attempt to use NSDateFormatter, I get a nil returned to me. What am I missing?
NSDate *createdAt = [messageData objectForKey:@"created_at"];
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"M/d/yy HH:mm"];
NSString *dateString = [format stringFromDate:createdAt];
label.text = dateString;
|
If the object associated with the @"created_at" key is a valid NSDate object, this code should work.
However, I'm guessing that it is actually an NSString. If so, it will produce the behavior you're describing.
If I'm right, the code snippet above is assigning an NSString object to an NSDate reference. NSDictionary returns untyped 'id' objects, so the compiler won't give you a type mismatch warning.
You'll have to use NSDateFormatter to parse the string into an NSDate (see dateFromString:).
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 5,
"tags": "iphone, objective c, cocoa, datetime, formatting"
}
|
Trying to scrape multiple urls from a csv file. But facing response 404 for all urls except last url which loads from csv file
import requests
from bs4 import BeautifulSoup
import csv
import lxml
with open('xyz/spec.csv') as file:
reqdata = []
for line in file:
headers = {'User-Agent': 'Mozilla/5.0'}
r = requests.get(line, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
need = soup.find_all('span', attrs={"class":"10965hju"})
needs = []
for tit in need:
needs.append(tit.text.strip())
reqdata.append(needs)
print(reqdata)
|
Since you are just reading lines from a csv file all of your urls have a linebreak character (`\n`) at the end, except for the last one.
The simplest solution for this would be
`r = requests.get(line.strip(), headers=headers)`
strip with no arguments removes leading and trailing whitespace.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, python 3.x, web scraping, beautifulsoup, httpresponse"
}
|
How to guarantee a clean install of macOS Mojave from an external USB drive
I recently received some Mac Mini's (2014 2.8 i5 16GB RAM) purchased online which came installed with El Capitain. I was concerned that the there could be a root kit installed on these second-hand refurbished machines. So I wanted to do a clean install of the OS. I followed instructions (< to create a bootable version of Sierra and restarted the machine with the `option` and reinstalled the OS from the USB disk.
To my surprise, when the system restarted after the "clean" install, the user that was created before the "clean" install was still there and so was all their user preferences and applications installed.
Is this normal for a "clean" install from USB? What prevents a re-seller from installing a root kit in the user's directory that may include a cron, or even another sub-system that would still be there after this "clean" install?
|
Like Allan said in his comment that step specifically says
> Once the USB drive has booted, select "Disk Utility" from the Utilities window, choose your Mac's startup drive from the list, and click "Erase".
This is one of the most vital steps in the process of a clean install. It **COMPLETELY** wipes the target drive of all information previously there. If you don't do that all you are doing is reinstalling macOS right over top of what is already there _leaving everything that was on the hard drive still there._
If you do that there will be nothing left, no users, 3rd party apps, malware, etc.
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 1,
"tags": "install, software update, macos"
}
|
How to use Nginx to redirect to specific page?
Hi am looking to use Nginx to redirect to a certain page for example: current domain is testing.example.com. The page I wana get to is testing.example.com/test but the domain i wana redirect from is t.example.com so:
t.example.com = testing.example.com/test
Any help thanks!
|
If all you want is to redirect all the traffic, use this following server block, if you want to concatenate the uri then you could add `$request_uri` in the return statement.
`$scheme` is used to preserve `http` and `https` protocols in the redirected-to location, otherwise you can replace it with either without using `$scheme`
server {
server_name t.example.com;
location / {
return 301 $scheme://testing.example.com/test;
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, redirect, nginx"
}
|
Surely *some* wordsmiths must love America[ns]?
People who like/admire English or French (the languages and/or the people and their culture) are easily identified as _Anglophiles_ or _Francophiles._
I'm not sure there are so many _Germanophiles,_ but that might be because they're diluted by the presence of _Teutophiles_.
My problem is on the (not ridiculously rare) occasions when I want to express positive feeling towards _American_ people (or their linguistic peculiarities), I don't have a similar word.
Am I missing something obvious? Or is there a little-known term?
|
Can't find a dictionary word but these neologisms should all be understandable:
* _Philamerican_ , á la _philhellene_.
* _**Americanophile_** , while this does not seem to have a dictionary entry, it does appear in print a few times.
|
stackexchange-english
|
{
"answer_score": 10,
"question_score": 17,
"tags": "names, collective nouns, category"
}
|
Make a List of String array from a List of String using LINQ
I have a given data (I just make it as a `List` here).
List<string> list1 = new List<string>();
foreach( var x in Regex.Split( "A B C D E F", " " ) )
list1.Add( x );
Now I want to make a final List like this.
List<string[]> list2 = new List<string[]>();
So, I tried with this code (I have tried with `LINQ` but, no gain).
int i = 0;
string[] array1 = new string[2];
foreach( var x in list1 )
{
if( i % 2 == 0 )
{
array1[0] = x;
}
else
{
array1[1] = x;
list2.Add( array1 );
array1 = new string[2];
}
i++;
}
I'd like to use LINQ for the same result. Please help.
Thanks.
(EDIT: Result should be A and B, C and D, E and F for each item in List 2)
|
list2 = list1.Where((x, i) => i % 2 == 0)
.Zip(list1.Where((x, i) => i % 2 == 1),
(x, y) => new[] { x, y })
.ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "c#, linq"
}
|
Install metabase using nssm and Inno Setup script
I want to open an administrative CMD window using Inno Setup and want to install:
nssm install metabase
I tried the following function, but it doesn't work.
Exec(ExpandConstant('{cmd}'), ' nssm install', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
Please someone help me. Thank you in advance.
|
You are effectively executing:
cmd nssm install
That wouldn't work anywhere, not only in Inno Setup. It should be:
cmd /c nssm install
Though, it's an overkill to run `nssm` via `cmd`. Run it directly:
nssm install
In Inno Setup Pascal Script:
Exec('nssm', 'install', '', SW_SHOW, ewWaitUntilTerminated, ResultCode);
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "installation, inno setup, pascalscript, metabase, nssm"
}
|
How to call seo tags from db
in db column having hash format title mobile description
i need to call these fields in a view page tags. how ? iam new to ror step by step will be more helpful.
|
suppose your db column returns mobile_description so in controller you defined it ex-
@mobile_description = {:keyword => "Talek", :mobile => "789966558"}
and in view_page you can use these as tags where you want to show it like this ex -
mobile number `@mobile_description[:mobile]`
mobile title `@mobile_description[:keyword]`
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -2,
"tags": "ruby on rails"
}
|
Refresh page selenium
Heyy ^^ I'm coding a selenium program, but I'm stuck in one place. This program is made to buy 1 graphics card, on a French site, for my son's birthday. So there you have it, I coded everything but now my concern is that the web page of this graphics card is only available when it is in stock so the program cannot find the button by xpath "add to cart" . So I had the idea to make a loop so that as long as the "add to cart" button is not available, the program opens the page of the graphics card to infinity (like this when it is available, the button appears and the rest is done). However, I don't know how to achieve this condition, this loop, can you help me? I am on selenium with webdriver
|
addtocart = driver.find_elements_by_xpath('somexpath')
while (not addtocart):
time.sleep(10) # wait for 10 seconds
driver.refresh()
addtocart = driver.find_elements_by_xpath('somexpath') # refind to avoid stale element exception
addtocart[0].click()
just use find elements and check for returned array length is zero or not
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "selenium, xpath, webdriver, refresh"
}
|
port forwarding on OSX without using the terminal
Can anyone tell me if there exists an app that simplifies setting up port forwarding on OSX without using the terminal?
|
The application Port Map may help you to easily configure ports if you have an UPnP router.
|
stackexchange-superuser
|
{
"answer_score": 1,
"question_score": 1,
"tags": "macos, port forwarding"
}
|
What are those glowing blue shields in Resident Evil 5 for?
They're hidden, and usually out of reach. When you shoot them they shatter but what does it get you? Any sort of bonus or is just for an achievement?
|
You can get Sheeva's tribal costume collecting all 30 of them
See here for their location
> Grabbing all 30 gets you that lovely getup, plus something special for Chris and a number of other trinkets
|
stackexchange-gaming
|
{
"answer_score": 5,
"question_score": 8,
"tags": "resident evil 5"
}
|
Casting List<bool> to List<object>
Is there any shortcut or better way to typecast `List<bool>` to `List<object>`?
I know i can do that by looping and casting individual item but i want to know is this possible to cast entire list in one statement.
|
you can do this with the `Enumerable.Cast<T>` method:
List<bool> bools= GetBoolList();
IList<Object> objects= bools.Cast<Object>().ToList();
|
stackexchange-stackoverflow
|
{
"answer_score": 9,
"question_score": 2,
"tags": "c#, .net, generics, covariance"
}
|
Apex trigger on lead to check for a converted status
I am a bit stuck writing a trigger that checks if the Lead Status was changed to a converted status without converting.
As per standard, "Qualified" is the only status that can be used as a converted status. But it is possible to have more than one converted status.
If a user selects one of the converted status in the standard editor, no actual conversion happens, but we want the users to not be able to do that at all. So my trigger should react to this behaviour with an error.
If I have a fixed status, I can of course hard code that, but I think that's suboptimal, I would like to do it more generic.
So: from Apex, can I find out if the current Lead Status is one that is marked as converted?
|
This is possible, you just need to check **IsConverted** field on Lead, therefore, if it is unchecked, than you need to prevent lead update if new status is contained in converted statuses.
trigger LeadTrigger on Lead (after insert, after update) {
List<LeadStatus> convertedStatuses = [
SELECT Id, MasterLabel
FROM LeadStatus
WHERE IsConverted = true
];
Set<String> convertedStatusesNames = new Set<String>();
for (LeadStatus status_i : convertedStatuses) {
convertedStatusesNames.add(status_i.MasterLabel);
}
for (Lead lead_i : Trigger.NEW) {
if (!lead_i.IsConverted && convertedStatusesNames.contains(lead_i.Status)) {
lead_i.addError('You cannot set status to converted without actually converting lead');
}
}
}
|
stackexchange-salesforce
|
{
"answer_score": 3,
"question_score": 2,
"tags": "apex, picklist, leads"
}
|
Mail server sends random emails to different accounts
so today i took a look at my Mercury Mail Server and noticed it was sending an awful lot of mail to a bunch of random mail addresses. I took a look at the emails and this is the original email: ~~4i ~~oP ~~8Q ~~7M ~~xu ~~h1 ~~cI ~~75 ~~YB ~~z1 ~168 ~8a nc984108—291
BI3UCuWq
Now when i translated it, it said something about marketing in it but i dont know why these would be sending and how to stop them. Does anyone know how to stop these randomly sent email spam? Thanks in advance for the heroic person that helps me out. -Matt.
|
* Check your mail logs to see what user is sending the mail. Are you using SMTPAUTH and in that case, are they logged in?
* Is it possible to send e-mails through your server _without_ authenticating?
* What IP address do the messages come from?
* Is it possible that a spam program may have been installed on the mail server machine, or on any other machine in your computing environment?
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "email, smtp, sendmail, spam"
}
|
AudioClip Progress bar in Java
I created an audio Player using java applet but i'm stuck at trying to create a progress bar, no need for seek or anything fancy, just a progress bar displaying the progress of the audio file being played.
I don't know how to get the current progress off the AudioClip, that's my main problem among other small things. any hints would be appreciated. thanks
|
You can't use AudioClip for that; you'll have to use the javax.sound API. The great Example Depot has good sample code to get you started.
Here's how to load and playback an audio file.
Here's how to query the clip for its current position.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "java, audio, progress bar"
}
|
Accessing Java Packages in different Drives
Consider if I have got a Package in my C:\x\y\z and another package in D:\m\n\o. How can I access them in my java program? Do I need to set any path?
|
You need to set your classpath to add each directory. Assuming that your package structure begins underneath each of those directories:
java -classpath C:\x\y\z;D:\m\n\o <MyClassName>
See docs.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 3,
"tags": "java, windows"
}
|
How to use substring in rawQuery android
Hi I'm trying to use substring in my query but I'm having this error
android.database.sqlite.SQLiteException: no such function: SUBSTRING (code 1)
i want to get the last 7 characters from each data result in my query. I'm using Cursor as well. here is my code
public Cursor DistinctResult() {
return this.myDataBase.rawQuery("select DISTINCT SUBSTRING("+KEY_LOCATION+",-7) from "+TBL, null);
}
What is the possible problem to it? is there any other option to do this? thank you
|
`no such function: SUBSTRING (code 1)` means that SUBSTRING function is not available in sqlite and that should be **SUBSTR()**
Just change **`SUBSTRING`** to **`SUBSTR`** that should help you
AND Please read this link for sqlite <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "android, database"
}
|
Create new array with deducted values of another array's elements - JS
I need to create an array that has same number of elements, but the values should deducted. Example:
Initial array:
myArray = [1, 3, 6, 7, 11, 14]
New array:
newArray = [1, 2, 3, 1, 4, 3]
So 1 - 0, 3 - 1, 6 - 3 etc... Any advice on how to achieve this?
|
myArray = [1, 3, 6, 7, 11, 14];
var i = 0;
console.log(myArray.map(e => {
var k = e - i;
i = e;
return k
}))
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -3,
"tags": "javascript"
}
|
Ceiling not working properly in SSRS Report
Used below expression to show only 50 Rows per page.
=Ceiling(RowNumber(Nothing)/50)
But still it shows only 42 rows per page. Crystal report shows perfectly fine but SSRS report doesn't.
) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "$entry\n <br />" ;
}
}
closedir($handle);
}
This Directory only holds `PHP` files , how would i be able to remove the extension from the echoed results? example: ( `index.php` would become `index` )
|
The easiest way to do this is by using the `glob` function:
foreach (glob('path/to/files/*.php') as $fileName) {
//extension .php is guaranteed here
echo substr($fileName, 0, -4), PHP_EOL;
}
The advantages of `glob` here is that you can do away with those pesky `readdir` and `opendir` calls. The only slight _"disatvantage"_ is that the value of `$fileName` will contain the path, too. However, that's an easy fix (just add one line):
foreach (glob('path/to/files/*.php') as $fullName) {
$fileName = explode('/', $fullName);
echo substr(
end($fileName),//the last value in the array is the file name
0, -4),
PHP_EOL;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, list"
}
|
How to make a new line for every space, except one?
I have a text file like this:
www.twitter.com,sev-pool,tiger lion,
www.google.com,"http google-pool,,
www.facebook.com,pool,usa mexico canada,
I want to make every space a new line except the space in **"http google-pool** in this example, because the `"` is _unmatched_ on this line.
Is there a way I can do this without using the line number? Perhaps an **if** statement dependent on the **"** , or any other way?
I am using the **tr** command:`tr " " "/n"` but I am unable to omit the desired line.
Expected output:
www.twitter.com,sev-pool,tiger
lion,
www.google.com,"http google-pool,,
www.facebook.com,pool,usa
mexico
canada,
|
An `awk` solution that works with your updated requirements (ignore lines with an unmatched `"`):
awk '/"[^"]*$/ { print; next } { gsub(" ", "\n"); print }' file
Note:
* The assumption is that the lines that contain an unmatched `"` should be excluded from the space-to-newline translation _as a whole_.
This yields:
www.twitter.com,sev-pool,tiger
lion,
www.google.com,"http google-pool,,
www.facebook.com,pool,usa
mexico
canada,
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "shell, unix, if statement, sh, tr"
}
|
addition of int and str
hello i am reading this python book and one of the exercises says:
> Write a function named right_justify that takes a string named s as a parameter and prints the string with enough leading spaces so that the last letter of the string is in column 70 of the display.
ok so i have the following code that prints 70 spaces and the string 'allen'
def right_justify(s):
print s
right_justify(' ' * 70 + 'Allen')
but when i try to subtract the number of spaces from the string 'Allen'
sub = len('allen')
def right_justify(s):
print s
right_justify(' ' * 70 - sub + 'Allen')
i get:
> "unsupported operand type(s) for -: 'str' and 'int'"
why does it work without the sub variable and it doesn't with it? I have checked the type of the sub and it comes out as an int.
|
You need parentheses:
' ' * (70 - sub) + 'Allen'
Your code is evaluated as:
((' ' * 70) - sub) + 'Allen'
That doesn't work because you can't subtract an int from a string.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "python"
}
|
PHP: Access Values from Array1 from inside Array2
I have some arrays like:
$Array1 = array
(
"foo" => "foo",
"foo2" => "foo2",
"bar" => "bar",
"bar2" => "bar2"
)
$Array2 = array
(
"fooo" => "bla " . $Array1,
...
)
and now I want something like:
echo $Array2["fooo"]["foo"];
for "bla foo"
But I just get
> Warning: Illegal string offset 'foo' in xy.php on line 37 G
How to do that?
|
Actually, it won't work the way you've done.
You may associate array2 to "fooo" directly, but can't concatenate an array to a string.
Try to do like this:
$Array1 = array
(
"foo" => "foo",
"foo2" => "foo2",
"bar" => "bar",
"bar2" => "bar2"
)
$Array2 = array
(
"fooo" => $Array1,
)
As you can see, I've associated $Array1 directly to "fooo" index, so I'll be able to access it by:
echo $Array2['fooo']['foo'];
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "php, arrays"
}
|
If $a>1$ and $b \mid a^2+1$ and $b>a$.Prove that $b-a > \sqrt{a}$.
If $a>1$ and $b \mid a^2+1$ and $b>a$.Prove that $b-a > \sqrt{a}$.
I take $b=a+m$ where $m$ is a natural number then we have:
$b \mid a^2+1 \Rightarrow b \mid m^2+1 \Rightarrow b-1 \le m^2 \Rightarrow a \le m^2 \Rightarrow \sqrt{a} \le b-a$
But I don't know why I get the equality case with it.I can't even prove or disprove that there is an equality case.
|
If you have
$$b-a=\sqrt{a}\to m=\sqrt{a}\to a=m^2\to b=m^2+m$$
once $b|a^2+1$ then
$$(m^2+m)|(m^4+1)\to m^4+1=k(m^2+m)\to m|m^4+1\to m=1$$
what is not true because $a=m^2>1$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 2,
"tags": "number theory"
}
|
android making Preferences (CheckBoxPreference) scrollable in XML
Hi, I'm trying to get my preference area to have scrollable text as most of the titles are too long. Is this something thats possible? I have seen posts regarding `TextViews`, and even those need a bit of encouragement to get going... any help appreciated. thanks
|
Not with standard `PreferenceActivity` you are most likely use there. Shorten your labels and use `description filed to clarify. Or just create help or manual for your app
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, android preferences"
}
|
Java BigInteger testBit 64-bit long
This is probably a silly question, but I can't seem to find a simple answer.
I'm reading in a 64-bit (8 byte) `long` value and I'm then trying to use the `BigInteger.testBit` to see if bit 63 is set, as it's being used as a flag.
long value = 0x4000863; //This value is actually read from a file
Long.toBinaryString(value) = 100000000000000100001100011
BigInteger test = new BigInteger(Long.toString(value));
if (test.testBit(63)) {
//yay
}
else {
//boo
}
The above code is what I'm currently trying, and it says bit 63 is not set. As it's being stored as a long, I didn't think I'd have to pad the value, or am I just doing something wrong entirely?
Any input or advice would be greatly appreciated.
Thanks.
|
You are counting the bits wrong:
public void test() {
// Binary - 100000000000000100001100011
// ^ This is bit 26
long value = 0x4000863;
// Binary - 1000000000000000000000000000000000000000000000000000000000000000
// ^ THIS is bit 63
long bigger = 0x8000000000000000L;
BigInteger test = new BigInteger(Long.toString(value));
System.out.println("L:" + Long.toBinaryString(value) + "\r\nB:" + test.toString(2) + "\r\nB63:" + test.testBit(63));
test = new BigInteger(Long.toString(bigger));
System.out.println("L:" + Long.toBinaryString(bigger) + "\r\nB:" + test.toString(2) + "\r\nB63:" + test.testBit(63));
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "java, binary, long integer, biginteger"
}
|
Why Visual Studio's custom hotkey for GitExtensions resets after restart?
I am using GitExtensions version 2.26 Visual Studio extension they comes with. I tried to assign custom keyboard hotkey to commit command like this:
!enter image description here
And everything works great until I will restart Visual Studio. After that hotkey gets magically un-assigned. Everything works if I select any other command, not from the **GitPlugin.*** group. Maybe somebody faced the same problem and found a workaround? Thanks!
|
As a workaround, you could grab the pull request added access keys to VS plugin menu items and build your own copy of the extension. After you copy the files from **GitExtensions\GitPlugin\bin** into **Documents\Visual Studio 2010\Addins** , you will get ~~accelerator~~ access keys for the Git menu. This will allow, for example, you to access **Commit** with **Alt+G, C**.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 4,
"tags": "visual studio, git, hotkeys, git extensions"
}
|
How to write a stored procedure which contains multiple parameters for in query?
I want to write a stored procedure like this
Create Proc dbo.GetApplicantsByIDs
as
Select * from Applicants where ID in (1,2,3,4)
How i can pass 1,2,3 as parameters and these ids may be multiple.
|
You can send your id's as XML to the SP.
create procedure dbo.GetApplicantsByIDs
@IDList xml
as
-- Table to hold the id's
declare @IDs table(ID int primary key)
-- Fill table with id's
insert into @IDs(ID)
select X.ID.value('.', 'int')
from @IDList.nodes('/i') as X(ID)
select *
from Applicants
where ID in (select ID
from @IDs)
The parameter string should look like this:
'<i>1</i><i>2</i><i>3</i>'
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "sql, sql server, sql server 2008, sql server 2005, tsql"
}
|
Firebase HTML TAG are not active in page
I have a WYSIWYG editor in my angular project and my users can save them modified posts in my Firebase database (With HTML TAG).
But, when I want to display them, I have something like this :
In HTML :

Hope it's help someone !
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "javascript, angularjs, firebase"
}
|
Is "found himself in hot water with the local council" a metaphor? If yes, what does that mean?
It sounds like the video is saying (link with a time stamp corresponds the following)
> In 2013, Grylls found himself in hot water with the local council after erecting a huge metal slide that ended with a drop off a cliff face into the sea below.
I understand the latter part, a huge metal slide.
the question is,
Is "found himself in hot water with the local council" a metaphor? If yes, what does that mean?
|
It is an idiom.
_To find oneself in hot water_ means to be in trouble, as stated in Cambridge dictionary.
|
stackexchange-ell
|
{
"answer_score": 1,
"question_score": 2,
"tags": "meaning"
}
|
How do I determine if a process is associated with a System.Diagnostics.Process object?
Given a particular **System.Diagnostics.Process** that has been assigned values to its properties `.FileName` and `.Arguments`, what is the best way to determine if it:
1. has ever been issued a `.Start()` command or
2. is currently associated with a process at all?
If `.Start()` was never issued, then calling `.CloseMainWindow()` causes an InvalidOperationException, which I'd like to avoid.
|
Have you tried checking `Process.Id` and one of the Exit properties ?
Ref.
In response to poster's comments: perhaps you will have to wrap in a try/catch and an exception being thrown indicates not started? It's not pretty!
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "c#, process"
}
|
How to understand "Natural Equivalence" in Category Theory intuitively?
.
For instance, in the above text (from Switzer's Algebraic Topology Book), by looking at the proof, it seems that the proof of natural equivalence is just proving one-one correspondence (i.e. bijection).
I am quite sure that "natural equivalence"="bijection" is not correct, so how do I interpret it correctly?
Thanks!
|
It is possible that indeed the authors are using the term _natural_ just to say that the bijection is the obvious one, meaning that they are using the word natural in a not-categorical way.
On the other hand that bijection is actually natural in the sense of category theory: that is the mappings $(i_X \colon [*,X] \to \pi_0(X))_X$ make commute the diagrams $$\require{AMScd} \begin{CD} [*,X] @>{i_X}>> \pi_0(X) \\\ @V[*,f]VV @VV\pi_0(f)V \\\ [*,Y] @>>{i_Y}> \pi_0(Y) \end{CD}$$ where $f \colon X \to Y$ is a continuous map between topological spaces, $[*,f]$ and $\pi_0(f)$ are the images of $f$ through the functors $[*,-],\pi_0 \colon \mathbf{Top} \to \mathbf{Set}$.
The proof that the $i_X$'s form a natural equivalence it is a matter of simple calculations (i.e. verifying the commutativity of the diagrams as above).
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 0,
"tags": "algebraic topology, category theory"
}
|
Backbone Marionette - Access to Router history
I'd like to add a back button in my navbar in order to be able to return to the previous page (I want the same behaviour when I click on this button and when I click on my browser's back button).
I wonder what is the best way to do it ?
|
All you need to do is add an event listener on your back button and call this code in the handler `window.history.back();`
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javascript, model view controller, backbone.js, router"
}
|
Too many open devices r
I'm trying to write many graphs to one olocation, but instead its writing a bunch of blank pictures:
my code looks like:
titleplot<-NULL
for(i in 1:99){
titleplot<-colnames(data[i])
mypath <- file.path("C:","Users","user.ME","Desktop","graph outputs", paste("myplot_", titleplot, ".jpg", sep = ""))
plot(data[,i],type="l", main =titleplot)
jpeg(file=mypath)
dev.off()
}
Does anyone know why this would happen or how I can remedy this?
|
You are supposed to put your `jpeg` command before you call your `plot` command.
jpeg(file=mypath)
plot(...)
dev.off()
|
stackexchange-stackoverflow
|
{
"answer_score": 11,
"question_score": 7,
"tags": "r"
}
|
local convexity of $L_p$ spaces
wiki says The spaces $L_p([0, 1])$ for $0 < p < 1$ are equipped with the F-norm they are not locally convex, since the only convex neighborhood of zero is the whole space Why is this so? <
|
**Key fact.** Given a function $f\in L^p([0,1])$ and a positive $\epsilon>0$, one can write $f$ as a finite convex combination of functions $g_1,\dots,g_n$ such that $\|g_k\|_{L^p}<\epsilon$ for all $k=1,\dots, n$.
Having the above, we conclude as follows: if $U$ is a convex neighborhood of $0$, then it contains the set $\\{g: \|g\|_{L^p}<\epsilon\\}$ for some $\epsilon>0$. The above fact, together with convexity, imply that $U$ contains all $L^p$ functions.
Proof of the key fact (sketch): For any $n$ there is a partition of $[0,1]$ into intervals $J_1,\dots,J_n$ such that $\int_{J_k} |f|^p=n^{-1}\int_0^1|f|^p$. Let $g_k=n\,f\,\chi_{J_k}$. Calculate $\|g_k\|_{L^p}$ and observe that it tends to $0$ as $n\to\infty$.
|
stackexchange-math
|
{
"answer_score": 5,
"question_score": 6,
"tags": "functional analysis, operator theory, topological vector spaces"
}
|
jest.fn() v/s jest.mock()?
For mocking uuidv4, I am using this :
import { v4 as uuidv4 } from "uuid";
jest.mock("uuid");
uuidv4.mockReturnValue("uuid123");
And for mocking window.confirm, I am using this:
window.confirm = jest.fn().mockImplementation(() => true);
These both are working all right. But when i try doing this i.e
const uuidv4 = jest.fn.mockImplementation(() => "uuid123");
I get this error
TypeError: jest.fn.mockImplementation is not a function
I am confused between jest.fn() and jest.mock().
Can someone please elaborate on which one to use and when to use, with suitable example?
|
Just a quick explanation for you:
* `jest.mock` is to mock a certain module. Once you write `jest.mock('uuid')` then it means all exported things would be turned to a `jest.Mock` type, that's why you can mock `v4` method: `v4.mockReturnValue('yourV4Id')`;
jest.mock('aModule');
import {aMember} from "aModule";
// is now a jest mock type <=> jest.fn()
aMember.mockReturnValue('a value');
* `jest.fn` is a function which returns a `jest.Mock` type which can be considered as an function to create whatever you want:
const aMock = jest.fn().mockReturnValue(1) // <=> const aMock = () => 1;
// The difference is jest mock type can be used to assert then. Most of cases is to check
// whether it gets called or not
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "unit testing, jestjs, mocking"
}
|
I'm not receiving push notifications anymore
The iOS app does not appear to be sending push notifications to my iPhone 5c running iOS 7.1.1 anymore.
I'm not sure exactly when the notifications stopped showing up, but I do recall rebooting my device at least once over the weekend. There was also a data center migration that took place during the weekend. I don't know if either of those might have caused it.
I've checked my notification settings and everything is enabled.
I've also tried deleting and reinstalling the app, but still no notifications show up. If I wasn't on the latest version already — which I'm pretty sure I was — I most certainly am at this point. The Help view says I'm on version 1.0.1.
Any ideas?
|
You're correct - there was a missing firewall rule on the outgoing service machine used to send push notifications. That combined with a bad connection string to our database that tracks exceptions means that nobody knew about it. Horray for the meta bug machine, you guys are at least 1.5x better than our exception logging framework.
|
stackexchange-meta
|
{
"answer_score": 3,
"question_score": 9,
"tags": "support, status completed, ios app"
}
|
Javascript Internet Explorer regex problem
i have this js code :
var str = "javascript:__doPostBack('ctl00$M$List$_rli2$ctl06','')";
alert (str);
var str = str.replace(/\$_rli\d+/, "$_rli" + 7);
alert (str);
And in IE it produces me result as follows:
javascript:__doPostBack('ctl00$M$Listjavascript:__doPostBack('ctl00$M$List$_rli2$ctl06','')rli7$ctl06','')
while it should work like this:
javascript:__doPostBack('ctl00$M$List$_rli7$ctl06','')
and it does in FF, Opera and Chrome.
It Replaces `$_` with whole previous string. No escape sequences seems to help.
What am i Doing wrong?
|
This is due to the way Internet Explorer handles references in replace. Use `$$` instead, which should work in all browsers:
var str = "javascript:__doPostBack('ctl00$M$List$_rli2$ctl06','')";
alert (str);
var str = str.replace(/\$_rli\d+/, "$$_rli" + 7);
alert (str);
// -> javascript:__doPostBack('ctl00$M$List$_rli7$ctl06','')
Alternatively, if you wanted to make it a bit clearer you could use an anonymous function that returns the replacement string:
var str = str.replace(/\$_rli\d+/, function () { return "$_rli" + 7; });
alert (str);
// -> javascript:__doPostBack('ctl00$M$List$_rli7$ctl06','')
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "javascript, regex, internet explorer"
}
|
HTML: ordered sublists
I want to create a ordered html list like this:
1.0 Introduction
1.1 Features
1.2 Readme
1.3 Thanks
...
How do I do this with html?
|
Counter's are the way to go. See this fiddle which goes three levels deep.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "html, css, html lists"
}
|
What are the rules for tuple mutability?
By trial&error I found some facts about tuples and mutability in Swift, but would like to learn about actual rules. Consider such code:
class T
{
var f : String = "hello"
}
let a = T();
let b = (f : "hello", "");
a.f = "world";
b.f = "world";
println(a.f)
println(b.f)
`a` behaves like fixed reference (you can change any member you like of the object, just not the main reference). So it is like `readonly` in C#.
But `b` behaves more like constant value -- the above code does not compile. One could say that `let` (or `var`) is applied to all the members of the tuple.
But it is guessing from my part -- so back to my question. What are the rules for tuples and their mutability?
|
As stated in The Swift Programming Language: The Basics, tuples are compound types in Swift. Therefore, if one creates a constant variable with `let` which has a tuple as type, all values in the tuple become constant too.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "swift, tuples, immutability"
}
|
How to translate "He can't buy me" in French?
I was studying les pronoms personnels and it's written in my textbook that:
_Indirect object pronouns are:_
> _Lui, leur, me, se, nous, vous_
— Which is kind of confusing because it doesn't include the "y"—
_Meanwhile, direct object pronouns are:_
> _Le, la, les_
In the direct objects pronouns there's no mention of (me, te, vous, nous) so if I want to say a sentence like:
> He bought you/ me/ us
How should I construct this sentence? Should I use moi/ toi/ vous instead?
|
there are many pronouns and it can definitely be confusing. Here are the categories you're talking about:
* pronoms personnels sujets: je, tu, il/elle/on, nous, vous, ils/elles
* pronoms compléments directs: me, te, le/la, nous, vous, les
* pronoms compléments indirects: me, te, lui, nous, vous, leur
* pronoms _y_ et _en_ (other situations)
* pronoms toniques: moi, toi, lui/elle, nous, vous, eux/elles
So to translate _He bought you/ me/ us_ , you can say: _Il t'/m'/nous a acheté-e-s_ -> don't forget to adjust the participe passé with the COD!
To know more about these different categories in grammar, here is an article for you: <
|
stackexchange-french
|
{
"answer_score": 1,
"question_score": 0,
"tags": "pronoms personnels"
}
|
php changing variable on database output
Hey i was looking here on other posts on stackoverflow and did't find an answer
i have a problem with changing variable on row output
i am inserting url to database with a var. for example
on my php file i have a variable called $site_id
$site_id = 5;
in the end i am using the url and the $site_id for using header but with a $site_id
$url = $row['url'];
header("Location: ".$url);
how can i change the variable?
|
You can do a simple string replace like this:
(Also i hope you made sure that you are save against SQL Injection for your DB)
$site_id = 5;
$url = ' //As an example from DB
$url = str_replace('$site_id', $site_id, $url);
header("Location: $url");
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "php, database"
}
|
Database Job Scheduling
I have a procedure written in PLJava that sends out updates over JMS in my postgres database.
What I would like to do is have that function called on an interval (every 15 seconds) internally in the database (preferably not from an outside process). Is this possible? Any ideas?
|
If you need no external access, you are presumably able to modify the database design so that you don't need the update at all. Can you explain more about what the update is doing?
As depesz said, you could use either cron or pgAgent, but they are only able to go down to a one minute granularity, not 15 seconds. Considering sleeping inside the stored procedure until the next iteration is not a good idea, because you will have an open transaction for all that time which is a really bad idea.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "sql, database, database design, postgresql, stored procedures"
}
|
Why should you scrub/clean cast iron cookware with salt?
I've seen this a number of times (for example here, or here at cooking.SE), and I do it at home, but I'd like to know for what reason salt is good for cleaning (cast) iron cookware.
I know it's a stop-gap measure when a non-stick pan looses it's coating (I can't find the reference).
|
The purpose for cleaning with salt is that it is an abrasive, and helps remove anything sticking to the pan, without being harsh enough to remove the seasoning.
Its _not_ a stop-gap measure for poor seasoning; it is intended to preserve the seasoning. The main issue is avoiding soaps and detergents which would tend to remove the seasoning that makes cast iron fairly non-stick.
|
stackexchange-cooking
|
{
"answer_score": 1,
"question_score": 2,
"tags": "food science, cookware, cast iron"
}
|
Filter Pandas DataFrame by comparing columns in a row
Each row in my DataFrame has two date columns. How can I filter out the rows in which 'Date A' is after 'Date B'?
Example:
symbol | reports_at | as_of | signal
...
A | 2012-02-15T21:00:00Z | 2012-02-01T12:00:00Z| 65.20464367
...
This row should be deleted from the DataFrame because the date in the 'reports_at' column occurs after the date in the 'as_of' column
|
You need `boolean indexing` or `query`:
**1.**
df1 = df[df['as_of'] > df['reports_at']]
**2.**
df1 = df.query('as_of > reports_at')
**3.**
df1 = df[df['reports_at'] <= df['as_of']]
**4.**
df1 = df.query('reports_at <= as_of')
|
stackexchange-stackoverflow
|
{
"answer_score": 17,
"question_score": 7,
"tags": "python, pandas, dataframe"
}
|
Which files get updated in a plugin update?
When a user updates a plugin from the WordPress admin panel, does every plugin file get overwritten, or just the ones that have changed from the previous version?
For example, let's say that a plugin has 3 files: a.php, b.php, and c.php
Version 2.0 has changes to a.php and b.php; c.php was unchanged. However, the user made a change to c.php before updating to 2.0. Does the user lose his changes?
|
When you update a plugin you just get a new Zip-file containing the whole plugin. You don't get the information which files in that archive changed. That's the reason why all files are overwritten.
|
stackexchange-wordpress
|
{
"answer_score": 8,
"question_score": 4,
"tags": "plugins, updates"
}
|
Possible to add "Even/Odd Classes" to image attachments via wp_get_attachment_image?
Im looking for a way to add an alternating even/odd class directly to each image attachment when its outputted via my function below:
<?php
function nongallery_img_slide( $post_id = null ) {
if ( $post_id == null ) return;
$images = get_posts(
array(
'numberposts' => -1,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post_id,
'orderby' => 'menu_order',
'order' => 'ASC',
//'exclude' => get_post_thumbnail_id( $post_id )
)
);
if ( count( $images ) > 0 ) {
foreach ( $images as $image ) {
echo wp_get_attachment_image( $image->ID, 'photogallery-img' );
}
}
}
?>
Can this be done?
Thanks!
|
`wp_get_attachment_image()` has a fourth parameter for custom attributes. Use it:
if ( count( $images ) > 0 ) {
$i = 0;
foreach ( $images as $image ) {
echo wp_get_attachment_image(
$image->ID,
'photogallery-img',
FALSE,
array (
'class' => 'attachment-photogallery-img '
. ( ( $i++ % 2 === 0 ) ? 'even' : 'odd' )
)
);
}
}
|
stackexchange-wordpress
|
{
"answer_score": 1,
"question_score": 0,
"tags": "attachments, images"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.