qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
37,295,383 | When I run the script, the browser proceeds to perpetually open new tabs until I end the process in the task manager. Shouldn't this loop only open the browser once? Even if you ignore the while loop and only focus on the browser request I get the same behavior. Does this have to do with the try/catch? What's going wro... | 2016/05/18 | [
"https://Stackoverflow.com/questions/37295383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4077513/"
] | If you want to execute the try/catch block only once in `while` you should put the `doOnce` in your finally block :
```
try
{
d.browse(...);
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
doOnce = true;
}
```
but if you want to exit from `while` when a... | ```
try
{
d.browse(...);
doOnce = true;
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
```
If your call to `browse` above raises an exception, you will never set the exit flag.
Why are you doing this in a loop? If your intent is to only do this step once, ... |
67,133,252 | I am relatively new using R, I wanted to create a new column called Reporting Month (with format: Date) for my table using "case when" statement and the condition is using a column called Period (with format: Character)
The codes executed but the output of the dates only range from 31/01/2020 to 31/12/2020, nothing for... | 2021/04/16 | [
"https://Stackoverflow.com/questions/67133252",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15665483/"
] | ```
library(lubridate)
dt %>% mutate(
Reporting_Month = ceiling_date(dmy(str_replace(Period, 'ZZZ', '01')), unit = 'month') - days(1))
Period Reporting_Month
1 ZZZ-APRIL-2019 2019-04-30
2 ZZZ-OCTOBER-2019 2019-10-31
3 ZZZ-JULY-2020 2020-07-31
4 ZZZ-DECEMBER-2021 2021-12-31
... | You can change the `Period` to `yearmon` class and then to Date with `frac = 1` to get last day of the month.
```
library(dplyr)
library(zoo)
dt %>% mutate(Reporting_Month = as.Date(as.yearmon(Period,'ZZZ-%b-%Y'),frac = 1))
# Period Reporting_Month
#1 ZZZ-MARCH-2019 2019-03-31
#2 ZZZ-JUNE-201... |
4,473,360 | Hey I am trying to do a sub query that allows me to get a count of something by grouping, then basically un-group and select a certain amount of rows based on the count I just got. This query is basically what I want if SQL would allow something like a contains() method or something.
```
select cat, mouse
from pets
wh... | 2010/12/17 | [
"https://Stackoverflow.com/questions/4473360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/154619/"
] | ```
select cat, mouse
from pets
where cat in (select cat
from pet
group by cat
having count(mouse) > 3);
```
Change '= 'to 'in'
The in keyword is what this is made for. | Not that it's horribly wrong to use an in subquery, but an approach using analytic functions usually performs a lot better for this sort of self-joining query.
```
select cat, mouse from
(
select cat, mouse, count(mouse) over(partition by cat) as ct
)
where ct = 3
``` |
72,529,328 | I've been looking at trying out rundeck but what I've found is that the project is kind of abandoned?
The github material is all abandoned and deprecated and there is no comprehensive guides for rundeck anywhere to be found.
Does anyone know what happened to this project? Is it only enterprise paying customer support t... | 2022/06/07 | [
"https://Stackoverflow.com/questions/72529328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17551265/"
] | I'm curious why you think the project is abandoned? The repo at <https://github.com/rundeck/rundeck> is quite active. We have releases every 3-4 weeks with release notes documented here: <https://docs.rundeck.com/docs/history/>. These release notes cover fixes and enhancements to both our Open Source and Commercial pro... | The project is still alive, you can follow all changes [here](https://github.com/rundeck/rundeck/pulls). Regarding the image tag you can use `SNAPSHOT` to get the last one, e.g: `rundeck/rundeck:SNAPSHOT` or just specify the latest stable version `rundeck/rundeck:4.3.1` at this moment.
You can see a lot of docker exam... |
1,248,634 | I want to exclude all directories from my search in PowerShell. Both `FileInfo` and `DirectoryInfo` contain `Attributtes` property that seems to be exactly what I want, but I wasn't able to find out how to filter based on it. Both
```
ls | ? { $_.Attributes -ne 'Direcory' }
ls | ? { $_.Attributes -notcontains 'Direcor... | 2009/08/08 | [
"https://Stackoverflow.com/questions/1248634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41071/"
] | You can use the `PSIsContainer` property:
```
gci | ? { !$_.PSIsContainer }
```
Your approach would work as well, but would have to look like this:
```
gci | ? { !($_.Attributes -band [IO.FileAttributes]::Directory) }
```
as the attributes are an enum and a bitmask.
Or, for your other approach:
```
gci | ? { "$... | You can also filter out directories by looking at their type directly:
```
ls | ?{$_.GetType() -ne [System.IO.DirectoryInfo]}
```
Directories are returned by get-childitem (or ls or dir) of type System.IO.DirectoryInfo, and files are of type System.IO.FileInfo. When using the types as literals in Powershell you need... |
1,248,634 | I want to exclude all directories from my search in PowerShell. Both `FileInfo` and `DirectoryInfo` contain `Attributtes` property that seems to be exactly what I want, but I wasn't able to find out how to filter based on it. Both
```
ls | ? { $_.Attributes -ne 'Direcory' }
ls | ? { $_.Attributes -notcontains 'Direcor... | 2009/08/08 | [
"https://Stackoverflow.com/questions/1248634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41071/"
] | You can use the `PSIsContainer` property:
```
gci | ? { !$_.PSIsContainer }
```
Your approach would work as well, but would have to look like this:
```
gci | ? { !($_.Attributes -band [IO.FileAttributes]::Directory) }
```
as the attributes are an enum and a bitmask.
Or, for your other approach:
```
gci | ? { "$... | ### Exclude directories in PowerShell:
```
Get-ChildItem | Where-Object {$_ -isnot [IO.DirectoryInfo]}
```
Or it's terse, but harder to read version:
```
gci | ? {$_ -isnot [io.directoryinfo]}
```
Credit goes to @Joey for his insightful comment using the `-is` operator :)
### However
Technically, I prefer *incl... |
1,248,634 | I want to exclude all directories from my search in PowerShell. Both `FileInfo` and `DirectoryInfo` contain `Attributtes` property that seems to be exactly what I want, but I wasn't able to find out how to filter based on it. Both
```
ls | ? { $_.Attributes -ne 'Direcory' }
ls | ? { $_.Attributes -notcontains 'Direcor... | 2009/08/08 | [
"https://Stackoverflow.com/questions/1248634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41071/"
] | You can use the `PSIsContainer` property:
```
gci | ? { !$_.PSIsContainer }
```
Your approach would work as well, but would have to look like this:
```
gci | ? { !($_.Attributes -band [IO.FileAttributes]::Directory) }
```
as the attributes are an enum and a bitmask.
Or, for your other approach:
```
gci | ? { "$... | Timings for different approaches, times of 5000 itarations on a short dir / 25 iterations on System32 dir. Measuring is done using:
```
(measure-command { for ($i=0;$i -lt 5e3;$i++) {
$files= gci | ? { !$_.PSIsContainer } # this is target to measure
} } ).totalmilliseconds
```
Results from slowest to fast... |
1,248,634 | I want to exclude all directories from my search in PowerShell. Both `FileInfo` and `DirectoryInfo` contain `Attributtes` property that seems to be exactly what I want, but I wasn't able to find out how to filter based on it. Both
```
ls | ? { $_.Attributes -ne 'Direcory' }
ls | ? { $_.Attributes -notcontains 'Direcor... | 2009/08/08 | [
"https://Stackoverflow.com/questions/1248634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41071/"
] | ### Exclude directories in PowerShell:
```
Get-ChildItem | Where-Object {$_ -isnot [IO.DirectoryInfo]}
```
Or it's terse, but harder to read version:
```
gci | ? {$_ -isnot [io.directoryinfo]}
```
Credit goes to @Joey for his insightful comment using the `-is` operator :)
### However
Technically, I prefer *incl... | You can also filter out directories by looking at their type directly:
```
ls | ?{$_.GetType() -ne [System.IO.DirectoryInfo]}
```
Directories are returned by get-childitem (or ls or dir) of type System.IO.DirectoryInfo, and files are of type System.IO.FileInfo. When using the types as literals in Powershell you need... |
1,248,634 | I want to exclude all directories from my search in PowerShell. Both `FileInfo` and `DirectoryInfo` contain `Attributtes` property that seems to be exactly what I want, but I wasn't able to find out how to filter based on it. Both
```
ls | ? { $_.Attributes -ne 'Direcory' }
ls | ? { $_.Attributes -notcontains 'Direcor... | 2009/08/08 | [
"https://Stackoverflow.com/questions/1248634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41071/"
] | You can also filter out directories by looking at their type directly:
```
ls | ?{$_.GetType() -ne [System.IO.DirectoryInfo]}
```
Directories are returned by get-childitem (or ls or dir) of type System.IO.DirectoryInfo, and files are of type System.IO.FileInfo. When using the types as literals in Powershell you need... | Timings for different approaches, times of 5000 itarations on a short dir / 25 iterations on System32 dir. Measuring is done using:
```
(measure-command { for ($i=0;$i -lt 5e3;$i++) {
$files= gci | ? { !$_.PSIsContainer } # this is target to measure
} } ).totalmilliseconds
```
Results from slowest to fast... |
1,248,634 | I want to exclude all directories from my search in PowerShell. Both `FileInfo` and `DirectoryInfo` contain `Attributtes` property that seems to be exactly what I want, but I wasn't able to find out how to filter based on it. Both
```
ls | ? { $_.Attributes -ne 'Direcory' }
ls | ? { $_.Attributes -notcontains 'Direcor... | 2009/08/08 | [
"https://Stackoverflow.com/questions/1248634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/41071/"
] | ### Exclude directories in PowerShell:
```
Get-ChildItem | Where-Object {$_ -isnot [IO.DirectoryInfo]}
```
Or it's terse, but harder to read version:
```
gci | ? {$_ -isnot [io.directoryinfo]}
```
Credit goes to @Joey for his insightful comment using the `-is` operator :)
### However
Technically, I prefer *incl... | Timings for different approaches, times of 5000 itarations on a short dir / 25 iterations on System32 dir. Measuring is done using:
```
(measure-command { for ($i=0;$i -lt 5e3;$i++) {
$files= gci | ? { !$_.PSIsContainer } # this is target to measure
} } ).totalmilliseconds
```
Results from slowest to fast... |
25,232,590 | Here is a code snippet illustrating my question:
```
const float D = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};
```
Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25232590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219153/"
] | You could initialize A during dynamic initialization time as follows:
```
const float *init_a(float x_)
{
static float data[4];
for(unsigned i=0; i<4; ++i)
data[i]=sin(i*x_);
return data;
}
const float D=0.1f;
const float *A=init_a(D);
``` | You may use code generator to generate initialization code. That is, write program that will write your initialization code for you. You may actually calculate values at generation-time.
Remember that C++ allows placing `,` after last element. It's also isn't necessary to specify array size. These two things should ea... |
25,232,590 | Here is a code snippet illustrating my question:
```
const float D = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};
```
Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25232590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219153/"
] | You could initialize A during dynamic initialization time as follows:
```
const float *init_a(float x_)
{
static float data[4];
for(unsigned i=0; i<4; ++i)
data[i]=sin(i*x_);
return data;
}
const float D=0.1f;
const float *A=init_a(D);
``` | You could either use [boost.preprocessor](http://www.boost.org/doc/libs/1_43_0/libs/preprocessor/doc/index.html) and in particular the `BOOST_PP_ENUM` macro, like the example below:
```
#include <iostream>
#include <cmath>
#include <boost/preprocessor/repetition/enum.hpp>
#define SIZE 4
#define D 0.1
#define ORDER... |
25,232,590 | Here is a code snippet illustrating my question:
```
const float D = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};
```
Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25232590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219153/"
] | You could initialize A during dynamic initialization time as follows:
```
const float *init_a(float x_)
{
static float data[4];
for(unsigned i=0; i<4; ++i)
data[i]=sin(i*x_);
return data;
}
const float D=0.1f;
const float *A=init_a(D);
``` | Ok I just realized this doesn't actually answer the question, because it specifies "without having to write initialization function and call it somewhere in my program?" But I can't think of a convenient alternative.
```
template<size_t N>
std::array<float, N> GetLookupTable(float d)
{
std::array<float, N> table;
... |
25,232,590 | Here is a code snippet illustrating my question:
```
const float D = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};
```
Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25232590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219153/"
] | You could initialize A during dynamic initialization time as follows:
```
const float *init_a(float x_)
{
static float data[4];
for(unsigned i=0; i<4; ++i)
data[i]=sin(i*x_);
return data;
}
const float D=0.1f;
const float *A=init_a(D);
``` | >
> Imagine that global array A is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization time
>
>
>
Create a generator and pass it through `std::generate_n()` (or plain `std::generate()`).
```
#include <algorithm>
#include <ar... |
25,232,590 | Here is a code snippet illustrating my question:
```
const float D = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};
```
Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25232590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219153/"
] | You could initialize A during dynamic initialization time as follows:
```
const float *init_a(float x_)
{
static float data[4];
for(unsigned i=0; i<4; ++i)
data[i]=sin(i*x_);
return data;
}
const float D=0.1f;
const float *A=init_a(D);
``` | This first part is obsolete in C++14, but not long:
```
template<unsigned...>struct indexes { using type=indexes; };
template<unsigned Max, unsigned...Is>struct make_indexes:make_indexes<Max-1,Max-1,Is...>{};
template<unsigned...Is>struct make_indexes<0,Is...>:indexes<Is...>{};
template<unsigned Max>using make_indexes... |
25,232,590 | Here is a code snippet illustrating my question:
```
const float D = 0.1F;
const float A[4] = {sin(0*D), sin(1*D), sin(2*D), sin(3*D)};
```
Imagine that global array `A` is much longer and you don't want to do all of this repetitive typing. Is there a shorter way to initialize array A at compile or initialization... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25232590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/219153/"
] | You could initialize A during dynamic initialization time as follows:
```
const float *init_a(float x_)
{
static float data[4];
for(unsigned i=0; i<4; ++i)
data[i]=sin(i*x_);
return data;
}
const float D=0.1f;
const float *A=init_a(D);
``` | In case you `A` array will always stays the same and is very big, you can always write a short script, which calculates every value in array and output could be used in source code to have static initialization.
In case formula is simple, even MS Excel could be used to *generate* that kind of static initialization dat... |
51,940,070 | Image

