qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | Was getting the same error *serverless: command not found* but instead of NPM was using YARN. To fix it had to execute (or better add to your ~/.bash\_profile):
```
export PATH="$PATH:$(yarn global bin)"
```
then, if not already installed:
```
yarn global add serverless
``` | Try with the following order
```
npm config set prefix /usr/local
sudo npm i -g serverless
sudo /usr/bin/node /usr/local/lib/node_modules/serverless/node_modules/tabtab/src/cli.js install --name serverless --auto
``` |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | Try running,
```
npm config set prefix /usr/local
```
and then,
```
npm i -g serverless
``` | Another option, following this [post](https://github.com/serverless/serverless/issues/4889), is to try `npx serverless ...` |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.
```
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
```
Reference link - <https://serverless.com/framework/docs/pr... | Try with the following order
```
npm config set prefix /usr/local
sudo npm i -g serverless
sudo /usr/bin/node /usr/local/lib/node_modules/serverless/node_modules/tabtab/src/cli.js install --name serverless --auto
``` |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.
```
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
```
Reference link - <https://serverless.com/framework/docs/pr... | Was getting the same error *serverless: command not found* but instead of NPM was using YARN. To fix it had to execute (or better add to your ~/.bash\_profile):
```
export PATH="$PATH:$(yarn global bin)"
```
then, if not already installed:
```
yarn global add serverless
``` |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.
```
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
```
Reference link - <https://serverless.com/framework/docs/pr... | my recomendation here is to allways install the serverless framework as a dev dependency (`npm install serverless --save-dev`) specially if you're working in a team where each member can have its own version of the framework. After that, you can call the framework using npm scripts. For example, you can create a new en... |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | my recomendation here is to allways install the serverless framework as a dev dependency (`npm install serverless --save-dev`) specially if you're working in a team where each member can have its own version of the framework. After that, you can call the framework using npm scripts. For example, you can create a new en... | Try with the following order
```
npm config set prefix /usr/local
sudo npm i -g serverless
sudo /usr/bin/node /usr/local/lib/node_modules/serverless/node_modules/tabtab/src/cli.js install --name serverless --auto
``` |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | Try running,
```
npm config set prefix /usr/local
```
and then,
```
npm i -g serverless
``` | If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.
```
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
```
Reference link - <https://serverless.com/framework/docs/pr... |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | Was getting the same error *serverless: command not found* but instead of NPM was using YARN. To fix it had to execute (or better add to your ~/.bash\_profile):
```
export PATH="$PATH:$(yarn global bin)"
```
then, if not already installed:
```
yarn global add serverless
``` | Another option, following this [post](https://github.com/serverless/serverless/issues/4889), is to try `npx serverless ...` |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | Try running,
```
npm config set prefix /usr/local
```
and then,
```
npm i -g serverless
``` | my recomendation here is to allways install the serverless framework as a dev dependency (`npm install serverless --save-dev`) specially if you're working in a team where each member can have its own version of the framework. After that, you can call the framework using npm scripts. For example, you can create a new en... |
45,130,789 | I am trying to set up the AWS Serverless framework in Ubuntu 16.04 LTS. I installed Node.js and have also installed Serverless using the following command: `npm install -g serverless` in the terminal.
But when I try to run `serverless` it returns an error saying `serverless: command not found`. Below is a screenshot f... | 2017/07/16 | [
"https://Stackoverflow.com/questions/45130789",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8309746/"
] | If the above options are not working (due to insufficient access or sudo access), following one will definitely work as it's saving the serverless into your local.
```
npm install serverless --save-dev
node ./node_modules/serverless/bin/serverless deploy
```
Reference link - <https://serverless.com/framework/docs/pr... | Another option, following this [post](https://github.com/serverless/serverless/issues/4889), is to try `npx serverless ...` |
58,488,272 | I have an adc that reads values on an interrupt and stores them in a FIFO.
In the main programm I wanted to read the whole FIFO just like a regular array and do FFT and stuff. After a little bit of thinking I realized that the interrupt could occur during the reading process and that the data wouldn't be accurate anym... | 2019/10/21 | [
"https://Stackoverflow.com/questions/58488272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9100853/"
] | What you can do is use a `LabelEncoder` to create the dictionary:
```
from sklearn.preprocessing import LabelEncoder
label_encoder = LabelEncoder()
labels = ['polmone', 'fegato', 'linfonodi']
encoded_labels = label_encoder.fit_transform(labels)
labels_dict = {}
for i in range(len(labels)):
labels_dict[labels[i]] =... | This works for me:
pandas.factorize( ['B', 'C', 'D', 'B'] )[0]
Output:
[0, 1, 2, 0]
Try to look up at hot encoding as well and tranforming categorical into numeric. |
58,488,272 | I have an adc that reads values on an interrupt and stores them in a FIFO.
In the main programm I wanted to read the whole FIFO just like a regular array and do FFT and stuff. After a little bit of thinking I realized that the interrupt could occur during the reading process and that the data wouldn't be accurate anym... | 2019/10/21 | [
"https://Stackoverflow.com/questions/58488272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9100853/"
] | What you can do is use a `LabelEncoder` to create the dictionary:
```
from sklearn.preprocessing import LabelEncoder
label_encoder = LabelEncoder()
labels = ['polmone', 'fegato', 'linfonodi']
encoded_labels = label_encoder.fit_transform(labels)
labels_dict = {}
for i in range(len(labels)):
labels_dict[labels[i]] =... | I think that a [Label encoder](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html) is what you need.
As specified in the doc this lib transfrom efficiently your labels in an integer sequence.
What you should do is something like:
```
from sklearn.preprocessing import LabelEncod... |
40,613,177 | After:
```
import unittest
loader = unittest.TestLoader()
tests = loader.discover('.')
testRunner = unittest.runner.TextTestRunner()
testResult = testRunner.run(tests)
```
I can get a list failures names and messages with:
```
for t in testResult.failures:
print t[0].id()
print t[1]
```
How to do the sam... | 2016/11/15 | [
"https://Stackoverflow.com/questions/40613177",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/895245/"
] | elethan put me on the right direction: <https://stackoverflow.com/a/40613695/895245>
This is what I got after using `TextTestRunner(resultclass=` and adding a nice constructor:
```
import unittest
from unittest.runner import TextTestResult
class TextTestResultWithSuccesses(TextTestResult):
def __init__(self, *ar... | I have done something similar in the past. The way I would do this is by first creating a test result class that in inherits from `TestTextResult` with a custom `addSuccess` method which will be called on each test success (`addFailure` is the method where the failing tests get appended to `failures`):
```
from unitte... |
18,404,219 | I'd like to store connection URLs in a JNDI binding for my Tomcat application. Since Tomcat uses `context.xml` for JNDI resource defining, I need to figure out the propert way to store a String (or multiple strings for multiple connections) in `context.xml`.
My reason for doing this is so that I can define different s... | 2013/08/23 | [
"https://Stackoverflow.com/questions/18404219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | You can use an `Environment`tag:
```
<Context>
<Environment name="myConnectionURL" value="amqp:5272//blah.example.com¶m1=4" type="java.lang.String"/>
</Context>
```
And you can read it almost as you specified in the question:
```
InitialContext initialContext = new InitialContext();
Context environmentConte... | You can configure named values that will be made visible to the web application as servlet context initialization parameters by nesting elements inside this element. For example, you can create an initialization parameter like this:
```
<Context>
...
<Parameter name="companyName" value="My Company, Incorp... |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | It looks like your indexing of `x` is off by 1. But here is a quick way to to do it using `apply`.
```
df['a_'] = df.a.apply(lambda r: x[r-1])
df['b_'] = df.b.apply(lambda r: x[r-1])
df
# returns:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4... | one option is `apply` with `lambda`
```
df['a_'] = df['a'].apply(lambda y: x[y])
df['b_'] = df['b'].apply(lambda y: x[y])
time a b a_ b_
0 0.000 6 5 1 0.5
1 0.008 6 9 1 6.0
2 0.016 1 9 -4 6.0
3 0.024 2 7 -3 2.0
4 0.032 1 5 -4 0.5
``` |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | IIUC, this can be solved with numpy indexing:
```
x = [-6, -4, -3, -2, -1, 0.5, 1, 2, 4, 6]
x = np.array(x)
df['a_'] = x[df['a']-1]
df['b_'] = x[df['b']-1]
# if you have more than two columns:
# for col in df.columns[1:]:
# df[col+'_'] = x[df[col] - 1]
```
Output:
```
time a b a_ b_
0 0.000 6 5 ... | one option is `apply` with `lambda`
```
df['a_'] = df['a'].apply(lambda y: x[y])
df['b_'] = df['b'].apply(lambda y: x[y])
time a b a_ b_
0 0.000 6 5 1 0.5
1 0.008 6 9 1 6.0
2 0.016 1 9 -4 6.0
3 0.024 2 7 -3 2.0
4 0.032 1 5 -4 0.5
``` |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | I also use numpy fancy index, but I would do it for all columns and construct a dict to use with assign. Just a different way to assign multiple columns at once.
```
a = np.array(x)
cols = ['a', 'b']
d = dict(zip(np.char.add(cols, '_'), a[df[cols] - 1].T))
df = df.assign(**d)
Out[721]:
time a b a_ b_
0 0.0... | one option is `apply` with `lambda`
```
df['a_'] = df['a'].apply(lambda y: x[y])
df['b_'] = df['b'].apply(lambda y: x[y])
time a b a_ b_
0 0.000 6 5 1 0.5
1 0.008 6 9 1 6.0
2 0.016 1 9 -4 6.0
3 0.024 2 7 -3 2.0
4 0.032 1 5 -4 0.5
``` |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | It looks like your indexing of `x` is off by 1. But here is a quick way to to do it using `apply`.
```
df['a_'] = df.a.apply(lambda r: x[r-1])
df['b_'] = df.b.apply(lambda r: x[r-1])
df
# returns:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4... | IIUC, this can be solved with numpy indexing:
```
x = [-6, -4, -3, -2, -1, 0.5, 1, 2, 4, 6]
x = np.array(x)
df['a_'] = x[df['a']-1]
df['b_'] = x[df['b']-1]
# if you have more than two columns:
# for col in df.columns[1:]:
# df[col+'_'] = x[df[col] - 1]
```
Output:
```
time a b a_ b_
0 0.000 6 5 ... |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | It looks like your indexing of `x` is off by 1. But here is a quick way to to do it using `apply`.
```
df['a_'] = df.a.apply(lambda r: x[r-1])
df['b_'] = df.b.apply(lambda r: x[r-1])
df
# returns:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4... | IIUC
```
d=dict(zip(range(1,len(x)+1),x))
df=pd.concat([df,df[['a','b']].applymap(lambda x : d.get(x)).add_suffix('_')],axis=1)
Out[15]:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4 0.032 1 5 -6.0 -1
``` |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | It looks like your indexing of `x` is off by 1. But here is a quick way to to do it using `apply`.
```
df['a_'] = df.a.apply(lambda r: x[r-1])
df['b_'] = df.b.apply(lambda r: x[r-1])
df
# returns:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4... | I also use numpy fancy index, but I would do it for all columns and construct a dict to use with assign. Just a different way to assign multiple columns at once.
```
a = np.array(x)
cols = ['a', 'b']
d = dict(zip(np.char.add(cols, '_'), a[df[cols] - 1].T))
df = df.assign(**d)
Out[721]:
time a b a_ b_
0 0.0... |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | IIUC, this can be solved with numpy indexing:
```
x = [-6, -4, -3, -2, -1, 0.5, 1, 2, 4, 6]
x = np.array(x)
df['a_'] = x[df['a']-1]
df['b_'] = x[df['b']-1]
# if you have more than two columns:
# for col in df.columns[1:]:
# df[col+'_'] = x[df[col] - 1]
```
Output:
```
time a b a_ b_
0 0.000 6 5 ... | IIUC
```
d=dict(zip(range(1,len(x)+1),x))
df=pd.concat([df,df[['a','b']].applymap(lambda x : d.get(x)).add_suffix('_')],axis=1)
Out[15]:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4 0.032 1 5 -6.0 -1
``` |
59,078,259 | I have a df that looks like this:
```
time a b
0 0.000 6 5
1 0.008 6 9
2 0.016 1 9
3 0.024 2 7
4 0.032 1 5
```
I want to use eac... | 2019/11/27 | [
"https://Stackoverflow.com/questions/59078259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11666502/"
] | I also use numpy fancy index, but I would do it for all columns and construct a dict to use with assign. Just a different way to assign multiple columns at once.
```
a = np.array(x)
cols = ['a', 'b']
d = dict(zip(np.char.add(cols, '_'), a[df[cols] - 1].T))
df = df.assign(**d)
Out[721]:
time a b a_ b_
0 0.0... | IIUC
```
d=dict(zip(range(1,len(x)+1),x))
df=pd.concat([df,df[['a','b']].applymap(lambda x : d.get(x)).add_suffix('_')],axis=1)
Out[15]:
time a b a_ b_
0 0.000 6 5 0.5 -1
1 0.008 6 9 0.5 4
2 0.016 1 9 -6.0 4
3 0.024 2 7 -4.0 1
4 0.032 1 5 -6.0 -1
``` |
975,196 | I have an issue with part of a script that is attempting to check if an attached volume is formatted before formatting.
The grep used in this check returns zero when the volume isnt formatted when using nvme volumes. This because the output of file -s seems to be a long string of characters:
`Xs\333d8\374R\352if\253w... | 2019/07/14 | [
"https://serverfault.com/questions/975196",
"https://serverfault.com",
"https://serverfault.com/users/481631/"
] | You can check the details of a specific device and act based on that:
```
blkid --match-token TYPE=ext4 /dev/nvme123 || mkfs.ext4 -m0 /dev/nvme123
```
What this does is:
1. `blkid` checks whether `/dev/nvme123` is `ext4` formatted, and if not it returns non-zero return code.
2. The double-pipe `||` runs the second ... | Try something like below
```
# for type in ext4 ext3 ext2 iso9660;do [[ `blkid |grep /dev/vdc|awk '{print $NF}'` =~ TYPE=\"$type\" ]] && echo matched ;done
```
Output
```
matched
```
List the expected filesystem types and check if match, flag it and use it for further processing. |
27,395,694 | Here is the code for setting broadcast reciever.
```
PendingIntent pendingIntentScheduler = PendingIntent.getBroadcast(context, REQUEST_CODE, intent, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm... | 2014/12/10 | [
"https://Stackoverflow.com/questions/27395694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4344258/"
] | Take a look at
<https://code.google.com/p/android/issues/detail?id=82001>
or
[AlarmManager not fires on time in Android Lollipop](https://stackoverflow.com/questions/27668444/alarmmanager-not-fires-on-time-in-android-lollipop) | Try This
```
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
Intent intent = new Intent(context, AlarmReceiver.class);
PendingIntent pi = PendingIntent.getBroadcast(context, AlarmActive, intent, PendingIntent.FLAG_UPDATE_CURRENT);
if (Build.VERSION.SDK_INT >= ... |
270,400 | When a user with at least 200 rep on any Stack Exchange site registers a new account on another SE site, they immediately receive 100 rep on that site as an [association bonus](https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus). This is a deliberate feature to give users who are already fami... | 2015/12/05 | [
"https://meta.stackexchange.com/questions/270400",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/174699/"
] | I don't want to lose this bonus. True, I might know nothing about [cooking](https://cooking.stackexchange.com/), but if I see there something I really like to know too, without satisfying answer (or with an excellent answer I want to award), being able to give a bounty is a very nice to have bonus, which I'm not going ... | Let me spend my Reputation the way I want
=========================================
Sometimes, I join a specific network site just to ask a specific question. I can't really engage with the site as I would with my "main" site, simply because I lack the knowledge to really be useful there.
However, if the question fee... |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | You can specify alternatives in a regular expression by using the `|` character:
```
\d+|[ABC]+
```
In your specific example, the string you want is seemingly always the second "word" (delimited by a space), so it can be beneficial to include the space in the regular expression to look for it. Either by using a capt... | Something like this: [0-9]+|[a-zA-Z]+ or maybe [0-9]+|(ABC)+; not sure what your rule for the characters is. |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | As at least one other answer has mentioned, it looks like you're picking out the second word in a space-delimited string, and regular expressions are more work than is necessary for that task. `String.indexOf` would be enough:
```
String line = ...;
int start = line.indexOf(" ") + 1;
int end = line.indexOf(" ", end);
... | Something like this: [0-9]+|[a-zA-Z]+ or maybe [0-9]+|(ABC)+; not sure what your rule for the characters is. |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | You could have something like this...
```
^[^ ]* ([^ ]*) .*$
``` | Something like this: [0-9]+|[a-zA-Z]+ or maybe [0-9]+|(ABC)+; not sure what your rule for the characters is. |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | You can specify alternatives in a regular expression by using the `|` character:
```
\d+|[ABC]+
```
In your specific example, the string you want is seemingly always the second "word" (delimited by a space), so it can be beneficial to include the space in the regular expression to look for it. Either by using a capt... | Try this regular expression:
```
"(\d+|ABC)"
``` |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | As at least one other answer has mentioned, it looks like you're picking out the second word in a space-delimited string, and regular expressions are more work than is necessary for that task. `String.indexOf` would be enough:
```
String line = ...;
int start = line.indexOf(" ") + 1;
int end = line.indexOf(" ", end);
... | Try this regular expression:
```
"(\d+|ABC)"
``` |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | You could have something like this...
```
^[^ ]* ([^ ]*) .*$
``` | Try this regular expression:
```
"(\d+|ABC)"
``` |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | You can specify alternatives in a regular expression by using the `|` character:
```
\d+|[ABC]+
```
In your specific example, the string you want is seemingly always the second "word" (delimited by a space), so it can be beneficial to include the space in the regular expression to look for it. Either by using a capt... | Try this regular expression:
```
^\w+\W+(\w+)
```
And make your expression to match the begin of a line with `^`. |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | As at least one other answer has mentioned, it looks like you're picking out the second word in a space-delimited string, and regular expressions are more work than is necessary for that task. `String.indexOf` would be enough:
```
String line = ...;
int start = line.indexOf(" ") + 1;
int end = line.indexOf(" ", end);
... | Try this regular expression:
```
^\w+\W+(\w+)
```
And make your expression to match the begin of a line with `^`. |
1,855,901 | In Java - I need to search/validate an input string for a number or for a specific string. it must be one of them.
For example - If I have this input lines:
```
cccccccc 123 vvvvvvvvv jhdakfksah
cccccccc ABC vvvvvvnhj yroijpotpo
cccdcdcd 234 vcbvbvbvbv lkjd dfdggf
ccccbvff ABC jflkjlkjlj fgdgfg
```
I need to find 1... | 2009/12/06 | [
"https://Stackoverflow.com/questions/1855901",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/225862/"
] | You could have something like this...
```
^[^ ]* ([^ ]*) .*$
``` | Try this regular expression:
```
^\w+\W+(\w+)
```
And make your expression to match the begin of a line with `^`. |
125,315 | We've got arround 25users connecting to our terminal server (remote desktop) - no active directory is used.
How can i hide the taskbar from the bottom of the page, not to auto-hide it. i want the users not to be able to use it (except the administrators of course).
Mike | 2010/03/23 | [
"https://serverfault.com/questions/125315",
"https://serverfault.com",
"https://serverfault.com/users/4287/"
] | I'm guessing that you're probably looking for more long-term auditing than using "Process Monitor" or repeatedly running "handle.exe". We'll see if my psychic powers pay off here.
"Object access" auditing is probably what you're looking for. If you're looking to audit access to files being access locally on a computer... | One way to do this is use a filter in [Process Monitor](http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx), one of the Sysinternals tools. The help file has a similar example. This is not a core OS component though so you would need to check it's appropriate to install it. |
125,315 | We've got arround 25users connecting to our terminal server (remote desktop) - no active directory is used.
How can i hide the taskbar from the bottom of the page, not to auto-hide it. i want the users not to be able to use it (except the administrators of course).
Mike | 2010/03/23 | [
"https://serverfault.com/questions/125315",
"https://serverfault.com",
"https://serverfault.com/users/4287/"
] | I'm guessing that you're probably looking for more long-term auditing than using "Process Monitor" or repeatedly running "handle.exe". We'll see if my psychic powers pay off here.
"Object access" auditing is probably what you're looking for. If you're looking to audit access to files being access locally on a computer... | You can download handle.exe from:
<http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx>
Very useful for viewing open handles. |
159,351 | Like I have virtual Memory size = 2 GB ,Physical Memory Size=4 GB..........
Is this case possible?
Please Explain | 2010/07/02 | [
"https://superuser.com/questions/159351",
"https://superuser.com",
"https://superuser.com/users/41647/"
] | It is possible.
One scenario that I can think of is when you have large amounts of memory (e.g. 16GB) and not much need for virtual memory (e.g. Hyper-V - since you tend to use only physical memory for running virtual machines). You still want some for core dumps and unexpected situations but total of 4GB is quite eno... | Yes, you can have that. Having 0 virtual memory is just a special case of "less than physical memory". |
159,351 | Like I have virtual Memory size = 2 GB ,Physical Memory Size=4 GB..........
Is this case possible?
Please Explain | 2010/07/02 | [
"https://superuser.com/questions/159351",
"https://superuser.com",
"https://superuser.com/users/41647/"
] | It is possible.
One scenario that I can think of is when you have large amounts of memory (e.g. 16GB) and not much need for virtual memory (e.g. Hyper-V - since you tend to use only physical memory for running virtual machines). You still want some for core dumps and unexpected situations but total of 4GB is quite eno... | yes it is possible ;) (virtual memory placed on hdd so 2 gb is good) (but if you asking which one is recomended by winodws OS's is - 1,5 x of your ram - i mean if you have a 4 gb you should use 6 gb virtual ram on hdd but i don't use virtual ram or i use if a game recommend virtual memory (strategy games sometimes want... |
39,550,424 | Adding the `-m` flag to g++ causes a `file format not recognized; treating as linker script`, which in turns causes a syntax error when linking.
I'm using this makefile:
```
# Compilers
CXX = g++
#CXX = clang++
CC = gcc
UNAME := $(shell uname)
# Directories used for input and output
SRCDIR = src/src
BUILDDIR = bui... | 2016/09/17 | [
"https://Stackoverflow.com/questions/39550424",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3988023/"
] | The int throws what's after the period. You may want to duplicate in 10 more. Get the first numeral to check if it greater than 5 add one to your percent.
Sorry for not writing code.
I'm on iOS now and my java rusty...
Good luck | ```
(100 * SEC_SINCE_MN) / SEC_IN_DAY
```
is multiplying the integer SEC\_SINCE\_MN by the integer 100, and then divides it by the integer SEC\_IN\_DAY. So that's an integer division. It just truncates the decimal part of the result.
What you want is to compute the accurate percentage, with the decimals, and then r... |
368,201 | I understand the concept that the voltage lags behind the current in a capacitor, which is why we have to use imaginary numbers to find the impedance of a simple Series RC-circuit like this:
[](https://i.stack.imgur.com/7kwTE.gif)
(source: [electronics-tutori... | 2018/04/12 | [
"https://electronics.stackexchange.com/questions/368201",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/181149/"
] | >
> Based of my limited understanding of the complex plane and rotation, multiplying by \$j\$ would rotate the reactance 90 degrees clockwise
>
>
>
This is incorrect. When measuring angles a positive angle is counterclockwise, not clockwise. This is the case in basic trigonometry/geometry as well.
In an RL circui... | If you multiply a real variable with \$j\$ it would be in the plane on the imaginary axis. so multiplying with \$j\$ turns it counterclockwise, \$-j\$ turns it clockwise.
Why it is \$-j\$ by the capacitor is because $$Z\_C=\frac{1}{j \omega C}$$ multiplying with $$\frac{j}{j}$$ generates a \$-j\$ in the numerator. \$Z... |
368,201 | I understand the concept that the voltage lags behind the current in a capacitor, which is why we have to use imaginary numbers to find the impedance of a simple Series RC-circuit like this:
[](https://i.stack.imgur.com/7kwTE.gif)
(source: [electronics-tutori... | 2018/04/12 | [
"https://electronics.stackexchange.com/questions/368201",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/181149/"
] | >
> Based of my limited understanding of the complex plane and rotation, multiplying by \$j\$ would rotate the reactance 90 degrees clockwise
>
>
>
This is incorrect. When measuring angles a positive angle is counterclockwise, not clockwise. This is the case in basic trigonometry/geometry as well.
In an RL circui... | Imaginary number conventions are arbitrary. The conventions have been chosen such that having a sine signal (voltage or amperage) occur with earlier phase corresponds to positive angles for the complex amplitude vector.
Now a capacitor has voltage trailing current, so the impedance (voltage divided by current) is nega... |
368,201 | I understand the concept that the voltage lags behind the current in a capacitor, which is why we have to use imaginary numbers to find the impedance of a simple Series RC-circuit like this:
[](https://i.stack.imgur.com/7kwTE.gif)
(source: [electronics-tutori... | 2018/04/12 | [
"https://electronics.stackexchange.com/questions/368201",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/181149/"
] | If you multiply a real variable with \$j\$ it would be in the plane on the imaginary axis. so multiplying with \$j\$ turns it counterclockwise, \$-j\$ turns it clockwise.
Why it is \$-j\$ by the capacitor is because $$Z\_C=\frac{1}{j \omega C}$$ multiplying with $$\frac{j}{j}$$ generates a \$-j\$ in the numerator. \$Z... | Imaginary number conventions are arbitrary. The conventions have been chosen such that having a sine signal (voltage or amperage) occur with earlier phase corresponds to positive angles for the complex amplitude vector.
Now a capacitor has voltage trailing current, so the impedance (voltage divided by current) is nega... |
30,431,328 | I am using the Java DB Web Starter boilerplate in IBM Bluemix. When I use it to create an app called SentimentAnalysisAPP, create fails with this error:
BXNUI2032E: An error occurred when contacting Cloud Foundry to create a resource. Resource: routes. Cloud Foundry message: "The host is taken: SentimentAnalysisAPP." ... | 2015/05/25 | [
"https://Stackoverflow.com/questions/30431328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4933930/"
] | Try naming your application something else. Bluemix will try to auto create the URL for your app based on what you type into the name of the app.
SentimentAnalysisAPP.mybluemix.net is already in use.
Pick a name that is more unique, like SentimentAnalysisPDHTest. | Like @Ram Vennam said, the problem is that your app name (in this case, SentimentAnalysisAPP) is not unique, that another Bluemix user is already using that app name and URL.
This question is fairly common and has been answered before. You need to search for "BXNUI2032E" and "the host is taken". Then you'll find answe... |
30,431,328 | I am using the Java DB Web Starter boilerplate in IBM Bluemix. When I use it to create an app called SentimentAnalysisAPP, create fails with this error:
BXNUI2032E: An error occurred when contacting Cloud Foundry to create a resource. Resource: routes. Cloud Foundry message: "The host is taken: SentimentAnalysisAPP." ... | 2015/05/25 | [
"https://Stackoverflow.com/questions/30431328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4933930/"
] | Try naming your application something else. Bluemix will try to auto create the URL for your app based on what you type into the name of the app.
SentimentAnalysisAPP.mybluemix.net is already in use.
Pick a name that is more unique, like SentimentAnalysisPDHTest. | That means the URL "SentimentAnalysisAPP.mybluemix.net" has been taken by someone else.
You need to create a unique host for it.
If you are running cf cli version 6.4 or above, you can use --random-route to let system generate one for you. eg.
cf push SentimentAnalysisAPP --random-route |
30,431,328 | I am using the Java DB Web Starter boilerplate in IBM Bluemix. When I use it to create an app called SentimentAnalysisAPP, create fails with this error:
BXNUI2032E: An error occurred when contacting Cloud Foundry to create a resource. Resource: routes. Cloud Foundry message: "The host is taken: SentimentAnalysisAPP." ... | 2015/05/25 | [
"https://Stackoverflow.com/questions/30431328",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4933930/"
] | That means the URL "SentimentAnalysisAPP.mybluemix.net" has been taken by someone else.
You need to create a unique host for it.
If you are running cf cli version 6.4 or above, you can use --random-route to let system generate one for you. eg.
cf push SentimentAnalysisAPP --random-route | Like @Ram Vennam said, the problem is that your app name (in this case, SentimentAnalysisAPP) is not unique, that another Bluemix user is already using that app name and URL.
This question is fairly common and has been answered before. You need to search for "BXNUI2032E" and "the host is taken". Then you'll find answe... |
3,093,342 | We have HTML source files which contain special characters encoded as `&#nnnn;` like in the word:
`außergewöhnlich`
We would like to convert them into plain UTF-8:
>
> außergewöhnlich
>
>
>
Is there any small tool to do that? | 2010/06/22 | [
"https://Stackoverflow.com/questions/3093342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274757/"
] | I suppose [ascii2uni](http://billposer.org/Software/uni2ascii.html) tool will perform required conversion.
The size of the tool is about several hundreds kilobytes, it is smaller than lynx, mentioned above. | You can do this with perl, and [`HTML::Entities`](http://search.cpan.org/~gaas/HTML-Parser-3.65/lib/HTML/Entities.pm) if you wish.
```
echo 'echo 'außergewöhnlich' |
perl -MHTML::Entities -pe'binmode STDOUT, ":utf8"; HTML::Entities::decode_entities($_)'
``` |
3,093,342 | We have HTML source files which contain special characters encoded as `&#nnnn;` like in the word:
`außergewöhnlich`
We would like to convert them into plain UTF-8:
>
> außergewöhnlich
>
>
>
Is there any small tool to do that? | 2010/06/22 | [
"https://Stackoverflow.com/questions/3093342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274757/"
] | I suppose [ascii2uni](http://billposer.org/Software/uni2ascii.html) tool will perform required conversion.
The size of the tool is about several hundreds kilobytes, it is smaller than lynx, mentioned above. | Here is a full shell solution (apparently you don't specify the 'language' to be used).
```
foo='außergewöhnlich'
echo "$foo"
außergewöhnlich
eval "$(printf '%s' "$foo" | sed 's/^/printf "/;s/�*\([0-9]*\);/\$( [ \1 -lt 128 ] \&\& printf "\\\\$( printf \"%.3o\\201\" \1)" || \$(which printf) \\\\... |
3,093,342 | We have HTML source files which contain special characters encoded as `&#nnnn;` like in the word:
`außergewöhnlich`
We would like to convert them into plain UTF-8:
>
> außergewöhnlich
>
>
>
Is there any small tool to do that? | 2010/06/22 | [
"https://Stackoverflow.com/questions/3093342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/274757/"
] | You can do this with perl, and [`HTML::Entities`](http://search.cpan.org/~gaas/HTML-Parser-3.65/lib/HTML/Entities.pm) if you wish.
```
echo 'echo 'außergewöhnlich' |
perl -MHTML::Entities -pe'binmode STDOUT, ":utf8"; HTML::Entities::decode_entities($_)'
``` | Here is a full shell solution (apparently you don't specify the 'language' to be used).
```
foo='außergewöhnlich'
echo "$foo"
außergewöhnlich
eval "$(printf '%s' "$foo" | sed 's/^/printf "/;s/�*\([0-9]*\);/\$( [ \1 -lt 128 ] \&\& printf "\\\\$( printf \"%.3o\\201\" \1)" || \$(which printf) \\\\... |
41,016,702 | I'm trying to automatically run an ajax url when my page is fully loaded using `.load()` function. It seems my code doesn't work.
Other information:
* The code is used for tracking affiliate users and is provided on the website for merchant users
* I'm not sure of the `jquery` version but I know my version doesn't a... | 2016/12/07 | [
"https://Stackoverflow.com/questions/41016702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5304955/"
] | This is completely working but just shows this error:
XMLHttpRequest cannot load <https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<http://localhost>' is therefore not allowed access.
This m... | Please check the error in your browser console
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). |
41,016,702 | I'm trying to automatically run an ajax url when my page is fully loaded using `.load()` function. It seems my code doesn't work.
Other information:
* The code is used for tracking affiliate users and is provided on the website for merchant users
* I'm not sure of the `jquery` version but I know my version doesn't a... | 2016/12/07 | [
"https://Stackoverflow.com/questions/41016702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5304955/"
] | I am really puzzled why you need to load a tracking pixel via Ajax:
I used to work in SEO and we would just include the link to the tracking pixel in an image e.g. via
`<img src="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748" width="1" height="1">`.
Then you have no cross... | This is completely working but just shows this error:
XMLHttpRequest cannot load <https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<http://localhost>' is therefore not allowed access.
This m... |
41,016,702 | I'm trying to automatically run an ajax url when my page is fully loaded using `.load()` function. It seems my code doesn't work.
Other information:
* The code is used for tracking affiliate users and is provided on the website for merchant users
* I'm not sure of the `jquery` version but I know my version doesn't a... | 2016/12/07 | [
"https://Stackoverflow.com/questions/41016702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5304955/"
] | I am really puzzled why you need to load a tracking pixel via Ajax:
I used to work in SEO and we would just include the link to the tracking pixel in an image e.g. via
`<img src="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748" width="1" height="1">`.
Then you have no cross... | Please check the error in your browser console
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=49748>. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). |
4,097,752 | How can I increase over 1062px form height in c# forms application ?
I can also use scrollable component for this problem.
Thanks. | 2010/11/04 | [
"https://Stackoverflow.com/questions/4097752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/51151/"
] | A form cannot be taller than the working area of your screen.
**EDIT**: You can make a `Panel` control and set its `AutoScroll` property to true.
However, this will result in a very poor user experience.
You should rethink your UI. | While the form cannot be taller than the working area of your screen you can set `AutoScroll` property on the form instead:
```
form1.AutoScroll = true;
```
This will have the scrollbars to automatically appear when the form contests are larger than its visible area. |
20,906,052 | **I use jdk1.6.0\_24, when I try to mock HTTP session with Mockito I have the next error:**
java.lang.UnsupportedClassVersionError: javax/servlet/http/HttpSession : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)... | 2014/01/03 | [
"https://Stackoverflow.com/questions/20906052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2993815/"
] | Try this:
```
static class Program
{
static void Main(string[] args)
{
var outputCount = 10;
var hours = new[] { 8, 12, 17 };
//var hours = new[] { 12, 17 };
//var hours = new[] { 6, 8, 10, 12, 16, 18, 22};
var d = new DateTime(2014, 01, 02, 15, 00, 00);
var d1 ... | I'm assuming the following: You have consecutively numbered periods. The first period (with index 0) begins on 2 Jan 2014 at 08:00h. You want return a `DateTime` that corresponds to perion `n`. Any three subsequent periods sum up to 24h, but the periods are of different length. The morning (0) and afternoon (1) periods... |
1,985,245 | I need to add a view to `NSOutlineView`.
This view contains some text field and button, while expanding the outlineview should show this view.
Please let me know how to add the view to `NSOutliveView`? | 2009/12/31 | [
"https://Stackoverflow.com/questions/1985245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/241522/"
] | NSTableView and, therefore, NSOutlineView do not gracefully handle subviews. It's not possible to use a view to display content in the way you described. Instead you need to subclass NSCell; each individual field in an NSTableView or NSOutlineView is a cell.
See the [Control and Cell Programming Topics for Cocoa](http... | You may need to post a mock-up picture somewhere to show what you mean (particularly the expanding part).
In general, you can add a view to a subview by using -addSubview: but this tends not to work well with NSTableView and NSOutlineView.
It sounds as if you want a view (as a set of controls) to stay at the bottom... |
37,720,837 | Will commented out CSS still have an impact/overhead of processing when the page is being rendered by the browser?
Or should we always aim to be as clean as possible? | 2016/06/09 | [
"https://Stackoverflow.com/questions/37720837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/27756/"
] | Well for what i have understood about Linux and the "&" optional command, it's already that what you call hidden. You may miss "disown" command so you can run the code in background while being able to close the shell.
>
> start it in the background:
>
>
>
> ```
> command &
>
> ```
>
> then run:
>
>
>
> ```
>... | You could use nohup to run the process in background:
```
$ sudo nohup ./file_name.sh &
```
There will be a new process to execute `file_name.sh`, output will be written to `nohup.out`. |
74,092,530 | I am trying to get hold of the image tag and make its display to none but in no way can I do this. Its giving me this error:script.js:107 Uncaught TypeError: Cannot read properties of undefined (reading 'display')
at view (script.js:107:15)
at HTMLImageElement.onclick (index.html:1:1)(error shown below)
Kindly help me ... | 2022/10/17 | [
"https://Stackoverflow.com/questions/74092530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19211186/"
] | It falls on Apple to track this data. I would start [here](https://help.apple.com/app-store-connect/#/itcf19c873df).
That page has instructions on how to manually find this data. If you need your program to access this data, I would start [here](https://developer.apple.com/documentation/appstoreconnectapi/download_sal... | It's a very deep and complicated story to track these parameters, especially if you're using an *app promotion* campaign.
If you want to do this yourself, here's an idea: you can spin up a redirect link that attributes your installs, then redirects users to the App Store (think: deeplink). If you also research on how ... |
21,122,018 | I understand that the following can be done .
```
User user = new User();
user.setUsername("a");
user.setPassword("abc");
Class c = user.getClass();
```
However I have a situation in which I have to extract the instance information from the variable "c"
Is it even possible ? . We do have a c.newInstance() method... | 2014/01/14 | [
"https://Stackoverflow.com/questions/21122018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1348423/"
] | **Update:**
It seems like, you just want to get the getter methods from your class, and invoke it to get the value for a particular instance.
You can get all the getters using [`Introspector`](http://docs.oracle.com/javase/7/docs/api/java/beans/Introspector.html). Write a generic method, taking 2 arguments - `Class<T... | >
> I need to access the existing instance of the User , which was responsible for creating the "c" variable in the first place
>
>
>
Can't be done because there is no link between the `getClass()` method's result and `c`. The problem is that the `Class` `c` represents an instance of the type of `c` not the partic... |
30,408,026 | I am trying to get the git log from remote server with Laravel built in SSH feature. Everything works but it takes ~7 seconds to connect over SSH, get the log, convert commits into array and then display them in the view. I don't know if it is normal or I need another approach for this, maybe python, cgi ...
This is t... | 2015/05/23 | [
"https://Stackoverflow.com/questions/30408026",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/650574/"
] | I generally do it with Paramiko, its easier
```
import paramiko
# ssh
print 'enter ssh'
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # this will automatically add the keys
ssh.connect(machineHostName, username=user, password=password)
# Run your commands
# example 1 : ls comm... | I ended up building a python API to execute commands in the server rather then connecting via SSH because using SSH library with PHP slows the web site a lot. With python executing commands and returning messages/errors it is a lot more faster (under 1 second). |
27,322,766 | I have two single vector data frames of unequal length
```
aa<-data.frame(c(2,12,35))
bb<-data.frame(c(1,2,3,4,5,6,7,15,22,36))
```
For each observation in aa I want to count the number of instances bb is less than aa
My result:
```
bb<aa
1 1
2 7
3 9
```
I have been able to do it two ways by creating a... | 2014/12/05 | [
"https://Stackoverflow.com/questions/27322766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4296857/"
] | ```
aa<-data.frame(c(2,12,35))
bb<-data.frame(c(1,2,3,4,5,6,7,15,22,36))
sapply(aa[[1]],function(x)sum(bb[[1]]<x))
# [1] 1 7 9
```
Some more realistic examples:
```
n <- 1.6e3
bb <- sample(1:n,1.7e6,replace=T)
aa <- 1:n
system.time(sapply(aa,function(x)sum(bb<x)))
# user system elapsed
# 14.63 2.23 16.8... | My original post I had been looking for the number of times bb
So in my example
```
aa<-data.frame(c(2,12,35))
bb<-data.frame(c(1,2,3,4,5,6,7,15,22,36))
x<-ecdf(bb[,1])
x(2)
[1] 0.2
x(12)
[1] 0.7
x(35)
[1] 0.9
```
To get the answers in my original post I would need to multiply by the number of data poin... |
24,744,899 | Is there any way that search view (after tap/click) expands over android launcher icon like over app title name?
Or maybe, is there a way to change my title to look like launcher icon (like on sreenshot) with some custom font..?
Screenshot:
 | 2014/07/14 | [
"https://Stackoverflow.com/questions/24744899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2107345/"
] | Using this code inside of my `onCreateOptionsMenu()` worked:
```
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setMaxWidth(5000);
searchView.setOnSearchClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
... | Here is an example I have used in the past to create that type of search view.
<http://www.edumobile.org/android/android-development/action-bar-search-view/>
Also the action bar should by default take your launcher icon unless you specifically set an android:logo attribute. You can also modify this programmatically u... |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | With SQL Server 2012 or higher you can do it in one line code:
```
LAG([MyValue],1) OVER (PARTITION BY [Category] ORDER BY [AnyColumnForOrdinal] ASC)
``` | select identity(int,1,1) as Id, \* into #temp from customer
select \* from #temp where Id = (select max(Id) as count from #temp group by Id) - 1
drop table #temp |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | As you asked I can give you example.
Imagine, that you have full bag of apples. How can you take second last apple? How you will know which one is second last? You can't do It while you not sort them in any way.
---
For now your data isn't sorted so you can't achieve It as expected. You can do It in following, onl... | select identity(int,1,1) as Id, \* into #temp from customer
select \* from #temp where Id = (select max(Id) as count from #temp group by Id) - 1
drop table #temp |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | As you asked I can give you example.
Imagine, that you have full bag of apples. How can you take second last apple? How you will know which one is second last? You can't do It while you not sort them in any way.
---
For now your data isn't sorted so you can't achieve It as expected. You can do It in following, onl... | i know this is too late but you can try this.
```
SELECT TOP 1 * FROM (SELECT * FROM dbo.customer
EXCEPT SELECT TOP (SELECT (COUNT(*)-2) FROM dbo.customer ) * FROM dbo.customer) A
``` |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | As you asked I can give you example.
Imagine, that you have full bag of apples. How can you take second last apple? How you will know which one is second last? You can't do It while you not sort them in any way.
---
For now your data isn't sorted so you can't achieve It as expected. You can do It in following, onl... | Posting as an answer as it is a big comment
David: ok i will do it next time but what i can do now for this problem there are many recods in thousand.is there any way to do this?? @Deepanshu Kalara
Me: @david sam, I dont think there is a way to do this now.
Best bet would be copy those thousand records in excel and h... |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | Try this
```
;WITH tbl_rn AS (
select
RowNum = row_number() OVER (ORDER BY @@rowcount),
customerID,
customer_name,
cont_no
from tbl
)
select
customerID,
customer_name,
cont_no
from tbl_rn
where RowNum = (select max(RowNum) - 1 from tbl_rn)
```
Here `RowNum` is ... | With SQL Server 2012 or higher you can do it in one line code:
```
LAG([MyValue],1) OVER (PARTITION BY [Category] ORDER BY [AnyColumnForOrdinal] ASC)
``` |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | As you probably already know, you need a column to order by to achieve this task. OVER Clause be used for this.
```
;WITH CTE as
(
SELECT
customerid, customer_name, cont_no,
row_number() over (order by newlymadesortcolumn desc) rn
FROM customer
)
SELECT customerid, customer_name, cont_no
FROM CTE
WHERE r... | >
> Datas should be sorted before they can be effectively search.
>
>
>
I would recommend to add an extra field in your table id with `autoincrement`.
**Its not a big deal as below :**
[](https://i.stack.imgur.com/nPyHp.png)
Query :
```
SELECT ... |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | As you probably already know, you need a column to order by to achieve this task. OVER Clause be used for this.
```
;WITH CTE as
(
SELECT
customerid, customer_name, cont_no,
row_number() over (order by newlymadesortcolumn desc) rn
FROM customer
)
SELECT customerid, customer_name, cont_no
FROM CTE
WHERE r... | Try this
```
;WITH tbl_rn AS (
select
RowNum = row_number() OVER (ORDER BY @@rowcount),
customerID,
customer_name,
cont_no
from tbl
)
select
customerID,
customer_name,
cont_no
from tbl_rn
where RowNum = (select max(RowNum) - 1 from tbl_rn)
```
Here `RowNum` is ... |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | i know this is too late but you can try this.
```
SELECT TOP 1 * FROM (SELECT * FROM dbo.customer
EXCEPT SELECT TOP (SELECT (COUNT(*)-2) FROM dbo.customer ) * FROM dbo.customer) A
``` | select identity(int,1,1) as Id, \* into #temp from customer
select \* from #temp where Id = (select max(Id) as count from #temp group by Id) - 1
drop table #temp |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | >
> Datas should be sorted before they can be effectively search.
>
>
>
I would recommend to add an extra field in your table id with `autoincrement`.
**Its not a big deal as below :**
[](https://i.stack.imgur.com/nPyHp.png)
Query :
```
SELECT ... | select identity(int,1,1) as Id, \* into #temp from customer
select \* from #temp where Id = (select max(Id) as count from #temp group by Id) - 1
drop table #temp |
31,716,524 | I have a table with many records and I want to know only the record which I have created at second last.
For ex: I have a table `customer` in which `customerID` are random numbers.
**Now I want to select second last row.**
```
customerID customer_name cont_no
---------------------------------------
7 ... | 2015/07/30 | [
"https://Stackoverflow.com/questions/31716524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5150826/"
] | As you probably already know, you need a column to order by to achieve this task. OVER Clause be used for this.
```
;WITH CTE as
(
SELECT
customerid, customer_name, cont_no,
row_number() over (order by newlymadesortcolumn desc) rn
FROM customer
)
SELECT customerid, customer_name, cont_no
FROM CTE
WHERE r... | With SQL Server 2012 or higher you can do it in one line code:
```
LAG([MyValue],1) OVER (PARTITION BY [Category] ORDER BY [AnyColumnForOrdinal] ASC)
``` |
31,436,277 | First of all, I need to split all clients in 2 categories:
* 'new client' - came in 2015 year
* 'old client' - came in 2000-2014 years
To do this - I push them into unrelated dimension 'Calendar'. And it works fine (while pushing them to original [Client] dimension - would raize error, I've checked it). But then, af... | 2015/07/15 | [
"https://Stackoverflow.com/questions/31436277",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4299452/"
] | As noted in [Issue 7707](https://github.com/pydata/pandas/issues/7707) -
>
> you need to specify month=1 and it will work
> (it's interpreting the first arg as the day keyword)
>
>
>
You need to specify the `months` keyword argument.
Example -
```
ts1 = ts + pd.tseries.offsets.MonthOffset(months=1)
``` | I think if you specify the offset value with the arguments months=1, it should work.
```
ts1 = ts + pd.tseries.offsets.MonthOffset(months=1)
print(ts1)
``` |
38,949,958 | >
> [main] WARN org.apache.pig.newplan.BaseOperatorPlan - Encountered Warning IMPLICIT\_CAST\_TO\_LONG 2 time(s).
>
>
>
```
avg_qtime1 = FOREACH avg_qtime GENERATE
qid,
ToDate((long)avg*1000) as avg_ans_time;
``` | 2016/08/15 | [
"https://Stackoverflow.com/questions/38949958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6716648/"
] | The error is caused by <http://github.com/google/oauth2client/issues/578>.
It will be fixed in a couple of weeks with a new AppEngine SDK. In the meantime you can downgrade the version of the oauth2client library in your app.yaml file. | I had this same issue which is a known issue with the SDK. I tried the other solutions suggested on SO (see [Google App Engine 'No module named pwd'](https://stackoverflow.com/q/28668007/7049567)) but it didn't work. I found a work around by installing an older version of oauth2client-2.0.0 overwriting the oauth2client... |
39,624,015 | What is a fast way (in C) to get a corresponding value based on other value from a set of completely unrelated values?
Example:
The values {0xFE, 0x84, 0x35} correspond to values {0, 1, 2}, which are used to index an array of functions.
```
void doStuff(int weirdValue)
{
int correspondingIndex = getIndexFromWeirdV... | 2016/09/21 | [
"https://Stackoverflow.com/questions/39624015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2634349/"
] | *Associative Arrays*, also called *Maps* or *Hashed Maps* or *Red-Black-Trees* would be the right solution for large amounts. Google 'std:map' for more details (that is C++, but you can use the concept, of course you have to implement it yourself)
For small amounts (maybe up to 20 or 30), a simple loop through is even... | With only 3 possible input values mapping to 3 consecutive values.
```
int getIndexFromWeirdValue(int x) {
static const int x[3] = {0xFE, 0x84, 0x35};
static const int y[3] = {0,1,2};
return (x==x[0])*y[0] + (x==x[1])*y[1] + (x==x[2])*y[2];
}
```
Other methods exist that perform in a similar non-branching fash... |
39,624,015 | What is a fast way (in C) to get a corresponding value based on other value from a set of completely unrelated values?
Example:
The values {0xFE, 0x84, 0x35} correspond to values {0, 1, 2}, which are used to index an array of functions.
```
void doStuff(int weirdValue)
{
int correspondingIndex = getIndexFromWeirdV... | 2016/09/21 | [
"https://Stackoverflow.com/questions/39624015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2634349/"
] | In the above example, domain of values is 8 bit so you can have an array of 256 values for that. Similarly if you a set of thousand values, you can simply have an array of that size. Although, this approach will be rough on memory, but it will give O(1) time complexity.
If the domain and range of values is unknown, th... | With only 3 possible input values mapping to 3 consecutive values.
```
int getIndexFromWeirdValue(int x) {
static const int x[3] = {0xFE, 0x84, 0x35};
static const int y[3] = {0,1,2};
return (x==x[0])*y[0] + (x==x[1])*y[1] + (x==x[2])*y[2];
}
```
Other methods exist that perform in a similar non-branching fash... |
53,873,786 | I have a number of rows I want to retrieve from the database but I want to print each row in the exact place I want and only even rows.
Is this possible? If yes, how can I achieve it?
```
<?php
$sql="Select * from plays where usertype=2 and idgame=$idgame";
$result=mysqli_query($link, $sql);
while($row = mysqli_fet... | 2018/12/20 | [
"https://Stackoverflow.com/questions/53873786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10685433/"
] | What you are missing is first opening the file for reading:
```
def checkUsername():
userName = str(input("WHAT IS YOUR NAME?"))
with open("usernames.txt", 'r') as usernames:
if userName in usernames.read():
print("WELCOME BACK" + userName)
print("LET\'S GET STARTED")
... | * You need to [open()](https://docs.python.org/3/library/functions.html#open) the file **before** calling the [read()](https://docs.python.org/3/tutorial/inputoutput.html#methods-of-file-objects) method.
* Check if username isn't empty after using [strip()](https://www.tutorialspoint.com/python/string_strip.htm)
* You ... |
53,873,786 | I have a number of rows I want to retrieve from the database but I want to print each row in the exact place I want and only even rows.
Is this possible? If yes, how can I achieve it?
```
<?php
$sql="Select * from plays where usertype=2 and idgame=$idgame";
$result=mysqli_query($link, $sql);
while($row = mysqli_fet... | 2018/12/20 | [
"https://Stackoverflow.com/questions/53873786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10685433/"
] | What you are missing is first opening the file for reading:
```
def checkUsername():
userName = str(input("WHAT IS YOUR NAME?"))
with open("usernames.txt", 'r') as usernames:
if userName in usernames.read():
print("WELCOME BACK" + userName)
print("LET\'S GET STARTED")
... | One issue with this function is that `usernames` is not defined, and the other is that both ends of the `if` block will return `False`.
One way you could solve these would be
```
def checkUsername(usernames_file):
fp = open(usernames_file, 'r') # the default mode is 'r', but it's explicit here
usernames = f... |
51,523,051 | I've googled a bunch and could find an answer anywhere but that maybe that I couldn't explain it well in few words.
```
Coffee| |Steve
Coffee| Cup | |
Turkey| Fork| |
|Fork |Mike
```
I'd like tho take the data in these four rows and consolidate it into two rows so it is displayed.
```
Coffee|Cu... | 2018/07/25 | [
"https://Stackoverflow.com/questions/51523051",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10134368/"
] | Using `library(tidyverse)` and making bold assumptions about your data set:
```
df <- data.frame(food = c("Coffee","Coffee","Turkey", NA),
utensil = c(NA, "Cup", "Fork", "Fork"),
name = c("Steve", NA, NA, "Mike"))
df <- df %>%
group_by(food) %>%
arrange(utensil) %>%
fill(utensil) %>%
... | I think it's best to decompose the table into a list, remove NA values, then take unique. Then you can just convert back to a data frame. I am using `read_r` to make a data frame here, but the rest is Base R.
```
myTab <- readr::read_csv("h1,h2,h3
Coffee,,Steve
Coffee,Cup,
Turkey,Fork,
,Fork,Mike")
myTab
## # A tibb... |
29,019,337 | I have the following code below to detect the day and time when the user hits a web page.
```
dim time_hour
dim time_min
dim day_name
dim shouldShowNormal
dim showMsg
time_hour = Hour(Now())
time_min = Minute(Now())
day_name = LCase(WeekdayName(Weekday(Now())))
shouldShowNormal = true
if (day_n... | 2015/03/12 | [
"https://Stackoverflow.com/questions/29019337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/277480/"
] | You could extract a function to check if the current time between the time specified, and then you only need to check the day + opening times
Since, from the functions you are using, minutes cannot go higher that 59, a simple function would do (it actually checks if the first 2 parameters are outside of the bounds, in... | ```
Function IsNormalTime(dDateTime)
'// Default is true
IsNormalTime = True
'// Check day of week and set start/end times
dim tStart, tEnd
select case WeekDay(dDateTime)
case 4 '// Wednesday
IsNormalTime = False
tStart = cDate("20:30:00")
tEnd = cDate("21:30:00")
case 5 '// Thursday
... |
9,135,355 | I have a xaml TextBlock bound as follows:
```
<TextBlock Text="{Binding LastName}"/>
```
How do I access SelectedItem.LastName in C# codebehind? Thanks.
Details:
Data are from an XML file
```
<Player>
<LastName>...</LastName>
<Age>...</Age>
</Player>
```
The combobox binding was simplified for clarity as a... | 2012/02/03 | [
"https://Stackoverflow.com/questions/9135355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/776676/"
] | @ughoavgfhw is on the right track, but it's actually much easier. You just need to set `opaque` to `NO` and set `backgroundColor` to semi-transparent.
```
@implementation MYWindow
- (void)setup
{
[self setStyleMask:NSBorderlessWindowMask];
[self setOpaque:NO];
[self setBackgroundColor:[NSColor colorWithCalibra... | Leave the `alphaValue` property to 1, and set the `opaque` property to `NO`. Then, replace the default `contentView` with one which fills itself with a color whose alpha component is 0.3 in its `drawRect:` method. When you change the `alphaValue` property, it changes how everything drawn in the window is displayed. Whe... |
9,135,355 | I have a xaml TextBlock bound as follows:
```
<TextBlock Text="{Binding LastName}"/>
```
How do I access SelectedItem.LastName in C# codebehind? Thanks.
Details:
Data are from an XML file
```
<Player>
<LastName>...</LastName>
<Age>...</Age>
</Player>
```
The combobox binding was simplified for clarity as a... | 2012/02/03 | [
"https://Stackoverflow.com/questions/9135355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/776676/"
] | There's a potential problem with this approach.
Requesting "[self setStyleMask:NSBorderlessWindowMask];" (with any of the possible StyleMask values) will cause the loss of keystroke events to that window on subsequent presentations of the window as a sheet. I reported a bug to Apple today on this point. | Leave the `alphaValue` property to 1, and set the `opaque` property to `NO`. Then, replace the default `contentView` with one which fills itself with a color whose alpha component is 0.3 in its `drawRect:` method. When you change the `alphaValue` property, it changes how everything drawn in the window is displayed. Whe... |
9,135,355 | I have a xaml TextBlock bound as follows:
```
<TextBlock Text="{Binding LastName}"/>
```
How do I access SelectedItem.LastName in C# codebehind? Thanks.
Details:
Data are from an XML file
```
<Player>
<LastName>...</LastName>
<Age>...</Age>
</Player>
```
The combobox binding was simplified for clarity as a... | 2012/02/03 | [
"https://Stackoverflow.com/questions/9135355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/776676/"
] | @ughoavgfhw is on the right track, but it's actually much easier. You just need to set `opaque` to `NO` and set `backgroundColor` to semi-transparent.
```
@implementation MYWindow
- (void)setup
{
[self setStyleMask:NSBorderlessWindowMask];
[self setOpaque:NO];
[self setBackgroundColor:[NSColor colorWithCalibra... | There's a potential problem with this approach.
Requesting "[self setStyleMask:NSBorderlessWindowMask];" (with any of the possible StyleMask values) will cause the loss of keystroke events to that window on subsequent presentations of the window as a sheet. I reported a bug to Apple today on this point. |
11,364,487 | ```
NSString *xml=@"<string>aaaa</string><string>bbbb</string><string>ccccc</string>";
```
I Want to store text of every elemnt in NSMutableArray | 2012/07/06 | [
"https://Stackoverflow.com/questions/11364487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1209231/"
] | Either you use xml parser which is the best option.
I suggest you [TBXML](http://www.tbxml.co.uk/TBXML/TBXML_Free.html) and [its performance is better than others](http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project)
or
Try this. `mtbArray` is you all require
```
NSString *x... | You can better use the [NSXMLParser](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html) for the purpose. Hope this helps you. |
72,365,733 | I would like to know if there is a more efficient way to do this since I have a millions-long dataset that has been stuck for days in this step.
```
for (i in 1:32000000){
if (!exists("df")){
df <- as.data.frame(Properties[[i]])
df <- as.data.frame(t(df))
}else{
temp_dataset <- as.data.frame(Prop... | 2022/05/24 | [
"https://Stackoverflow.com/questions/72365733",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16277186/"
] | A way will be using `rbind` in `do.call`.
```
do.call(rbind, Properties)
```
Benchmark: (Based on @Adam)
```
set.seed(42)
n <- 1e5
Properties <- replicate(n, setNames(runif(3), c("PP1", "PP2", "PP3")), simplify = FALSE)
bench::mark(check = FALSE
, dplyr = dplyr::bind_rows(Properties)
, rbind = do.cal... | You can try using `transpose()` from `data.table`. This should be pretty fast.
Sample data:
```r
n <- 100000
Properties <- replicate(n, setNames(runif(3), c("PP1", "PP2", "PP3")), simplify = FALSE)
head(Properties, 3)
# [[1]]
# PP1 PP2 PP3
# 0.8036237 0.9423731 0.9593770
#
# [[2]]
# PP1 ... |
3,690,246 | I wish to compute this formula in matlab
```
[m,n,d]=size(img1);
matrix1=sum(abs(img1-img2));
a= matrix1/ m*n ;
b=a*100;
```
where img1,img2 are two images of dimension 512\*512\*3
The objective is to obtain a single numeral value, but i am getting a matrix. The actaul formula in case of a matrix A,B with i rows an... | 2010/09/11 | [
"https://Stackoverflow.com/questions/3690246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/389264/"
] | The fact that your image matrices are 3-D indicates that they are [truecolor RGB images](http://www.mathworks.com/help/techdoc/creating_plots/f2-10709.html#f2-12468). For matrix `M`, the first color plane `M(:,:,1)` is the red component, the second color plane `M(:,:,2)` is the green component, and the third color plan... | The sum function is returning a matrix.
<http://faculty.petra.ac.id/resmana/private/matlab-help/techdoc/ref/sum.html>
Your matrix1 is divided by a scalar (equal to 512\*512) - so this also results in a matrix. I believe you wanted to divide by an m by n matrix instead.
Also you need parenthesis around m\*n if you want... |
10,038,167 | ```
class classe (){
public:
int key;
static void *funct(void *context){
printf("Output: %d, ", key);
}
void Go(){
classe c = static_cast<this>(context); //<- This doesn't work, Context of this-> goes here
pthread_create(&t, NULL, &classe::funct, c);
}
};
int main(){
... | 2012/04/06 | [
"https://Stackoverflow.com/questions/10038167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668138/"
] | I can see a few problems with your code:
First, `static_cast<>` requires a type in the `<>`, and `this` acts like a variable (so not a type). The type of `this` is `classe*` (pointer to `classe` object) within `classe`.
Second, there is no `context` available in `classe:Go()`. There is a parameter for `classe::fuct()... | First, you need to define `context` somewhere. Second, `this` is a keyword that represents a pointer to the object that the member function is being called on. `static_cast` requires a type in the template argument. Replace `static_cast<this>` with `static_cast<classe*>`, and change the type of `c` to `classe *` in ord... |
10,038,167 | ```
class classe (){
public:
int key;
static void *funct(void *context){
printf("Output: %d, ", key);
}
void Go(){
classe c = static_cast<this>(context); //<- This doesn't work, Context of this-> goes here
pthread_create(&t, NULL, &classe::funct, c);
}
};
int main(){
... | 2012/04/06 | [
"https://Stackoverflow.com/questions/10038167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668138/"
] | First, you need to define `context` somewhere. Second, `this` is a keyword that represents a pointer to the object that the member function is being called on. `static_cast` requires a type in the template argument. Replace `static_cast<this>` with `static_cast<classe*>`, and change the type of `c` to `classe *` in ord... | You seem to be a little confused about where some of the key parts go. Here's a rough skeleton that I think does most of what you want.
```
class classe {
public:
classe(int k) : key(k) { }
void Go() {
// where does "t" come from?
pthread_create(&t, NULL, &funct, static_cas... |
10,038,167 | ```
class classe (){
public:
int key;
static void *funct(void *context){
printf("Output: %d, ", key);
}
void Go(){
classe c = static_cast<this>(context); //<- This doesn't work, Context of this-> goes here
pthread_create(&t, NULL, &classe::funct, c);
}
};
int main(){
... | 2012/04/06 | [
"https://Stackoverflow.com/questions/10038167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668138/"
] | I can see a few problems with your code:
First, `static_cast<>` requires a type in the `<>`, and `this` acts like a variable (so not a type). The type of `this` is `classe*` (pointer to `classe` object) within `classe`.
Second, there is no `context` available in `classe:Go()`. There is a parameter for `classe::fuct()... | You seem to be a little confused about where some of the key parts go. Here's a rough skeleton that I think does most of what you want.
```
class classe {
public:
classe(int k) : key(k) { }
void Go() {
// where does "t" come from?
pthread_create(&t, NULL, &funct, static_cas... |
10,038,167 | ```
class classe (){
public:
int key;
static void *funct(void *context){
printf("Output: %d, ", key);
}
void Go(){
classe c = static_cast<this>(context); //<- This doesn't work, Context of this-> goes here
pthread_create(&t, NULL, &classe::funct, c);
}
};
int main(){
... | 2012/04/06 | [
"https://Stackoverflow.com/questions/10038167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668138/"
] | I can see a few problems with your code:
First, `static_cast<>` requires a type in the `<>`, and `this` acts like a variable (so not a type). The type of `this` is `classe*` (pointer to `classe` object) within `classe`.
Second, there is no `context` available in `classe:Go()`. There is a parameter for `classe::fuct()... | Try something like this:
```
#include <stdio.h>
#include <pthread.h>
class classe
{
public:
int key;
static void* funct(void *context)
{
classe* c = static_cast<classe*>(context);
printf("Output: %d, ", c->key);
return context;
}
void Go()
{
pthread_t t;
... |
10,038,167 | ```
class classe (){
public:
int key;
static void *funct(void *context){
printf("Output: %d, ", key);
}
void Go(){
classe c = static_cast<this>(context); //<- This doesn't work, Context of this-> goes here
pthread_create(&t, NULL, &classe::funct, c);
}
};
int main(){
... | 2012/04/06 | [
"https://Stackoverflow.com/questions/10038167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/668138/"
] | Try something like this:
```
#include <stdio.h>
#include <pthread.h>
class classe
{
public:
int key;
static void* funct(void *context)
{
classe* c = static_cast<classe*>(context);
printf("Output: %d, ", c->key);
return context;
}
void Go()
{
pthread_t t;
... | You seem to be a little confused about where some of the key parts go. Here's a rough skeleton that I think does most of what you want.
```
class classe {
public:
classe(int k) : key(k) { }
void Go() {
// where does "t" come from?
pthread_create(&t, NULL, &funct, static_cas... |
3,760,313 | I'm doing a jquery plugin that moves the background of a div (based on another plugin). I don't understand why if I've only 1 on element using $(".video").moveBackground(); works well.
If I've 2 elements or more, only works the last one.
The code: <http://jsfiddle.net/7PfEN/> . It doesn't works on jsfiddle but works f... | 2010/09/21 | [
"https://Stackoverflow.com/questions/3760313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/401115/"
] | I believe your problem is that the plugin uses a `sys` object for storing the animation timer, and the `sys` object is global for all of the elements you pass in via a single call to `.moveBackground()`.
So while this won't work...
```
$('.video').moveBackground();
```
I believe this would...
```
$('.video').each(... | First, your jsFiddle is trying to `$(".image").moveBackground()` instead of `$(".video")`
But the real problem is that each call to init() is overwriting your **global** `sys.elem` value. In greatly abbreviated form, here's an approach that might work for you:
```
function init(elem) {
...
$(elem).hover( function... |
50,995,267 | I'm looking to access a value from a tibble using inline code in an R Markdown document.
The following code gives me a 1 x 2 tibble.
```
#library(tidyverse)
#library(knitr)
# Minimal working example
df <- tibble(
Event = c("Swimming","Swimming","Swimming","Camping","Hiking","Hiking")
)
df
# Creates 1 row x 2 colu... | 2018/06/22 | [
"https://Stackoverflow.com/questions/50995267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8453014/"
] | Your line of code that you want to display inline doesn't run even when not in R Markdown, try it in the console. When using special operators like `[`, `[[`, `$` with the pipe, you need to specify them in the prefix rather than infix form like other functions, like this. Note the comparison of your attempted code, and... | Is this what you are after?
```
df %>% count(Event)
# A tibble: 3 x 2
# Event n
# 1 Camping 1
# 2 Hiking 2
# 3 Swimming 3
# To get the first row
(df %>% count(Event))[1,]
# Event n
# 1 Camping 1
``` |
50,995,267 | I'm looking to access a value from a tibble using inline code in an R Markdown document.
The following code gives me a 1 x 2 tibble.
```
#library(tidyverse)
#library(knitr)
# Minimal working example
df <- tibble(
Event = c("Swimming","Swimming","Swimming","Camping","Hiking","Hiking")
)
df
# Creates 1 row x 2 colu... | 2018/06/22 | [
"https://Stackoverflow.com/questions/50995267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8453014/"
] | Your line of code that you want to display inline doesn't run even when not in R Markdown, try it in the console. When using special operators like `[`, `[[`, `$` with the pipe, you need to specify them in the prefix rather than infix form like other functions, like this. Note the comparison of your attempted code, and... | I'm learning several ways to do this - thanks all!
**1.** Following @labatnok:
```
r df %>% count(Event) %>% slice(which.max(n)) %>% {.[1,1]}
```
**2.** Following @mmyoung77:
```
`r df %>% count(Event) %>% arrange(desc(n)) %>% slice(1) %$% Event`
# result
[1] "Swimming"
```
This approach avoids using "which.max... |
50,995,267 | I'm looking to access a value from a tibble using inline code in an R Markdown document.
The following code gives me a 1 x 2 tibble.
```
#library(tidyverse)
#library(knitr)
# Minimal working example
df <- tibble(
Event = c("Swimming","Swimming","Swimming","Camping","Hiking","Hiking")
)
df
# Creates 1 row x 2 colu... | 2018/06/22 | [
"https://Stackoverflow.com/questions/50995267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8453014/"
] | I'm learning several ways to do this - thanks all!
**1.** Following @labatnok:
```
r df %>% count(Event) %>% slice(which.max(n)) %>% {.[1,1]}
```
**2.** Following @mmyoung77:
```
`r df %>% count(Event) %>% arrange(desc(n)) %>% slice(1) %$% Event`
# result
[1] "Swimming"
```
This approach avoids using "which.max... | Is this what you are after?
```
df %>% count(Event)
# A tibble: 3 x 2
# Event n
# 1 Camping 1
# 2 Hiking 2
# 3 Swimming 3
# To get the first row
(df %>% count(Event))[1,]
# Event n
# 1 Camping 1
``` |
37,108,357 | I have applied GEE to the following dataset (str as below). Everything is fine.
```
> str(cd4.5m2)
'data.frame': 1300 obs. of 7 variables:
$ id : Factor w/ 260 levels "1","5","29","32",..: 1 1 1 1 1 2 2 2 2 2 ...
$ Treatment: Factor w/ 4 levels "Alternating",..: 2 2 2 2 2 1 1 1 1 1 ...
$ Age : num 36... | 2016/05/09 | [
"https://Stackoverflow.com/questions/37108357",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5442972/"
] | I changed the correlation structure to AR1, and it worked. I did test the correlation (decreased over time) and AR1 is the correct structure to use.
But normally unstructured should be the save option? | I just reordered my data and it works. I'd like to suggest you try reordering your data like `cd4.5m1<-cd4.5m1[order(cd4.5m1$id),]`. Credits:KDG |
813,370 | Anyone know of a good way to convert a JSON object to nested form fields.
For example: consider a JSON object:
```
{'a':{'b':{'c':'1200'}}}, 'z':'foo', 'bar':{'baz':'1', 'id':2}}
```
I should get:
```
{'a[b][c]':'1200', 'z':'foo', 'bar[baz]':'1', 'bar[id]':2};
```
Any ideas?
I am currently using jquery and it f... | 2009/05/01 | [
"https://Stackoverflow.com/questions/813370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/86847/"
] | So, I have no clue why you want to do what you say you want to do, and I hope you will fill us all in, but this code should be close enough for you to be able to tweak it (this is based on [**some code of mine that I use to find differences in JavaScript object graphs**](https://stackoverflow.com/questions/264430/how-c... | ```
obj = {'a':{'b':{'c':'1200'}}}, 'z':'foo', 'bar':{'baz':'1', 'id':2}}
```
is internally equivalent to
```
{['a']['b']['c']:'1200', ['z']:'foo', ['bar']['baz']:'1', ['bar']['id']:2}
```
Please note that this is not JSON object anymore.
You already can refer first object properties in this way:
```
var z = obj... |
813,370 | Anyone know of a good way to convert a JSON object to nested form fields.
For example: consider a JSON object:
```
{'a':{'b':{'c':'1200'}}}, 'z':'foo', 'bar':{'baz':'1', 'id':2}}
```
I should get:
```
{'a[b][c]':'1200', 'z':'foo', 'bar[baz]':'1', 'bar[id]':2};
```
Any ideas?
I am currently using jquery and it f... | 2009/05/01 | [
"https://Stackoverflow.com/questions/813370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/86847/"
] | So, I have no clue why you want to do what you say you want to do, and I hope you will fill us all in, but this code should be close enough for you to be able to tweak it (this is based on [**some code of mine that I use to find differences in JavaScript object graphs**](https://stackoverflow.com/questions/264430/how-c... | I would actually recommend a function that takes a nested JSON object and turns it into a HTTP POST string. jQuery will accept that for all of its arguments that require HTTP parameters.
I have written and used the function below in several production apps (use at your own risk):
```
$.httpSerialize = function(items,... |
813,370 | Anyone know of a good way to convert a JSON object to nested form fields.
For example: consider a JSON object:
```
{'a':{'b':{'c':'1200'}}}, 'z':'foo', 'bar':{'baz':'1', 'id':2}}
```
I should get:
```
{'a[b][c]':'1200', 'z':'foo', 'bar[baz]':'1', 'bar[id]':2};
```
Any ideas?
I am currently using jquery and it f... | 2009/05/01 | [
"https://Stackoverflow.com/questions/813370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/86847/"
] | ```
obj = {'a':{'b':{'c':'1200'}}}, 'z':'foo', 'bar':{'baz':'1', 'id':2}}
```
is internally equivalent to
```
{['a']['b']['c']:'1200', ['z']:'foo', ['bar']['baz']:'1', ['bar']['id']:2}
```
Please note that this is not JSON object anymore.
You already can refer first object properties in this way:
```
var z = obj... | I would actually recommend a function that takes a nested JSON object and turns it into a HTTP POST string. jQuery will accept that for all of its arguments that require HTTP parameters.
I have written and used the function below in several production apps (use at your own risk):
```
$.httpSerialize = function(items,... |
137,264 | I've finished the game, got all the items except one. This is the one to the right of the green shark fin. What and where is it? | 2013/10/24 | [
"https://gaming.stackexchange.com/questions/137264",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/57976/"
] | It's the purple fin as they already said.
The trick to get it is to squeeze and keep yourself as high as you can in the screen, then just spam black\_demons to kill sharks (I recommend to have the unicorn horn to do this).
If you have enough HP and HP regen you won't die till very late, when there're already 3 snakes... | I saw the answer in another thread on here. Its the Purple Fin. You have to go through the sea for a very long time and end up at a point where you basically have three sharks and two snakes on screen at any one time, so you need mega health to get there. |
41,103,948 | I am trying to use the copyTo function in google sheets api via node.js wherein it would copy a sheet from one spreadsheet to another. Here is my code:
```
function copySheet(auth){
var sheets = google.sheets('v4');
var spreadsheetID_foo = 'some spreadsheet id';
var spreadsheetID_test = 'another spreadsheet id';
shee... | 2016/12/12 | [
"https://Stackoverflow.com/questions/41103948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1427873/"
] | Change your OR to AND
```
DELETE FROM MyRecords
WHERE Column_1 NOT LIKE '01%' AND Column_1 NOT LIKE '10%'
```
Another option
```
DELETE FROM MyRecords
WHERE Left(Column_1,2) NOT IN ('01','10')
```
(A little more readable but won't use the index) | First identify which records you want to keep ('01%' & '10%'),
```
Select * MyRecords WHERE (Column_1 LIKE '01%' OR Column_1 LIKE '10%');
```
then put a NOT in front of the conditions and change it to a delete.
```
DELETE FROM MyRecords WHERE NOT (Column_1 LIKE '01%' OR Column_1 LIKE '10%');
```
This makes it ve... |
14,555 | First: I would consider myself an advanced beginner in terms of administration. I know enough to be dangerous to myself and my projects :)
I have an addon website hosted at HostGator. The HostGator server basically treats addons like subdomains, but presents them publicly as separate websites.
I installed Joomla! 3 ... | 2015/12/03 | [
"https://joomla.stackexchange.com/questions/14555",
"https://joomla.stackexchange.com",
"https://joomla.stackexchange.com/users/7370/"
] | The preceding period to the htaccess name is NOT a typo like you believe - that is how it should be - the complete file name SHOULD BE:
`.htaccess`
If you have "htaccess" then that is the reason that internal links are not being rewritten back to being processed with index.php as the "htaccess" file is never used by... | There is no problem with changing the directory in Cpanel as long as the corresponding change is made in the configuration.php file and possibly in your root directory .htaccess file as well.
So check `public $live_site = '';` in your configuration.php
since whatever is between the two single quotes `''` determines yo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.