qid
int64 1
74.7M
| question
stringlengths 0
70k
| date
stringlengths 10
10
| metadata
list | response
stringlengths 0
115k
|
---|---|---|---|---|
57,785,687 |
I have a Pandas Dataframe containing multiple colums of strings.
I now like to check a certain column against a list of allowed substrings and then get a new subset with the result.
```
substr = ['A', 'C', 'D']
df = pd.read_excel('output.xlsx')
df = df.dropna()
# now filter all rows where the string in the 2nd column doesn't contain one of the substrings
```
The only approach I found was creating a List of the corresponding column an then do a list comprehension, but then I loose the other columns. Can I use list comprehension as part of e.g. `df.str.contains()`?
```
year type value price
2000 ty-A 500 10000
2002 ty-Q 200 84600
2003 ty-R 500 56000
2003 ty-B 500 18000
2006 ty-C 500 12500
2012 ty-A 500 65000
2018 ty-F 500 86000
2019 ty-D 500 51900
```
expected output:
```
year type value price
2000 ty-A 500 10000
2006 ty-C 500 12500
2012 ty-A 500 65000
2019 ty-D 500 51900
```
|
2019/09/04
|
[
"https://Stackoverflow.com/questions/57785687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9360663/"
] |
You could use [`pandas.Series.isin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.isin.html)
```py
>>> df.loc[df['type'].isin(substr)]
year type value price
0 2000 A 500 10000
4 2006 C 500 12500
5 2012 A 500 65000
7 2019 D 500 51900
```
|
12,802,957 |
I have three web projects on Asp.net MVC3:
Portal.Web -> Common controllers and models
Portal.WebsiteCustom -> Custom website 1
Portal.WebsiteCustom2 -> Custom website 2
Both custom sites uses the controllers and models of Portal.Web.
Now i would like to add the common views on this project and set MVC to look on Portal.Web project for common views.
Is this possible?
How i could archieve this?
Thanks.
|
2012/10/09
|
[
"https://Stackoverflow.com/questions/12802957",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445003/"
] |
>
> Is this possible?
>
>
>
Yes.
>
> How i could archieve this?
>
>
>
You will have to embed those views as resources into the assembly and then reference the assembly in your client MVC project. Next you will have to write a custom virtual path provider that is able to retrieve those views as embedded resources instead of looking for them in the current project folder which is the default process.
You could use the [`Razor Generator package`](http://razorgenerator.codeplex.com/) which allows you to [`simplify the process`](http://razorgenerator.codeplex.com/documentation) as it already provides you with the custom virtual provider that you don't need to manually write. And here's an [outdated article](http://www.chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/) that you could also check.
|
273,530 |
Suppose $$y^{'}+p(x)y=q(x),\,\,\,y(x\_0)=y\_0$$ where $p$ and $q$ are continuous functions in some interval $I$ containing $x\_0$. Show that the particular solution is $$y(x)=e^{\int\_{x\_o}^{x}{p(t)}dt}[\int\_{x\_0}^{x}{e^{\int\_{x\_0}^{t}{p(\xi)}d\xi}q(t)dt+y\_0}]$$
I have no idea where the $\xi$ comes from. I can only get the general solution $$y(x)=\frac{1}{I(x)}{\int{}I(x)q(x)dx+C} ,$$ where $I(x)$ is an integrating factor
|
2013/01/09
|
[
"https://math.stackexchange.com/questions/273530",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/54398/"
] |
Searching for the method called **Variation of Parameters**, we will find out, for the linear 1-order differential equation $y'+p(x)y=q(x)$ where the functions $p(x), q(x)$ have the conditions as you gave them above; there is a solution like $y\_1(x)=\text{e}^{\int-p(x)dx}$.(You know all of these)
The method goes further and tells us that the one-parameter family of solutions of our equation is as the form you noted above as well. In fact we set $y(x)=v(x)y\_1(x)$ into the equation to find another part of solution which is free of any constant. This is the particular solution $$y\_p(x)=\text{e}^{\int-p(x)dx}\int\text{e}^{\int-p(x)dx}f(x)dx$$. In 2-order linear equation we can easily understand why this approach was made.
Now I make an example to see why that formula arisen. Let we have $y'=f(x,y),\; y(x\_0)=y\_0$. You surely accept that if $f(x,y)$ be continuous in a region containing the point $(x\_0,y\_0)$ then by integrating from both sides of our latter OE, we have $$y(x)=c+\int\_{x\_0}^{x}f(t,y(t))dt$$ and certainly $$y(x\_0)=c+\int\_{x\_0}^{x\_0}f(t,y(t))dt=c$$ and so $$y(x)=y\_0 +\int\_{x\_0}^{x}f(t,y(t))dt$$. I hope you got the point. Moreover @experimentX gave you additional points.
|
377,587 |
I'm trying to use the `tikz-feynman` package to produce a fairly simple diagram, I produced the following plot:
```
\documentclass[tikz]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram [horizontal=a to b] {
i1 [particle=\(q\)] -- [fermion] a -- [fermion] i2[particle=\(\bar{q}\)],
a -- [gluon, edge label=\(g\)] b,
f1 [particle=\(g\)] -- [gluon] b -- [dashed, red] f2 [red, particle=\(G\)]],
};
\end{document}
```
and would like to add a gluon radiation off the line that connects the `i1` and `a` vertexes. My understanding is that I would have to redo the diagram placing the vertexes manually. Is that so?
|
2017/06/30
|
[
"https://tex.stackexchange.com/questions/377587",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/9585/"
] |
Once the diagram has been placed with [Ti*k*Z-Feynman](http://jpellis.me/projects/tikz-feynman) ([CTAN](http://ctan.org/pkg/tikz-feynman)), you can access the vertices as you would with other coordinates in Ti*k*Z.
In your case, you probably don't want to redraw the whole diagram as you want to make it salient as it is the same diagram except with initial state radiation extra. In the solution below, I add an extra vertex `(r)` which I then connect with a gluon line to 80% of the distance from `(i1)` to `(a)`.
```
\RequirePackage{luatex85}
\documentclass[tikz, border=10pt]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\begin{tikzpicture}
\begin{feynman}
\diagram [horizontal=a to b] {
i1 [particle=\(q\)]
-- [fermion] a
-- [fermion] i2[particle=\(\bar{q}\)],
a -- [gluon, edge label=\(g\)] b,
f1 [particle=\(g\)]
-- [gluon] b
-- [dashed, red] f2 [red, particle=\(G\)]],
};
\vertex [above left=of f1] (r);
\draw [gluon] ($(i1)!0.8!(a)$) -- (r);
\end{feynman}
\end{tikzpicture}
\end{document}
```
[](https://i.stack.imgur.com/uasBB.png)
|
24,981,863 |
In my iOS 7.1 application that I'm trying to develop, I need to figure out percentages of a specific number which is entered in a UITextField. It would appear when executing the code I get the wrong percentage of that number entered.
I've tried two different ways to get the require percentage answer I'm looking for, however it keeps giving the wrong answer.
Below here is the two methods that I've tried.
For example I want to get 72% of 250. If you were to do this on a calculator or better yet a excel spreadsheet I get the right answer 250 x 1 - 72% = 70. This is the correct answer I want
Method1 (.m file) Not working
Values that are set the the specific .text parameters:
```
Entered in the UITextField _linuxOracleOnDiskw_oRTC.text = 250
Value set to UITextField _formulaNumber.text = 1
Percentage Value set to _linuxOracle_Percent.text = 0.72
_linuxOracleOnDiskwithRTC.text = [NSString stringWithFormat:@"%.2f", ([_linuxOracleOnDiskw_oRTC.text doubleValue])*([_formulaNumber.text doubleValue])-([_linuxOracle_Percent.text doubleValue])];
```
When executed I the answer or vale that gets entered in the UITextField \_linuxOracleOnDiskwithRTC.text is 249.28. This is wrong should be 70
Second method tried is as follows:
```
float linuxOracleOnDiskw_oRTC = [_linuxOracleOnDiskw_oRTC.text floatValue];
```
\_linuxOracleOnDiskwithRTC.text = [NSString stringWithFormat:@"%.2f", (linuxOracleOnDiskw\_oRTC \* 1 - 72/100.0f )];
If someone can tell me what I maybe doing wrong and point me in the right direction with calculating percentages of a specific number entered in a UITextField I would be extremely GREATFUL.
|
2014/07/27
|
[
"https://Stackoverflow.com/questions/24981863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3881740/"
] |
Don't omit your brackets when performing calculations with code. For "250 x 1 - 72%" to get 70, you need to do this:
250 x (1 - 0.72) = 250 x 0.28 = 70
Formulas in () will be calculated first, followed by multiplication and division (whichever first), then followed by addition and subtraction (whichever first). So, insert your brackets appropriately.
|
56,045,959 |
There are a lot of posts about how to count `NaN` in a list or pandas series, as well as the time efficiency of the various options. One solution I have not seen is self equality: If `y == np.nan` then `(y != y) is True`. So a quick way to count the NaNs in a list would be:
```py
import pandas as pd
import numpy as np
lst = pd.Series([np.nan, 5, 4, 3, 2, np.nan])
count = sum(1 for x in lst if x != x)
```
I hadn't seen that solution before, which makes me wonder: When will this fail to work the way I want it to work (eg maybe for dtypes that aren't in my columns - I have floats and strings? I've done some testing with my own data, and found this solution to be equivalent to:
```py
count = lst.isnull().sum()
# and
count = len([x for x in lst if x != x])
```
I've found that the speed is in this order from fastest to slowest: `sum`, `len`, `.sum()`
|
2019/05/08
|
[
"https://Stackoverflow.com/questions/56045959",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5531578/"
] |
You could use [`numpy.isnan()`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.isnan.html), so your code would look like:
```py
import pandas as pd
import numpy as np
lst = pd.Series([np.nan, 5, 4, 3, 2, np.nan])
count = len([x for x in lst if np.isnan(x)])
```
But if you want to be fancy:
```py
count = sum(np.isnan(lst))
```
Or if you're concerned about memory:
```py
# Less elegant, but does the job
count = 0
for x in lst:
if np.isnan(x):
count += 1
```
|
36,511,990 |
Assume I receive two arguments to a template, T1 and T2. If I know T1 is itself a templated class (e.g., a container), and T2 can be anything, is it possible for me to determine the base template type for T1 and rebuild it using T2 as its argument?
For example, if I receive `std::vector<int>` and `std::string`, I would want to automatically build `std::vector<std::string>`. However if I were given `std::set<bool>` and `double`, it would produce `std::set<double>`.
After reviewing type\_traits, relevant blogs, and other questions here, I don't see a general approach to solving this problem. The only way I can currently see to accomplish this task is to build template adapters for each type that could be passed in as T1.
For example, if I had:
```
template<typename T_inner, typename T_new>
std::list<T_new> AdaptTemplate(std::list<T_inner>, T_new);
template<typename T_inner, typename T_new>
std::set<T_new> AdaptTemplate(std::set<T_inner>, T_new);
template<typename T_inner, typename T_new>
std::vector<T_new> AdaptTemplate(std::vector<T_inner>, T_new);
```
I should be able to use decltype and rely on operator overloading to solve my problem. Something along the lines of:
```
template <typename T1, typename T2>
void MyTemplatedFunction() {
using my_type = decltype(AdaptTemplate(T1(),T2()));
}
```
Am I missing something? Is there a better approach?
**WHY do I want to do this?**
I'm building a C++ library where I want to simplify what users need to do to build modular templates. For example, if a user wants to build an agent-based simulation, they might configure a World template with an organism type, a population manager, an environment manager, and a systematics manager.
Each of the managers also need to know the organism type, so a declaration might look something like:
```
World< NeuralNetworkAgent, EAPop<NeuralNetworkAgent>,
MazeEnvironment<NeuralNetworkAgent>,
LineageTracker<NeuralNetworkAgent> > world;
```
I'd much rather users not have to repeat `NeuralNetworkAgent` each time. If I am able to change template arguments, then default arguments can be used and the above can be simplified to:
```
World< NeuralNetworkAgent, EAPop<>, MazeEnvironment<>, LineageTracker<> > world;
```
Plus it's easier to convert from one world type to another without worrying about type errors.
Of course, I can deal with most errors using static\_assert and just deal with the longer declarations, but I'd like to know if a better solution is possible.
|
2016/04/09
|
[
"https://Stackoverflow.com/questions/36511990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2301053/"
] |
define a util class, like following:
```
public class AcitivtyUtil {
public static void showActivity(Activity from, Class<?> to, boolean finish) {
Intent intent = new Intent(from, to);
from.startActivity(intent);
if (finish) {
from.finish();
}
}
}
```
then you can call `ActivityUtil.showActivity(this, TargetActivity.class, true|false)` at any Activity.
some error in your code:
```
public void ShowActivity(Activity act) // here you can't pass a Activity object as parameter, you should pass Class<?>, so it should be act.class
{
Intent intent = new Intent(this, act.class);
startActivity(intent);
}
```
If you don't want use util class, you can also define the `showActivity()` in your Activity class as member method, recommend define it in BaseActivity, so you need not duplicate it in all Activity.
```
public void showActivity(Class<?> to, boolean finish) {
Intent intent = new Intent(this, to);
startActivity(intent);
if (finish) {
finish();
}
}
```
|
41,353 |
I face a problem where I need to compute similarities over bilingual (English and French) texts. The "database" looks like this:
```
+-+-+-+
| |F|E|
+-+-+-+
|1|X|X|
+-+-+-+
|2| |X|
+-+-+-+
|3|X| |
+-+-+-+
|4|X| |
+-+-+-+
|5| |X|
+-+-+-+
|6|X|X|
+-+-+-+
|7|X| |
+-+-+-+
```
which means that I have English and French texts (variable long single sentences) for each "item" with either in both version (in this case the versions are loose translations of each other) or only in one language.
The task is to find the closest item ID for any incoming new sentence irrespective the actual language of either of the sentence in the "database" or of the incoming sentence (that is, the matching sentence in the "database" needn't necessarily be in the same language as the incoming sentence as long as the meaning is the closest). I hope this goal explanation is clear.
Originally I planned to build a word2vec from scratch for both languages (the vocabulary is quite specific so I would have preferred my own word2vec) and find similarities only for the corresponding language for each new sentence but this would omit all candidates from the items where the corresponding language sentences are missing.
So I wonder if generating a common word2vec encoding for the combined corpus is viable (the word2vec method itself being language agnostic) but I cannot figure out if such a solution would be superior.
Additionally, the number of the sentences is not very large (about 10.000) maybe word2vec generation from scratch is not the best idea on one hand, but there are really specific terms in the corpora on the other hand.
|
2018/11/17
|
[
"https://datascience.stackexchange.com/questions/41353",
"https://datascience.stackexchange.com",
"https://datascience.stackexchange.com/users/21560/"
] |
This paper from Amazon explains how you can use aligned bilingual word embeddings to generate a similarity score between two sentences of different languages. Used movie subtitles in four language pairs (English to German, French, Portuguese and Spanish) to show the efficiency of their system.
["Unsupervised Quality Estimation Without Reference Corpus for Subtitle Machine Translation Using Word Embeddings"](https://ieeexplore.ieee.org/document/8665529)
|
58,783,984 |
am making a card where i have the image and description below but the image is too zoomed and doesnt look attractive i've tried to adjust the height and image but it doesnt work
[](https://i.stack.imgur.com/ZXyPR.png)
HTML
```
<div id="event-card">
<div id="card-image">
<img src="{{ URL::to('/assets/photos/event3.jpg') }}">
</div>
<div class="container" id="card-details">
{{$event->eventName}}
</div>
</div>
```
This is the CSS
```
#event-card{
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: 0.3s;
display: inline-block;
width:250px;
height:250px;
overflow: hidden;
margin-right:10px;
margin-bottom:10px;
border-radius: 8px;
margin-top:40px;
}
#card-image {
background-image:url('/churchill/public/assets/photos/event3.jpg');
height:60%;
width: 100%;
background-size:cover;
overflow:hidden;
background-repeat: no-repeat;
}
#event-cards{
width:80%;
margin-left:156px;
}
```
|
2019/11/09
|
[
"https://Stackoverflow.com/questions/58783984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
All well.. images.. biggest problem ever :D
Well you actually have few options.
I will be straightforward
```css
img {
width: 100%;
height: 100%;
object-fit: cover;
}
```
This will make image look natural and not stretched but it might cut it on sides for that
```css
img {
max-width: 100%;
height: auto;
}
```
This might be best solution for you. Image won't go over parent in width and it will go in height big enough to keep its aspect ratio and it will look natural. Play with it and see what looks best for you
PS: You also have
```css
object-fit: fill;
object-fit: contain;
object-fit: cover;
object-fit: scale-down;
object-fit: none;
```
|
12,703,271 |
I need to write a script in CentOS, which will run in background.
This script need to check whether a file name "status.txt" has been created in /root/MyFile folder on not. If that file is created, an event should be captured by my script.
What code snippet I should write in my script, so that it gets event that the txt file has been created in a folder?
Any help is greatly appreciated.
|
2012/10/03
|
[
"https://Stackoverflow.com/questions/12703271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1716243/"
] |
The simplest solution:
```
while true; do
do
[ -e "/root/MyFile/status.txt" ] && { echo file is created; break; }
sleep 1
done
```
Instead of `echo file is created` you can write the commands you want to execute.
You can to the same with **inotify**:
```
inotifywait --format '%f' -m /root/MyFile 2> /dev/null | while read file
do
[ "$file" = status.txt ] \
&& [ -e "/root/Myfile/$file" ] \
&& { echo file is created ; break; }
done
```
This that solution has that advantage that you will get the action instantly, as the file will be created. And in the first case you will too wait for the second. The second advantage, that you need to poll the filesystem every second.
But this solution has disadvantages also:
* it works only on Linux;
* you need relatively modern kernel;
* you need to install inotify-tools;
* if you create many files before `status.txt` will be created, you make many additional comparison operation.
Resuming:
I think, you need the first solution.
|
33,938 |
I'm trying to set Single-Click (in explorer) in some Kiosk-like PCs, running Windows XP, but I can't find any way to set it through GPO.
Is there any way to do this?
|
2009/06/30
|
[
"https://serverfault.com/questions/33938",
"https://serverfault.com",
"https://serverfault.com/users/132/"
] |
You're not going to be able to change this with "Administrative Templates". This is one of those annoying values that's stored in a REG\_BINARY structure (specifically HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellState) and is wholly undocumented in structure.
You could script a registry merge to this value, but if Explorer is already running when you change this value you won't see the effect until the next logon. Explorer is able to update itself when you change this setting in the menu via some undocumented API. Yay undocumented APIs... *sigh* You'll also be changing more than just the single-click behaviour if you merge over top of it-- there are other things in this opaque binary value.
(I'd love Microsoft to take the attitude that 100% of settings in Windows, Office, etc must be customizable via Group Policy.)
|
3,004,566 |
This is my first time posting so do correct me if I am doing anything wrong.
Please help me with this math problem from the British Maths Olympiad (1994 British Maths Olympiad1 Q1 Number Theory).
>
> Starting with any three digit number $n$ (such as $n = 625$) we obtain a new number $f(n)$ which is equal to the sum of the three digits of $n$, their three products in pairs, and the product of all three digits.
> Find all three digit numbers such that $\frac{n}{f(n)}=1$.
>
>
>
The only solution I found is $199$, can someone verify it please?
|
2018/11/19
|
[
"https://math.stackexchange.com/questions/3004566",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/616837/"
] |
Let $n=100a+10b+c,$ where $a> 0$ and $b,c\geq 0$. We are trying to solve $$100a+10b+c=a+b+c+ab+ac+bc+abc \\ \implies 99a+9b=abc+ab+ac+bc \\ \implies a(99-b-c-bc)=b(c-9) \\$$$c-9\leq 0$, but $b+c+bc\leq 99$. So the above equation holds iff $b=c=9$, which means $a$ can take any value.
|
2,434,413 |
As the title states, I need to relace all occurrences of the $ sign in a string variable with an underscore.
I have tried:
```
str.replace(new RegExp('$', 'g'), '_');
```
But this doesn't work for me and nothing gets replaced.
|
2010/03/12
|
[
"https://Stackoverflow.com/questions/2434413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/111292/"
] |
The `$` in RegExp is a special character, so you need to escape it with backslash.
```
new_str = str.replace(new RegExp('\\$', 'g'), '_');
```
however, in JS you can use the simpler syntax
```
new_str = str.replace(/\$/g, '_');
```
|
36,426,547 |
I am using Ubuntu 14.04
I wanted to install package "requests" to use in python 3.5, so I installed it using pip3. I could see it in /usr/lib/python3.4, but while trying to actually execute scripts with Python 3.5 I always got "ImportError: No module named 'requests'"
OK, so I figured, perhaps that's because the package is not in python3.5 but in python3.4. Therefore, I tried to uninstall and install i again, but it just kept popping up where I didn't want it (not to mention, when I run apt-get remove pip3-requests, it actually removed pip3 for me as well lol). Therefore, I tried physically removing python3.4 from usr/lib and usr/local/lib in order to try and see if maybe pip3 was confused and installed packages in wrong directories.
I'm afraid it was not a good idea... when I now run e.g.
`sudo pip3 install reqests`
I get the following error:
`Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'`
Is there any way to fix this now? And to actually use requests package?
When I use
```
sudo apt-get install python3-pip
```
It works and starts unpacking etc. but then I get a long error that starts with:
```
Setting up python3.4 (3.4.3-1ubuntu1~14.04.3)
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
dpkg: error processing package python3.4 (--configure):
subprocess installed post-installation script returned error exit status 134
dpkg: dependency problems prevent configuration of python3:
```
(...)
and ends with
```
python3 depends on python3.4 (>= 3.4.0-0~); however:
Package python3.4 is not configured yet.
dpkg: error processing package python3-wheel (--configure):
dependency problems - leaving unconfigured
E: Sub-process /usr/bin/dpkg returned an error code (1)
```
|
2016/04/05
|
[
"https://Stackoverflow.com/questions/36426547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4680896/"
] |
**First of all, it is a very bad idea to remove your *system* Python 3 in Ubuntu (which 3.4 is in recent
subrevisions of Trusty LTS)**. That is because it is a **vital part of the system**. If you run the command `apt-cache rdepends python3`, you'd see that packages such as `ubuntu-minimal`, `ubuntu-release-upgrader-core`, `lsb-release`, `lsb-core`, `ubuntu-core-libs` and so on, all depend on Ubuntu's version of Python 3 being installed (and this is the **python3.4** in Ubuntu 14.04.4). If you force-remove python 3.4 by hand, you've ruined your system.
It might very well be
that you now have to reinstall the whole operating system, unless you manage to reinstall all the system
`.deb` packages that put data in `/usr/lib/python3.4`.
And especially so if you do it with force. It can make your system even unbootable, so do not reboot that
computer before you've successfully reinstalled Python 3... actually I am not sure how to do it safely since
it seems you've forcefully removed all system dependencies from the /usr/lib)
---
You should try to reinstall python3.4
```
sudo apt-get install --reinstall python3.4
```
But now the bigger problem is that you've still missing all sorts of dependencies for your system programs.
Do note that `pip` also should be available as a *module*. Thus to ensure that you install for Python 3.5,
you can do
```
sudo python3.5 -mpip install requests
```
The `pip3` is a wrapper for a `pip` that installs to the *system* Python 3 version (3.4 in your case).
|
70,814,373 |
```
x =[1,2,3,4,5,6]
y = [1,2,3,4,5]
if x == y:
print("Numbers found")
else:
print("Numbers not found")
```
*I want to print the numbers which are not present in list y.*
|
2022/01/22
|
[
"https://Stackoverflow.com/questions/70814373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17741997/"
] |
The fastest way is to transform both in sets and print the difference:
```
>>> print(set(x).difference(set(y)))
{6}
```
This code print numbers present in `x` but not in `y`
|
36,809,868 |
I have two inputs one for min and the other for max value.
How can I add validation so the min < max?
```html
<div class="form-group">
<label class="control-label"> Montant minimum</label>
<input id="min" class="form-control" type="number" ng-model="type.minMontant" required/>
</div>
<div class="form-group">
<label class="control-label"> Montant maximum</label>
<input id="max" class="form-control" type="number" ng-model="type.maxMontant" required/>
</div>
```
And then when I'll try to pick a value, it must be in [min,max] ?
|
2016/04/23
|
[
"https://Stackoverflow.com/questions/36809868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6120367/"
] |
**Not Sure if this is wat you want**
**if you want validation messages to show then you have to use angular-messages**
```
<div ng-app>
<div class="form-group">
<label class="control-label"> Montant minimum</label>
<input id="min" class="form-control" type="number" min="0" max="{{maxMontant}}" ng-model="minMontant" required/>
</div>
<div class="form-group">
<label class="control-label"> Montant maximum</label>
<input id="max" class="form-control" type="number" max="10" ng-model="maxMontant" required/>
</div>
</div>
```
|
450,107 |
I'm trying to compile a project from the command line, like this:
```
devenv.exe myproj.sln /build release
```
It looks like the code compiles well, but that's not all I need:
I want to be able to capture the output (e.g. warnings, errors) from the compiler as they occur. Unfortunately as soon as I issue the above command I am returned to the command prompt.
When I look at process-explorer or taskmgr.exe I can see that the devenv.exe process (and a few other sub-processes) working away. If I look in the output folder I can see all of my files gradually appearing.
Is there a way of making VCC work a little bit more like GCC - when I issue a build command or make a project using a Makefile, I get a stream of messages and the console blocks until the process has completed.
Update: Thanks, two excellent solutions. I can confirm that it works.
|
2009/01/16
|
[
"https://Stackoverflow.com/questions/450107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46411/"
] |
devenv uses this interesting dispatcher that switches between command line mode and windowed mode. There's actually a devenv.com in addition to devenv.exe, and since \*.com takes precedence over \*.exe, it gets invoked first. devenv.com analyzes the command line and decides what to invoke.
In other words, change your command line to:
```
devenv myproj.sln /build release
```
And you should be ok.
|
62,761,664 |
I'm getting via url querystring variables like:
myserver\_state=1&myserver\_running=2&myserver\_mem=3
Currently i'm adding to an existing json like:
```
{
"key1": "1",
"key2": "2",
"key3": "3",
"myserver_state": "1",
"myserver_running": "2",
"myserver_mem": "3"
}
```
And i really want it like this:
```
{
"key1": "1",
"key2": "2",
"key3": "3",
"myserver": {
"state": "1",
"running": "2",
"mem": "3"
}
}
```
I'm using this to load them:
```
$formdata = array(
'state'=> $_POST['state'],
'uassip'=> $_POST['uassip'],
'uassipport'=> $_POST['uassipport'],
'c_uacminrtpport'=> $_POST['c_uacminrtpport'],
'c_uacmaxrtpport'=> $_POST['c_uacmaxrtpport'],
'c_cps'=> $_POST['c_cps'],
'c_totalcalls'=> $_POST['c_totalcalls'],
'c_maxchannels'=> $_POST['c_maxchannels'],
'c_duration'=> $_POST['c_duration'],
'c_to'=> $_POST['c_to'],
'c_uacxml'=> $_POST['c_uacxml']
);
echo "fromdata: <br>"; echo var_dump($formdata) . "<br><hr>";
if(file_put_contents('testconfig.json', json_encode($formdata) )) echo 'OK';
else echo 'Unable to save data in "testconfig.json"';
```
Many thanks!
EDIT:
following comments i tried:
status.php?server1[current\_state]=10
this actually works to:
```
"c_uacxml": "telnyx-uac-invite-ok.xml",
"server1": {
"current_state": "10"
}
}
```
Which is great, BUT, if i then want to add an element like this:
status.php?server1[current\_mem]=1
This actually REPLACES the whole `server1`
```
"c_uacxml": "telnyx-uac-invite-ok.xml",
"server1": {
"current_mem": "10"
}
}
```
and i lose the already existing current\_state
|
2020/07/06
|
[
"https://Stackoverflow.com/questions/62761664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2115947/"
] |
Just use multidimensional array within your URL like:
```
test.php?key1=1&key2=2&myserver[state]=1&myserver[running]=2&myserver[mem]=3
```
so easy script
```
<?php
echo '<pre>';
echo json_encode($_GET, JSON_PRETTY_PRINT);
```
will give you
```
{
"key1": "1",
"key2": "2",
"myserver": {
"state": "1",
"running": "2",
"mem": "3"
}
}
```
of course, if required you can use also POST request with the same naming rules.
|
42,343,463 |
I am having below dummy table
```
select * from (
select 'A' as col1, 'B' as col2 from dual
union
select 'B' as col1, 'A' as col2 from dual
union
select 'A' as col1, 'C' as col2 from dual
union
select 'C' as col1, 'A' as col2 from dual
union
select 'A' as col1, 'D' as col2 from dual
)a
```
which will give output as below
```
col1 col2
A B
A C
A D
B A
C A
```
I wants to find the distinct values from that table like below
```
col1 col2
A B
A C
A D
```
first row can be A B or B A same as second can be A C or C A
Is it possible??
We got the solution for above problem which is below
```
select distinct least(col1, col2), greatest(col1, col2)
from the_table;
```
but if there is more than 2 column, then i wouldn't work
Let us assume the below scenario
Input
```
col1 col2 col3
A B E
A C E
A D E
B A F
C A E
```
Output
```
col1 col2 col3
A B E
A D E
B A F
C A E
```
then what would be the possible solution ?
|
2017/02/20
|
[
"https://Stackoverflow.com/questions/42343463",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2431786/"
] |
Here is one method:
```
select col1, col2
from t
where col1 <= col2
union all
select col1, col2
from t
where col1 > col2 and
not exists (select 1 from t t2 where t2.col1 = t.col2 and t2.col2 = t.col1);
```
|
9,582,357 |
My knowledge of MVC and Razor is quite basic so I'm hoping its something rather simple. Basically, I have my `Controllers` as normal but my `Views` folder has a nested structure. For example, instead of:
```
Views -> Index.cshtml
```
It is like
```
Views -> BrandName -> Index.cshtml
```
I created a custom helper to work around this, but I'm not sure how it would work with query string urls? As an example here is a controller:
```
private DataService ds = new DataService();
//
// GET: /Collections/
public ActionResult Index()
{
return View();
}
//
// GET: /Collections/Collection?id=1
public ActionResult Collection(int id)
{
var collectionModel = ds.GetCollection(id);
return View(collectionModel);
}
```
But how do I get `ActionResult Collection` to look at:
```
Views -> Brand2 -> Collection.cshtml
```
Here is the workaround method I was using:
```
public static string ResolvePath(string pageName)
{
string path = String.Empty;
//AppSetting Key=Brand
string brand = ConfigurationManager.AppSettings["Brand"];
if (String.IsNullOrWhiteSpace(brand))
path = "~/Views/Shared/Error.cshtml"; //Key [Brand] was not specified
else
path = String.Format("~/Views/{0}/{1}", brand, pageName);
return path;
}
```
|
2012/03/06
|
[
"https://Stackoverflow.com/questions/9582357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/849843/"
] |
Use the following
```
public ActionResult Collection(int id)
{
var collectionModel = ds.GetCollection(id);
return View("/Brand2/Collection", collectionModel);
}
```
The above code will search for the following views.
```
~/Views/Brand2/Collection.aspx
~/Views/Brand2/Collection.ascx
~/Views/Shared/Brand2/Collection.aspx
~/Views/Shared/Brand2/Collection.ascx
~/Views/Brand2/Collection.cshtml
~/Views/Brand2/Collection.vbhtml
~/Views/Shared/Brand2/Collection.cshtml
~/Views/Shared/Brand2/Collection.vbhtml
```
or to be more direct
```
public ActionResult Collection(int id)
{
var collectionModel = ds.GetCollection(id);
return View("~/Brand2/Collection.cshtml", collectionModel);
}
```
Now, I want to be the first to warn you that you should never, never, never use this answer. There is a good reason for following the conventions inherent in an MVC application. Placing your files in known locations makes it easier for everyone to understand your application.
|
1,605,718 |
I need to calculate:
$$
\iint \_D \frac{2y^2+x^2}{xy}~\mathrm dx~\mathrm dy
$$
over the set $D$ which is:
$$
y\leq x^2 \leq 2y , \quad 1\leq x^2 +y^2 \leq 2 , \quad x\geq 0
$$
can someone help me understand what possible change of variables can I do here?
Thanks a lot in advance .
|
2016/01/09
|
[
"https://math.stackexchange.com/questions/1605718",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/173919/"
] |
You have $$\begin{aligned}\vert f(x)-f(y) \vert &= \left\vert \sqrt{x^2+1}-\sqrt{y^2+1} \right\vert \\
&= \left\vert (\sqrt{x^2+1}-\sqrt{y^2+1}) \frac{\sqrt{x^2+1}+\sqrt{y^2+1}}{\sqrt{x^2+1}+\sqrt{y^2+1}} \right\vert \\
&= \left\vert \frac{x^2-y^2}{\sqrt{x^2+1}+\sqrt{y^2+1}} \right\vert \\
&\le \frac{\vert x-y \vert (\vert x \vert + \vert y \vert )}{ \sqrt{x^2+1}+\sqrt{y^2+1}} \\
&\le \vert x-y \vert
\end{aligned}$$ hence choosing $\delta = \epsilon$ will work.
|
54,902,426 |
I'm trying to use a plotly example in Python 3, but getting a syntax error in this line:
```
return map(lambda (x, y, an): (x, y), cornersWithAngles)
```
I already read that using parentheses to unpack the arguments in a lambda is not allowed in Python 3, but I don't know how exactly to adjust my code to solve that problem.
Here is the complete code (error is on line 16):
```
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.tools import FigureFactory as FF
import scipy
def PolygonSort(corners):
n = len(corners)
cx = float(sum(x for x, y in corners)) / n
cy = float(sum(y for x, y in corners)) / n
cornersWithAngles = []
for x, y in corners:
an = (np.arctan2(y - cy, x - cx) + 2.0 * np.pi) % (2.0 * np.pi)
cornersWithAngles.append((x, y, an))
cornersWithAngles.sort(key = lambda tup: tup[2])
return map(lambda (x, y, an): (x, y), cornersWithAngles)
def PolygonArea(corners):
n = len(corners)
area = 0.0
for i in range(n):
j = (i + 1) % n
area += corners[i][0] * corners[j][1]
area -= corners[j][0] * corners[i][1]
area = abs(area) / 2.0
return area
corners = [(0, 0), (3, 0), (2, 10), (3, 4), (1, 5.5)]
corners_sorted = PolygonSort(corners)
area = PolygonArea(corners_sorted)
x = [corner[0] for corner in corners_sorted]
y = [corner[1] for corner in corners_sorted]
annotation = go.Annotation(
x=5.5,
y=8.0,
text='The area of the polygon is approximately %s' % (area),
showarrow=False
)
trace1 = go.Scatter(
x=x,
y=y,
mode='markers',
fill='tozeroy',
)
layout = go.Layout(
annotations=[annotation],
xaxis=dict(
range=[-1, 9]
),
yaxis=dict(
range=[-1, 12]
)
)
trace_data = [trace1]
fig = go.Figure(data=trace_data, layout=layout)
py.iplot(fig, filename='polygon-area')
```
|
2019/02/27
|
[
"https://Stackoverflow.com/questions/54902426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5890524/"
] |
This is an oversight in the SystemVerilog LRM. There's no syntax to specify a required set of parameters for an interface in a module header.
You might check your synthesis tool to see if they provide any way of specifying parameter overrides for the top-level synthesis instance.
|
195,688 |
I've written a code in a WP\_Query to converting a string (the\_content) to an array (choices). But it seems wrong! In fact, the choices array is empty after each loop. However str string is notnull. How can i handle this array to be nutnull?
Any help would be appreciated.
```
$first_query = new WP_Query( $args );
while ($first_query->have_posts()) : $first_query->the_post();
the_title(); //echo the title
the_content(); //echo the content
$str = the_content();
$choices = explode("-",$str);
var_dump($choices);
endwhile;
```
|
2015/07/27
|
[
"https://wordpress.stackexchange.com/questions/195688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71448/"
] |
You have a couple of issues here
* `the_content()` echos the content to screen. You should be using `get_the_content()` which returns the content. Just remember, `get_the_content()` is unfiltered, so if you need filtered content, use `apply_filters( 'the_content', get_the_content() )` which will return filtered content.
* Your `explode()` function is probably wrong as well. You are using a hyphen to explode your content into pieces of an array. If your content don't contain hyphens, your array will only have one key with the complete content as value. You would probably need to use white spaces (*`explode( ' ', get_the_content() );`*) or regular expressions or something similar to targt more than hypens or white spaces to explode the content. In one of my [previous posts for custom excerpts](https://wordpress.stackexchange.com/a/141136/31545) , I have used something similar to explode my content, here is something you can try and experiment with
```
preg_match_all('/(<[^>]+>|[^<>\s]+)\s*/u', get_the_content(), $tokens);
var_dump( $tokens );
```
|
108,171 |
How do I get the following to show up (on stackoverflow) with color syntax highlighting?
class Foo
{
internal Foo()
{
for (int i = 0; i < 42; ++i);
}
}
|
2011/10/02
|
[
"https://meta.stackexchange.com/questions/108171",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/170189/"
] |
See <https://stackoverflow.com/editing-help>.
Basically, for code, indent four spaces -- you can do this by pasting code then highlighting and hitting `Ctrl` + `K` or the ``{}`` button above the editing box.
As far as syntax highlighting, see [Changes to syntax highlighting](https://meta.stackexchange.com/questions/72082/changes-to-syntax-highlighting) and [Interface options for specifying language prettify](https://meta.stackexchange.com/questions/63800/interface-options-for-specifying-language-prettify/81970#81970).
The correct language will often be inferred by the tags on the question, but you can manually specify it with an HTML comment:
```
<!-- language: c# -->
public static bool IsAwesome { get { return true; } }
```
or
```
<!-- language: lang-js -->
setTimeout(function () { alert("JavaScript"); }, 1000);
```
before the code block.
|
12,521 |
Who knows two hundred eighty-five?
----------------------------------
?חמישה ושמונים ומאתים - מי יודע
-------------------------------
In the spirit of the song ["Echad - mi yodeya"](http://en.wikipedia.org/wiki/Echad_Mi_Yodea), please post interesting and significant Jewish facts about the number 285.
The best lazy gematria I can come up with for this one is weak, but that's no reason to be cowed.
Check out [mi-yodeya-series](/questions/tagged/mi-yodeya-series "show questions tagged 'mi-yodeya-series'") for the previous two hundred eighty-four entries in this ongoing series.
Please include sources for your information wherever possible, as with all other answers on this site.
|
2011/12/22
|
[
"https://judaism.stackexchange.com/questions/12521",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/2/"
] |
As Alex correctly noted here [Arba'a Ushmonim Umatayim - mi yodeya?](https://judaism.stackexchange.com/questions/12394/arbaa-ushmonim-umatayim-mi-yodeya/12404#12404) 285 is the most psukim read on a regular shabbat in sefard/chassidishe shuls:
* Mattot 112
* Ma'asei 132
* Maftir 3
* Haftora 27
* Mincha 11
* TOTAL 285
Note the longer haftorah than the previous answer.
|
40,849,509 |
Using the defaults of the train in caret package, I am trying to train a random forest model for the dataset xtr2 (dim(xtr2): 765 9408). The problem is that it unbelievably takes too long (more than one day for one training) to fit the function. As far as I know train in its default uses bootstrap sampling (25 times) and three random selection of mtry, so why it should take so long?
Please notice that I need to train the rf, three times in each run (because I need to make a mean of the results of different random forest models with the same data), and it takes about three days, and I need to run the code for 10 different samples, so it would take me 30 days to have the results.
My question is how I can make it faster?
1. Can changing the defaults of train make the operation time less? for example using CV for training?
2. Can parallel processing with caret package help? if yes, how it can be done?
3. Can tuneRF of random forest package make any changes to the time?
This is the code:
```
rffit=train(xtr2,ytr2,method="rf",ntree=500)
rf.mdl =randomForest(x=xtr2,y=as.factor(ytr2),ntree=500,
keep.forest=TRUE,importance=TRUE,oob.prox =FALSE ,
mtry = rffit$bestTune$mtry)
```
Thank you,
|
2016/11/28
|
[
"https://Stackoverflow.com/questions/40849509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6845158/"
] |
My thoughts on your questions:
1. Yes! But don't forget you also have control over the search grid `caret` uses for the tuning parameters; in this case, `mtry`. I'm not sure what the default search grid is for `mtry`, but try the following:
ctrl <- trainControl("cv", number = 5, verboseIter = TRUE)
set.seed(101) # for reproducibility
rffit <- train(xtr2, ytr2, method = "rf", trControl = ctrl, tuneLength = 5)
2. Yes! See the `caret` website: <http://topepo.github.io/caret/parallel-processing.html>
3. Yes and No! `tuneRF` simply uses the OOB error to find an optimal value of `mtry` (the only tuning parameter in `randomForest`). Using cross-validation tends to work better and produce a more honest estimate of model performance. `tuneRF` can take a long time but should be quicker than k-fold cross-validation.
Overall, the online manual for `caret` is quite good: <http://topepo.github.io/caret/index.html>.
Good luck!
|
16,605,578 |
this is my array:
```
orlist=""
orlist="T_TAB1 \n"
orlist=$orlist"T_TAB2 \n"
orlist=$orlist"T_TAB3 \n"
orlist=$orlist"T_TAB4 \n"
echo $orlist
arrIdx=0
OLD_IFS=$IFS;
IFS="\n"
for IndixList in ${orlist[@]};
do
echo $IndxList
MYDIR[${arraryIndix}]=$IndixList
(( arraryIndix = $arraryIndix+ 1 ))
done
IFS=$OLD_IFS
```
i have to do a SELECT in a oracle db inside a for loop so i have to read the $orlist tab by tab. I've tried this but doesn't work it takes the whole array not tab by tab:
```
for arraryIndix in ${orlist[@]};
do
echo "SET HEADING OFF" >> ${FILEOR_SQL}
echo "SET TERMOUT OFF" >> ${FILEOR_SQL}
echo "SET PAGESIZE 0" >> ${FILEOR_SQL}
echo "SET LINESIZE 1000" >> ${FILEOR_SQL}
echo "SET FEEDBACK OFF" >> ${FILEOR_SQL}
echo "SET TRIMSPOOL ON" >> ${FILEOR_SQL}
echo "SPOOL ${FILE_DAT}" >> ${FILEOR_SQL}
echo "SELECT * " >> ${FILEOR_SQL}
echo "FROM ${orlist[@]}" >> ${FILEOR_SQL}
echo "WHERE REP_ARG = 2; " >> ${FILEOR_SQL}
echo "SPOOL OFF" >> ${FILEOR_SQL}
echo "COMMIT;" >> ${FILEOR_SQL}
echo "SET HEADING ON" >> ${FILEOR_SQL}
echo "SET TERMOUT ON" >> ${FILEOR_SQL}
echo "SET PAGESIZE 14" >> ${FILEOR_SQL}
echo "SET FEEDBACK ON" >> ${FILEOR_SQL}
echo "SET TRIMSPOOL OFF" >> ${FILEOR_SQL}
echo "EXIT;" >> ${FILEOR_SQL}
sqlplus -S -L ${Connection} @${FILEOR_SQL} #connection is a var for connect with `sqlplus`
done
```
Any suggestions? Thanks in advance
|
2013/05/17
|
[
"https://Stackoverflow.com/questions/16605578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1540456/"
] |
Well your problem came because if you write `\n`, it's not necessarily treated as a new line, somebody have to translate the sequence of `\` followed by `n` as a newline. also same in `IFS="\n"` IFS needs to be set to something which evaluates to a newline, not a combination of `\` and `n`. Also orlist is a variable, you have not used it as an array, and at the for loop, it is not going to be treated as an array.
I did some changes and it seemed to work fine
```
#!/usr/local/bin/ksh
orlist=""
orlist="T_TAB1 \n"
orlist=$orlist"T_TAB2 \n"
orlist=$orlist"T_TAB3 \n"
orlist=$orlist"T_TAB4 \n"
echo $orlist
arrIdx=0
OLD_IFS=$IFS;
IFS=$'\n'
#IFS=""
arraryIndix=0
for IndxList in `echo -e $orlist`
do
echo "Hello $IndxList "
MYDIR[${arraryIndix}]=$IndxList
((arraryIndix++))
done
IFS=$OLD_IFS
echo "Finally ${MYDIR[@]}"
```
Output
```
T_TAB1 \nT_TAB2 \nT_TAB3 \nT_TAB4 \n
Hello T_TAB1
Hello T_TAB2
Hello T_TAB3
Hello T_TAB4
Finally T_TAB1 T_TAB2 T_TAB3 T_TAB4
$ ksh --version
version sh (AT&T Research) 93t+ 2010-02-02
```
Update following comments
```
FILEOR_SQL=""
func() {
echo "SET HEADING OFF" >> ${FILEOR_SQL}
echo "SET TERMOUT OFF" >> ${FILEOR_SQL}
echo "SET PAGESIZE 0" >> ${FILEOR_SQL}
echo "SET LINESIZE 1000" >> ${FILEOR_SQL}
echo "SET FEEDBACK OFF" >> ${FILEOR_SQL}
echo "SET TRIMSPOOL ON" >> ${FILEOR_SQL}
echo "SPOOL random " >> ${FILEOR_SQL}
echo "SELECT * " >> ${FILEOR_SQL}
echo "FROM $1" >> ${FILEOR_SQL}
echo "WHERE REP_ARG = 2; " >> ${FILEOR_SQL}
echo "SPOOL OFF" >> ${FILEOR_SQL}
echo "COMMIT;" >> ${FILEOR_SQL}
echo "SET HEADING ON" >> ${FILEOR_SQL}
echo "SET TERMOUT ON" >> ${FILEOR_SQL}
echo "SET PAGESIZE 14" >> ${FILEOR_SQL}
echo "SET FEEDBACK ON" >> ${FILEOR_SQL}
echo "SET TRIMSPOOL OFF" >> ${FILEOR_SQL}
echo "EXIT;"
}
orlist=""
orlist="T_TAB1 \n"
orlist=$orlist"T_TAB2 \n"
orlist=$orlist"T_TAB3 \n"
orlist=$orlist"T_TAB4 \n"
echo $orlist
OLD_IFS=$IFS;
IFS=$'\n'
arraryIndix=0;
for IndxList in `echo -e $orlist`
do
FILEOR_SQL="testfilesql"$arraryIndix
func $IndxList
((arraryIndix++))
done
IFS=$OLD_IFS
```
|
3,989,152 |
I want to calculate
$$\sum\_{k=0}^\infty\binom{k+3}k(0.2)^k$$
to get the exact value of it. I have excel and other tools to help me so it is fine if it is computationally expensive. Is there a clear and repeatable way to solve this infinite series? Thank you. This is my first post and be sure to give me some suggestions as well.
|
2021/01/17
|
[
"https://math.stackexchange.com/questions/3989152",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/875026/"
] |
It’s a general fact that
$$\sum\_{k\ge 0}\binom{k+n}nx^k=\frac1{(1-x)^{n+1}}\;.$$
You can prove this by induction on $n$, starting with the geometric series
$$\frac1{1-x}=\sum\_{k\ge 0}x^k$$
and differentiating repeatedly with respect to $x$. You want the case $n=3$:
$$\sum\_{k\ge 0}\binom{k+3}kx^k=\sum\_{k\ge 0}\binom{k+3}3x^k=\frac1{(1-x)^4}\,.$$
Now just substitute $x=0.2$.
|
1,576,277 |
I hosted one `DotNetNUke Application` to my production server, and locally it works perfectly. But, when browsing it redirects to the error page.
How do I set the `default.aspx` as my application default page? I am getting the error as below:
```
DotNetNuke Error
--------------------------------------------------------------------------------
Windows Vista
Return to Site
```
Can anyone can help me, please? Will be appreciated.
**UPDATE:**
Hi, I changed the Path in the PortalAlias table to the server url and `default.aspx` as the starting page, but it displays the `error.aspx` as default page.
Please help me resolve this problem..
|
2009/10/16
|
[
"https://Stackoverflow.com/questions/1576277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/191017/"
] |
That's very easy - build a folder tree based on GUID values parts.
For example, make 256 folders each named after the first byte and only store there files that have a GUID starting with this byte. If that's still too many files in one folder - do the same in each folder for the second byte of the GUID. Add more levels if needed. Search for a file will be very fast.
By selecting the number of bytes you use for each level you can effectively choose the tree structure for your scenario.
|
61,174,221 |
I need to parse date value to specific format without using format field in dateFromString operator.
[Mongo Playground](https://mongoplayground.net/p/U9thsJCE88V)
Current situation :
in Mongodb 4.0 if I format dateString using below it code it give me mentioned output.
```
parsedDate: {
$dateFromString: {
dateString: "$dateS",
format: format: "%Y-%m-%dT%H"
}
}
Output: "parsedDate": ISODate("2020-01-16T08:00:00Z")
```
I cannot use format field in 3.6 since its not supported.
How do I convert my date to
`format: "%Y-%m-%dT%H"` in 3.6?
|
2020/04/12
|
[
"https://Stackoverflow.com/questions/61174221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10516241/"
] |
If I get the requirement right, Try the following query which uses: [`$dateFromParts`](https://docs.mongodb.com/manual/reference/operator/aggregation/dateFromParts/)
**Input:**
```
[
{
"date": ISODate("2020-01-16T08:54:17.604Z")
}
]
```
**Query:**
```
db.collection.aggregate([
{
$project: {
outputDate: {
$dateFromParts: {
"year": {
$year: "$date"
},
"month": {
$month: "$date"
},
"day": {
$dayOfMonth: "$date"
},
"hour": {
$hour: "$date"
}
}
}
}
}
]);
```
**O/P:**
```
[
{
"_id": ObjectId("5a934e000102030405000000"),
"outputDate": ISODate("2020-01-16T08:00:00Z")
}
]
```
[Playground Test Link](https://mongoplayground.net/p/BiAeIbEBZCO)
|
37,167,788 |
I have a TableViewController in a TabBar.
When I select one cell of my tableView, I want start a new controller with pushViewController(MyNewController).
This is my code :
**In my TableView :**
```
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let myController = (storyboard.instantiateViewControllerWithIdentifier("MyViewController") as? MyViewController)!
myController.parameter = self.tableau[indexPath.row]
UINavigationController().pushViewController(myController, animated: true)
}
```
**In my TabBar :**
```
func viewDidLoad() {
super.viewDidLoad()
var controllerArray: [UIViewController] = []
let controller: UIViewController = ClubPreviewListViewController()
controller.title = "TEST"
controllerArray.append(controller)
self.view.addSubview(pageMenu!.view)
}
```
*(I use CAPSPageMenu for customize my TabBar, but it's not the problem, I have the same problem without)*
**In my controller :**
```
deinit {
print ("TEST")
}
```
When I select a cell, the log write "TEST" everytime I select but don't change the view.
I think it's my navigationController the problem, but I don't know how to fix it.
Before I implement the TabBar, I use my TableView alone, and the push did works.
Sorry for my english ! Thanks for your help.
**EDIT:**
I change my pushViewController :
```
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let myController = (storyboard.instantiateViewControllerWithIdentifier("MyViewController") as? MyViewController)!
myController.parameter = self.tableau[indexPath.row]
//UINavigationController().pushViewController(myController, animated: true)
self.navigationController?.pushViewController(myController, animated: true)
}
```
Same reaction.
My NavigationController isn't directly link with my TabBar. I need to create an other one ? I don't really understand how NavigationController works !
[This is my configuration](http://i.stack.imgur.com/OtUJL.jpg)
**EDIT2:**
**If I use the navigationController of my TabBar and not of my TableView, the view change !**
```
self.saveTabBarNavigationController.pushViewController(myController, animated: true)
```
|
2016/05/11
|
[
"https://Stackoverflow.com/questions/37167788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6175849/"
] |
First, the correct way to write your query is:
```
SELECT CustomerID, SUM(SubTotal)
FROM Sales.SalesOrderHeader
GROUP BY CustomerID;
```
Using `SELECT DISTINCT` with window functions is clever. But, it overcomplicates the query, can have poorer performance, and is confusing to anyone reading it.
To get the information by year (for each customer), just add that to the `SELECT` and `GROUP BY`:
```
SELECT CustomerID, YEAR(OrderDate) as yyyy, SUM(SubTotal)
FROM Sales.SalesOrderHeader
GROUP BY CustomerID, YEAR(OrderDate)
ORDER BY CustomerId, yyyy;
```
If you actually want to get separate rows with subtotals, then study up on `GROUPING SETS` and `ROLLUP`. These are options to the `GROUP BY`.
|
1,077 |
Do publishers give you an advance as some sort of earnest money for your manuscript? If your work doesn't sell very well do you have to give the advance back to them?
Do they ever just buy your work and you get some money plus royalties?
thanks.
|
2011/01/11
|
[
"https://writers.stackexchange.com/questions/1077",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/289/"
] |
**No.** That's the meaning of the word "advance": these are monies that the publisher is willing to give you up-front with the belief that your work will sell enough copies to cover the advance.
Keep in mind that the advance is not "free money": it's a portion of the royalties for your book that you receive ahead of time. You won't receive any further royalties for your book until it's sold enough copies that the royalties you would have earned cover the advance. If your book fails to "earn out" the advance (sell enough copies to cover the advance), you can expect to have a hard time getting another contract with that publisher, and possibly with other publishers as well.
|
49,548,107 |
how to add progress view in moya swift ?,
is this correct. is this a correct way to use progressblock.
```
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
if response.completed{
self.view.hideLoadingHUD()
}else{
self.view.showLoadingHUD()
}
}) { (result) in
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
self.view.hideLoadingHUD()
}
}
```
|
2018/03/29
|
[
"https://Stackoverflow.com/questions/49548107",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5852117/"
] |
just modify the `hideLoadingHud` in inside the success or failure block. bz that part result handler
```
let instance = MoyaProvider<ServiceType>()
self.view.showLoadingHUD()
instance.request(.GetRouteDetail, callbackQueue: DispatchQueue.main, progress: { (response) in
}) { (result) in
self.view.hideLoadingHUD()
switch result{
case .success(let response):
print(response)
case .failure(let error):
print(error)
}
}
```
|
73,459,978 |
I'm trying to do a database migration using `GCP Database Migration Service`
My source database is of `Postgres` type (hosted on `Heroku`), but the name of the database is not `postgres` but rather something like `d12bdsdjs` ...
My question is ... is there a way for me to use the `GCP Database Migration Service` to somehow migrate this database ? There seems to be no field on the form where I can provide this value in `GCP console` ... maybe I can somehow set it if I create my `migration job` using the `GCP SDK` or something ?
Please advise
|
2022/08/23
|
[
"https://Stackoverflow.com/questions/73459978",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2599899/"
] |
Use a `for` loop to generate a range of valid indices for each array:
```
for($i = 0; $i -lt $array1.Count; $i++){
Write-Host "Server named '$($array1[$i])' has SID '$($array2[$i])'"
}
```
But a better solution would be to create a single array of *objects* that have both pieces of information stored in named properties:
```
$array = @'
Name,ID
Server1,SID1
Server2,SID2
'@ |ConvertFrom-Csv
```
Now you can use a `foreach` loop without having to worry about the index:
```
foreach($computer in $array){
Write-Host "Server named '$($computer.Name)' has SID '$($computer.ID)'"
}
```
|
4,349 |
Google Translate is notoriously unreliable for Latin.
However, the translations do make some amount of sense.
**Is there some kind of translation task involving Latin that Google Translate is relatively reliable for?**
I tried it for simple phrases to and from English.
Here are the result of my little test1:
1. Puer canem amat. → The boy dog loves. (The boy loves the dog.)
2. Canem puer amat. → The boy loves the dog. (Correct!)
3. Puerum canis amat. → The dog loves the child. (Correct!)
4. Canis puerum amat. → The dog loves the child. (Correct!)
5. Puer canis amat. → The boy dog loves. (The boy of the dog loves.)
6. Canis puer amat. → The dog loves the child. (The boy of the dog loves.)
7. Canis pueri amat. → The dog loves children. (The dog of the boy loves.)
8. Pueri canis amat. → The dog loves children. (The dog of the boy loves.)
9. The boy loves the dog. → Puer canem diligit. (Correct!)
10. The dog loves the boy. → Canis puerum amat. (Correct!)
11. The boy of the dog loves. → Puer canem amat. (Puer canis amat.)
12. The dog of the boy loves. → Canis pueri amat. (Correct!)
13. The boy and the dog walk together because it does not rain. → Puer et canis ambulare quia non pluet simul. (Puer et canis una ambulant quia non pluit.)
These might not be the perfect example sentences, but they demonstrate some basic syntax.
(Whether or not the content makes sense should not affect translation in simple cases like this, but it might be that Google Translate is not wired that way.)
It seems that translation from Latin to English is very difficult even with simple structures.
English to Latin is much better, but it fails for the slightly more complicated sentence.
Google does offer alternatives, and some of them greatly improve the last sentence, but someone with no knowledge in Latin will not be able to pick the right ones.
The tool might work better for translating individual words2 or with some language other than English.
And perhaps it does translate simple SVO clauses consistently well from English to Latin — I did not do an extensive test, and I have no prior experience.
Does someone have more experience with Google Translate?
It would be good to know if there is something it is useful and reliable for, even if the scope is very limited.
---
1
Format:
Original → Google translation (better translation if Google fails)
2
For translating individual words it's better to look at [any online Latin dictionary](https://latin.stackexchange.com/q/867/79).
But my question is not whether there are better tools than Google Translate.
The question whether Google Translate can be trusted for anything at all regarding Latin.
|
2017/05/11
|
[
"https://latin.stackexchange.com/questions/4349",
"https://latin.stackexchange.com",
"https://latin.stackexchange.com/users/79/"
] |
A classmate of mine who got his Ph.D. in natural-language processing and now works at Google told me the following. It might be out of date and I might be remembering it wrong. But I just did a little, er, googling, and this seems to be passably well corroborated by other sources.
How it works
------------
Google Translate is completely statistical. It has no model of grammar, syntax, or meaning. It works by correlating sequences of up to five consecutive words found in texts from both languages.
Here's the conceit. Ignore all the complexity, structure, and meaning of language and pretend that people speak just by randomly choosing one word after another. The only question now is how to calculate the probabilities. A simple way is to say that the probability of each word is determined by the previous word spoken. For example, if the last word you said was "two", there is a certain probability that your next word will be "or". If you just said "or", there is a certain probability that your next word will be "butane". You could calculate these word-to-next-word probabilities from their frequencies in real text. If you [generate new text](https://www.jwz.org/dadadodo/dadadodo.cgi) according to these probabilities, you'll get random but just slightly coherent gibberish: TWO OR BUTANE GAS AND OF THE SAME. That's called a [Markov model](https://en.wikipedia.org/wiki/Markov_model). If you use a window of more words, say five, the resulting gibberish will look more likely to have been written by a schizophrenic than by an aphasic. A variation called a [hidden Markov model](https://en.wikipedia.org/wiki/Hidden_Markov_model) introduces "states", where each state has its own set of probabilities for "emitting" words as well as a set of "transition" probabilities for what will be the next state. This can simulate a little more of the influence of context on each word choice.
Google Translate's algorithm is proprietary, and I think it's a little more sophisticated than hidden Markov models, but the principle is the same. They let computers run on lots of text in each language, assigning [probabilities to word sequences](https://en.wikipedia.org/wiki/Language_model) according to the principle "Assuming this text was generated by a random gibberish-generator, what probabilities [maximize the chance](https://en.wikipedia.org/wiki/Maximum_likelihood_estimation) that this exact text would have been generated?" Manually translated texts provide data to line up word sequences in one language with word sequences in another. Translation, then, is finding the highest-probability sequence from one language's gibberish-generator that corresponds to whatever makes the other language's gibberish-generator produce the input text.
What it's reliable for
======================
Consequently, you won't learn much about what Google Translate is reliable for by trying out different grammatical structures. If you're lucky, all you'll get from that is an [ELIZA effect](https://en.wikipedia.org/wiki/ELIZA_effect). What Google Translate is most reliable for is translating documents produced by the United Nations between the languages in use there. This is because UN documents have provided a disproportionately large share of the manually translated texts from which Google Translate draws its five-word sequences.
Witness what happens when I type this in:
>
> À l'exception de ce qui peut être convenu dans les accords particuliers de tutelle conclus conformément aux Articles 77, 79 et 81 et plaçant chaque territoire sous le régime de tutelle, et jusqu'à ce que ces accords aient été conclus, aucune disposition du présent Chapitre ne sera interprétée comme modifiant directement ou indirectement en aucune manière les droits quelconques d'aucun État ou d'aucun peuple ou les dispositions d'actes internationaux en vigueur auxquels des Membres de l'Organisation peuvent être parties.
>
>
>
It gives me:
>
> Except as may be agreed upon in the special guardianship agreements concluded in accordance with Articles 77, 79 and 81 and placing each territory under the trusteeship system, and until such agreements have been concluded, This Chapter shall not be construed as directly or indirectly modifying in any way the rights of any State or any people or the provisions of international instruments in force to which Members of the Organization may be parties.
>
>
>
Perfect! ([Almost](http://www.un.org/en/sections/un-charter/chapter-xii/index.html).)
This is why its Latin translations tend to be so poor: it has a very thin corpus of human-made translations of Latin on which to base its probability estimates—and, of course, it's using an approach that's based on probabilities of word sequences, disregarding grammar and meaning.
So, until the United Nations starts doing its business in Latin, Google Translate is not going to do a very good job. And even then, don't expect much unless you're translating text pasted from UN documents.
The five-word window
====================
Here's an illustration of the five-word window. I enter:
>
> Pants, as you expected, were worn.
>
>
> Pants were worn.
>
>
> Pants, as you expected, are worn.
>
>
>
The Latin translations (with my manual translations back to English):
>
> [Anhelat](https://en.wiktionary.org/wiki/anhelo#Latin) quemadmodum speravimus confecta. *(He is panting just as we hoped accomplished.)*
>
>
> [Braccas](https://en.wiktionary.org/wiki/braca#Latin) sunt attriti. *(The trousers have been worn away [like "attrition"].)*
>
>
> Anhelat, ut spe [teris](https://en.wiktionary.org/wiki/tero#Latin). *(He is panting, just as, by hope, you are wearing [something] out.)*
>
>
>
Notice that the first and third sentences border on ungrammatical nonsense. The second sentence makes sense but it's ungrammatical; it should be *Braccae sunt attritae.* There aren't any five-word sequences in Google Translate's English database that line up well with "pants as you expected were/are," so it's flailing. Notice that in the third sentence, by the time it got to "worn", it had forgotten which sense of "pants" it chose at the start of the sentence. Or rather, it didn't forget, because it never tracked it. It only tracked five-word sequences.
So, whether the sentence makes sense sort of affects the translation, but it's worse than that. What matters is exact, word-for-word matching with texts in the database.
Entering Latin into Google Translate (with words changed from the first sentence shown in bold):
>
> Abraham vero aliam duxit uxorem nomine Cetthuram.
>
>
> **Quintilianus** vero aliam duxit uxorem nomine Cetthuram.
>
>
> Abraham vero aliam duxit uxorem nomine **Iuliam**.
>
>
> Abraham vero **canem** duxit uxorem nomine **Fido**.
>
>
>
English output:
>
> And Abraham took another wife, and her name was Keturah.
>
>
> Quintilian, now the wife of another wife, and her name was Keturah.
>
>
> And Abraham took another wife, and the name of his wife, a daughter named Julia.
>
>
> And Abraham took a wife, and brought him to a dog by the name of Fido.
>
>
>
The Vulgate and the [ASV translation](https://www.biblegateway.com/passage/?search=Genesis%2025&version=ASV) (or similar) would appear to be among Google Translate's source texts. Notice what happens when the input is off by as little as one word.
---
The above explains just enough so that a layperson can understand what Google Translate is good at, what it's bad at, and why—and so they won't be misled by the results of experimenting with different grammatical structures. If you're interested in more rigorous and thorough information about the full complexities of this approach, google for "[statistical machine translation](https://www.google.com/search?q=statistical+machine+translation)". Some further info is [here](https://en.wikipedia.org/wiki/Google_Translate#Method_of_translation), including Google's rollout, now in progress, of an entirely new translation algorithm (which hasn't reached Latin yet).
|
24,275 |
I have a mac and raspberry pi connected via ethernet cable which are communicated fine. Internet sharing is turned on but my raspberry pi can't connect to the internet.
My mac is connected to the internet via Wifi with the following settings:

Internet is working on my mac and have connected an ethernet cable between my mac and my raspberry pi. I turned on internet sharing on my mac and gave the ethernet the following settings:

I gave my raspberry pi a static IP address in the same subnet (192.168.1.20) by editing the network/interaces file and set the gateway the same as my Macs ip address, which looks like this:
```
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.1.20
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.90
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
```
I can ping from my RPi to my mac (ping 192.168.1.90) and can ssh into my RPi from my mac (set up previously; ssh [email protected]).
**The problem**: I can't seem to connect to the internet. Running `sudo apt-get update` shows errors in the lines of "temporary failure resolving archive.raspberrypi.org'. Any help or advice is appreciated.
**Update 1:** The output of "route" is (after waiting many seconds):
```
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.1.254 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
```
|
2014/11/04
|
[
"https://raspberrypi.stackexchange.com/questions/24275",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/22249/"
] |
Your route is incorrect:
default 192.168.1.254
If your gateway (in this case the Mac) is at .1.90, your gateway has to be at .1.90
If you have just set the fixed IP in network/interfaces, then you may need to restart your networking stack (/etc/init.d/network restart).
Also check your current network configuration with "ifconfig eth0", you may see the problem right there. To fix your route do this: "route add default gw 192.168.1.90"
|
1,612,989 |
The number of maps $f$ from the set $\{1,2,3\}$ into the set $\{1,2,3,4,5\}$ such that $f(i)\le f(j)$, whenever $i<j$.
|
2016/01/15
|
[
"https://math.stackexchange.com/questions/1612989",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/305289/"
] |
You have to choose the $3$ function values $f(1),f(2),f(3)$ from $5$ possibilities, with repetition allowed. The order of the $3$ chosen numbers is not important, because once you have chosen them, the condition $f(i)\le f(j)$ tells you which is $f(1)$, which is $f(2)$ and which is $f(3)$.
The number of choices of $3$ elements from $5$, with order not important and repetition allowed, is
$$C(5+3-1,3)=C(7,3)=35\ .$$
For the ideas behind this see [here](https://en.wikipedia.org/wiki/Stars_and_bars_%28combinatorics%29).
|
83,380 |
I have found lots of information online about European pilots owning and flying N-reg aircraft using trusts set up in the US. I live in Europe, but I'm a US citizen, so must I also set up a trust because I don't live in the US? I cannot seem to find a definitive answer on this with references to supporting regulation.
|
2021/01/08
|
[
"https://aviation.stackexchange.com/questions/83380",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/52979/"
] |
As a US citizen you can own an N-reg aircraft directly, regardless of where you live. The regulations on aircraft registration are in [14 CFR Part 47](https://www.ecfr.gov/cgi-bin/text-idx?node=pt14.1.47#se14.1.47_17). They say *who* can register an N-reg aircraft, but they don't say anything about *where* that person must be. 47.3(a)(1) simply says:
>
> **§47.3 Registration required.**
>
>
> (a) An aircraft may be registered under 49 U.S.C. 44103 only when the
> aircraft is not registered under the laws of a foreign country and is—
>
>
> (1) Owned by a citizen of the United States;
>
>
>
The regulations are summarized in a more readable way on [this FAA site](https://www.faa.gov/licenses_certificates/aircraft_certification/aircraft_registry/register_aircraft/). A trust allows a non-US citizen (or non-resident alien) to own an N-reg aircraft provided they have no more than 25% of the voting rights in the trust, per 47.7(c)(2)(iii).
|
41,673,206 |
There are around 3 hundred components rendered inside the wrapper component and its taking to much of time to render. But I need thousand of components to get rendered inside the wrapper container. How can I achieve this without any performance issues while rendering the components
[Image shows the rendering time taken by 300 components which is too much](https://i.stack.imgur.com/WhoMQ.png)
|
2017/01/16
|
[
"https://Stackoverflow.com/questions/41673206",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2282123/"
] |
You could sort the strings for the same order and join it.
```js
function getUnique(a, b) {
return [a.toString(), b.toString()].sort().join('');
}
console.log(getUnique("apple", "ball"));
console.log(getUnique("ball", "apple"));
```
For numbers, i suggest to use a separator and numerical order.
```js
function getUnique(a, b) {
return [a, b].sort(function (a, b) { return a - b; }).join('|');
}
console.log(getUnique(1, 111)); // 1|111
console.log(getUnique(111, 1)); // 1|111
console.log(getUnique(11, 11)); // 11|11
```
|
10,432,297 |
I'm working with a simple ASMX web service that gives the users the ability to add comments. For each comment that gets added I add a timestamp to the row. The issue I'm running into is that If I add two comments 1 second apart they will both have the same timestamp. Instead of using `DateTime.Now` in my code I use a static class so I can easily write unit tests.
Here is my `Time` class:
```
public class Time : IDisposable
{
public static DateTime Now;
static Time()
{
ResetToDefault();
}
public static IDisposable Freeze(DateTime dateTimeToFreeze)
{
Now = dateTimeToFreeze;
return new Time();
}
void IDisposable.Dispose()
{
ResetToDefault();
}
private static void ResetToDefault()
{
Now = DateTime.Now;
}
}
```
I'm guessing this class is the culprit because if I replace all instances of `Time.Now` with `DateTime.Now` everything works as expected.
What is causing my `Time` class to freeze and not always refresh when requesting the current time?
|
2012/05/03
|
[
"https://Stackoverflow.com/questions/10432297",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1135049/"
] |
If you right click on the file, you should be able to see the permissions and attributes of the file.
|
6,095 |
The stock media player on my phone has an annoying behaviour. Whenever I unplug the headphones, if the media player is paused or not running, it immediately starts running and playing my playlist. This is very annoying because everyone in the room is forced to listen to my songs until I manage to tap (twice) the Music Widget.
Has this been happening to anyone else? And what did you do to fix it?
*Note: I'm not sure if it's Android's stock player or if it's Motorola's stock player, it's just called "Music".
Note 2: From the comments, it seems this is Android's stock music app.*
**Motorola-Milestone, firmware 2.1-update1.**
|
2011/02/17
|
[
"https://android.stackexchange.com/questions/6095",
"https://android.stackexchange.com",
"https://android.stackexchange.com/users/1926/"
] |
This is a known bug in Android (even in certain Eclair systems).
There's a widget called [Headset Blocker](https://market.android.com/details?id=com.idunnolol.headsetblocker) that when added to any of your homescreens and activated prevents the music player from playing whenever you unplug your headest. Freeware and it works. See if it helps.
|
82,650 |
I have an EOS 750D and [simple reversing ring](http://photovideo.com.au/images/CANREV52270.jpg). There is no problem with capturing photos using the viewfinder. I have to use M mode and set everything manually.
But when I use live view (or try to capture video) I can only see a black screen. When in video mode, there is a message: "Ensure the lens is mounted..." Then I can capture video, but it is only a black screen with sound.
Is there a simple way to fool the mount that there is lens attached, or do I have to buy a [more sophisticated set](http://www.phototools.co.nz/image/cache/data/reverse_3-10982-675x502.jpg)? What pins of the EF mount shall be connected?
|
2016/09/08
|
[
"https://photo.stackexchange.com/questions/82650",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/39108/"
] |
Basic cameras use "exposure simulation" in Liveview to help the shooter visualize what the final exposure will be. This creates problems when using manual lenses or any lens that does not communicate with the camera.
More advanced cameras have the option to turn off "exposure simulation" but basic cameras like the 750D or SL1 do not have this option and you must live with the dark screen.
One way to avoid this problem is to use a Canon compatible ETTL flash in the hotshoe as any Canon dedicated flash will automatically disable Exp Sim for flash photography.
One other option is to install Magic Lantern software on your camea as it includes an option to disable Exp Sim.
|
53,868,770 |
I simply want to use a modified example of Nested flex on the [PrimeNG Flex](https://www.primefaces.org/primeng/#/flexgrid) by using the code below:
```
<h3>Nested</h3>
<div class="p-grid nested-grid">
<div class="p-col-8">
<div class="p-grid">
<div class="p-col-6">
<div class="box">6</div>
</div>
<div class="p-col-6">
<div class="box">6</div>
</div>
<div class="p-col-12">
<div class="box">12</div>
</div>
</div>
</div>
<div class="p-col-4">
<div class="box box-stretched">4</div>
</div>
</div>
```
However, the col divs act as the total size is not 12, instead 11 and if the total p-col number is 12 or more, the elements wrap to the next row that I do not want. On the other hand, I have a look at all of the main divs and body paddings and margins but there is no problem with that. I think the padding of the p-cols does not causing this problem and their paddings are also 0-5 px range. Any idea how to fix this problem?
|
2018/12/20
|
[
"https://Stackoverflow.com/questions/53868770",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/836018/"
] |
the example in the site shows kind of like this
i don't think you need 'p-grid nested-grid'
```
<div class="p-grid">
<div class="p-col-8">
<div class="p-grid">
<div class="p-col-6">
6
</div>
<div class="p-col-6">
6
</div>
<div class="p-col-12">
12
</div>
</div>
</div>
<div class="p-col-4">
4
</div>
```
|
52,616,343 |
I'm wondering if it's better practice to use Bundle or make another class entirely to save data?
During a fragment change I can set it up so that onSaveInstanceState() saves information. Alternatively, I could store that information as a static variable in another class, then create a getter function in that class and use it to "restore" the variables state under onCreateView().
I would much prefer to use another class as I feel like I have more control over the management of my data, but I'm not sure if this would cause any issues or if this is bad practice as I haven't seen any mention of people doing it this way.
|
2018/10/02
|
[
"https://Stackoverflow.com/questions/52616343",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10318432/"
] |
For the various steps, I can give you the following hints.
### File names
For obtaining mp3 file names the [glob](https://docs.python.org/3/library/glob.html) module is your friend: `glob.iglob('*.mp3', recursive=True)`.
### Dealing with mp3
For dealing with mp3 files you can use practically any command line utility that serves your needs. A few examples:
* [avprobe](https://askubuntu.com/a/249843/445311)
* [exiftool, ffmpeg, mplayer](https://askubuntu.com/a/303461/445311)
* [mediainfo](https://superuser.com/a/595205/742396)
You can run these tools from within python via the [subprocess](https://docs.python.org/3/library/subprocess.html) module. For example:
```
subprocess.check_output(['avprobe', 'path/to/file'])
```
Then you can parse the output as appropriate; how to detect if the file is broken needs to be explored though.
### Dive into mp3
If you're feeling adventurous then you can also scan the mp3 files directly. [Wikipedia](https://en.wikipedia.org/wiki/MP3#File_structure) gives a hint about the file structure. So in order to get the bit rate the following should do:
```
with open('path/to/file', 'rb') as fp:
fp.read(2) # Skip the first two bytes.
bit_rate = fp.read(1) & 0xf0
```
|
13,823 |
I have installed MySQL via [homebrew](https://brew.sh/): `brew install mysql`. I'd like to get the MySQL preference pane hooked up to my installation of MySQL through homebrew. How can I achieve this?
|
2011/05/09
|
[
"https://apple.stackexchange.com/questions/13823",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/6162/"
] |
See [my answer to your question at superuser.com](https://superuser.com/a/413814/121764).
|
51,643,920 |
Given these two classes:
```
public class Abc
{
public static void Method(string propertyName) { }
}
public class Def
{
public int Prop { get; }
public void Method2() { Abc.Method("Prop"); }
}
```
As is, Roslyn rule CA1507 (use nameof) will be triggered for `Method2`. I don't want that, because that string is used for long-term custom serialization and can never change (if we decide to change the name of `Prop` we won't be changing that string). I don't want to disable the rule on an assembly level or even class level. There are also hundreds of callers like `Def` so I want something that doesn't require me to do anything to the callers.
Is there some kind of [ExcludeParameterFromCodeAnalysis] I can put on the `propertyName` param to be excluded from all or some code analysis?
Here's the concept I hope exists, or some variant on it:
```
public class Abc
{
public static void Method([SuppressMessageForCallers("CA1507")]string propertyName) { }
}
public class Def
{
public int Prop { get; }
public void Method2() { Abc.Method("Prop"); }
}
```
|
2018/08/02
|
[
"https://Stackoverflow.com/questions/51643920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2234468/"
] |
I believe that this rule only [triggers](https://github.com/dotnet/roslyn-analyzers/blob/ea231a69f9891764f10c5ed214409627da010be7/src/Microsoft.CodeQuality.Analyzers/Core/Maintainability/UseNameofInPlaceOfString.cs#L67)1 when the name of your parameter is `paramName` or `propertyName`2. So let's change the parameter:
```
public class Abc
{
public static void Method(string propertySerializationName) { }
}
```
---
1Even if you don't know or can guess at which specific analyzer implements a warning, it looks like searching the [roslyn-analyzers](https://github.com/dotnet/roslyn-analyzers) repository for the specific code (`CA1507`) should help you find them without too many false positives.
2Weirdly, it wouldn't even appear to trigger on a parameter called `parameterName`.
|
6,229,913 |
I am struggling to get my interior background image to display in IE, works fine in FF and chrome. Cant figure it out.
```
<div id="banner">
<div id="banner-image"><cms:CMSEditableImage ID="BannerPhoto" runat="server" ImageHeight="284" ImageWidth="892" /></div>
</div>
<div id="interior-content-block">
<div id="repeating-content">
<div id="interior-content">
<cc1:CMSEditableRegion ID="txtMain" runat="server" DialogHeight="312" RegionType="HtmlEditor" RegionTitle="Main Content" />
</div>
</div>
<div id="side-navigation">
<cms:CMSListMenu ID="CMSListMenuSub" runat="server" HighlightAllItemsInPath="true" ClassNames="CMS.MenuItem" RenderCssClasses="true" CSSPrefix="side1;side2" DisplayHighlightedItemAsLink="true" Path="/{0}/%"/>
</div>
<div style="clear: both;"></div>
```
```
#repeating-content-landing
{
float: left;
margin: 0px 0px 0px 40px;
background: #959398 url(../site-images/landing-page/final-landing-page-design.jpg);
width: 820px;
}
#interior-content
{
padding: 32px 32px 32px 32px;
background: #999999 url(../site-images/interior-content.gif)repeat-y;
min-height: 312px;
}
#interior-content-landing
{
padding: 0px 0px 0px 0px;
background: #999999 url(../site-images/landing-page/final-landing-page-design.jpg) no-repeat;
min-height: 700px;
}
<style />
```
|
2011/06/03
|
[
"https://Stackoverflow.com/questions/6229913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/783021/"
] |
You can change how the keyboard behaves when it appears over the Ad. Go into your AndroidManifest.xml and add this attribute in the activity tag with the AdMob banner.
```
android:windowSoftInputMode="adjustPan"
```
This will prevent the ads from jumping above the keyboard and hiding the input. Instead, they will appear behind the keyboard (hidden). I don't know if this is against AdMob policy, I am just providing a solution.
|
56,394 |
I have replaced three flats on my new bike and found each time a tear or hole at the base of the air valve. What can cause this.
|
2018/08/11
|
[
"https://bicycles.stackexchange.com/questions/56394",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/38917/"
] |
1. As Kibbee suggests, the wrong size valve.
2. A badly-formed valve hole in the rim. It's not that unusual to find that there is a "lip" of metal at the hole that will cut into the tube. This requires a bit of filing with a small round file to correct.
3. Running the tire flat or with very low pressure. As an under-inflated tire rolls on the ground it tends to "walk" along the rim, tugging on the valve stem.
4. Poor tube installation technique. Most importantly, inflate the tube slightly before installing -- just enough that it rounds out (though it should still be limp).
|
1,650,529 |
An often given example of a group of infinite order where every element has infinite order is the group $\dfrac{\mathbb{(Q, +)}}{(\mathbb{Z, +})}$.
But I don't see why every element necessarily has finite order in this group. Why is this true?
Also, what is the identity element of this group?
|
2016/02/11
|
[
"https://math.stackexchange.com/questions/1650529",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/312641/"
] |
The identity of $G =\mathbb Q / \mathbb Z$ is $\mathbb Z$.
1) Every element of $G$ has **finite** order. Indeed, if you take any $r + \mathbb Z \in G$ where $r \in \mathbb Q$ then we may write $r = \frac{m}{n}$, with $m,n \in \mathbb Z $ and $n > 0$. Thus
$$n (r + \mathbb Z) = m + \mathbb Z = \mathbb Z$$
then it follows that $\left|r + \mathbb Z\right| \leq n$.
**Edit:**
2) The group has **infinite** order because we may choose an element in $G$ with arbitrarily large order, consider $\frac{1}{n} + \mathbb Z$, where $\left|\frac{1}{n} + \mathbb Z\right| = n$ (why?).
|
32,730 |
The following code evaluates the similarity between two time series:
```
set.seed(10)
RandData <- rnorm(8760*2)
America <- rep(c('NewYork','Miami'),each=8760)
Date = seq(from=as.POSIXct("1991-01-01 00:00"),
to=as.POSIXct("1991-12-31 23:00"), length=8760)
DatNew <- data.frame(Loc = America,
Doy = as.numeric(format(Date,format = "%j")),
Tod = as.numeric(format(Date,format = "%H")),
Temp = RandData,
DecTime = rep(seq(1, length(RandData)/2) / (length(RandData)/2),
2))
require(mgcv)
mod1 <- gam(Temp ~ Loc + s(Doy) + s(Doy,by = Loc) +
s(Tod) + s(Tod,by = Loc),data = DatNew, method = "ML")
```
Here, `gam` is used to evaluate how the temperature at New York and Miami vary from the mean temperature (of both locations) at different times of the day. The problem that I now have is that I need to include an interaction term which shows how the temperature of each location varies throughout at the day for different days of the year. I eventually hope to display all of this information on one graph (for each location). So, for Miami I hope to have one graph that shows how the temperature varies from the mean during different times of the day and different times of the year (3d plot?)
|
2012/07/21
|
[
"https://stats.stackexchange.com/questions/32730",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/12141/"
] |
The "a" in "gam" stands for "additive" which means no interactions, so if you fit interactions you are really not fitting a gam model any more.
That said, there are ways to get some interaction like terms within the additive terms in a gam, you are already using one of those by using the `by` argument to `s`. You could try extending this to having the argument `by` be a matrix with a function (sin, cos) of doy or tod. You could also just fit smoothing splines in a regular linear model that allows interactions (this does not give the backfitting that gam does, but could still be useful).
You might also look at projection pursuit regression as another fitting tool. Loess or more parametric models (with sin and/or cos) might also be useful.
Part of decision on what tool(s) to use is what question you are trying to answer. Are you just trying to find a model to predict future dates and times? are you trying to test to see if particular predictors are significant in the model? are you trying to understand the shape of the relationship between a predictor and the outcome? Something else?
|
36,403,859 |
How do I use "UPSERT" or "INSERT INTO likes (user\_id,person\_id) VALUES (32,64) ON CONFLICT (user\_id,person\_id) DO NOTHING" in PostgreSQL 9.5 on Rails 4.2?
|
2016/04/04
|
[
"https://Stackoverflow.com/questions/36403859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3384741/"
] |
Have a look at `active_record_upsert` gem here: <https://github.com/jesjos/active_record_upsert>. This does the upsert, but obviously only on Postgres 9.5+.
|
27,150,695 |
This may (should) have been asked before somewhere but I can't seem to find an answer. If someone provides a link I can delete this post!:
Just trying to get my head around some of composer's (probably applies to other package managers too) functionality.
Basically I just want to know what composer does in the following scenarios:
1.
My main project has a dependency:
```
"guzzlehttp/guzzle": "5.0.*",
```
My external bundle has a dependency on
```
"guzzlehttp/guzzle": "5.0.*",
```
Does composer install guzzlehttp/guzzle one time because it knows it only needs it once?
2.
Same scenario but in the future if someone updates the main project to use:
```
"guzzlehttp/guzzle": "6.0.*",
```
Will composer now install 2 versions of guzzle (5 and 6) (I presume this is what it should do), or will it take the highest version (i.e. 6)? Also if there are 2 versions will this cause any conflicts because namespaces might be the same?
Thanks
|
2014/11/26
|
[
"https://Stackoverflow.com/questions/27150695",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1624933/"
] |
### To question 1
Yes Composer can only install one version of each extension/package.
### To question 2
Because of answer 1: Composer would consider your main project and the external package as incompatible.
In this case you could
* stay with version 5 at your main project too.
* ask the external package owner to upgrade to version 6 too if it's compatible to.
* fork the external package and make it compatible to version 6 yourself
|
33,785,851 |
I've tried this code.
```
varying vec2 blurCoordinates[2][2];
```
But it results in error:
Vertex shader compilation failed.
ERROR: 0:10: '[' : Syntax error: syntax error
ERROR: 1 compilation errors. No code generated.
|
2015/11/18
|
[
"https://Stackoverflow.com/questions/33785851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4426075/"
] |
As already noted in genpfault's answer, GLSL does not support multidimensional arrays right from the beginning.
The extension [`GL_ARB_arrays_of_arrays`](https://www.opengl.org/registry/specs/ARB/arrays_of_arrays.txt) does provide the features you are looking for. It was promoted an OpenGL core feature in Version 4.3, so beginning with GLSL 4.30, you can use that without relying on extensions.
|
38,092,075 |
So simply put I'm trying to make a simple search engine where I've got a MySQL database and its contents being displayed on a HTML table (using PHP to get the information) and I want to make a search bar that as you type, filters the list automatically.
I've found tutorials on how to make that with plain text where it displays in just a list, but nothing on how to filter an already displayed table.
If someone could point in me in the direction of some helpful links or maybe some code I could use to start me off that would be great, sorry if this has been answered before, I've been looking for 20 odd minutes and just can't find anything that works.
**TLDR**: Making a search bar that as you type, filters an HTML table filled a with MySQL database table's information brought onto the page via PHP code, cant find any tutorials or helpful links/code after 20-ish min of searching and came here.
|
2016/06/29
|
[
"https://Stackoverflow.com/questions/38092075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5800070/"
] |
I have doubt in the way you are passing the data.
Try to pass the data without doing **stringify** and see if it works.
|
1,199,486 |
How can i use the server.mappath method in a C# class library class ,which acts as my BusinessLayer for My ASP.NET WEbsite
|
2009/07/29
|
[
"https://Stackoverflow.com/questions/1199486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/40521/"
] |
By calling it?
```
var path = System.Web.HttpContext.Current.Server.MapPath("default.aspx");
```
Make sure you add a reference to the System.Web assembly.
|
99,841 |
>
> Slight specific staining with the antibody was observed in **isolated** peripheral blood lymphocytes.
>
>
>
Would this **isolated** always evoke the meaning "[happening or existing only once, separate](http://dictionary.cambridge.org/dictionary/english/isolated)", as in
>
> There were only a few **isolated** cases of violent behaviour.
>
>
>
or might it half-imply that "someone has *isolated* these lymphocytes from tissue", and thus the term is better avoided in this sentence for clarity's sake?
What would be good alternatives? I can think of "individual" and "single".
|
2016/08/06
|
[
"https://ell.stackexchange.com/questions/99841",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/2127/"
] |
I would interpret this sentence as meaning "isolated ... from tissue." However, I am not a physician or biologist and I can't say whether one would interpret it differently. What I can do is quote a number of publications that use that phrase:
>
> [*Apoptogenic effect of fentanyl on freshly isolated peripheral blood lymphocytes.*](http://www.ncbi.nlm.nih.gov/pubmed/15284552)
>
>
>
In this case, the use of *freshly* tells us that it does not mean "isolated cases."
>
> In this study, we used in vitro isolated peripheral blood lymphocytes as
> biosensors to test the effect of hypobaric hypoxia on seven climbers by
> measuring the functional activity of these cells.
>
>
> — [*Peripheral blood lymphocytes: a model for monitoring physiological adaptation to high altitude.*](http://www.ncbi.nlm.nih.gov/pubmed/21190502)
>
>
>
Since "in vitro" means "outside a living organism," we can also safely assume that this usage does not mean "isolated cases."
>
> Thirteen patients with SLE with active disease, 10 patients with inactive
> disease, and 14 controls entered the study. In addition, samples from 10 of
> the 13 patients with active disease could be studied at a moment of inactive
> disease as well. **Isolated peripheral blood lymphocytes were stained** for
> the lymphocyte subset markers CD4, CD8, CD19, their respective activation
> markers CD25, HLA-DR, CD38, and the costimulatory molecules CD40L, CD28,
> CD40, CD80, and CD86. Expression was measured by flow cytometry.
>
>
> — [*Expression of costimulatory molecules on peripheral blood lymphocytes of patients with systemic lupus erythematosus*](http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1753642/)
>
>
>
Again, this usage cannot refer to "isolated cases." This time because it's being used as an adjective to modify "peripheral blood lymphocytes."
These were the first three results when searching for the phrase"isolated peripheral blood lymphocytes," so I think it is safe to conclude that that phrase will only ever be interpreted to mean "isolated ... from tissue."
---
If you wish to express that staining was observed in only some of the lymphocytes, you might want to reword the sentence as:
>
> Slight specific staining with the antibody was observed in **a small number
> of** peripheral blood lymphocytes.
>
>
>
If your intention was to say that slight staining was observed in those lymphocytes not clustered together, you might say:
>
> Slight specific staining with the antibody was observed in **discrete**
> peripheral blood lymphocytes.
>
>
>
The definition of *discrete* from Oxford Dictionaries:
>
> [**discrete**](http://www.oxforddictionaries.com/definition/english/discrete)
>
> Individually separate and distinct:
>
> "*That is, does age affect general ability or does it have discrete effects on individual abilities?*"
>
>
>
Be careful not to confuse *discrete* and [*discreet*](http://www.oxforddictionaries.com/definition/english/discreet).
|
37,739,324 |
I have the following code where `Model.VerticalType` contains string. I want to compare it with an `Enum` but I get error:
Operator '==' cannot be applied to operands of type 'string' and
`DGS.DGSAPI.UI.BusinessModels.Enums.VerticalType.Voice`
```
@if (Model.VerticalType == DGS.DGSAPI.UI.BusinessModels.Enums.VerticalType.Voice)
{
<img src="@phoneWSource" />
}
```
|
2016/06/10
|
[
"https://Stackoverflow.com/questions/37739324",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5788013/"
] |
Call `.ToString()` on the enum value.
```
@if (Model.VerticalType == DGS.DGSAPI.UI.BusinessModels.Enums.VerticalType.Voice.ToString())
```
This will convert the enum to it's name, in this case `Voice`.
|
12,511,801 |
I have two dictionaries as follows:
`D1={'a':1,'b':2,'c':3}`
and
`D2={'b':2,'c':3,'d':1}`
I want to merge these two dictionaries and the result should be as follows:
`D3={'a':1,'b':2,'c':3,'b':2,'c':3,'d':1}`
how can I achieve this in python?
|
2012/09/20
|
[
"https://Stackoverflow.com/questions/12511801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1321663/"
] |
>
> I want to merge these two dictionaries and the result should be as
> follows:
>
>
> D3={'a':1,'b':2,'c':3,'b':2,'c':3,'d':1}
>
>
> how can I achieve this in python?
>
>
>
You can't. You can only have one value per key in a Python dict. What you can do is to have a list or a set as the value.
Here is an example with a set:
```
d1 = { 'a': 1, 'b': 2, 'c': 3 }
d2 = { 'a': 1, 'b': 5, 'd': 4 }
d3 = {}
def add_dict(target, d):
for key in d:
target.setdefault(key, set([])).add(d[key])
add_dict(d3, d1)
add_dict(d3, d2)
```
This will give you `d3`:
```
{'a': set([1]), 'c': set([3]), 'b': set([2, 5]), 'd': set([4])}
```
You can also do this with a list (possibly closer to your example):
```
d1 = { 'a':1, 'b':2, 'c': 3}
d2 = { 'b':2 ,'c':3, 'd': 1}
d3 = {}
def add_dict(target, d):
for key in d:
target.setdefault(key, []).append(d[key])
add_dict(d3, d1)
add_dict(d3, d2)
```
You'll get this:
```
{'a': [1], 'c': [3, 3], 'b': [2, 2], 'd': [1]}
```
However, looking at `{'a':1,'b':2,'c':3,'b':2,'c':3,'d':1}` (which can't be a dict), it seems that you're after a different data structure altogether. Perhaps something like this:
```
d1 = { 'a':1, 'b':2, 'c': 3}
d2 = { 'b':2 ,'c':3, 'd': 1}
result = []
result += [ { 'key': key, 'value': d1[key] } for key in d1 ]
result += [ { 'key': key, 'value': d2[key] } for key in d2 ]
```
This would produce this, which looks closer to the data structure you had in mind initially:
```
[ {'value': 1, 'key': 'a'},
{'value': 3, 'key': 'c'},
{'value': 2, 'key': 'b'},
{'value': 3, 'key': 'c'},
{'value': 2, 'key': 'b'},
{'value': 1, 'key': 'd'} ]
```
|
69,908,135 |
I just tried building my old project in vs2019 to newer vs2022 but getting following error and unable to build it.
Can somebody suggest what can be done to resolve the issue?
```
Severity Code Description Project File Line Suppression State
Error The "ResolveManifestFiles" task failed unexpectedly.
System.Globalization.CultureNotFoundException: Culture is not supported.
Parameter name: name
v4.0_12.0.0.0_de_89845dcd8080cc91 is an invalid culture identifier.
at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride)
at Microsoft.Build.Tasks.ResolveManifestFiles.GetItemCulture(ITaskItem item)
at Microsoft.Build.Tasks.ResolveManifestFiles.GetOutputAssemblies(List`1 publishInfos, List`1 assemblyList)
at Microsoft.Build.Tasks.ResolveManifestFiles.GetOutputAssembliesAndSatellites(List`1 assemblyPublishInfos, List`1 satellitePublishInfos)
at Microsoft.Build.Tasks.ResolveManifestFiles.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Kings ERP
```
|
2021/11/10
|
[
"https://Stackoverflow.com/questions/69908135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1761822/"
] |
Not sure why, but if you remove "Enable ClickOnce security settings" it'll work.
Regards
|
72,363,010 |
How can I add random numbers (for example from 1 to 100) into an array using Julia language? Also, the array already has to have a defined length (for example 30 numbers).
|
2022/05/24
|
[
"https://Stackoverflow.com/questions/72363010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19053578/"
] |
If your initial vector is `v`, you can do as follows:
```
v .+= rand(1:100,length(v))
```
* `rand(1:100,length(v))` will generate a random vector of integers between 1 and 100 and of length identical to `v`'s one (the `length(v)` part), you can read the [rand()](https://docs.julialang.org/en/v1/stdlib/Random/#Base.rand) doc for further details.
* `.+=` is the Julia syntax to do an "in-place" vector addition. Concerning performance, this is an important syntax to know, see ["dot call" syntax](https://docs.julialang.org/en/v1/manual/mathematical-operations/#man-dot-operators)
---
**Update** a more efficient approach, is :
```
map!(vi->vi+rand(1:100),v,v)
```
Note: the approach is more efficient as it avoids the creation of the `rand(1:100,length(v))` temporary vector.
---
**Update** an alternative, if you want to **fill** (and not to add) the vector with random integers, is @DNS's one (see comment) :
```
using Random
v = Vector{Int}(undef,30)
rand!(v,1:100)
```
Note:
* `Vector{Int}(undef,30)` is the Julia's way to create a vector of 30 **uninitialized** integers.
* the `rand!()`function **fills** this vector with random integers. Internally it uses a for loop.
.
```
rand!(A::AbstractArray{T}, X) where {T} = rand!(default_rng(), A, X)
# ...
function rand!(rng::AbstractRNG, A::AbstractArray{T}, sp::Sampler) where T
for i in eachindex(A)
@inbounds A[i] = rand(rng, sp)
end
A
end
```
|
80,633 |
What is the best textbook (or book) for studying Etale cohomology?
|
2011/11/10
|
[
"https://mathoverflow.net/questions/80633",
"https://mathoverflow.net",
"https://mathoverflow.net/users/-1/"
] |
Not a textbook, but a free PDF by J.S. Milne, <http://www.jmilne.org/math/CourseNotes/LEC.pdf>, pretty good IMHO.
|
58,595 |
>
> Es ist für beide fast so, als **seien** sie niemals getrennt gewesen.
>
>
>
Warum wird hier der Konjunktiv 1 verwendet?
Es handelt sich um keine indirekte Rede wo der Konjunktiv 1 hauptsächlich verwendet wird.
Meines Wissens nach sollte hier Konjunktiv 2 verwendet werden, also:
>
> Es ist für beide fast so, als **wären** sie niemals getrennt gewesen.
>
>
>
|
2020/05/14
|
[
"https://german.stackexchange.com/questions/58595",
"https://german.stackexchange.com",
"https://german.stackexchange.com/users/40962/"
] |
Von der Konsistenz her gesehen hast Du recht und es müsste der Konjunktiv 2 verwendet werden. Da sie tatsächlich getrennt waren, beschreibt der Nebensatz eine irreale Situation, wofür normalerweise der Konjunktiv 2 verwendet wird. Es liegt keine indirekte Rede (oder ähnliches) vor, die den Konjunktiv 1 verlangen würde.
Einige Präskriptivisten raten deshalb von dieser Verwendung ab, z. B. [Belles Lettres](https://www.belleslettres.eu/content/konjunktiv/konjunktiv.php#vergleich):
>
> Der Konjunktiv 1 hat in Vergleichssätzen allerdings nichts verloren. Die Wortkombinationen *als sei, als habe* usw. sind also immer falsch. Richtig sind *als wäre* und *als hätte*.
>
>
>
**Aber:** Es ist tatsächlich sehr üblich, dass in solchen irrealen Vergleichssätzen der Konjunktiv 1 verwendet wird. So beobachtet zum Beispiel [der Duden](https://www.duden.de/sprachwissen/sprachratgeber/Nebensatze-mit-als-ob-als-wenn-wie-wenn):
>
> In irrealen Vergleichssätzen mit *als ob, als wenn* und *wie wenn* wird sowohl der Konjunktiv I als auch der Konjunktiv II verwendet:
>
>
>
> >
> > Du tust ja geradezu, als ob du zu gar nichts zu gebrauchen wär[e]st/sei[e]st.
> >
> >
> >
>
>
> Der Konjunktiv II *([...] zu gebrauchen wärest)* ist aber üblicher. Das gilt auch für irreale Vergleichssätze mit *als* bei folgender Verbform:
>
>
>
> >
> > Sie lächelte, als hätte/habe sie niemals lügen müssen.
> >
> >
> >
>
>
>
Warum der Duden hier einen vagen Unterschied zwischen *als* und *als ob* macht, ist mir unklar. Mir ist kein Unterschied in der Verwendung bewusst.
Von diesem deskriptiven Standpunkt ist die Verwendung des Konjunktiv 1 in Vergleichssätzen legitim:
Es ist korrekt, weil es so verwendet wird (und zwar auch in der Hochsprache).
Ob diese Verwendung aus Schludrigkeit, Hyperkorrektur, dem Lateinischen, oder etwas anderem erwachsen ist, kann ich nicht sagen.
Die Antwort auf Deine Frage ist also:
Der Konjunktiv 1 wird hier verwendet, da es sich um einen irrealen Vergleichssatz handelt und diese einen Spezialfall darstellen.
|
57,032,235 |
I'm trying to filter a Dataframe based on the length of the string in the index. In the following example I'm trying to filter out everything but `Foo Bar`:
```
index Value
Foo 1
Foo Bar 2
Bar 3
In: df[df.index.apply(lambda x: len(x.split()) > 1]
Out: AttributeError: 'Index' object has no attribute 'apply'
```
Is there any way to perform this operation directly on the index rather than resetting the index and applying the function on the new column?
|
2019/07/15
|
[
"https://Stackoverflow.com/questions/57032235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7542939/"
] |
We do not need `apply` here
```
df[df.index.str.count(' ')==1]
```
To fix your code `map`
```
df[df.index.map(lambda x: len(x.split()) > 1)]
```
|
6,904,065 |
this is from selenium grid. How to write java/C# code to make parallel execution.
Is this enough?
```
ISelenium selenium1 = new DefaultSelenium("localhost", 5555, "*iehta", "http://localhost/");
ISelenium selenium2 = new DefaultSelenium("localhost", 5556, "*iehta", "http://localhost/");
ISelenium selenium4 = new DefaultSelenium("localhost", 5557, "*iehta", "http://localhost/");
selenium1.Start();
selenium2.Start();
selenium3.Start();
```
Because when I run <http://localhost:4444/console> there are 3 Available Remote Controls but 0 Active Remote Controls even if I run code from up.
Code from ant which I do not understand 100%. Why is there parameter
`<arg value="-parallel"/>`?
```
<target name="run-demo-in-parallel" description="Run Selenium tests in parallel">
<java classpathref="demo.classpath"
classname="org.testng.TestNG"
failonerror="true"
>
<sysproperty key="java.security.policy" file="${basedir}/lib/testng.policy"/>
<sysproperty key="webSite" value="${webSite}" />
<sysproperty key="seleniumHost" value="${seleniumHost}" />
<sysproperty key="seleniumPort" value="${seleniumPort}" />
<sysproperty key="browser" value="${browser}" />
<arg value="-d" />
<arg value="${basedir}/target/reports" />
<arg value="-suitename" />
<arg value="Selenium Grid Demo In Parallel" />
<arg value="-parallel"/>
<arg value="methods"/>
<arg value="-threadcount"/>
<arg value="10"/>
<arg value="-testclass"/>
<arg value="com.thoughtworks.selenium.grid.demo.WebTestForASingleBrowser"/>
</java>
</target>
```
|
2011/08/01
|
[
"https://Stackoverflow.com/questions/6904065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/267679/"
] |
Why is there parameter
```
<arg value="-parallel"/>?
```
This is for testng. This would run all the methods/classes/tests in parallel rather than sequentially. You can see more about this property [here](http://testng.org/doc/documentation-main.html#parallel-running). You have registered 3 RCs and ideally you should see all 3 being used for execution. You can check the grid console link to see the utilization - <http://localhost:4444/console> where localhost is the IP on which hub is running and port is the portnumber on which hub is listening to.
EDIT:
Change your code to point to selenium hub port rather than RC port. By default Hub port will be 4444. Also make sure you have started the RC nodes with environment as \*iehta.
```
`ISelenium selenium1 = new DefaultSelenium("localhost", 4444, "*iehta",` "http://localhost/");
```
|
513,765 |
The comments section of [this post](http://www.ehow.com/how_5157582_calculate-pi.html) says that $\pi$ does repeat itself if done under base 11... and that it somehow defines the universe.
* Can anyone expand on the idea that irrational numbers may repeat if a different base is used?
* Does $\pi$ in fact repeat under base 11?
* Is there any known value in numbers that have this property? (or conversely the ones that don't have this property?)
|
2013/10/03
|
[
"https://math.stackexchange.com/questions/513765",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/4420/"
] |
The comment is mistaken.
A number is rational if and only if its expansion *in any base* is eventually recurring (possibly with a recurring string of $0$s). Thus $\pi$ has no recurring expansion in any base.
---
**Why?** Well suppose it did. Then
$$\pi = n . d\_1d\_2 \cdots d\_k \overline{r\_1 r\_2 \cdots r\_{\ell}}$$
in some base $b$ say, where $r\_1 \cdots r\_{\ell}$ is the recurring part. Thus
$$b^k\pi = m . \overline{r\_1 r\_2 \cdots r\_{\ell}}$$
where $m$ is some integer, it doesn't really matter what it is. Also notice
$$b^{k+\ell}\pi = mr\_1 r\_2 \cdots r\_{\ell}. \overline{r\_1 r\_2 \cdots r\_{\ell}}$$
Subtracting one from the other gives
$$b^{k+\ell}\pi - b^k\pi = mr\_1 r\_2 \cdots r\_{\ell} - m = M$$
where $M$ is again some integer, and hence
$$\pi = \dfrac{M}{b^{k+\ell} - b^k}$$
so $\pi$ is rational.
...this ain't true -- we know that $\pi$ is irrational -- so our assumption that $\pi$ has a recurring expansion to base $b$ must have been mistaken.
---
My notation above was a bit sloppy. The $d\_i$ and $r\_i$s refer to *digits* whilst the other letters refer to *numbers*. I hope it's understandable, but if it isn't then let me know and I'll clarify.
|
43,185,964 |
Getting this error why trying to deploy the war in weblogic
>
> Caused By: weblogic.management.DeploymentException: [HTTP:101170]The
> servlet Web Rest Services is referenced in servlet-mapping /myrest/\*
> but not defined in web.xml.
> at weblogic.servlet.internal.WebAppServletContext.verifyServletMappings(WebAppServletContext.java:1465)
> at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2809)
> at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
> at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:822)
> at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
>
>
>
my web.xml:
```
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>REST</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>rest.apis</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Web Rest Services</servlet-name>
<url-pattern>/myrest/*</url-pattern>
</servlet-mapping>
</web-app>
```
If required I can paste the code of rest resources but not sure it matters.
What worries me, can there be issue with weblogic?
Note: Recently app server was upgraded to weblogic 12.1.2
|
2017/04/03
|
[
"https://Stackoverflow.com/questions/43185964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1847484/"
] |
>
> `<servlet-name --> Jersey Web Application != Web Rest Services`
>
>
>
The `<servlet-name>` in the `<servlet-mapping>` should correspond to a `<servlet-name>` in a `<servlet>` definition. Hence the error
>
> The servlet Web Rest Services is referenced in servlet-mapping /myrest/\* but not defined in web.xml
>
>
>
|
18,630,436 |
I need to read permanent (burned-in) MAC address of network adapter. Since MAC address can be easily spoofed, I need to read the real one which is written on EEPROM. I need to do it using C++ on Linux.
I tried using [ethtool](http://linux.die.net/man/8/ethtool) which is quite good and works fine. However on some systems it does not work as intented.
```
ethtool -P eth0
```
returns this:
```
Permanent address: 00:00:00:00:00:00
```
and
```
ethtool -e eth0
```
returns this:
```
Cannot get EEPROM data: Operation not supported
```
---
Network Adapter has following info:
* driver: ucc\_geth
* version: 1.1
* firmware-version: N/A
* bus-info: QUICC ENGINE
Linux kernel version is: 2.6.32.13
Question is: Can i fix this issue with any update(driver, kernel etc)?
Additionally, I make the same ethtool calls with `ioctl` function in C++. Is there any way to fix this inside the code? Or is there any other way to get the permanent MAC address from EEPROM?
|
2013/09/05
|
[
"https://Stackoverflow.com/questions/18630436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1338432/"
] |
If you haven't find the answer yet, you might want to check this out.
<https://serverfault.com/questions/316976/can-i-get-the-original-mac-address-after-it-has-been-changed>
|
66,323,859 |
I am trying to understand the memory leak.
I don't understand why below MyInt deconstruct in main is never called and a memory leak happens.
```
class MyInt
{
int *_p;
public:
MyInt(int *p = NULL) { _p = p; }
~MyInt()
{
delete _p;
}
int &operator*() { return *_p; }
};
int main()
{
double t[] = {1.0, 2.0, 3.0, 4.0, 5.0};
for (size_t i = 0; i < 5; ++i)
{
MyInt *en = new MyInt(new int(i));
std::cout << **en << "/" << t[i] << " = " << **en / t[i] << std::endl;
return 0;
}
```
|
2021/02/22
|
[
"https://Stackoverflow.com/questions/66323859",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9261745/"
] |
>
> I don't understand why below MyInt deconstruct in main is never called and a memory leak happens.
>
>
>
Because you use an allocated pointer to `MyInt`.
You have to call
```
delete en;
```
to de-allocate it.
Deleting `en`, the destructor of `MyInt` is called and the memory associated to `_p` is de-allocated.
Suggestion: you tagged C++11, so you can use smart pointers.
So, inside `MyInt`, use a smart pointer
```
#include <memory>
class MyInt
{
std::unique_ptr<int> my_p;
public:
MyInt (int *p = NULL) : my_p{p}
{ }
// no explicit destructor required anymore
int &operator*() { return *my_p; }
};
```
In `main()`, use a smart pointer as well:
```
#include <memory>
for (std::size_t i = 0; i < 5; ++i)
{
std::unique_ptr<MyInt> en { new MyInt(new int(i)) };
// use en and the content pointer
// no more delete en required
}
```
|
445,304 |
I am designing a system to 'hack' into a CAN bus. My first idea was to split the target CAN bus, terminating both ends into isolated CAN transceivers, and use a MCU to pass packets between the buses while altering values inside the packets. Below is a rough picture of the setup:
[](https://i.stack.imgur.com/O55to.jpg)
My problem is that while connected to the target CAN bus, the system fails to transmit on either CAN bus. In the program I can see it is receiving, but the MCU gets stuck in a loop of failed transmissions.
The weird part is that I can prove the code and hardware are all viable in a different environment. When I hook up the hardware to a test rig I made using a couple of development boards and a power supply, it works well! The packets from both devices are seen on both buses. The packet bits look healthy and square. I am at a loss figuring out what specifically is different about the environments on my desktop and on the target CAN bus that make it break.
System details follow:
MCU - [STM32F746ZGT6](https://www.st.com/resource/en/datasheet/stm32f746zg.pdf)
Isolated CAN transceivers - [ADM3054](https://www.analog.com/media/en/technical-documentation/data-sheets/ADM3054.pdf)
Bus speed - 125kHz (confirmed with oscilloscope and CAN sniffer tool)
I'd really appreciate help thinking through this system design, and understanding how it might cause CAN transmissions might fail.
Thanks!
EDIT:
Upon farther thought, I think I realize the area to focus on is between the TxR and the MCU. If the MCU is refusing to declare a successful transmission, than it must think something wrong is happening on the bus. It can only interact with the bus via TX and RX. I will scope TX and RX to see if I can see any weird errors, possibly caused by reflections or something interfering with RX during transmission?
EDIT 2: added schematic and layout image
[](https://i.stack.imgur.com/sbbmM.png)
[](https://i.stack.imgur.com/rOB9z.png)
|
2019/06/25
|
[
"https://electronics.stackexchange.com/questions/445304",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/183950/"
] |
According to your schematic, you broke up the bus in two and there's no termination anywhere. You get the wrong impedance instead of the expected 60 Ohm. Before each transceiver on the "hack" device, you need terminating resistors of 120 Ohm between CANH and CANL.
In addition, the "hacker" MCU's CAN controller must actively participate on the bus, you can't have it set to listen-only or loopback mode. Otherwise the other node on the bus will have none to speak with and eventually go error passive mode.
|
6,756 |
It seems pretty normal to see screenshots of MS Word, steps for "this is how you generate a template". I don't think Microsoft would object.
But I'm not sure about reprinting images from in-game scenes for specific games, like Diablo II. Do you need to obtain permission to include a screenshot of a game in your book?
|
2012/12/06
|
[
"https://writers.stackexchange.com/questions/6756",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/389/"
] |
There are four factors to determining Fair Use of copyrighted material that must be weighed in the balance:
* Purpose and character of use...better if not for profit; better if transforming in some way
* The nature of the work...factual is better, creative works less so
* The amount and substance of the work...less is better; uses that don't get at "the heart of the work" are better. There are no rules about percentages, etc, despite myths to the contrary.
* The effect of the use on market value...if it doesn't take away from real or potential profit, better
Depending on the nature of the book you are writing, you are probably quite safe using screenshots. You are likely writing something that will stimulate sales and that isn't going to reveal workings of the game that are protected.
Your publisher should have experience with this and probably has a policy for when they ask permission. Unfortunately, many people and organizations don't understand Fair Use and err too far on the side of caution, ceding rights they don't actually have to.
I teach about Fair Use regularly; you can find more information here: <http://iteachu.uaf.edu/develop-courses/constructing-a-course/copyright/>
|
7,615,807 |
After renaming my heroku app from the heroku website, whenever I cd to its directory in a terminal and run any heroku command, I get `App not found`. Does anybody know of a way to remedy this?
|
2011/09/30
|
[
"https://Stackoverflow.com/questions/7615807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/454761/"
] |
Try to update the git remote for the app:
```
git remote rm heroku
git remote add heroku [email protected]:yourappname.git
```
|
1,746,676 |
I am creating a classifieds website.
Im storing all ads in mysql database, in different tables.
Is it possible to find these ads somehow, from googles search engine?
Is it possible to create meta information about each ad so that google finds them?
How does major companies do this?
I have thought about auto-generating a html-page for each ad inserted, but 500thousand auto-generated html pages doesn't really sound that good of a solution!
Any thoughts and idéas?
**UPDATE**:
Here is my basic website so far:
(ALL PHP BASED)
I have a search engine which searches database for records.
After finding and displaying search results, you can click on a result ('ad') and then PHP fetches info from the database and displays it, simple!
In the 'put ad' section of my site, you can put your own ad into a mysql database.
I need to know how I should make google find ads in my website also, as I dont think google-crawler can search my database just because users can.
Please explain your answers more thoroughly so that I understand fully how this works!
Thank you
|
2009/11/17
|
[
"https://Stackoverflow.com/questions/1746676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
Google doesn't find database records. Google finds web pages. If you want your classifieds to be found then they'll need to be on a Web page of some kind. You can help this process by giving Google a site map/index of all your classifieds.
I suggest you take a look at [Google Basics](http://www.google.com/support/webmasters/bin/answer.py?answer=70897&hl=en) and [Creating and submitting SitemapsPrint](http://www.google.com/support/webmasters/bin/answer.py?answer=156184&hl=en). Basically the idea is to spoon feed Google every URL you want Google to find. So if your reference your classifieds this way:
```
http://www.mysite.com/classified?id=1234
```
then you create a list of every URL required to find every classified and yes this might be hundreds of thousands or even millions.
The above assumes a single classified per page. You can of course put 5, 10, 50 or 100 on a single page and then create a smaller set of URLs for Google to crawl.
Whatever you do however remember this: your sitemap should reflect how your site is used. Every URL Google finds (or you give it) will appear in the index. So don't give Google a URL that a user couldn't reach by using the site normally or that you don't want a user to use.
So while 50 classifieds per page might mean less requests from Google, if that's not how you want users to use your site (or a view you want to provide) then you'll have to do it some other way.
Just remember: Google indexes *Web pages* not *data*.
|
213,778 |
I want to perform a statistical test: Wilcoxon Signed Rank Test to test if there is a significant difference between them, but I don't know if the two samples are dependent or not?
Context: I have a dataset that contains a set of elements, I want to predict the dependent variable, I use two models A and B to perform the prediction using LOOCV. So, I have two samples based on the absolute errors (sample A: contains the absolute errors based on prediction of Model A, Sample B: contains the absolute erroers based on prediction of Model B).
My Question: is the sample A and B are dependent or independent?
Thank you in advance
|
2016/05/21
|
[
"https://stats.stackexchange.com/questions/213778",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/116392/"
] |
The answer is *dependent*. Or, to be a bit more precise: paired.
The thing to keep in mind here is that you only have one sample, and have two measurements for each observations in that sample.
If, instead, you had two distinct samples (e.g., one representing the first 100 cases in your data set and the other the second 100 cases), and were comparing the predictive accuracy between these two samples, you would then have two independent samples.
|
22,875,579 |
I would like to add a CSS class to a Bootstrap (3.x) tooltip, but it seems not working. So I would like to use Firebug to inspect the tooltip content. However, when I move my mouse to the Firebug area, the dynamically generated tooltip disappers.
How can I inspect a dynamically generated Bootstrap tooltip?
Here is the [jsfiddle link](http://jsfiddle.net/mddc/4JGx9/9/).
```
<label>
Some Text
<a href="#" data-toggle="tooltip" title="Tooltip goes here!">?</a>
</label>
$(function() {
$('[data-toggle="tooltip"]').tooltip({
'animation': true,
'placement': 'top'
});
});
```
Thanks!
|
2014/04/05
|
[
"https://Stackoverflow.com/questions/22875579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/997474/"
] |
1. Enable the [*Script* panel](https://getfirebug.com/wiki/index.php/Script_Panel)
2. Reload the page
3. Inspect the `<label>` element containing `Some Text?`
4. Right-click the element and choose *Break On Child Addition or Removal* from the context menu
5. Move the mouse over the question mark
=> The script execution will stop and you'll see a hint showing you the tooltip element.

6. Press the *Step Over* button () or press `F10` once, so the element is added to the DOM
7. Switch to the [*HTML* panel](https://getfirebug.com/wiki/index.php/HTML_Panel)
=> There you'll see the `<div>` containing the tooltip and you'll be able to check its styles.

|
64,288,547 |
Currently doing a school mini-project where we have to make a program to extract the domain name from a few given URL's, and put those which end in .uk (ie are websites from the united kingdom) in a list.
A couple of specifications:
* We cannot import any modules or anything.
* We can ignore urls that don't start with either "http://" or "https://"
I was originally just going to do:
```
uksites = []
file = open('urlfile.txt','r')
urllist = file.read().splitlines()
for url in urllist:
if "http://" in url:
domainstart = url.find("http://") + len("http://")
elif "https://" in url:
domainstart = url.find("https://") + len("https://")
domainend = url.find("/", domainstart)
if domainend >= 0:
domain = url[domainstart:domainend]
else:
domain = url[domainstart:]
if domain[-3:] = ".uk":
uksites.append(url)
```
But then our professor warned us that not all domain names will be ended with a "/" (for example, one of the given ones in the test file we were supplied ends with ":")
Is this the only other valid character that can signify the end of a domain name? or are there even more?
If so how could I approach this?
The test file is pretty short, it contains a few "links" (some aren't real sites apparently):
```
http://google.com.au/
https://google.co.uk/
https://00.auga.com/shop/angel-haired-dress/
http://applesandoranges.co.uk:articles/best-seasonal-fruits-for-your-garden/
https://www.youtube.com/watch?v=GVbG35DeMto
http://docs.oracle.com/en/java/javase/11/docs/api/
https://www.instagram.co.uk/posts/hjgjh42324/
```
|
2020/10/09
|
[
"https://Stackoverflow.com/questions/64288547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13292868/"
] |
This should work
```py
def compute():
ret = []
hs = ['https:', 'http:']
domains = ['uk']
file = open('urlfile.txt','r')
urllist = file.read().splitlines()
for url in urllist:
url_t = url.split('/')
# \setminus {http*}
if url_t[0] in hs:
url_t = (url_t[2]).split('.')
else:
url_t = (url_t[0]).split('.')
# get domain
if ':' in url_t[-1]:
url_t = (url_t[-1].split(':'))[0]
else:
url_t = url_t[-1]
# verify it
if url_t in domains:
ret.append(url)
return ret
if __name__ == '__main__':
print(compute())
```
|
45,867,756 |
I am trying to customize the font on my site title to Raleway in Wordpress.
I have added the google font code in `Customize` > `Typography`. This is working to change the font on my PC but not on my mobile device.
I added this code to the Custom CSS panel:
```
@site-title {
font-family: 'Raleway';
font-style: light;
src: url ('https://fonts.googleapis.com/css?family=Raleway');
}
```
Nothing seems to work. Any ideas of what I can do?
my site: [stillnorthretreatco.com](http://stillnorthretreatco.com)
Thanks!!
|
2017/08/24
|
[
"https://Stackoverflow.com/questions/45867756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8513028/"
] |
`#` is only used to indicate a comment when used inside Python code. In your query, it is inside the query string, and so is not parsed as a comment identifier, but as part of the query.
If you delete it, you are left with 8 `%s` and only 7 items inside `payload`.
|
33,273,809 |
I'm making a basic calculator where you can plus, times, divide and minus as i was experimenting to see if it worked i noticed that instead of 5 divided by being equal to 1.25 it only displayed 1.
Here's the code i use to handle the math problems:
```
if (box.getSelectedItem().equals(divide)){
JOptionPane.showMessageDialog(null, Integer.parseInt(first.getText()) / Integer.parseInt(second.getText()), "Answer", -1);
main(args);
}
```
Is there code that displays the decimal points as well?
|
2015/10/22
|
[
"https://Stackoverflow.com/questions/33273809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5448013/"
] |
Since you are using Integer,it is happening.
Use [Double](http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html) to preserve decimals.
In your case,use
```
Double.parseDouble(first.getText()) / Double.parseDouble(second.getText())
```
|
9,929 |
One of Blackberry's [strongest assets](http://www.marketwatch.com/story/rim-the-long-slow-death-spiral-begins-2011-12-20?pagenumber=2) is the "network" that it uses. Can someone explain, or link to technical information that covers what this secure network is, and what it does better than the rest?
|
2011/12/20
|
[
"https://security.stackexchange.com/questions/9929",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/396/"
] |
How dare you! How dare you question the most secure mobile platform available to mankind! My attempt at humor there.. now to a serious answer before the mods attack. Blackberry has some whitepapers regarding security here: <http://us.blackberry.com/ataglance/security/>
I would argue the network is not RIM's strongest asset. Corporate and government adoption of the product due to the level of control they have over the devices is RIM's strongest asset. MDM is a hot topic now, but people seem forget that RIM has been doing it for 14 years.
Unfortunately for RIM the pendelum has swung away from corporate control towards the "bring your own device" philosophy, and with good reason. Android and IOS offers a better user experience.
|
15,053,715 |
I'm making a management program with C# & SQL Server 2008. I want to search records using Blood Group, District & Club Name wise all at a time. This is what is making prob:
```
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM Table2
WHERE @Blood_Group =" + tsblood.Text + "AND @District =" + tsdist.Text +
"AND Club_Name =" + tscname.Text, Mycon1);
```
Can anyone tell me what is the correct syntax? Tnx in advance. :)
|
2013/02/24
|
[
"https://Stackoverflow.com/questions/15053715",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2104796/"
] |
The correct syntax is to use parametrized queries and absolutely never use string concatenations when building a SQL query:
```
string query = "SELECT * FROM Table2 WHERE BloodGroup = @BloodGroup AND District = @District AND Club_Name = @ClubName";
using (SqlDataAdapter sda = new SqlDataAdapter(query, Mycon1))
{
sda.SelectCommand.Parameters.AddWithValue("@BloodGroup", tsblood.Text);
sda.SelectCommand.Parameters.AddWithValue("@District", tsdist.Text);
sda.SelectCommand.Parameters.AddWithValue("@ClubName", tscname.Text);
...
}
```
This way your parameters will be properly encoded and your code not vulnerable to SQL injection attacks. Checkout [`bobby tables`](http://bobby-tables.com/).
Also notice how I have wrapped IDisposable resources such as a SqlDataAdapter into a using statement to ensure that it is properly disposed even in case of an exception and that your program will not be leaking unmanaged handles.
|
34,995 |
I planted red and new potatoes in early May. They were planted 6-8 inches deep. The potatoes were sprouted potatoes from our local hardware store. Our soil is heavy clay but the potatoes were planted in purchased hummus which had been worked into the soil to a depth of about 15 inches. Our climate zone is zone 9B.
[](https://i.stack.imgur.com/A8pEG.jpg)
[](https://i.stack.imgur.com/qXDvJ.jpg)
As you can see, the potato plants only grew to about 1 ft high. Some of the plants dried up so we started harvesting today (Aug 13). To our surprise, there were no potatoes at all. We watered the potatoes using a drip system (2 GPH) that was set to 15 minutes once per week. However, the summer here has been very hot and whenever the plants looked wilted, we added an additional watering cycle.
|
2017/08/13
|
[
"https://gardening.stackexchange.com/questions/34995",
"https://gardening.stackexchange.com",
"https://gardening.stackexchange.com/users/19536/"
] |
Judging by the state of the plants when you dug them up, and what the soil surface looks like there are no nutrients whatever in it.
The potatoes *tried* to grow, using the material stored in the tuber, but that's as much as they managed to do. The leaves never developed properly, nor did the roots. They would have grown just as "well" if you had just put them on a concrete driveway and ignored them.
"Purchased humus" doesn't necessarily contain any nutrients. If you really want to grow potatoes in this soil, I would dig the area now to break it up, then spread about a 6 inch depth of horse manure on the surface and leave it for 3 months to let the micro-organisms to break it down and release the nutrients, then dig it in. That might give you better results next year!
|
34,640,668 |
I'm working on a plugin for Revit. Revit permits only dll type addins and I chose c# and wpf for gui. I couldn't initialize wpf natively so I needed to contain it in a system.windows.window as content.
Now if I close that window with upper right X program continues (looping processing etc.) it doesn't get terminated. Window.close() again just closes the window not the application it self.
How should I exit my app and not keep it lurking in the shadows?
```
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
public class FDNMain : IExternalCommand
{
public Result Execute(ExternalCommandData CommandData, ref string message, ElementSet elements)
{
FDNControl wpfControl = new FDNControl();
return Result.Succeeded;
}
}
```
Above is the Revit external command class which cannot initialize (show up) the wpfControl. So I need to wrap the wpfcontrol with a System.Windows.Window as below:
```
Window hostWindow = new Window();
hostWindow.Content = wpfControl;
hostWindow.Show();
```
|
2016/01/06
|
[
"https://Stackoverflow.com/questions/34640668",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4338414/"
] |
Unfortunately I don't know how to do this without any existing form. But I'm sure you have some kind of main form you can access. Or you can obtain a `Form` using
```
var invokingForm = Application.OpenForms[0];
```
So you can change the code of your method like this:
```
static void OnNewMessage(object sender, S22.Xmpp.Im.MessageEventArgs e)
{
var invokingForm = Application.OpenForms[0]; // or whatever Form you can access
if (invokingForm.InvokeRequired)
{
invokingForm.BeginInvoke(new EventHandler<S22.Xmpp.Im.MessageEventArgs>(OnNewMessage), sender, e);
return; // important!!!
}
// the rest of your code goes here, now running
// on the same ui thread as invokingForm
if(CheckIfFormIsOpen(e.Jid.ToString(), e.Message.ToString()) == true)
{
}
else
{
newMessageFrm tempMsg = new newMessageFrm(e.Jid.ToString());
tempMsg._msgText = e.Jid.ToString() + ": " + e.Message.ToString();
tempMsg.frmId = e.Jid.ToString();
tempMsg.Show();
}
}
```
Note that I assumend that `S22.Xmpp.Im.MessageEventArgs` is inherited from `System.EventArgs`.
|
35,253,840 |
I am building an app which uploads files to the server via ajax.
The problem is that users most likely sometimes won't have the internet connection and client would like to have the ajax call scheduled to time when user have the connection back. This is possible that user will schedule the file upload when he's offline and close the app. Is it possible to do ajax call when the application is closed (not in background)?
When app is in the background, we can use background-fetch but I have never faced a problem to do something when app is closed.
|
2016/02/07
|
[
"https://Stackoverflow.com/questions/35253840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2008950/"
] |
The short answer is no, your app can't run code after being terminated.
You can run code in your `AppDelegate`'s `applicationWillTerminate`, but that method is mainly intended for saving user data and other similar tasks.
See [this answer](https://stackoverflow.com/a/32225247/5389870) also.
|
26,556 |
I am wanting to write a chess engine (see here: [Creating chess engine, machine learning vs. traditional engine?](https://chess.stackexchange.com/questions/26489/creating-chess-engine-machine-learning-vs-traditional-engine)). The first step I am doing is taking a position in as an FEN and converting this position into an ideal move. Pseudocode would look something like this:
`Position → Move`
or using notation:
`rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 → e4`
I am trying to create an enumeration of every possible chess move, and I feel that I may be missing some. This includes moves like "e4", "Nxf5", "Bg3+", "Qxh4#", "exf8N#". My total count of unique moves that can be expressed using algebraic notation is **1884**. Can anybody confirm the total number of unique moves that can be expressed using algebraic notation? My full list of moves can be found here: <https://pastebin.com/xDNqbFt2>
|
2019/10/08
|
[
"https://chess.stackexchange.com/questions/26556",
"https://chess.stackexchange.com",
"https://chess.stackexchange.com/users/19802/"
] |
I immediately notice that you've missed the castling moves (O-O and O-O-O).
I would list the pawn-promoting moves according to their PGN syntax (=Q/R/N/B suffix), as that's the most commonly used in computer chess.
Algebraic notation can be ambiguous for sliding and leaping pieces (everything except pawn and king, actually) which may require specifying the origin rank, file, or both. The latter is only needed for queens, bishops and knights, as rooks are always disambiguated by one or the other.
It might be useful to treat the suffix codes indicating whether the move results in check or checkmate as orthogonal to the move itself, since pretty much any move can theoretically have those results. This would effectively divide the number of unique moves you need to handle by three. Conversely, the different promotions of a pawn definitely should be considered as unique moves.
|
988,147 |
Can one give an example of an abelian Banach algebra with empty character space? Such algebra must be necessarily non-unital.
I couldn't find any examples of such algebras.
Thanks!
|
2014/10/23
|
[
"https://math.stackexchange.com/questions/988147",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/186437/"
] |
The [Volterra algebra](http://mathworld.wolfram.com/VolterraAlgebra.html) $V$ is an example of a commutative Banach algebra without maximal ideals (hence with empty character space). See also Definition 4.7.38 in
>
> H. G. Dales, *Banach algebras and automatic continuity*, London Math. Soc.
> Monographs, Volume 24, Clarendon Press, Oxford, 2000.
>
>
>
Okay, let me prove this claim. This relies on three facts:
The algebra $V$ has a bounded approximate identity, *e.g.* $(n\cdot \mathbf{1}\_{\big[0, \tfrac{1}{n}\big]})\_{n=1}^\infty$, hence by the [Cohen factorisation theorem](http://en.wikipedia.org/wiki/Cohen%E2%80%93Hewitt_factorization_theorem), $V = V^2$. Consequently, [all maximal ideals of $V$ (if exist) are closed](https://math.stackexchange.com/questions/859247/maximal-ideals-and-maximal-subspaces-of-normed-algebras/863704#863704).
Now apply a result of Dixmier which tells you that no prime ideal of $V$ is closed. Of course, maximal ideals are prime so, the conclusion follows. You will find the proof of Dixmier's result in the above-mentioned book by Dales (Theorem 4.7.58).
|
59,699,155 |
Now I started studying Angular, I was doing a simple exercise, but I had a giant doubt.
I have two components (Navbar and app), in navbar I present one that returns me the value 5. In the component app, by clicking the EXECUTE button, I want the value displayed in Navbar to 4 (-1). Is there a way to do this or make an event emitter that I pressed the EXECUTE button on the app component and thus perform a function on the navbar that allows me to reduce the number 5 to 4?
Thank you !
**[DEMO](https://stackblitz.com/edit/angular-vc5ndg?file=src%2Fapp%2Fnavbar%2Fnavbar.component.ts)**
**Navbar component**
```
total:any;
number = 5;
constructor() { }
ngOnInit() {
this.GetNumber();
}
GetNumber(){
this.total = this.number - 1;
}
```
|
2020/01/11
|
[
"https://Stackoverflow.com/questions/59699155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12696698/"
] |
In your case, the "button" and the component are in the same .html -and in the same `<router-outlet></router-outlet>` you only need a [template reference variable](https://angular.io/guide/template-syntax#template-reference-variables-var)
```
<app-navbar #navbar></app-navbar>
<p>My APP COMPONENT</p>
<button (click)="getNumber(navbar)">Execute Function</button>
```
Your getNumber function has access to all the properties or functions of your navbar,e.g.
```
getNumber(navbar:any){
navbar.getNumber()
console.log(navbar.number)
}
```
(\*)NOTE: I use the recomender notation to named functions using camelCase and only use a named in Capitalize when we defined a Class
If you use a service, you need inject in constructor of the two components the service, see [interaction using a service](https://angular.io/guide/component-interaction#parent-and-children-communicate-via-a-service), The idea using a service is that one component call a method of service that emit a value and in the other component we subscribe to the service to get the value emited, see [SO answer](https://stackoverflow.com/questions/40788458/how-to-call-component-method-from-service-angular2/57669031#57669031)
|
83,697 |
Everybody needs a leisure activity. Most of the books I need for mine are downstairs, with none in the bedroom. But as I like to keep an eye on things I have this (unsorted) pile by my bed to remind me.
**What's my hobby?**
[](https://i.stack.imgur.com/KfTm8.jpg)
**Hint 1**
>
> Did you notice the hint in the question?
>
>
>
**Hint 2**
>
> Don't worry too much about the knowledge tag. You don't need any external knowledge at all to work out the answer, and once you have it you should be able to validate it with minimal research.
>
>
>
**Hint 3**
>
> No anagrams were used in the making of this puzzle. And it's nothing to do with beds or bedrooms.
>
>
>
|
2019/05/06
|
[
"https://puzzling.stackexchange.com/questions/83697",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/58787/"
] |
Your hobby is
>
> **birdwatching** (hinted by the word "hobby" and the reference to "keeping an eye on things").
>
>
>
We have:
>
> The Four **Feathers**
>
> What is the name of this book? (published by **Pelican**)
>
> Poems of Matthew **Arnold** -- "Arnold" means something like "strength of the eagle", etymologically.
>
> The Annotated Snark edited by **Martin** Gardner
>
> The Testament of Mary by **Colm** Tóibín -- "Colm" means "dove".
>
> I have Landed by Stephen **Jay** Gould
>
> Life ... by **Robin** Skynner and John Cleese
>
> **Lore** & Language ... -- "lore", among several other meanings, means a particular portion of a bird's head
>
> Life and Times of the Thunderbolt Kid by **Bill** Bryson
>
>
>
Explanations that I proposed, apparently *aren't* the intended ones, but seem worth recording:
>
> Matthew Arnold: one poem is called **Philomena** (= nightingale), and the introduction in that edition is by Sir Arthur **Quiller**-Couch (quiller = not-fully-fledged young bird).
>
> Testament of Mary: I wondered whether it was the **Penguin** edition of that play.
>
> Lore and language...: O**pie** (pie = magpie, near enough), **Peter** (first name of one of the two Opies who wrote the book; it denotes the call of certain birds), and **Iona** (first name of other author), the famous island sharing whose name is strongly associated with St **Columba** (meaning dove).
>
>
>
|
1,687 |
Editing a question has the effect of bumping it on top of the front page.
Should we limit the number of edits done on old questions? Bumping forty old questions in the front page has just the effect to hide the newest questions.
I am asking the question because something I observed between today, and yesterday. I am not putting the blame on who is editing questions; I am wondering if we should not schedule those activities, in the same way it has been done in a different SE site.
|
2011/07/29
|
[
"https://english.meta.stackexchange.com/questions/1687",
"https://english.meta.stackexchange.com",
"https://english.meta.stackexchange.com/users/252/"
] |
Are you referring to JSBangs removing a tag from 40 different questions? That's the only thing I see at the moment, scrolling down.
If you need to remove a lot of tags, **you should post a request here on meta,** since developers have the ability to destroy tags without causing revisions.
So the mistake in this case is deciding to manually remove a tag with too many questions.
|
6,902,467 |
In some programming API's I see a list of methods to call, like getBoolean(String key, getDouble(String key), and getString(String key). Some other API's use a general get(String key) method, and return an Object which you are supposed to cast to an appropriate type yourself.
Now I am writing my own data accessing point, and I am wondering which approach to use. What are the advantages and disadvantages of each approach? When would you choose one over the other?
|
2011/08/01
|
[
"https://Stackoverflow.com/questions/6902467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/789939/"
] |
Advantage: getBoolean(), getDouble(), etc. allow you to return the respective primitive types. As far as I've seen, that's the primary reason anyone writes methods like that.
|
12,766,528 |
I want to create a function object, which also has some properties held on it. For example in JavaScript I would do:
```
var f = function() { }
f.someValue = 3;
```
Now in TypeScript I can describe the type of this as:
```
var f: { (): any; someValue: number; };
```
However I can't actually build it, without requiring a cast. Such as:
```
var f: { (): any; someValue: number; } =
<{ (): any; someValue: number; }>(
function() { }
);
f.someValue = 3;
```
How would you build this without a cast?
|
2012/10/07
|
[
"https://Stackoverflow.com/questions/12766528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/664175/"
] |
Update: This answer was the best solution in earlier versions of TypeScript, but there are better options available in newer versions (see other answers).
The accepted answer works and might be required in some situations, but have the downside of providing no type safety for building up the object. This technique will at least throw a type error if you attempt to add an undefined property.
```
interface F { (): any; someValue: number; }
var f = <F>function () { }
f.someValue = 3
// type error
f.notDeclard = 3
```
|
3,059,019 |
INFORMIX-SQL or any other SQL-based DB:
Suppose I have an app where depending on the value of some columns, example:
```
company.code char(3) {abc}
company.branch char(2) {01}
```
Can I construct table name "abc01" for inclusion in SELECT \* FROM abc01; ?
In other words, a variable table name.. same question applies for column names.
|
2010/06/17
|
[
"https://Stackoverflow.com/questions/3059019",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/366797/"
] |
Only in a language which can manipulate character strings and handle Dynamic SQL. It has to create the statement on the fly.
You can only use placeholders in queries for values, not for the structural elements of the query such as the table name or column name.
|
29,549,905 |
I am trying to create a simple 3D scatter plot but I want to also show a 2D projection of this data on the same figure.
This would allow to show a correlation between two of those 3 variables that might be hard to see in a 3D plot.
I remember seeing this somewhere before but was not able to find it again.
Here is some toy example:
```
x= np.random.random(100)
y= np.random.random(100)
z= sin(x**2+y**2)
fig= figure()
ax= fig.add_subplot(111, projection= '3d')
ax.scatter(x,y,z)
```
|
2015/04/09
|
[
"https://Stackoverflow.com/questions/29549905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1130635/"
] |
You can add 2D projections of your 3D scatter data by using the `plot` method and specifying `zdir`:
```
import numpy as np
import matplotlib.pyplot as plt
x= np.random.random(100)
y= np.random.random(100)
z= np.sin(3*x**2+y**2)
fig= plt.figure()
ax= fig.add_subplot(111, projection= '3d')
ax.scatter(x,y,z)
ax.plot(x, z, 'r+', zdir='y', zs=1.5)
ax.plot(y, z, 'g+', zdir='x', zs=-0.5)
ax.plot(x, y, 'k+', zdir='z', zs=-1.5)
ax.set_xlim([-0.5, 1.5])
ax.set_ylim([-0.5, 1.5])
ax.set_zlim([-1.5, 1.5])
plt.show()
```

|
827,893 |
I have two menu items for dir, mark, regexp, multiple and single on the menu bar in dired mode. While it doesn't affect the usage, but it seems something is wrong and makes me feel uncomfortable. Anyone know what is the cause?
Thank you very much!
|
2014/10/17
|
[
"https://superuser.com/questions/827893",
"https://superuser.com",
"https://superuser.com/users/380371/"
] |
Do you see this problem already with `emacs -Q`?
If not, then try to see which part of your config file triggers this problem.
|
32,626,809 |
I'm looking for a way to map "emacs" to "emacs -nw" in powershell. I tried this (screenshot below), and it adds it as an alias, but it doesn't work. However, the command "emacs -nw" works before setting the alias.
[](https://i.stack.imgur.com/q4HkM.png)
And I also want a way to save that alias for future sessions (restarting the powershell gets me back to square zero)
EDIT:(aditional info)
Also tried creating a function, but when calling that function powershell freezes for a while, then I get the following message (screenshot below)
[](https://i.stack.imgur.com/PMnc0.png)
EDIT2:(aditional info)
At first, `function enw {emacs.exe -nw}` (changed function name to 'enw' for explanation purposes) seems to work. But then there's a problem. For the standard emacs, I can type `emacs -nw filename.txt`, and that would open the file `filename.txt` in `emacs -nw`. Calling the function `enw filename.txt` will not open the `filename.txt` file, providing the same result as just typing `enw`.
The solution to this is `function enw {Param($myparam) emacs.exe -nw $myparam}`
|
2015/09/17
|
[
"https://Stackoverflow.com/questions/32626809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3603899/"
] |
try creating a function:
```
function emacs {emacs.exe -nw}
```
then add it to your powershell profile ( `$profile` )
|
48,583,446 |
Which one is better: having a BLOB field in the same table or having a 1-TO-1 reference to it in another table?
I'm making a MySQL database whose main table is called item(ID, Description). This table is consulted by a program I'm developing in VB.NET which offers the possibility to double-click a specific item obtained with a query. Once opened its dedicated form, I would like to show an image stored in the BLOB field, a sort of item preview. The problem is I don't know where is better to create this BLOB field.
Assuming to have a table like this: Item(ID, Description, BLOB), will the BLOB field affect the database performance on queries like:
```
SELECT ID, Description FROM Item;
```
If yes, what do you think about this solution:
```
Item(ID, Description)
Images(Item, File)
```
Where Images.Item references to Item.ID, and File is the BLOB field.
|
2018/02/02
|
[
"https://Stackoverflow.com/questions/48583446",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3802998/"
] |
You can add the BLOB field directly to your main table, as BLOB fields are not stored in-row and require a separate look-up to retrieve its contents. Your dependent table is needless.
BUT another and preferred way is to store on your database table only a pointer (path to the file on server) to your image file. In this way you can retrive the path and access the file from your VB.NET application.
|
30,540,835 |
I am struggling with a problem big time and just can't see how it can be done... so any help appreciated from you SQL gurus!
What I have now is a table like this:
```
Sticker Price Cash Price Credit Price Value
Yes Yes NULL 107
NULL Yes NULL 115
Yes Yes NULL 127
```
And what I need to do is construct a table (flipped) to show :
```
Text Value IsDefault
Sticker Price Sticker 1
Cash Price Cash 0
```
And do not show Credit Price because all values were NULL in the first table.
Basically I want to only show Sticker if it's not all NULL, Cash if it's not all NULL, etc...
I thought of pivot but just cant work my head round it!!!
Currently I have this to give the top table:
```
SELECT SH1.[Sticker Price], SH1.[Credit Price], SH1.[Cash Price], SH1.[Credit Price], UG.Description as Value,
CASE ROW_NUMBER() OVER(ORDER BY UG.Description)
WHEN 1 THEN 1 ELSE 0 END as ISDEFAULT
FROM [uStore].[dbo].[ACL_UserGroup] UG
INNER JOIN [uStore].[dbo].[ACL_UserGroupMembership] UGM ON UG.UserGroupId = UGM.UserGroupId
INNER JOIN [XMPDBHDS].[XMPieHDSSchema60].[Sheet1] SH1 ON CONVERT(nvarchar(100), SH1.[Centre Code]) = UG.Description
WHERE UGM.UserId = 1012
```
I just can't see how I can get the table I want from this with my limited SQL knowledge...
|
2015/05/30
|
[
"https://Stackoverflow.com/questions/30540835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4955095/"
] |
What do you mean by "any subsequent errors then end up failing silently"? If the original promise `rp` fails, the `catch` executes… *at the time of failure.* Once a promise is rejected, that's it, there can be no "subsequent errors."
Also, `should` looks like an assertion (e.g. from `chai`) which would suggest that you are trying to test this. Chai's `should.throw` doesn't throw an error, it checks that an error has been thrown. If you are testing this, you need to indicate to the test (`it` block) that the test is async, not sync — usually by naming & invoking a `done` parameter. Otherwise, the request will be sent out, and then before ANY response can be made, the script will synchronously end and no errors will be listened for.
What's more, you are spec'ing that something should `throw` to console, but nothing in your code `throw`s! If you DID write in a `throw`, you should understand that `throw` inside a `then` or `catch` will simply cause the outgoing promise from that handler to be rejected with the thrown value (yes, `catch` exports a new promise, just like `then` — it is 100% sugar for `.then(null, errHandler)`. If you want errors to be re-thrown back into the window, you need to finalize the chain with Bluebird's `.done()` promise method, accessed in request-promise via the somewhat arcane `.promise().done()`. But even in that case you'd still need to specify that you're doing an async test.
In short, it's not entirely clear what you think some of this code is supposed to be doing, and how it differs from your expectations. Please clarify!
```
var rp = require('request-promise');
rp.get({ // start an async call and return a promise
uri: 'http://httpstat.us/500',
transform: function(body, res){
res.data = JSON.parse(body);
return res;
}
}).then(function(res){ // if rp.get resolves, push res.data
results.push(res.data);
})
.catch(function(err){ // if rp.get rejects (e.g. 500), do this:
should.throw.error.to.console(); // test if something is thrown (but nothing has been!)
var respErr = JSON.parse(err.error);
var errorResult = {
origUrl: respErr.origUrl,
error: respErr
};
results.push(errorResult); // push an object with some of the error info into results
});
// this line (e.g., end of script) is reached before any of the async stuff above settles. If you are testing something, you need to make the test async and specify when it's complete by invoking `done()` (not the same as ending the promise chain in Bluebird's `.done()`).
```
|
54,617,134 |
The problem is incorrect path to remote host, but is not true. I have acces to my server via ftp without problems. All WP files are there and the site is working fine (frontend/backent). I have also access to phpMyAdmin to MySQL datepase binded to this site.
I have notce that paht to the web files is differ depend on FTP or SFTP is. In FTP app is such stright:
```
/[all wp files]
```
in editor app (such TextWrangler), after the samy access id/pass, I have got such path:
```
/home/[accountname]/public_html/[all wp files]
```
After click on detect button, app changing the path filed on:
- *blanc* - under FTP connection
or
- *public\_html* - under SFTP
so it mean conection between MAMP and my server is working. Fine. But after this when I trying to Check URLs & credentials or when I trying Import Host... I received:
**Error code: -3010** (The 'Path' to your remote document root is incorrect. The 'Path' field on the remote tab is the document root of your remote site that will be accessed via your Public Site URL (e.g.: 'public\_html').) - Start auto detect not solved the problem.
or
**Error code: -3113** (The 'Path' to your remote document root is incorrect. The 'Path' field on the remote tab is the document root of your remote site that will be accessed via your Public Site URL (e.g.: 'public\_html').)
**But it is not true!** All files are there!
Please help. Should I use some special code under Apache tab (Additional parameters for VirtualHost directive or Directory directive?
Should I know something more from my serverprovider (home.pl) and solved this problem with them (there is no, in my subscription plan, access via cPanel or so, to set up something)?
Should I change something in https.conf file?
I'm not so using server coding so please forgive me but I have no idea where is the problem (but I'm trying to learn) :o)
My environment is:
MacOS X: 10.13.6
MAMP Pro: 5.2.2 (17923)
Thanx for any help or redirection to the answers someware else (I used searching ;o) but without success or I used wrong ask).
|
2019/02/10
|
[
"https://Stackoverflow.com/questions/54617134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11041089/"
] |
relative pathes resolved by current directory. Solutions: Get script directory and combine with the relative path, something like:
```
require(dirname(__FILE__).'/../../../app.config.php');
```
|
24,217,412 |
I am in the process of making a simple racing game using Apple's SceneKit library. I have modeled a left turn section of the race track. I am able to successfully load the model into an SCNGeometry that I can then render. However, I would like to be able to use this model for both a left and right turn segment. To do this, I need to mirror the SCNGeometry over the y-z plane, though I can't for the life of me figure out how.
In SpriteKit, one can mirror a sprite by setting the corresponding SKNode's scale to -1. However, if I set the SCNGeometry's SCNNode's x scale to -1, the SCNGeometry will not render at all. While I can mirror the model in my modeling software, I would prefer not to have two basically identical models. Any suggestions would be appreciated.
|
2014/06/14
|
[
"https://Stackoverflow.com/questions/24217412",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2351182/"
] |
Alright, turns out setting the SCNNode's x scale to -1 does in fact mirror the SCNGeometry.The issue is, when an SCNGeometry is mirrored that way, all of the faces are pointed inwards instead of outwards so none are rendered. If the object's material is changed so that the front faces are culled instead of the back faces, the SCNGeometry will be mirrored as expected.
|
71,321 |
My daughter is 8 and has been taking private piano lessons for around 3 months now but will take a break from lessons over the summer. In the fall (when school starts back up) she will be taking cello lessons at school.
What if anything can I do with her over the summer on the piano that will help prepare her or make learning the cello easier come fall?
She is learning to read (both treble and bass clef since she is playing the piano) and I have started doing some ear training games with her, but I am looking for more and am open to suggestions.
The ear training we have been doing is very basic so far, all diatonic, I play I, IV, V to get the key in her ear and then play DO and another note and she has to tell me what note it is.
(I studied music in school, and play the drums and Guitar, just so you know my background. I do not have any experience with classic instruments like the cello and have never played a fretless string instrument.)
|
2018/05/25
|
[
"https://music.stackexchange.com/questions/71321",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/10492/"
] |
I have a couple of thoughts. First, she will be reading primarily bass clef for cello, so any drilling of those notes in particular will be useful. Also, help her to "forget" her piano fingering. I have piano students who play stringed instruments and discussing fingering is such a pain. I wish there was a universal fingering system! "1" on piano is thumb. "1" on cello is index finger, and so on. You could make or purchase flash cards to help with note reading. You can do a lot of rhythm games as well.
|
2,042,775 |
Solve the following recurrence relation by examining the first few values for a formula and then prove your conjectured formula by induction
$h\_n=h\_{n-1} -n+3, \ (n\geq 1); \ h\_0=2$
---
Here I've gone all the way to $n=8$ and the only pattern I've noticed is in the differences. By that I mean,
---
$h\_0=2$
$h\_1=2-1+3=4;$ $\ \ \ \ $from $h\_1$ to $h\_0$ there's a difference of $+2$
$h\_2=4-2+3=5;$$\ \ \ \ $from $h\_2$ to $h\_1$ there's a difference of $+1$
$h\_3=5-3+3=5;$$\ \ \ \ $from $h\_3$ to $h\_2$ there's a difference of $+0$
$h\_4=5-4+3=4;$$\ \ \ \ $from $h\_4$ to $h\_3$ there's a difference of $-1$
$h\_5=4-5+3=2;$$\ \ \ \ $from $h\_5$ to $h\_4$ there's a difference of $-2$
$h\_6=2-6+3=-1;$$\ \ \ \ $from $h\_6$ to $h\_5$ there's a difference of $-3$
$h\_7=-1-7+3=-5;$$\ \ \ \ $from $h\_7$ to $h\_6$ there's a difference of $-4$
$h\_8=-5-8+3=-10;$$\ \ \ \ $from $h\_8$ to $h\_7$ there's a difference of $-5$
---
I'm not really sure what this means as far as the formula goes though
Note: I'm only struggling with coming up with the formula. I can handle the induction.
|
2016/12/04
|
[
"https://math.stackexchange.com/questions/2042775",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/373431/"
] |
You noticed the pattern examining the first few values and noticed that the difference between successive terms varies as a linear function of $n$.
If you make an analogy with derivatives, this seesm to mean that the terms vary as a quadratic function of $n$.
|
47,949,328 |
I'm trying to pass a json script to curl using powershell. It seems to work if I hard code it right into a variable escaping the double quotes with backslash, but I want to pass the json in a file. I tried putting the json script in a separate json file and then use get-content and throw it in a variable, but it does not seem to work I get a "Validation\_Error". Any suggestions
This Works
[](https://i.stack.imgur.com/JEHdc.png)
But I want to do something like this
$json = Get-Content C:\test.json
curl -v -X POST <https://api.paypal.com/v1/invoicing/invoices/> \ -H "Content-Type:application/json" \ -H "Authorization: Bearer $token" \ -d $json
|
2017/12/23
|
[
"https://Stackoverflow.com/questions/47949328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4352563/"
] |
Try:
```
$json = Get-Content C:\test.json -Raw
```
By default `Get-Content` loads into an array of strings. The `-Raw` flag forces it to load into a single string.
You should also be able to do this and tell curl to read the file itself:
```
curl -v -X POST https://[...] -d @test.json
```
From the man page:
>
> If you start the data with the letter @, the rest should be a file name to read the data from[.]
>
>
>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.