I am trying to find the position of the rectangle in the image. Considering the top part of the image as reference, how can I find the position of the rectangle? I want the coordinates of the four vertices.
I have tried findContours and bounded rectangle method but have... | 2018/08/21 | [
"https://Stackoverflow.com/questions/51940070",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10252290/"
] | Just get contour and then find bounding rectangle. Check [this tutorial](https://docs.opencv.org/3.1.0/dd/d49/tutorial_py_contour_features.html) from official documentation.
```
import cv2
img = cv2.imread('image.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray, 80, 255, cv2.THRESH... | just adapting the [cv2 tutorial](https://docs.opencv.org/3.1.0/dd/d49/tutorial_py_contour_features.html), you can find the largest contour and then obtain its bounding rectangle.
```
img = cv2.imread('/home/kvnp/Desktop/v02J6.jpg',0) #read in the image with correct dtype
_,thresh = cv2.threshold(img,200,255,0) # thr... |
8,116 | Have an old(ish) laptop with a Pentium T4400 @ 2.20 GHz processor, and some old software1 that requires Windows 95 or NT.
With a view to running this software on that hardware, I tried installing Windows 95, 98, ME, 2000, and NT from CD-ROM with no success whatsoever.
Can it be a configuration problem? Which is the l... | 2018/11/01 | [
"https://retrocomputing.stackexchange.com/questions/8116",
"https://retrocomputing.stackexchange.com",
"https://retrocomputing.stackexchange.com/users/7265/"
] | Windows 2000 is the latest (5.0) version of NT. Last Update was 2005, EOL in 2010. The Laptop isn't anywhere near being old (or OT here), as its at maximum from 2010. While this seem late, it should be possible to install Win2k, update it to SP4 and include drivers for the Laptop from XP, as the original XP driver mode... | ### Windows XP Mode
Quite a bit of older software will NOT run natively in Windows 7 or above. However, most of this software, whether DOS-based or older Windows software, will run just fine in [Windows XP Mode.](https://www.microsoft.com/en-us/download/details.aspx?id=8002)
Unfortunately, Windows XP Mode is not avai... |
8,116 | Have an old(ish) laptop with a Pentium T4400 @ 2.20 GHz processor, and some old software1 that requires Windows 95 or NT.
With a view to running this software on that hardware, I tried installing Windows 95, 98, ME, 2000, and NT from CD-ROM with no success whatsoever.
Can it be a configuration problem? Which is the l... | 2018/11/01 | [
"https://retrocomputing.stackexchange.com/questions/8116",
"https://retrocomputing.stackexchange.com",
"https://retrocomputing.stackexchange.com/users/7265/"
] | Windows 2000 is the latest (5.0) version of NT. Last Update was 2005, EOL in 2010. The Laptop isn't anywhere near being old (or OT here), as its at maximum from 2010. While this seem late, it should be possible to install Win2k, update it to SP4 and include drivers for the Laptop from XP, as the original XP driver mode... | >
> IIRC, Windows 98 & ME are versions of 95, and 2000 is a version of NT? Later Windows versions are more different?
>
>
>
All modern windows is based on the "NT line", but of course it has evolved over the years and sometimes things break.
IIRC in terms of windows system stuff NT4->2K was a pretty big change, 2... |
8,116 | Have an old(ish) laptop with a Pentium T4400 @ 2.20 GHz processor, and some old software1 that requires Windows 95 or NT.
With a view to running this software on that hardware, I tried installing Windows 95, 98, ME, 2000, and NT from CD-ROM with no success whatsoever.
Can it be a configuration problem? Which is the l... | 2018/11/01 | [
"https://retrocomputing.stackexchange.com/questions/8116",
"https://retrocomputing.stackexchange.com",
"https://retrocomputing.stackexchange.com/users/7265/"
] | Windows 2000 is the latest (5.0) version of NT. Last Update was 2005, EOL in 2010. The Laptop isn't anywhere near being old (or OT here), as its at maximum from 2010. While this seem late, it should be possible to install Win2k, update it to SP4 and include drivers for the Laptop from XP, as the original XP driver mode... | You mention the processor but not the amount of memory installed. It's possible that it contains more RAM than older versions of Windows can deal with.
You could try using a virtual machine (VM) such as [VirtualBox](https://www.virtualbox.org) which can be configured to support older versions of Windows with a single ... |
121,258 | I am using
Avast free antivirus real time protection and weekly scan
Malwarebytes free anti malware weekly scan
Malwarebytes Anti-ransomware
EMET
good enough? Anything else I should do or choose another software? | 2016/04/22 | [
"https://security.stackexchange.com/questions/121258",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/100097/"
] | Malware is a fast evolving beast and their is no single solution which will protect you. But you can reduce the risk in various ways. First you need to know how the malware gets delivered:
* A major delivery vector for malware is mail, i.e. either as an attachment in the mail or mail which includes a link to some site... | Anti-virus software is useless. In fact, it is worse than useless because it gives you a false sense of security. Even Symantec, a major provider of AV software, has publicly admitted what all security pros know: AV is useless ([Symantec exec declares AV is "dead", WSJ 2014](http://www.wsj.com/news/articles/SB100014240... |
35,740,974 | In C# with Unity i am trying to create a Dictionary of Classes.
All the classes inherit from a base Class (Building Script) which has a number of Virtual Methods
i have set up my Dictionary thus:
```
Dictionary<string, BuildingScript> buildingScripts = new Dictionary<string, BuildingScript>();
```
And am trying to... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35740974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4163521/"
] | Your dictionary has been declared as `Dictionary<string, BuildingScript>`, so its value should be an **instance** of `BuildingScript`.
Consider difference: `FarmScript` itself is type, but `new FarmScript()` is instance of that type.
So your code should look like:
```
buildingScripts.Add("Farm", new FarmScript());
b... | Although not really shown in the posts, but they seem to be the classes to me:
```
FarmScript //class
HunterScript //class
FisherScript //class
```
while what you need are the instances:
```
FarmScript farmScript = new FarmScript(); //instances of the classes
HunterScript hunterScript = new HunterScript();
FisherSc... |
35,740,974 | In C# with Unity i am trying to create a Dictionary of Classes.
All the classes inherit from a base Class (Building Script) which has a number of Virtual Methods
i have set up my Dictionary thus:
```
Dictionary<string, BuildingScript> buildingScripts = new Dictionary<string, BuildingScript>();
```
And am trying to... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35740974",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4163521/"
] | Your dictionary has been declared as `Dictionary<string, BuildingScript>`, so its value should be an **instance** of `BuildingScript`.
Consider difference: `FarmScript` itself is type, but `new FarmScript()` is instance of that type.
So your code should look like:
```
buildingScripts.Add("Farm", new FarmScript());
b... | OK, solved it myself.... though if there are better ways of doing this (and i sure bet there are) then please post them so i can learn.
I changed the Add's to the Dictionary like this:
```
FarmScript bs1 = new FarmScript();
DictionaryStore.buildingScripts.Add("Farm", bs1);
HunterScript bs2 = new HunterScript();
Dicti... |
67,298 | I want to write my own custom file system in Linux. Can I share it over standard NFS without making any changes to the local NFS server? If so what VFS APIs are required to be implemented by my file system? Any other guidelines / gotchas for such an approach? | 2013/03/08 | [
"https://unix.stackexchange.com/questions/67298",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/33804/"
] | Yes. Once linux recognizes it as a filesystem and mounts it, it can be shared over NFS like any other filesystem, whether it's a hard drive, CD, USB stick, or even another NFS filesystem shared from somewhere else.
That's what abstraction layers are *for*. | That are two separate tasks:
1. Write a local filesystem for Linux
2. Export it via NFS
The second one is really (mostly) independent of the first one (if the kernel can mount it, it can be exported). The hard work is in the first point. And as lots of experiences with remote file systems have shown, full POSIX compl... |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | If you need to remove item use
```
list.remove(position)
adapter.notifyItemRemoved(position)
``` | Put the creation of item itself in an if statement.
Example:-
```
if ((viewModel.get(position).getTitle()) != null) {
holder.textView.setText(viewModel.get(position).getTitle());
}
``` |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | There are several ways of approaching this:
1. First, you can just hide the ViewHolder instance that is passed in onBindViewHolder(). RecyclerView doesn't care how you bind your data with UI. Just do stuffs and update your UI here in onBindViewHolder().
```
@Override
public void onBindViewHolder(ViewHolder holder, in... | If you need to remove item use
```
list.remove(position)
adapter.notifyItemRemoved(position)
``` |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | If you need to remove item use
```
list.remove(position)
adapter.notifyItemRemoved(position)
``` | Well, after some mistakes I finally got what I needed! I changed some strings in my ViewModel from:
```
for (IssueViewResponse.MessageItem message : response.getMessages()) {
this.messages.add(new MessageItem(message));
}
```
to:
```
for (IssueViewResponse.MessageItem message : response.getMessages(... |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | If you need to remove item use
```
list.remove(position)
adapter.notifyItemRemoved(position)
``` | check your list and if the current item is null or not. If it is, then remove the item from the list and call notifyDataSetChanged();
```
if ((android.get(position).getname())==null) {
pos = android.get(position);
android.remove(pos);
notify... |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | There are several ways of approaching this:
1. First, you can just hide the ViewHolder instance that is passed in onBindViewHolder(). RecyclerView doesn't care how you bind your data with UI. Just do stuffs and update your UI here in onBindViewHolder().
```
@Override
public void onBindViewHolder(ViewHolder holder, in... | Put the creation of item itself in an if statement.
Example:-
```
if ((viewModel.get(position).getTitle()) != null) {
holder.textView.setText(viewModel.get(position).getTitle());
}
``` |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | There are several ways of approaching this:
1. First, you can just hide the ViewHolder instance that is passed in onBindViewHolder(). RecyclerView doesn't care how you bind your data with UI. Just do stuffs and update your UI here in onBindViewHolder().
```
@Override
public void onBindViewHolder(ViewHolder holder, in... | Well, after some mistakes I finally got what I needed! I changed some strings in my ViewModel from:
```
for (IssueViewResponse.MessageItem message : response.getMessages()) {
this.messages.add(new MessageItem(message));
}
```
to:
```
for (IssueViewResponse.MessageItem message : response.getMessages(... |
45,096,495 | I have a RecyclerView and I need some `if statement` in my Adapter to make RecyclerView skip and do not create an item if one field in my ViewModel is empty. For example I have ViewModel with title and picture in it, so if the title is empty - do not create an item for it. So:
```
if (TextUtils.isEmpty(viewModel.getMe... | 2017/07/14 | [
"https://Stackoverflow.com/questions/45096495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6795368/"
] | There are several ways of approaching this:
1. First, you can just hide the ViewHolder instance that is passed in onBindViewHolder(). RecyclerView doesn't care how you bind your data with UI. Just do stuffs and update your UI here in onBindViewHolder().
```
@Override
public void onBindViewHolder(ViewHolder holder, in... | check your list and if the current item is null or not. If it is, then remove the item from the list and call notifyDataSetChanged();
```
if ((android.get(position).getname())==null) {
pos = android.get(position);
android.remove(pos);
notify... |
49,649,468 | In Ruby, What is the difference between `@@variable` to `self.variable`
1. In the scope of main.
2. In the scope of the class
3. In the scope of a method
For example my file looks like:
```
self.variable = 'data'
@@variable = 'data'
def class A
self.variable = 'data'
@@variable = 'data'
def method()
sel... | 2018/04/04 | [
"https://Stackoverflow.com/questions/49649468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6782134/"
] | ```
self.variable = 'data'
```
This is a method call at toplevel. The `self.` just distinguishes it as a method call versus a local variable definition. Assuming you have `def variable= x` somewhere, it will call that method. Otherwise it's a `NoMethodError`
```
@@variable = 'data'
```
This generates a warning: "c... | 1. Difference between `@@variable` and `self.variable` in scope of `main`.
As we probably know, `@@variable` is a class variable.
`@@variable` will attach itself to the class of `self.class`. The class of main is `Object`.
To demonstrate:
```
self # => main
self.class # => Object
@@variable = "variable"
self.class.... |
25,819,406 | Trying out the new uGUI in Unity 4.6, scripting the buttons... Iterate through a directory and create a button for each file... The value of f.Name in the AddListener bit should be set independently for each button. Instead every button has the value of the last f.Name to be processed (the last file alphabetically in t... | 2014/09/13 | [
"https://Stackoverflow.com/questions/25819406",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3137390/"
] | Be carefull when using lambda expressions inside a foreach loop. The following code:
```
var someList = new List<int> {1, 2, 3, 4};
var listOfClosures = new List<Func<int>>();
foreach (int v in someList)
{
listOfClosures.Add( () => v );
}
```
is (more or less) equivalent to:
```
var someList = new List<int> {1,... | ```
string captured;
foreach (FileInfo f in fileInfo) {
Button btnCurrLvl = (Button) Instantiate(btnLvl);
btnCurrLvl.GetComponentInChildren<Text>().text = f.Name.Remove(f.Name.Length-5);
btnCurrLvl.name = f.Name;
captured = f.Name;
btnCurrLvl.GetComponent<Button>().onClick.AddListener(() => LoadLocalLvl(captu... |
18,517 | At my workplace I have been assigned to create an accurate 3D model of our Dell PowerEdge R820 servers so we can insert our custom cards and run a CFD and thermal analysis on them. The end goal is to have an exact understanding off all the airflow and heat transfer within the servers and server racks to help in designi... | 2017/12/20 | [
"https://engineering.stackexchange.com/questions/18517",
"https://engineering.stackexchange.com",
"https://engineering.stackexchange.com/users/13810/"
] | Your options are a bit limited. Either you get the model from Dell, or you model it yourself.
Getting the model is a long shot, but if you are a really big customer that might happen. However this is not necceserily a godsend, since:
* The model may not be accurate enough for your need. They may have ripped some dat... | For your IR camera, you need an image of a known object at a known temperature in the same environment as a temperature reference , then when you have the IR image you can cross-reference the colours to approximate the temperatures. Check out some building thermal images for the idea. |
27,641,764 | If I do this in node:
```
console.log('1');
console.log('2');
```
outputs:
```
1
2
```
And the process ends.
If I change it to this:
```
console.log('1');
var Firebase = require('firebase');
var ref = new Firebase('https://<some-base>.firebaseio.com/');
console.log('2');
```
outputs:
```
1
2
```
and the pr... | 2014/12/24 | [
"https://Stackoverflow.com/questions/27641764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/971592/"
] | [Engineer at Firebase] Currently, instantiating the Firebase client with `new Firebase(...)` will create a long-lived persistent connection that keeps the Node.js process alive.
This is admittedly not ideal for a bunch of use cases, and we have some work to do here to ensure that the process exits cleanly and automati... | One workaround I found when using [tape](https://github.com/substack/tape "tape") was to call `test.onFinish(() => process.exit());` at the end. It's not ideal but it seems to get the job done running it both directly and with a test runner.
Example:
```
const test = require('tape');
test('Some test', (t) => {
// ... |
14,691,368 | I have the following view controllers built in my app. The presenting controller is "PatientSelectViewController" (let's call it controller A) and it allows to either manually enter the patient ID in a text field or press a "Scan Barcode" button which would perform a segue to another view controller - namely, "BarcodeS... | 2013/02/04 | [
"https://Stackoverflow.com/questions/14691368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1959008/"
] | Heroku does not install `test` or `development` gems by default.
If you want to load `fake` in your production, you should remove `gem 'faker', '0.3.1'` from the `group :development, :test do` and place it outside any group:
```
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'gravatar_image_tag', '0.1.... | I got this issue with the "Rub on Rails 3 Tutorial".
Per gabrielhilals answer, the fix was to move require 'faker' to inside the task
before fix:
```
require 'faker'
namespace :db do
desc "Fill database with sample data"
task :populate => :environment do
...
...
end
end
```
after fix:
```
namespace :... |
156,979 | For me it seems that in the following case expression seems not to be fitting, I think the second example is shorter, simpler and may even be more correct.
1. dugite - Elegant bindings for working with Git in your Node applications
2. dugite - Elegant bindings to work with Git in your Node applications | 2018/01/19 | [
"https://ell.stackexchange.com/questions/156979",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/-1/"
] | If one says "I ate out on Monday" it necessarily implies the nearest previous Monday.
"Last Monday" generally implies "Monday of last week". For example, if today were Tuesday or Wednesday and someone said "I ate out last Monday", almost no one would wonder if they meant yesterday. But as days pass, particularly towa... | So I'd say if a Monday had past since you ate out, then I suppose you would say "I Ate Out Last Monday."
If, say its the next day, so Tuesday. "I ate out on Monday," Would be what you want to say. |
24,100,983 | I am trying to save the pronunciation of a French word into a .wav or .mp3 file.
I was wondering if there was anywhere on the Google Translate API (since it has a pronunciation functionality) that allows me to achieve this objective. Other libraries would work too. | 2014/06/07 | [
"https://Stackoverflow.com/questions/24100983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3718533/"
] | Since this question was asked, it's gotten much harder to "scrape" MP3s from Google Translate, but Google has (finally) set up a [TTS API](https://cloud.google.com/text-to-speech/). Interestingly it is billed in input characters, with the first 1 or 4 million input characters per month being free (depending on whether ... | Similar functionality is provided by the [Speech Synthesis API](https://developers.google.com/web/updates/2014/01/Web-apps-that-talk-Introduction-to-the-Speech-Synthesis-API) (under development). Third-party libraries are already there, such as [ResponsiveVoice.JS](http://responsivevoice.org/). |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | Assuming you mean you want to detect the height the phone was raised from its staring point, yes. The android accelerometer measures force, more info on how to use it can be found [here](http://developer.android.com/reference/android/hardware/SensorEvent.html#values). Keep in mind that the accelerometer isn't a perfect... | Yes, bt you need to integrate the output twice and add in the two integration constants - initial velocity and displacement.
Rgds,
Martin |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | Assuming you mean you want to detect the height the phone was raised from its staring point, yes. The android accelerometer measures force, more info on how to use it can be found [here](http://developer.android.com/reference/android/hardware/SensorEvent.html#values). Keep in mind that the accelerometer isn't a perfect... | The inaccuracy of the accelerometer will be insignificant when compared to the error caused by an unstable accelerometer. What I mean by this is the fact that as you move your phone you will not be able to keep the accelerometer orientated perfectly i.e. you will 'naturally' rotate it about its longitudinal,lateral and... |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | Assuming you mean you want to detect the height the phone was raised from its staring point, yes. The android accelerometer measures force, more info on how to use it can be found [here](http://developer.android.com/reference/android/hardware/SensorEvent.html#values). Keep in mind that the accelerometer isn't a perfect... | You get position by integrating the linear acceleration twice but **the error is horrible. It is useless in practice.**
Here is [an explanation why (Google Tech Talk)](http://www.youtube.com/watch?v=C7JQ7Rpwn2k) at 23:20. I highly recommend this video.
Similar questions:
[track small movements of iphone with no GPS]... |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | Assuming you mean you want to detect the height the phone was raised from its staring point, yes. The android accelerometer measures force, more info on how to use it can be found [here](http://developer.android.com/reference/android/hardware/SensorEvent.html#values). Keep in mind that the accelerometer isn't a perfect... | First of all you measure Linear acceleration and gravity together (also some noise)
So it means when you are using accelerometer you will get
Accelerometer Readings = Linear Acc. + Gravity + Noise
Here you just only need Linear Acc. but the Accelerometer reads all the values |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | The inaccuracy of the accelerometer will be insignificant when compared to the error caused by an unstable accelerometer. What I mean by this is the fact that as you move your phone you will not be able to keep the accelerometer orientated perfectly i.e. you will 'naturally' rotate it about its longitudinal,lateral and... | Yes, bt you need to integrate the output twice and add in the two integration constants - initial velocity and displacement.
Rgds,
Martin |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | You get position by integrating the linear acceleration twice but **the error is horrible. It is useless in practice.**
Here is [an explanation why (Google Tech Talk)](http://www.youtube.com/watch?v=C7JQ7Rpwn2k) at 23:20. I highly recommend this video.
Similar questions:
[track small movements of iphone with no GPS]... | Yes, bt you need to integrate the output twice and add in the two integration constants - initial velocity and displacement.
Rgds,
Martin |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | Yes, bt you need to integrate the output twice and add in the two integration constants - initial velocity and displacement.
Rgds,
Martin | First of all you measure Linear acceleration and gravity together (also some noise)
So it means when you are using accelerometer you will get
Accelerometer Readings = Linear Acc. + Gravity + Noise
Here you just only need Linear Acc. but the Accelerometer reads all the values |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | The inaccuracy of the accelerometer will be insignificant when compared to the error caused by an unstable accelerometer. What I mean by this is the fact that as you move your phone you will not be able to keep the accelerometer orientated perfectly i.e. you will 'naturally' rotate it about its longitudinal,lateral and... | First of all you measure Linear acceleration and gravity together (also some noise)
So it means when you are using accelerometer you will get
Accelerometer Readings = Linear Acc. + Gravity + Noise
Here you just only need Linear Acc. but the Accelerometer reads all the values |
7,462,924 | Is it possible to use the accelerometer to detect height? For instance, if I'm holding the phone on my hand and then detect the height after raising my arm?
Thanks | 2011/09/18 | [
"https://Stackoverflow.com/questions/7462924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/919810/"
] | You get position by integrating the linear acceleration twice but **the error is horrible. It is useless in practice.**
Here is [an explanation why (Google Tech Talk)](http://www.youtube.com/watch?v=C7JQ7Rpwn2k) at 23:20. I highly recommend this video.
Similar questions:
[track small movements of iphone with no GPS]... | First of all you measure Linear acceleration and gravity together (also some noise)
So it means when you are using accelerometer you will get
Accelerometer Readings = Linear Acc. + Gravity + Noise
Here you just only need Linear Acc. but the Accelerometer reads all the values |
57,063 | When learning to ride, my dad taught me to always have the inside pedal up when cornering. He reinforced the lesson by telling me about a race he'd been in where someone clipped a pedal when cornering and took down 20-30 people in the pack behind him as he went down.
To me it's quite intuitive to keep that inside peda... | 2018/09/13 | [
"https://bicycles.stackexchange.com/questions/57063",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/18643/"
] | I guess it's because when you lean to the right you'd naturally expect your weight to be on your right-side leg -- IOW your right leg is straight and load-bearing, and your left is bent/relaxed i.e. off the ground.
Once your pedal ever scrapes the ground I think you change your mind about the correct way to do it. | Been at races where the competitors have ground down the pedals to allow continued pedalling through the turn. I often keep my cadence through a turn on road and typically will stutter on a trail turn because I lack confidence in the traction holding. There are times when negotiating a tighter turn or when an obstacle ... |
57,063 | When learning to ride, my dad taught me to always have the inside pedal up when cornering. He reinforced the lesson by telling me about a race he'd been in where someone clipped a pedal when cornering and took down 20-30 people in the pack behind him as he went down.
To me it's quite intuitive to keep that inside peda... | 2018/09/13 | [
"https://bicycles.stackexchange.com/questions/57063",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/18643/"
] | People put the inside pedal down because it's the natural thing to do. You want the bike to lean to the left, so you press down on the left side; you want the bike to lean right, so you press on the right.
Putting the outside pedal down is a learnt behaviour, so it's only done by people who have been taught it. Also, ... | Been at races where the competitors have ground down the pedals to allow continued pedalling through the turn. I often keep my cadence through a turn on road and typically will stutter on a trail turn because I lack confidence in the traction holding. There are times when negotiating a tighter turn or when an obstacle ... |
47,255,762 | I am currently trying to read in from a text file that looks like so:
```
10/11/17, 10:00, 02:00, [mary, john, scott]
11/11/17, 12:00, 01:30, [ashley, john, sarah]
12/11/17, 12:00, 03:00, [steve, mick]
```
and I want the program to read in the files as individual elements:
```
"10/11/17", "10:00", "02:00", [mary,... | 2017/11/13 | [
"https://Stackoverflow.com/questions/47255762",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | First, split the lines into their four parts, and then do some fancy magic with the last element in the list:
```
for line in infile:
line_list = line.split(', ', maxsplit=3)
line_list[3] = line_list[3].strip("[]").split(', ')
``` | Add a ',' is split()
infile = open('todo.txt').read().splitlines()
for line in infile:
print(line.split(',')) |
17,016,722 | Here's my main:
```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Button btn = (Button) findViewById(R.id.newgame_button);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
... | 2013/06/10 | [
"https://Stackoverflow.com/questions/17016722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2073001/"
] | ```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Button btn = (Button) findViewById(R.id.newgame_button);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void o... | In my application I use the following code to change the background:
```
View view = this.getWindow().getDecorView();
view.setBackgroundColor(Color.BLACK);
```
Try it, maybe it will work for you. |
17,016,722 | Here's my main:
```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Button btn = (Button) findViewById(R.id.newgame_button);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
... | 2013/06/10 | [
"https://Stackoverflow.com/questions/17016722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2073001/"
] | ```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Button btn = (Button) findViewById(R.id.newgame_button);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void o... | Figured it out:
```
public void changeBackground(View v)
{
View root = findViewById(R.id.main);
root.setBackgroundColor(getResources().getColor(R.color.red));
}
```
Apparently, using `getRootView()` is not good when you're dealing with your main `View`. I don't know, but this worked. |
17,016,722 | Here's my main:
```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Button btn = (Button) findViewById(R.id.newgame_button);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
... | 2013/06/10 | [
"https://Stackoverflow.com/questions/17016722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2073001/"
] | ```
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
Button btn = (Button) findViewById(R.id.newgame_button);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void o... | @Steve P.
Change this
```
public void changeBackground(View v) {
v.setBackgroundColor(getResources().getColor(R.color.red)); }
```
with this one
```
public void ChangeBackground(View v)
{
View parentsView = (View) v.getParent();
parentsView.setBackgroundColor(Color.RED);
}
``` |
63,911,775 | The first input of following code is a single value like `a=3`, and second input is an array consisting of pairs of values like: `B = [[1000, 1], [1000, 3], [999, 4]]`. If the first value of each pair is even then I want the corresponding output value to be based on some specific calculation as shown in the code; if th... | 2020/09/16 | [
"https://Stackoverflow.com/questions/63911775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Ignoring the input, let's say you have an array
```
B = np.array([[1000, 1], [1000, 3], [999, 4]])
```
You can perform selective computations using a mask. The quickest way to type is probably using `np.where`:
```
C = np.where(B[:, 0] % 2, 2 * (B[:, 0] - 15), 3 * (B[:, 0] - 99))
```
This is a bit inefficient sin... | Probably a case for nested `for` loops. You have your outer loop, then loop through your calculations a certain number of times. So, from your example, try something like:
```
for i in range(a):
for x in range(B[i][1]):
if B[i][0] % 2 == 0:
B[i][0]=(B[i][0]-99)*3
else:
B... |
68,995,671 | I can't seem to find something that relates to my specific scenario - I'm aware of how to display an image under normal circumstances. However, due to the nature of the system I'm working on, a lot of the data is sensitive in nature (including images) so I anonify the files in storage (stripping the filename and extens... | 2021/08/31 | [
"https://Stackoverflow.com/questions/68995671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13168911/"
] | In startup you can add this to make it work:
```
app.UseStaticFiles(new StaticFileOptions
{
DefaultContentType = "image/gif"
});
```
I think this will try to make all files without extensions an image?
The good thing is you can lock it to a certain folder using the FileProvider:
```
app.UseStaticFiles(new S... | You should be able to display an image without bothering with the file extension. The file extension just makes it faster for the browser to display the file, however in the event that it doesn't have an extension, the browser will display the file by guessing or looking at its MIME type.
So just make sure that your w... |
8,074,812 | There are a lot of form tags with the same name on the same page, when I click submit on one of them what is the expected behavior? | 2011/11/10 | [
"https://Stackoverflow.com/questions/8074812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964196/"
] | The form which contains that submit button will be submitted. | If you are using JavaScript/jQuery to submit the forms, than it will only submit the 1st instance of the form. If you are using a submit button for each individual form, it should only submit that form, however some browsers may do this different, although I doubt it.
### However...
Why would you ever have multiple f... |
8,074,812 | There are a lot of form tags with the same name on the same page, when I click submit on one of them what is the expected behavior? | 2011/11/10 | [
"https://Stackoverflow.com/questions/8074812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964196/"
] | The form which contains that submit button will be submitted. | The `name=` attribute has no special meaning in regards to which form data is going to be submitted. (And it's going to be the form the submit button associates to.)
<http://www.w3.org/TR/html4/interact/forms.html#h-17.3>
It's sort of equivalent to the `id=` attribute, so avoiding identical names would be a good idea... |
8,074,812 | There are a lot of form tags with the same name on the same page, when I click submit on one of them what is the expected behavior? | 2011/11/10 | [
"https://Stackoverflow.com/questions/8074812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964196/"
] | If you have multiple forms with the same name it won't make a difference, only the form which contains the submit button that was pressed will be submitted. The form name is not actually referenced in the GET or POST request the FORM makes after being submitted.
If you are submitting the FORM via javascript the behav... | The form which contains that submit button will be submitted. |
8,074,812 | There are a lot of form tags with the same name on the same page, when I click submit on one of them what is the expected behavior? | 2011/11/10 | [
"https://Stackoverflow.com/questions/8074812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964196/"
] | If you are using JavaScript/jQuery to submit the forms, than it will only submit the 1st instance of the form. If you are using a submit button for each individual form, it should only submit that form, however some browsers may do this different, although I doubt it.
### However...
Why would you ever have multiple f... | The `name=` attribute has no special meaning in regards to which form data is going to be submitted. (And it's going to be the form the submit button associates to.)
<http://www.w3.org/TR/html4/interact/forms.html#h-17.3>
It's sort of equivalent to the `id=` attribute, so avoiding identical names would be a good idea... |
8,074,812 | There are a lot of form tags with the same name on the same page, when I click submit on one of them what is the expected behavior? | 2011/11/10 | [
"https://Stackoverflow.com/questions/8074812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964196/"
] | If you have multiple forms with the same name it won't make a difference, only the form which contains the submit button that was pressed will be submitted. The form name is not actually referenced in the GET or POST request the FORM makes after being submitted.
If you are submitting the FORM via javascript the behav... | If you are using JavaScript/jQuery to submit the forms, than it will only submit the 1st instance of the form. If you are using a submit button for each individual form, it should only submit that form, however some browsers may do this different, although I doubt it.
### However...
Why would you ever have multiple f... |
8,074,812 | There are a lot of form tags with the same name on the same page, when I click submit on one of them what is the expected behavior? | 2011/11/10 | [
"https://Stackoverflow.com/questions/8074812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/964196/"
] | If you have multiple forms with the same name it won't make a difference, only the form which contains the submit button that was pressed will be submitted. The form name is not actually referenced in the GET or POST request the FORM makes after being submitted.
If you are submitting the FORM via javascript the behav... | The `name=` attribute has no special meaning in regards to which form data is going to be submitted. (And it's going to be the form the submit button associates to.)
<http://www.w3.org/TR/html4/interact/forms.html#h-17.3>
It's sort of equivalent to the `id=` attribute, so avoiding identical names would be a good idea... |
26,098,410 | Just trying to tidy up a little bit of code here. I have a php command to output some html. However, one of my comands is quite a large amount of html, I was wondering if it's possible to output code referenced in a different file?
For example, my current php looks like this:
```
$output .= '<div class="contact-form ... | 2014/09/29 | [
"https://Stackoverflow.com/questions/26098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344228/"
] | you can instead use getfilecontent function of php
```
$output .= file_get_contents('file_with_long_code.html');
``` | $output .= file\_get\_contents('file\_with\_long\_code.html');
Yes, it is possible. |
26,098,410 | Just trying to tidy up a little bit of code here. I have a php command to output some html. However, one of my comands is quite a large amount of html, I was wondering if it's possible to output code referenced in a different file?
For example, my current php looks like this:
```
$output .= '<div class="contact-form ... | 2014/09/29 | [
"https://Stackoverflow.com/questions/26098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344228/"
] | you can instead use getfilecontent function of php
```
$output .= file_get_contents('file_with_long_code.html');
``` | html file.tpl.php:
```
<div class="contact-form <?=$css_class; ?>" >
<h4 class="form-title"><?=$title; ?></h4>
SOME VERY LONG CODE
```
main file:
```
<?php
ob_start();
include('file.tpl.php');
$output = ob_get_contents();
ob_end_clean();
?>
``` |
26,098,410 | Just trying to tidy up a little bit of code here. I have a php command to output some html. However, one of my comands is quite a large amount of html, I was wondering if it's possible to output code referenced in a different file?
For example, my current php looks like this:
```
$output .= '<div class="contact-form ... | 2014/09/29 | [
"https://Stackoverflow.com/questions/26098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344228/"
] | you can instead use getfilecontent function of php
```
$output .= file_get_contents('file_with_long_code.html');
``` | You could do something like this:
```
ob_start();
include('somefile.php');
$output = ob_get_contents();
```
Read more about output buffering in the docs:
<http://php.net/manual/en/function.ob-start.php>
I recommend using a PHP Framework, most of them have a very good functionality for these Kinds of... |
26,098,410 | Just trying to tidy up a little bit of code here. I have a php command to output some html. However, one of my comands is quite a large amount of html, I was wondering if it's possible to output code referenced in a different file?
For example, my current php looks like this:
```
$output .= '<div class="contact-form ... | 2014/09/29 | [
"https://Stackoverflow.com/questions/26098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344228/"
] | html file.tpl.php:
```
<div class="contact-form <?=$css_class; ?>" >
<h4 class="form-title"><?=$title; ?></h4>
SOME VERY LONG CODE
```
main file:
```
<?php
ob_start();
include('file.tpl.php');
$output = ob_get_contents();
ob_end_clean();
?>
``` | $output .= file\_get\_contents('file\_with\_long\_code.html');
Yes, it is possible. |
26,098,410 | Just trying to tidy up a little bit of code here. I have a php command to output some html. However, one of my comands is quite a large amount of html, I was wondering if it's possible to output code referenced in a different file?
For example, my current php looks like this:
```
$output .= '<div class="contact-form ... | 2014/09/29 | [
"https://Stackoverflow.com/questions/26098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344228/"
] | You could do something like this:
```
ob_start();
include('somefile.php');
$output = ob_get_contents();
```
Read more about output buffering in the docs:
<http://php.net/manual/en/function.ob-start.php>
I recommend using a PHP Framework, most of them have a very good functionality for these Kinds of... | $output .= file\_get\_contents('file\_with\_long\_code.html');
Yes, it is possible. |
26,098,410 | Just trying to tidy up a little bit of code here. I have a php command to output some html. However, one of my comands is quite a large amount of html, I was wondering if it's possible to output code referenced in a different file?
For example, my current php looks like this:
```
$output .= '<div class="contact-form ... | 2014/09/29 | [
"https://Stackoverflow.com/questions/26098410",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1344228/"
] | You could do something like this:
```
ob_start();
include('somefile.php');
$output = ob_get_contents();
```
Read more about output buffering in the docs:
<http://php.net/manual/en/function.ob-start.php>
I recommend using a PHP Framework, most of them have a very good functionality for these Kinds of... | html file.tpl.php:
```
<div class="contact-form <?=$css_class; ?>" >
<h4 class="form-title"><?=$title; ?></h4>
SOME VERY LONG CODE
```
main file:
```
<?php
ob_start();
include('file.tpl.php');
$output = ob_get_contents();
ob_end_clean();
?>
``` |
28,573,479 | I am using Cython to wrap a set of C++ classes, allowing a Python interface to them. Example Code is provided below:
BaseClass.h:
```
#ifndef __BaseClass__
#define __BaseClass__
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
class BaseClass
{
public:
BaseClass(){};
v... | 2015/02/17 | [
"https://Stackoverflow.com/questions/28573479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2217927/"
] | Your code, as written, doesn't compile. I suspect that your real `PyDerivedClass` doesn't really derive from `PyBaseClass` as if it did that last line would have to be
```
(<DerivedClass*>self.thisptr).SetObject(inputObject.thisptr)
```
This would also explain the type error you're getting, which is a bug I can't re... | Honestly, this looks like a bug. The object you're passing in is an instance of the desired class, but it still throws an error. You may want to bring it up on the cython-users mailing list so the main developers can look at it.
A possible workaround would be to define a [fused type](http://docs.cython.org/src/usergui... |
28,573,479 | I am using Cython to wrap a set of C++ classes, allowing a Python interface to them. Example Code is provided below:
BaseClass.h:
```
#ifndef __BaseClass__
#define __BaseClass__
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
class BaseClass
{
public:
BaseClass(){};
v... | 2015/02/17 | [
"https://Stackoverflow.com/questions/28573479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2217927/"
] | After a lot of help from the answers below, and experimentation, I think I understand how implementing basic inheritance within Cython works, I'm answering my own question to validate/improve my understanding, as well as hopefully help out anyone who in the future may encounter a related issue. If there is anything wro... | Honestly, this looks like a bug. The object you're passing in is an instance of the desired class, but it still throws an error. You may want to bring it up on the cython-users mailing list so the main developers can look at it.
A possible workaround would be to define a [fused type](http://docs.cython.org/src/usergui... |
28,573,479 | I am using Cython to wrap a set of C++ classes, allowing a Python interface to them. Example Code is provided below:
BaseClass.h:
```
#ifndef __BaseClass__
#define __BaseClass__
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
class BaseClass
{
public:
BaseClass(){};
v... | 2015/02/17 | [
"https://Stackoverflow.com/questions/28573479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2217927/"
] | After a lot of help from the answers below, and experimentation, I think I understand how implementing basic inheritance within Cython works, I'm answering my own question to validate/improve my understanding, as well as hopefully help out anyone who in the future may encounter a related issue. If there is anything wro... | Your code, as written, doesn't compile. I suspect that your real `PyDerivedClass` doesn't really derive from `PyBaseClass` as if it did that last line would have to be
```
(<DerivedClass*>self.thisptr).SetObject(inputObject.thisptr)
```
This would also explain the type error you're getting, which is a bug I can't re... |
181,051 | I am trying to export an image from the print composer using this layer [ESRI rest layer][1] as a basemap. <http://services.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer>
I connected to the layer using the python plugin and this tutorial. <http://hub.qgis.org/wiki/quantum-gis/Arcgis_rest>
Wh... | 2016/02/17 | [
"https://gis.stackexchange.com/questions/181051",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/57516/"
] | Since version 2.14, you have the option to add ArcGis MapServer Layer directly from the "Add Layer" menu.
[](https://i.stack.imgur.com/AL8xc.png)
The ArcGIS REST API connector plugin - which I think is what you referred to in the now removed url - w... | In Print Composer, go to the Composition tab in the right-hand menu. Scroll down to Export Settings. Check what your export resolution is set at. Chances are, it is a higher resolution than what is displayed as a preview in print composer. Try setting this to 300 dpi, or lower.
If the export resolution is too high, i... |
16,052,311 | In my android project i have taken 2 image button(start and stop).
when i pressed START IMAGE BUTTON then it converted to STOP IMAGE BUTTON BUT again when i pressed STOP IMAGE BUTTON it does not converted into START BUTTON.so let me know where is the problem.
```
mImageButton.setOnFocusChangeListener(
new OnFocusC... | 2013/04/17 | [
"https://Stackoverflow.com/questions/16052311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189622/"
] | In Android `onFocusChange` is called before `onCLick`. Whatever you set in the `onFocusChange` method is ignored, as the `onClick` will be called next, and it changes the image bak to `R.drawable.stop`.
You shouldn't use `onFocusChange` at all for what you are trying to do. Only use onClick instead.
```
private boole... | You are toggling the button images in `onFocusChangeListener` instead of `onClickListener`. `ToggleButton` seems to be the right fit for the scenario you are describing. |
16,052,311 | In my android project i have taken 2 image button(start and stop).
when i pressed START IMAGE BUTTON then it converted to STOP IMAGE BUTTON BUT again when i pressed STOP IMAGE BUTTON it does not converted into START BUTTON.so let me know where is the problem.
```
mImageButton.setOnFocusChangeListener(
new OnFocusC... | 2013/04/17 | [
"https://Stackoverflow.com/questions/16052311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189622/"
] | In Android `onFocusChange` is called before `onCLick`. Whatever you set in the `onFocusChange` method is ignored, as the `onClick` will be called next, and it changes the image bak to `R.drawable.stop`.
You shouldn't use `onFocusChange` at all for what you are trying to do. Only use onClick instead.
```
private boole... | the correct way is to use Selectors
create the following ImgBtnSelector.xml in drawable
```
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="@drawable/custom_info_bubble1" />
<item
android:state_pressed="false"
andr... |
16,052,311 | In my android project i have taken 2 image button(start and stop).
when i pressed START IMAGE BUTTON then it converted to STOP IMAGE BUTTON BUT again when i pressed STOP IMAGE BUTTON it does not converted into START BUTTON.so let me know where is the problem.
```
mImageButton.setOnFocusChangeListener(
new OnFocusC... | 2013/04/17 | [
"https://Stackoverflow.com/questions/16052311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189622/"
] | In Android `onFocusChange` is called before `onCLick`. Whatever you set in the `onFocusChange` method is ignored, as the `onClick` will be called next, and it changes the image bak to `R.drawable.stop`.
You shouldn't use `onFocusChange` at all for what you are trying to do. Only use onClick instead.
```
private boole... | Try This Code.. May Be Help You.
```
boolean isStart = true ;
boolean isStop = false;
mImageButton.setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(isStart){
isStart =false ;
isStop = true ;
mImageButton.setImageResource(R.drawable.play... |
16,052,311 | In my android project i have taken 2 image button(start and stop).
when i pressed START IMAGE BUTTON then it converted to STOP IMAGE BUTTON BUT again when i pressed STOP IMAGE BUTTON it does not converted into START BUTTON.so let me know where is the problem.
```
mImageButton.setOnFocusChangeListener(
new OnFocusC... | 2013/04/17 | [
"https://Stackoverflow.com/questions/16052311",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2189622/"
] | In Android `onFocusChange` is called before `onCLick`. Whatever you set in the `onFocusChange` method is ignored, as the `onClick` will be called next, and it changes the image bak to `R.drawable.stop`.
You shouldn't use `onFocusChange` at all for what you are trying to do. Only use onClick instead.
```
private boole... | ```
Boolean isStart=true;//This is global
mImageButton.setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(isStart)
mImageButton.setImageResource(R.drawable.stop);
else
mImageButton.setImageResource(R.drawable.start);
isStart=!isStart;
}
... |
71,325,296 | ```
def enumerator(fruits):
for index, fruit in enumerate(fruits):
print(f"Fruit: {fruit}, under the index: {index}.")
just_a_variable = enumerator(["apple", "banana", "lemon"]) # Im just assigning function call
# to the variable "just_a_variable"
# and boom, when I run the program the function is called. ... | 2022/03/02 | [
"https://Stackoverflow.com/questions/71325296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16544518/"
] | In general if you add parenthesis after a function (like one of the two examples below), it is called.
```py
function_name(arguments)
variable = function_name(arguments)
```
If you just want a variable to point to a function:
```py
variable = function
```
Then the following two statements will become identical:
... | The line `just_a_variable = enumerator(["apple", "banana", "lemon"])` *is* calling function `enumerator`. Technically, that is what the parenthesis after `enumerator` do.
Perhaps you noticed that simply running the file is running that line (and calling `enumerator`). As a scripting language, this is how Python works ... |
26,227,151 | The app should send a local notification to the user when the app is in the background...
i have followed every tutorial there is, i am doing exactly as the tutorials say and **i dont have any errors after writing the code or warnings** **but the Local notifications still wont appear after trying everything.**
i am u... | 2014/10/07 | [
"https://Stackoverflow.com/questions/26227151",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4115319/"
] | Add this to your didFInishLaunchingWithOptions method in your app delegate:
```
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIU... | Since the Notifications are changed in iOS 8.0, add this in your AppDelegate didFinishLaunchingWithOptions:
```
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForType... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | I don't know anything about the install process. But `%~dp0` will give the absolute path of your running batch file. So if your exe is in the same folder, you could try:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "%~dp0MyService.exe"
``` | If you create a .bat file, then the working directory is based on the location from where you invoked the .bat. If you created a shortcut to the .bat file, then the working directory is based on the location of the .bat file. Any relative path in your script is interpreted relative to the working directory.
To avoid c... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | If you create a .bat file, then the working directory is based on the location from where you invoked the .bat. If you created a shortcut to the .bat file, then the working directory is based on the location of the .bat file. Any relative path in your script is interpreted relative to the working directory.
To avoid c... | although this is an old question...
what helped me to solve the issue is to run the installer with logs
For example:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe" /LogToConsole /ShowCallStack
```
In my case the original error was like yours
>
> FileNotFoundException
>
>
>
... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | If you create a .bat file, then the working directory is based on the location from where you invoked the .bat. If you created a shortcut to the .bat file, then the working directory is based on the location of the .bat file. Any relative path in your script is interpreted relative to the working directory.
To avoid c... | Have you tried setting working directory to C:\Services? |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | although this is an old question...
what helped me to solve the issue is to run the installer with logs
For example:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe" /LogToConsole /ShowCallStack
```
In my case the original error was like yours
>
> FileNotFoundException
>
>
>
... | It works for me (of course) - It looks for `MyService.exe` in the containing folder.
`"c:\windows\system32"` is not the location of `installutil`, so perhaps earlier in the batch file the working directory is changed somehow.
Presuming this is not the only command in the batch file:
Try to add `set OLDDIR=%CD%`... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | For my own usage I created a small .bat file:
```
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" %1
```
And now, when I want to install service I just drag .exe file on the .bat. Works perfect :) | Have you tried setting working directory to C:\Services? |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | I don't know anything about the install process. But `%~dp0` will give the absolute path of your running batch file. So if your exe is in the same folder, you could try:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "%~dp0MyService.exe"
``` | It works for me (of course) - It looks for `MyService.exe` in the containing folder.
`"c:\windows\system32"` is not the location of `installutil`, so perhaps earlier in the batch file the working directory is changed somehow.
Presuming this is not the only command in the batch file:
Try to add `set OLDDIR=%CD%`... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | I don't know anything about the install process. But `%~dp0` will give the absolute path of your running batch file. So if your exe is in the same folder, you could try:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "%~dp0MyService.exe"
``` | For my own usage I created a small .bat file:
```
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" %1
```
And now, when I want to install service I just drag .exe file on the .bat. Works perfect :) |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | If you create a .bat file, then the working directory is based on the location from where you invoked the .bat. If you created a shortcut to the .bat file, then the working directory is based on the location of the .bat file. Any relative path in your script is interpreted relative to the working directory.
To avoid c... | It works for me (of course) - It looks for `MyService.exe` in the containing folder.
`"c:\windows\system32"` is not the location of `installutil`, so perhaps earlier in the batch file the working directory is changed somehow.
Presuming this is not the only command in the batch file:
Try to add `set OLDDIR=%CD%`... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | Have you tried setting working directory to C:\Services? | It works for me (of course) - It looks for `MyService.exe` in the containing folder.
`"c:\windows\system32"` is not the location of `installutil`, so perhaps earlier in the batch file the working directory is changed somehow.
Presuming this is not the only command in the batch file:
Try to add `set OLDDIR=%CD%`... |
10,394,690 | 3
I'm trying to install a Windows Service using a batch file, let's call it "setup.bat". Inside the file I have the following commands:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
```
When I excute the batch file (running as administrator on windows7) I get this:
Exception occu... | 2012/05/01 | [
"https://Stackoverflow.com/questions/10394690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/846351/"
] | I don't know anything about the install process. But `%~dp0` will give the absolute path of your running batch file. So if your exe is in the same folder, you could try:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "%~dp0MyService.exe"
``` | although this is an old question...
what helped me to solve the issue is to run the installer with logs
For example:
```
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe" /LogToConsole /ShowCallStack
```
In my case the original error was like yours
>
> FileNotFoundException
>
>
>
... |
42,805,975 | [](https://i.stack.imgur.com/iO0RE.png)
I would like to change the pants color from blue (#0088f0) to red (#f00000) directly in the code (it's a 2D sprite).
I searched a lot but didn't find something working with a sprite without recoloring specifics... | 2017/03/15 | [
"https://Stackoverflow.com/questions/42805975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4792376/"
] | You can achieve what you want with using shaders. You need to create new material, assign shader to it, and then, assign this material to the image component on the scene. Here is shader code:
```
Shader "PiotrMitrega/ColorSwap"
{
Properties
{
_MainTex("Sprite", 2D) = "white" {}
_ColorToChange(... | I think you can use another material instead of default material. You can change color or cut off sprite it seem posible.
<https://docs.unity3d.com/Manual/Materials.html> |
1,299,956 | I am using Ubuntu 20.04 on Dell vostro 7500. But the whole system crash frequently. The symptom is the screen shows no response to keyboard event and mouse event(mouse cannot move or click), but the screen is still light and showing the graphic contents(but everything including the time is stuck). `SysRq+REISUB`, which... | 2020/12/14 | [
"https://askubuntu.com/questions/1299956",
"https://askubuntu.com",
"https://askubuntu.com/users/1144575/"
] | I have upgrade the kernel from `5.4.0-58` to `5.8.0-36` for nearly 20 days and the crash has disappeared since then.
For those who share the same problem, you can upgrade your kernel from the official repository of ubuntu:
```
sudo apt install linux-image-5.8.0-36-generic
```
Best wishes. | sof-audio-pci errors are related to Sound Open Firmware. From their GIT page, "Sound Open Firmware is an open source community that provides an open source audio DSP firmware and SDK for audio or signal processing on modern DSPs." From what I understand, SOF, plus ALSA(Advanced Linux Sound Architecture), plus Pulse Aud... |
3,841,127 | $$\lim\limits\_{x\to -\infty} (e^{-x} \cos{x})=\lim\limits\_{x\to -\infty} \left(\dfrac{\cos{x}}{e^x}\right)$$
From there, I see that $e^x$ approaches $0$ while $\cos{x}$ oscillates between $-1$ and $1$.
My answer is that **the limit does not exist**. What is the proper reasoning to explain this? Does the limit oscil... | 2020/09/26 | [
"https://math.stackexchange.com/questions/3841127",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/655928/"
] | Yes your idea is right, to show that in a rigorous way let consider that for $x\_n= -2\pi n \to -\infty$ as $n\to \infty$
$$e^{-x\_n} \cos{x\_n}=e^{-x\_n}=\infty$$
and for $x\_n= -\pi n$
$$e^{-x\_n} \cos{x\_n}=-e^{-x\_n}=-\infty$$
therefore the limit doesn't exist. | Take $x=\frac{\pi}{2}+\pi k$, where $k$ is integer and $k\rightarrow-\infty$.
We see that $e^{-x}\cos{x}=0.$
In another hand, for $x=\pi k$ and $k\rightarrow-\infty$ we have $|e^{-x}\cos{x}|\rightarrow+\infty$.
Id est, the limit does not exist. |
3,841,127 | $$\lim\limits\_{x\to -\infty} (e^{-x} \cos{x})=\lim\limits\_{x\to -\infty} \left(\dfrac{\cos{x}}{e^x}\right)$$
From there, I see that $e^x$ approaches $0$ while $\cos{x}$ oscillates between $-1$ and $1$.
My answer is that **the limit does not exist**. What is the proper reasoning to explain this? Does the limit oscil... | 2020/09/26 | [
"https://math.stackexchange.com/questions/3841127",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/655928/"
] | Yes your idea is right, to show that in a rigorous way let consider that for $x\_n= -2\pi n \to -\infty$ as $n\to \infty$
$$e^{-x\_n} \cos{x\_n}=e^{-x\_n}=\infty$$
and for $x\_n= -\pi n$
$$e^{-x\_n} \cos{x\_n}=-e^{-x\_n}=-\infty$$
therefore the limit doesn't exist. | Apply the ratio test on the sequence $x=-2\pi n$. |
3,841,127 | $$\lim\limits\_{x\to -\infty} (e^{-x} \cos{x})=\lim\limits\_{x\to -\infty} \left(\dfrac{\cos{x}}{e^x}\right)$$
From there, I see that $e^x$ approaches $0$ while $\cos{x}$ oscillates between $-1$ and $1$.
My answer is that **the limit does not exist**. What is the proper reasoning to explain this? Does the limit oscil... | 2020/09/26 | [
"https://math.stackexchange.com/questions/3841127",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/655928/"
] | Take $x=\frac{\pi}{2}+\pi k$, where $k$ is integer and $k\rightarrow-\infty$.
We see that $e^{-x}\cos{x}=0.$
In another hand, for $x=\pi k$ and $k\rightarrow-\infty$ we have $|e^{-x}\cos{x}|\rightarrow+\infty$.
Id est, the limit does not exist. | Apply the ratio test on the sequence $x=-2\pi n$. |
247,314 | >
> 1) They are driving to New York tomorrow morning. (Present Continuous)
>
> 2) I'll be in the office tomorrow morning. (Future Simple)
>
>
>
Why can't you use the Future Simple in the first question?
Why is the Future Simple used in the second question? | 2020/05/13 | [
"https://ell.stackexchange.com/questions/247314",
"https://ell.stackexchange.com",
"https://ell.stackexchange.com/users/53953/"
] | Yes, *[to google](https://www.dictionary.com/browse/google)* is used also as a generic term for internet searching.
>
> 1) verb (used with object), Goo·gled, Goo·gling.
> (often lowercase)
>
>
> to search the Internet for information about (a person, topic, etc.):
>
>
> * We googled the new applicant to check ... | Note that the usual phrase in English is, "Google something", not "Google for something". |
29,020,684 | I don't understand why but I can't connect to my school server from my network at home. I'm using login as always like ssh name@host.com but it still don't work.
Here is debug report with -v
```
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29020684",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3062571/"
] | You can also do the concatenation within R itself, by setting the column type to string, and then using the paste0(string1, string2) function. | You can use the & sign
```
=A1&C1
```
concatenate does also work in excel
```
=CONCATENATE(A1,C1)
``` |
308,820 | I have big issue with url-rewriting for IIS 7.0.
I've written simple module for rewriting for my NET3.5/IIS7 web application. Here is a part of the code.
```
public void Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest... | 2008/11/21 | [
"https://Stackoverflow.com/questions/308820",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/39656/"
] | I think
```
target="(name=myDictionary)"
```
should do the trick in the `@scr.reference` annotation. See <http://felix.apache.org/site/apache-felix-maven-scr-plugin.html> | In standard DS, you can use target attribute of the reference element. In Felix world, where annotations can be used, I don't know what is the equivalent.
The target attribute is an LDAP filter, which matches against the service properties. So, your filter should be:
`(name=myDictionary)` |
23,076,776 | ```
[
{"tag":"fujairah","count":1},
{"tag":"worldwide","count":3},
{"tag":"saudi","count":1},
{"tag":"miami","count":1},
{"tag":"rwo-dealer","count":7},
{"tag":"new york","count":2},
{"tag":"surabaya","count":1},
{"tag":"phillippines","count":1},
{"tag":"vietnam","count":1},
{"tag":"norway","count":1},
{"tag":"x","coun... | 2014/04/15 | [
"https://Stackoverflow.com/questions/23076776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3534753/"
] | It doesn't matter the number of items, it may be just your case. It's just that's not the correct way to implement a sorting function. You should return 1 (or any positive value, if the first item is "greater" than the second), -1 (or any negative value) or 0 (if the items are equal). Try something like this:
```
.sor... | As noted in the accepted answer the only way to assure the compare function results in expected sort order is to return a number other than 0.
The reasoning for this though is important and should be noted for reference purposes. ECMA standards allow for browser implementations to be unstable. As such there can be no ... |
43,726,728 | I want to optimize KNN. There is a lot about SVM, RF and XGboost; but very few for KNN.
As far as I know the number of neighbors is one parameter to tune.
But what other parameters to test? Is there any good article?
Thank you | 2017/05/01 | [
"https://Stackoverflow.com/questions/43726728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106842/"
] | KNN is so simple method that there is pretty much nothing to tune besides K. The whole method is literally:
```
for a given test sample x:
- find K most similar samples from training set, according to similarity measure s
- return the majority vote of the class from the above set
```
Consequently the only thin... | Lejlot, pretty much summed it all. K-NN is so simple that it's an instance based nonparametric algorithm, that's what makes it so beautiful, and works really well for certain specific examples. Most of K-NN research is not in K-NN itself but in the computation and hardware that goes into it. If you'd like some readings... |
43,726,728 | I want to optimize KNN. There is a lot about SVM, RF and XGboost; but very few for KNN.
As far as I know the number of neighbors is one parameter to tune.
But what other parameters to test? Is there any good article?
Thank you | 2017/05/01 | [
"https://Stackoverflow.com/questions/43726728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106842/"
] | KNN is so simple method that there is pretty much nothing to tune besides K. The whole method is literally:
```
for a given test sample x:
- find K most similar samples from training set, according to similarity measure s
- return the majority vote of the class from the above set
```
Consequently the only thin... | By optimizing if you are also focusing on the reduction of prediction time (you should) then there are other aspects which you can implement to make the algorithm more efficient (But these are not parameter tuning). The major draw back with the KNN is that with the increasing number of training examples, the prediction... |
43,726,728 | I want to optimize KNN. There is a lot about SVM, RF and XGboost; but very few for KNN.
As far as I know the number of neighbors is one parameter to tune.
But what other parameters to test? Is there any good article?
Thank you | 2017/05/01 | [
"https://Stackoverflow.com/questions/43726728",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106842/"
] | Lejlot, pretty much summed it all. K-NN is so simple that it's an instance based nonparametric algorithm, that's what makes it so beautiful, and works really well for certain specific examples. Most of K-NN research is not in K-NN itself but in the computation and hardware that goes into it. If you'd like some readings... | By optimizing if you are also focusing on the reduction of prediction time (you should) then there are other aspects which you can implement to make the algorithm more efficient (But these are not parameter tuning). The major draw back with the KNN is that with the increasing number of training examples, the prediction... |
37,852,417 | I have two entities:
```
public class Transport
{
[Key]
public int TransportID {get; set;}
public string Model { get; set; }
public string Brand { get; set; }
}
public class TransportOwner
{
[Key]
public int TransportOwnerID {get; set;}
public in... | 2016/06/16 | [
"https://Stackoverflow.com/questions/37852417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6324239/"
] | Well you can actually do this:
```
List<OwnerTransportTransport> ListIWantToShow =
(from transport in dbContext.TransportOwner
select new OwnerTransportTransport()
{
ID = transport.ID,
Transp... | I created class:
```
public class OwnerTransportTransport
{
public int OwnerTransportID { get; set; }
public int TransportID { get; set; }
public string Brand { get; set; }
public string Model { get; set; }
}
```
And then finaly what I needed :)
```
var query = dbContext.TransportOwner.AsQueryable();
ListIW... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.