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 |
|---|---|---|---|---|---|
11,236,839 | ```
String s = new String({'h','e','l','l','o'});
```
I received the error:
>
> 1 Invalid expression term '{'
>
>
>
I thought `{'h','e','l','l','o'}` should be a character array, why did it fail to compile? | 2012/06/28 | [
"https://Stackoverflow.com/questions/11236839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1136700/"
] | I think you mean:
```
String s = new String(new[] {'h','e','l','l','o'});
```
The code you had before was not initializing an array correctly. Check out the MSDN article on [implicitly typed arrays](http://msdn.microsoft.com/en-us/library/bb384090.aspx) for more info.
You could also explicitly specify the type of t... | Try something like this:
```
String s = new String(new char [] {'h','e','l','l','o'});
``` |
574,040 | It's been a while since I have soldered, so I bought a cheap unbranded soldering iron to use while I re-familiarised myself with the skill. After a few weeks of use, I turned it on just now and it popped with a blue spark. Now it appears to be dead. Did I do something wrong, or is that simply what happens sometimes whe... | 2021/07/03 | [
"https://electronics.stackexchange.com/questions/574040",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/288848/"
] | Just looking at how these wires are soldered to the PCB indicates a low quality product. I would not blame you but the product instead. | This soldering iron is garbage. The PCB has been soldered by machine and is likely ok. The power cable looks like it hasn't even be soldered on in a factory but by home workers with bad equipment and bad skills. It starts by the cables not being properly deinsulated (you can see a number of torn copper strands) and the... |
574,040 | It's been a while since I have soldered, so I bought a cheap unbranded soldering iron to use while I re-familiarised myself with the skill. After a few weeks of use, I turned it on just now and it popped with a blue spark. Now it appears to be dead. Did I do something wrong, or is that simply what happens sometimes whe... | 2021/07/03 | [
"https://electronics.stackexchange.com/questions/574040",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/288848/"
] | Just looking at how these wires are soldered to the PCB indicates a low quality product. I would not blame you but the product instead. | It looks like the mains cord was not fully soldered to the board.
-----------------------------------------------------------------
You can see a stray whisker of the ground still. There were probably also loose strands on the current-carying conductors. They probably flexed enough to touch when you were handling the ... |
574,040 | It's been a while since I have soldered, so I bought a cheap unbranded soldering iron to use while I re-familiarised myself with the skill. After a few weeks of use, I turned it on just now and it popped with a blue spark. Now it appears to be dead. Did I do something wrong, or is that simply what happens sometimes whe... | 2021/07/03 | [
"https://electronics.stackexchange.com/questions/574040",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/288848/"
] | Just looking at how these wires are soldered to the PCB indicates a low quality product. I would not blame you but the product instead. | That thing was not UL Listed
----------------------------
and should never have been plugged into AC power. It violated the safety codes of lots of countries.
Never plug anything into AC power that isn't UL Listed.\*
[](https://i.stack.imgur.com/rO7... |
574,040 | It's been a while since I have soldered, so I bought a cheap unbranded soldering iron to use while I re-familiarised myself with the skill. After a few weeks of use, I turned it on just now and it popped with a blue spark. Now it appears to be dead. Did I do something wrong, or is that simply what happens sometimes whe... | 2021/07/03 | [
"https://electronics.stackexchange.com/questions/574040",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/288848/"
] | This soldering iron is garbage. The PCB has been soldered by machine and is likely ok. The power cable looks like it hasn't even be soldered on in a factory but by home workers with bad equipment and bad skills. It starts by the cables not being properly deinsulated (you can see a number of torn copper strands) and the... | It looks like the mains cord was not fully soldered to the board.
-----------------------------------------------------------------
You can see a stray whisker of the ground still. There were probably also loose strands on the current-carying conductors. They probably flexed enough to touch when you were handling the ... |
574,040 | It's been a while since I have soldered, so I bought a cheap unbranded soldering iron to use while I re-familiarised myself with the skill. After a few weeks of use, I turned it on just now and it popped with a blue spark. Now it appears to be dead. Did I do something wrong, or is that simply what happens sometimes whe... | 2021/07/03 | [
"https://electronics.stackexchange.com/questions/574040",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/288848/"
] | This soldering iron is garbage. The PCB has been soldered by machine and is likely ok. The power cable looks like it hasn't even be soldered on in a factory but by home workers with bad equipment and bad skills. It starts by the cables not being properly deinsulated (you can see a number of torn copper strands) and the... | That thing was not UL Listed
----------------------------
and should never have been plugged into AC power. It violated the safety codes of lots of countries.
Never plug anything into AC power that isn't UL Listed.\*
[](https://i.stack.imgur.com/rO7... |
574,040 | It's been a while since I have soldered, so I bought a cheap unbranded soldering iron to use while I re-familiarised myself with the skill. After a few weeks of use, I turned it on just now and it popped with a blue spark. Now it appears to be dead. Did I do something wrong, or is that simply what happens sometimes whe... | 2021/07/03 | [
"https://electronics.stackexchange.com/questions/574040",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/288848/"
] | That thing was not UL Listed
----------------------------
and should never have been plugged into AC power. It violated the safety codes of lots of countries.
Never plug anything into AC power that isn't UL Listed.\*
[](https://i.stack.imgur.com/rO7... | It looks like the mains cord was not fully soldered to the board.
-----------------------------------------------------------------
You can see a stray whisker of the ground still. There were probably also loose strands on the current-carying conductors. They probably flexed enough to touch when you were handling the ... |
29,416,053 | How do I assert that none of the methods of a stubbed/mocked object were called? For a single method it's fairly simple, just call `Stub(x => x.METHOD()).Repeat.Never()` but if you have bunch of methods or lots of overloaded methods it gets inconvenient.
Is there a neat workaround for this? | 2015/04/02 | [
"https://Stackoverflow.com/questions/29416053",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/190281/"
] | I haven't really used rhino-mocks, but as @Lee suggested in his comment you should be able to achieve the effect you're after using `StrictMock` without any other expectations. So, given the following test:
```
public void TestStrickMock() {
var mockRepo = new MockRepository();
// Create a StrictMock ... | As others have said, use a `StrictMock`.
This passes.
```
var mockFoo = MockRepository.GenerateStrictMock<IFoo>();
mockFoo.VerifyAllExpectations();
```
This fails.
```
var mockFoo = MockRepository.GenerateStrictMock<IFoo>();
mockFoo.Bar();
mockFoo.VerifyAllExpectations();
``` |
741,907 | I have a question about VMware and NIC Teaming. Here is my easy test scenario. I have two VMs. VM1 and VM2. I want to copy 1 big file from VM1 to VM2 because I want to see that I can gain more copy speed than 1Gbit/s. But i can’t get more speed than about 113MB/s… (which is nearly the 1Gbit/s) But I don’t understand wh... | 2015/12/09 | [
"https://serverfault.com/questions/741907",
"https://serverfault.com",
"https://serverfault.com/users/243929/"
] | A NIC team does NOT provide any more bandwidth. A single network connection (like the one between your 2 VM's) will never use more than one of the possible NIC's in the team. The point of a NIC team is to balance **many** connections across the available NIC's.
With your chosen load balancing method (Route based on th... | While NIC Teaming can provide additional bandwidth, it's greatest benefit is fault tolerance to your setup. There is still an aggregate bandwidth increase, but as far as I know with most equipment, you will not be able to get greater than 1gbps for a ***single*** transfer even if you have 4 teamed 1gbps connections. Wh... |
16,013,692 | I have installed Robot Framework. I am searching for example Test Cases for Robot Framework using Selenium Library.
I need a guideline to start writing TCs on Robot Framework. Help is appreciated. | 2013/04/15 | [
"https://Stackoverflow.com/questions/16013692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2264353/"
] | Probably because of Quirksmode?
Add a Doctype! | Why adding the style to the `input`? It isn't doing anything.
The `input` has a `type="checkbox"` attribute. Thus `text-align:center;` is a bit strange because there will never be text inside. Even the `vertical-align` property does not belong there. There isn't anything inside the checkbox to align...
The CSS code yo... |
94,349 | According to Catholicism, an act of heresy is a mortal sin.
>
> "Heresy is the obstinate post-baptismal denial of some truth which must be believed with divine and catholic faith, or it is likewise an obstinate doubt concerning the same ...
>
>
>
[Catechism of the Catholic Church #2089](https://www.vatican.va/arc... | 2023/01/31 | [
"https://christianity.stackexchange.com/questions/94349",
"https://christianity.stackexchange.com",
"https://christianity.stackexchange.com/users/29846/"
] | [Heresy is a species of unbelief](https://isidore.co/aquinas/summa/SS/SS011.html#SSQ11A1THEP1), [which is a sin](https://isidore.co/aquinas/summa/SS/SS010.html#SSQ10A1THEP1) against the theological virtue of faith, [which resides in the intellect](https://isidore.co/aquinas/summa/SS/SS004.html#SSQ4A2THEP1).
St. Thomas... | The reason is in the definition of heresy. As you stated
>
> "Heresy is the obstinate post-baptismal denial of some truth which must be believed with divine and catholic faith, or it is likewise an obstinate doubt concerning the same"
>
>
>
If some truth must be believed with divine and catholic faith, then one w... |
94,349 | According to Catholicism, an act of heresy is a mortal sin.
>
> "Heresy is the obstinate post-baptismal denial of some truth which must be believed with divine and catholic faith, or it is likewise an obstinate doubt concerning the same ...
>
>
>
[Catechism of the Catholic Church #2089](https://www.vatican.va/arc... | 2023/01/31 | [
"https://christianity.stackexchange.com/questions/94349",
"https://christianity.stackexchange.com",
"https://christianity.stackexchange.com/users/29846/"
] | [Heresy is a species of unbelief](https://isidore.co/aquinas/summa/SS/SS011.html#SSQ11A1THEP1), [which is a sin](https://isidore.co/aquinas/summa/SS/SS010.html#SSQ10A1THEP1) against the theological virtue of faith, [which resides in the intellect](https://isidore.co/aquinas/summa/SS/SS004.html#SSQ4A2THEP1).
St. Thomas... | **In Catholicism, why is heresy a mortal sin?**
According to the Catholic Church the sin of heresy is a mortal sin because it is destructive to the virtue of Christian faith and it’s revolt against a Divinely constituted authority.
It can at times seem complicated.
>
> [**Gravity of the sin of heresy**](https://www... |
94,349 | According to Catholicism, an act of heresy is a mortal sin.
>
> "Heresy is the obstinate post-baptismal denial of some truth which must be believed with divine and catholic faith, or it is likewise an obstinate doubt concerning the same ...
>
>
>
[Catechism of the Catholic Church #2089](https://www.vatican.va/arc... | 2023/01/31 | [
"https://christianity.stackexchange.com/questions/94349",
"https://christianity.stackexchange.com",
"https://christianity.stackexchange.com/users/29846/"
] | **In Catholicism, why is heresy a mortal sin?**
According to the Catholic Church the sin of heresy is a mortal sin because it is destructive to the virtue of Christian faith and it’s revolt against a Divinely constituted authority.
It can at times seem complicated.
>
> [**Gravity of the sin of heresy**](https://www... | The reason is in the definition of heresy. As you stated
>
> "Heresy is the obstinate post-baptismal denial of some truth which must be believed with divine and catholic faith, or it is likewise an obstinate doubt concerning the same"
>
>
>
If some truth must be believed with divine and catholic faith, then one w... |
17,181,511 | What's the preferred way to handle long numbers, like a bank account number, that should be read one character at a time? I know users can get TalkBack to read out a number this way, but it would be nice if we could hint that it should do this from the start.
Is it a good idea to set a content description with spaces ... | 2013/06/19 | [
"https://Stackoverflow.com/questions/17181511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/772122/"
] | I have talked to several screen-reader users and they have all confirmed that we shouldn't go out of our way to do anything out of the ordinary in cases like this. They all say "Don't worry, we can figure it out. You don't need to help us."
If a screen reader user gets to an area that they need more clarity on they wi... | Use the following delegate for your editText or textView
```
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
switch (host.getId()... |
69,030 | According to the [this answer](https://www.answers.com/boating/What_do_red_buoy%27s_and_green_buoy%27s_mean_when_boating), in the US buoys on the right are red when returning to a harbour, with green on the left. This is in contrast to most of the rest of the world.
What caused this split in the conventions? | 2022/05/18 | [
"https://history.stackexchange.com/questions/69030",
"https://history.stackexchange.com",
"https://history.stackexchange.com/users/37663/"
] | There used to be very many more buoyage systems in use around the world which resulted in confusion and danger. An agreement to unify the system was agreed at Geneva in 1936 by the League of Nations, but the collapse of the League and World War II scuppered that. In 1965 IALA (the International Association of Lighthous... | [@Martin's existing answer](https://history.stackexchange.com/questions/69030/why-does-the-us-use-the-opposite-convention-to-the-rest-of-the-world-for-colour/69031#69031) is good, but I'd like to emphasize a point behind his point: Basically, the reason that standards consolidation has not gone further is because it is... |
65,319,127 | I'm working on a python assignment and this is where I got so far. I'm stuck and cannot execute the application. I'm making a calculator that scores the average and gives a grade letter. I was looking into my professor's video and there was "import tkinter.messagebox as tkm" but Im not sure how to implement this in the... | 2020/12/16 | [
"https://Stackoverflow.com/questions/65319127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14819494/"
] | `messagebox` can help to create fast small message windows.
The usage is very simple, just implement this in your code:
```
from tkinter import messagebox
```
In you case:
```
from tkinter import messagebox as tkm
```
Then:
```
messagebox.function(title,message,options)
```
In your case:
```
tkm.function(titl... | There are multiple problems in your code. First, you define window two times. The second time, you just override your frist instance of window, so just leave that out.
Then you are not packing your Buttons, which means they will not be shown in your window. Lastly, you are missing the most important part of your Tkinte... |
278,210 | I know lazy loading is required when an expensive database call is being made. It would make sense using lazy loading in this example. The below example is in the context of asp.net so it's thread safe.
```
private list<Customer> _AllCustomers;
public list<Customer> AllCustomers {
get {
if (_AllCustomers == null) ... | 2015/04/03 | [
"https://softwareengineering.stackexchange.com/questions/278210",
"https://softwareengineering.stackexchange.com",
"https://softwareengineering.stackexchange.com/users/170706/"
] | There's an additional thing you may want to take into account besides the sheer speed factor.
**The code itself.** And it's maintainability.
* Does this kind of lazy loading make the code slower to write, or harder to understand and change?
* Does it make the architecture more complex that it needs to be?
Some examp... | IMHO Lazy loading is a pattern in your list of design choices. There is no "always" or "never" .. more the question: when should I and when shouldn't I.
Way back when I used to always have lazy loading for most things, these days I rarely use it, preferring instead to load "a good amount" (more formally known as a "bo... |
56,998,499 | I am trying to catch strings around the acronym ADJ. The strings look like this:
```
·NOM·JJ·ADJ+CASE_DEF_GEN
·NOM·JJ·ADJ+CASE_DEF_ACC
·NOM·JJ·ADJ+CASE_INDEF_GEN
·NOM·DT+JJ·DET+ADJ+NSUFF_FEM_SG+CASE_DEF_GEN
·NOM·JJ·ADJ+CASE_INDEF_GEN
·NOM·JJ·ADJ+NSUFF_FEM_SG+CASE_INDEF_GEN
·NOM·DT+JJ·DET+ADJ+NSUFF_FEM_SG+CASE_DEF_ACC
... | 2019/07/11 | [
"https://Stackoverflow.com/questions/56998499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11772741/"
] | My guess is that you want to make sure if you have an `ADJ` in the string, which if so, maybe we could simplify our expression to something similar to:
```
([A-Z·+#_]*)\bADJ\b([A-Z·+#_]*)
```
The expression is explained on the top right panel of [this demo](https://regex101.com/r/dT1FsF/1/), if you wish to explore/s... | Removing the `?` at the end would match the whole strings,
```
/[A-Z·\+#_]*?[·\+]ADJ[·\+][A-Z_·\+#]*/g
```
I am not entirely sure why you needed a `?` in a `*`. |
56,998,499 | I am trying to catch strings around the acronym ADJ. The strings look like this:
```
·NOM·JJ·ADJ+CASE_DEF_GEN
·NOM·JJ·ADJ+CASE_DEF_ACC
·NOM·JJ·ADJ+CASE_INDEF_GEN
·NOM·DT+JJ·DET+ADJ+NSUFF_FEM_SG+CASE_DEF_GEN
·NOM·JJ·ADJ+CASE_INDEF_GEN
·NOM·JJ·ADJ+NSUFF_FEM_SG+CASE_INDEF_GEN
·NOM·DT+JJ·DET+ADJ+NSUFF_FEM_SG+CASE_DEF_ACC
... | 2019/07/11 | [
"https://Stackoverflow.com/questions/56998499",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11772741/"
] | That `*?` quantifier after the `+ADJ+` phrase is satisfied with the empty string right after it, since the `?` makes the quantifier before it match ["*the minimum number of times possible*"](https://perldoc.perl.org/perlre.html#Quantifiers) and for `*` that is zero times.
So drop the `?`, which also has no purpose fo... | Removing the `?` at the end would match the whole strings,
```
/[A-Z·\+#_]*?[·\+]ADJ[·\+][A-Z_·\+#]*/g
```
I am not entirely sure why you needed a `?` in a `*`. |
10,220,468 | I have a worksheet which does two things.
First it updates ODBC data tables from a SQL server, then updates one of the data tables to include formula with references to another excel spreadsheet.
Secondly, it refreshes a pivot table that is based on data from the updated table above.
However, it updates the pivot ta... | 2012/04/19 | [
"https://Stackoverflow.com/questions/10220468",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/687586/"
] | You need to check your connections properties and disable the "Enable Background Refresh" option.
Or set the backgroundquery property to false in your code.
This should force excel to wait for the query to finish before continuing. | I had this problem; Readify's answer was spot on. Here's my code.
```
Range("Table_sqlserver_database[[#Headers],[column_name]]").Select
With Selection.ListObject.QueryTable
.BackgroundQuery = False
End With
``` |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | 1. Create a new `FileStream`.
2. `Seek()` to the end.
3. `Write()` the bytes.
4. `Close()` the stream. | I'm not exactly sure what the question is, but C# has a `BinaryWriter` method that takes an array of bytes.
[BinaryWriter(Byte[])](http://msdn.microsoft.com/en-us/library/bx149a0k.aspx)
```
bool writeFinished = false;
string fileName = "C:\\test.exe";
FileStream fs = new FileString(fileName);
BinaryWriter bw = new Bi... |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | One way would be to create a [`FileStream`](http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx) with the [`FileMode.Append`](http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx) creation mode.
>
> Opens the file if it exists and seeks to the end of the file, or
> creates a new file.
>
>
... | I'm not exactly sure what the question is, but C# has a `BinaryWriter` method that takes an array of bytes.
[BinaryWriter(Byte[])](http://msdn.microsoft.com/en-us/library/bx149a0k.aspx)
```
bool writeFinished = false;
string fileName = "C:\\test.exe";
FileStream fs = new FileString(fileName);
BinaryWriter bw = new Bi... |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | You can also use the built-in `FileSystem.WriteAllBytes Method (String, Byte[], Boolean)`.
```
public static void WriteAllBytes(
string file,
byte[] data,
bool append
)
```
Set append to **True** to append to the file contents; **False** to overwrite the file contents. Default is False. | I'm not exactly sure what the question is, but C# has a `BinaryWriter` method that takes an array of bytes.
[BinaryWriter(Byte[])](http://msdn.microsoft.com/en-us/library/bx149a0k.aspx)
```
bool writeFinished = false;
string fileName = "C:\\test.exe";
FileStream fs = new FileString(fileName);
BinaryWriter bw = new Bi... |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | I'm not exactly sure what the question is, but C# has a `BinaryWriter` method that takes an array of bytes.
[BinaryWriter(Byte[])](http://msdn.microsoft.com/en-us/library/bx149a0k.aspx)
```
bool writeFinished = false;
string fileName = "C:\\test.exe";
FileStream fs = new FileString(fileName);
BinaryWriter bw = new Bi... | you can simply create a function to do this
```
public static void AppendToFile(string fileToWrite, byte[] DT)
{
using (FileStream FS = new FileStream(fileToWrite, File.Exists(fileToWrite) ? FileMode.Append : FileMode.OpenOrCreate, FileAccess.Write)) {
FS.Write(DT, 0, DT.Length);
FS.Close();
}
... |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | One way would be to create a [`FileStream`](http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx) with the [`FileMode.Append`](http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx) creation mode.
>
> Opens the file if it exists and seeks to the end of the file, or
> creates a new file.
>
>
... | 1. Create a new `FileStream`.
2. `Seek()` to the end.
3. `Write()` the bytes.
4. `Close()` the stream. |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | 1. Create a new `FileStream`.
2. `Seek()` to the end.
3. `Write()` the bytes.
4. `Close()` the stream. | you can simply create a function to do this
```
public static void AppendToFile(string fileToWrite, byte[] DT)
{
using (FileStream FS = new FileStream(fileToWrite, File.Exists(fileToWrite) ? FileMode.Append : FileMode.OpenOrCreate, FileAccess.Write)) {
FS.Write(DT, 0, DT.Length);
FS.Close();
}
... |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | One way would be to create a [`FileStream`](http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx) with the [`FileMode.Append`](http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx) creation mode.
>
> Opens the file if it exists and seeks to the end of the file, or
> creates a new file.
>
>
... | You can also use the built-in `FileSystem.WriteAllBytes Method (String, Byte[], Boolean)`.
```
public static void WriteAllBytes(
string file,
byte[] data,
bool append
)
```
Set append to **True** to append to the file contents; **False** to overwrite the file contents. Default is False. |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | One way would be to create a [`FileStream`](http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx) with the [`FileMode.Append`](http://msdn.microsoft.com/en-us/library/system.io.filemode.aspx) creation mode.
>
> Opens the file if it exists and seeks to the end of the file, or
> creates a new file.
>
>
... | you can simply create a function to do this
```
public static void AppendToFile(string fileToWrite, byte[] DT)
{
using (FileStream FS = new FileStream(fileToWrite, File.Exists(fileToWrite) ? FileMode.Append : FileMode.OpenOrCreate, FileAccess.Write)) {
FS.Write(DT, 0, DT.Length);
FS.Close();
}
... |
6,862,369 | I suppose this is more or less trivial thing but here it goes...
I have few relational tables and I'm trying to retrieve rows depending on 2 values. Here's my query so far:
```
SELECT `inventory`.*, `tags`.*, `tags_inv`.*, `categories`.*, `categories_inv`.*
FROM (`tags`)
LEFT JOIN `tags_inv` ON `tags_inv`.`tag_id` = ... | 2011/07/28 | [
"https://Stackoverflow.com/questions/6862369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175793/"
] | You can also use the built-in `FileSystem.WriteAllBytes Method (String, Byte[], Boolean)`.
```
public static void WriteAllBytes(
string file,
byte[] data,
bool append
)
```
Set append to **True** to append to the file contents; **False** to overwrite the file contents. Default is False. | you can simply create a function to do this
```
public static void AppendToFile(string fileToWrite, byte[] DT)
{
using (FileStream FS = new FileStream(fileToWrite, File.Exists(fileToWrite) ? FileMode.Append : FileMode.OpenOrCreate, FileAccess.Write)) {
FS.Write(DT, 0, DT.Length);
FS.Close();
}
... |
30,046,894 | I need the sessions in my web application not to timeout. They should be there until the user log out manually. It might be a bad call but I must implement it.
I tried the below in web.xml
```
<session-config>
<session-timeout>
-1
</session-timeout>
</session-config>
```
However the ... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30046894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1379286/"
] | You can do this too :
```
<session-config>
<session-timeout>0</session-timeout>
</session-config>
```
You can see how it works just [here](https://stackoverflow.com/questions/15382895/session-timeout-in-web-xml) | use a HttpSessionListener. In the sessionCreated() method, you can set the session timeout programmatically.
```
public class MyHttpSessionListener implements HttpSessionListener{
public void sessionCreated(HttpSessionEvent event){
event.getSession().setMaxInactiveInterval(-1); //in seconds
}
public void ses... |
30,046,894 | I need the sessions in my web application not to timeout. They should be there until the user log out manually. It might be a bad call but I must implement it.
I tried the below in web.xml
```
<session-config>
<session-timeout>
-1
</session-timeout>
</session-config>
```
However the ... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30046894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1379286/"
] | I want to advise *against* setting an infinite Session Timeout. It is a very bad call, as this is one certain way to implement a Memory Leak. As a result you will have an ever growing set of 'active' sessions. Each of them have the potential to store a considerable amount of data in Session Attributes. Each of them can... | use a HttpSessionListener. In the sessionCreated() method, you can set the session timeout programmatically.
```
public class MyHttpSessionListener implements HttpSessionListener{
public void sessionCreated(HttpSessionEvent event){
event.getSession().setMaxInactiveInterval(-1); //in seconds
}
public void ses... |
30,046,894 | I need the sessions in my web application not to timeout. They should be there until the user log out manually. It might be a bad call but I must implement it.
I tried the below in web.xml
```
<session-config>
<session-timeout>
-1
</session-timeout>
</session-config>
```
However the ... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30046894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1379286/"
] | You can do this too :
```
<session-config>
<session-timeout>0</session-timeout>
</session-config>
```
You can see how it works just [here](https://stackoverflow.com/questions/15382895/session-timeout-in-web-xml) | In web.xml define the following
```
<session-config>
<session-timeout>-1</session-timeout>
</session-config>
```
which has the same effect as the code posted above and will apply to all sessions for that web-app. |
30,046,894 | I need the sessions in my web application not to timeout. They should be there until the user log out manually. It might be a bad call but I must implement it.
I tried the below in web.xml
```
<session-config>
<session-timeout>
-1
</session-timeout>
</session-config>
```
However the ... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30046894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1379286/"
] | I want to advise *against* setting an infinite Session Timeout. It is a very bad call, as this is one certain way to implement a Memory Leak. As a result you will have an ever growing set of 'active' sessions. Each of them have the potential to store a considerable amount of data in Session Attributes. Each of them can... | In web.xml define the following
```
<session-config>
<session-timeout>-1</session-timeout>
</session-config>
```
which has the same effect as the code posted above and will apply to all sessions for that web-app. |
30,046,894 | I need the sessions in my web application not to timeout. They should be there until the user log out manually. It might be a bad call but I must implement it.
I tried the below in web.xml
```
<session-config>
<session-timeout>
-1
</session-timeout>
</session-config>
```
However the ... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30046894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1379286/"
] | You can do this too :
```
<session-config>
<session-timeout>0</session-timeout>
</session-config>
```
You can see how it works just [here](https://stackoverflow.com/questions/15382895/session-timeout-in-web-xml) | You can also use the following:
```
HttpSession session = request.getSession();
session.setMaxInactiveInterval(0);
```
or
```
HttpSession session = request.getSession();
session.setMaxInactiveInterval(-1);
```
 |
30,046,894 | I need the sessions in my web application not to timeout. They should be there until the user log out manually. It might be a bad call but I must implement it.
I tried the below in web.xml
```
<session-config>
<session-timeout>
-1
</session-timeout>
</session-config>
```
However the ... | 2015/05/05 | [
"https://Stackoverflow.com/questions/30046894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1379286/"
] | I want to advise *against* setting an infinite Session Timeout. It is a very bad call, as this is one certain way to implement a Memory Leak. As a result you will have an ever growing set of 'active' sessions. Each of them have the potential to store a considerable amount of data in Session Attributes. Each of them can... | You can also use the following:
```
HttpSession session = request.getSession();
session.setMaxInactiveInterval(0);
```
or
```
HttpSession session = request.getSession();
session.setMaxInactiveInterval(-1);
```
 |
33,200,888 | I'm Trying to set up my front-end build system with brunch but have an annoying issue that whatever I do brunch ignores *bower\_components* folder and doesn't process anything in it.
this is my brunch-config.coffee file
```
module.exports = config:
files:
javascripts:
joinTo:
... | 2015/10/18 | [
"https://Stackoverflow.com/questions/33200888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1309013/"
] | [tl;dr Jsfiddle](http://jsfiddle.net/Darker/c79fyymd/1/)
--------------------------------------------------------
The data type of `moveTo` and `lineTo` paramteters is [`unrestricted double`](http://www.w3.org/TR/WebIDL/#idl-unrestricted-double). You can see that it's 32bit floating point number, presumably signed. Th... | Let's say we have a `canvas.height = 500` and `canvas.width = 500` and we want to prevent the coords to be within the range `0 to 500`. We can use those properties to set a range when the context is called using a `function()`.
```
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
... |
2,538,818 | Consider integer x, such that $100 \le x \le 999$
Reshuffle the digits of x and call it y.
Find $\vert x-y\vert$, call each digit of this new 3 digit integer; a, b, and c.
Then any 1 of three digits can be found if we are told 2 of them by $a+b+c \equiv0(\mod 9)$
For example: $x = 314$, reshuffle; $y = 134$.
$\ver... | 2017/11/27 | [
"https://math.stackexchange.com/questions/2538818",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/380538/"
] | Let $x= x\_1\*100+x\_2\*10+x\_3$ and $y $ has the same digits but as the coefficients of different powers of $10$. So $y=x\_1\*10^i+x\_2\*10^j+x\_3\*10^k $ where $\{i,j,k\}=\{0,1,2\} $.
So $x-y= x\_1\*(100-10^i)+x\_2\*(10-10^j)+x\_3\*(1-10^k) $.
It's well-known and easy to prove that $9$ divides $10^m-10^n $ for all ... | It comes from the [divisibility test for $9$](https://en.wikipedia.org/wiki/Divisibility_rule#Divisibility_by_3_or_9). To find the remainder on division by $9$ add the digits. If the sum is $10$ or greater add the digits again. Keep going until you get to a single digit. That will be the remainider, except that if the ... |
2,030,523 | Honestly I have no idea where to start and It'd be so nice if someone provided me with a step by step explanation , Thank you !
1) $\neg q \rightarrow \neg p \equiv p \rightarrow q$
2) $p \lor (p \land q) \equiv p$
3) $(p \lor q) \land \neg p = \neg p \land q$ | 2016/11/25 | [
"https://math.stackexchange.com/questions/2030523",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/393062/"
] | Since $\mathbf{A}\_{k\times n}$ is a k by n matrix ,through your way of picking $X\_{ij}$ :
$$\Pr\left[X\_{ij}=1| j \_ {fixed}\right]=\dfrac{1}{n}$$
And there will be k one's in your Matrix $$\mathbf{X}=[X\_{ij}]$$
So,
\begin{align}\mathbb{E}\left[X\_j\right]&=\sum\_{j=1}^n\mathbb{E}\left[X\_{ij}\right]\\&=\frac{k}{n... | Symetry arguments are nice (!). Here, $X\_{ij}=1$ for row-maximums. Assuming an i.i.d. continuous source distribution, there is a single row-maximum per row, for a total of $k$ row-maximums for the whole matrix; i.e.
$$
\sum\_{i,j}X\_{ij}=\sum\_{i}X\_i=k \rightarrow \sum\_{i}E(X\_i)=k.
$$
As symetry tells us that $E(X\... |
43,287,029 | I am loading data from the controller and displaying in view as a list of clickable items in HTML. When selected i want to call a method in the controller to perform some logic.
```
items.push("<li><a href='#' ng-click='choosePostcode(" + result.postcode + ");return false;'>" + result.postcode + "</a></li>");
```
... | 2017/04/07 | [
"https://Stackoverflow.com/questions/43287029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7200639/"
] | >
> It is obviously looking for the file in the same directory as the launcher`
>
>
>
No, that is not the case. The actual mechanism is that is uses the directory where the JAR file with the runtime classes is located. If you put `i4jruntime.jar` into the classpath yourself, then it may use a wrong directory. | If you want to exclude the Install4j runtime library from the GUI, here is how I did it:
[](https://i.stack.imgur.com/IMxiV.png) |
23,247,791 | i have written following stored procedure:
in which there are 2 tables arts and artist.artistId is a foreign key in arts table.
```
create procedure spInsertArts(
@artsId int out,
@name varchar(50),
@category varchar(50),
@artistId int
)
as
begin
declare @artistId in... | 2014/04/23 | [
"https://Stackoverflow.com/questions/23247791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3202311/"
] | There are issue in `config.xml path`
it Should be
```
app/code/local/Emm/Sales/etc/config.xml
```
from `app/code/local/Emm/etc/config.xml`
Also Need to modify config.xml
```
<?xml version="1.0" ?>
<config>
<modules>
<Emm_Sales>
<version>1.0.0</version>
</Emm_Sales>
</modules>
... | Try changing your /app/code/local/Emm/etc/config.xml file.
Change the tag history by order\_history
```
<?xml version="1.0"?>
<config>
<global>
<blocks>
<sales>
<rewrite>
<order_history>Emm_Sales_Block_Order_History</order_history>
</rewri... |
23,247,791 | i have written following stored procedure:
in which there are 2 tables arts and artist.artistId is a foreign key in arts table.
```
create procedure spInsertArts(
@artsId int out,
@name varchar(50),
@category varchar(50),
@artistId int
)
as
begin
declare @artistId in... | 2014/04/23 | [
"https://Stackoverflow.com/questions/23247791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3202311/"
] | The error is in /app/etc/modules/Emm\_Sales.xml file. XML tags are case sensitive, so you need to write codePool with capital letter, like this:
```
<?xml version="1.0"?>
<config>
<modules>
<Emm_Sales>
<active>true</active>
<codePool>local</codePool>
</Emm_Sales>
</modu... | Try changing your /app/code/local/Emm/etc/config.xml file.
Change the tag history by order\_history
```
<?xml version="1.0"?>
<config>
<global>
<blocks>
<sales>
<rewrite>
<order_history>Emm_Sales_Block_Order_History</order_history>
</rewri... |
5,246,853 | Easy question, I have a stack panel with a toolbar and listbox, I want the listbox to fill the remaining space, but it won't. Here's what I have at the moment.
```
<Window x:Class="TestClientMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winf... | 2011/03/09 | [
"https://Stackoverflow.com/questions/5246853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518551/"
] | Try using a `DockPanel`, with the `ToolBar` docked to the top or bottom and the `LastChildFill` property on the `DockPanel` set to `true`.
```
<DockPanel Name="dockPanel1" LastChildFill="True">
<ToolBar Height="26" Name="toolBar1" DockPanel.Dock="Top"/>
<ListBox Name="listBox1" MinHeight="{Binding ElementName=... | A StackPanel will not be easily convinced to do what you want.
I would use a Grid instead. |
5,246,853 | Easy question, I have a stack panel with a toolbar and listbox, I want the listbox to fill the remaining space, but it won't. Here's what I have at the moment.
```
<Window x:Class="TestClientMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winf... | 2011/03/09 | [
"https://Stackoverflow.com/questions/5246853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518551/"
] | Try using a `DockPanel`, with the `ToolBar` docked to the top or bottom and the `LastChildFill` property on the `DockPanel` set to `true`.
```
<DockPanel Name="dockPanel1" LastChildFill="True">
<ToolBar Height="26" Name="toolBar1" DockPanel.Dock="Top"/>
<ListBox Name="listBox1" MinHeight="{Binding ElementName=... | Use DockPanel instead of StackPanel and set LastChildFill attribute to true. That should do the trick. |
5,246,853 | Easy question, I have a stack panel with a toolbar and listbox, I want the listbox to fill the remaining space, but it won't. Here's what I have at the moment.
```
<Window x:Class="TestClientMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winf... | 2011/03/09 | [
"https://Stackoverflow.com/questions/5246853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518551/"
] | Try using a `DockPanel` instead of a `StackPanel`. That way you can set `LastChildFill` to true and your `ListBox`, being the last contained element, will stretch to fill up its remaining space:
```
<DockPanel LastChildFill="True" HorizontalAlignment="Stretch" Name="dockPanel1" VerticalAlignment="Stretch">
<ToolBa... | Try using a `DockPanel`, with the `ToolBar` docked to the top or bottom and the `LastChildFill` property on the `DockPanel` set to `true`.
```
<DockPanel Name="dockPanel1" LastChildFill="True">
<ToolBar Height="26" Name="toolBar1" DockPanel.Dock="Top"/>
<ListBox Name="listBox1" MinHeight="{Binding ElementName=... |
5,246,853 | Easy question, I have a stack panel with a toolbar and listbox, I want the listbox to fill the remaining space, but it won't. Here's what I have at the moment.
```
<Window x:Class="TestClientMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winf... | 2011/03/09 | [
"https://Stackoverflow.com/questions/5246853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518551/"
] | Use DockPanel instead of StackPanel and set LastChildFill attribute to true. That should do the trick. | A StackPanel will not be easily convinced to do what you want.
I would use a Grid instead. |
5,246,853 | Easy question, I have a stack panel with a toolbar and listbox, I want the listbox to fill the remaining space, but it won't. Here's what I have at the moment.
```
<Window x:Class="TestClientMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winf... | 2011/03/09 | [
"https://Stackoverflow.com/questions/5246853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518551/"
] | Try using a `DockPanel` instead of a `StackPanel`. That way you can set `LastChildFill` to true and your `ListBox`, being the last contained element, will stretch to fill up its remaining space:
```
<DockPanel LastChildFill="True" HorizontalAlignment="Stretch" Name="dockPanel1" VerticalAlignment="Stretch">
<ToolBa... | A StackPanel will not be easily convinced to do what you want.
I would use a Grid instead. |
5,246,853 | Easy question, I have a stack panel with a toolbar and listbox, I want the listbox to fill the remaining space, but it won't. Here's what I have at the moment.
```
<Window x:Class="TestClientMainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winf... | 2011/03/09 | [
"https://Stackoverflow.com/questions/5246853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/518551/"
] | Try using a `DockPanel` instead of a `StackPanel`. That way you can set `LastChildFill` to true and your `ListBox`, being the last contained element, will stretch to fill up its remaining space:
```
<DockPanel LastChildFill="True" HorizontalAlignment="Stretch" Name="dockPanel1" VerticalAlignment="Stretch">
<ToolBa... | Use DockPanel instead of StackPanel and set LastChildFill attribute to true. That should do the trick. |
66,892,115 | I've a problem where i can't get `POST` from `html`
**Log:**
```
127.0.0.1 - - [01/Apr/2021 00:51:25] "←[37mGET /main?user=adasd&pass=123123 HTTP/1.1←[0m" 200 -
127.0.0.1 - - [01/Apr/2021 00:51:25] "←[36mGET /static/css/index.css HTTP/1.1←[0m" 304 -
127.0.0.1 - - [01/Apr/2021 00:51:25] "←[36mGET /static/js/index.js ... | 2021/03/31 | [
"https://Stackoverflow.com/questions/66892115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10613167/"
] | You can use Element.remove() in a loop
```js
const uls = document.querySelectorAll('#custom_description_video > ul')
uls.forEach(el => el.remove())
```
```html
<div id="custom_description_video">
<div>Some div</div>
<div>Another div</div>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<ul>... | Here is another approach to remove all child tag elements:
```
var parentElement = document.getElementById('custom_description_video');
Array.prototype.slice.call(parentElement.getElementsByTagName('ul')).forEach(function(item) { item.parentNode.removeChild(item); } );
``` |
37,727,391 | Hello guys I'm new in here. I have a little problem this my `HomeController` and I will do Get and Create with web API but I can't find and write a Edit / Details and Delete.
```
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
List<Product1Model> lst =new List... | 2016/06/09 | [
"https://Stackoverflow.com/questions/37727391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6445616/"
] | You can use `ng-show` somthing like :
```
<td class="item-row-quote">
<span ng-show = "item.unit != null" class="quote-price-text" ng-model="row.dollarPerUnitText" id="dollarPerUnit">{{ '$/' + item.unit }}</span></td>
```
I hope that this is what you mean by `nothing` it is not clear. | If you have one or two properties that may have null, then you can update them with empty strings in the controller.
```
DefaultController.$inject = ['$http'];
function DefaultController($http) {
var vm = this;
vm.item;
function getItem() {
var config = {
transformResponse: function(d... |
35,840,546 | Here i need get a value from JavaScript object, if the first 8 digits of property is matched with argument.
Here is what I'm tried...
```
var input = { 4546546512349: {}, 7200000000007: {}, 9399543200000: {} }
function find_key(query){
$.each(input, function(k, v) {
if (k.substring(0,8) == query){
console... | 2016/03/07 | [
"https://Stackoverflow.com/questions/35840546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5829971/"
] | A solution with [`Array#filter()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). It returns an array with the matched keys.
```js
function findKey(query) {
return Object.keys(input).filter(function (k) {
return k.substring(0, 8) == query;
});
}
va... | Your code already works, but if you are looking for a more concise solution then
```
function find_key(input,query)
{
return input[Object.keys(input).filter( function(value){ if (value.indexOf( "45465465" ) == 0) {return value;}})[0]];
}
var input = { 4546546512349: {}, 7200000000007: {}, 9399543200000: {} };
fin... |
74,408,136 | Hello I have a project for my studies which is to display data on a dashboard that will be more or less modifiable by the user according to his needs.
I'm trying to open a modal window but it doesn't work and i can't figure out where my mistake came from.
```js
const body = document.querySelector("body"),
sidebar =... | 2022/11/11 | [
"https://Stackoverflow.com/questions/74408136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19930293/"
] | Adding to the earlier answer, the modal window doesn't close on clicking the close button. It only closes by clicking outside of it. This should solve it all: remove the modal-trigger class in the overlay class. It should be `<div class="overlay">` not `<div class="overlay modal-trigger">` and for demonstration, I chan... | It should be working now, remember that `querySelector()` only grab the first match, you should use `querySelectorAll()` method instead, that is iterable and grabs all elements that match.
```js
const body = document.querySelector("body"),
sidebar = body.querySelector(".sidebar"),
btn = body.querySelector("#btn");... |
43,795,994 | i'm using spring boot and my index.html is in src/main/resources/templates directory and below is the content. If i render a static content from html itself it renders but when i try to render from react component it doesn't render anything
```
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<meta char... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43795994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7966465/"
] | Well, for all time-related operations, PHP expects you to set a `default` timezone (otherwise warnings are given). However, I think you're simply looking for a formatting operation.
```
<?php
date_default_timezone_set("UTC");
$source = "Mon Apr 03 00:50:15 CST 2017";
$dateOb = new DateTime($source);
print_r($dateOb);
... | you can use `date_format` if you only want to format your date.
```
$date=date_create("Mon Apr 03 00:50:15 CST 2017");
echo date_format($date,"Y-m-d H:i:s");
``` |
43,795,994 | i'm using spring boot and my index.html is in src/main/resources/templates directory and below is the content. If i render a static content from html itself it renders but when i try to render from react component it doesn't render anything
```
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
<meta char... | 2017/05/05 | [
"https://Stackoverflow.com/questions/43795994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7966465/"
] | Well, for all time-related operations, PHP expects you to set a `default` timezone (otherwise warnings are given). However, I think you're simply looking for a formatting operation.
```
<?php
date_default_timezone_set("UTC");
$source = "Mon Apr 03 00:50:15 CST 2017";
$dateOb = new DateTime($source);
print_r($dateOb);
... | You need to set your desired timezone to be used by all date/time functions by setting your timezone identifier using `date_default_timezone_set('parameter');`. Find the list of supported timezones at <http://php.net/manual/en/timezones.php>. And then use `date_default_timezone_get();` to get your given timezone
```
... |
10,059,169 | I'ver wondered, why is it that in front of an NSError, such as below, do we put: `&error` and not `error`?
E.g.
```
NSArray *result = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
```
Hope you can explain, also is this always the way or only in certain situations this is needed? Thanks. | 2012/04/07 | [
"https://Stackoverflow.com/questions/10059169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427292/"
] | You need to take the address of `error` because the function needs to modify it. `error` is passed *by pointer*, so you need the "take address" operator `&` for it.
C and Objective-C pass parameters *by value*. If you pass `error` without an ampersand and the method that you call modifies it, your function that made t... | The `error` parameter's type is `(NSError **)`, that is a pointer to a pointer to an NSError. The `error` variable that you use as the argument is probably declared as `NSError *`, so in order to get the types to match properly, you have to use the address of operator to get a pointer to a pointer (`&error`). The reaso... |
10,059,169 | I'ver wondered, why is it that in front of an NSError, such as below, do we put: `&error` and not `error`?
E.g.
```
NSArray *result = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
```
Hope you can explain, also is this always the way or only in certain situations this is needed? Thanks. | 2012/04/07 | [
"https://Stackoverflow.com/questions/10059169",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/427292/"
] | You need to take the address of `error` because the function needs to modify it. `error` is passed *by pointer*, so you need the "take address" operator `&` for it.
C and Objective-C pass parameters *by value*. If you pass `error` without an ampersand and the method that you call modifies it, your function that made t... | Essentially, the root of the issue is a hack for wanting to return a second (optional) object.
How can we do this, as we can only return one thing? Well, we could return some sort of `(return_value, error)` tuple, but that's a bit unwieldy. We can have as many parameters as we like though, can we do something with tho... |
6,746,175 | I am dealing with html writen long time ago and there is a problem with FireFox.
Some tr elements have position property set to relative , which surprisingly makes the border of those tr's invisble. When I remove the style, it all works fine... so the question is:
"**How does position:relative affect tr element?*... | 2011/07/19 | [
"https://Stackoverflow.com/questions/6746175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445190/"
] | I'm also not entirely sure without seeing code, but:
From the spec: <http://www.w3.org/TR/CSS21/visuren.html#propdef-position>
>
> The effect of 'position:relative' on table-row-group,
> table-header-group, table-footer-group, **table-row,** table-column-group,
> table-column, table-cell, and table-caption element... | The interaction is probably that position:relative is disabling the border-collapse property. Of course, without seeing any code, it's pretty difficult to tell.
Update: If you look at your code you will see that the tr in question never has a border of its own. Setting `position: relative` affects display on the `th` ... |
6,746,175 | I am dealing with html writen long time ago and there is a problem with FireFox.
Some tr elements have position property set to relative , which surprisingly makes the border of those tr's invisble. When I remove the style, it all works fine... so the question is:
"**How does position:relative affect tr element?*... | 2011/07/19 | [
"https://Stackoverflow.com/questions/6746175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445190/"
] | The interaction is probably that position:relative is disabling the border-collapse property. Of course, without seeing any code, it's pretty difficult to tell.
Update: If you look at your code you will see that the tr in question never has a border of its own. Setting `position: relative` affects display on the `th` ... | Use transform instead of position:
```
.header {
transform: translateY(2px);
}
``` |
6,746,175 | I am dealing with html writen long time ago and there is a problem with FireFox.
Some tr elements have position property set to relative , which surprisingly makes the border of those tr's invisble. When I remove the style, it all works fine... so the question is:
"**How does position:relative affect tr element?*... | 2011/07/19 | [
"https://Stackoverflow.com/questions/6746175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/445190/"
] | I'm also not entirely sure without seeing code, but:
From the spec: <http://www.w3.org/TR/CSS21/visuren.html#propdef-position>
>
> The effect of 'position:relative' on table-row-group,
> table-header-group, table-footer-group, **table-row,** table-column-group,
> table-column, table-cell, and table-caption element... | Use transform instead of position:
```
.header {
transform: translateY(2px);
}
``` |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | You can use `GNU find`:
```
find . -maxdepth 1 -exec grep -q stringA {} \; -exec grep -q stringB {} \; \
-printf '%10s %p\n' |
sort -n
``` | ```
egrep -l '(stringA|stringB)' * | xargs ls -1S
```
`egrep` allows for regular expressions, so the above will search for stringA OR stringB in all files, the `-l` option tells egrep to just output the files matched (and supress the output of the matching lines). Piping it to `xargs ls -1S` will pass all the files ... |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | You can use `GNU find`:
```
find . -maxdepth 1 -exec grep -q stringA {} \; -exec grep -q stringB {} \; \
-printf '%10s %p\n' |
sort -n
``` | Using [perl](/questions/tagged/perl "show questions tagged 'perl'") (portable and no problem with space in filenames) :
```
perl -Mautodie -wle '
for (<"*.txt">) {
open my $fh, "<", $_;
my @list = <$fh>;
close $fh;
if (grep { /stringA/ } @list and grep { /stringB/ } @list) {
... |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | You can use `GNU find`:
```
find . -maxdepth 1 -exec grep -q stringA {} \; -exec grep -q stringB {} \; \
-printf '%10s %p\n' |
sort -n
``` | ### Method #1
You could use the following chain:
```
$ grep -l stringA * | tr '\n' '\0' | xargs -0 grep -l stringB | xargs du | sort -nr
```
The `tr` converts the output of `grep` so that if any filenames include spaces they'll be protected going forward. Everything else is pretty straight-forward. The use of `xarg... |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | You can use `GNU find`:
```
find . -maxdepth 1 -exec grep -q stringA {} \; -exec grep -q stringB {} \; \
-printf '%10s %p\n' |
sort -n
``` | With `zsh` and GNU tools:
```
grep -lZ -- stringA *.txt(oL) | xargs -r0 grep -l -- stringB
``` |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | Using [perl](/questions/tagged/perl "show questions tagged 'perl'") (portable and no problem with space in filenames) :
```
perl -Mautodie -wle '
for (<"*.txt">) {
open my $fh, "<", $_;
my @list = <$fh>;
close $fh;
if (grep { /stringA/ } @list and grep { /stringB/ } @list) {
... | ```
egrep -l '(stringA|stringB)' * | xargs ls -1S
```
`egrep` allows for regular expressions, so the above will search for stringA OR stringB in all files, the `-l` option tells egrep to just output the files matched (and supress the output of the matching lines). Piping it to `xargs ls -1S` will pass all the files ... |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | ### Method #1
You could use the following chain:
```
$ grep -l stringA * | tr '\n' '\0' | xargs -0 grep -l stringB | xargs du | sort -nr
```
The `tr` converts the output of `grep` so that if any filenames include spaces they'll be protected going forward. Everything else is pretty straight-forward. The use of `xarg... | ```
egrep -l '(stringA|stringB)' * | xargs ls -1S
```
`egrep` allows for regular expressions, so the above will search for stringA OR stringB in all files, the `-l` option tells egrep to just output the files matched (and supress the output of the matching lines). Piping it to `xargs ls -1S` will pass all the files ... |
85,731 | I am in a folder with lots of `.txt` file, I would like to find all the files which contain both `stringA` and `stringB` (not necessarily on the same line), then list these files in the order of the size (from small to big)
I have tried the follows, but it doesn't work:
```
ls -lS | for f in *; do grep -q stringA $f ... | 2013/08/06 | [
"https://unix.stackexchange.com/questions/85731",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/44648/"
] | With `zsh` and GNU tools:
```
grep -lZ -- stringA *.txt(oL) | xargs -r0 grep -l -- stringB
``` | ```
egrep -l '(stringA|stringB)' * | xargs ls -1S
```
`egrep` allows for regular expressions, so the above will search for stringA OR stringB in all files, the `-l` option tells egrep to just output the files matched (and supress the output of the matching lines). Piping it to `xargs ls -1S` will pass all the files ... |
62,070,007 | I have to dataframe that I want to merge on the date, id and time variable in order to compute a duration.
```
from numpy import *
from pandas import *
df1 = DataFrame({
'id': ['a']*4,
'date': ['02-02-2015']*4,
'time_1': ['08:00:00', '09:00:00', '10:30:00', '12:45']})
df1
id date time
0 a 02-02-2015... | 2020/05/28 | [
"https://Stackoverflow.com/questions/62070007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12999640/"
] | Using different merge methods, came to the same answer. Eventually used `merge_as0f` `direction =backward` as per your request. Unfortunately not similar to yours in the sense that I have no NaN. Happy to help furtherif you gave information on how you end up with NaN in one row.
```
#Join dateto time and coerce to... | Using the solution suggested by @wwnde, I've found one that scales better to my real data set:
```
import numpy as np
import pandas as pd
df1 = DataFrame({
'id': ['a']*4,
'date': ['02-02-2015']*4,
'time_1': ['08:00:00', '09:00:00', '10:30:00', '12:45:00']
})
df2 = DataFrame({
'id': ['a']*7,
'date... |
45,744,159 | I am trying to create the HTTPClient for building a framework using Apache HTTPClient in Java for REST webservices.
Here I found that we can create the client using the below two ways. I want to know the difference between them.
1.HTTPCLientBuilder.create().build()
2.HTTPClients.custom().build() | 2017/08/17 | [
"https://Stackoverflow.com/questions/45744159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | The answer is on SO, just a bit hidden. Reposting euphoria99's answer from this [question](https://stackoverflow.com/questions/21574478/what-is-the-difference-between-closeablehttpclient-and-httpclient-in-apache-http):
```
HttpClient (interface)
implemented by:
CloseableHttpClient - ThreadSafe.
DefaultHttpClient - ... | If you look at the source of `HttpClients` you will see:
```
/**
* Creates builder object for construction of custom
* {@link CloseableHttpClient} instances.
*/
public static HttpClientBuilder custom() {
return HttpClientBuilder.create();
}
```
So, to answer the question, the only difference is one extra call... |
32,934 | I have read/played a couple of "Choose your own adventure"-style book and am interested in the process of creating one.
**Where can I find (preferrably free) online resources, such as *How-To-Write* or styleguide articles and blogs, about writing a "Choose your own adventure"-style books?**
The main reason for askin... | 2018/02/01 | [
"https://writers.stackexchange.com/questions/32934",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/23159/"
] | The original books always used the second person 'you'. (I still have one on my book shelf.) Other variations may use the first person.
There are many variations on the theme. For example, some require you to keep track of health, supplies, etc. whereas with others all you do is turn the pages. Some require dice. Othe... | It's worth noting that "[Choose Your Own Adventure](https://en.wikipedia.org/wiki/Choose_Your_Own_Adventure)" is a specific brand of children's novelty "gamebooks," and that nearly all books written in this format are released under that brand. It's not --at least to my knowledge --a viable sub-genre outside the brand.... |
32,934 | I have read/played a couple of "Choose your own adventure"-style book and am interested in the process of creating one.
**Where can I find (preferrably free) online resources, such as *How-To-Write* or styleguide articles and blogs, about writing a "Choose your own adventure"-style books?**
The main reason for askin... | 2018/02/01 | [
"https://writers.stackexchange.com/questions/32934",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/23159/"
] | The blogger **These Heterogenous Tasks** has been writing his analysis on specific **CYOA** books, and general observations about their history, trends, and common structure.
<https://heterogenoustasks.wordpress.com/category/cyoa/>
One article in particular is often cited by other writers:
[**Standard Patterns in Cho... | It's worth noting that "[Choose Your Own Adventure](https://en.wikipedia.org/wiki/Choose_Your_Own_Adventure)" is a specific brand of children's novelty "gamebooks," and that nearly all books written in this format are released under that brand. It's not --at least to my knowledge --a viable sub-genre outside the brand.... |
32,934 | I have read/played a couple of "Choose your own adventure"-style book and am interested in the process of creating one.
**Where can I find (preferrably free) online resources, such as *How-To-Write* or styleguide articles and blogs, about writing a "Choose your own adventure"-style books?**
The main reason for askin... | 2018/02/01 | [
"https://writers.stackexchange.com/questions/32934",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/23159/"
] | The original books always used the second person 'you'. (I still have one on my book shelf.) Other variations may use the first person.
There are many variations on the theme. For example, some require you to keep track of health, supplies, etc. whereas with others all you do is turn the pages. Some require dice. Othe... | FYI, there is a gaming company called [Choice of Games](https://www.choiceofgames.com/). They have quite a number of these CYOA games available on the web and for tablets, etc. The really useful part is that they have a tool that is free for authors to use to create their own stories. This may or may not be useful for ... |
32,934 | I have read/played a couple of "Choose your own adventure"-style book and am interested in the process of creating one.
**Where can I find (preferrably free) online resources, such as *How-To-Write* or styleguide articles and blogs, about writing a "Choose your own adventure"-style books?**
The main reason for askin... | 2018/02/01 | [
"https://writers.stackexchange.com/questions/32934",
"https://writers.stackexchange.com",
"https://writers.stackexchange.com/users/23159/"
] | The blogger **These Heterogenous Tasks** has been writing his analysis on specific **CYOA** books, and general observations about their history, trends, and common structure.
<https://heterogenoustasks.wordpress.com/category/cyoa/>
One article in particular is often cited by other writers:
[**Standard Patterns in Cho... | FYI, there is a gaming company called [Choice of Games](https://www.choiceofgames.com/). They have quite a number of these CYOA games available on the web and for tablets, etc. The really useful part is that they have a tool that is free for authors to use to create their own stories. This may or may not be useful for ... |
52,642,515 | I'm trying to modify a multidimensional array inside a foreach loop using a function.
However when I check my results with a print\_r() the outcome is not what I want it to be and I'm not receiving any errors either.
```
foreach ($layoutData as $key => $data) {
$method = $data[ 'acf_fc_layout' ];
... | 2018/10/04 | [
"https://Stackoverflow.com/questions/52642515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9253624/"
] | Try this one, I think it needs to be override but overriding is not a good practice.
I hope this helps
```
.mCSB_dragger_bar{
width:13px!important;
}
```
and if you want the scroll knob to also adjust its width you may also override
```
.mCSB_draggerRail{
width:13px!important;
}
``` | Add below css and you're all set... Check now...
```
.mCS-dark-3.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar {
width: 10px !important;
}
```
Note: Change width as per your requirement. |
52,642,515 | I'm trying to modify a multidimensional array inside a foreach loop using a function.
However when I check my results with a print\_r() the outcome is not what I want it to be and I'm not receiving any errors either.
```
foreach ($layoutData as $key => $data) {
$method = $data[ 'acf_fc_layout' ];
... | 2018/10/04 | [
"https://Stackoverflow.com/questions/52642515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9253624/"
] | Try this one, I think it needs to be override but overriding is not a good practice.
I hope this helps
```
.mCSB_dragger_bar{
width:13px!important;
}
```
and if you want the scroll knob to also adjust its width you may also override
```
.mCSB_draggerRail{
width:13px!important;
}
``` | Add the Below styles to your stylesheet
```
.mCS-dark-3.mCSB_scrollTools .mCSB_draggerRail{
width:15px !important;
}
.mCS-dark-3.mCSB_scrollTools .mCSB_dragger .mCSB_dragger_bar{
width:15px !important;
}
``` |
31,510,624 | Below are my environment settings
* SQL Server 2008 R2
* ASP.NET MVC
* Entity Framework
In my application I want to do post processing of transaction after they are inserted in database. So basically I want a separate application to be listening to database events, and whenever a new row is created in table `Orders`... | 2015/07/20 | [
"https://Stackoverflow.com/questions/31510624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2567548/"
] | You have to specifically tell the webpage to execute your function when it's loaded.
Instead of returning the string I believe you'd like to write it in the body of the webpage.
This is a simple way to do so :
```
<html>
<head>
<script>
var myFunction = function(){
document.bo... | Try this
```
<html>
<head>
</head>
<body onload='myFunction()'>
<script type="text/javascript">
var myFunction = function(){
return "hello world";
}
</script>
</body>
</html>
``` |
31,510,624 | Below are my environment settings
* SQL Server 2008 R2
* ASP.NET MVC
* Entity Framework
In my application I want to do post processing of transaction after they are inserted in database. So basically I want a separate application to be listening to database events, and whenever a new row is created in table `Orders`... | 2015/07/20 | [
"https://Stackoverflow.com/questions/31510624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2567548/"
] | You have to specifically tell the webpage to execute your function when it's loaded.
Instead of returning the string I believe you'd like to write it in the body of the webpage.
This is a simple way to do so :
```
<html>
<head>
<script>
var myFunction = function(){
document.bo... | ```
<html>
<head>
</head>
<body>
<Script>
function myFunction(){
document.write("hello");
}
</script>
<Script>
myFunction();
</Script>
</body>
</html>
```
This was asked already
[How to call a javascript function within an HTML body](https://stackoverflow.com/questions/19869639/how-to-call-a-javascript... |
2,262,244 | This is a specific equation of course. It is an example. I am not sure if this was a mistake in the lecture series or some exotic way that I have not the smarts to figure out. Usually it is something like
$$r = (x,y,z) + t(x\_0,y\_0,z\_0)$$
The first vector being a position vector and the second vector being the dir... | 2017/05/02 | [
"https://math.stackexchange.com/questions/2262244",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/347779/"
] | For sure it can.
For example, take two points in space $P\_1$ and $P\_2$, if we construct a line that joins them and choose one parameter $t$, for convenience that ranges $[0,1]$. And impose that for $t=0$ we must obtain point $P\_1$ and for $t=1$ we must obtain the other, we can write without any loss of generality t... | There are many different ways to represent 3D lines.
What you have here is a parametric form of the line representing all the points given a parameter $t \in \mathbb{R}$
* The linear interpolation between two points
$$ {\bf r} = (1-t)\, {\bf r}\_1 + t\, {\bf r}\_2 $$
* Or you can look at a point and direction
$$ {... |
6,265,136 | I'm having a little trouble with a SQL query, and thought I'd solicit the wisdom of the crowd to see what I'm missing. I'm pretty sure the below works, but it seems really poor and I'm wondering if there's a smarter way (ideally using joins instead of sub-selects) to do this.
**The Problem**
Let's say I have some tab... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6265136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | The question change a bit, so I have redone the answer...
```
SELECT
PrizeId
FROM
(
SELECT
PrizeRule_Map.PrizeId,
PrizeRule_Map.RuleId
FROM
PrizeRule_Map
INNER JOIN
Rule
ON Rule.RuleId = PrizeRule_Map.RuleId
INNER JOIN
Conditional
ON Conditional.RuleId = Rule.RuleID
LEFT J... | Try the following:
```
SELECT Rule.RuleId, Rule.RuleName
FROM Rule
INNER JOIN Conditional ON Rule.RuleId = Conditional.RuleId
Where Conditional.ExpectedValue == true
``` |
6,265,136 | I'm having a little trouble with a SQL query, and thought I'd solicit the wisdom of the crowd to see what I'm missing. I'm pretty sure the below works, but it seems really poor and I'm wondering if there's a smarter way (ideally using joins instead of sub-selects) to do this.
**The Problem**
Let's say I have some tab... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6265136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | To get all `RuleId`s where ALL Conditionals are true:
```
SELECT r.RuleID
FROM Rule r
JOIN Conditional c
ON c.RuleId = r.RuleId
LEFT JOIN Input i
ON i.InputId = c.InputId
GROUP BY r.RuleID
HAVING COUNT( CASE WHEN (c.ExpectedValue=1) AND (i.InputId IS NOT NULL)
OR (c.ExpectedValue=0) AN... | Try the following:
```
SELECT Rule.RuleId, Rule.RuleName
FROM Rule
INNER JOIN Conditional ON Rule.RuleId = Conditional.RuleId
Where Conditional.ExpectedValue == true
``` |
6,265,136 | I'm having a little trouble with a SQL query, and thought I'd solicit the wisdom of the crowd to see what I'm missing. I'm pretty sure the below works, but it seems really poor and I'm wondering if there's a smarter way (ideally using joins instead of sub-selects) to do this.
**The Problem**
Let's say I have some tab... | 2011/06/07 | [
"https://Stackoverflow.com/questions/6265136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/364/"
] | The question change a bit, so I have redone the answer...
```
SELECT
PrizeId
FROM
(
SELECT
PrizeRule_Map.PrizeId,
PrizeRule_Map.RuleId
FROM
PrizeRule_Map
INNER JOIN
Rule
ON Rule.RuleId = PrizeRule_Map.RuleId
INNER JOIN
Conditional
ON Conditional.RuleId = Rule.RuleID
LEFT J... | To get all `RuleId`s where ALL Conditionals are true:
```
SELECT r.RuleID
FROM Rule r
JOIN Conditional c
ON c.RuleId = r.RuleId
LEFT JOIN Input i
ON i.InputId = c.InputId
GROUP BY r.RuleID
HAVING COUNT( CASE WHEN (c.ExpectedValue=1) AND (i.InputId IS NOT NULL)
OR (c.ExpectedValue=0) AN... |
30,972,574 | I've looked at a couple different articles which seem to suggest two different ways of doing custom scoping in Dagger 2:
1. [MVP Presenters that Survive Configuration Changes Part-2](http://blog.bradcampbell.nz/mvp-presenters-that-survive-configuration-changes-part-2/) ([Github repo](https://github.com/grandstaish/hel... | 2015/06/22 | [
"https://Stackoverflow.com/questions/30972574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1290264/"
] | After reading the answer by @vaughandroid, and [What determines the lifecycle of a component (object graph) in Dagger 2?](https://stackoverflow.com/questions/28411352/what-determines-the-lifecycle-of-a-component-object-graph-in-dagger-2?rq=1) I think I understand custom scopes well enough to answer my own question.
Fi... | Your understanding is correct. The named scopes allow you to communicate intention, but they all work the same way.
* For scoped provider methods, each Component instance will create 1 instance of the provided object.
* For unscoped provider methods, each Component instance will create a new instance of the provided o... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | Seems like your examples formatted with three digits groups except last, you can write a simple function, uses thousand seperator and adds last digit:
```
>>> def phone_format(n):
... r... | You can use the function [`clean_phone()`](https://sfu-db.github.io/dataprep/user_guide/clean/clean_phone.html) from the library [DataPrep](https://dataprep.ai/). Install it with `pip install dataprep`.
```py
>>> from dataprep.clean import clean_phone
>>> df = pd.DataFrame({'phone': ['5555555', '5555555555', '18005555... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | Seems like your examples formatted with three digits groups except last, you can write a simple function, uses thousand seperator and adds last digit:
```
>>> def phone_format(n):
... r... | A simple solution might be to start at the back and insert the hyphen after four numbers, then do groups of three until the beginning of the string is reached. I am not aware of a built in function or anything like that.
You might find this helpful:
<http://www.diveintopython3.net/regular-expressions.html#phonenumbers... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | You can use the function [`clean_phone()`](https://sfu-db.github.io/dataprep/user_guide/clean/clean_phone.html) from the library [DataPrep](https://dataprep.ai/). Install it with `pip install dataprep`.
```py
>>> from dataprep.clean import clean_phone
>>> df = pd.DataFrame({'phone': ['5555555', '5555555555', '18005555... | In my case, I needed to get a phone pattern like "\*\*\* \*\*\* \*\*\*" by country.
So I re-used `phonenumbers` package in our project
```py
from phonenumbers import country_code_for_region, format_number, PhoneMetadata, PhoneNumberFormat, parse as parse_phone
import re
def get_country_phone_pattern(country_code: st... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | Seems like your examples formatted with three digits groups except last, you can write a simple function, uses thousand seperator and adds last digit:
```
>>> def phone_format(n):
... r... | In my case, I needed to get a phone pattern like "\*\*\* \*\*\* \*\*\*" by country.
So I re-used `phonenumbers` package in our project
```py
from phonenumbers import country_code_for_region, format_number, PhoneMetadata, PhoneNumberFormat, parse as parse_phone
import re
def get_country_phone_pattern(country_code: st... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | for library: phonenumbers ([pypi](http://pypi.python.org/pypi/phonenumbers), [source](https://github.com/daviddrysdale/python-phonenumbers))
>
> Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
>
>
>
The readme is insufficient, but I found the ... | You can use the function [`clean_phone()`](https://sfu-db.github.io/dataprep/user_guide/clean/clean_phone.html) from the library [DataPrep](https://dataprep.ai/). Install it with `pip install dataprep`.
```py
>>> from dataprep.clean import clean_phone
>>> df = pd.DataFrame({'phone': ['5555555', '5555555555', '18005555... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | for library: phonenumbers ([pypi](http://pypi.python.org/pypi/phonenumbers), [source](https://github.com/daviddrysdale/python-phonenumbers))
>
> Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
>
>
>
The readme is insufficient, but I found the ... | A simple solution might be to start at the back and insert the hyphen after four numbers, then do groups of three until the beginning of the string is reached. I am not aware of a built in function or anything like that.
You might find this helpful:
<http://www.diveintopython3.net/regular-expressions.html#phonenumbers... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | for library: phonenumbers ([pypi](http://pypi.python.org/pypi/phonenumbers), [source](https://github.com/daviddrysdale/python-phonenumbers))
>
> Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
>
>
>
The readme is insufficient, but I found the ... | More verbose, one dependency, but guarantees consistent output for most inputs and was fun to write:
```py
import re
def format_tel(tel):
tel = tel.removeprefix("+")
tel = tel.removeprefix("1") # remove leading +1 or 1
tel = re.sub("[ ()-]", '', tel) # remove space, (), -
assert(len(tel) == 10)
... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | for library: phonenumbers ([pypi](http://pypi.python.org/pypi/phonenumbers), [source](https://github.com/daviddrysdale/python-phonenumbers))
>
> Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
>
>
>
The readme is insufficient, but I found the ... | In my case, I needed to get a phone pattern like "\*\*\* \*\*\* \*\*\*" by country.
So I re-used `phonenumbers` package in our project
```py
from phonenumbers import country_code_for_region, format_number, PhoneMetadata, PhoneNumberFormat, parse as parse_phone
import re
def get_country_phone_pattern(country_code: st... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | for library: phonenumbers ([pypi](http://pypi.python.org/pypi/phonenumbers), [source](https://github.com/daviddrysdale/python-phonenumbers))
>
> Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
>
>
>
The readme is insufficient, but I found the ... | Seems like your examples formatted with three digits groups except last, you can write a simple function, uses thousand seperator and adds last digit:
```
>>> def phone_format(n):
... r... |
7,058,122 | I'm having trouble creating a jQuery Accordion using javascript. It creates the Accodion labels just fine, and shows the text of the first element too. It does not show the second elements text, and when you click on it, you lose the first oned text forever too.
```
$("#tab-dock").append('<div id="daccordion">')
$("#... | 2011/08/14 | [
"https://Stackoverflow.com/questions/7058122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/894020/"
] | for library: phonenumbers ([pypi](http://pypi.python.org/pypi/phonenumbers), [source](https://github.com/daviddrysdale/python-phonenumbers))
>
> Python version of Google's common library for parsing, formatting, storing and validating international phone numbers.
>
>
>
The readme is insufficient, but I found the ... | Here's one adapted from [utdemir's solution](https://stackoverflow.com/a/7058216/27915) and [this solution](https://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators) that will work with Python 2.6, as the "," formatter is new in Python 2.7.
```
def phone_format(phone_number):... |
70,636,263 | How would you translate the following condition into a list comprehension?
```
a = list()
if inputs is not None:
for i in inputs:
a.append(my_function(i))
else:
a.append(my_function())
```
I was thinking:
```
a = [my_function(input) for input in inputs else my_function() if inputs is not None]
```
but... | 2022/01/08 | [
"https://Stackoverflow.com/questions/70636263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4853442/"
] | >
> Question: Is there a way to process the file, without resorting to the hack?
>
>
>
I am assuming that you are using [JSON-lib](http://json-lib.sourceforge.net/) as implied by the `[json-lib]` tag.
I am also assuming that you have encountered this problem in writing the unit tests for your code. (If not ... wh... | You can read jsonStr as JSON Object, then convert it to Java Object:
```
net.sf.json.JSON json = JSONSerializer.toJSON(jsonStr);
YourJavaObject jObj = null;
List<YourJavaObject> list = null;
if(json instanceof JSONObject){
jObj = (YourJavaObject)JSONObject.toBean(JSONObject.fromObject(json), Y... |
4,577,971 | We know that $\varphi(t) = \cos{t}$ is a characteristic function of Rademacher random variable. Is the function $\phi(t) = \cos{t} \cdot 1\_{|t| \le \pi /2}$ still a characteristic function of some random variable?
The only thing we have to check is if $\phi$ is positively-defined. I tried looking for some examples co... | 2022/11/16 | [
"https://math.stackexchange.com/questions/4577971",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/215263/"
] | If your given function $\phi (t) = {\Bbb E}(e^{ i t X})$ is the characteristic function of a random variable $X$ whose probability density is $f(x)dx$, then $ \phi(t)$ is the Fourier transform of $f(x)$ and the extremely useful **Fourier inversion formula** allows us to recover the function $f(x)$ by the general identi... | Suppose $\phi$ is the Fourier transform of a finite measure $\mu$ on $(\mathbb{R},\mathscr{B}(\mathbb{R}))$. [By Lévy inversion](https://www.wolframalpha.com/input?i=integrate+%28e%5E%7Bi5x%7D-e%5E%7Bi3x%7D%29%2F%28ix%29*cos%28x%29+from+-pi%2F2+to+pi%2F2)
$$\begin{aligned}\frac{\mu(3)+\mu(5)}{2}+\mu((3,5))&=\int\_{[-\p... |
66,622,740 | is it possible with pure JS to paste selected text into specified textarea? In my case, I want to select text in one of the textareas and when ctrl & A is pressed, selected text would paste into last (V1) textarea.
I have found similar case (<https://jsfiddle.net/QenBV/1/>), but it's only made for 1 input textarea, bu... | 2021/03/14 | [
"https://Stackoverflow.com/questions/66622740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14472252/"
] | That's simply not how the API is designed.
From [the definition of `object.__str__(self)`](https://docs.python.org/3/reference/datamodel.html#object.__str__):
>
> Called by str(object) and the built-in functions format() and print() to compute the “informal” or nicely printable string representation of an object.
> ... | >
> When I try to print it, everything goes fine, but writing `Person` to file fails
>
>
>
Why not use `print` then?
```
print(dan, file=fl)
```
That will behave exactly like the print you are expecting (including a trailing newline), but write to a file instead of stdout. |
15,525,955 | I'm trying to create a search, where the SQL query depends on a radio button and a textbox.
```
SELECT * FROM [Sales] WHERE (text in radio button) = (text in textbox)
```
How can I implement this?
Below is my full code.
```
Protected Sub btnSearch_Click(sender As Object, e As ImageClickEventArgs) Handles btnSearch... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15525955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2188011/"
] | Looking at your code I see a lot of unnecessary lines. I wish to give you an example of what I think you could do to simplify your code.
First, remove the code not needed for the SqlDataSource (I suppose that you have already opened the connection with the database and however this could be done just one time at click... | when using SQLDatasource, you dont have to specify Connections, it manages its own connection.
what you need to do is:
1. Update the Select Statement based on the Radio Button Status
2. Call the DataSource DataBind Function `SqlDataSource3.DataBind()`
Also, Better Approach is Using Stored Procedure that allow Null V... |
15,525,955 | I'm trying to create a search, where the SQL query depends on a radio button and a textbox.
```
SELECT * FROM [Sales] WHERE (text in radio button) = (text in textbox)
```
How can I implement this?
Below is my full code.
```
Protected Sub btnSearch_Click(sender As Object, e As ImageClickEventArgs) Handles btnSearch... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15525955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2188011/"
] | when using SQLDatasource, you dont have to specify Connections, it manages its own connection.
what you need to do is:
1. Update the Select Statement based on the Radio Button Status
2. Call the DataSource DataBind Function `SqlDataSource3.DataBind()`
Also, Better Approach is Using Stored Procedure that allow Null V... | HORRIBLE SOLUTIONS everywhere on internet. This is probably the simplest in the world.
```
PrintWriter out=response.getWriter();
out.print("<html>");
out.print("<body>");
out.print("<form>");
out.print("<textarea rows='5' columns='500' name='t1'></textarea>");
//o... |
15,525,955 | I'm trying to create a search, where the SQL query depends on a radio button and a textbox.
```
SELECT * FROM [Sales] WHERE (text in radio button) = (text in textbox)
```
How can I implement this?
Below is my full code.
```
Protected Sub btnSearch_Click(sender As Object, e As ImageClickEventArgs) Handles btnSearch... | 2013/03/20 | [
"https://Stackoverflow.com/questions/15525955",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2188011/"
] | Looking at your code I see a lot of unnecessary lines. I wish to give you an example of what I think you could do to simplify your code.
First, remove the code not needed for the SqlDataSource (I suppose that you have already opened the connection with the database and however this could be done just one time at click... | HORRIBLE SOLUTIONS everywhere on internet. This is probably the simplest in the world.
```
PrintWriter out=response.getWriter();
out.print("<html>");
out.print("<body>");
out.print("<form>");
out.print("<textarea rows='5' columns='500' name='t1'></textarea>");
//o... |
18,844,218 | I am using SQL Server 2008. I want to get Start Date and End Date of all quarters of year. For example if I pass 2013 in query then output should like
```
StartDate EndDate QuarterNo
-------------------------------------------------------------
2013-04-01 00:00:00.000 2013-06-30 00:... | 2013/09/17 | [
"https://Stackoverflow.com/questions/18844218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635294/"
] | ```
select
dateadd(M, 3*number, CONVERT(date, CONVERT(varchar(5),@year)+'-1-1')),
dateadd(D,-1,dateadd(M, 3*number+3, CONVERT(date, CONVERT(varchar(5),@year)+'-1-1'))),
Number QuarterNo
from master..spt_values
where type='p'
and number between 1 and 4
```
You'll probably want to use dates, not dateti... | Last date of previous quarter. This code can run on SQL Server 2012 and later
```
select EOMONTH(DATEFROMPARTS(year(DATEADD(month, -1, GETDATE())),DATENAME(qq,DATEADD(month, -1, GETDATE())) * 3,1)) AS QuarterEnd
``` |
18,844,218 | I am using SQL Server 2008. I want to get Start Date and End Date of all quarters of year. For example if I pass 2013 in query then output should like
```
StartDate EndDate QuarterNo
-------------------------------------------------------------
2013-04-01 00:00:00.000 2013-06-30 00:... | 2013/09/17 | [
"https://Stackoverflow.com/questions/18844218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635294/"
] | ```
select
dateadd(M, 3*number, CONVERT(date, CONVERT(varchar(5),@year)+'-1-1')),
dateadd(D,-1,dateadd(M, 3*number+3, CONVERT(date, CONVERT(varchar(5),@year)+'-1-1'))),
Number QuarterNo
from master..spt_values
where type='p'
and number between 1 and 4
```
You'll probably want to use dates, not dateti... | My favorite way but EOMONTH and DATEFROMPARTS doesn't exist before SQLServer 2012:
```
DECLARE
@FISCAL_YEAR INT = 2013,
@QUATER INT = 2
SELECT
DATEFROMPARTS(@fiscal_year,(@Quater * 3)-2,1) AS QuaterStart,
EOMONTH(DATEFROMPARTS(@fiscal_year,@Quater * 3,1)) AS QuaterEnd
``` |
18,844,218 | I am using SQL Server 2008. I want to get Start Date and End Date of all quarters of year. For example if I pass 2013 in query then output should like
```
StartDate EndDate QuarterNo
-------------------------------------------------------------
2013-04-01 00:00:00.000 2013-06-30 00:... | 2013/09/17 | [
"https://Stackoverflow.com/questions/18844218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635294/"
] | My favorite way but EOMONTH and DATEFROMPARTS doesn't exist before SQLServer 2012:
```
DECLARE
@FISCAL_YEAR INT = 2013,
@QUATER INT = 2
SELECT
DATEFROMPARTS(@fiscal_year,(@Quater * 3)-2,1) AS QuaterStart,
EOMONTH(DATEFROMPARTS(@fiscal_year,@Quater * 3,1)) AS QuaterEnd
``` | ```
SELECT
CAST(DATEADD(M,3*(NUMBER-1),DATEADD(YYYY,DATEDIFF(YYYY,0,GETDATE()),0)) AS DATE) [QT START DATE]
, CAST(DATEADD(D,-1,DATEADD(M,3*(NUMBER),DATEADD(YYYY,DATEDIFF(YYYY,0,GETDATE()),0))) AS DATE) [QT END DATE]
, NUMBER AS [QUARTER NAME]
FROM MASTER..SPT_VALUES
WHERE TYPE='P'
AND NUMBER BETWEEN... |
18,844,218 | I am using SQL Server 2008. I want to get Start Date and End Date of all quarters of year. For example if I pass 2013 in query then output should like
```
StartDate EndDate QuarterNo
-------------------------------------------------------------
2013-04-01 00:00:00.000 2013-06-30 00:... | 2013/09/17 | [
"https://Stackoverflow.com/questions/18844218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1635294/"
] | One more way to do it
```
SELECT DATEADD(mm, (quarter - 1) * 3, year_date) StartDate,
DATEADD(dd, -1, DATEADD(mm, quarter * 3, year_date)) EndDate,
quarter QuarterNo
FROM
(
SELECT '2013-04-01' year_date
) s CROSS JOIN
(
SELECT 1 quarter UNION ALL
SELECT 2 UNION ALL
SELECT 3 UNION ALL
SELECT ... | ```
SELECT
CAST(DATEADD(M,3*(NUMBER-1),DATEADD(YYYY,DATEDIFF(YYYY,0,GETDATE()),0)) AS DATE) [QT START DATE]
, CAST(DATEADD(D,-1,DATEADD(M,3*(NUMBER),DATEADD(YYYY,DATEDIFF(YYYY,0,GETDATE()),0))) AS DATE) [QT END DATE]
, NUMBER AS [QUARTER NAME]
FROM MASTER..SPT_VALUES
WHERE TYPE='P'
AND NUMBER BETWEEN... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.