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 |
|---|---|---|---|---|---|
55,119,643 | How find sum of all value in that object? In object included array with another object with value and may be "next" array with similar structure object.
```
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
``` | 2019/03/12 | [
"https://Stackoverflow.com/questions/55119643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6289878/"
] | You would need recursion to deal with the arbitrary nesting of your object:
```js
const nestedSum = o => (o.next || []).reduce((acc, o) => acc + nestedSum(o), o.value);
// Demo
const data = {
value: 4,
next: [{
value: 3,
next: [{value: 5}]
}, {
value: 3,
next: []
},
]
... | The structure of your object is called tree [Tree (data structure)](https://en.wikipedia.org/wiki/Tree_(data_structure)).
You can use [breadth-first](https://en.wikipedia.org/wiki/Tree_traversal#Breadth-first_search) or [depth-first](https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search) approach to [traverse... |
55,119,643 | How find sum of all value in that object? In object included array with another object with value and may be "next" array with similar structure object.
```
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
``` | 2019/03/12 | [
"https://Stackoverflow.com/questions/55119643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6289878/"
] | Use [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) and [Object.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) to sum the values recursively:
```js
const obj = {
value: 4,
next: [{
value: 3,
... | You need a recursive function and check if the value of a key is a number then add with the variable , else if it is an array like `next` then iterate through it and again call the same function with a new object
```js
let data = {
value: 4,
next: [{
value: 3,
next: [{
value: 4
}, {... |
55,119,643 | How find sum of all value in that object? In object included array with another object with value and may be "next" array with similar structure object.
```
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
``` | 2019/03/12 | [
"https://Stackoverflow.com/questions/55119643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6289878/"
] | ```js
function sum(obj, current = 0) {
const nextSum = (obj.next || []).reduce((nextSum, obj) => nextSum + sum(obj, current), 0)
return current + nextSum + obj.value
}
const example = {
value: 4,
next: [
{
value: 3,
next: [{
value: 7
}]
},
{
value: 3
... | You need a recursive function and check if the value of a key is a number then add with the variable , else if it is an array like `next` then iterate through it and again call the same function with a new object
```js
let data = {
value: 4,
next: [{
value: 3,
next: [{
value: 4
}, {... |
55,119,643 | How find sum of all value in that object? In object included array with another object with value and may be "next" array with similar structure object.
```
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
``` | 2019/03/12 | [
"https://Stackoverflow.com/questions/55119643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6289878/"
] | The structure of your object is called tree [Tree (data structure)](https://en.wikipedia.org/wiki/Tree_(data_structure)).
You can use [breadth-first](https://en.wikipedia.org/wiki/Tree_traversal#Breadth-first_search) or [depth-first](https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search) approach to [traverse... | You need a recursive function and check if the value of a key is a number then add with the variable , else if it is an array like `next` then iterate through it and again call the same function with a new object
```js
let data = {
value: 4,
next: [{
value: 3,
next: [{
value: 4
}, {... |
55,119,643 | How find sum of all value in that object? In object included array with another object with value and may be "next" array with similar structure object.
```
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
``` | 2019/03/12 | [
"https://Stackoverflow.com/questions/55119643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6289878/"
] | Use [reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce) and [Object.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries) to sum the values recursively:
```js
const obj = {
value: 4,
next: [{
value: 3,
... | The structure of your object is called tree [Tree (data structure)](https://en.wikipedia.org/wiki/Tree_(data_structure)).
You can use [breadth-first](https://en.wikipedia.org/wiki/Tree_traversal#Breadth-first_search) or [depth-first](https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search) approach to [traverse... |
55,119,643 | How find sum of all value in that object? In object included array with another object with value and may be "next" array with similar structure object.
```
{
value: 4,
next: [
{
value: 3,
next: [...]
},
{
value: 3,
next: [...]
},
...
]
}
``` | 2019/03/12 | [
"https://Stackoverflow.com/questions/55119643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6289878/"
] | ```js
function sum(obj, current = 0) {
const nextSum = (obj.next || []).reduce((nextSum, obj) => nextSum + sum(obj, current), 0)
return current + nextSum + obj.value
}
const example = {
value: 4,
next: [
{
value: 3,
next: [{
value: 7
}]
},
{
value: 3
... | The structure of your object is called tree [Tree (data structure)](https://en.wikipedia.org/wiki/Tree_(data_structure)).
You can use [breadth-first](https://en.wikipedia.org/wiki/Tree_traversal#Breadth-first_search) or [depth-first](https://en.wikipedia.org/wiki/Tree_traversal#Depth-first_search) approach to [traverse... |
31,602 | I've been working on creating my first decentralized application, and I'm currently working on [this tutorial](https://www.safaribooksonline.com/library/view/decentralized-applications/9781491924532/ch03.html) which attempts to create a decentralized version of Twitter.
I want to integrate an IPFS to store data from u... | 2017/11/25 | [
"https://ethereum.stackexchange.com/questions/31602",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/23675/"
] | 1. `geth --rpc` starts the rpc interface. The rpc interface is required to be able to connect with clients (websites, for example) that want to access the Ethereum blockchain. Use options `--rpcaddress` and `--rpcport` to set address and port of the rpc interface. With `--rpcapi` you can limit access via rpc to certain... | --rpc has been replaced with --http. You can find more details here <https://stackoverflow.com/questions/69463898/flag-provided-but-not-defined-rpc/69643321#69643321> |
59,352,742 | Tl;dr: I'm getting a `require is not defined` error in the Chrome JS console, despite having installed node.js and requrejs.
---
I am trying to access API keys in an external JSON file using the following code in `main.js`:
```js
function readTextFile(file, callback) {
var rawFile = new XMLHttpRequest();
raw... | 2019/12/16 | [
"https://Stackoverflow.com/questions/59352742",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10768444/"
] | This code:
```
var cors = require('cors')
var app = express()
app.use(cors());
```
Belongs in a node.js server. It is not to be run inside of Chrome. It's purpose is to help you create an http server that can ACCEPT cross origin http requests from a browser.
A browser will only allow a cross origin XMLHttpRequest... | `require()` is NodeJS feature, see the [link](https://nodejs.org/en/knowledge/getting-started/what-is-require/) for more details.
Could You please share the command You start the app? |
41,124,388 | I have `@Controller` with method with signature like this:
```
@PostMapping
@ResponseBody
public ResponseEntity<Result> uploadFileAndReturnJson(@RequestParam("file") MultipartFile file) {}
```
I want to construct multipart request without physically creating any file. I tried doing it like this:
```
private MultiPa... | 2016/12/13 | [
"https://Stackoverflow.com/questions/41124388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5678184/"
] | Your code looks fine and it should work with byte[]. You can use `MultiPartSpecBuilder(byte[] content)` like below.
```
private MultiPartSpecification getMultiPart() {
return new MultiPartSpecBuilder("Test-Content-In-File".getBytes()).
fileName("book.txt").
controlName("file").... | ```
try {
RestAssured.given()
.header(new Header("content-type", "multipart/form-data"))
.multiPart("file",new File( "./src/main/resources/test.txt"))
.formParam("description", "This is my doc")
.auth().preemptive().basic(loginModel.getUsername(), loginModel.getPassw... |
41,124,388 | I have `@Controller` with method with signature like this:
```
@PostMapping
@ResponseBody
public ResponseEntity<Result> uploadFileAndReturnJson(@RequestParam("file") MultipartFile file) {}
```
I want to construct multipart request without physically creating any file. I tried doing it like this:
```
private MultiPa... | 2016/12/13 | [
"https://Stackoverflow.com/questions/41124388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5678184/"
] | Your code looks fine and it should work with byte[]. You can use `MultiPartSpecBuilder(byte[] content)` like below.
```
private MultiPartSpecification getMultiPart() {
return new MultiPartSpecBuilder("Test-Content-In-File".getBytes()).
fileName("book.txt").
controlName("file").... | I needed to send multiple request with files and json data , i solve it like that
```
public static Response Post(JSONObject body, String URL, String file1, String file2) {
try {
return RestAssured.given().baseUri(URL).urlEncodingEnabled(false)
.accept("application/json, text/pl... |
41,124,388 | I have `@Controller` with method with signature like this:
```
@PostMapping
@ResponseBody
public ResponseEntity<Result> uploadFileAndReturnJson(@RequestParam("file") MultipartFile file) {}
```
I want to construct multipart request without physically creating any file. I tried doing it like this:
```
private MultiPa... | 2016/12/13 | [
"https://Stackoverflow.com/questions/41124388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5678184/"
] | ```
try {
RestAssured.given()
.header(new Header("content-type", "multipart/form-data"))
.multiPart("file",new File( "./src/main/resources/test.txt"))
.formParam("description", "This is my doc")
.auth().preemptive().basic(loginModel.getUsername(), loginModel.getPassw... | I needed to send multiple request with files and json data , i solve it like that
```
public static Response Post(JSONObject body, String URL, String file1, String file2) {
try {
return RestAssured.given().baseUri(URL).urlEncodingEnabled(false)
.accept("application/json, text/pl... |
161,425 | I'm developing a social network and to my knowledge, the best way of storing between pages which user is logged on is using cookies. So, suppose I'm storing a cookie of the user ID which is logged in.
Anyway, what's stopping the user from changing the cookie's value in order to trick the website into thinking they're ... | 2017/06/07 | [
"https://security.stackexchange.com/questions/161425",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/150347/"
] | >
> So, suppose I'm storing a cookie of the user ID which is logged in.
>
>
>
That's not how session cookies work. The cookie shoudn't just contain the ID of the current user since that would obviously allow an attacker to tamper with the value.
Instead, a common approach is that the web application issues a suff... | If you authenticate a user based on a plaintext cookie with a username then you can't ensure whoever has the cookie is the person they say they are. Anyone can create a cookie with whatever username they want. It's up to you to ensure that they are who they say they are.
If I knew someone's username I could create a c... |
161,425 | I'm developing a social network and to my knowledge, the best way of storing between pages which user is logged on is using cookies. So, suppose I'm storing a cookie of the user ID which is logged in.
Anyway, what's stopping the user from changing the cookie's value in order to trick the website into thinking they're ... | 2017/06/07 | [
"https://security.stackexchange.com/questions/161425",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/150347/"
] | It is possible to store information in cookies and prevent users from tampetering with the data in the cookies. The way to do this is to create a HMAC of the cookie value and store that along with the cookie. Then whenever you receive a cookie value, check if it has the correct HMAC. Since HMACs need a secret key to cr... | If you authenticate a user based on a plaintext cookie with a username then you can't ensure whoever has the cookie is the person they say they are. Anyone can create a cookie with whatever username they want. It's up to you to ensure that they are who they say they are.
If I knew someone's username I could create a c... |
161,425 | I'm developing a social network and to my knowledge, the best way of storing between pages which user is logged on is using cookies. So, suppose I'm storing a cookie of the user ID which is logged in.
Anyway, what's stopping the user from changing the cookie's value in order to trick the website into thinking they're ... | 2017/06/07 | [
"https://security.stackexchange.com/questions/161425",
"https://security.stackexchange.com",
"https://security.stackexchange.com/users/150347/"
] | >
> So, suppose I'm storing a cookie of the user ID which is logged in.
>
>
>
That's not how session cookies work. The cookie shoudn't just contain the ID of the current user since that would obviously allow an attacker to tamper with the value.
Instead, a common approach is that the web application issues a suff... | It is possible to store information in cookies and prevent users from tampetering with the data in the cookies. The way to do this is to create a HMAC of the cookie value and store that along with the cookie. Then whenever you receive a cookie value, check if it has the correct HMAC. Since HMACs need a secret key to cr... |
66,351,081 | Guys I'm trying to put two buttons from two different forms on the same line.
I tried to put an id on both buttons so that I can manage them in css.
In particular, what I want to do is put the "delete" button next to the "update" button.
This is what I tried to do but it doesn't work because the "delete" button stays u... | 2021/02/24 | [
"https://Stackoverflow.com/questions/66351081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15051230/"
] | There are [two](https://github.com/mongoosastic/mongoosastic/issues/441) [issues](https://github.com/mongoosastic/mongoosastic/issues/380) closed without a solution in the mongoosastic repository, suggesting that this is very likely a bug in the library that may not have a solution in user code.
What those issues and ... | It's not immediately clear [from the source code](https://github.com/mongoosastic/mongoosastic/blob/558ba1a486ae1efdb0a48dba279d69118679d3c5/lib/mongoosastic.js#L385) why the `modelName` would be `undefined`...
In any event, each `mongoosastic` model constructor [accepts an `index` parameter](https://github.com/mongoo... |
64,786,477 | I am trying to create a function that will query times in a table and then return the correct time based on the site.
The times in the table being queried have the opening and closing times of the branch. I am not sure if I should be using CASE or IF.
When I use `CASE`, I get this error:
>
> Msg 444, Level 16, Stat... | 2020/11/11 | [
"https://Stackoverflow.com/questions/64786477",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14619192/"
] | First of all I think you didn't specify all requirements.
I expect that you pass the location code to the function.
your function could have a look like
```
CREATE FUNCTION YourFunction
(
@locationCode varchar(2)
)
RETURNS TIME
AS
BEGIN
DECLARE @OpenTime TIME
DECLARE @WorkStart TIME
SET @WorkStart = '... | "Select statements included within a function cannot return data to a client"
To clarify the error message: you must assign your result to a variable and return the variable. A SELECT as shown in your question, will return a dataset to the client. As noted in the error message, that is not allowed for a function. Retu... |
12,268,913 | I recently modify the "include\_path" var in my php.ini file. Before you ask, I restarted the apache service. The change work for every pages we access from a web browser.
The problem is the cron jobs doesn't seems to consider that change. When I do a phpinfo() inside the cron job, it uses the same php.ini file than t... | 2012/09/04 | [
"https://Stackoverflow.com/questions/12268913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/738638/"
] | Several systems use a separate php.ini file for web and CLI. You will need to make changes in that one as well: [How to find the php.ini file used by the command line?](https://stackoverflow.com/questions/2750580/how-to-find-the-php-ini-file-used-by-the-command-line)
The easiest way to find this file is to run this a... | PHP generally has two .ini files. One for in-webserver (SAPI) and one for command-line (CLI) usage. If you modified only the SAPI one, then anything running from CLI (e.g. cron jobs) will not see the change.
do a `php -i` at the command line to see where PHP is looking for its ini file while in that mode. |
50,703,782 | I'm having some issues writing a simple for loop with conditions in r.
I've got this array:
```
Temp <- c("A", "A", "B", "A", "C", "C", "A", "B")
```
I want to count the couples in this array, by using two indexes which are incremented during the loop.It's mandatory to follow the order of the sequence.
The final re... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50703782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433862/"
] | in base `R`:
```
# unique letter values
ut <- unique(Temp)
# expand to get a data.frame with all combinations
expnd <- data.frame(pair=do.call(paste0,expand.grid(ut,ut)),stringsAsFactors = FALSE)
# merge it with the table containing counts of all pair combinations
out <- merge(expnd, table(pair=paste0(head(Temp,-1... | You can try
```
library(tidyverse)
b <- table(sapply(seq_along(Temp), function(x) paste0(Temp[x], Temp[x+1]))[-length(Temp)])
expand.grid(unique(Temp), unique(Temp)) %>%
unite(Var1, Var1, Var2, sep = "") %>%
left_join(as.data.frame(b,stringsAsFactors = F)) %>%
mutate(Freq=ifelse(is.na(Freq), 0, Freq))
Var Fre... |
50,703,782 | I'm having some issues writing a simple for loop with conditions in r.
I've got this array:
```
Temp <- c("A", "A", "B", "A", "C", "C", "A", "B")
```
I want to count the couples in this array, by using two indexes which are incremented during the loop.It's mandatory to follow the order of the sequence.
The final re... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50703782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433862/"
] | in base `R`:
```
# unique letter values
ut <- unique(Temp)
# expand to get a data.frame with all combinations
expnd <- data.frame(pair=do.call(paste0,expand.grid(ut,ut)),stringsAsFactors = FALSE)
# merge it with the table containing counts of all pair combinations
out <- merge(expnd, table(pair=paste0(head(Temp,-1... | ```
library(magrittr)
n <- length(Temp)
sapply(1:(n-1),function(i) paste(Temp[i:(i+1)], collapse = "")) %>%
factor(levels = paste0(rep(LETTERS[1:3], each = 3), LETTERS[1:3])) %>%
table()
AA AB AC BA BB BC CA CB CC
1 2 1 1 0 0 1 0 1
``` |
50,703,782 | I'm having some issues writing a simple for loop with conditions in r.
I've got this array:
```
Temp <- c("A", "A", "B", "A", "C", "C", "A", "B")
```
I want to count the couples in this array, by using two indexes which are incremented during the loop.It's mandatory to follow the order of the sequence.
The final re... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50703782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433862/"
] | Here is a simple base solution:
```
table(sapply(1:(length(Temp) - 1), function(x) paste(Temp[x:(x+1)], collapse = "")))
AA AB AC BA CA CC
1 2 1 1 1 1
```
If you really want to see all possible permutations you can use any package that will generate permutations with repetition. Below we use `gtools`.
```
l... | in base `R`:
```
# unique letter values
ut <- unique(Temp)
# expand to get a data.frame with all combinations
expnd <- data.frame(pair=do.call(paste0,expand.grid(ut,ut)),stringsAsFactors = FALSE)
# merge it with the table containing counts of all pair combinations
out <- merge(expnd, table(pair=paste0(head(Temp,-1... |
50,703,782 | I'm having some issues writing a simple for loop with conditions in r.
I've got this array:
```
Temp <- c("A", "A", "B", "A", "C", "C", "A", "B")
```
I want to count the couples in this array, by using two indexes which are incremented during the loop.It's mandatory to follow the order of the sequence.
The final re... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50703782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433862/"
] | Here is a simple base solution:
```
table(sapply(1:(length(Temp) - 1), function(x) paste(Temp[x:(x+1)], collapse = "")))
AA AB AC BA CA CC
1 2 1 1 1 1
```
If you really want to see all possible permutations you can use any package that will generate permutations with repetition. Below we use `gtools`.
```
l... | You can try
```
library(tidyverse)
b <- table(sapply(seq_along(Temp), function(x) paste0(Temp[x], Temp[x+1]))[-length(Temp)])
expand.grid(unique(Temp), unique(Temp)) %>%
unite(Var1, Var1, Var2, sep = "") %>%
left_join(as.data.frame(b,stringsAsFactors = F)) %>%
mutate(Freq=ifelse(is.na(Freq), 0, Freq))
Var Fre... |
50,703,782 | I'm having some issues writing a simple for loop with conditions in r.
I've got this array:
```
Temp <- c("A", "A", "B", "A", "C", "C", "A", "B")
```
I want to count the couples in this array, by using two indexes which are incremented during the loop.It's mandatory to follow the order of the sequence.
The final re... | 2018/06/05 | [
"https://Stackoverflow.com/questions/50703782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4433862/"
] | Here is a simple base solution:
```
table(sapply(1:(length(Temp) - 1), function(x) paste(Temp[x:(x+1)], collapse = "")))
AA AB AC BA CA CC
1 2 1 1 1 1
```
If you really want to see all possible permutations you can use any package that will generate permutations with repetition. Below we use `gtools`.
```
l... | ```
library(magrittr)
n <- length(Temp)
sapply(1:(n-1),function(i) paste(Temp[i:(i+1)], collapse = "")) %>%
factor(levels = paste0(rep(LETTERS[1:3], each = 3), LETTERS[1:3])) %>%
table()
AA AB AC BA BB BC CA CB CC
1 2 1 1 0 0 1 0 1
``` |
36,557,058 | I have a text file (textfile.txt) in a folder called DOT and I am trying to convert that file to an Excel file (Excelfile.xls) using Python code. I am not familiar with Python but from other comments I wrote the code below. The code does not work. Could anyone help me get the correct syntax?
```
book = xlwt.Workbook(... | 2016/04/11 | [
"https://Stackoverflow.com/questions/36557058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6099978/"
] | This is based on documentation from: <https://pypi.python.org/pypi/xlwt>
You will need to read the file line by line, format it and write it to the xls file.
```
import xlwt
import xlrd
book = xlwt.Workbook()
ws = book.add_sheet('First Sheet') # Add a sheet
f = open('/DOT/textfile.txt', 'r+')
data = f.readlines()... | I had a similar problem. The txt file’s content was actually separated by “Tab” blanks (get to know this when importing data in Excel).
Searched and tried some answers, but only got this working fine with mine.
<https://mail.python.org/pipermail/tutor/2011-May/083411.html> |
45,194,284 | I'm working on a linux server right now and have a list of servers I would like to do control using salt-stack(a DSC tool) While working on my linux+ I came across a really neat command -- xargs I've been using it to simplify a lot of my linux administration life, however I cam into an issue with it and I'm wondering i... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45194284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8021878/"
] | ```
for server in $(< servers); do echo salt ${server}.servers.fakefqdn.com cmd.run 'date'; done
``` | Using xargs, this should work as you want:
```
cat servers | xargs -I % sudo salt %.servers.fakefqdn.com cmd.run 'date'
``` |
16,192,991 | How can I do a parse of Metar information in Java programming?
I'v searched in the Internet and ther's a lot of complex things, I want something more simple.
I don't know how to use Regex or something like that...
example of Metar Info :<http://weather.noaa.gov/pub/data/observations/metar/stations/ABBN.TXT>
>
> 2011... | 2013/04/24 | [
"https://Stackoverflow.com/questions/16192991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1837447/"
] | I found a solution, there's the code (it can be useful for somebody):
```
for (int i=0; i<httpGet.length(); i++) {
char c = httpGet.charAt(i);
if(c=='M' && Character.isDigit(httpGet.charAt(i+1)) &&
Character.isDigit(httpGet.charAt(i+2)) &&
httpGet.ch... | Regex is almost certainly what your gonna want, yes is daunting but you will use it over and over again. The RMK section is going to be the hardest, it's the most free form. The only alternative is to go through character by character with a lot of if's or case statements. |
16,192,991 | How can I do a parse of Metar information in Java programming?
I'v searched in the Internet and ther's a lot of complex things, I want something more simple.
I don't know how to use Regex or something like that...
example of Metar Info :<http://weather.noaa.gov/pub/data/observations/metar/stations/ABBN.TXT>
>
> 2011... | 2013/04/24 | [
"https://Stackoverflow.com/questions/16192991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1837447/"
] | I found a solution, there's the code (it can be useful for somebody):
```
for (int i=0; i<httpGet.length(); i++) {
char c = httpGet.charAt(i);
if(c=='M' && Character.isDigit(httpGet.charAt(i+1)) &&
Character.isDigit(httpGet.charAt(i+2)) &&
httpGet.ch... | This looks promising, I googled java METAR parse :-)
<http://jfall-javafx.googlecode.com/svn-history/r6/WeatherFX/src/com/feldt/metar/Metar.java> |
15,836,423 | I'm trying to figure out how to set some environment variable which would make g++ to link to correct versions of the libraries.
I have some old boost libraries in /usr/lib64 (linking against these will fail) and new libraries in /v/users/regel/lib. So the linker should link against the new libraries.
Command:
```
$... | 2013/04/05 | [
"https://Stackoverflow.com/questions/15836423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/738107/"
] | As the GCC manual [says](https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html#Environment-Variables), `LIBRARY_PATH` is the correct environment variable to add directories to the library search path.
If you add `-v` to the `g++` command you should see the `LIBRARY_PATH` that it uses, and you should see it inc... | Try specifying the library path in a .conf file in /etc/ld.so.conf.d/
The linker looks at paths specified in files in /etc/ld.so.conf.d/ while linking.
Make sure you run 'ldconfig' once you create the file, that will force it to update its cache. |
13,691,562 | I have this line:
`[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types (countyfair)`
How do i split it from the **3rd ]** and have 2 parts:
```
[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc]
```
and
```
I'm Sure [he/she] is leading CORN @types ... | 2012/12/03 | [
"https://Stackoverflow.com/questions/13691562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1060070/"
] | This one skips three `]`s:
```
use strict;
use warnings;
while (<>) {
if (my ($p1, $p2) = (/([^]]+][^]]+][^]]+])\s*(.*)/)) {
print "$p1 : $p2\n";
}
}
```
Using an array:
```
my @a;
while (<>) {
if (@a = (/([^]]+][^]]+][^]]+])\s*(.*)/)) {
print join(",", @a), "\n";
}
}
``` | I got interested in a generic function, so here it is:
```
#!/usr/bin/env perl
use strict;
use warnings;
my $str = q{[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types (countyfair)}; #'# fix highlight
my ($first, $second) = split_after_nth( qr/]/, $str, 3 );
$second... |
13,691,562 | I have this line:
`[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types (countyfair)`
How do i split it from the **3rd ]** and have 2 parts:
```
[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc]
```
and
```
I'm Sure [he/she] is leading CORN @types ... | 2012/12/03 | [
"https://Stackoverflow.com/questions/13691562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1060070/"
] | This one skips three `]`s:
```
use strict;
use warnings;
while (<>) {
if (my ($p1, $p2) = (/([^]]+][^]]+][^]]+])\s*(.*)/)) {
print "$p1 : $p2\n";
}
}
```
Using an array:
```
my @a;
while (<>) {
if (@a = (/([^]]+][^]]+][^]]+])\s*(.*)/)) {
print join(",", @a), "\n";
}
}
``` | A look-behind for three strings each terminated by `]` will do the trick. You didn't mention what you wanted to do with the whitespace after the third `]` so I've left it there.
```
use strict;
use warnings;
my $s = q{[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types ... |
13,691,562 | I have this line:
`[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types (countyfair)`
How do i split it from the **3rd ]** and have 2 parts:
```
[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc]
```
and
```
I'm Sure [he/she] is leading CORN @types ... | 2012/12/03 | [
"https://Stackoverflow.com/questions/13691562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1060070/"
] | A look-behind for three strings each terminated by `]` will do the trick. You didn't mention what you wanted to do with the whitespace after the third `]` so I've left it there.
```
use strict;
use warnings;
my $s = q{[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types ... | I got interested in a generic function, so here it is:
```
#!/usr/bin/env perl
use strict;
use warnings;
my $str = q{[Fri Oct 5 09:11 2012] 0.005 [ext2/1/rel 322 (0,50)] [abc] I'm Sure [he/she] is leading CORN @types (countyfair)}; #'# fix highlight
my ($first, $second) = split_after_nth( qr/]/, $str, 3 );
$second... |
36,614,034 | I'm running out of ideas on how to uncompress an array (request array A[] to response array B[])
Here are my definitions
**A** is a request class.
```
class A
{
public string Date { get; set; }
public decimal Price { get; set; }
}
```
Below is my array of requests of class A with its initalization.
```
var ... | 2016/04/14 | [
"https://Stackoverflow.com/questions/36614034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1210896/"
] | You could do this using `GroupBy` linq extension, following query returns `List<B>`objects.
```
var results = request.Select(s=>
new
{
Price = s.Price,
Date = DateTime.ParseExact(s.Date, "dd-MM-yyyy", null) // convert to Date.
})
.GroupBy(g=>g.Price)... | Pseudocode (assumes request is ordered by date - if not you can sort it easily):
```
int lastPrice = -1;
//count the distinct price ranges
int responseSize = 0;
foreach (A requestObj in request) {
if (requestObj.price != lastPrice) {
responseSize++;
lastPrice = requestObj.price;
}
}
//set the initial element
... |
36,614,034 | I'm running out of ideas on how to uncompress an array (request array A[] to response array B[])
Here are my definitions
**A** is a request class.
```
class A
{
public string Date { get; set; }
public decimal Price { get; set; }
}
```
Below is my array of requests of class A with its initalization.
```
var ... | 2016/04/14 | [
"https://Stackoverflow.com/questions/36614034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1210896/"
] | You could do this using `GroupBy` linq extension, following query returns `List<B>`objects.
```
var results = request.Select(s=>
new
{
Price = s.Price,
Date = DateTime.ParseExact(s.Date, "dd-MM-yyyy", null) // convert to Date.
})
.GroupBy(g=>g.Price)... | This can also be done with the following:
```
var response = from reqItem in request
group reqItem by reqItem.Price into g
select new B()
{
Start = g.Min(m => DateTime.Parse(m.Date)).ToString("dd-MM-yyyy"),
End = g.Max(m => DateTime.Parse(m.Date)).ToString("dd-MM-yyyy"),
Price = g.Key
};
``` |
36,614,034 | I'm running out of ideas on how to uncompress an array (request array A[] to response array B[])
Here are my definitions
**A** is a request class.
```
class A
{
public string Date { get; set; }
public decimal Price { get; set; }
}
```
Below is my array of requests of class A with its initalization.
```
var ... | 2016/04/14 | [
"https://Stackoverflow.com/questions/36614034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1210896/"
] | Pseudocode (assumes request is ordered by date - if not you can sort it easily):
```
int lastPrice = -1;
//count the distinct price ranges
int responseSize = 0;
foreach (A requestObj in request) {
if (requestObj.price != lastPrice) {
responseSize++;
lastPrice = requestObj.price;
}
}
//set the initial element
... | This can also be done with the following:
```
var response = from reqItem in request
group reqItem by reqItem.Price into g
select new B()
{
Start = g.Min(m => DateTime.Parse(m.Date)).ToString("dd-MM-yyyy"),
End = g.Max(m => DateTime.Parse(m.Date)).ToString("dd-MM-yyyy"),
Price = g.Key
};
``` |
27,731,015 | i want to create an android application,
the apk has a text box and one button perhaps.
in the text box the user will input their HTML codes/strings.
and by clicking the button it will show the output of the codes they type from the textbox. | 2015/01/01 | [
"https://Stackoverflow.com/questions/27731015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4410140/"
] | you can do it like this
```
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.WebView01);
final String mimeType = "text/html";
final String encodi... | call this line:
```
wv.loadData(yourHtmlData, "text/html", "UTF-8");
``` |
17,152,150 | Here is a line of code that I have:
```
public class ReminderHandler() {
if (edittext.containsReminderWords()){
test.setText("Do you want me to remind you to " + sharedPref.getString(toremember, toremember) + "?");
}
}
```
I want the program to wait for either a yes or a no answer from the edittext after th... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17152150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2491252/"
] | You better use [AlertDialog](http://developer.android.com/reference/android/app/AlertDialog.html). Check [this link](http://developer.android.com/guide/topics/ui/dialogs.html) to know more about android Dialogs | you would do this with an event:
* a button near the text input that say something like "do it"/"save"/"done", etc.
* an event, like focus changed, touch up,etc. see: <http://developer.android.com/guide/topics/ui/ui-events.html> |
17,152,150 | Here is a line of code that I have:
```
public class ReminderHandler() {
if (edittext.containsReminderWords()){
test.setText("Do you want me to remind you to " + sharedPref.getString(toremember, toremember) + "?");
}
}
```
I want the program to wait for either a yes or a no answer from the edittext after th... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17152150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2491252/"
] | JOptionPane has plenty of options for you to use.
```
JOptionPane.showConfirmDialog(null, "Do you want to do something?")
```
See [here](http://docs.oracle.com/javase/6/docs/api/javax/swing/JOptionPane.html#showConfirmDialog%28java.awt.Component,%20java.lang.Object%29) for the documentation | you would do this with an event:
* a button near the text input that say something like "do it"/"save"/"done", etc.
* an event, like focus changed, touch up,etc. see: <http://developer.android.com/guide/topics/ui/ui-events.html> |
17,152,150 | Here is a line of code that I have:
```
public class ReminderHandler() {
if (edittext.containsReminderWords()){
test.setText("Do you want me to remind you to " + sharedPref.getString(toremember, toremember) + "?");
}
}
```
I want the program to wait for either a yes or a no answer from the edittext after th... | 2013/06/17 | [
"https://Stackoverflow.com/questions/17152150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2491252/"
] | You better use [AlertDialog](http://developer.android.com/reference/android/app/AlertDialog.html). Check [this link](http://developer.android.com/guide/topics/ui/dialogs.html) to know more about android Dialogs | JOptionPane has plenty of options for you to use.
```
JOptionPane.showConfirmDialog(null, "Do you want to do something?")
```
See [here](http://docs.oracle.com/javase/6/docs/api/javax/swing/JOptionPane.html#showConfirmDialog%28java.awt.Component,%20java.lang.Object%29) for the documentation |
11,465,067 | I have 3 text boxes where user will enter some value inside it. Then user will click on done button which then it will redirect user to another page and the page will show user what data entered by them before in label before they hit save button to be saved in db. I would like to use session in this case but the i don... | 2012/07/13 | [
"https://Stackoverflow.com/questions/11465067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220691/"
] | When you use `Scanner.nextInt()`, it does not consume the new line (or other delimiter) itself so the next token returned will typically be an empty string. Thus, you need to follow it with a `Scanner.nextLine()`. You can discard the result instead of assigning it to `a`:
```
int a = in.nextInt();
in.nextLine();
```... | Instead of
```
s = in.nextLine();
```
try
```
in.nextLine();
s = in.nextLine();
```
The call to nextInt() still leaves a trailing newline.
Calling in.nextLine() actually goes to the next line. Then in.nextLine will get your actual result. |
11,465,067 | I have 3 text boxes where user will enter some value inside it. Then user will click on done button which then it will redirect user to another page and the page will show user what data entered by them before in label before they hit save button to be saved in db. I would like to use session in this case but the i don... | 2012/07/13 | [
"https://Stackoverflow.com/questions/11465067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220691/"
] | Instead of
```
s = in.nextLine();
```
try
```
in.nextLine();
s = in.nextLine();
```
The call to nextInt() still leaves a trailing newline.
Calling in.nextLine() actually goes to the next line. Then in.nextLine will get your actual result. | Try it like this :D
```
import java.util.Scanner;
public class Hello {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int a;
String s = null;
System.out.print("Enter int: ");
a = in.nextInt();
while ((s = in.nextLine()).trim().isEmpty... |
11,465,067 | I have 3 text boxes where user will enter some value inside it. Then user will click on done button which then it will redirect user to another page and the page will show user what data entered by them before in label before they hit save button to be saved in db. I would like to use session in this case but the i don... | 2012/07/13 | [
"https://Stackoverflow.com/questions/11465067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220691/"
] | Instead of
```
s = in.nextLine();
```
try
```
in.nextLine();
s = in.nextLine();
```
The call to nextInt() still leaves a trailing newline.
Calling in.nextLine() actually goes to the next line. Then in.nextLine will get your actual result. | ```
import java.util.Scanner;
public class Hello{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int a;
String s;
System.out.println("Enter int : ");
a = in.nextInt();
System.out.println("Enter String : ");
s = in.next();
... |
11,465,067 | I have 3 text boxes where user will enter some value inside it. Then user will click on done button which then it will redirect user to another page and the page will show user what data entered by them before in label before they hit save button to be saved in db. I would like to use session in this case but the i don... | 2012/07/13 | [
"https://Stackoverflow.com/questions/11465067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220691/"
] | When you use `Scanner.nextInt()`, it does not consume the new line (or other delimiter) itself so the next token returned will typically be an empty string. Thus, you need to follow it with a `Scanner.nextLine()`. You can discard the result instead of assigning it to `a`:
```
int a = in.nextInt();
in.nextLine();
```... | Try it like this :D
```
import java.util.Scanner;
public class Hello {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int a;
String s = null;
System.out.print("Enter int: ");
a = in.nextInt();
while ((s = in.nextLine()).trim().isEmpty... |
11,465,067 | I have 3 text boxes where user will enter some value inside it. Then user will click on done button which then it will redirect user to another page and the page will show user what data entered by them before in label before they hit save button to be saved in db. I would like to use session in this case but the i don... | 2012/07/13 | [
"https://Stackoverflow.com/questions/11465067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1220691/"
] | When you use `Scanner.nextInt()`, it does not consume the new line (or other delimiter) itself so the next token returned will typically be an empty string. Thus, you need to follow it with a `Scanner.nextLine()`. You can discard the result instead of assigning it to `a`:
```
int a = in.nextInt();
in.nextLine();
```... | ```
import java.util.Scanner;
public class Hello{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int a;
String s;
System.out.println("Enter int : ");
a = in.nextInt();
System.out.println("Enter String : ");
s = in.next();
... |
69,986,583 | I'd like to create several plots by looping ggplot. I created a small df (*plothelp\_df*) for deriving the plot object names and variable names during the loop. But I am struggling with naming the plot objects dynamically when trying to derive the names from *plothelp\_df*.
Here the code:
```
### Creating df which lo... | 2021/11/16 | [
"https://Stackoverflow.com/questions/69986583",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16918018/"
] | Instead of storing your plots as single objects I would suggest to store them in a (named) list, which in general is the recommend way to do. Additionally I would suggest to create your plots via e.g. `lapply` instead of using a `for` loop. Finally, if `aes_string` works you also make use of the `.data` pronoun from `r... | This can also be done simply with `assign()` and `paste0()` in the `for` loop putting plots individually in the R environment.
```
library(ggplot2)
# Using mtcars dataset
cylinder <- unique(mtcars$cyl)
for(i in 1:length(cylinder)){
data <- mtcars[which(mtcars$cyl == cylinder[i]),]
plot <-
ggplot(data = da... |
11,908,579 | I seriously hope someone here can help me with this one... eventhough it's somewhat complicated to explain what I'm searching for.
Basically I'm looking for a "countdown/countup" javascript - *sounding pretty straight forward, right?*
I have found lots of variations of this sort of script but none of them meets the f... | 2012/08/10 | [
"https://Stackoverflow.com/questions/11908579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1289669/"
] | You can use for the "Done" button click callback something like
```
if (!$("#AddCustomerDialog form").valid())
return false;
var postUrl = $("#AddCustomerDialog form").attr('action');
$.post(postUrl, $(containerSelector + ' form').serialize(),
function (result) {
$("#AddCustomerDialog").dialog(... | declare a variable in your html page script, now in the return data from your php code add an echo script with the variable name and set here the id you want
in your script: var foo;
in your php code
```
echo 'data for insert in div';
echo '<script>foo=id_you_want</script>';
exit();
```
with this you set the foo ... |
23,445 | Can an employer force an employee to donate to a charity and is it legal that they know how much an employee contributes? This is in the U.S. with a large global corporation. | 2017/10/19 | [
"https://law.stackexchange.com/questions/23445",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/3645/"
] | "Probable cause" and "reasonable suspicion" are things that apply to law enforcement, not private authority.
Your school may also have conditions of entry that include, or be in a jurisdiction with laws that specifically allow, search of student persons and their property under some given circumstances. This may or ma... | It is not illegal for someone to search my bag or even my person if I give consent. As a child (which you are until 18), consent given by your parents is consent given by you. |
23,445 | Can an employer force an employee to donate to a charity and is it legal that they know how much an employee contributes? This is in the U.S. with a large global corporation. | 2017/10/19 | [
"https://law.stackexchange.com/questions/23445",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/3645/"
] | The school admins likely did not even need to call the parents to obtain permission to search the bag. School admins only need *reasonable grounds* to believe there is evidence of a crime. This lower bar is due to [inherent nature of the school environment](https://www.law.cornell.edu/supremecourt/text/469/325) and wha... | It is not illegal for someone to search my bag or even my person if I give consent. As a child (which you are until 18), consent given by your parents is consent given by you. |
23,445 | Can an employer force an employee to donate to a charity and is it legal that they know how much an employee contributes? This is in the U.S. with a large global corporation. | 2017/10/19 | [
"https://law.stackexchange.com/questions/23445",
"https://law.stackexchange.com",
"https://law.stackexchange.com/users/3645/"
] | The school admins likely did not even need to call the parents to obtain permission to search the bag. School admins only need *reasonable grounds* to believe there is evidence of a crime. This lower bar is due to [inherent nature of the school environment](https://www.law.cornell.edu/supremecourt/text/469/325) and wha... | "Probable cause" and "reasonable suspicion" are things that apply to law enforcement, not private authority.
Your school may also have conditions of entry that include, or be in a jurisdiction with laws that specifically allow, search of student persons and their property under some given circumstances. This may or ma... |
64,051 | The display of maps and data within an interactive framework is becoming more prevalent online. I'm thinking beyond merely the ability to pan/zoom/control layers, but more along the lines of displaying spatial and non-spatial data, together, in a unique format (e.g. animated charts).
For example, [this website](http:/... | 2013/06/20 | [
"https://gis.stackexchange.com/questions/64051",
"https://gis.stackexchange.com",
"https://gis.stackexchange.com/users/2114/"
] | >
> This question has been converted to Community Wiki and wiki locked
> because it is an example of a question that seeks a list of answers
> and appears to be popular enough to protect it from closure. It
> should be treated as a special case and should not be viewed as the
> type of question that is encouraged on t... | A List of 'OpenSource' GIS & **WebMap Servers**
<http://en.wikipedia.org/wiki/List_of_geographic_information_systems_software>
Recommend Geoserver 2.1
<http://geoserver.org/display/GEOS/Stable> |
53,317,899 | I'm trying to call **chrome.exe** inside a **C#** program by using **System.Diagnostics.Process** namespace.
my **chrome.exe** is located inside path **C:\Program Files (x86)\Google\Chrome\Application**
if I call **RunProc** function by passing bellow parameters - (keep absolute path of the exe and keep WorkingDirect... | 2018/11/15 | [
"https://Stackoverflow.com/questions/53317899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10299461/"
] | The only way for this to work is for you to change *your* working directory to the passed in working directory before attempting to start the other process. The `WorkingDirectory` property is just that, and doesn't in any way get involved in locating the executable to run. That just relies on your working directory and... | Why not just call the .exe from the path where it is located directly ?
```
Process.Start(@"C:\new\folder\abcd.exe");
```
Or just put
```
proc.StartInfo.WorkingDirectory = @"c:\new\folder";
```
before proc.start(); |
53,317,899 | I'm trying to call **chrome.exe** inside a **C#** program by using **System.Diagnostics.Process** namespace.
my **chrome.exe** is located inside path **C:\Program Files (x86)\Google\Chrome\Application**
if I call **RunProc** function by passing bellow parameters - (keep absolute path of the exe and keep WorkingDirect... | 2018/11/15 | [
"https://Stackoverflow.com/questions/53317899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10299461/"
] | Why not just call the .exe from the path where it is located directly ?
```
Process.Start(@"C:\new\folder\abcd.exe");
```
Or just put
```
proc.StartInfo.WorkingDirectory = @"c:\new\folder";
```
before proc.start(); | What do you think about combining the absolute path of the .exe within your static method and check if the path exists before you call the Process start:
```c
using System.Diagnostics;
using System.IO;
namespace RunProc
{
class Program
{
static void Main(string[] args)
{
RunProc(@"... |
53,317,899 | I'm trying to call **chrome.exe** inside a **C#** program by using **System.Diagnostics.Process** namespace.
my **chrome.exe** is located inside path **C:\Program Files (x86)\Google\Chrome\Application**
if I call **RunProc** function by passing bellow parameters - (keep absolute path of the exe and keep WorkingDirect... | 2018/11/15 | [
"https://Stackoverflow.com/questions/53317899",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10299461/"
] | The only way for this to work is for you to change *your* working directory to the passed in working directory before attempting to start the other process. The `WorkingDirectory` property is just that, and doesn't in any way get involved in locating the executable to run. That just relies on your working directory and... | What do you think about combining the absolute path of the .exe within your static method and check if the path exists before you call the Process start:
```c
using System.Diagnostics;
using System.IO;
namespace RunProc
{
class Program
{
static void Main(string[] args)
{
RunProc(@"... |
7,365,405 | If I pass a number of selectors to jQuery, how can I differentiate the selector that fires the event, and return that selector as a string? For example:
```
$('#selector-a, #selector-b, #selector-c').click(function(){
console.log( $(this).selector ); // logs an empty string
});
``` | 2011/09/09 | [
"https://Stackoverflow.com/questions/7365405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/62983/"
] | Obviously the URL is wrong. See my answer to this related question:
* [Reading an image in Netbeans](https://stackoverflow.com/questions/7014123/reading-an-image-in-netbeans/7014177#7014177)
As for your second question, it is possible to combine multiple layout managers, although each container is limited to *exactly... | The package isn't named "res", but "resources" as we can see from your snapshot.
```
Image cima = ImageIO.read(YourClass.class.getResource("/resources/cross.png"));
```
---
Change the catch body to this:
```
} catch (IOException ex){
System.out.println("ERROR");
ex.printStackTrace();
}
```
And tell us what e... |
9,407,654 | I am using ExtJs4.
```
new Ext.Window({
id: token + '_window',
animateTarget: token + '_taskbar', //Button id
height: 300,
width: 300,
title: name,
maximizable: true,
minimizable: true,
iconCls: 'basketball-small-icon',
html: 'This is the <b>' + name + '</b> window',
listeners:... | 2012/02/23 | [
"https://Stackoverflow.com/questions/9407654",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1213885/"
] | If I understand well, you want to reuse the window, with a different content.
So, you should create only one window, that you reuse by updating the html content and calling show() on this window.
To perform that, you need to add the property `closeAction:'hide'`. This way, your window won't be destroyed when clicking o... | You don't have to call destroy() since once the window is closed, it is automatically destroyed.
See api of [Ext.Window](http://docs.sencha.com/ext-js/4-0/#!/api/Ext.window.Window-method-close).
And do not call close() in your beforeclose handler since it's already about to close.
I think you can use 'new' w... |
5,829,059 | I have written a script which stores digital signatures in binaries and script files. This question is only regarding scripts: Currently, all these signatures get stored in one single line (a comment) such as:
```
#!/usr/bin/perl
print "Hello"
print " World\n"
#Signature:ASDASG13412sdflsal4sf etc........
```
The exa... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5829059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/669602/"
] | Most scripting languages will have long enough limits, if indeed they have a formal limit on the length of lines. POSIX recommends 2048 minimum.
How long are your signatures? Most likely, not more than 1024...in which case, I really wouldn't worry. If it doesn't work for some language, you should report the bug rather... | In Python, you should not have any problem with line length as long as you have sufficient memory. In PHP, you may be limited by the amount of memory PHP interpreter is allowed to use (set in php.ini) |
5,829,059 | I have written a script which stores digital signatures in binaries and script files. This question is only regarding scripts: Currently, all these signatures get stored in one single line (a comment) such as:
```
#!/usr/bin/perl
print "Hello"
print " World\n"
#Signature:ASDASG13412sdflsal4sf etc........
```
The exa... | 2011/04/29 | [
"https://Stackoverflow.com/questions/5829059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/669602/"
] | Most scripting languages will have long enough limits, if indeed they have a formal limit on the length of lines. POSIX recommends 2048 minimum.
How long are your signatures? Most likely, not more than 1024...in which case, I really wouldn't worry. If it doesn't work for some language, you should report the bug rather... | Perl also has no fixed maximum line length, other than imposed by memory usage. |
3,863,754 | I want to find out common `days/dates` between `two periods`.
For example
```
period1: 25-10-2010 to 25-11-2010
period2: 10-11-2010 to 10-12-2010
```
Here `15 days`, `10-11` to `25-11` are common. How can I find it in PHP or Zend Framework. | 2010/10/05 | [
"https://Stackoverflow.com/questions/3863754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/765545/"
] | ```
In [33]: hash?
```
>
> Return a hash value for the object. Two objects with the same
> value have the same hash value. **The reverse is not necessarily true, but
> likely**.
>
>
>
Why not just use the tuple (ida,idb) as the key?
```
import pprint
class SomeClass(object):
def __init__(self,ida,idb):
... | There are only 2\*\*<word size> possible hashes, so you would have to run a 128-bit version of Python to even store all (2\*\*64)\*\*2 possible hashes in the first place. And yes, it could *still* be possible to have collisions. Use a `set` if you need to store unique objects; just define `__hash__()` and `__eq__()` in... |
3,863,754 | I want to find out common `days/dates` between `two periods`.
For example
```
period1: 25-10-2010 to 25-11-2010
period2: 10-11-2010 to 10-12-2010
```
Here `15 days`, `10-11` to `25-11` are common. How can I find it in PHP or Zend Framework. | 2010/10/05 | [
"https://Stackoverflow.com/questions/3863754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/765545/"
] | Like Ignacio said, you can have hash collisions. Why don't you just use the tuple itself? Tuples are immutable and it looks like your ida and idb are (immutable) integers. | There are only 2\*\*<word size> possible hashes, so you would have to run a 128-bit version of Python to even store all (2\*\*64)\*\*2 possible hashes in the first place. And yes, it could *still* be possible to have collisions. Use a `set` if you need to store unique objects; just define `__hash__()` and `__eq__()` in... |
3,863,754 | I want to find out common `days/dates` between `two periods`.
For example
```
period1: 25-10-2010 to 25-11-2010
period2: 10-11-2010 to 10-12-2010
```
Here `15 days`, `10-11` to `25-11` are common. How can I find it in PHP or Zend Framework. | 2010/10/05 | [
"https://Stackoverflow.com/questions/3863754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/765545/"
] | ```
In [33]: hash?
```
>
> Return a hash value for the object. Two objects with the same
> value have the same hash value. **The reverse is not necessarily true, but
> likely**.
>
>
>
Why not just use the tuple (ida,idb) as the key?
```
import pprint
class SomeClass(object):
def __init__(self,ida,idb):
... | Like Ignacio said, you can have hash collisions. Why don't you just use the tuple itself? Tuples are immutable and it looks like your ida and idb are (immutable) integers. |
2,439,139 | Hey I have a general recurrence relation as follows, and I want to find a general sum formula in terms of the variable.
$U\_1=DE$
$U\_n=(U\_{n-1} + D)E$
$D$ and $E$ are real positive numbers, can there be a sum formula for $n$ terms in terms of $D$ and $E$? | 2017/09/21 | [
"https://math.stackexchange.com/questions/2439139",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/448452/"
] | Hint:
$$U\_2=EU\_1+U\_1=(E+1)U\_1$$
$$U\_3 = EU\_2+U\_1=(E^2+E)U\_1+U\_1=(E^2+E+1)U\_1$$
$$U\_4 = EU\_3+U\_1=(E^3+E^2+E)U\_1+U\_1=(E^3+E^2+E+1)U\_1$$
Do you see a pattern? Use also $1+E+E^2+...+E^{n-1}=\frac{1-E^{n}}{1-E}$.
If you found the candidate for the formula you can plug it into the recurrence equation and... | Notice the recurrence relation can be rewritten as
$$U\_{n+1} = (U\_n + D)E = U\_n E + \frac{DE}{1-E}(1-E) \implies
U\_{n+1} - \frac{DE}{1-E} = \left(U\_n - \frac{DE}{1-E}\right)E$$
After the offset $-\frac{DE}{1-E}$, each term is a multiple of $E$ of previous term. For general $n$, this leads to
$$U\_n - \frac{DE}{1-... |
2,439,139 | Hey I have a general recurrence relation as follows, and I want to find a general sum formula in terms of the variable.
$U\_1=DE$
$U\_n=(U\_{n-1} + D)E$
$D$ and $E$ are real positive numbers, can there be a sum formula for $n$ terms in terms of $D$ and $E$? | 2017/09/21 | [
"https://math.stackexchange.com/questions/2439139",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/448452/"
] | Hint:
$$U\_2=EU\_1+U\_1=(E+1)U\_1$$
$$U\_3 = EU\_2+U\_1=(E^2+E)U\_1+U\_1=(E^2+E+1)U\_1$$
$$U\_4 = EU\_3+U\_1=(E^3+E^2+E)U\_1+U\_1=(E^3+E^2+E+1)U\_1$$
Do you see a pattern? Use also $1+E+E^2+...+E^{n-1}=\frac{1-E^{n}}{1-E}$.
If you found the candidate for the formula you can plug it into the recurrence equation and... | $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
\newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
\newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\ds}[1]{\displaystyle{#1}}
\newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
\new... |
2,439,139 | Hey I have a general recurrence relation as follows, and I want to find a general sum formula in terms of the variable.
$U\_1=DE$
$U\_n=(U\_{n-1} + D)E$
$D$ and $E$ are real positive numbers, can there be a sum formula for $n$ terms in terms of $D$ and $E$? | 2017/09/21 | [
"https://math.stackexchange.com/questions/2439139",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/448452/"
] | Hint:
$$U\_2=EU\_1+U\_1=(E+1)U\_1$$
$$U\_3 = EU\_2+U\_1=(E^2+E)U\_1+U\_1=(E^2+E+1)U\_1$$
$$U\_4 = EU\_3+U\_1=(E^3+E^2+E)U\_1+U\_1=(E^3+E^2+E+1)U\_1$$
Do you see a pattern? Use also $1+E+E^2+...+E^{n-1}=\frac{1-E^{n}}{1-E}$.
If you found the candidate for the formula you can plug it into the recurrence equation and... | WLOG, $D=1$ (see why ?)
Then as there is this factor $E$, consider $U\_n=V\_nE^n$.
The recurrence becomes
$$V\_1E=E,$$ and $$V\_nE^n=(V\_{n-1}E^{n-1}+1)E$$ or
$$V\_n=V\_{n-1}+E^{-n},$$ which is the summation of a geometric series.
$$V\_n=\frac{1-E^{-n}}{1-E^{-1}},$$ and
$$U\_n=\frac{E^n-1}{1-E^{-1}}.$$
Now the s... |
2,439,139 | Hey I have a general recurrence relation as follows, and I want to find a general sum formula in terms of the variable.
$U\_1=DE$
$U\_n=(U\_{n-1} + D)E$
$D$ and $E$ are real positive numbers, can there be a sum formula for $n$ terms in terms of $D$ and $E$? | 2017/09/21 | [
"https://math.stackexchange.com/questions/2439139",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/448452/"
] | Hint:
$$U\_2=EU\_1+U\_1=(E+1)U\_1$$
$$U\_3 = EU\_2+U\_1=(E^2+E)U\_1+U\_1=(E^2+E+1)U\_1$$
$$U\_4 = EU\_3+U\_1=(E^3+E^2+E)U\_1+U\_1=(E^3+E^2+E+1)U\_1$$
Do you see a pattern? Use also $1+E+E^2+...+E^{n-1}=\frac{1-E^{n}}{1-E}$.
If you found the candidate for the formula you can plug it into the recurrence equation and... | I'm always a fan of the generating function approach.
The given recurrence can be defined as $u\_0=0$ and $u\_n=(u\_{n-1}+d)e$.
\begin{align}
U(x) &= \sum\_{j=0}^{\infty}u\_jx^j\\
&= \sum\_{j=1}^{\infty}u\_jx^j\\
&= \sum\_{j=1}^{\infty}(u\_{j-1}+d)ex^j\\
&= \sum\_{j=0}^{\infty}(u\_{j-1}+d)ex^{j+1}\\
&= ex\sum\_{j=0}^... |
2,439,139 | Hey I have a general recurrence relation as follows, and I want to find a general sum formula in terms of the variable.
$U\_1=DE$
$U\_n=(U\_{n-1} + D)E$
$D$ and $E$ are real positive numbers, can there be a sum formula for $n$ terms in terms of $D$ and $E$? | 2017/09/21 | [
"https://math.stackexchange.com/questions/2439139",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/448452/"
] | Hint:
$$U\_2=EU\_1+U\_1=(E+1)U\_1$$
$$U\_3 = EU\_2+U\_1=(E^2+E)U\_1+U\_1=(E^2+E+1)U\_1$$
$$U\_4 = EU\_3+U\_1=(E^3+E^2+E)U\_1+U\_1=(E^3+E^2+E+1)U\_1$$
Do you see a pattern? Use also $1+E+E^2+...+E^{n-1}=\frac{1-E^{n}}{1-E}$.
If you found the candidate for the formula you can plug it into the recurrence equation and... | I have previously shown [here](https://math.stackexchange.com/questions/2400524/solving-simple-linear-recurrences-with-generating-functions/2402627#2402627), that $f\_n=Af\_{n-1}+B$, which I call a *short* Fibonacci sequence, has the general solution
$$f\_n=\frac{[(A-1)f\_0+B]A^n-B}{A-1},\quad n\ge0$$
This gives us a... |
71,039,912 | I have a file with tons of lines using a semicolon (`;`) as a delimiter. I have about 5 fields and need to change the format of only the first 2 fields without affecting the remainder of each line
`20211119000751;20211119000759;IDNumber;Code;THings;SomeStuff`
I want the end result to look like
`2021-11-19 00:07:51;2... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71039912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7845766/"
] | Use capture-groups with fixed number of digits.
```sh
sed -E 's/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1-\2-\3 \4:\5:\6/g' input > output
``` | Using awk:
```
$ awk -v FS=";" '
function process_date(date)
{
# 20211119000751 -> 2021-11-19 00:07:51
new_date = substr(date, 1, 4) \
"-" \
substr(date, 5, 2) \
"-" \
substr(date, 7, 2) \
" " \
substr(date, 9, 2) \
":" substr(date, 11, 2) \
... |
71,039,912 | I have a file with tons of lines using a semicolon (`;`) as a delimiter. I have about 5 fields and need to change the format of only the first 2 fields without affecting the remainder of each line
`20211119000751;20211119000759;IDNumber;Code;THings;SomeStuff`
I want the end result to look like
`2021-11-19 00:07:51;2... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71039912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7845766/"
] | Use capture-groups with fixed number of digits.
```sh
sed -E 's/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1-\2-\3 \4:\5:\6/g' input > output
``` | Crappy but working solution (each line add a character at a given position
`/./` select any char
the n number at the end is the number of repetition of the selected pattern, so `/4` repeat `/./` 4 times
& is the selected motif, plus a character, sor for example :
`s/./&-/4' take any first 4 character, and replace them ... |
71,039,912 | I have a file with tons of lines using a semicolon (`;`) as a delimiter. I have about 5 fields and need to change the format of only the first 2 fields without affecting the remainder of each line
`20211119000751;20211119000759;IDNumber;Code;THings;SomeStuff`
I want the end result to look like
`2021-11-19 00:07:51;2... | 2022/02/08 | [
"https://Stackoverflow.com/questions/71039912",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7845766/"
] | Use capture-groups with fixed number of digits.
```sh
sed -E 's/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/\1-\2-\3 \4:\5:\6/g' input > output
``` | Since only `bash` is tagged, here's a solution using bash's string indexing:
```sh
while IFS=\; read -r x y z
do printf '%s;%s;%s\n' \
"${x::4}-${x:4:2}-${x:6:2} ${x:8:2}:${x:10:2}:${x:12:2}" \
"${y::4}-${y:4:2}-${y:6:2} ${y:8:2}:${y:10:2}:${y:12:2}" \
"$z"
done
``` |
16,463,152 | ```
sub open_files {
my @files = @_;
my @lines;
foreach (@files){
print "$_\[1\]\n";
}
foreach my $f (@files){
print "$f\[2\]\n";
open(my $fh,'<',$f) or die " '$f' $!";
print "$fh\[3\]\n";
push(@lines,<$fh>);
close($fh);
}
return @lines... | 2013/05/09 | [
"https://Stackoverflow.com/questions/16463152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2016977/"
] | ```
use warnings;
use strict;
die "Usage: $0 (abs path to dir) " if @ARGV != 1;
my $dir = shift @ARGV;
our @html_files = ();
file_find($dir);
print "html files: @html_files\n";
sub file_find {
my $dir = shift;
opendir my $dh, $dir or warn "$dir: $!";
my @files = grep { $_ !~ /^\.{1,2}$/ } readdir $dh;... | The short answer is that [`glob`](http://perldoc.perl.org/functions/glob.html) does not recurse into sub-directories.
Instead, use [`File::Find`](https://metacpan.org/module/File%3a%3aFind):
```
use strict;
use warnings;
use feature 'say';
use File::Find 'find';
my @files;
find( sub { push @files, $File::Find::name ... |
36,512,337 | I'd like to create a form field. And then display two variables (already assigned with values) inside it when the page loads itself. I know I can use "`<input id="formField" value="John Smith"/>` but I'd like to use `document.getElementById` to do this. What is wrong with my code?
The form field loads, but it is empt... | 2016/04/09 | [
"https://Stackoverflow.com/questions/36512337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6179680/"
] | `input` elements do not have an `innerHTML` property. You want to set the `value` property, like so:
`document.getElementById("formField").value = z;`
Other things to note:
* You're setting `x` equal to `one` and `y` equal to `two`, then just using `one` and `two` directly. No point in having `x` and `y`.
* `one` an... | <http://jsbin.com/buroxaciba/edit?html,output>
innerHTML is normally used for div, span, p and similar elements.
input type number -> text |
36,512,337 | I'd like to create a form field. And then display two variables (already assigned with values) inside it when the page loads itself. I know I can use "`<input id="formField" value="John Smith"/>` but I'd like to use `document.getElementById` to do this. What is wrong with my code?
The form field loads, but it is empt... | 2016/04/09 | [
"https://Stackoverflow.com/questions/36512337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6179680/"
] | There are couple of issues in your code
1. `input type = "number"` but you are trying to put a string to its value. Which will not work. So change input type to text
2. `one` & `two` are variables, so there is no `one.value` and `two.value`. Simply `one + two` will work
3. You have to use `.value` instead of `innerHT... | `input` elements do not have an `innerHTML` property. You want to set the `value` property, like so:
`document.getElementById("formField").value = z;`
Other things to note:
* You're setting `x` equal to `one` and `y` equal to `two`, then just using `one` and `two` directly. No point in having `x` and `y`.
* `one` an... |
36,512,337 | I'd like to create a form field. And then display two variables (already assigned with values) inside it when the page loads itself. I know I can use "`<input id="formField" value="John Smith"/>` but I'd like to use `document.getElementById` to do this. What is wrong with my code?
The form field loads, but it is empt... | 2016/04/09 | [
"https://Stackoverflow.com/questions/36512337",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6179680/"
] | There are couple of issues in your code
1. `input type = "number"` but you are trying to put a string to its value. Which will not work. So change input type to text
2. `one` & `two` are variables, so there is no `one.value` and `two.value`. Simply `one + two` will work
3. You have to use `.value` instead of `innerHT... | <http://jsbin.com/buroxaciba/edit?html,output>
innerHTML is normally used for div, span, p and similar elements.
input type number -> text |
66,964,028 | (*VSCode*)
When I Disunite the event from jsx code. (at. class Component)
Like This⬇
```
handleSubmit = e => { ...}
render(){
return (
<>
<form onSubmit={this.handelSubmit}>
<input
ref={this.onRefInput}
type='number'
value={this.state.value}
onChange={this.onChange}
... | 2021/04/06 | [
"https://Stackoverflow.com/questions/66964028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12796086/"
] | You can assign a type to either to the function itself or to the arguments of the function, which is the event.
---
```
React.FormEventHandler<HTMLFormElement>
```
This is the type for the function. If you use it like this:
```
handleSubmit: React.FormEventHandler<HTMLFormElement> = e => {
}
```
Then the type fo... | In advance, sorry for that This answer is not a complete solution
I had the same problem, and I searched a lot, and try to change all settings.json about typescript.inlayHints.
unfortunately, nothing works
So I go to the implementation of onSubmit
[]... |
2,848,522 | As in c # to create and then call the function? In C + + do so:
```
int func (int value)
{
value +=2;
}
```
But as is done in c #? | 2010/05/17 | [
"https://Stackoverflow.com/questions/2848522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/312900/"
] | Here's the same function translated in C#:
```
public void Func(ref int value)
{
// Parameter is passed by reference so any modification
// to the value will propagate to the caller
value +=2;
}
```
And call it like this:
```
int value = 5;
Func(ref value); // value is now 7
```
---
UPDATE:
If as an a... | Considering your example is wrong... well, anyway.
```
public void func(ref int value)
{
value+=2;
}
``` |
35,378,833 | When I try to execute my app in the simulator or in my iPhone I get the next error:
```
App installation failed
This application or a bundle it contains has the same bundle identifier as this application or another bundle that it contains. Bundle identifiers must be unique.
```
["). | For me selecting Product > Clean in Xcode from menu and running again worked! |
54,140,661 | I have created a MySQL deployment in kubernetes and exposed it as nodes-port.
***What I can do:***
Access it from inside the cluster using
`kubectl run -it --rm --image=mysql:5.6 --restart=Never mysql-client -- mysql -h mysql -ppassword`
**What I want to do:**
Access the MySQL server from outside the cluster... | 2019/01/11 | [
"https://Stackoverflow.com/questions/54140661",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8123139/"
] | You can access it by `mysql -u {username} -p {password} -h {any kubernetes worker ip} -P {nodePort}`. After you start mysql container and expose it ad node port through a service. | You need to specify the MYSQL\_ROOT\_PASSWORD while bringing up the pod. How were you able to bring it up in Docker without it? |
318,230 | I wanted to make a little script involving messages on my Mac and after some research I discovered it was indeed possible. The only problem is that the "AppleScript handler" option in Messages>Preferences>General is missing for me. [This very option is listed right on the Apple website under the High Sierra heading.](h... | 2018/03/15 | [
"https://apple.stackexchange.com/questions/318230",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/280065/"
] | Yes, Apple DID remove that feature in 10.13.4. I actually opened a case on this with Apple Support (I even referenced this page) and they got back to me today and informed me that it really has been removed from Messages. The Apple representative suggested going to <http://www.apple.com/feedback/> if I wanted to expres... | I have spoken with apple tech support senior advisor and they called me back and confirmed that the applescript handler option in messages has been removed in the latest operating system update 10.13.4. If you would like to send them feedback go to Apple.com/feedback and let them know your thoughts and that we would li... |
194,382 | I would like to pull a from another phtml to my, how can I do this?
I would like to use the same div that appears for the desktop cart for the mobile cart.
**My Phtml**
```
<div class="carrinho-cheio-mobile" style="display: none;">Itens in cart!</div>
```
**Magento PHTML**
```
<?php $_items = $this->getRecentItems... | 2017/09/22 | [
"https://magento.stackexchange.com/questions/194382",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/56552/"
] | There are several ways how to do this, so below is just one example. For purpose of simplicity lets say that you have one select(A), and based on its value (or change of its value) you want to load new options for the other select (B) (with ajax in this example). The example below was used where select A represented at... | **app/code/VendoreName/ModuleName/view/adminhtml/ui\_component**
**ui\_formname.xml**
```
<form>
...............................................................................................................
........................................................................................................ |
27,530,868 | I have a simple program, WITHOUT "public int a;", the program runs no problem,
but after add "public int a;", the programm has errors, what is the problem?
there is no special meaning for this int field "a", i just want to try something and find this problem
, so you have made a mistake in peeking.
By flipping the inequality to point away from the observed value, you assure yourself of not being able to reject (perhaps with some exotic exceptions, bu... |
21,109,598 | I want to register a notification observer outside of the class that is observing the notification reception.
i tried to do it like this :
```
[[NSNotificationCenter defaultCenter]
addObserver:[ViewController class]
selector:@selector(NotificationReceived:)
name:@"notification" object:nil];
... | 2014/01/14 | [
"https://Stackoverflow.com/questions/21109598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2136812/"
] | You have two possibilities:
* Simply set the attribute `AutoPostBack="false"` on your button or whatever control.
* As an alternative you could also add the following javascript to the click event of the button :
```
onclick="return false"
```
This prevents the button from submitting. | First you have to know about Sever Control and normal HTML control.
If you used Server Button Control then your Page reload on each click.
If you wan to stop it then you have to use AutoPostBack="false", using this your server side method calling is stop.
Otherwise use Normal HTML Button Control and use JavaScript to r... |
21,109,598 | I want to register a notification observer outside of the class that is observing the notification reception.
i tried to do it like this :
```
[[NSNotificationCenter defaultCenter]
addObserver:[ViewController class]
selector:@selector(NotificationReceived:)
name:@"notification" object:nil];
... | 2014/01/14 | [
"https://Stackoverflow.com/questions/21109598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2136812/"
] | Try following:
```
<asp:button runat="server".... OnClientClick="return false;" />
``` | First you have to know about Sever Control and normal HTML control.
If you used Server Button Control then your Page reload on each click.
If you wan to stop it then you have to use AutoPostBack="false", using this your server side method calling is stop.
Otherwise use Normal HTML Button Control and use JavaScript to r... |
57,272,749 | I inherited some code to maintain, with this line in it:
```
this.setState({}); // Force update
```
Is this guaranteed to cause a re-render? | 2019/07/30 | [
"https://Stackoverflow.com/questions/57272749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275803/"
] | `setState` merges the object passed as argument into the actual state in an immutable way. `this.setState({})` will merge nothing to state but will actually return a new object, the shallow comparison performed by `React` will always assert to `false` and a re render will be triggered, unless explicitly cancelled with ... | According to the documentation it is and several other methods in order
1. static getDerivedStateFromProps()
2. shouldComponentUpdate()
3. render()
4. getSnapshotBeforeUpdate()
5. componentDidUpdate()
please see this [link](https://reactjs.org/docs/react-component.html#updating) for detailed |
57,272,749 | I inherited some code to maintain, with this line in it:
```
this.setState({}); // Force update
```
Is this guaranteed to cause a re-render? | 2019/07/30 | [
"https://Stackoverflow.com/questions/57272749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275803/"
] | `setState` merges the object passed as argument into the actual state in an immutable way. `this.setState({})` will merge nothing to state but will actually return a new object, the shallow comparison performed by `React` will always assert to `false` and a re render will be triggered, unless explicitly cancelled with ... | You can actually [test it](https://snack.expo.io/@remeus/force-re-render) easily:
```js
import React, { Component } from 'react';
import { Button } from 'react-native';
class Test extends Component {
render() {
console.log('render');
return <Button onPress={() => this.setState({})} title='Test' />;
}
}
e... |
57,272,749 | I inherited some code to maintain, with this line in it:
```
this.setState({}); // Force update
```
Is this guaranteed to cause a re-render? | 2019/07/30 | [
"https://Stackoverflow.com/questions/57272749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275803/"
] | `setState` merges the object passed as argument into the actual state in an immutable way. `this.setState({})` will merge nothing to state but will actually return a new object, the shallow comparison performed by `React` will always assert to `false` and a re render will be triggered, unless explicitly cancelled with ... | It depends. If you want to render a component, react internally checks is DOM equals with previous(this occurs if props of component is not changed at all). If dom equals with previous version, react checks `shouldComponentUpdate`. `forceUpdate` is different than `this.setState({})`, which always render components. |
57,272,749 | I inherited some code to maintain, with this line in it:
```
this.setState({}); // Force update
```
Is this guaranteed to cause a re-render? | 2019/07/30 | [
"https://Stackoverflow.com/questions/57272749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275803/"
] | You can actually [test it](https://snack.expo.io/@remeus/force-re-render) easily:
```js
import React, { Component } from 'react';
import { Button } from 'react-native';
class Test extends Component {
render() {
console.log('render');
return <Button onPress={() => this.setState({})} title='Test' />;
}
}
e... | According to the documentation it is and several other methods in order
1. static getDerivedStateFromProps()
2. shouldComponentUpdate()
3. render()
4. getSnapshotBeforeUpdate()
5. componentDidUpdate()
please see this [link](https://reactjs.org/docs/react-component.html#updating) for detailed |
57,272,749 | I inherited some code to maintain, with this line in it:
```
this.setState({}); // Force update
```
Is this guaranteed to cause a re-render? | 2019/07/30 | [
"https://Stackoverflow.com/questions/57272749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275803/"
] | According to the documentation it is and several other methods in order
1. static getDerivedStateFromProps()
2. shouldComponentUpdate()
3. render()
4. getSnapshotBeforeUpdate()
5. componentDidUpdate()
please see this [link](https://reactjs.org/docs/react-component.html#updating) for detailed | It depends. If you want to render a component, react internally checks is DOM equals with previous(this occurs if props of component is not changed at all). If dom equals with previous version, react checks `shouldComponentUpdate`. `forceUpdate` is different than `this.setState({})`, which always render components. |
57,272,749 | I inherited some code to maintain, with this line in it:
```
this.setState({}); // Force update
```
Is this guaranteed to cause a re-render? | 2019/07/30 | [
"https://Stackoverflow.com/questions/57272749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275803/"
] | You can actually [test it](https://snack.expo.io/@remeus/force-re-render) easily:
```js
import React, { Component } from 'react';
import { Button } from 'react-native';
class Test extends Component {
render() {
console.log('render');
return <Button onPress={() => this.setState({})} title='Test' />;
}
}
e... | It depends. If you want to render a component, react internally checks is DOM equals with previous(this occurs if props of component is not changed at all). If dom equals with previous version, react checks `shouldComponentUpdate`. `forceUpdate` is different than `this.setState({})`, which always render components. |
56,381,375 | I have a column [LongText] in a table and its row value is merging of all Attributes and their values. Below is the example.
Can we split colon before and after words into two columns as shown in expected result? need it in sql 2014
```
Longtext
TYPE: SOLID WEDGE 1,SOLID WEDGE 2, VALVE SIZE: 1 IN, PRESSURE RATING: ... | 2019/05/30 | [
"https://Stackoverflow.com/questions/56381375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11578665/"
] | Swift 5
=======
Indeed there is - I found the answer at the UIKonf 2019 where I heard from Erica Sadun that there is a way by using `Swift 5 String Interpolation` to achieve this in one single line. All you need is this reusable extension:
```swift
extension String.StringInterpolation {
mutating func appendInterp... | You can use [Ternary operator](https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html#ID71)
```
let msg = "Contact \(me.name)" + (me.isFavorite ? " is a favorite contact" : "")
``` |
56,381,375 | I have a column [LongText] in a table and its row value is merging of all Attributes and their values. Below is the example.
Can we split colon before and after words into two columns as shown in expected result? need it in sql 2014
```
Longtext
TYPE: SOLID WEDGE 1,SOLID WEDGE 2, VALVE SIZE: 1 IN, PRESSURE RATING: ... | 2019/05/30 | [
"https://Stackoverflow.com/questions/56381375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11578665/"
] | Swift 5
=======
Indeed there is - I found the answer at the UIKonf 2019 where I heard from Erica Sadun that there is a way by using `Swift 5 String Interpolation` to achieve this in one single line. All you need is this reusable extension:
```swift
extension String.StringInterpolation {
mutating func appendInterp... | I tend to create a second `String` variable which may or may not be empty, and unconditionally append it...
```swift
let me = Contact(name: "Stefan", isFavorite: true)
let favorite = me.isFavorite ? " is a favorite contact" : ""
var message = "Contact \(me.name)\(favorite)"
``` |
56,381,375 | I have a column [LongText] in a table and its row value is merging of all Attributes and their values. Below is the example.
Can we split colon before and after words into two columns as shown in expected result? need it in sql 2014
```
Longtext
TYPE: SOLID WEDGE 1,SOLID WEDGE 2, VALVE SIZE: 1 IN, PRESSURE RATING: ... | 2019/05/30 | [
"https://Stackoverflow.com/questions/56381375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11578665/"
] | You can use [Ternary operator](https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html#ID71)
```
let msg = "Contact \(me.name)" + (me.isFavorite ? " is a favorite contact" : "")
``` | I tend to create a second `String` variable which may or may not be empty, and unconditionally append it...
```swift
let me = Contact(name: "Stefan", isFavorite: true)
let favorite = me.isFavorite ? " is a favorite contact" : ""
var message = "Contact \(me.name)\(favorite)"
``` |
1,219,635 | I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
```
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plu... | 2009/08/02 | [
"https://Stackoverflow.com/questions/1219635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | As soon as you use `$.fn.foo.bar()` -- `this` points to `$.fn.foo`, which is what you would expect in JavaScript (`this` being the object that the function is called on.)
I have noticed in plugins from jQuery UI (like sortable) where you call functions like:
```
$(...).sortable("serialize");
$(...).sortable({options}... | Well, I'm sure there are many ways to skin this cat. The jQuery UI library uses a pattern like this:
```
// initialize a dialog window from an element:
$('#selector').dialog({});
// call the show method of a dialog:
$('#selector').dialog('show');
``` |
1,219,635 | I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
```
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plu... | 2009/08/02 | [
"https://Stackoverflow.com/questions/1219635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | I know this has already been answered but I have created a plugin that does exactly what you want:
<http://code.google.com/p/jquery-plugin-dev/source/browse/trunk/jquery.plugin.js>
I've included a small example below, but check out this jQuery Dev Group post for a more in-depth example: <http://groups.google.com/grou... | Well, I'm sure there are many ways to skin this cat. The jQuery UI library uses a pattern like this:
```
// initialize a dialog window from an element:
$('#selector').dialog({});
// call the show method of a dialog:
$('#selector').dialog('show');
``` |
1,219,635 | I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
```
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plu... | 2009/08/02 | [
"https://Stackoverflow.com/questions/1219635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | Well, I'm sure there are many ways to skin this cat. The jQuery UI library uses a pattern like this:
```
// initialize a dialog window from an element:
$('#selector').dialog({});
// call the show method of a dialog:
$('#selector').dialog('show');
``` | I'm a fan of the pattern I've seen on Eric Martin's [SimpleModal](http://www.ericmmartin.com/projects/simplemodal/). This works well for when I'm NOT acting on DOM elements -- in this case a wrapper to utilize localStorage.
This way I can easily refer to the constructor:
```
$.totalStorage('robo', 'cop');
```
...or... |
1,219,635 | I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
```
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plu... | 2009/08/02 | [
"https://Stackoverflow.com/questions/1219635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | As soon as you use `$.fn.foo.bar()` -- `this` points to `$.fn.foo`, which is what you would expect in JavaScript (`this` being the object that the function is called on.)
I have noticed in plugins from jQuery UI (like sortable) where you call functions like:
```
$(...).sortable("serialize");
$(...).sortable({options}... | I know this has already been answered but I have created a plugin that does exactly what you want:
<http://code.google.com/p/jquery-plugin-dev/source/browse/trunk/jquery.plugin.js>
I've included a small example below, but check out this jQuery Dev Group post for a more in-depth example: <http://groups.google.com/grou... |
1,219,635 | I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
```
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plu... | 2009/08/02 | [
"https://Stackoverflow.com/questions/1219635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | As soon as you use `$.fn.foo.bar()` -- `this` points to `$.fn.foo`, which is what you would expect in JavaScript (`this` being the object that the function is called on.)
I have noticed in plugins from jQuery UI (like sortable) where you call functions like:
```
$(...).sortable("serialize");
$(...).sortable({options}... | I'm a fan of the pattern I've seen on Eric Martin's [SimpleModal](http://www.ericmmartin.com/projects/simplemodal/). This works well for when I'm NOT acting on DOM elements -- in this case a wrapper to utilize localStorage.
This way I can easily refer to the constructor:
```
$.totalStorage('robo', 'cop');
```
...or... |
1,219,635 | I'm creating a jQuery plugin that that is rather large in scope. In fact, the plugin technically consists of a few plugins that all work together.
```
(function($){
$.fn.foo = function(){
//plugin part A
}
$.fn.bar = function(){
//plugin part B
}
$.fn.baz = function(){
//plu... | 2009/08/02 | [
"https://Stackoverflow.com/questions/1219635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/42523/"
] | I know this has already been answered but I have created a plugin that does exactly what you want:
<http://code.google.com/p/jquery-plugin-dev/source/browse/trunk/jquery.plugin.js>
I've included a small example below, but check out this jQuery Dev Group post for a more in-depth example: <http://groups.google.com/grou... | I'm a fan of the pattern I've seen on Eric Martin's [SimpleModal](http://www.ericmmartin.com/projects/simplemodal/). This works well for when I'm NOT acting on DOM elements -- in this case a wrapper to utilize localStorage.
This way I can easily refer to the constructor:
```
$.totalStorage('robo', 'cop');
```
...or... |
70,024,064 | I'm using react and this is my code.
```
import { useEffect, useState } from "react";
const Test = (props) => {
const [sort, setSort] = useState(1);
const [albums, setAlbums] = useState([
{
"userId": 1,
"id": 1,
"title": "A letter",
"photos": {
... | 2021/11/18 | [
"https://Stackoverflow.com/questions/70024064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2395282/"
] | Don't do this with String split, replace etc. At some point, it will fail.
You should parse the sql statement. Example with [JsqlParser](https://github.com/JSQLParser/JSqlParser) like
```
public class Main {
public static void main(String[] args) throws JSQLParserException {
Select stmt = (Select) CCJSq... | You can do it as follow:
```
String query = "SELECT COUNT(project_id) AS 'count', project.name AS 'projects' FROM test JOIN project ON project_id = project.id";
LinkedList<String> queryColumns = new LinkedList<>();
String[] test = query.replace("SELECT", "").split("FROM")[0].split(","); //You have a string from which ... |
10,668,405 | There are various points in a Grid.
Say (x,y) can be reached from (x-1,y+1) in a single unit of time. then what would be the general formula for finding distance between a point (x1,y1) to (x2,y2).
say for (0,0) to (-2,-1) i.e. coordinate can be negative too.
I could not think of general formula. | 2012/05/19 | [
"https://Stackoverflow.com/questions/10668405",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/646961/"
] | If I understand the question correctly, and diagonal movements have the same cost as "manhattan" movements, it's cheaper than the manhattan distance in most cases -- only the maximum of the x and y distances is relevant:
max(abs(x1 - x2), abs(y1 - y2))
Basically you move diagonally at cost 1 per unit until you have r... | if (x,y) can be reached from (x-1, y+1).
Then all points reachable from (x1,y1) are (x1+k, y1-k) where k is greater than 0. |
1,478,697 | I frequently see python code similar to
```
for line in open(filename):
do_something(line)
```
When does filename get closed with this code?
Would it be better to write
```
with open(filename) as f:
for line in f.readlines():
do_something(line)
``` | 2009/09/25 | [
"https://Stackoverflow.com/questions/1478697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173922/"
] | `filename` would be closed when it falls out of scope. That normally would be the end of the method.
Yes, it's better to use `with`.
>
> Once you have a file object, you perform all file I/O by calling methods of this object. [...] When you are done with the file, you should finish by calling the `close` method on t... | The `with` part is better because it close the file afterwards.
You don't even have to use `readlines()`. `for line in file` is enough.
I don't think the first one closes it. |
1,478,697 | I frequently see python code similar to
```
for line in open(filename):
do_something(line)
```
When does filename get closed with this code?
Would it be better to write
```
with open(filename) as f:
for line in f.readlines():
do_something(line)
``` | 2009/09/25 | [
"https://Stackoverflow.com/questions/1478697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173922/"
] | The `with` part is better because it close the file afterwards.
You don't even have to use `readlines()`. `for line in file` is enough.
I don't think the first one closes it. | python is garbage-collected - cpython has reference counting and a backup cycle detecting garbage collector.
File objects close their file handle when the are deleted/finalized.
Thus the file will be eventually closed, and in cpython will closed as soon as the for loop finishes. |
1,478,697 | I frequently see python code similar to
```
for line in open(filename):
do_something(line)
```
When does filename get closed with this code?
Would it be better to write
```
with open(filename) as f:
for line in f.readlines():
do_something(line)
``` | 2009/09/25 | [
"https://Stackoverflow.com/questions/1478697",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173922/"
] | `filename` would be closed when it falls out of scope. That normally would be the end of the method.
Yes, it's better to use `with`.
>
> Once you have a file object, you perform all file I/O by calling methods of this object. [...] When you are done with the file, you should finish by calling the `close` method on t... | python is garbage-collected - cpython has reference counting and a backup cycle detecting garbage collector.
File objects close their file handle when the are deleted/finalized.
Thus the file will be eventually closed, and in cpython will closed as soon as the for loop finishes. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.