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 |
|---|---|---|---|---|---|
37,633 | For an ordinary bicycle (neither fixed gear nor capable of changing any gears).
Is it possible to modify it to **have a reverse gear** on it?
(i.e. reverse pedaling causes the bicycle to go backward)
(By modifying or attaching components to the rear wheel)
Thank you in advance | 2016/03/14 | [
"https://bicycles.stackexchange.com/questions/37633",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/25010/"
] | I have repaired a pedal powered toy that had an arrangement like this. It was an Italian ride-on toy tractor that had a modified coaster brake set up so that instead of back pedalling applying a brake, the "brake" mechanism inside the hub locked against the hub body so that you could pedal the toy backwards. The modifi... | Yes. Some type of freewheel or freehub manual lockup should do the trick. It would also be cool if you could pedal backwards to apply power forwards, thus using muscles in a different way. |
37,633 | For an ordinary bicycle (neither fixed gear nor capable of changing any gears).
Is it possible to modify it to **have a reverse gear** on it?
(i.e. reverse pedaling causes the bicycle to go backward)
(By modifying or attaching components to the rear wheel)
Thank you in advance | 2016/03/14 | [
"https://bicycles.stackexchange.com/questions/37633",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/25010/"
] | Have a look at the system Berg toys use for their go-karts. Its called a **BFR hub** (for brake, forward and reverse). This hub lets you go forward or backward, while always pedalling in forward direction. It also has a freewheel.
The system needs two chains, with this being in the middle of your drive sprocket and ax... | Cut then weld the bottom cranks and rear hub of two bikes to mirror the drive side. You will have gears and chains on both sides of your bike. -]---[- To make one ride backwards full time, just swap the parts right to left. |
37,633 | For an ordinary bicycle (neither fixed gear nor capable of changing any gears).
Is it possible to modify it to **have a reverse gear** on it?
(i.e. reverse pedaling causes the bicycle to go backward)
(By modifying or attaching components to the rear wheel)
Thank you in advance | 2016/03/14 | [
"https://bicycles.stackexchange.com/questions/37633",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/25010/"
] | Such a hub exists for trike and quads . Pedal forward with 3 or 5 gears then having a coaster brake to stop . At full stop with the brake engaged continued backward pedal pressure will cause the cycle will move in reverse in a reduced gear . Sturmey-Archer has made these hubs for the niche market (velomobiles ) for som... | While it may be possible, by creating a mechanism that shifts the chain from one freewheel to another, or disconnecting one temporarily through mechanical actuators, the hassle and engineering it would take to make happen would be outweighed by the fact that it is almost entirely pointless. A fixed gear would be your b... |
37,633 | For an ordinary bicycle (neither fixed gear nor capable of changing any gears).
Is it possible to modify it to **have a reverse gear** on it?
(i.e. reverse pedaling causes the bicycle to go backward)
(By modifying or attaching components to the rear wheel)
Thank you in advance | 2016/03/14 | [
"https://bicycles.stackexchange.com/questions/37633",
"https://bicycles.stackexchange.com",
"https://bicycles.stackexchange.com/users/25010/"
] | While it may be possible, by creating a mechanism that shifts the chain from one freewheel to another, or disconnecting one temporarily through mechanical actuators, the hassle and engineering it would take to make happen would be outweighed by the fact that it is almost entirely pointless. A fixed gear would be your b... | Yes. Some type of freewheel or freehub manual lockup should do the trick. It would also be cool if you could pedal backwards to apply power forwards, thus using muscles in a different way. |
51,123,365 | Before everything, I read:
[question 1 regarding process is not defined](https://stackoverflow.com/questions/48325449/referenceerror-process-is-not-defined-error-in-heroku-app-with-node-and-socket)
[question 2 regarding process is not defined](https://stackoverflow.com/questions/30239060/uncaught-referenceerror-proce... | 2018/07/01 | [
"https://Stackoverflow.com/questions/51123365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9961496/"
] | We found that the last solution in [this thread](https://stackoverflow.com/questions/50313745/angular-6-process-is-not-defined-when-trying-to-serve-application/50313953) worked for us:
Specifically:
```
npm i -S process, then add this to polyfill.ts:
import * as process from 'process';
window['process'] = process... | Updating Elastic search client to 15.1.1 resolved similar kind problem
```
"elasticsearch": "^15.1.1",
```
Please try this. |
66,950,757 | I want to invoke setApiHelper method in the below code using java reflection. How can I do so?
```
object PlayerUtils {
private var apiHelper: String? = null
fun setApiHelper(apiHelper: String) {
this.apiHelper = apiHelper
println(apiHelper)
}
fun getApiHelper(): String? {
retu... | 2021/04/05 | [
"https://Stackoverflow.com/questions/66950757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5903601/"
] | Usually when you want to access `object` declared in Kotlin using Java code, you can do like below code snippet:
```
PlayerUtils.INSTANCE.setApiHelper("");
//or
PlayerUtils.INSTANCE.getApiHelper();
```
Now that being said, in order to access methods of `PlayerUtils` in Java using reflection, you'll need to access it... | You need to set accessible true for the method as below -
```
Class<?> cls = Class.forName("reflection.PlayerUtils");
cls.newInstance();
Method method = cls.getDeclaredMethod("setApiHelper");
method.setAccessible(true);
method.invoke(cls.newInstance(), "TESTING");
``` |
67,588,992 | I'm using Pandoc v1.12.2.1 to convert `html` to `docx`. It's working, generally, but I'm trying to get it to read in a `docx` template file so I can tell it to use Arial for the font and to make all headings black (instead of blue as they're coming out at the moment).
The template file is at
```
/path/to/my/project/p... | 2021/05/18 | [
"https://Stackoverflow.com/questions/67588992",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/138557/"
] | Pandoc 1.x expects the reference document to be passed via the `--reference-docx` command line parameter. Conceptually the reference doc is different from a template, as the latter allows to use conditionals and variable substitution. A different command line flag is used to make the difference more recognizable.
Note... | The short answer is "Do it in Windows". I emailed the template to my Windows laptop, loaded the docx into Word in Windows 10, updated the styles in that, and then emailed it back to myself and used it in Linux, and it instantly worked.
So, there must be some difference to how LibreOffice saves docx stylesheets, compar... |
62,791,646 | I am pretty new to Tornado. I can't understand the difference between using `run_on_executor` and defining an `async` method. Is it the same? Is the one multithreaded and the other not?
Thank you in advance. | 2020/07/08 | [
"https://Stackoverflow.com/questions/62791646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7674438/"
] | `run_on_executor` is for interfacing with blocking non-async code.
You are correct that async code is only executed in a single thread.
Maybe an example would illustrate the point.
Let's say your Tornado web service interfaces with a library that makes use of `requests` to fetch country info for a given IP address. S... | From the docs
>
> Utilities for working with Future objects.
>
>
> Tornado previously provided its own Future class, but now uses
> asyncio.Future. This module contains utility functions for working
> with **asyncio**.Future in a way that is backwards-compatible with
> Tornado’s old Future implementation.
>
>
> W... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | There is a super hacky way of doing this using a getter defined on `String.prototype` as a helper function.
*(You probably don't want to do that)*
```js
Object.defineProperty (String.prototype, "asNumber",{
get: function () { return +this}
});
let input = {latitude: "17.0009", longitude: "82.2108"}
let {latitu... | I would probably set things up so that each "object type" I cared about had a corresponding "parser type": an object with the same keys, but whose values are the appropriate parsing functions for each member.
Like so:
```js
"use strict";
var arr = {
latitude: "17.0009",
longitude: "82.2108"
};
function... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | Whilst you cannot perform type conversion within the destructuring expression itself, a possible alternative/workaround could be to destructure the properties within the arguments of a function, and then return an array with the new types within it.
For example, something like the following:
```js
const input = {lat... | I would probably set things up so that each "object type" I cared about had a corresponding "parser type": an object with the same keys, but whose values are the appropriate parsing functions for each member.
Like so:
```js
"use strict";
var arr = {
latitude: "17.0009",
longitude: "82.2108"
};
function... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | You could destructure the values, take an array of the values and map the a new data type of the value and assign this values back to the variables.
```js
let input = { latitude: "17.0009", longitude: "82.2108" },
{ latitude, longitude} = input;
[latitude, longitude] = [latitude, longitude].map(Number);
conso... | Whilst you cannot perform type conversion within the destructuring expression itself, a possible alternative/workaround could be to destructure the properties within the arguments of a function, and then return an array with the new types within it.
For example, something like the following:
```js
const input = {lat... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | Destructuring is just a nice way to unpack properties from objects and arrays and assign them to variables. As the trasnpiled code in the question suggests, any kind of operation is not possible.
One *hack* would be to create 2 more variables (which don't exist in `input`) and set the [default value](https://developer... | It's not possible - no operations can be performed on a property during destructuring. If you use destructuring to extract a property into a variable, that variable will be `===` to the original property value.
(of course, you could transform the original object's values to Number prior to destructuring, but that's no... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | If you don't mind using `lodash`, you can try this:
```
import { mapValues } from 'lodash';
const input = {latitude: "17.0009", longitude: "82.2108"}
const {latitude, longitude} = mapValues(input, Number);
``` | I would probably set things up so that each "object type" I cared about had a corresponding "parser type": an object with the same keys, but whose values are the appropriate parsing functions for each member.
Like so:
```js
"use strict";
var arr = {
latitude: "17.0009",
longitude: "82.2108"
};
function... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | You could have a **reusable function**, like this below:
```
const numberInputs = input =>
Object.keys(input).reduce((acc, val) => {
acc[val] = +input[val];
return acc;
}, {});
```
and then reuse it across...
Then do:
```
let {latitude,longitude} = numberInputs(input);
console.log(typeof l... | It's not possible - no operations can be performed on a property during destructuring. If you use destructuring to extract a property into a variable, that variable will be `===` to the original property value.
(of course, you could transform the original object's values to Number prior to destructuring, but that's no... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | It's not possible - no operations can be performed on a property during destructuring. If you use destructuring to extract a property into a variable, that variable will be `===` to the original property value.
(of course, you could transform the original object's values to Number prior to destructuring, but that's no... | I would probably set things up so that each "object type" I cared about had a corresponding "parser type": an object with the same keys, but whose values are the appropriate parsing functions for each member.
Like so:
```js
"use strict";
var arr = {
latitude: "17.0009",
longitude: "82.2108"
};
function... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | Destructuring is just a nice way to unpack properties from objects and arrays and assign them to variables. As the trasnpiled code in the question suggests, any kind of operation is not possible.
One *hack* would be to create 2 more variables (which don't exist in `input`) and set the [default value](https://developer... | There is a super hacky way of doing this using a getter defined on `String.prototype` as a helper function.
*(You probably don't want to do that)*
```js
Object.defineProperty (String.prototype, "asNumber",{
get: function () { return +this}
});
let input = {latitude: "17.0009", longitude: "82.2108"}
let {latitu... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | You could destructure the values, take an array of the values and map the a new data type of the value and assign this values back to the variables.
```js
let input = { latitude: "17.0009", longitude: "82.2108" },
{ latitude, longitude} = input;
[latitude, longitude] = [latitude, longitude].map(Number);
conso... | It's not possible - no operations can be performed on a property during destructuring. If you use destructuring to extract a property into a variable, that variable will be `===` to the original property value.
(of course, you could transform the original object's values to Number prior to destructuring, but that's no... |
55,194,119 | [react-native run-android log](https://i.stack.imgur.com/0bN2u.png)
please ask for any sufficient data needed for the solution. also i am new in react-native and would like to learn more on it | 2019/03/16 | [
"https://Stackoverflow.com/questions/55194119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11211796/"
] | You could destructure the values, take an array of the values and map the a new data type of the value and assign this values back to the variables.
```js
let input = { latitude: "17.0009", longitude: "82.2108" },
{ latitude, longitude} = input;
[latitude, longitude] = [latitude, longitude].map(Number);
conso... | If you don't mind using `lodash`, you can try this:
```
import { mapValues } from 'lodash';
const input = {latitude: "17.0009", longitude: "82.2108"}
const {latitude, longitude} = mapValues(input, Number);
``` |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | converting to string just to get the length won't work if there is a decimal or it's large enough that the string conversion uses scientific notation.
```
var size = floor(log(num)/log(10))+1;
```
This will give the place of the highest significant digit (1 to 9 results in 1, 10 to 99 results in 2, 100 to 999 result... | It does currently not work for negative numbers – also a user of the API may just assume this – which could easily be solved by using the absolute value of the input number:
```
if(Math.abs(num) < 1000) {
``` |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | converting to string just to get the length won't work if there is a decimal or it's large enough that the string conversion uses scientific notation.
```
var size = floor(log(num)/log(10))+1;
```
This will give the place of the highest significant digit (1 to 9 results in 1, 10 to 99 results in 2, 100 to 999 result... | Looks pretty clear for me, A few things:
1 - If is less than 1k, avoid the other operations, so after the type-check, add that validation.
2 - For more expressibility, considerate using a dictionary or avoid array of suffix.
```
function abbreviationNumber (num) {
if(typeof num !== 'number') {
... |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | converting to string just to get the length won't work if there is a decimal or it's large enough that the string conversion uses scientific notation.
```
var size = floor(log(num)/log(10))+1;
```
This will give the place of the highest significant digit (1 to 9 results in 1, 10 to 99 results in 2, 100 to 999 result... | None of the given answers - or the original code for that - is actually *correct*.
Here is a minimal test harness to test the heart of the whole problem: Figuring out the right exponent for a given number:
```
function test(input, expected, func) {
var result = func(input);
if (result !== expected) {
... |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | It does currently not work for negative numbers – also a user of the API may just assume this – which could easily be solved by using the absolute value of the input number:
```
if(Math.abs(num) < 1000) {
``` | Looks pretty clear for me, A few things:
1 - If is less than 1k, avoid the other operations, so after the type-check, add that validation.
2 - For more expressibility, considerate using a dictionary or avoid array of suffix.
```
function abbreviationNumber (num) {
if(typeof num !== 'number') {
... |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | Your function does not entirely work as you would expect for larger numbers.
I did some testing of your code in my browser's console and I came across this:
```
> abbrNum(1234567890123)
"1.2T"
> abbrNum(1234567890123456)
"1.2T"
```
You should add some support for when a number is too big. Perhaps you could throw an... | It does currently not work for negative numbers – also a user of the API may just assume this – which could easily be solved by using the absolute value of the input number:
```
if(Math.abs(num) < 1000) {
``` |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | It does currently not work for negative numbers – also a user of the API may just assume this – which could easily be solved by using the absolute value of the input number:
```
if(Math.abs(num) < 1000) {
``` | None of the given answers - or the original code for that - is actually *correct*.
Here is a minimal test harness to test the heart of the whole problem: Figuring out the right exponent for a given number:
```
function test(input, expected, func) {
var result = func(input);
if (result !== expected) {
... |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | Your function does not entirely work as you would expect for larger numbers.
I did some testing of your code in my browser's console and I came across this:
```
> abbrNum(1234567890123)
"1.2T"
> abbrNum(1234567890123456)
"1.2T"
```
You should add some support for when a number is too big. Perhaps you could throw an... | Looks pretty clear for me, A few things:
1 - If is less than 1k, avoid the other operations, so after the type-check, add that validation.
2 - For more expressibility, considerate using a dictionary or avoid array of suffix.
```
function abbreviationNumber (num) {
if(typeof num !== 'number') {
... |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | Looks pretty clear for me, A few things:
1 - If is less than 1k, avoid the other operations, so after the type-check, add that validation.
2 - For more expressibility, considerate using a dictionary or avoid array of suffix.
```
function abbreviationNumber (num) {
if(typeof num !== 'number') {
... | None of the given answers - or the original code for that - is actually *correct*.
Here is a minimal test harness to test the heart of the whole problem: Figuring out the right exponent for a given number:
```
function test(input, expected, func) {
var result = func(input);
if (result !== expected) {
... |
100,606 | I'm very new to JavaScript, so I'm not sure how to optimize the following code (which seems to run fine) further, though I did try to implement a few tips found on the web — such as using local variables for document elements, using do/while loops instead of for, or using `join` for string concatenation. I've read abou... | 2015/08/11 | [
"https://codereview.stackexchange.com/questions/100606",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/80961/"
] | Your function does not entirely work as you would expect for larger numbers.
I did some testing of your code in my browser's console and I came across this:
```
> abbrNum(1234567890123)
"1.2T"
> abbrNum(1234567890123456)
"1.2T"
```
You should add some support for when a number is too big. Perhaps you could throw an... | None of the given answers - or the original code for that - is actually *correct*.
Here is a minimal test harness to test the heart of the whole problem: Figuring out the right exponent for a given number:
```
function test(input, expected, func) {
var result = func(input);
if (result !== expected) {
... |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | **Try this code:**
The below code used to check the text presence in the entire web page.
```
if(driver.getPageSource().contains("your Text"))
{
//Click xyz
}
else
{
//Click abc
}
```
If you want to check the text on a particular web element
```
if(driver.findElement(By.id("Locator ID")).getText().equalsI... | Here we can use try ,except function using python web driver. see below the code
```
webtable=driver.find_element_by_xpath("xpath value")
print webtable.text
try:
xyz=driver.find_element_by_xpath(("xpath value")
xyz.click()
except:
abc=driver.find_element_by_xpath(("xpath value")
abc.click()
``` |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | First of all, XPaths of this type and `byLinkText` are really bad locators and will fail frequently. The locators should be **descriptive, unique, and unlikely to change**. Priority is to use:
1. **ID**
2. **Class**
3. **CSS** ([better performence than XPath](http://elementalselenium.com/tips/34-xpath-vs-css-revisited... | Here we can use try ,except function using python web driver. see below the code
```
webtable=driver.find_element_by_xpath("xpath value")
print webtable.text
try:
xyz=driver.find_element_by_xpath(("xpath value")
xyz.click()
except:
abc=driver.find_element_by_xpath(("xpath value")
abc.click()
``` |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | Here we can use try ,except function using python web driver. see below the code
```
webtable=driver.find_element_by_xpath("xpath value")
print webtable.text
try:
xyz=driver.find_element_by_xpath(("xpath value")
xyz.click()
except:
abc=driver.find_element_by_xpath(("xpath value")
abc.click()
``` | Try this below code:-
```
Assert.assertTrue(driver.getPageSource().contains(textOnThePage));
``` |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | **Try this code:**
The below code used to check the text presence in the entire web page.
```
if(driver.getPageSource().contains("your Text"))
{
//Click xyz
}
else
{
//Click abc
}
```
If you want to check the text on a particular web element
```
if(driver.findElement(By.id("Locator ID")).getText().equalsI... | You need to wrap the "IsDisplayed" in a try catch. "IsDisplayed" can only be called if the element exists.
You may want to override the Implicit Time Out as well, else the try/catch will take a long time. |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | **Try this code:**
The below code used to check the text presence in the entire web page.
```
if(driver.getPageSource().contains("your Text"))
{
//Click xyz
}
else
{
//Click abc
}
```
If you want to check the text on a particular web element
```
if(driver.findElement(By.id("Locator ID")).getText().equalsI... | First of all, XPaths of this type and `byLinkText` are really bad locators and will fail frequently. The locators should be **descriptive, unique, and unlikely to change**. Priority is to use:
1. **ID**
2. **Class**
3. **CSS** ([better performence than XPath](http://elementalselenium.com/tips/34-xpath-vs-css-revisited... |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | **Try this code:**
The below code used to check the text presence in the entire web page.
```
if(driver.getPageSource().contains("your Text"))
{
//Click xyz
}
else
{
//Click abc
}
```
If you want to check the text on a particular web element
```
if(driver.findElement(By.id("Locator ID")).getText().equalsI... | Try this below code:-
```
Assert.assertTrue(driver.getPageSource().contains(textOnThePage));
``` |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | First of all, XPaths of this type and `byLinkText` are really bad locators and will fail frequently. The locators should be **descriptive, unique, and unlikely to change**. Priority is to use:
1. **ID**
2. **Class**
3. **CSS** ([better performence than XPath](http://elementalselenium.com/tips/34-xpath-vs-css-revisited... | You need to wrap the "IsDisplayed" in a try catch. "IsDisplayed" can only be called if the element exists.
You may want to override the Implicit Time Out as well, else the try/catch will take a long time. |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | You need to wrap the "IsDisplayed" in a try catch. "IsDisplayed" can only be called if the element exists.
You may want to override the Implicit Time Out as well, else the try/catch will take a long time. | Try this below code:-
```
Assert.assertTrue(driver.getPageSource().contains(textOnThePage));
``` |
14,974,526 | I have a code to copy propper configuration file on deploy:
```
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CopyConfigFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CopyConfigFile... | 2013/02/20 | [
"https://Stackoverflow.com/questions/14974526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/761244/"
] | First of all, XPaths of this type and `byLinkText` are really bad locators and will fail frequently. The locators should be **descriptive, unique, and unlikely to change**. Priority is to use:
1. **ID**
2. **Class**
3. **CSS** ([better performence than XPath](http://elementalselenium.com/tips/34-xpath-vs-css-revisited... | Try this below code:-
```
Assert.assertTrue(driver.getPageSource().contains(textOnThePage));
``` |
37,429,502 | I want to get string like `"99.99%"` from `Double`,and I used format to get this:
```
let rate = 99.99999
let str = String(format: "%.2f%", rate)
// output 99.99
```
And `\%` is not allowed. So how to add percent sign in string format, please help me! | 2016/05/25 | [
"https://Stackoverflow.com/questions/37429502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5234233/"
] | write `%` twice:
```
rate = 99.99
let str = String(format: "%.2f%%", rate)
``` | >
> The % symbol has a special use in a printf statement. How would you
> place this character as part of the output on the screen?
>
>
>
You can do this by using %% in the printf statement. For example, you can write printf(“10%%”) to have the output appear as 10% on the screen.
Hope it help you :) |
64,225,690 | I want to save all my email messages from the inbox folder of outlook using Python. I can save the First or the last messages but couldn't understand how to get all the messages of the folder. Hence, I was trying to use a loop to iterate the code for all mails. I have tried to use the following code:
```
from win32com... | 2020/10/06 | [
"https://Stackoverflow.com/questions/64225690",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5599538/"
] | The problem is below
```
message = messages.GetLast()
name = str(message.subject)
```
and
```
message.SaveAs(os.getcwd()+'//'+name)
```
You calculate the name once (before the loop) and use it in the loop.
You need to calculate the name during the loop. | The full code would look something like this.... (I got this answer from balderman)
```
from win32com.client import Dispatch
import os
import re
os.chdir("D:\\email")
outlook = Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6)
messages = inbox.items
for message in messages:
... |
38,006,308 | I am new to AngularJS and I want to set maximum value from JSON response.
**My JSON response :**
```
var json_response = [
{
"division": "Development",
"divisionactualcount": "100",
"divisiontargetcount": "10"
},
{
"division": "QA",
"divisionactualcount": "200",
"divisiontargetcount": "1... | 2016/06/24 | [
"https://Stackoverflow.com/questions/38006308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5819537/"
] | You can't move or resize a widget inside a layout because its position and its size are managed by the layout. If you want to manage its geometry yourself, do not use a layout. | Qt layouts are designed to help you make scalable user interfaces. For this, moving or resizing the button is usually done by the layout using [`sizeHint()`](http://doc.qt.io/qt-5/qwidget.html#sizeHint-prop) and [`sizePolicy()`](http://doc.qt.io/qt-5/qwidget.html#sizePolicy-prop).
I would suggest reading up on how to ... |
38,006,308 | I am new to AngularJS and I want to set maximum value from JSON response.
**My JSON response :**
```
var json_response = [
{
"division": "Development",
"divisionactualcount": "100",
"divisiontargetcount": "10"
},
{
"division": "QA",
"divisionactualcount": "200",
"divisiontargetcount": "1... | 2016/06/24 | [
"https://Stackoverflow.com/questions/38006308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5819537/"
] | You can't move or resize a widget inside a layout because its position and its size are managed by the layout. If you want to manage its geometry yourself, do not use a layout. | Well I found a solution to that
Break the Layout, arrange the widgets and then set the layout |
2,338 | Let's say I managed to realize something interesting, tricky and not foundable with a simple web search.
Should I post it on Ask Ubuntu, with me asking a question and answering it myself right after? | 2012/01/19 | [
"https://meta.askubuntu.com/questions/2338",
"https://meta.askubuntu.com",
"https://meta.askubuntu.com/users/5592/"
] | Absolutely!
I [do](https://askubuntu.com/questions/93334/how-do-i-make-quickly-apps-install-into-opt) [that](https://askubuntu.com/questions/82322/how-do-i-fix-broken-networking-in-cloned-virtual-machines) [all](https://askubuntu.com/questions/60712/how-do-i-quickly-encrypt-a-file-with-aes) [the](https://askubuntu.com... | Just a follow up since this won't fit in a comment, but I've been using AU as a sort of "personal documentation system" for when I am trying to do something and the information on the net is bad and I want to make sure that it's available to people and in a place where it can be peer reviewed:
Pre-write your answer ah... |
2,674,353 | Question :
$x^4 + px^3 + qx^2 + px + 1 =0 $ has real roots. Then what is the minimum value of $ p^2 +q^2 $ .
How I started ?
I started by dividing the whole equation by $x^2$ then we get
$ (x + \frac{1}{x} ) ^2 + p (x + \frac{1}{x} ) + q - 2 = 0 $
Then put $(x + \frac{1}{x} ) = t$. Then discriminant should be grea... | 2018/03/03 | [
"https://math.stackexchange.com/questions/2674353",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | I find the following characterizations extremely helpful for both intuition and also computations:
1. The interior of a set $A$ is the largest open set that is contained in $A$.
2. The closure of a set $A$ is the smallest closed set containing $A$.
So for instance, when you try to argue that the disk $$D=\{x \in \ma... | A point $ b $ is in the boundary of a set $A$ if every open ball B(b;r) contains
a point inside $A$ and a point outside $A$.
Note that in metric topology drawing a graph is often helpful.
For a disk $B(b;r )$ the boundary is the circle $d(x,b)=r $.
Because every open ball centered at $x$ has points for which $d(x... |
2,674,353 | Question :
$x^4 + px^3 + qx^2 + px + 1 =0 $ has real roots. Then what is the minimum value of $ p^2 +q^2 $ .
How I started ?
I started by dividing the whole equation by $x^2$ then we get
$ (x + \frac{1}{x} ) ^2 + p (x + \frac{1}{x} ) + q - 2 = 0 $
Then put $(x + \frac{1}{x} ) = t$. Then discriminant should be grea... | 2018/03/03 | [
"https://math.stackexchange.com/questions/2674353",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | I find the following characterizations extremely helpful for both intuition and also computations:
1. The interior of a set $A$ is the largest open set that is contained in $A$.
2. The closure of a set $A$ is the smallest closed set containing $A$.
So for instance, when you try to argue that the disk $$D=\{x \in \ma... | Hope the following proof helps.
So with $B=B\_{r}(a)=\{x\in{\bf{R}}^{n}:|x-a|<r\}$, we are to prove that $\partial B=S\_{r}(a)=\{x\in{\bf{R}}^{n}:|x-a|=r\}$.
Given $\epsilon>0$ and $x\in S\_{r}(a)$, we need to find $x\_{\epsilon}\in B$, $y\_{\epsilon}\in B^{c}$ such that $x\_{\epsilon},y\_{\epsilon}\in B\_{\epsilon}(... |
2,674,353 | Question :
$x^4 + px^3 + qx^2 + px + 1 =0 $ has real roots. Then what is the minimum value of $ p^2 +q^2 $ .
How I started ?
I started by dividing the whole equation by $x^2$ then we get
$ (x + \frac{1}{x} ) ^2 + p (x + \frac{1}{x} ) + q - 2 = 0 $
Then put $(x + \frac{1}{x} ) = t$. Then discriminant should be grea... | 2018/03/03 | [
"https://math.stackexchange.com/questions/2674353",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/-1/"
] | Hope the following proof helps.
So with $B=B\_{r}(a)=\{x\in{\bf{R}}^{n}:|x-a|<r\}$, we are to prove that $\partial B=S\_{r}(a)=\{x\in{\bf{R}}^{n}:|x-a|=r\}$.
Given $\epsilon>0$ and $x\in S\_{r}(a)$, we need to find $x\_{\epsilon}\in B$, $y\_{\epsilon}\in B^{c}$ such that $x\_{\epsilon},y\_{\epsilon}\in B\_{\epsilon}(... | A point $ b $ is in the boundary of a set $A$ if every open ball B(b;r) contains
a point inside $A$ and a point outside $A$.
Note that in metric topology drawing a graph is often helpful.
For a disk $B(b;r )$ the boundary is the circle $d(x,b)=r $.
Because every open ball centered at $x$ has points for which $d(x... |
11,561,506 | Hi, I'm making a website and with a form but firefox keeps displaying unwanted text in the input fields when its value is empty.
This happens when using email or tel in the input method.
```
<form action='locatie.php?root=<?php echo $root; ?>' target='_self' method='post' onSubmit='return checkForm()' >
<table... | 2012/07/19 | [
"https://Stackoverflow.com/questions/11561506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1537903/"
] | You're setting the `placeholder` attribute on the `<input>` field, whose purpose it is to show something as long as no data is entered.
Just remove that attribute and you'll be fine.
Citing from [MDN](https://developer.mozilla.org/en/HTML/Element/Input):
>
> **placeholder**
>
>
> A hint to the user of what can be... | Clear your cookies, saved form data and browser cache. Also disable JS to see if this is the culprit.
You might also want to remove the placeholder="" attribute if you're not using it anyway.
I strongly recommend you download the "web developer toolbar" by Chris Pederick, because clearing all of this from your browse... |
11,561,506 | Hi, I'm making a website and with a form but firefox keeps displaying unwanted text in the input fields when its value is empty.
This happens when using email or tel in the input method.
```
<form action='locatie.php?root=<?php echo $root; ?>' target='_self' method='post' onSubmit='return checkForm()' >
<table... | 2012/07/19 | [
"https://Stackoverflow.com/questions/11561506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1537903/"
] | You're setting the `placeholder` attribute on the `<input>` field, whose purpose it is to show something as long as no data is entered.
Just remove that attribute and you'll be fine.
Citing from [MDN](https://developer.mozilla.org/en/HTML/Element/Input):
>
> **placeholder**
>
>
> A hint to the user of what can be... | The Placeholder is the problem but the solution is not to remove it. Use autocomplete="off" inside the input tag. |
11,561,506 | Hi, I'm making a website and with a form but firefox keeps displaying unwanted text in the input fields when its value is empty.
This happens when using email or tel in the input method.
```
<form action='locatie.php?root=<?php echo $root; ?>' target='_self' method='post' onSubmit='return checkForm()' >
<table... | 2012/07/19 | [
"https://Stackoverflow.com/questions/11561506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1537903/"
] | The Placeholder is the problem but the solution is not to remove it. Use autocomplete="off" inside the input tag. | Clear your cookies, saved form data and browser cache. Also disable JS to see if this is the culprit.
You might also want to remove the placeholder="" attribute if you're not using it anyway.
I strongly recommend you download the "web developer toolbar" by Chris Pederick, because clearing all of this from your browse... |
43,922,207 | My objective is manage my custom preferences. For this, I have the following code:
***MainActivity.java***
```
public class MainActivity extends ActionBarActivity implements View.OnTouchListener, GoogleMap.OnInfoWindowClickListener, LocationListener, GoogleMap.OnMapClickListener{
public boolean onOption... | 2017/05/11 | [
"https://Stackoverflow.com/questions/43922207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1508925/"
] | The main problem is the KEY `@+id/perimer` and `@+id/leguage` that you used for your `EditTextPreference` and `ListPreference`.
`SharedPreferences` is unable to recognize it as preference `KEY`. As you added resource prefix `@+id`, its treated as `int` resource `id` that's why still it works with below lines but doin... | I've done something similar to this and I think this should work. But this code is untested and may throw some error.
```js
public class Preferences extends PreferenceActivity implements android.preference.Preference.OnPreferenceChangeListener {
private ListPreference lang_list;
@Override protected void onCreat... |
16,317,809 | How to create a relative symbolic link that would always point to original folder two levels up? I would like to create a computer-independent alias that would work on any machine, provided that the original folder exists two levels up.
Basically, what I want is this:
```
|-- Original
|-- folder 1
|-... | 2013/05/01 | [
"https://Stackoverflow.com/questions/16317809",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/485146/"
] | I think, you have the order of the arguments backwards. It should be:
```
$ ln -s <dest> <link>
```
Where `<dest>` becomes the contents of the new link created.
In your specific example:
```
$ cd "folder 1"/"folder 2"
$ ln -s ../../Original Original
```
Or, in one command, from base directory:
```
$ ln -s Origi... | take out the first `/` - thats an absolute link from root, you want `../../` to be relative from current location. |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | add this code, it will show a alert view to ask user for permission.
```
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUser... | 蘇健豪's answer is good.
In Swift it looks like this:
```
let registerUserNotificationSettings = UIApplication.instancesRespondToSelector("registerUserNotificationSettings:")
if registerUserNotificationSettings {
var types: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Sound
... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | add this code, it will show a alert view to ask user for permission.
```
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUser... | Try this for Objective-C
```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog(@"didFinishLaunchingWithOptions");
if ([UIApplication instancesRespondToSelector:@sele... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | add this code, it will show a alert view to ask user for permission.
```
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUser... | ```
//register notifications
if([application respondsToSelector:@selector(registerUserNotificationSettings:)]) //ios 8+
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | add this code, it will show a alert view to ask user for permission.
```
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) {
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUser... | In the swift language....
```
var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound;
var setting = UIUserNotificationSettings(forTypes: type, categories: nil);
UIApplication.sharedApplication().registerUserNotificationSettings(setting);
UIApplication.sharedApplication().... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | 蘇健豪's answer is good.
In Swift it looks like this:
```
let registerUserNotificationSettings = UIApplication.instancesRespondToSelector("registerUserNotificationSettings:")
if registerUserNotificationSettings {
var types: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Sound
... | Try this for Objective-C
```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog(@"didFinishLaunchingWithOptions");
if ([UIApplication instancesRespondToSelector:@sele... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | 蘇健豪's answer is good.
In Swift it looks like this:
```
let registerUserNotificationSettings = UIApplication.instancesRespondToSelector("registerUserNotificationSettings:")
if registerUserNotificationSettings {
var types: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Sound
... | ```
//register notifications
if([application respondsToSelector:@selector(registerUserNotificationSettings:)]) //ios 8+
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | 蘇健豪's answer is good.
In Swift it looks like this:
```
let registerUserNotificationSettings = UIApplication.instancesRespondToSelector("registerUserNotificationSettings:")
if registerUserNotificationSettings {
var types: UIUserNotificationType = UIUserNotificationType.Alert | UIUserNotificationType.Sound
... | In the swift language....
```
var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound;
var setting = UIUserNotificationSettings(forTypes: type, categories: nil);
UIApplication.sharedApplication().registerUserNotificationSettings(setting);
UIApplication.sharedApplication().... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | ```
//register notifications
if([application respondsToSelector:@selector(registerUserNotificationSettings:)]) //ios 8+
{
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]];
... | Try this for Objective-C
```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog(@"didFinishLaunchingWithOptions");
if ([UIApplication instancesRespondToSelector:@sele... |
24,203,066 | I want to show an alert when the local notification is fired, but for that I have to ask for permission, as it says to me when I run the app on my iPhone:
>
> Attempting to schedule a local notification {fire date = Friday 13 June 2014 12 h 10 min 27 s Central European Summer Time, time zone = (null), repeat interva... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24203066",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3737316/"
] | In the swift language....
```
var type = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound;
var setting = UIUserNotificationSettings(forTypes: type, categories: nil);
UIApplication.sharedApplication().registerUserNotificationSettings(setting);
UIApplication.sharedApplication().... | Try this for Objective-C
```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
NSLog(@"didFinishLaunchingWithOptions");
if ([UIApplication instancesRespondToSelector:@sele... |
31,161,836 | The purpose of my program is to take a data txt file and edit it, and/or make additions and subtractions to it.
The text file format is like this:
```
Name|Address|Phone|# of people coming|isRSVP
```
The code I have seems to be doing it's job all the way up until I try to click one of the names within a *listbox* an... | 2015/07/01 | [
"https://Stackoverflow.com/questions/31161836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3952899/"
] | The problem lies in this line:
```
foreach (string person in list)
```
The list is defined as being `string[,]` which when you for each over will do every element, not just the column of data. You really should do something such as:
```
for(int index = 0; index <= list.GetUpperBound(0); index++)
{
string slice1... | Try to use a "Person" object and override equals(). Right now you're trying to put your multidimensional array (list[0]) into a string, it'll give you a unwanted result. You should use list[0,0] instead. |
31,161,836 | The purpose of my program is to take a data txt file and edit it, and/or make additions and subtractions to it.
The text file format is like this:
```
Name|Address|Phone|# of people coming|isRSVP
```
The code I have seems to be doing it's job all the way up until I try to click one of the names within a *listbox* an... | 2015/07/01 | [
"https://Stackoverflow.com/questions/31161836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3952899/"
] | The problem lies in this line:
```
foreach (string person in list)
```
The list is defined as being `string[,]` which when you for each over will do every element, not just the column of data. You really should do something such as:
```
for(int index = 0; index <= list.GetUpperBound(0); index++)
{
string slice1... | In agreement with Adam Gritt, I tested the following code and it seemed to work:
```
using System;
namespace so_foreach_bounds
{
class MainClass
{
public static void Main (string[] args)
{
//System.Text.StringBuilder newFile = new System.Text.StringBuilder();
string txt... |
768 | Background: I have the opportunity to pursue a Computer Science graduate degree at a well respected program (around top 20). I spoke with the professors at the university and I feel like I am a good fit with their research program. My ultimate pursuits are to complete a PhD in CS. I've done research as an undergraduate... | 2012/03/16 | [
"https://academia.stackexchange.com/questions/768",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/455/"
] | I'm afraid I have contradictory advice.
* If you've been offered a funded place, there is no guarantee the funding will still be there in a year. What you know is that you are good enough to get into a grad school, but there is a luck component too. The school I went to told us that 1 in 10 applicants was good enough ... | * You could defer admission, but it's a little unusual to defer for a year. Check with the departmental grad advisor and make sure everything is absolutely clear on this front
* It's a risk: admissions pools vary from year to year, and maybe the professor who wanted to take you on doesn't have funding, or already hired... |
768 | Background: I have the opportunity to pursue a Computer Science graduate degree at a well respected program (around top 20). I spoke with the professors at the university and I feel like I am a good fit with their research program. My ultimate pursuits are to complete a PhD in CS. I've done research as an undergraduate... | 2012/03/16 | [
"https://academia.stackexchange.com/questions/768",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/455/"
] | I'm afraid I have contradictory advice.
* If you've been offered a funded place, there is no guarantee the funding will still be there in a year. What you know is that you are good enough to get into a grad school, but there is a luck component too. The school I went to told us that 1 in 10 applicants was good enough ... | If I were to make an opinion out of whatever you have said in this post, I will say go for B without further thought :)
Reasons: 1) A one year industry job is hardly helpful as an experience anywhere, let alone for a prospective PhD. There is another question on this forum analysing the worth of job before PhD.
2) Y... |
768 | Background: I have the opportunity to pursue a Computer Science graduate degree at a well respected program (around top 20). I spoke with the professors at the university and I feel like I am a good fit with their research program. My ultimate pursuits are to complete a PhD in CS. I've done research as an undergraduate... | 2012/03/16 | [
"https://academia.stackexchange.com/questions/768",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/455/"
] | I'm afraid I have contradictory advice.
* If you've been offered a funded place, there is no guarantee the funding will still be there in a year. What you know is that you are good enough to get into a grad school, but there is a luck component too. The school I went to told us that 1 in 10 applicants was good enough ... | I will advise exactly the contrary of what bravo just said in another answer : go for A ! If you don't, there is a good probability that you will ask yourself continuously "was my choice to go for a PhD the best one?". With this year of experience, you will know for sure what you want, this is priceless. And this is th... |
768 | Background: I have the opportunity to pursue a Computer Science graduate degree at a well respected program (around top 20). I spoke with the professors at the university and I feel like I am a good fit with their research program. My ultimate pursuits are to complete a PhD in CS. I've done research as an undergraduate... | 2012/03/16 | [
"https://academia.stackexchange.com/questions/768",
"https://academia.stackexchange.com",
"https://academia.stackexchange.com/users/455/"
] | I'm afraid I have contradictory advice.
* If you've been offered a funded place, there is no guarantee the funding will still be there in a year. What you know is that you are good enough to get into a grad school, but there is a luck component too. The school I went to told us that 1 in 10 applicants was good enough ... | This decision strongly depends on your character and goals, so you should ask yourself what you will gain and loose while working in the industry for a year / going to grad school right away. What skills will you learn while working that will help you with PhD later? Will you have enough motivation to complete your PhD... |
91,947 | I am fetching emails via POP from another Gmail account and am applying a label @Private to all such emails.
Now, on my private email I also receive emails from services like Bitbucket. So I wanted to filter those emails as well and have created a filter @Bitbucket for all such emails.
However my @Private is now ov... | 2016/04/15 | [
"https://webapps.stackexchange.com/questions/91947",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9780/"
] | You can't remove a label with a filter.
However, it seems that Gmail applies filters sequentially, so if you change the order of your filters so that...
* the `@BitBucket` filter is listed *above* the `@Private` filter, and
* the `@Private` filter includes a negative search in its search criteria (e.g., `-label:@BitB... | I pull via POP3 from 3 different email accounts. Each of them get their own label.
The settings page where you specify the account details also allows you to specify the label to use. The last item in the pull-down of labels is "new label..." |
91,947 | I am fetching emails via POP from another Gmail account and am applying a label @Private to all such emails.
Now, on my private email I also receive emails from services like Bitbucket. So I wanted to filter those emails as well and have created a filter @Bitbucket for all such emails.
However my @Private is now ov... | 2016/04/15 | [
"https://webapps.stackexchange.com/questions/91947",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9780/"
] | Another, possibly easier way than [reordering your labels and excluding those already labeled](https://webapps.stackexchange.com/a/91956/354) would be to simply add the NOT operator in the first filter against the same criteria in the second.
So, if your first filter looks something like this:
```
from:bitbucket.com
... | I pull via POP3 from 3 different email accounts. Each of them get their own label.
The settings page where you specify the account details also allows you to specify the label to use. The last item in the pull-down of labels is "new label..." |
91,947 | I am fetching emails via POP from another Gmail account and am applying a label @Private to all such emails.
Now, on my private email I also receive emails from services like Bitbucket. So I wanted to filter those emails as well and have created a filter @Bitbucket for all such emails.
However my @Private is now ov... | 2016/04/15 | [
"https://webapps.stackexchange.com/questions/91947",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9780/"
] | I used this idea when I could identify everything which *should not have* a specific label. This is simply turning the normal pattern of say what should be labelled on its head. I wanted to label *everything which wasn't in a standard folder* (well certain standard folders) with [Gmail]/Archive to make gmail so that ar... | I pull via POP3 from 3 different email accounts. Each of them get their own label.
The settings page where you specify the account details also allows you to specify the label to use. The last item in the pull-down of labels is "new label..." |
91,947 | I am fetching emails via POP from another Gmail account and am applying a label @Private to all such emails.
Now, on my private email I also receive emails from services like Bitbucket. So I wanted to filter those emails as well and have created a filter @Bitbucket for all such emails.
However my @Private is now ov... | 2016/04/15 | [
"https://webapps.stackexchange.com/questions/91947",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9780/"
] | You can't remove a label with a filter.
However, it seems that Gmail applies filters sequentially, so if you change the order of your filters so that...
* the `@BitBucket` filter is listed *above* the `@Private` filter, and
* the `@Private` filter includes a negative search in its search criteria (e.g., `-label:@BitB... | Another, possibly easier way than [reordering your labels and excluding those already labeled](https://webapps.stackexchange.com/a/91956/354) would be to simply add the NOT operator in the first filter against the same criteria in the second.
So, if your first filter looks something like this:
```
from:bitbucket.com
... |
91,947 | I am fetching emails via POP from another Gmail account and am applying a label @Private to all such emails.
Now, on my private email I also receive emails from services like Bitbucket. So I wanted to filter those emails as well and have created a filter @Bitbucket for all such emails.
However my @Private is now ov... | 2016/04/15 | [
"https://webapps.stackexchange.com/questions/91947",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9780/"
] | You can't remove a label with a filter.
However, it seems that Gmail applies filters sequentially, so if you change the order of your filters so that...
* the `@BitBucket` filter is listed *above* the `@Private` filter, and
* the `@Private` filter includes a negative search in its search criteria (e.g., `-label:@BitB... | I used this idea when I could identify everything which *should not have* a specific label. This is simply turning the normal pattern of say what should be labelled on its head. I wanted to label *everything which wasn't in a standard folder* (well certain standard folders) with [Gmail]/Archive to make gmail so that ar... |
91,947 | I am fetching emails via POP from another Gmail account and am applying a label @Private to all such emails.
Now, on my private email I also receive emails from services like Bitbucket. So I wanted to filter those emails as well and have created a filter @Bitbucket for all such emails.
However my @Private is now ov... | 2016/04/15 | [
"https://webapps.stackexchange.com/questions/91947",
"https://webapps.stackexchange.com",
"https://webapps.stackexchange.com/users/9780/"
] | Another, possibly easier way than [reordering your labels and excluding those already labeled](https://webapps.stackexchange.com/a/91956/354) would be to simply add the NOT operator in the first filter against the same criteria in the second.
So, if your first filter looks something like this:
```
from:bitbucket.com
... | I used this idea when I could identify everything which *should not have* a specific label. This is simply turning the normal pattern of say what should be labelled on its head. I wanted to label *everything which wasn't in a standard folder* (well certain standard folders) with [Gmail]/Archive to make gmail so that ar... |
52,264,843 | I am trying to read the screen resolution from within a Qt application, but without using the GUI module.
So I have tried using:
```
xrandr |grep \* |awk '{print $1}'
```
command through *QProcess*, but it shows a warning and does not give any output:
>
> `unknown escape sequence:'\\*'`
>
>
>
Rewriting it wi... | 2018/09/10 | [
"https://Stackoverflow.com/questions/52264843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5527743/"
] | You have to use bash and pass the argument in quotes:
```
#include <QCoreApplication>
#include <QProcess>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QProcess process;
QObject::connect(&process, &QProcess::readyReadStandardOutput, [&process](){
qDebug()<<pr... | You can't use QProcess to execute piped system commands like that, it is designed to run a single program with arguments Try:
```
QProcess process;
process.start("bash -c xrandr |grep * |awk '{print $1}'");
```
OR
```
QProcess process;
QStringList args = QString("-c,xrandr,|,grep *,|,awk '{print $1}'").split(",");
... |
40,351,157 | I'm supposed to be writing code that takes a string of comma separated values without spaces (ex. `my,name,is,jack`). First we had to write a function
```
string nextstring(string str, int start_index)
```
that returns a single "value" from your initial string depending on the start index. The second part of the pr... | 2016/10/31 | [
"https://Stackoverflow.com/questions/40351157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7097094/"
] | The actual problem is not where I was thinking it is, the query is alright, I used `ArrayHelper::toArray($modelTeam)` method to convert the model object to an array to further iterate over the array and display all the records, and that is where the problem lies.
I needed to use the second parameter `$properties` for ... | To use IFNULL in a select with Yii2 you must create a new expression.
```
$modelTeam = Teams::find()
->select(['T.id', 'T.name', 'T.status'])
->addSelect([new Expression('IFNULL(T.image,"no-image.png") as DP')])
->from('{{%teams}} T')
->all()
``` |
40,351,157 | I'm supposed to be writing code that takes a string of comma separated values without spaces (ex. `my,name,is,jack`). First we had to write a function
```
string nextstring(string str, int start_index)
```
that returns a single "value" from your initial string depending on the start index. The second part of the pr... | 2016/10/31 | [
"https://Stackoverflow.com/questions/40351157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7097094/"
] | ```
$modelTeam = Teams::find()
->select(['T.id', 'T.name', 'T.status'])
->addSelect([new Expression('IFNULL(T.image,"no-image.png") as DP')])
->from('{{%teams}} T')
->all();
$arrTeam = $modelTeam->asArray()->all();
``` | To use IFNULL in a select with Yii2 you must create a new expression.
```
$modelTeam = Teams::find()
->select(['T.id', 'T.name', 'T.status'])
->addSelect([new Expression('IFNULL(T.image,"no-image.png") as DP')])
->from('{{%teams}} T')
->all()
``` |
40,351,157 | I'm supposed to be writing code that takes a string of comma separated values without spaces (ex. `my,name,is,jack`). First we had to write a function
```
string nextstring(string str, int start_index)
```
that returns a single "value" from your initial string depending on the start index. The second part of the pr... | 2016/10/31 | [
"https://Stackoverflow.com/questions/40351157",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7097094/"
] | The actual problem is not where I was thinking it is, the query is alright, I used `ArrayHelper::toArray($modelTeam)` method to convert the model object to an array to further iterate over the array and display all the records, and that is where the problem lies.
I needed to use the second parameter `$properties` for ... | ```
$modelTeam = Teams::find()
->select(['T.id', 'T.name', 'T.status'])
->addSelect([new Expression('IFNULL(T.image,"no-image.png") as DP')])
->from('{{%teams}} T')
->all();
$arrTeam = $modelTeam->asArray()->all();
``` |
36,931 | I need paragraphed footnotes precisely as `manyfoot` offers them, but also some of `bigfoot`'s other features (mainly "natural" order of the notes).
As `bigfoot` is described as "a drop-in replacement of the `manyfoot` package" I suppose it should somehow be possible to switch off the advanced heuristics for the layou... | 2011/12/02 | [
"https://tex.stackexchange.com/questions/36931",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/6819/"
] | Try something like
```
\usepackage{bigfoot}
\DeclareNewFootnote[para]{default}
\expandafter\def\csname @makefnbreak\endcsname{\unskip\linebreak[0]\quad}
``` | "Natural order of the notes" does not require `bigfoot`. That functionality is separately provided by the [`perpage`](http://ctan.org/pkg/perpage) package. |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | You can use a regex expression. The method [`re.sub()`](http://docs.python.org/2/library/re.html#re.sub) will take three parameters:
* The regex expression
* The replacement
* The string
**Code:**
```
import re
s = 'cats--'
output = re.sub("[^\\w]", "", s)
print output
```
**Explanation:**
* The part `"\\w"` ma... | By using strip you have to know the substring to be stripped.
```
>>> 'cats--'.strip('-')
'cats'
```
You could use `re` to get rid of the non-alphanumeric characters but you would shoot with a cannon on a mouse IMO. With `str.isalpha()` you can test any strings to contain alphabetic characters, so you only need to k... |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | ```
def strip_nonalnum(word):
if not word:
return word # nothing to strip
for start, c in enumerate(word):
if c.isalnum():
break
for end, c in enumerate(word[::-1]):
if c.isalnum():
break
return word[start:len(word) - end]
print([strip_nonalnum(s) for s ... | You can use a regex expression. The method [`re.sub()`](http://docs.python.org/2/library/re.html#re.sub) will take three parameters:
* The regex expression
* The replacement
* The string
**Code:**
```
import re
s = 'cats--'
output = re.sub("[^\\w]", "", s)
print output
```
**Explanation:**
* The part `"\\w"` ma... |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | To remove one or more chars other than letters, digits and `_` from both ends you may use
```
re.sub(r'^\W+|\W+$', '', '??cats--') # => cats
```
Or, if `_` is to be removed, too, wrap `\W` into a character class and add `_` there:
```
re.sub(r'^[\W_]+|[\W_]+$', '', '_??cats--_')
```
See the [regex demo](https://r... | You can use a regex expression. The method [`re.sub()`](http://docs.python.org/2/library/re.html#re.sub) will take three parameters:
* The regex expression
* The replacement
* The string
**Code:**
```
import re
s = 'cats--'
output = re.sub("[^\\w]", "", s)
print output
```
**Explanation:**
* The part `"\\w"` ma... |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | ```
def strip_nonalnum(word):
if not word:
return word # nothing to strip
for start, c in enumerate(word):
if c.isalnum():
break
for end, c in enumerate(word[::-1]):
if c.isalnum():
break
return word[start:len(word) - end]
print([strip_nonalnum(s) for s ... | By using strip you have to know the substring to be stripped.
```
>>> 'cats--'.strip('-')
'cats'
```
You could use `re` to get rid of the non-alphanumeric characters but you would shoot with a cannon on a mouse IMO. With `str.isalpha()` you can test any strings to contain alphabetic characters, so you only need to k... |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | I believe that this is the shortest non-regex solution:
```
text = "`23`12foo--=+"
while len(text) > 0 and not text[0].isalnum():
text = text[1:]
while len(text) > 0 and not text[-1].isalnum():
text = text[:-1]
print text
``` | By using strip you have to know the substring to be stripped.
```
>>> 'cats--'.strip('-')
'cats'
```
You could use `re` to get rid of the non-alphanumeric characters but you would shoot with a cannon on a mouse IMO. With `str.isalpha()` you can test any strings to contain alphabetic characters, so you only need to k... |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | To remove one or more chars other than letters, digits and `_` from both ends you may use
```
re.sub(r'^\W+|\W+$', '', '??cats--') # => cats
```
Or, if `_` is to be removed, too, wrap `\W` into a character class and add `_` there:
```
re.sub(r'^[\W_]+|[\W_]+$', '', '_??cats--_')
```
See the [regex demo](https://r... | By using strip you have to know the substring to be stripped.
```
>>> 'cats--'.strip('-')
'cats'
```
You could use `re` to get rid of the non-alphanumeric characters but you would shoot with a cannon on a mouse IMO. With `str.isalpha()` you can test any strings to contain alphabetic characters, so you only need to k... |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | ```
def strip_nonalnum(word):
if not word:
return word # nothing to strip
for start, c in enumerate(word):
if c.isalnum():
break
for end, c in enumerate(word[::-1]):
if c.isalnum():
break
return word[start:len(word) - end]
print([strip_nonalnum(s) for s ... | I believe that this is the shortest non-regex solution:
```
text = "`23`12foo--=+"
while len(text) > 0 and not text[0].isalnum():
text = text[1:]
while len(text) > 0 and not text[-1].isalnum():
text = text[:-1]
print text
``` |
22,650,554 | I have written some code to comb through approximately 10000 web pages on a website to put together a profile of the user demographics on the website. The basis of the program is to read each line of the source code of the website, parse out the data wanted, then move onto the next page.
I am encountering an issue wh... | 2014/03/26 | [
"https://Stackoverflow.com/questions/22650554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3362791/"
] | To remove one or more chars other than letters, digits and `_` from both ends you may use
```
re.sub(r'^\W+|\W+$', '', '??cats--') # => cats
```
Or, if `_` is to be removed, too, wrap `\W` into a character class and add `_` there:
```
re.sub(r'^[\W_]+|[\W_]+$', '', '_??cats--_')
```
See the [regex demo](https://r... | I believe that this is the shortest non-regex solution:
```
text = "`23`12foo--=+"
while len(text) > 0 and not text[0].isalnum():
text = text[1:]
while len(text) > 0 and not text[-1].isalnum():
text = text[:-1]
print text
``` |
27,249,894 | I have List Object.that list i am passing to Gson.
```
Gson gson = new Gson();
String toJson = gson.toJson(userDetailFeedNotifierVoList);
System.out.println("Gson Object : " + toJson);
```
Here I am getting in console :
```
[
{
"title": "Suman Mudiraj assigned you a to-do item named tes... | 2014/12/02 | [
"https://Stackoverflow.com/questions/27249894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3940240/"
] | Try this -
```
$newArray = array();
foreach ($yourArray as $value) {
$newArray[] = array($value[2], $value[3]);
}
``` | ```
array_map(function($elem) {
return array($elem[2], $elem[3]);
}, $array);
``` |
65,185,272 | I'ld like to implement a general Gaussian function for scalars and vectors. In Ada or C++ I simply would choose template for this, but in Haskell it's a little bit confusing.
I would start by defining a class that can apply Gaussian operators, like combining or calculating the probability:
```
class Gaussian g where
... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10236449/"
] | This seems like a textbook use-case for [Functional dependencies](https://wiki.haskell.org/Functional_dependencies), a GHC-only language feature that allows multi-parameter type classes where one parameter uniquely determines the other:
```hs
{-# LANGUAGE FunctionalDependencies #-}
class Guassian g a | g -> a where
... | Others have mentioned functional dependencies. Another option is to use a type family to make `a` depend on `g`:
```
class Gaussian g where
type Scalar g
(!*) :: g -> g -> g
prob :: g -> Scalar g -> Float
instance Gaussian Gaussian1D where
type Scalar Gaussian1D = Float
prob :: Gaussian1D -> Float -> Float
... |
65,185,272 | I'ld like to implement a general Gaussian function for scalars and vectors. In Ada or C++ I simply would choose template for this, but in Haskell it's a little bit confusing.
I would start by defining a class that can apply Gaussian operators, like combining or calculating the probability:
```
class Gaussian g where
... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10236449/"
] | This seems like a textbook use-case for [Functional dependencies](https://wiki.haskell.org/Functional_dependencies), a GHC-only language feature that allows multi-parameter type classes where one parameter uniquely determines the other:
```hs
{-# LANGUAGE FunctionalDependencies #-}
class Guassian g a | g -> a where
... | A good reason to have a multiparameter class is to be able to switch the base numeric type from `Float` to `Double` at will.
We can start by defining a scalar Gaussian distribution type like this, with `f` as the floating-point type argument:
```
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamType... |
65,185,272 | I'ld like to implement a general Gaussian function for scalars and vectors. In Ada or C++ I simply would choose template for this, but in Haskell it's a little bit confusing.
I would start by defining a class that can apply Gaussian operators, like combining or calculating the probability:
```
class Gaussian g where
... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10236449/"
] | If you write `g a`, for example in:
```
(!*) :: **g a** -> **g a** -> **g a**
```
It means that `g` takes a type parameter. That should for example work if `Gaussian1D` was defined as:
```
data Gaussian1D **a** = Gaussian1D **a** **a**
```
But that is not the case here. You can make a typeclass with two type parame... | Others have mentioned functional dependencies. Another option is to use a type family to make `a` depend on `g`:
```
class Gaussian g where
type Scalar g
(!*) :: g -> g -> g
prob :: g -> Scalar g -> Float
instance Gaussian Gaussian1D where
type Scalar Gaussian1D = Float
prob :: Gaussian1D -> Float -> Float
... |
65,185,272 | I'ld like to implement a general Gaussian function for scalars and vectors. In Ada or C++ I simply would choose template for this, but in Haskell it's a little bit confusing.
I would start by defining a class that can apply Gaussian operators, like combining or calculating the probability:
```
class Gaussian g where
... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10236449/"
] | If you write `g a`, for example in:
```
(!*) :: **g a** -> **g a** -> **g a**
```
It means that `g` takes a type parameter. That should for example work if `Gaussian1D` was defined as:
```
data Gaussian1D **a** = Gaussian1D **a** **a**
```
But that is not the case here. You can make a typeclass with two type parame... | A good reason to have a multiparameter class is to be able to switch the base numeric type from `Float` to `Double` at will.
We can start by defining a scalar Gaussian distribution type like this, with `f` as the floating-point type argument:
```
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamType... |
65,185,272 | I'ld like to implement a general Gaussian function for scalars and vectors. In Ada or C++ I simply would choose template for this, but in Haskell it's a little bit confusing.
I would start by defining a class that can apply Gaussian operators, like combining or calculating the probability:
```
class Gaussian g where
... | 2020/12/07 | [
"https://Stackoverflow.com/questions/65185272",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10236449/"
] | Others have mentioned functional dependencies. Another option is to use a type family to make `a` depend on `g`:
```
class Gaussian g where
type Scalar g
(!*) :: g -> g -> g
prob :: g -> Scalar g -> Float
instance Gaussian Gaussian1D where
type Scalar Gaussian1D = Float
prob :: Gaussian1D -> Float -> Float
... | A good reason to have a multiparameter class is to be able to switch the base numeric type from `Float` to `Double` at will.
We can start by defining a scalar Gaussian distribution type like this, with `f` as the floating-point type argument:
```
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamType... |
307,670 | I'm measuring the garbage output of various cities in my country. I have 5 independent variables as predictors measured at 4 time points.
I'm not interested in the effects of time. I just want to know the regression coefficients for each of my variables. To find that out, I could do 4 separate multiple regressions, o... | 2017/10/12 | [
"https://stats.stackexchange.com/questions/307670",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/124317/"
] | Are the time points relevant (like time of day) or are they just multiple samples? If they are just multiple samples, you might just take the mean over time points, then run a single regression. You should **not** run 4 separate regressions (what would that tell you, anyway?). If the time points are relevant (I mean, t... | This depends on the type of data set. Categorical data or continuous data. For each of the independent variable you can take the average. Then you will get a single value for each independent variable. Apply a multiple linear regression. Again, this is purely depends on your data type. In this case, Assuming that it is... |
70,264 | Can a character without [natural attacks](http://www.d20pfsrd.com/bestiary/rules-for-monsters/universal-monster-rules#TOC-Natural-Attacks) or [improved unarmed strike](http://www.d20pfsrd.com/feats/combat-feats/improved-unarmed-strike-combat---final) use their [unarmed strike](http://www.d20pfsrd.com/equipment---final/... | 2015/10/24 | [
"https://rpg.stackexchange.com/questions/70264",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/23058/"
] | I assume you are referring to combat manoeuvres that can be attempted in place of a melee attack, namely trip, disarm, and sunder.
According to [this FAQ](http://paizo.com/paizo/faq/v5748nruor1fm#v5748eaic9nvd) on the Paizo website:
>
> When making a trip combat maneuver, you don't have to use a weapon with the trip... | Yes, subject to all the relevant restrictions (like provoking an attack of opportunity).
Why do you think they can't be? In fact many [combat maneuvers](http://www.d20pfsrd.com/gamemastering/combat#TOC-Combat-Maneuvers) (e.g. bull rush) don't really make use of a weapon at all.
Naturally there are specific exception ... |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | See: <http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#zip_files> | I know it's not an answer to your question, but if possible consider using [Strawberry Perl](http://strawberryperl.com/), a CPAN-friendly distribution of Perl for Windows. It has a tidy installer, ships with make, a compiler and a properly configured CPAN shell all ready to go.
And then you can use something like [min... |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | See: <http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#zip_files> | You might be interested in [A guide to installing modules for Win32](http://www.perlmonks.org/?node_id=434813). It's a bit outdated (it talks about the command-line ppm) but the principles remain the same. |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | See: <http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#zip_files> | Since this is a very frequent scenario, I complete the answers here :
As far as ActivePerl 5.14 is concerned you can also download ".tar.gz" files for your platform, or download so-called ".ppmx" files (same format). Save the files and invoke the ppm installer later when offline :
```
ppm.bat install MIME-Lite-3.028.... |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | I am sure there is an easier way, but I just checked a ppd file and it is just an xml file ...
So you should be able to do the following if you want to install manually on a pc with no connection:
Open the file , ex
```
http://trouchelle.com/ppm/Acme-LOLCAT.ppd
```
and download the appropriate file pointed to in th... | I know it's not an answer to your question, but if possible consider using [Strawberry Perl](http://strawberryperl.com/), a CPAN-friendly distribution of Perl for Windows. It has a tidy installer, ships with make, a compiler and a properly configured CPAN shell all ready to go.
And then you can use something like [min... |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | I am sure there is an easier way, but I just checked a ppd file and it is just an xml file ...
So you should be able to do the following if you want to install manually on a pc with no connection:
Open the file , ex
```
http://trouchelle.com/ppm/Acme-LOLCAT.ppd
```
and download the appropriate file pointed to in th... | You might be interested in [A guide to installing modules for Win32](http://www.perlmonks.org/?node_id=434813). It's a bit outdated (it talks about the command-line ppm) but the principles remain the same. |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | I am sure there is an easier way, but I just checked a ppd file and it is just an xml file ...
So you should be able to do the following if you want to install manually on a pc with no connection:
Open the file , ex
```
http://trouchelle.com/ppm/Acme-LOLCAT.ppd
```
and download the appropriate file pointed to in th... | Since this is a very frequent scenario, I complete the answers here :
As far as ActivePerl 5.14 is concerned you can also download ".tar.gz" files for your platform, or download so-called ".ppmx" files (same format). Save the files and invoke the ppm installer later when offline :
```
ppm.bat install MIME-Lite-3.028.... |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | I know it's not an answer to your question, but if possible consider using [Strawberry Perl](http://strawberryperl.com/), a CPAN-friendly distribution of Perl for Windows. It has a tidy installer, ships with make, a compiler and a properly configured CPAN shell all ready to go.
And then you can use something like [min... | You might be interested in [A guide to installing modules for Win32](http://www.perlmonks.org/?node_id=434813). It's a bit outdated (it talks about the command-line ppm) but the principles remain the same. |
219,079 | In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as *.tar.gz*
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet ... | 2008/10/20 | [
"https://Stackoverflow.com/questions/219079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46478/"
] | Since this is a very frequent scenario, I complete the answers here :
As far as ActivePerl 5.14 is concerned you can also download ".tar.gz" files for your platform, or download so-called ".ppmx" files (same format). Save the files and invoke the ppm installer later when offline :
```
ppm.bat install MIME-Lite-3.028.... | You might be interested in [A guide to installing modules for Win32](http://www.perlmonks.org/?node_id=434813). It's a bit outdated (it talks about the command-line ppm) but the principles remain the same. |
84,894 | What is the best method for importing video from my JVC Everio HDD video camera into Ubuntu 11.10? | 2011/12/03 | [
"https://askubuntu.com/questions/84894",
"https://askubuntu.com",
"https://askubuntu.com/users/36481/"
] | Before installing anything, try these key combinations:
* `alt` + `|` (the key above `Tab`, may be ```, `º`, `|`...) to switch between instances of the current application
* `alt` + `ESC` to direct switch to the next window
* `alt` + `Tab`, of course, to switch between different applications
You can see the three key... | I tried this and as soon as I launched ccsm:
* my desktop was gone. No start menu, taskbar, launcher.. Just the wallpaper.
* `Alt+Tab` doesn't work at all.
I was able to launch a Terminal using right click on desktop. Many people faced this under different situations. Solution always said reset `compiz` config, delet... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.