qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
45,880,127 | Let's say we have a fake data source which will return data it holds in batch
```
class DataSource(size: Int) {
private var s = 0
implicit val g = scala.concurrent.ExecutionContext.global
def getData(): Future[List[Int]] = {
s = s + 1
Future {
Thread.sleep(Random.nextInt(s * 100))
... | 2017/08/25 | [
"https://Stackoverflow.com/questions/45880127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6273735/"
] | The following is one way to achieve the same behavior with Akka Streams, using your `DataSource` class:
```
import scala.concurrent.Future
import scala.util.Random
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.scaladsl._
object StreamsExample extends App {
implicit val system = ActorSystem(... | I just figured out that by using flatMapConcat can achieve what I wanted to achieve. There is no point to start another question as I have had the answer already. Put my sample code here just in case someone is looking for similar answer.
This type of API is very common for some integration between traditional Enterpr... |
5,923,078 | I need to add my own data type to a list which is in a function, here's my code:
```
type Car = (String, String, Int, String)
testDatabase :: [Car]
testDatabase = [("Ford", "Petrol", 2006, "Sport")]
addNewCar :: Car
addNewCar newCar = newCar:testDatabase
```
Here's the error I get:
```
ERROR file:.\template.hs... | 2011/05/07 | [
"https://Stackoverflow.com/questions/5923078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/84546/"
] | The inferred type of `addNewCar` is `([Char],[Char],Int,[Char]) -> [([Char],[Char],Int,[Char])`, which is the same as `Car -> [Car]`. This type says that `addNewCar` is a function which takes a car and returns a list of cars. This is exactly the type you want.
However your type signature says that `addNewCar` is simpl... | You have a type error in your code. `addNewCar` is a function that takes a car and returns a list of cars, so it should have the type
```
addNewCar :: Car -> [Car]
```
You could also just remove the type signature, and the compiler will infer it automatically. |
68,561,708 | I'm trying to use Tesseract-OCR to get the readings on below images but having issues getting consistent results with the spotted background. I have below configuration on my pytesseract
`CONFIG = f"—psm 6 -c tessedit_char_whitelist=01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄabcdefghijklmnopqrstuvwxyzåäö.,-"`
I have also... | 2021/07/28 | [
"https://Stackoverflow.com/questions/68561708",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10833061/"
] | The problem is that `$newdir` contains `/` characters, so your `sed` command ends up looking like `s/'MyDir'//dir/to/my/file/g`, which won't work -- the first `/` effectively terminates your `sed` expression, and everything else is garbage.
Fortunately, `sed` let's you use *any* character as a delimiter to the `s` com... | One way to get around the "does my data contain the delimiter" problem is to use shell variable expansion to escape the delimiter character:
```sh
sed -i "s|'MyDir'|${newdir//|/\\|}|g" myconf.conf
```
Demo:
```sh
$ newdir="/a/dir/with|a/pipe"
$ sed "s|'MyDir'|${newdir}|g" <<< "this is 'MyDir' here"
sed: 1: "s|'MyD... |
66,197,785 | In Google Sheets, from one sheet I am trying to lookup the game info for the next game based on a game schedule that is maintained on a second sheet. The game dates and times in the schedule are maintained in separate columns as displayed below.
For example, since it's now 11:55am on 2/14, I'm looking for a function t... | 2021/02/14 | [
"https://Stackoverflow.com/questions/66197785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5008312/"
] | You can try
```
=ARRAYFORMULA(TRANSPOSE(
INDEX(Schedule!A3:C15, MATCH(NOW(),Schedule!A3:A15+Schedule!B3:B15,1)+1)
))
```
[](https://i.stack.imgur.com/cFfuT.png)
`MATCH` to assume that the range `A3:A16+B3:B16` is sorted in ascending order and ret... | B2:
```
=TODAY()
```
B3:
```
=INDEX(SPLIT(NOW(), " "),,2)
```
B4:
```
=INDEX(INDIRECT("Schedule!"&ADDRESS(MATCH(B2+B3, Schedule!A1:A+Schedule!B1:B, 1)+1, 3)))
```
[](https://i.stack.imgur.com/D4gxq.png) |
73,359,729 | I have a dataframe which contains post and comments.
Every comment has an id and a parent id (identifies the comment or post which the comment was a response to).
Posts only have an id, since they don't answer to anything.
| submission | id | parent id |
| --- | --- | --- |
| post1 | 1 | |
| comment1 | 2 | 1 |
| comm... | 2022/08/15 | [
"https://Stackoverflow.com/questions/73359729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18694315/"
] | You can use placehoders on prepare statements, this is why we use them to prevent sql injection
One other thing never use column names as variables names, databases can not differentiate
```
DROP procedure IF EXISTS `sp_insurance_contract_get`;
DELIMITER $$
CREATE PROCEDURE `sp_insurance_contract_get` (enquiryCode_ ... | When you say
```
WHERE enquiryCode = enquiryCode
```
you compare that named column to itself. The result is true always (unless the column value is NULL).
Change the names of your SP's parameters, so you can say something like
```
WHERE enquiryCode_param = enquiryCode
```
and things should work.
Notice that you... |
73,972,845 | ```
class Employee:
def __init__(self, name, salary, increment):
self.name = name
self.salary = salary
self.increment = increment
@property
def salaryafterIncre(self):
return self.salary * (1+self.increment)
@salaryafterIncre.setter
def salaryafterIncre(self):
... | 2022/10/06 | [
"https://Stackoverflow.com/questions/73972845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20174942/"
] | What about
```java
@Configuration
public class Config {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@Bean
public ModelMapper modelMapper(final CurrencyConverterService currencyConverter) {
ModelMapper modelMapper = new ModelMapper();
...
}
...
}
```
when you cr... | Solution 1: use javax.inject.Provider
-------------------------------------
Assuming you are using Maven you can add the following dependency:
```xml
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency... |
73,972,845 | ```
class Employee:
def __init__(self, name, salary, increment):
self.name = name
self.salary = salary
self.increment = increment
@property
def salaryafterIncre(self):
return self.salary * (1+self.increment)
@salaryafterIncre.setter
def salaryafterIncre(self):
... | 2022/10/06 | [
"https://Stackoverflow.com/questions/73972845",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20174942/"
] | What about
```java
@Configuration
public class Config {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@Bean
public ModelMapper modelMapper(final CurrencyConverterService currencyConverter) {
ModelMapper modelMapper = new ModelMapper();
...
}
...
}
```
when you cr... | You can write @Lazy at the top of the @Autowired in of the class where you are injecting dependencies.
As that will break the cycle.
However you have to write it on the top of @Autowired |
57,323,676 | I'm adding new UIWindow to show passcode view controller when the app is entering foreground.
Before iOS 13 in AppDelegate I had property `var passcodeWindow = UIWindow(frame: UIScreen.main.bounds)` where my `rootViewController` was the passcode view controller and in `applicationWillEnterForeground` method I was doi... | 2019/08/02 | [
"https://Stackoverflow.com/questions/57323676",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7661368/"
] | You can try this:
```
if #available(iOS 13.0, *) {
if let currentWindowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
passcodeWindow.windowScene = currentWindowScene
}
}
``` | You need a strong reference for your UIWindow instance, and the most important thing is that you need to set "isHidden" property false.
```
newWindow = UIWindow.init(frame: CGRect.init(x: 0, y: 0, width: 100, height: 100))
newWindow?.backgroundColor = UIColor.systemBlue
newWindow?.windowScene = (scene as? UIWindowScen... |
19,612,822 | I know that there are different ways to do this, but I just want to know why my regex isn't working. This isn't actually something that I need to do, I just wanted to see if I could do this with a regex, and I have no idea why my code isn't working.
Given a string S, I want to find all non-overlapping substrings that ... | 2013/10/26 | [
"https://Stackoverflow.com/questions/19612822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2073001/"
] | Assuming what you actually want is for the subsequence Q to contain no `a`s between the first `a` and the first `b` and no `a`s or `b`s between the first `b` and the first `c` after the first `b`, the correct regex to use is:
```
r'a[^ab]*b[^abc]*c'
```
The regex that you're currently using will do everything that i... | It could help if you look at the inverse class.
In all cases `abc` is the trivial solution.
And, in this case non-greedy probably doesn't apply because
there are fixed sets of characters used in the example inverse classes.
```
# Type 1 :
# ( b or c can be between A,B )
# ( a or b can be between B,C )
... |
44,144 | I wonder what the following violin technique is called it happens in the following video at ar 4;50. It seems that it is some sort of slapping motion with the bow and also something that resembles pull offs. | 2016/05/04 | [
"https://music.stackexchange.com/questions/44144",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/7306/"
] | Looks to me like the player is interspersing conventionally bowed notes with left-hand pizzicato notes. This is similar to the pull-off (*ligado*) technique on guitar, but has a quite different sound.
I only watched the clip once, but it appears that the passages that combine bowed and L.H. pizzicato are executed as f... | It's a combination of spiccato bowing (bouncing the bow off the strings) alternating with left-hand pizzicato.
Of course the *real* Paganini did this sort of party trick having slashed three of the violin strings with a knife, and then holding the violin upside down, if some of the stories about him are to be believe... |
44,144 | I wonder what the following violin technique is called it happens in the following video at ar 4;50. It seems that it is some sort of slapping motion with the bow and also something that resembles pull offs. | 2016/05/04 | [
"https://music.stackexchange.com/questions/44144",
"https://music.stackexchange.com",
"https://music.stackexchange.com/users/7306/"
] | Looks to me like the player is interspersing conventionally bowed notes with left-hand pizzicato notes. This is similar to the pull-off (*ligado*) technique on guitar, but has a quite different sound.
I only watched the clip once, but it appears that the passages that combine bowed and L.H. pizzicato are executed as f... | While I didn't notice the col legno battuto anywhere the rest of the above information is correct. Also noteworthy is the incorporation of ricochet bowing in the phrasing of the beginning of this piece. The spiccato that appears in other parts of the piece you will notice uses the middle and lower half of the bow. The ... |
125,050 | I like to add users to an [OG group](https://www.drupal.org/project/og) using [vbo](https://www.drupal.org/project/views_bulk_operations), a custom action and [og\_group()](http://drupalcontrib.org/api/drupal/contributions!og!og.module/function/og_group/7).
I build up a page with a [view](https://www.drupal.org/projec... | 2014/07/29 | [
"https://drupal.stackexchange.com/questions/125050",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/23004/"
] | I would use a db\_query to find all nodes that that field appears on and then update them with a node\_load here is the code:
```
$result = db_query('SELECT f.entity_id FROM {field_data_field_thefield} f');
foreach ($result as $record) {
$node = node_load($record->entity_id);
// update node
}
``` | You can either do it programmatically or using views.
Using Views : Create a view page and under the fields section add the following fields:
Node id and the specific field you would like to update.
Update the filter condition as follows:
Node type = 'YOUR NODE TYPE'
AND
"Your required field" = NOT NULL
The output... |
125,050 | I like to add users to an [OG group](https://www.drupal.org/project/og) using [vbo](https://www.drupal.org/project/views_bulk_operations), a custom action and [og\_group()](http://drupalcontrib.org/api/drupal/contributions!og!og.module/function/og_group/7).
I build up a page with a [view](https://www.drupal.org/projec... | 2014/07/29 | [
"https://drupal.stackexchange.com/questions/125050",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/23004/"
] | I would use a db\_query to find all nodes that that field appears on and then update them with a node\_load here is the code:
```
$result = db_query('SELECT f.entity_id FROM {field_data_field_thefield} f');
foreach ($result as $record) {
$node = node_load($record->entity_id);
// update node
}
``` | ```
$nid = 1;
$thefield = db_select('field_data_field_thefield', 'f');
->fields('f',array('entity_id'))
->condition('f.entity_id', $nid, '=');
->execute()
->fetchField();
if($thefield){
Do Something...
}
```
You could use a db\_query instead of db\_select to make it even quicker |
125,050 | I like to add users to an [OG group](https://www.drupal.org/project/og) using [vbo](https://www.drupal.org/project/views_bulk_operations), a custom action and [og\_group()](http://drupalcontrib.org/api/drupal/contributions!og!og.module/function/og_group/7).
I build up a page with a [view](https://www.drupal.org/projec... | 2014/07/29 | [
"https://drupal.stackexchange.com/questions/125050",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/23004/"
] | I would use a db\_query to find all nodes that that field appears on and then update them with a node\_load here is the code:
```
$result = db_query('SELECT f.entity_id FROM {field_data_field_thefield} f');
foreach ($result as $record) {
$node = node_load($record->entity_id);
// update node
}
``` | If you want to update any field in node , then better to use `node_load()` function.
Because if you use any custom **select** or **update** query then
* first thing you need to update it in all the tables (main and revision tables).
* Second thing, drupal events will not trigger that is attached with updation.
If y... |
125,050 | I like to add users to an [OG group](https://www.drupal.org/project/og) using [vbo](https://www.drupal.org/project/views_bulk_operations), a custom action and [og\_group()](http://drupalcontrib.org/api/drupal/contributions!og!og.module/function/og_group/7).
I build up a page with a [view](https://www.drupal.org/projec... | 2014/07/29 | [
"https://drupal.stackexchange.com/questions/125050",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/23004/"
] | I would use a db\_query to find all nodes that that field appears on and then update them with a node\_load here is the code:
```
$result = db_query('SELECT f.entity_id FROM {field_data_field_thefield} f');
foreach ($result as $record) {
$node = node_load($record->entity_id);
// update node
}
``` | The field API allows you to load/attach just one field in a list of entities with [`field_attach_load()`](https://api.drupal.org/api/drupal/modules!field!field.attach.inc/function/field_attach_load/7). This approach is field storage agnostic, invokes field-level hooks, and reads from the field cache if possible. |
70,682,557 | I'm trying to display a static image located in the same folder as my Html file but it seems I can't get the right path for it to display correctly. The application I'm developing is an atlassian plugin that also includes a java backend to get Data from the Database and I'm displaying it on the frontend using HTML and ... | 2022/01/12 | [
"https://Stackoverflow.com/questions/70682557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12995281/"
] | ```
s=df.mask((df-df.apply(lambda x: x.std() )).gt(5))#mask where condition applies
s=s.assign(A=s.A.fillna(s.A.max()),B=s.B.fillna(s.B.max())).sort_index(axis = 0)#fill with max per column and resort frame
A B
0 1.0 2.0
1 1.0 6.0
2 2.0 8.0
3 1.0 8.0
4 2.0 1.0
``` | Calculate a column-wise z-score (if you deem something an outlier if it lies outside a given number of standard deviations of the column) and then calculate a boolean mask of values outside your desired range
```
def calc_zscore(col):
return (col - col.mean()) / col.std()
zscores = df.apply(calc_zscore, axis=0)
ou... |
70,682,557 | I'm trying to display a static image located in the same folder as my Html file but it seems I can't get the right path for it to display correctly. The application I'm developing is an atlassian plugin that also includes a java backend to get Data from the Database and I'm displaying it on the frontend using HTML and ... | 2022/01/12 | [
"https://Stackoverflow.com/questions/70682557",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12995281/"
] | ```
s=df.mask((df-df.apply(lambda x: x.std() )).gt(5))#mask where condition applies
s=s.assign(A=s.A.fillna(s.A.max()),B=s.B.fillna(s.B.max())).sort_index(axis = 0)#fill with max per column and resort frame
A B
0 1.0 2.0
1 1.0 6.0
2 2.0 8.0
3 1.0 8.0
4 2.0 1.0
``` | Per the discussion in the comments you need to decide what your threshold is. say it is q=100, then you can do
```
q = 100
df.loc[df['A'] > q,'A'] = max(df.loc[df['A'] < q,'A'] )
df
```
this fixes column A:
```
A B
0 1 2
1 1 6
2 2 8
3 1 115
4 2 1
```
do the same for B |
53,455 | I'm running Raspbian Jessie on my Raspberry Pi 3 and I'm doing a little house alarm project. When the alarm is activated the Pi should transmit FM signal of an alarm sound on a frequency that a few radios in the house will be tuned at. The program I use for transmiting FM is [here](http://www.icrobotics.co.uk/wiki/inde... | 2016/08/13 | [
"https://raspberrypi.stackexchange.com/questions/53455",
"https://raspberrypi.stackexchange.com",
"https://raspberrypi.stackexchange.com/users/51879/"
] | PWM should not conflict with I2C.
Everything below presumes the (predominant) Broadcom pin numbering scheme, which does not correlate to the physical arrangement of the pins.
I've never used GPIO 4 for PWM; the normal PWM pins used are 12, 13, 18, and 19, making use of two separate PWM channels derived from one clock... | You can also create aditional i2c busses on the raspberry pi to solve i2c conflicts
<https://www.instructables.com/id/Raspberry-PI-Multiple-I2c-Devices/> |
19,717,124 | I have this enumeration:
```
Enum Lame_Bitrate
kbps_8 = 8
kbps_16 = 16
kbps_24 = 24
kbps_32 = 32
kbps_40 = 40
kbps_48 = 48
kbps_56 = 56
kbps_64 = 64
kbps_80 = 80
kbps_96 = 96
kbps_112 = 112
kbps_128 = 128
kbps_144 = 144
kbps_160 = 160
kbps_192 = 192
kbps_... | 2013/10/31 | [
"https://Stackoverflow.com/questions/19717124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1248295/"
] | If you want to find the nearest enum:
```
Dim number = 190
Dim allBitrates() As Lame_Bitrate = DirectCast([Enum].GetValues(GetType(Lame_Bitrate)), Lame_Bitrate())
Dim nearestBitrate = allBitrates.OrderBy(Function(br) Math.Abs(number - br)).First()
```
If you want to find all nearest enums (in case of multiple with t... | I've adapted @Tim Schmelter solution and I've did 3 generic functions.
Just I want to share this.
· Get Nearest Enum Value:
```
' Enum Bitrate As Short : kbps_128 = 128 : kbps_192 = 192 : kbps_256 = 256 : kbps_320 = 320 : End Enum
' MsgBox(Get_Nearest_Enum_Value(Of Bitrate)(133).ToString) ' Result: kbps_128
' MsgBox... |
4,094,297 | How can I find the limit of series $\sum\_{k=1}^{n-1} \frac{1}{nk}$?
I need to show that this series converges to $0$ as $n\to \infty$ in order to prove that the Cauchy Product of two non-absolutely convergent series can converge. I multiplied $\sum a\_k=\sum \frac{(-1)^k}{k}$, where $a\_0=0,$ by itself. And I got $b\... | 2021/04/08 | [
"https://math.stackexchange.com/questions/4094297",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/746652/"
] | Let $S\_n=\sum\_{k=1}^{n-1}\frac1k$. By [Stolz's formula](https://en.wikipedia.org/wiki/Stolz%E2%80%93Ces%C3%A0ro_theorem)($\cdot/\infty$ case),
$$\lim\_{n\to\infty}\frac{S\_n}n=\lim\_{n\to\infty}\frac{S\_{n+1}-S\_{n}}{(n+1)-n}=\lim\_{n\to\infty}\frac1n=0.$$ | **Hint**
$$\sum\_{k=1}^{n-1} \frac{1}{nk}=\frac{1}{n}\sum\_{k=1}^{n-1} \frac{1}{k}=\frac{H\_{n-1}}{n}$$
Now, use the asymptotics
$$H\_p=\gamma+\log(p)+\frac 1{2p}+O\left(\frac{1}{p^2}\right)$$ and continue with Taylor series. |
1,596,611 | I am working on preparing for JEE and was working on this math problem.
We have the sum, $$\sum\_{n=1}^{120}n!=1!+2!+3!+\ldots+120!$$
Now I am given the question, which says that what happens when this sum is divided by $120$. Does it divide evenly? If not, then what is its remainder? | 2016/01/02 | [
"https://math.stackexchange.com/questions/1596611",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/302159/"
] | Note that $5!=120$, and all terms after $n=5$ are also divisible by $120$. Therefore, we can conclude that $120$ does not divide evenly and our remainder is the sum of the terms before $n=5$: $$\sum\_{n=1}^4{n!}=1!+2!+3!+4!=33$$ | Since every term after the first one is even, the whole sum is odd. But $120$ is even, hence it does not divide the sum. |
22,975,258 | ```
mysql> USE bitcoin;
Database changed
mysql> CREATE TABLE btc ( uuid VARCHAR(36) NOT NULL, ign VARCHAR(20) NOT NULL, btc DOUBLE(30) NOT NULL, ) ENGINE=InnoDB;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') N... | 2014/04/09 | [
"https://Stackoverflow.com/questions/22975258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3123121/"
] | The issue was with the hash formatting. I changed it:
```
sign_in_and_redirect(:user, authentication.user.user_id)
```
and that solved it. | Change
```
sign_in_and_redirect(:user, authentication.user)
```
To
```
sign_in_and_redirect(authentication.user)
``` |
30,782,662 | This is allowed by the Java compiler, what is it doing?
```
int x = x = 1;
```
I realize that x is assigned to x, but how can it have two `=`s? | 2015/06/11 | [
"https://Stackoverflow.com/questions/30782662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3171100/"
] | x = 1 both assigns the value 1 to x and also 'returns' 1, it allows for things like this:
```
while ((line = reader.readLine()) != null)
``` | `int x` puts `x` on the stack.
The right hand part `x = 1` assigns 1 to `x`. But this is an *expression* with value 1.
Finally this is re-assigned to `x`. |
30,782,662 | This is allowed by the Java compiler, what is it doing?
```
int x = x = 1;
```
I realize that x is assigned to x, but how can it have two `=`s? | 2015/06/11 | [
"https://Stackoverflow.com/questions/30782662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3171100/"
] | x = 1 both assigns the value 1 to x and also 'returns' 1, it allows for things like this:
```
while ((line = reader.readLine()) != null)
``` | Read assignment statement from right to left:
Acording to [Assignment Operators](https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.26)
>
> There are 12 assignment operators; all are syntactically
> right-associative (they group right-to-left). Thus, a=b=c means
> a=(b=c), which assigns the value... |
30,782,662 | This is allowed by the Java compiler, what is it doing?
```
int x = x = 1;
```
I realize that x is assigned to x, but how can it have two `=`s? | 2015/06/11 | [
"https://Stackoverflow.com/questions/30782662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3171100/"
] | Read assignment statement from right to left:
Acording to [Assignment Operators](https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.26)
>
> There are 12 assignment operators; all are syntactically
> right-associative (they group right-to-left). Thus, a=b=c means
> a=(b=c), which assigns the value... | `int x` puts `x` on the stack.
The right hand part `x = 1` assigns 1 to `x`. But this is an *expression* with value 1.
Finally this is re-assigned to `x`. |
18,533,563 | I have created the wordpress folder inside the root. Now I wanna to set it main domain.
for example. my site url is <http://www.example.com>
wordpress url is <http://www.example.com/wordpress>
Now I wanna set wordpress as site url , it open with the main url
when I enter the <http://www.example.com> then it show me ... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18533563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1734190/"
] | As you didn't post the Java code you wrote, so I can't point out what went wrong exactly.
However, I don't think same id matters anyway. (But that's really bad, you should change it though)
Remember, `switchTo().frame()` has three overloads, you shouldn't be using index or name/id, but pass in the frame element itsel... | The problem is not that the elements have the same name, but rather that they are identical (even their parents have the same ID).
I would definitely bring this up with the developers of the site (the fact that two elements have the same ID...which is a big no-no on websites).
Regardless, you can do `driver.findEleme... |
18,533,563 | I have created the wordpress folder inside the root. Now I wanna to set it main domain.
for example. my site url is <http://www.example.com>
wordpress url is <http://www.example.com/wordpress>
Now I wanna set wordpress as site url , it open with the main url
when I enter the <http://www.example.com> then it show me ... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18533563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1734190/"
] | The problem is not that the elements have the same name, but rather that they are identical (even their parents have the same ID).
I would definitely bring this up with the developers of the site (the fact that two elements have the same ID...which is a big no-no on websites).
Regardless, you can do `driver.findEleme... | In this kind of case Xpath is a bast way to find an element. You can differentiate both element by their Xpath. |
18,533,563 | I have created the wordpress folder inside the root. Now I wanna to set it main domain.
for example. my site url is <http://www.example.com>
wordpress url is <http://www.example.com/wordpress>
Now I wanna set wordpress as site url , it open with the main url
when I enter the <http://www.example.com> then it show me ... | 2013/08/30 | [
"https://Stackoverflow.com/questions/18533563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1734190/"
] | As you didn't post the Java code you wrote, so I can't point out what went wrong exactly.
However, I don't think same id matters anyway. (But that's really bad, you should change it though)
Remember, `switchTo().frame()` has three overloads, you shouldn't be using index or name/id, but pass in the frame element itsel... | In this kind of case Xpath is a bast way to find an element. You can differentiate both element by their Xpath. |
7,853,736 | Leaks is telling me that the following is a memory leak, but I'm not sure why.
TitledArray.h
```
@interface TitledArray : NSObject {
NSMutableArray *realArray;
BOOL uniqueTitles;
BOOL uniqueIDs;
}
@property (nonatomic) BOOL uniqueTitles;
@property (nonatomic) BOOL uniqueIDs;
@property (nonatomic, retain) NSMutable... | 2011/10/21 | [
"https://Stackoverflow.com/questions/7853736",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1001482/"
] | When assigning to a property that has `retain` in the `@property` declaration, the synthesized setter retains the value already, so autorelease the thing that you are assigning to the property, like so:
```
-(id)init {
if ( self = [super init]) {
self.storageWeights = [[[TitledArray alloc] initWithUniqueTi... | Looks like you had a //self.realArray = [[NSMutableArray alloc] init]; in the init. Do a clean build and then run the tools again. That old code might have been in there for some reason and would certainly be flagged as a leak.
One other thing, put `self.realArray = nil` in the `dealloc` of TitledArray. |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | I would suggest implementing a custom HandleErrorAttribute action filter.
See this link for more details:
<http://msdn.microsoft.com/en-us/library/dd410203%28v=vs.90%29.aspx>
Setting up a HandleErrorAttribute action filter gives you complete control over which actions are handled by the filter, and it's easy to se... | The easiest way I think you can do that is using the elmah library.
Take a look at this: <http://code.google.com/p/elmah/wiki/MVC> and this
<http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx> |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | I would suggest implementing a custom HandleErrorAttribute action filter.
See this link for more details:
<http://msdn.microsoft.com/en-us/library/dd410203%28v=vs.90%29.aspx>
Setting up a HandleErrorAttribute action filter gives you complete control over which actions are handled by the filter, and it's easy to se... | I think the easiest way is using ExceptionHandler attribute since it's ready to use anytime you create a new ASP.NET MVC 3 project. You can still configure Web.config to use a custom error page and handling exceptions in global Application\_Error method as usual but when an exception occurs the URL is not displayed as ... |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | **For Global Error Handling**
All you have to do is change the customErrors mode="On" in web.config page
Error will be displayed through Error.cshtml resides in shared folder.
*Make sure that Error.cshtml Layout is not null*.
[It sould be something like: @{ Layout = "~/Views/Shared/\_Layout.cshtml"; } ... | I would suggest implementing a custom HandleErrorAttribute action filter.
See this link for more details:
<http://msdn.microsoft.com/en-us/library/dd410203%28v=vs.90%29.aspx>
Setting up a HandleErrorAttribute action filter gives you complete control over which actions are handled by the filter, and it's easy to se... |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | I would suggest implementing a custom HandleErrorAttribute action filter.
See this link for more details:
<http://msdn.microsoft.com/en-us/library/dd410203%28v=vs.90%29.aspx>
Setting up a HandleErrorAttribute action filter gives you complete control over which actions are handled by the filter, and it's easy to se... | you can create custom exception in MVC if you want to customize a way of exception handling.
you can find useful post here .
<http://www.professionals-helpdesk.com/2012/07/creating-custom-exception-filter-in-mvc.html> |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | **For Global Error Handling**
All you have to do is change the customErrors mode="On" in web.config page
Error will be displayed through Error.cshtml resides in shared folder.
*Make sure that Error.cshtml Layout is not null*.
[It sould be something like: @{ Layout = "~/Views/Shared/\_Layout.cshtml"; } ... | The easiest way I think you can do that is using the elmah library.
Take a look at this: <http://code.google.com/p/elmah/wiki/MVC> and this
<http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx> |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | The easiest way I think you can do that is using the elmah library.
Take a look at this: <http://code.google.com/p/elmah/wiki/MVC> and this
<http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx> | you can create custom exception in MVC if you want to customize a way of exception handling.
you can find useful post here .
<http://www.professionals-helpdesk.com/2012/07/creating-custom-exception-filter-in-mvc.html> |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | **For Global Error Handling**
All you have to do is change the customErrors mode="On" in web.config page
Error will be displayed through Error.cshtml resides in shared folder.
*Make sure that Error.cshtml Layout is not null*.
[It sould be something like: @{ Layout = "~/Views/Shared/\_Layout.cshtml"; } ... | I think the easiest way is using ExceptionHandler attribute since it's ready to use anytime you create a new ASP.NET MVC 3 project. You can still configure Web.config to use a custom error page and handling exceptions in global Application\_Error method as usual but when an exception occurs the URL is not displayed as ... |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | I think the easiest way is using ExceptionHandler attribute since it's ready to use anytime you create a new ASP.NET MVC 3 project. You can still configure Web.config to use a custom error page and handling exceptions in global Application\_Error method as usual but when an exception occurs the URL is not displayed as ... | you can create custom exception in MVC if you want to customize a way of exception handling.
you can find useful post here .
<http://www.professionals-helpdesk.com/2012/07/creating-custom-exception-filter-in-mvc.html> |
5,995,781 | I'm new in mysql and I'm currently having an issue with a query. I need to get an average duration for each activity each day within a week. The date format is like: '2000-01-01 01:01:01', but I want to get rid of the 01:01:01 thing and only care about the date. How do I do that?
The table is something like this:
```... | 2011/05/13 | [
"https://Stackoverflow.com/questions/5995781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/636625/"
] | **For Global Error Handling**
All you have to do is change the customErrors mode="On" in web.config page
Error will be displayed through Error.cshtml resides in shared folder.
*Make sure that Error.cshtml Layout is not null*.
[It sould be something like: @{ Layout = "~/Views/Shared/\_Layout.cshtml"; } ... | you can create custom exception in MVC if you want to customize a way of exception handling.
you can find useful post here .
<http://www.professionals-helpdesk.com/2012/07/creating-custom-exception-filter-in-mvc.html> |
36,242 | [Yebamoth 61b](http://halakhah.com/yebamoth/yebamoth_61.html#PARTb) discusses the positive commandment of being fruitful and multiplying. As far as I am aware, one makes no blessing before intercourse. Why not?
Please cite sources! | 2014/03/12 | [
"https://judaism.stackexchange.com/questions/36242",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/4682/"
] | UPDATE FOUND THIS:
>
> The גליוני הש"ס to Berachos 35a discusses that there should be a
> blessing on marital relations, and concludes that Birkas Ha'erusin
> accomplishes that. It would seem he held this concept can extend to
> other pleasures, although this could still be in the realm of "a need
> of the body.
... | The Shulchan Aruch ([EH 63:2](http://beta.hebrewbooks.org/tursa.aspx?a=eh_x7690)) actually does quote a beracha from the Bahag, to be made after the first bi'ah with a Betula. The Aruch HaShulchan says that we are not noheg to say this beracha anymore.
However, that beracha is not a beracha on the mitzva, but it appea... |
36,242 | [Yebamoth 61b](http://halakhah.com/yebamoth/yebamoth_61.html#PARTb) discusses the positive commandment of being fruitful and multiplying. As far as I am aware, one makes no blessing before intercourse. Why not?
Please cite sources! | 2014/03/12 | [
"https://judaism.stackexchange.com/questions/36242",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/4682/"
] | The Maggid Ta'alumos to the Rif on Maseches Berachos, daf 35a (25a in pages of the Rif) says that we do not make the blessing because she may not get pregnant and then the mitzvah was not fulfilled. He also addresses that Onah is a negative commandment and therefore has no blessing.
However, he does indicate that the ... | UPDATE FOUND THIS:
>
> The גליוני הש"ס to Berachos 35a discusses that there should be a
> blessing on marital relations, and concludes that Birkas Ha'erusin
> accomplishes that. It would seem he held this concept can extend to
> other pleasures, although this could still be in the realm of "a need
> of the body.
... |
36,242 | [Yebamoth 61b](http://halakhah.com/yebamoth/yebamoth_61.html#PARTb) discusses the positive commandment of being fruitful and multiplying. As far as I am aware, one makes no blessing before intercourse. Why not?
Please cite sources! | 2014/03/12 | [
"https://judaism.stackexchange.com/questions/36242",
"https://judaism.stackexchange.com",
"https://judaism.stackexchange.com/users/4682/"
] | The Maggid Ta'alumos to the Rif on Maseches Berachos, daf 35a (25a in pages of the Rif) says that we do not make the blessing because she may not get pregnant and then the mitzvah was not fulfilled. He also addresses that Onah is a negative commandment and therefore has no blessing.
However, he does indicate that the ... | The Shulchan Aruch ([EH 63:2](http://beta.hebrewbooks.org/tursa.aspx?a=eh_x7690)) actually does quote a beracha from the Bahag, to be made after the first bi'ah with a Betula. The Aruch HaShulchan says that we are not noheg to say this beracha anymore.
However, that beracha is not a beracha on the mitzva, but it appea... |
4,312,729 | Having a bit of trouble trying to get an xsd to match two documents:
XML Document 1:
```
<?xml version="1.0" encoding="UTF-8"?>
<video contenttype="asf" fileextension=".wmv" hascontent="no" lang="en-GB" length="1800" pid="3678738364972" sid="">
<lastmodified timestamp="1282678200000">
Tue, 24 Aug 2010 19:... | 2010/11/30 | [
"https://Stackoverflow.com/questions/4312729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/223863/"
] | I believe you do need to match namespace. I once faced a similar issue, where the XML document was out of my control (Adobe Smart Forms), and I wanted to validate it against my XSD.
To do this I **cleaned** the XML document before I validated, adjusting the namespace, and in my case removing alot of garbage that Adob... | As far as I'm aware, you don't need a namespace. I've never used one in any of my XSD schemas.
Here's Microsoft's documentation on the feature:
<http://msdn.microsoft.com/en-us/library/aa258639%28SQL.80%29.aspx> |
109,381 | I have a content type that has a mix of user-editable fields and auto-populated fields (from an external source). I would like to mark those fields as disabled right when I create them so the user cannot overwrite them. I know there are readonly modules and ways to do this in hook\_form\_alter but I'm curious if I can ... | 2014/04/07 | [
"https://drupal.stackexchange.com/questions/109381",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/25639/"
] | The simple bulk action support in Drupal 8 core does not currently support this feature. | The issue about [Port Views Bulk Operations to Drupal 8](https://www.drupal.org/project/views_bulk_operations/issues/1823572) is closed (completed) now.
If somebody has problem with it, try to use /admin/yourpath in views, then you use admin theme and select/deselect all button should work. |
109,381 | I have a content type that has a mix of user-editable fields and auto-populated fields (from an external source). I would like to mark those fields as disabled right when I create them so the user cannot overwrite them. I know there are readonly modules and ways to do this in hook\_form\_alter but I'm curious if I can ... | 2014/04/07 | [
"https://drupal.stackexchange.com/questions/109381",
"https://drupal.stackexchange.com",
"https://drupal.stackexchange.com/users/25639/"
] | The simple bulk action support in Drupal 8 core does not currently support this feature. | If you need "select all" you can use the module [VBO](https://www.drupal.org/project/views_bulk_operations).
Then you can replace the field "Node: Views bulk operation" with the "Global: Views bulk operations" which supports selecting all rows. |
74,553,190 | Im trying to make a complex queryset and I want to include my `ForeignKeys` names instead of pk. I'm using ajax to get a live feed from user inputs and print the results on a `DataTable` but I want to print the names instead of the pk. Im getting a queryset and when I `console.log` it, `sensor_name` is not in there.
My... | 2022/11/23 | [
"https://Stackoverflow.com/questions/74553190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Use parameter expansion to strip prefix and suffix.
```
for f in /root/Desktop/match/jars/44a65820/*; do
link="${f%-44a65820.jar}.jar";
ln -s "$f" "/root/Desktop/match/jars/${link##*/}";
done
``` | Given the simplified tree for testing
```bash
shell> tree /tmp/match
/tmp/match
└── jars
└── 44a65820
├── one.jar
├── three.jar
└── two.jar
```
In Ansible, declare the variable
```yaml
match_files: "{{ st.files|map(attribute='path')|list }}"
```
and [find](https://docs.ansible.com/ansi... |
42,304,119 | I'm building a robot for a school project. I am currently using an Arduino Uno, two DC motors and an ultrasonic sensor. The two motors are being controlled via the [Arduino Motor Shield v3](https://store.arduino.cc/usa/arduino-motor-shield-rev3). I want the robot to be autonomous so it has to be able to move around on ... | 2017/02/17 | [
"https://Stackoverflow.com/questions/42304119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7564671/"
] | There are a few different ways to do this.
```
library(data.table)
dt = data.table("Group" = c(rep("A",4),rep("B",4)), "value" = rep(1:4, each = 2))
knitr::kable(dt)
> dt
Group value
1: A 1
2: A 1
3: A 2
4: A 2
5: B 3
6: B 3
7: B 4
8: B 4
```
We c... | You can use `duplicated` function with negation (`!`) to retain values of "group" only at transitions but be careful that is does
not result in loss of information from other columns (if they are important). In the demo datset we retain only transitions of `cyl` variable.
```
mtcarsSubset = mtcars[,1:5]
knitr::kabl... |
42,304,119 | I'm building a robot for a school project. I am currently using an Arduino Uno, two DC motors and an ultrasonic sensor. The two motors are being controlled via the [Arduino Motor Shield v3](https://store.arduino.cc/usa/arduino-motor-shield-rev3). I want the robot to be autonomous so it has to be able to move around on ... | 2017/02/17 | [
"https://Stackoverflow.com/questions/42304119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7564671/"
] | Finally, I changed the data-frame that then is converted into a table.
`ReplicationTable %>% mutate(dependent_variable = ifelse(duplicated(dependent_variable), "", dependent_variable)`
This replaces all entries with an empty string after the first unique entry in `dependent_variable`. This also works in grouped data-f... | You can use `duplicated` function with negation (`!`) to retain values of "group" only at transitions but be careful that is does
not result in loss of information from other columns (if they are important). In the demo datset we retain only transitions of `cyl` variable.
```
mtcarsSubset = mtcars[,1:5]
knitr::kabl... |
42,304,119 | I'm building a robot for a school project. I am currently using an Arduino Uno, two DC motors and an ultrasonic sensor. The two motors are being controlled via the [Arduino Motor Shield v3](https://store.arduino.cc/usa/arduino-motor-shield-rev3). I want the robot to be autonomous so it has to be able to move around on ... | 2017/02/17 | [
"https://Stackoverflow.com/questions/42304119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7564671/"
] | There are a few different ways to do this.
```
library(data.table)
dt = data.table("Group" = c(rep("A",4),rep("B",4)), "value" = rep(1:4, each = 2))
knitr::kable(dt)
> dt
Group value
1: A 1
2: A 1
3: A 2
4: A 2
5: B 3
6: B 3
7: B 4
8: B 4
```
We c... | Finally, I changed the data-frame that then is converted into a table.
`ReplicationTable %>% mutate(dependent_variable = ifelse(duplicated(dependent_variable), "", dependent_variable)`
This replaces all entries with an empty string after the first unique entry in `dependent_variable`. This also works in grouped data-f... |
162,767 | When generating a matrix barcode, it takes 1 minute per 10000 files .That's how to generating a matrix barcode for big quantities in less time.
[Here](http://www.mediafire.com/file/ciadoloynverba7/library_used_for_datamatrix.txt) is the library used to encoder data.
My code for button generating:
```
Class1 CLS = ne... | 2017/05/07 | [
"https://codereview.stackexchange.com/questions/162767",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/138262/"
] | 1. Strings are immutable so whenever you're concatenating them you're effectively creating new instances every time, this can slow down performance a lot, instead use `StringBuilder` and it's method `Append()` to build strings.
2. Avoid duplicate operations per each cycle unless it's necessary, such as `Convert.ToInt32... | I totally agree with Denis' answer, here. On top of that, I'd add:
1. It's just 6 milliseconds for each barcode, including save to disk: it's not that slow at the end of day, and you have a custom library doing most of the job, so that means that you really have to squeeze every single possible fraction of millisecond... |
162,767 | When generating a matrix barcode, it takes 1 minute per 10000 files .That's how to generating a matrix barcode for big quantities in less time.
[Here](http://www.mediafire.com/file/ciadoloynverba7/library_used_for_datamatrix.txt) is the library used to encoder data.
My code for button generating:
```
Class1 CLS = ne... | 2017/05/07 | [
"https://codereview.stackexchange.com/questions/162767",
"https://codereview.stackexchange.com",
"https://codereview.stackexchange.com/users/138262/"
] | 1. Strings are immutable so whenever you're concatenating them you're effectively creating new instances every time, this can slow down performance a lot, instead use `StringBuilder` and it's method `Append()` to build strings.
2. Avoid duplicate operations per each cycle unless it's necessary, such as `Convert.ToInt32... | I don't see you using the `i` variable inside your loop? If it's just for counting you could perhaps rewrite the loop to:
```
var counter = Convert.ToInt32(textBox1.Text);
while(counter-- >= 0)
{
//Code goes here...
}
```
I also see you always use the row at index `0`, is this intended or is that where you mean... |
10,772,530 | I am curious about this. I must learn Prolog for my course, but the applications that I seen mostly are written using C++, C# or Java. Applications written by Prolog, to me is very very rare application.
So, I wonder how Prolog is used and implement the real-world application? | 2012/05/27 | [
"https://Stackoverflow.com/questions/10772530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326261/"
] | I once asked my supervisor a similar question, when he is giving us a Prological lecture.
And he told me that people do not really use prolog to implement a whole huge system. Instead, people write the main part with other language(which is more sane and trivial), and link it to a "decision procedure" or something wri... | According to the Tiobe Software Index, Prolog is currently #36: between Haskell and FoxPro:
<http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html>
What's it used for?
I first heard of it with respect to Japan's (now defunct) "Fifth Generation" project:
<http://en.wikipedia.org/wiki/Fifth_generation_comp... |
10,772,530 | I am curious about this. I must learn Prolog for my course, but the applications that I seen mostly are written using C++, C# or Java. Applications written by Prolog, to me is very very rare application.
So, I wonder how Prolog is used and implement the real-world application? | 2012/05/27 | [
"https://Stackoverflow.com/questions/10772530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326261/"
] | * **Microsoft Windows NT Networking Installation and Configuration applet**
One of the notorious and in a way notable examples is Microsoft Windows NT OS network interface configuration code that involved a Small Prolog interpreter built in. Here is a [link](http://www.drdobbs.com/cpp/184409294) to the story written b... | According to the Tiobe Software Index, Prolog is currently #36: between Haskell and FoxPro:
<http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html>
What's it used for?
I first heard of it with respect to Japan's (now defunct) "Fifth Generation" project:
<http://en.wikipedia.org/wiki/Fifth_generation_comp... |
10,772,530 | I am curious about this. I must learn Prolog for my course, but the applications that I seen mostly are written using C++, C# or Java. Applications written by Prolog, to me is very very rare application.
So, I wonder how Prolog is used and implement the real-world application? | 2012/05/27 | [
"https://Stackoverflow.com/questions/10772530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326261/"
] | SWI-Prolog website is served from... SWI-prolog, using just a small subset of the libraries available.
Well, it's not a commercial application, but it's rather [real world](http://www.swi-prolog.org/).
Much effort was required to make the runtime able to perform 24x7 service (mainly garbage collection) and required p... | According to the Tiobe Software Index, Prolog is currently #36: between Haskell and FoxPro:
<http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html>
What's it used for?
I first heard of it with respect to Japan's (now defunct) "Fifth Generation" project:
<http://en.wikipedia.org/wiki/Fifth_generation_comp... |
10,772,530 | I am curious about this. I must learn Prolog for my course, but the applications that I seen mostly are written using C++, C# or Java. Applications written by Prolog, to me is very very rare application.
So, I wonder how Prolog is used and implement the real-world application? | 2012/05/27 | [
"https://Stackoverflow.com/questions/10772530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326261/"
] | SWI-Prolog website is served from... SWI-prolog, using just a small subset of the libraries available.
Well, it's not a commercial application, but it's rather [real world](http://www.swi-prolog.org/).
Much effort was required to make the runtime able to perform 24x7 service (mainly garbage collection) and required p... | I once asked my supervisor a similar question, when he is giving us a Prological lecture.
And he told me that people do not really use prolog to implement a whole huge system. Instead, people write the main part with other language(which is more sane and trivial), and link it to a "decision procedure" or something wri... |
10,772,530 | I am curious about this. I must learn Prolog for my course, but the applications that I seen mostly are written using C++, C# or Java. Applications written by Prolog, to me is very very rare application.
So, I wonder how Prolog is used and implement the real-world application? | 2012/05/27 | [
"https://Stackoverflow.com/questions/10772530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1326261/"
] | SWI-Prolog website is served from... SWI-prolog, using just a small subset of the libraries available.
Well, it's not a commercial application, but it's rather [real world](http://www.swi-prolog.org/).
Much effort was required to make the runtime able to perform 24x7 service (mainly garbage collection) and required p... | * **Microsoft Windows NT Networking Installation and Configuration applet**
One of the notorious and in a way notable examples is Microsoft Windows NT OS network interface configuration code that involved a Small Prolog interpreter built in. Here is a [link](http://www.drdobbs.com/cpp/184409294) to the story written b... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE M
SET M.BitField=1
from MailSubscription M
inner join #temp2 t2 on M.UserProfile_id=t2.UserProfile_Id
inner join #temp t on M.Service_id=t.ServiceId
and t.EmailAddress=t2.EmailAddress
``` | You could use a filtering join:
```
update m
set BitField = 1
from MailSubscription m
join #temp t1
on t1.Service_id = m.Service_id
join #temp2 t2
on t2.UserProfile_Id= m.UserProfile_Id
and t1.EmailAddress = t2.EmailAddress
``` |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE MailSubscription SET BitField=1
FROM #temp2
JOIN #temp on #temp2.EmailAddress=#temp.EmailAddress
WHERE MailSubscription.Service_id = #temp.ServiceId
AND MailSubscription.UserProfile_id = #temp2.UserProfile_Id
``` | Another option with EXISTS operator
```
UPDATE MailSubscription
SET BitField = 1
WHERE EXISTS (
SELECT 1
FROM #temp2 t2 JOIN #temp t ON t2.EmailAddress = t.EmailAddress
WHERE t2.UserProfile_Id = MailSubscription.UserProfile_Id
AND t.Service_Id = MailSubscripti... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE M
SET M.BitField=1
from MailSubscription M
inner join #temp2 t2 on M.UserProfile_id=t2.UserProfile_Id
inner join #temp t on M.Service_id=t.ServiceId
and t.EmailAddress=t2.EmailAddress
``` | ```
UPDATE MailSubscription SET BitField=1
FROM #temp2
JOIN #temp on #temp2.EmailAddress=#temp.EmailAddress
WHERE MailSubscription.Service_id = #temp.ServiceId
AND MailSubscription.UserProfile_id = #temp2.UserProfile_Id
``` |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | You could use a filtering join:
```
update m
set BitField = 1
from MailSubscription m
join #temp t1
on t1.Service_id = m.Service_id
join #temp2 t2
on t2.UserProfile_Id= m.UserProfile_Id
and t1.EmailAddress = t2.EmailAddress
``` | I think this should help u find the answer.
```
Update 'Tablename'
SET Mailsubscription = 1
WHERE concat(UserProfile_Id ,".", Service_Id) IN (
SELECT concat(t.UserProfile_Id , "." , t2,Service_Id)
FROM #temp t INNER JOIN #temp2 t2
ON t2.E... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE MailSubscription SET BitField=1
FROM #temp2
JOIN #temp on #temp2.EmailAddress=#temp.EmailAddress
WHERE MailSubscription.Service_id = #temp.ServiceId
AND MailSubscription.UserProfile_id = #temp2.UserProfile_Id
``` | I think this should help u find the answer.
```
Update 'Tablename'
SET Mailsubscription = 1
WHERE concat(UserProfile_Id ,".", Service_Id) IN (
SELECT concat(t.UserProfile_Id , "." , t2,Service_Id)
FROM #temp t INNER JOIN #temp2 t2
ON t2.E... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | You could use a filtering join:
```
update m
set BitField = 1
from MailSubscription m
join #temp t1
on t1.Service_id = m.Service_id
join #temp2 t2
on t2.UserProfile_Id= m.UserProfile_Id
and t1.EmailAddress = t2.EmailAddress
``` | ```
update MailSubscription set
BitField = 1
from MailSubscription as MS
where
exists
(
select *
from #temp2 as T2
inner join #temp as T on T.EmailAddress = T2.EmailAddress
where
T2.UserProfile_Id = MS.UserProfile_Id and
T.Service_Id = MS.Service_I... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE M
SET M.BitField=1
from MailSubscription M
inner join #temp2 t2 on M.UserProfile_id=t2.UserProfile_Id
inner join #temp t on M.Service_id=t.ServiceId
and t.EmailAddress=t2.EmailAddress
``` | I think this should help u find the answer.
```
Update 'Tablename'
SET Mailsubscription = 1
WHERE concat(UserProfile_Id ,".", Service_Id) IN (
SELECT concat(t.UserProfile_Id , "." , t2,Service_Id)
FROM #temp t INNER JOIN #temp2 t2
ON t2.E... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE M
SET M.BitField=1
from MailSubscription M
inner join #temp2 t2 on M.UserProfile_id=t2.UserProfile_Id
inner join #temp t on M.Service_id=t.ServiceId
and t.EmailAddress=t2.EmailAddress
``` | ```
update MailSubscription set
BitField = 1
from MailSubscription as MS
where
exists
(
select *
from #temp2 as T2
inner join #temp as T on T.EmailAddress = T2.EmailAddress
where
T2.UserProfile_Id = MS.UserProfile_Id and
T.Service_Id = MS.Service_I... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE M
SET M.BitField=1
from MailSubscription M
inner join #temp2 t2 on M.UserProfile_id=t2.UserProfile_Id
inner join #temp t on M.Service_id=t.ServiceId
and t.EmailAddress=t2.EmailAddress
``` | Another option with EXISTS operator
```
UPDATE MailSubscription
SET BitField = 1
WHERE EXISTS (
SELECT 1
FROM #temp2 t2 JOIN #temp t ON t2.EmailAddress = t.EmailAddress
WHERE t2.UserProfile_Id = MailSubscription.UserProfile_Id
AND t.Service_Id = MailSubscripti... |
17,922,077 | I have table with two FK `UserProfile_Id` and `Service_Id`. This table contains bit field which value I need to change.
I have two temporary tables:
First table **#temp2**:
```
EmailAddress,
UserProfile_Id
```
Second table **#temp**:
```
EmailAddress,
Service_Id
```
This statement does not work:
```
UPDATE Ma... | 2013/07/29 | [
"https://Stackoverflow.com/questions/17922077",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714342/"
] | ```
UPDATE MailSubscription SET BitField=1
FROM #temp2
JOIN #temp on #temp2.EmailAddress=#temp.EmailAddress
WHERE MailSubscription.Service_id = #temp.ServiceId
AND MailSubscription.UserProfile_id = #temp2.UserProfile_Id
``` | ```
update MailSubscription set
BitField = 1
from MailSubscription as MS
where
exists
(
select *
from #temp2 as T2
inner join #temp as T on T.EmailAddress = T2.EmailAddress
where
T2.UserProfile_Id = MS.UserProfile_Id and
T.Service_Id = MS.Service_I... |
52,485,689 | I am new in Android, I have finished some Android app development courses and now I am trying to apply what I learned. I've chosen a news app for it. It will extract news' from 5-10 source and display them in recyclerview.
I recognized that the course materials I used is outdated. I've used AsynctaskLoader to handle ... | 2018/09/24 | [
"https://Stackoverflow.com/questions/52485689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10392737/"
] | If you've already written it with Loaders there's no reason to rush to change it. Deprecated doesn't mean gone. And no, Loaders don't add significant performance penalty- any perf issues would be elsewhere in your app. | Loaders have been deprecated as of Android P (API 28). The recommended option for dealing with loading data while handling the Activity and Fragment lifecycles is to use a combination of ViewModels and LiveData. ViewModels survive configuration changes like Loaders but with less boilerplate. LiveData provides a lifecyc... |
52,485,689 | I am new in Android, I have finished some Android app development courses and now I am trying to apply what I learned. I've chosen a news app for it. It will extract news' from 5-10 source and display them in recyclerview.
I recognized that the course materials I used is outdated. I've used AsynctaskLoader to handle ... | 2018/09/24 | [
"https://Stackoverflow.com/questions/52485689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10392737/"
] | Loaders are good because of its ability to handle life cycle, but it is not as efficient as LiveData and ViewModel. If you care about performance, speed and being latest, use Android Architecture Components (LiveData, ViewModel), also, you don't have to stick to the old system of doing things, you can write a simple As... | Loaders have been deprecated as of Android P (API 28). The recommended option for dealing with loading data while handling the Activity and Fragment lifecycles is to use a combination of ViewModels and LiveData. ViewModels survive configuration changes like Loaders but with less boilerplate. LiveData provides a lifecyc... |
30,299,397 | I'm trying to show `UIActionSheet` on iPad from button on `UITableViewCell`. It works fine on iOS 7, but not working properly on iOS 8. `UIActionSheet` containts some visual artifacts and I'm getting this warning in console:
```
Unable to simultaneously satisfy constraints.
Probably at least one of the con... | 2015/05/18 | [
"https://Stackoverflow.com/questions/30299397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1561346/"
] | `UIActionSheet` is deprecated, so you can use `UIAlertViewController` available in iOS 8.0 or later.
```
- (IBAction)onFavoriteBtn:(id)sender {
CGPoint btnPosition = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:btnPosition];
if (in... | Looks like your favorite button superview is too small to embed action sheet. Try to use window to display action sheet, just don't forget convert coordinates of favorites button:
```
- (void)onFavoriteBtn:(id)sender {
CGPoint btnPosition = [sender convertPoint:CGPointZero toView:_tableView];
NSIndexPath *inde... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | ### `Using ES6:`
```js
let numbers = [3,1,5,9,7]
let ascending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => a - b)
ascending.pop()
let min = ascending.reduce((a, b) => a + b)
let descending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => b - a)
descending.pop()
let max = descending.reduce((a, b) =... | Here a function which solves your problem.
```js
const minMaxSum = (arr) => {
const orderedAr = arr.sort((a, b) => a - b);
const min = orderedAr
.slice(0, 4)
.reduce((val, acc) => acc + val, 0);
const max = orderedAr
.slice(-4)
.reduce((val, acc) => acc + val, 0);
return... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | ### `Using ES6:`
```js
let numbers = [3,1,5,9,7]
let ascending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => a - b)
ascending.pop()
let min = ascending.reduce((a, b) => a + b)
let descending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => b - a)
descending.pop()
let max = descending.reduce((a, b) =... | My approach considering Optimal time/space complexity:
* find min/max values from input array with Infinity/-Infinity
* calculate totalSum of input array
* print out (totalSum - max, totalSum - min)
##### Time: O(n) where n is # elements in input array
##### Space: O(1) no extra memory needed
```
function miniMaxSu... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | ### `Using ES6:`
```js
let numbers = [3,1,5,9,7]
let ascending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => a - b)
ascending.pop()
let min = ascending.reduce((a, b) => a + b)
let descending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => b - a)
descending.pop()
let max = descending.reduce((a, b) =... | Here's the full code with more optimized and cleaned with all test cases working-
Using Arrays.sort()
```
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the miniMaxSum f... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | ### `Using ES6:`
```js
let numbers = [3,1,5,9,7]
let ascending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => a - b)
ascending.pop()
let min = ascending.reduce((a, b) => a + b)
let descending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => b - a)
descending.pop()
let max = descending.reduce((a, b) =... | **New Answer**
```js
const arr = [5,5,5,5,7]
const min = (arr) => {
const max = Math.max(...arr)
const min = Math.min(...arr)
let maxIndexValue
let minIndexValue
let maxResult = 0
let minResult = 0
if(arr.reduce((val, c) => val + c) / arr.length === arr[0]){
const arrayFilter = a... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | You could take the first value as start value for `sum`, `min` and `max` value and iterate from the second item. Then add the actual value and check `min` and `max` values and take adjustments.
At the end return the delta of `sum` and `max` and `sum` and `min`.
```js
function minMaxSum(array) {
var sum = array[0... | **New Answer**
```js
const arr = [5,5,5,5,7]
const min = (arr) => {
const max = Math.max(...arr)
const min = Math.min(...arr)
let maxIndexValue
let minIndexValue
let maxResult = 0
let minResult = 0
if(arr.reduce((val, c) => val + c) / arr.length === arr[0]){
const arrayFilter = a... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | ### `Using ES6:`
```js
let numbers = [3,1,5,9,7]
let ascending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => a - b)
ascending.pop()
let min = ascending.reduce((a, b) => a + b)
let descending = JSON.parse(JSON.stringify(numbers)).sort((a, b) => b - a)
descending.pop()
let max = descending.reduce((a, b) =... | Have a look at this code.
```js
function miniMaxSum(arr) {
// Write your code here
const MaxValue = Math.max(...arr)
const MinValue = Math.min(...arr)
const MaxSum = arr.reduce((a,b) => a+b) - MinValue
const MinSum = arr.reduce((a,b) => a+b) - MaxValue
return `${MinSum} ${MaxSum}`
}
``` |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | You could take the first value as start value for `sum`, `min` and `max` value and iterate from the second item. Then add the actual value and check `min` and `max` values and take adjustments.
At the end return the delta of `sum` and `max` and `sum` and `min`.
```js
function minMaxSum(array) {
var sum = array[0... | Have a look at this code.
```js
function miniMaxSum(arr) {
// Write your code here
const MaxValue = Math.max(...arr)
const MinValue = Math.min(...arr)
const MaxSum = arr.reduce((a,b) => a+b) - MinValue
const MinSum = arr.reduce((a,b) => a+b) - MaxValue
return `${MinSum} ${MaxSum}`
}
``` |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | You could take the first value as start value for `sum`, `min` and `max` value and iterate from the second item. Then add the actual value and check `min` and `max` values and take adjustments.
At the end return the delta of `sum` and `max` and `sum` and `min`.
```js
function minMaxSum(array) {
var sum = array[0... | Here's the full code with more optimized and cleaned with all test cases working-
Using Arrays.sort()
```
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
// Complete the miniMaxSum f... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | You could take the first value as start value for `sum`, `min` and `max` value and iterate from the second item. Then add the actual value and check `min` and `max` values and take adjustments.
At the end return the delta of `sum` and `max` and `sum` and `min`.
```js
function minMaxSum(array) {
var sum = array[0... | My approach considering Optimal time/space complexity:
* find min/max values from input array with Infinity/-Infinity
* calculate totalSum of input array
* print out (totalSum - max, totalSum - min)
##### Time: O(n) where n is # elements in input array
##### Space: O(1) no extra memory needed
```
function miniMaxSu... |
60,362,680 | Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
For example `var arr = [1,3,5,7,9]` the output will be 16 24.
Here is my so... | 2020/02/23 | [
"https://Stackoverflow.com/questions/60362680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11213856/"
] | You could take the first value as start value for `sum`, `min` and `max` value and iterate from the second item. Then add the actual value and check `min` and `max` values and take adjustments.
At the end return the delta of `sum` and `max` and `sum` and `min`.
```js
function minMaxSum(array) {
var sum = array[0... | The solution is simple, just get the min and max value, sum the array and extract min or max in order to get the max sum or min sum.
As pseudocede:
```
min_value = find_min_value(arr)
max_value = find_max_value(arr)
max_sum = sum_array(arr) - min_value
min_sum = sum_array(arr) - max_value
```
:) |
39,277,227 | I have the following :
```
$data = [
{model_num : "ABC", revision : "AA", "testRecipeID":85, value : 31.25, treatment : 'Pressure' },
{model_num : "ABC", revision : "AA", "testRecipeID":85, value : 31.25, treatment : 'Gas' },
{model_num : "ABC", revision : "AA", "testRecipeID":85, value : 33.12, treatment : '... | 2016/09/01 | [
"https://Stackoverflow.com/questions/39277227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5636625/"
] | If you need the structure, you can try with [JSON Encode](http://php.net/manual/en/function.json-encode.php):
```
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
echo json_encode($arr);
?>
```
Which outputs:
```
{"a":1,"b":2,"c":3,"d":4,"e":5}
```
If you need it to be an array, use:
``... | Because neither of the previous answers managed to provide the desired output, I am compelled to answer this pivot question.
1. Create a temporary string from the 3 identifying column values.
2. Use that string as the first level key while grouping related row data.
3. The null coalescing assignment operator spares yo... |
39,277,227 | I have the following :
```
$data = [
{model_num : "ABC", revision : "AA", "testRecipeID":85, value : 31.25, treatment : 'Pressure' },
{model_num : "ABC", revision : "AA", "testRecipeID":85, value : 31.25, treatment : 'Gas' },
{model_num : "ABC", revision : "AA", "testRecipeID":85, value : 33.12, treatment : '... | 2016/09/01 | [
"https://Stackoverflow.com/questions/39277227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5636625/"
] | This is your JS function in PHP
```
<?php
$data = '[
{"model_num" : "ABC", "revision" : "AA", "testRecipeID":85, "value" : 31.25, "treatment" : "Pressure" },
{"model_num" : "ABC", "revision" : "AA", "testRecipeID":85, "value" : 31.25, "treatment" : "Gas" },
{"model_num" : "ABC", "revision" : "AA", "testRecipeID":85, "... | Because neither of the previous answers managed to provide the desired output, I am compelled to answer this pivot question.
1. Create a temporary string from the 3 identifying column values.
2. Use that string as the first level key while grouping related row data.
3. The null coalescing assignment operator spares yo... |
72,047 | I would like to build a electronic flatulence (fart) detector. I was thinking of methane because detectors are readily available, but I read <http://en.wikipedia.org/wiki/Flatulence> and it says:
>
> However, not all humans produce flatus that contains methane. For example, in one study of the feces of nine adults, o... | 2013/06/08 | [
"https://electronics.stackexchange.com/questions/72047",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/24932/"
] | It looks like Hydrogen is the major component: [Normal Flatus](http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1378885/). 360mL perday. How much per fart will take some closer reading.
Here is an Arduino flamable gas detector, it probably can sense Hydrogen:
[LM393 MQ-9](http://dx.com/p/lm393-mq-9-flammable-gas-detectio... | Weird project. Chairs that detect farts? No thanks.
Anyway I would suggest you look at an off-the-shelf propane sensor. Propane (C3H8) and methane (CH4) are very similar. In fact many of them are described as Propane Methane sensors. They are cheap and made in the thousands for RV's and Boats. A friend of mine always ... |
72,047 | I would like to build a electronic flatulence (fart) detector. I was thinking of methane because detectors are readily available, but I read <http://en.wikipedia.org/wiki/Flatulence> and it says:
>
> However, not all humans produce flatus that contains methane. For example, in one study of the feces of nine adults, o... | 2013/06/08 | [
"https://electronics.stackexchange.com/questions/72047",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/24932/"
] | Methane was used by another guy used in his office chair to detect his own flatus, but if that source is real, Futurlec seems to offer [dozens of gas sensors](http://www.futurlec.com/Gas_Sensors.shtml) for whatever gas you like.
As an example: [The Twittering Office Chair](http://www.instructables.com/id/The-Twitterin... | Weird project. Chairs that detect farts? No thanks.
Anyway I would suggest you look at an off-the-shelf propane sensor. Propane (C3H8) and methane (CH4) are very similar. In fact many of them are described as Propane Methane sensors. They are cheap and made in the thousands for RV's and Boats. A friend of mine always ... |
41,077,180 | I'm attempting to nest an arc generated using `d3.arc` perfectly inside another arc.
I can do this by drawing "on my own":
```html
<!DOCTYPE html>
<html>
<head>
<script data-require="d3@4.0.0" data-semver="4.0.0" src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<script>
function arc_posi... | 2016/12/10 | [
"https://Stackoverflow.com/questions/41077180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16363/"
] | I don't think that there is a good way to do this just using `d3.arc` because that is meant for drawing sections of circles and you're trying to draw a partial ellipse.
You can get close by generating the angle offset using the stroke width and the radius of the inner arc as `offsetAngle = sin(stroke width / inner rad... | You draw second arc with outer radius `R - 2 * strokewidth` and center shifted by `strokewidth`.
But smaller arc should have **the same center** as larger one and outer radius `R - strokewidth` |
41,077,180 | I'm attempting to nest an arc generated using `d3.arc` perfectly inside another arc.
I can do this by drawing "on my own":
```html
<!DOCTYPE html>
<html>
<head>
<script data-require="d3@4.0.0" data-semver="4.0.0" src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<script>
function arc_posi... | 2016/12/10 | [
"https://Stackoverflow.com/questions/41077180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16363/"
] | *(This is not an answer, but just a comment, which I chose to disguise as an answer because I need the S.O. snippet)*
I believe that [Paul S](https://stackoverflow.com/a/41082900/5768908) is right, and he deserves the *big prize* of the green tick: what you're trying to paint in the inner (orange) path is **not** an a... | You draw second arc with outer radius `R - 2 * strokewidth` and center shifted by `strokewidth`.
But smaller arc should have **the same center** as larger one and outer radius `R - strokewidth` |
41,077,180 | I'm attempting to nest an arc generated using `d3.arc` perfectly inside another arc.
I can do this by drawing "on my own":
```html
<!DOCTYPE html>
<html>
<head>
<script data-require="d3@4.0.0" data-semver="4.0.0" src="https://d3js.org/d3.v4.min.js"></script>
</head>
<body>
<script>
function arc_posi... | 2016/12/10 | [
"https://Stackoverflow.com/questions/41077180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16363/"
] | I don't think that there is a good way to do this just using `d3.arc` because that is meant for drawing sections of circles and you're trying to draw a partial ellipse.
You can get close by generating the angle offset using the stroke width and the radius of the inner arc as `offsetAngle = sin(stroke width / inner rad... | *(This is not an answer, but just a comment, which I chose to disguise as an answer because I need the S.O. snippet)*
I believe that [Paul S](https://stackoverflow.com/a/41082900/5768908) is right, and he deserves the *big prize* of the green tick: what you're trying to paint in the inner (orange) path is **not** an a... |
2,522,609 | I am having a php file which executes some code to generate a html file.Its like I m having a form from which some data will be posted to x.php file, which gives a output(a webpage). I want to save that output in a html file.What the most efficient way of doing this.?
**EDIT**
I want to save it on sever side. Actually... | 2010/03/26 | [
"https://Stackoverflow.com/questions/2522609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/179855/"
] | using `ob_*` functions such as `ob_get_contents()`, a php script can catch it's output. | probably with ob\_start and output\_callback see <http://php.net/manual/en/function.ob-start.php> |
2,522,609 | I am having a php file which executes some code to generate a html file.Its like I m having a form from which some data will be posted to x.php file, which gives a output(a webpage). I want to save that output in a html file.What the most efficient way of doing this.?
**EDIT**
I want to save it on sever side. Actually... | 2010/03/26 | [
"https://Stackoverflow.com/questions/2522609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/179855/"
] | Try something like this:
```
// Start output buffering
ob_start();
// run code in x.php file
// ...
// saving captured output to file
file_put_contents('filename.htm', ob_get_contents());
// end buffering and displaying page
ob_end_flush();
```
If you cannot use the [ob\_\* functions](http://de3.php.net/manual/en/re... | using `ob_*` functions such as `ob_get_contents()`, a php script can catch it's output. |
2,522,609 | I am having a php file which executes some code to generate a html file.Its like I m having a form from which some data will be posted to x.php file, which gives a output(a webpage). I want to save that output in a html file.What the most efficient way of doing this.?
**EDIT**
I want to save it on sever side. Actually... | 2010/03/26 | [
"https://Stackoverflow.com/questions/2522609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/179855/"
] | Try something like this:
```
// Start output buffering
ob_start();
// run code in x.php file
// ...
// saving captured output to file
file_put_contents('filename.htm', ob_get_contents());
// end buffering and displaying page
ob_end_flush();
```
If you cannot use the [ob\_\* functions](http://de3.php.net/manual/en/re... | probably with ob\_start and output\_callback see <http://php.net/manual/en/function.ob-start.php> |
2,522,609 | I am having a php file which executes some code to generate a html file.Its like I m having a form from which some data will be posted to x.php file, which gives a output(a webpage). I want to save that output in a html file.What the most efficient way of doing this.?
**EDIT**
I want to save it on sever side. Actually... | 2010/03/26 | [
"https://Stackoverflow.com/questions/2522609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/179855/"
] | Look at ob functions (see <http://php.net/manual/en/function.ob-start.php>) that allows you to capture every output (echo, print, etc...) from the page. | probably with ob\_start and output\_callback see <http://php.net/manual/en/function.ob-start.php> |
2,522,609 | I am having a php file which executes some code to generate a html file.Its like I m having a form from which some data will be posted to x.php file, which gives a output(a webpage). I want to save that output in a html file.What the most efficient way of doing this.?
**EDIT**
I want to save it on sever side. Actually... | 2010/03/26 | [
"https://Stackoverflow.com/questions/2522609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/179855/"
] | Try something like this:
```
// Start output buffering
ob_start();
// run code in x.php file
// ...
// saving captured output to file
file_put_contents('filename.htm', ob_get_contents());
// end buffering and displaying page
ob_end_flush();
```
If you cannot use the [ob\_\* functions](http://de3.php.net/manual/en/re... | Look at ob functions (see <http://php.net/manual/en/function.ob-start.php>) that allows you to capture every output (echo, print, etc...) from the page. |
27,906,479 | I have an application that I developed standalone and now am trying to integrate into a much larger model. Currently, on the server side, there are 11 tables and an average of three navigation properties per table. This is working well and stable.
The larger model has 55 entities and 180+ relationships and includes m... | 2015/01/12 | [
"https://Stackoverflow.com/questions/27906479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2719246/"
] | Ok, some of what you are describing can be explained by breeze's default behavior of compressing the payload of any query results that return multiple instances of the same entity. If you are using something like the default 'json.net' assembly for serialization, then each entity is sent with an extra '$id' property an... | After looking at your Gist, I think I see the issue. Your metadata is out of sync with the actual results returned by your query. In particular, if you look for the '$id' value of "17" in your actual results you'll notice that it is first found in the 'Client' property of the 'Repayment' type, but your metadata doesn't... |
6,646,509 | What are the datatypes available in asterisk server dial plan?
how to check the date type? | 2011/07/11 | [
"https://Stackoverflow.com/questions/6646509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809719/"
] | Asterisk dial plan language is weakly-typed (has no 'types' as such). All values are strings, but can be treated as numbers in some context (e.g. arithmetic expressions). The only way to check 'the type' is to use a regular expression to check the value.
There are some functions like [HASH](http://www.voip-info.org/wi... | No, in dialplan everything is a string. You can use AGI to check date or compare various things.
What exactly do you need? I'm guessing but maybe this will be useful: [How to include contexts based on time and date](http://www.voip-info.org/wiki/view/Asterisk+tips+openhours) |
6,646,509 | What are the datatypes available in asterisk server dial plan?
how to check the date type? | 2011/07/11 | [
"https://Stackoverflow.com/questions/6646509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809719/"
] | Asterisk dial plan language is weakly-typed (has no 'types' as such). All values are strings, but can be treated as numbers in some context (e.g. arithmetic expressions). The only way to check 'the type' is to use a regular expression to check the value.
There are some functions like [HASH](http://www.voip-info.org/wi... | There is no type in dialplan, everything can be treated string variable.
But if required, you can always use your favorite programming language using AGI. |
6,646,509 | What are the datatypes available in asterisk server dial plan?
how to check the date type? | 2011/07/11 | [
"https://Stackoverflow.com/questions/6646509",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/809719/"
] | No, in dialplan everything is a string. You can use AGI to check date or compare various things.
What exactly do you need? I'm guessing but maybe this will be useful: [How to include contexts based on time and date](http://www.voip-info.org/wiki/view/Asterisk+tips+openhours) | There is no type in dialplan, everything can be treated string variable.
But if required, you can always use your favorite programming language using AGI. |
38,682,341 | I want to have three images on a row, if the total width of these three images doesn't fit the browser window then all three images should be below each other. So it's "all or nothing", there should never be only two images beside each other and one below (this happens then you gradually decrease browser window width u... | 2016/07/31 | [
"https://Stackoverflow.com/questions/38682341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6659536/"
] | The parent of your `<a>` element is a `td` element, and the `td` element doesn't have a following-sibling - certainly not a following sibling that is a `tr`. If you want the next row in the table, use
```
.//a[@class="..."]/ancestor::tr[1]/following-sibling::tr[1]
```
or
```
.//tr[descendant::a/@class="..."]/follow... | If you want to select just next `tr` after `<a class="productnamecolor colors_productname">` simply use following two ways :-
* using [`following`](https://developer.mozilla.org/en-US/docs/Web/XPath/Axes/following) axis :
```
(.//a[@class="productnamecolor colors_productname"]/following::tr)[1]
```
* using [`precedi... |
2,070,906 | How to keep session alive for 1week without logout PHP, overwriting default server values?
I need to do this in the PHP code. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2070906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131637/"
] | You can set the session lifetime in your script by using the session\_set\_cookie\_params -function call before the session is started. The first argument of the function call defines the session lifetime in seconds relative to the server time (so make sure the server clock is correct):
For example, to make a session ... | Just wanted to add this even though it's an old thread for the sake of completeness for future googlers:
>
> Beware if you are on a Debian system.
>
>
>
The `/etc/cron.d/php5` script will still clean your `/var/lib/php5/` directory containing your sessions based on the `php.ini` value `session.gc_maxlifetime`. |
2,070,906 | How to keep session alive for 1week without logout PHP, overwriting default server values?
I need to do this in the PHP code. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2070906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131637/"
] | You can set the session lifetime in your script by using the session\_set\_cookie\_params -function call before the session is started. The first argument of the function call defines the session lifetime in seconds relative to the server time (so make sure the server clock is correct):
For example, to make a session ... | Alternative solution:
You say people are leaving open their browsers for days and complain that session expire. Simple solution: don't let session expire by sending an keep-alive request using eg. XMLHttpRequest every 10 minutes. |
2,070,906 | How to keep session alive for 1week without logout PHP, overwriting default server values?
I need to do this in the PHP code. | 2010/01/15 | [
"https://Stackoverflow.com/questions/2070906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/131637/"
] | Just wanted to add this even though it's an old thread for the sake of completeness for future googlers:
>
> Beware if you are on a Debian system.
>
>
>
The `/etc/cron.d/php5` script will still clean your `/var/lib/php5/` directory containing your sessions based on the `php.ini` value `session.gc_maxlifetime`. | Alternative solution:
You say people are leaving open their browsers for days and complain that session expire. Simple solution: don't let session expire by sending an keep-alive request using eg. XMLHttpRequest every 10 minutes. |
11,941,257 | Last days as a result of some customer complains and discussion with our marketing guys I've got a request to change the default behavior of the configurable products options. They asked me to remove the + $xx.xx from the options drop-down as it is confusing the customers/visitors and just leave the available options w... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11941257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1177078/"
] | See this from prototype manual <http://prototypejs.org/doc/latest/language/Function/prototype/wrap/> you can wrap whatever object method and even call "parent" if needed and here's a pseudo sample:
```
//where Product.Config is the object/class you need to "override"
Product.Config.prototype.getOptionLabel = Product.... | Just to add to @anton-s's absolutely correct answer, you can also do "full" class rewrites:
```
// Create the original class
var ClassA = Class.create();
ClassA.prototype = {
initialize: function(config) {
this.config = config;
},
test: function(msg) {
console.log('Hi from class A with mess... |
11,941,257 | Last days as a result of some customer complains and discussion with our marketing guys I've got a request to change the default behavior of the configurable products options. They asked me to remove the + $xx.xx from the options drop-down as it is confusing the customers/visitors and just leave the available options w... | 2012/08/13 | [
"https://Stackoverflow.com/questions/11941257",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1177078/"
] | See this from prototype manual <http://prototypejs.org/doc/latest/language/Function/prototype/wrap/> you can wrap whatever object method and even call "parent" if needed and here's a pseudo sample:
```
//where Product.Config is the object/class you need to "override"
Product.Config.prototype.getOptionLabel = Product.... | **How to override \js\varien\configurable.js in Magento 1.9 EE and add new data attribute**
Create file \js\jsoverride\configurable.js:
```
Product.Config.prototype.reloadOptionLabels = Product.Config.prototype.reloadOptionLabels.wrap(function (parentMethod, element) {
var selectedPrice;
if (element.optio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.