qid int64 1 74.7M | question stringlengths 15 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 4 30.2k | response_k stringlengths 11 36.5k |
|---|---|---|---|---|---|
7,858,228 | This is just an academic question (I would never do this in real code):
**If I were to use shared\_ptr<> universally in my code, would the behavior be equivalent to a gc-collected language like Java?**
If not, how would the behavior be different from a gc-embedded language? Which C++ construct would yield equivalent ... | 2011/10/22 | [
"https://Stackoverflow.com/questions/7858228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975129/"
] | No, there'd be a couple of important differences:
* You would get a memory leak any time you have a cyclic reference. A garbage collector can handle cycles, ref-counting can't.
* You would avoid any stalls or pauses because no garbage collection ever occurs. On the other hand, you'd likely spend more total CPU time cl... | The main difference is that reference counting alone can't free circular data structures.
Many cases of such structures can nevertheless be handled by using `weak_ptr` appropriately, and some cases can be handled by delegating cleanup responsibility to a collection object.
However, the most frivolous spaghetti struct... |
7,858,228 | This is just an academic question (I would never do this in real code):
**If I were to use shared\_ptr<> universally in my code, would the behavior be equivalent to a gc-collected language like Java?**
If not, how would the behavior be different from a gc-embedded language? Which C++ construct would yield equivalent ... | 2011/10/22 | [
"https://Stackoverflow.com/questions/7858228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975129/"
] | No, there'd be a couple of important differences:
* You would get a memory leak any time you have a cyclic reference. A garbage collector can handle cycles, ref-counting can't.
* You would avoid any stalls or pauses because no garbage collection ever occurs. On the other hand, you'd likely spend more total CPU time cl... | Its worth noting that a shared ptr is much larger that a Java reference. Generally this won't matter but some situations it might.
In Java 6, 64-bit JVMs still use 32-bit references access up to 32 GB of heap (it can do this because objects are on 8 byte boundaries) However a shared ptr uses two pointers (each 8 byte... |
7,858,228 | This is just an academic question (I would never do this in real code):
**If I were to use shared\_ptr<> universally in my code, would the behavior be equivalent to a gc-collected language like Java?**
If not, how would the behavior be different from a gc-embedded language? Which C++ construct would yield equivalent ... | 2011/10/22 | [
"https://Stackoverflow.com/questions/7858228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975129/"
] | No, there'd be a couple of important differences:
* You would get a memory leak any time you have a cyclic reference. A garbage collector can handle cycles, ref-counting can't.
* You would avoid any stalls or pauses because no garbage collection ever occurs. On the other hand, you'd likely spend more total CPU time cl... | @jalf says this in his answer:
>
> You would avoid any stalls or pauses because no garbage collection ever occurs.
>
>
>
While smart pointers (or any reference counting scheme) have no pause while garbage collection occurs, you *can* get a pause if you null the last external pointer to a large data structure, an... |
7,858,228 | This is just an academic question (I would never do this in real code):
**If I were to use shared\_ptr<> universally in my code, would the behavior be equivalent to a gc-collected language like Java?**
If not, how would the behavior be different from a gc-embedded language? Which C++ construct would yield equivalent ... | 2011/10/22 | [
"https://Stackoverflow.com/questions/7858228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975129/"
] | Garbage collection happens whenever the GC decides that it should. `shared_ptr`s are not collected. An object managed by a `shared_ptr` will only *ever* be destroyed in the destructor of a `shared_ptr`. And therefore, you know exactly when memory can and can *not* be freed.
You still have control over when memory goes... | Its worth noting that a shared ptr is much larger that a Java reference. Generally this won't matter but some situations it might.
In Java 6, 64-bit JVMs still use 32-bit references access up to 32 GB of heap (it can do this because objects are on 8 byte boundaries) However a shared ptr uses two pointers (each 8 byte... |
7,858,228 | This is just an academic question (I would never do this in real code):
**If I were to use shared\_ptr<> universally in my code, would the behavior be equivalent to a gc-collected language like Java?**
If not, how would the behavior be different from a gc-embedded language? Which C++ construct would yield equivalent ... | 2011/10/22 | [
"https://Stackoverflow.com/questions/7858228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975129/"
] | The main difference is that reference counting alone can't free circular data structures.
Many cases of such structures can nevertheless be handled by using `weak_ptr` appropriately, and some cases can be handled by delegating cleanup responsibility to a collection object.
However, the most frivolous spaghetti struct... | Its worth noting that a shared ptr is much larger that a Java reference. Generally this won't matter but some situations it might.
In Java 6, 64-bit JVMs still use 32-bit references access up to 32 GB of heap (it can do this because objects are on 8 byte boundaries) However a shared ptr uses two pointers (each 8 byte... |
7,858,228 | This is just an academic question (I would never do this in real code):
**If I were to use shared\_ptr<> universally in my code, would the behavior be equivalent to a gc-collected language like Java?**
If not, how would the behavior be different from a gc-embedded language? Which C++ construct would yield equivalent ... | 2011/10/22 | [
"https://Stackoverflow.com/questions/7858228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/975129/"
] | @jalf says this in his answer:
>
> You would avoid any stalls or pauses because no garbage collection ever occurs.
>
>
>
While smart pointers (or any reference counting scheme) have no pause while garbage collection occurs, you *can* get a pause if you null the last external pointer to a large data structure, an... | Its worth noting that a shared ptr is much larger that a Java reference. Generally this won't matter but some situations it might.
In Java 6, 64-bit JVMs still use 32-bit references access up to 32 GB of heap (it can do this because objects are on 8 byte boundaries) However a shared ptr uses two pointers (each 8 byte... |
12,379,253 | I am still a java newbie and trying to play around learning threads. My question is that it does not loop 5 times. It runs one time and exits. I am using a.class to lock on the class object, such that both the threads are locking on the same object monitor.
```
class a implements Runnable {
Thread thr;
int count;
... | 2012/09/11 | [
"https://Stackoverflow.com/questions/12379253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547453/"
] | Here you go, with the original code:
```
class a implements Runnable {
Thread thr;
int count;
static String time = "Tock";
a(String s) {
thr = new Thread(this, s);
thr.start();
}
public void run() {
count++;
if (Thread.currentThread().getName().compareTo("one"... | When comparing strings (and objects in general), you should use `equals` as opposed to `==` (which is generally reserved for primitives): `while(time.equals("Tock"))`. `==` on strings will often times result in `false` when you want it to (and think it should) return `true`, and hence your loop will exit before expecte... |
12,379,253 | I am still a java newbie and trying to play around learning threads. My question is that it does not loop 5 times. It runs one time and exits. I am using a.class to lock on the class object, such that both the threads are locking on the same object monitor.
```
class a implements Runnable {
Thread thr;
int count;
... | 2012/09/11 | [
"https://Stackoverflow.com/questions/12379253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/547453/"
] | Here you go, with the original code:
```
class a implements Runnable {
Thread thr;
int count;
static String time = "Tock";
a(String s) {
thr = new Thread(this, s);
thr.start();
}
public void run() {
count++;
if (Thread.currentThread().getName().compareTo("one"... | The answer to why you only loop once is that you call `notify()` on an object that is not locked and thus an `IllegalMonitorStateException` is thrown and caught by the empty catch statement.
This is one way to do it. Not saying that it is the best. I tried to keep it close to your code:
```
public class TickTock {
... |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | `iframe`s are used a lot to include complete pages. When those pages are hosted on another domain you get problems with cross side scripting and stuff. There are ways to fix this.
Frames were used to divide your page into multiple parts (for example, a navigation menu on the left). Using them is no longer recommended. | ***Inline frame is just one "box" and you can place it anywhere on your site.
Frames are a bunch of 'boxes' put together to make one site with many pages.*** |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | The difference is an iframe is able to "float" within content in a page, that is you can create an html page and position an iframe within it. This allows you to have a page and place another document directly in it. A `frameset` allows you to split the screen into different pages (horizontally and vertically) and disp... | ***Inline frame is just one "box" and you can place it anywhere on your site.
Frames are a bunch of 'boxes' put together to make one site with many pages.*** |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | The difference is an iframe is able to "float" within content in a page, that is you can create an html page and position an iframe within it. This allows you to have a page and place another document directly in it. A `frameset` allows you to split the screen into different pages (horizontally and vertically) and disp... | `iframe`s are used a lot to include complete pages. When those pages are hosted on another domain you get problems with cross side scripting and stuff. There are ways to fix this.
Frames were used to divide your page into multiple parts (for example, a navigation menu on the left). Using them is no longer recommended. |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | The difference is an iframe is able to "float" within content in a page, that is you can create an html page and position an iframe within it. This allows you to have a page and place another document directly in it. A `frameset` allows you to split the screen into different pages (horizontally and vertically) and disp... | While the security is the same, it may be easier for fraudulent applications to dupe users using an iframe since they have more flexibility regarding where the frame is placed. |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | `iframe`s are used a lot to include complete pages. When those pages are hosted on another domain you get problems with cross side scripting and stuff. There are ways to fix this.
Frames were used to divide your page into multiple parts (for example, a navigation menu on the left). Using them is no longer recommended. | While the security is the same, it may be easier for fraudulent applications to dupe users using an iframe since they have more flexibility regarding where the frame is placed. |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | `iframe`s are used a lot to include complete pages. When those pages are hosted on another domain you get problems with cross side scripting and stuff. There are ways to fix this.
Frames were used to divide your page into multiple parts (for example, a navigation menu on the left). Using them is no longer recommended. | The only reasons I can think of are actually in the [wiki article you referenced](http://en.wikipedia.org/wiki/3-D_Secure) to mention a couple...
>
> "The "Verified by Visa" system has drawn some criticism, since it is
> hard for users to differentiate between the legitimate Verified by
> Visa pop-up window or inli... |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | IFrame is just an "internal frame". The reason why it can be considered less secure (than not using any kind of frame at all) is because you can include content that does not originate from your domain.
All this means is that you should trust whatever you include in an iFrame or a regular frame.
Frames and IFrames ar... | While the security is the same, it may be easier for fraudulent applications to dupe users using an iframe since they have more flexibility regarding where the frame is placed. |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | The only reasons I can think of are actually in the [wiki article you referenced](http://en.wikipedia.org/wiki/3-D_Secure) to mention a couple...
>
> "The "Verified by Visa" system has drawn some criticism, since it is
> hard for users to differentiate between the legitimate Verified by
> Visa pop-up window or inli... | While the security is the same, it may be easier for fraudulent applications to dupe users using an iframe since they have more flexibility regarding where the frame is placed. |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | Basically the difference between `<frame>` tag and `<iframe>` tag is :
When we use `<frame>` tag then the content of a web page constitutes of frames which is created by using `<frame>` and `<frameset>` tags only (*and `<body>` tag is not used*) as :
```
<html>
<head>
<title>HTML Frames</title>
</head>
<frameset rows... | ***Inline frame is just one "box" and you can place it anywhere on your site.
Frames are a bunch of 'boxes' put together to make one site with many pages.*** |
1,079,128 | Looking at options for embedding the 3D Secure page inside my own order form, I came across the following:
"Some commerce sites will devote the full browser page to the authentication rather than using a frame (not necessarily an iFrame, which is a less secure object anyway)."
from <http://en.wikipedia.org/wiki/3-D_S... | 2009/07/03 | [
"https://Stackoverflow.com/questions/1079128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7140/"
] | ***Inline frame is just one "box" and you can place it anywhere on your site.
Frames are a bunch of 'boxes' put together to make one site with many pages.*** | While the security is the same, it may be easier for fraudulent applications to dupe users using an iframe since they have more flexibility regarding where the frame is placed. |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | You assign a pointer to a constant string (which comes as a part of your text and is thus not writable memory).
Fix with `char str[] = "hello";` this will create a r/w copy of the constant string on your stack.
What you do is a perfectly valid pointer assignment. What the compiler does not know is that in a standard ... | When you initialize a `char *` using a literal string, then you shouldn't try to modify it's contents: the variable is pointing to memory that doesn't belong to you.
You *can* use:
```
char str[] = "hello";
str[0] = 'H';
```
With this code you've declared an array which is initialized with a copy of the literal str... |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | You assign a pointer to a constant string (which comes as a part of your text and is thus not writable memory).
Fix with `char str[] = "hello";` this will create a r/w copy of the constant string on your stack.
What you do is a perfectly valid pointer assignment. What the compiler does not know is that in a standard ... | Your code has undefined behavior in runtime. You are attempting to write to a literal string, which is not allowed. Such writes may trigger an error or have undefined behavior. Your specific C compiler has `str` point to read-only memory, and attempting to write to that memory leads to a segmentation fault. Even though... |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | You assign a pointer to a constant string (which comes as a part of your text and is thus not writable memory).
Fix with `char str[] = "hello";` this will create a r/w copy of the constant string on your stack.
What you do is a perfectly valid pointer assignment. What the compiler does not know is that in a standard ... | ```
char *str = "hello";
```
When you declare `str` as above, it is not guaranteed which part of memory it will be stored. str might be read-only depending on implementation. So trying to change it will cause segmentation fault.
In order to avoid segmentation faullt, declare `str` as an array of characters instead. |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | You assign a pointer to a constant string (which comes as a part of your text and is thus not writable memory).
Fix with `char str[] = "hello";` this will create a r/w copy of the constant string on your stack.
What you do is a perfectly valid pointer assignment. What the compiler does not know is that in a standard ... | ```
char *str = "hello";
```
here the string hello is a literal.
string literals are always stored in read only memory.
this is the reason you are getting a segmentation fault when you are trying to change the value at read only memory. |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | You assign a pointer to a constant string (which comes as a part of your text and is thus not writable memory).
Fix with `char str[] = "hello";` this will create a r/w copy of the constant string on your stack.
What you do is a perfectly valid pointer assignment. What the compiler does not know is that in a standard ... | Declaring str as char\* reserves memory for the pointer, but not for the string.
The compiler can put the memory for "hello" anywhere he likes.
You have no guarantee that str[i] is writable, so that's why in some compilers this results in a seg fault.
If you want to make sure that the string is in writable memory, the... |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | When you initialize a `char *` using a literal string, then you shouldn't try to modify it's contents: the variable is pointing to memory that doesn't belong to you.
You *can* use:
```
char str[] = "hello";
str[0] = 'H';
```
With this code you've declared an array which is initialized with a copy of the literal str... | Your code has undefined behavior in runtime. You are attempting to write to a literal string, which is not allowed. Such writes may trigger an error or have undefined behavior. Your specific C compiler has `str` point to read-only memory, and attempting to write to that memory leads to a segmentation fault. Even though... |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | When you initialize a `char *` using a literal string, then you shouldn't try to modify it's contents: the variable is pointing to memory that doesn't belong to you.
You *can* use:
```
char str[] = "hello";
str[0] = 'H';
```
With this code you've declared an array which is initialized with a copy of the literal str... | ```
char *str = "hello";
```
When you declare `str` as above, it is not guaranteed which part of memory it will be stored. str might be read-only depending on implementation. So trying to change it will cause segmentation fault.
In order to avoid segmentation faullt, declare `str` as an array of characters instead. |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | When you initialize a `char *` using a literal string, then you shouldn't try to modify it's contents: the variable is pointing to memory that doesn't belong to you.
You *can* use:
```
char str[] = "hello";
str[0] = 'H';
```
With this code you've declared an array which is initialized with a copy of the literal str... | ```
char *str = "hello";
```
here the string hello is a literal.
string literals are always stored in read only memory.
this is the reason you are getting a segmentation fault when you are trying to change the value at read only memory. |
12,761,916 | >
> **Possible Duplicate:**
>
> [Difference between char \*str=“STRING” and char str[] = “STRING”?](https://stackoverflow.com/questions/3862842/difference-between-char-str-string-and-char-str-string)
>
>
>
I wrote the following code:
```
int main()
{
char *str = "hello";
str[0] = 'H';
printf("%s\n... | 2012/10/06 | [
"https://Stackoverflow.com/questions/12761916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1032610/"
] | When you initialize a `char *` using a literal string, then you shouldn't try to modify it's contents: the variable is pointing to memory that doesn't belong to you.
You *can* use:
```
char str[] = "hello";
str[0] = 'H';
```
With this code you've declared an array which is initialized with a copy of the literal str... | Declaring str as char\* reserves memory for the pointer, but not for the string.
The compiler can put the memory for "hello" anywhere he likes.
You have no guarantee that str[i] is writable, so that's why in some compilers this results in a seg fault.
If you want to make sure that the string is in writable memory, the... |
133,319 | I've previously read some of Buterin's posts and he's been especially critical of cross-chain bridges. I know they aren't bridges where digital assets are stored non-natively, but are Chainlink keepers a vulnerability since they're performing `checkUpkeep` off-chain? What guarantee do developers have that the code they... | 2022/08/09 | [
"https://ethereum.stackexchange.com/questions/133319",
"https://ethereum.stackexchange.com",
"https://ethereum.stackexchange.com/users/104442/"
] | Doe
*Disclaimer: I'm a Chainlink Labs employee.*
**What is "off-chain"?**
To your question regarding what is "off-chain". Off-chain is a synonym for using the blockchain client's simulation capability to tell you what would have happened if you submitted a transaction, without using gas. This uses on-chain data and ... | Keepers are a bit different. They just run a function you specify, so there's not really any way for them to be malicious other than just ignoring your request (at which point you (or anyone) can still run the function). Their oracles would be more of a similar risk since they can change what their putting on-chain (e.... |
15,096,308 | There's a code
```
file_paths = {nature:[], nature_thumb:[]}
```
Elsif version that works fine:
```
Find.find('public/uploads') do |path|
if path =~ /.*nature.*\.(jpg|png|gif)$/ and path !~ /.*nature\/thumb.*\.(jpg|png|gif)$/
file_paths[:nature] << path
elsif
path =~ /.*nature\/thumb.*\.(jpg|png... | 2013/02/26 | [
"https://Stackoverflow.com/questions/15096308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1201917/"
] | You must use CompareTo() rather than the > operation.
See here: <http://msdn.microsoft.com/en-gb/library/system.icomparable.aspx>
In your case you'd put:
```
if (matrix[row, col].CompareTo(max_val) > 0)
``` | Implementing `IComparable` means that it defines the `CompareTo` method, not that the `>` operator is defined. You need to use:
```
if (matrix[row, col].CompareTo(max_val) > 0) {
``` |
15,096,308 | There's a code
```
file_paths = {nature:[], nature_thumb:[]}
```
Elsif version that works fine:
```
Find.find('public/uploads') do |path|
if path =~ /.*nature.*\.(jpg|png|gif)$/ and path !~ /.*nature\/thumb.*\.(jpg|png|gif)$/
file_paths[:nature] << path
elsif
path =~ /.*nature\/thumb.*\.(jpg|png... | 2013/02/26 | [
"https://Stackoverflow.com/questions/15096308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1201917/"
] | You must use CompareTo() rather than the > operation.
See here: <http://msdn.microsoft.com/en-gb/library/system.icomparable.aspx>
In your case you'd put:
```
if (matrix[row, col].CompareTo(max_val) > 0)
``` | ```
if (matrix[row, col] > max_val)
```
Should be
```
if (matrix[row, col].CompareTo(max_val) > 0)
```
Since [IComparable](http://msdn.microsoft.com/en-us/library/4d7sx9hd.aspx) provides only `CompareTo` not `>`. |
15,096,308 | There's a code
```
file_paths = {nature:[], nature_thumb:[]}
```
Elsif version that works fine:
```
Find.find('public/uploads') do |path|
if path =~ /.*nature.*\.(jpg|png|gif)$/ and path !~ /.*nature\/thumb.*\.(jpg|png|gif)$/
file_paths[:nature] << path
elsif
path =~ /.*nature\/thumb.*\.(jpg|png... | 2013/02/26 | [
"https://Stackoverflow.com/questions/15096308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1201917/"
] | Implementing `IComparable` means that it defines the `CompareTo` method, not that the `>` operator is defined. You need to use:
```
if (matrix[row, col].CompareTo(max_val) > 0) {
``` | ```
if (matrix[row, col] > max_val)
```
Should be
```
if (matrix[row, col].CompareTo(max_val) > 0)
```
Since [IComparable](http://msdn.microsoft.com/en-us/library/4d7sx9hd.aspx) provides only `CompareTo` not `>`. |
8,088,370 | ```
void menu() {
print();
Scanner input = new Scanner( System.in );
while(true) {
String s = input.next();
switch (s) {
case "m": print(); continue;
case "s": stat(); break;
case "[A-Z]{1}[a-z]{2}\\d{1,}": filminfo( s ); break;
case "Jur1": filminfo(s); break... | 2011/11/11 | [
"https://Stackoverflow.com/questions/8088370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1020678/"
] | You can't use a regex as a switch case. (Think about it: how would Java know whether you wanted to match the string `"[A-Z]{1}[a-z]{2}\\d{1,}"` or the regex?)
What you could do, in this case, is try to match the regex in your default case.
```
switch (s) {
case "m": print(); continue;
case "s": st... | I don't think you can use regex in switch cases.
>
> The String in the switch expression is compared with the expressions
> associated with each case label as if the String.equals method were
> being used.
>
>
>
See <http://download.oracle.com/javase/7/docs/technotes/guides/language/strings-switch.html> for mor... |
14,899,626 | Is there a way to use an OpenType font on Windows Phone 7 Silverlight application? I want to use Lobster which is only available AFAIK in OpenType format. It renders in Blend but not when I deploy to the emulator.
I have included the .otf file in my project and set the Properties to 'Content' and 'Copy If Newer'.
[Th... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14899626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199/"
] | As far as I can see, there is nothing wrong with the query.
When I try it, it returns only the obj rows where there is a corresponding date and a corresponding option.
```
insert into dates values
(1, 1, '22/01/2013'),
(2, 1, '23/01/2013'),
(3, 2, '22/01/2013'),
(4, 2, '23/01/2013'),
(5, 3, '23/01/2013'),
(6, 3, '24/... | Change your line
```
WHERE dates.dispo_date="22/01/2013"
```
for
```
WHERE DATE(dates.dispo_date)="22/01/2013"
```
Handling dates in text fields is a little tricky (also bad practice). Make sure both dates are in the same format. |
14,899,626 | Is there a way to use an OpenType font on Windows Phone 7 Silverlight application? I want to use Lobster which is only available AFAIK in OpenType format. It renders in Blend but not when I deploy to the emulator.
I have included the .otf file in my project and set the Properties to 'Content' and 'Copy If Newer'.
[Th... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14899626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/199/"
] | As far as I can see, there is nothing wrong with the query.
When I try it, it returns only the obj rows where there is a corresponding date and a corresponding option.
```
insert into dates values
(1, 1, '22/01/2013'),
(2, 1, '23/01/2013'),
(3, 2, '22/01/2013'),
(4, 2, '23/01/2013'),
(5, 3, '23/01/2013'),
(6, 3, '24/... | First, I'm a little confused on which ID's map to which tables. I might respectfully suggest that the id field in DATES be renamed to date\_id, the id in OPTION be renamed to option\_id, and the id in obj to obj\_id. Makes those relationships MUCH clearer for folks looking in through the keyhole. I'm going in a bit of ... |
55,587,675 | i can't delete file & folder in android 8 and above. file.delete() return false in all possible way
```
File csvFile = new File(Environment.getExternalStorageDirectory().getPath() + "/Notes/help.csv");
File txtFile = new File(Environment.getExternalStorageDirectory().getPath() + "/Notes/MyFile.txt");
folder = new File... | 2019/04/09 | [
"https://Stackoverflow.com/questions/55587675",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10122286/"
] | This may be a permission problem.
Starting from Android 8, READ\_EXTERNAL\_STORAGE and WRITE\_EXTERNAL\_STORAGE need to request separately. So even if you can read the file, it is possible you can't delete it.
If you are sure not a permission problem, then change your code to
```
try {
Files.delete(theFileName);
... | When you do `new File()` it doesn't create anything, it is just an object that points to a file (a bit like a path). If you were to write to that file object then it would exist, and then you could delete it.
In other words, I think you can't delete it because you never created it in the first place. |
53,682,058 | When I declare or just write a function which takes a 2-dimensional `char`-array in C, Visual Studio tells me I have to put a value in the columns parameter, for example:
```
void board(char mat[][MAX_COLUMNS]);
```
so my question is why do I even need to tell C one dimension of the 2 dimensional array, and why does... | 2018/12/08 | [
"https://Stackoverflow.com/questions/53682058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10700430/"
] | Because arrays are not first class objects in C. When you pass an array to a function, it *decays* to a pointer and the callee cannot guess the size. For a 1D array, it still allows to access elements through pointer arithmetics. But for a 2D array (an array of array) pointer arithmetics require that the size of the se... | Weather Vane pointed out well.
Plus, if you want to circumvent that restriction, use this prototype:
```
void board(char *mat, int rows, int columns);
```
And you can access it by this expression.
```
mat[i*columns+j]
```
when you want to access `i`th row `j`th column element.
Hope it helped! |
53,682,058 | When I declare or just write a function which takes a 2-dimensional `char`-array in C, Visual Studio tells me I have to put a value in the columns parameter, for example:
```
void board(char mat[][MAX_COLUMNS]);
```
so my question is why do I even need to tell C one dimension of the 2 dimensional array, and why does... | 2018/12/08 | [
"https://Stackoverflow.com/questions/53682058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10700430/"
] | Weather Vane pointed out well.
Plus, if you want to circumvent that restriction, use this prototype:
```
void board(char *mat, int rows, int columns);
```
And you can access it by this expression.
```
mat[i*columns+j]
```
when you want to access `i`th row `j`th column element.
Hope it helped! | ```
void board(char mat[][MAX_COLUMNS]);
```
is equivalent to
```
void board(char (*mat)[MAX_COLUMNS]);
```
with `char (*mat)[MAX_COLUMNS]` being the type your 2D-array is decayed to when passed to `board()`: To a pointer to its 1st element, as done to any array passed to a function. |
53,682,058 | When I declare or just write a function which takes a 2-dimensional `char`-array in C, Visual Studio tells me I have to put a value in the columns parameter, for example:
```
void board(char mat[][MAX_COLUMNS]);
```
so my question is why do I even need to tell C one dimension of the 2 dimensional array, and why does... | 2018/12/08 | [
"https://Stackoverflow.com/questions/53682058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10700430/"
] | Weather Vane pointed out well.
Plus, if you want to circumvent that restriction, use this prototype:
```
void board(char *mat, int rows, int columns);
```
And you can access it by this expression.
```
mat[i*columns+j]
```
when you want to access `i`th row `j`th column element.
Hope it helped! | Suppose you have an array
```
char arr[3][4];
```
and define the function as
```
void board(char mat[][4])
```
The array decays to a pointer, so if the function wants to access `mat[2][1]` then the offset from the pointer will be **row x width + column** elements, so `2 * 4 + 1 = 9`. Note that arrays are always c... |
53,682,058 | When I declare or just write a function which takes a 2-dimensional `char`-array in C, Visual Studio tells me I have to put a value in the columns parameter, for example:
```
void board(char mat[][MAX_COLUMNS]);
```
so my question is why do I even need to tell C one dimension of the 2 dimensional array, and why does... | 2018/12/08 | [
"https://Stackoverflow.com/questions/53682058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10700430/"
] | Because arrays are not first class objects in C. When you pass an array to a function, it *decays* to a pointer and the callee cannot guess the size. For a 1D array, it still allows to access elements through pointer arithmetics. But for a 2D array (an array of array) pointer arithmetics require that the size of the se... | ```
void board(char mat[][MAX_COLUMNS]);
```
is equivalent to
```
void board(char (*mat)[MAX_COLUMNS]);
```
with `char (*mat)[MAX_COLUMNS]` being the type your 2D-array is decayed to when passed to `board()`: To a pointer to its 1st element, as done to any array passed to a function. |
53,682,058 | When I declare or just write a function which takes a 2-dimensional `char`-array in C, Visual Studio tells me I have to put a value in the columns parameter, for example:
```
void board(char mat[][MAX_COLUMNS]);
```
so my question is why do I even need to tell C one dimension of the 2 dimensional array, and why does... | 2018/12/08 | [
"https://Stackoverflow.com/questions/53682058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10700430/"
] | Because arrays are not first class objects in C. When you pass an array to a function, it *decays* to a pointer and the callee cannot guess the size. For a 1D array, it still allows to access elements through pointer arithmetics. But for a 2D array (an array of array) pointer arithmetics require that the size of the se... | Suppose you have an array
```
char arr[3][4];
```
and define the function as
```
void board(char mat[][4])
```
The array decays to a pointer, so if the function wants to access `mat[2][1]` then the offset from the pointer will be **row x width + column** elements, so `2 * 4 + 1 = 9`. Note that arrays are always c... |
18,308,643 | How can I run a Streaming Map Reduce job remotely on Azure Cluster using C#? My mappers and reducers are written either in Java or C++. The .Net C# SDK's job execution method takes JobType in input so I am unable to specify type of C++ and Java based mapper/reducer.
There is another class `StreamingProcessExecutor` w... | 2013/08/19 | [
"https://Stackoverflow.com/questions/18308643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/421611/"
] | Try this one -
```
DECLARE @Xml XML, @UserTableType SYSNAME = '[dbo].[MyType]'
DECLARE @Sql NVARCHAR(MAX)
SELECT @Sql = 'SELECT ' +
STUFF((SELECT ' ,T.Data.value(''@' +
c.name + ''', ''' +
t.name +
CASE WHEN c.user_type_id IN... | There're a several issues here:
* Your table is table variable, so to get schema you have to query `sys.table_types`.
* When you select `for xml for auto`, your node element name will be xml safe @Data - `<_x0040_Data ...`, so I suggest to user for `xml path`.
And your code becomes:
```
CREATE PROC dbo.uSpShredUserD... |
5,277,139 | I've been struggling with this issue for a few days now and I'm still not able to figure it out. I've created a sample project to hopefully help figure this issue out. The main issue is when I load a user from my context and perform an UpdateModel() on this object it seems to delete my entity references and I get null ... | 2011/03/11 | [
"https://Stackoverflow.com/questions/5277139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | I figured this question out thanks to Morteza Manavi on the entity framework website. My issue was caused by my ContactInformation model properties, 'contactid' & 'contacttypeid' not being nullable. Once I fixed this everything with UpdateModel() worked correctly. Thank you very much! | Have you used any data annotations on your key values like [Required] or [StringLength], that would explain the error message. |
29,151,572 | ```
import java.io.BufferedReader;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStreamReader;
public class FileRead
{
public static void main (String[] args) throws IOException
{
try
{
FileInputStream fstream = new FileInputStream("data.txt");
BufferedRea... | 2015/03/19 | [
"https://Stackoverflow.com/questions/29151572",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4691008/"
] | I don't understand, the model shouldn't have to look at params[:reschedule] to know if it's "simply a change to the remind\_at time" -- the model is the thing being changed, it should be able to look at *what's actually being changed* and make sure it's only `remind_at`.
Looking at `params[:reschedule]` wouldn't be r... | if its mass assignment..then include the attribute in [attr\_accessible](http://apidock.com/rails/ActiveRecord/Base/attr_accessible/class) or else set it explicitly in controller or model |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | Jay is
>
> your heart
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> the heart does not stop even when sleeping
>
>
>
```
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.
My kind can be you or you can be me
if you know a body by its... | I'll take a crack at it:
Jay is
>
> A Joule, the SI unit of energy.
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> `J` is the standard abbreviation for Joule, which is also considered to be a measure of work performed.
>
>
>
```
but don't get me wrong I know not Silent ... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | Jay is
>
> your heart
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> the heart does not stop even when sleeping
>
>
>
```
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.
My kind can be you or you can be me
if you know a body by its... | I'll give it a try, this is what i've got so far:
Jay is
>
> an atom
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> atoms get together and break appart all the time to produce every kind of physical nature.
>
>
>
```
but don't get me wrong I know not Silent Bob
and g... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | Jay is
>
> your heart
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> the heart does not stop even when sleeping
>
>
>
```
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.
My kind can be you or you can be me
if you know a body by its... | I think the answer is
>
> computers.
>
>
>
*Hello everyone, my name is Jay*
>
> This might be a specific computer; I'm not really sure.
>
>
>
*I work for you 24 hours a day,*
>
> Lots of computers do this.
>
>
>
*but don't get me wrong I know not Silent Bob
and got nothing to do with weed on t... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | Jay is
>
> your heart
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> the heart does not stop even when sleeping
>
>
>
```
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.
My kind can be you or you can be me
if you know a body by its... | \*Hello everyone, my name is Jay
>
> Jay is Carbon ?
>
>
>
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.
>
> we are carbon-based
>
>
>
My kind can be you or you can be me
if you know a body by its chemistry.
We're not o... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
>
> As I already said this did only give the hint that those "Jays" are working 24 hours a day
>
>
>
*My kind can be you or you can be me
if you kn... | I'll take a crack at it:
Jay is
>
> A Joule, the SI unit of energy.
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> `J` is the standard abbreviation for Joule, which is also considered to be a measure of work performed.
>
>
>
```
but don't get me wrong I know not Silent ... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
>
> As I already said this did only give the hint that those "Jays" are working 24 hours a day
>
>
>
*My kind can be you or you can be me
if you kn... | I'll give it a try, this is what i've got so far:
Jay is
>
> an atom
>
>
>
```
Hello everyone, my name is Jay
I work for you 24 hours a day,
```
>
> atoms get together and break appart all the time to produce every kind of physical nature.
>
>
>
```
but don't get me wrong I know not Silent Bob
and g... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
>
> As I already said this did only give the hint that those "Jays" are working 24 hours a day
>
>
>
*My kind can be you or you can be me
if you kn... | I think the answer is
>
> computers.
>
>
>
*Hello everyone, my name is Jay*
>
> This might be a specific computer; I'm not really sure.
>
>
>
*I work for you 24 hours a day,*
>
> Lots of computers do this.
>
>
>
*but don't get me wrong I know not Silent Bob
and got nothing to do with weed on t... |
6,288 | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
*My kind can be you or you can be me
if you know a body by its chemistry.
We're not only human, but mostly a thing!
We have many shapes, on the air ... | 2014/12/19 | [
"https://puzzling.stackexchange.com/questions/6288",
"https://puzzling.stackexchange.com",
"https://puzzling.stackexchange.com/users/5122/"
] | *Hello everyone, my name is Jay
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.*
>
> As I already said this did only give the hint that those "Jays" are working 24 hours a day
>
>
>
*My kind can be you or you can be me
if you kn... | \*Hello everyone, my name is Jay
>
> Jay is Carbon ?
>
>
>
I work for you 24 hours a day,
but don't get me wrong I know not Silent Bob
and got nothing to do with weed on the job.
>
> we are carbon-based
>
>
>
My kind can be you or you can be me
if you know a body by its chemistry.
We're not o... |
55,945,937 | I have a set of objects in a MongoDB. The object includes an array of types. Now I am connecting to the DB with Mongoose and would like to now the number of objects for each Type.
For example my objects look like
```
{
"name": "abc",
"tags": ["a","b","c"]
}
```
Now I would like to get the total number of Objects w... | 2019/05/02 | [
"https://Stackoverflow.com/questions/55945937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8966014/"
] | ```
collection.aggregate([
{$unwind: "$tags" },
{$group: {
_id: "$tags",
count: {$sum : 1}
}},
]);
```
this will give output like this:
```
/* 1 */
{
"_id" : "c",
"count" : 2
}
/* 2 */
{
"_id" : "b",
"count" : 3
}
/* 3 */
{
"_id" : "a",
"count" : 2
}
``` | Use `count` which is a collection method. It returns the count only instead of all documents. If You need the documents , replace `count` with `find`
```
collection.count({tags:"a"})
``` |
69,166,004 | I tried to deploy something like [this example](https://www.serverless.com/blog/how-to-create-a-rest-api-in-java-using-dynamodb-and-serverless/) from [serverless](https://www.serverless.com/). Building my `serverless.yml`, I run into this error, of which I don't find a handle to deal with:
```yaml
service: products-ap... | 2021/09/13 | [
"https://Stackoverflow.com/questions/69166004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13914780/"
] | It's a really simple solution. You created `int` function that never returns a value. If you have a function that you don't want any value to be returned, just make it `void`. To make your code work simply change function type from `int` to `void`
```
void Task(int balance, int balance2, int option)
```
The second i... | You are missing "return balance" at the end of the Task() function. You define your function to return integer, that means you have to have return statement inside the function. Also, you have to have main() function, not main1() as in your case. Every C/C++ needs function that is called main() and it represent the ent... |
28,907,292 | I run the following query:
```
select * from my_temp_table
```
And get this output:
>
> PNRP1-109/RT
>
> PNRP1-200-16
>
> PNRP1-209/PG
>
> 013555366-IT
>
>
>
How can I alter my query to strip the last two characters from each value? | 2015/03/06 | [
"https://Stackoverflow.com/questions/28907292",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4632588/"
] | Use the `SUBSTR()` function.
```
SELECT SUBSTR(my_column, 1, LENGTH(my_column) - 2) FROM my_table;
``` | Another way using a regular expression:
```
select regexp_replace('PNRP1-109/RT', '^(.*).{2}$', '\1') from dual;
```
This replaces your string with group 1 from the regular expression, where group 1 (inside of the parens) includes the set of characters after the beginning of the line, not including the 2 characters ... |
29,312,315 | I have a table with time periods like (no overlap in time periods):
```
start_date end_date
-----------------------------
12-aug-14 12-nov-14
12-jan-15 12-apr-15
12-jun-15 12-aug-15
... 5 more
```
I'm trying to find the in between time periods - something like:
```
12-nov-14 1... | 2015/03/28 | [
"https://Stackoverflow.com/questions/29312315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264806/"
] | `sort` your table, use `rownum` and then `join` them:
```
WITH CTE AS (
SELECT
START_DATE,
END_DATE,
ROWNUM AS RN
FROM ( SELECT START_DATE, END_DATE FROM TABLE_NAME ORDER BY 1,2)
)
SELECT T1.END_DATE, T2.START_DATE
FROM CTE T1 JOIN CTE T2 ON T2.RN=T1.RN+1
``` | This is kind of tricky. You are currently creating a cartesian, which is close, after you create your cartesian, use a group-by to limit it back down to just the start-rows, and the minimum end-rows:
```
select
l1.end_date,
min(l2.start_date)
from
lease l1
inner join lease l2 ON
l1.place_no = l2.pl... |
29,312,315 | I have a table with time periods like (no overlap in time periods):
```
start_date end_date
-----------------------------
12-aug-14 12-nov-14
12-jan-15 12-apr-15
12-jun-15 12-aug-15
... 5 more
```
I'm trying to find the in between time periods - something like:
```
12-nov-14 1... | 2015/03/28 | [
"https://Stackoverflow.com/questions/29312315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1264806/"
] | Use `lead()`. That is what the function is designed for:
```
select l.*,
lead(start_date) over (partition by place_no order by start_date) as next_start_date,
(lead(start_date) over (partition by place_no order by start_date) as next_start_date - end_date) as gap
from lease l
where l1.place_no = 'P1';
`... | This is kind of tricky. You are currently creating a cartesian, which is close, after you create your cartesian, use a group-by to limit it back down to just the start-rows, and the minimum end-rows:
```
select
l1.end_date,
min(l2.start_date)
from
lease l1
inner join lease l2 ON
l1.place_no = l2.pl... |
35,468,956 | Completely lost here. I have a mysql database with an appointment table. The important for this is that is has a start\_date and end\_date
Suppose I need to find the next available 30 minute slot. Need to stat Mon-Fri and 7am to 7 pm
Basically I need a way to automatically do this process. What would my sql query loo... | 2016/02/17 | [
"https://Stackoverflow.com/questions/35468956",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/528130/"
] | `analysttest.rss.channel.item[0]` gives the fist item, which you can `#assign` to a shorther name for convenience. Note that at least 1 item must exist, or else you get an error. (Or, you can do something like `<#assign item = analysttest.rss.channel.item[0]!someDefault>`, where `someDefault` is like `''`, `[]`, `{}`, ... | ```
<#assign item = analysttest.rss.channel.item[0]>
<div>
<h3 class="bstitle">${item.title}</h3>
<span class="bsauthor">${item.author}</span>
<span>${item.pubDate}</span>
<p>${item.description}</p>
</div>
``` |
21,333,935 | I have a legacy project which has a singleton class like this:
```
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton inst;
return inst;
}
void foo();
};
```
The project uses a DLL which needs to use the same class (part of the source is shared between the hos... | 2014/01/24 | [
"https://Stackoverflow.com/questions/21333935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140367/"
] | One way would be to put an ifdef in your Instance() method so that it behaved differently in your app and dll. For example, have the app one call an exported function on the dll which internally calls the dlls Instance() method. Have the dll version work as originally.
Beware though, unless you make methods like foo()... | The common solution is to have another dll that holds the singleton but not implemented with a static member. See this [answer](https://stackoverflow.com/a/6936218/109960) for example. |
21,333,935 | I have a legacy project which has a singleton class like this:
```
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton inst;
return inst;
}
void foo();
};
```
The project uses a DLL which needs to use the same class (part of the source is shared between the hos... | 2014/01/24 | [
"https://Stackoverflow.com/questions/21333935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140367/"
] | I've solved the same problem (eg. class used within library, in other library and also in main application) by moving the static Singleton inst; into cpp file.
```
Foo.h
class Foo{
public:
static Foo *getInstance();
...
Foo.cpp
Foo *Foo::getInstance(){
static Foo instance;
return &foo;
}
```
The static variab... | The common solution is to have another dll that holds the singleton but not implemented with a static member. See this [answer](https://stackoverflow.com/a/6936218/109960) for example. |
21,333,935 | I have a legacy project which has a singleton class like this:
```
class Singleton
{
public:
static Singleton& Instance()
{
static Singleton inst;
return inst;
}
void foo();
};
```
The project uses a DLL which needs to use the same class (part of the source is shared between the hos... | 2014/01/24 | [
"https://Stackoverflow.com/questions/21333935",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/140367/"
] | One way would be to put an ifdef in your Instance() method so that it behaved differently in your app and dll. For example, have the app one call an exported function on the dll which internally calls the dlls Instance() method. Have the dll version work as originally.
Beware though, unless you make methods like foo()... | I've solved the same problem (eg. class used within library, in other library and also in main application) by moving the static Singleton inst; into cpp file.
```
Foo.h
class Foo{
public:
static Foo *getInstance();
...
Foo.cpp
Foo *Foo::getInstance(){
static Foo instance;
return &foo;
}
```
The static variab... |
41,805,638 | This works perfectly fine. Now, I would like to incorporate this into a function and just call the function within my expression. It doesn't work.
**Working code:**
```
render: function() {
return (
<div>
{this.props.list.map(function(listValue){
return <p>{listValue}</p>;
... | 2017/01/23 | [
"https://Stackoverflow.com/questions/41805638",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2951933/"
] | You've extracted the call to `map` into another function and *maybe* assumed the `return` call inside it was sufficient to return the result of the whole call (it just returns the mapped value for that iteration of map).
You just need to return the result of your map in your `addText` function:
```
var List = React.c... | Tnx **@Thomas altmann**, I forgot to make another return prior to my first return
```
var List = React.createClass({
addText: function()
{
return (this.props.list.map(function(listValue){
return <p>{listValue}</p>;
})
);
},
render: function() {
return (
... |
682,964 | I am new to networking, my problem is: I have two internet connections in my company, so when one internet goes down, it should access from another – but it's not working: the Internet is connected to different routers and then connected to a switch. If I want to share Internet connections, what setting do I want to ch... | 2013/12/02 | [
"https://superuser.com/questions/682964",
"https://superuser.com",
"https://superuser.com/users/278512/"
] | First: You are doing it backwards.
First priority is to CLEAN the machine.
And the only certain way to do that is to boot from a rescue-medium and scan/clean the machine from there.
But sometimes you don't have a choice.
Example: When you have a machine that uses some form of disk-encryption so you can't get a... | Open file:
```
openfiles /Query /FO:csv | more
```
View NetBIOS network open files:
```
net files
```
Process commandline, caption, Pid:
```
Wmic process get CommandLine, name, ProcessId | more
```
Process path, caption, Pid:
```
Wmic process get ExecutablePath, name, ProcessId | more
```
Network active pro... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | So you can do this used `apply` and `nested functions`
```
import pandas as pd
ID = [2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2002222,2002222,2002222,2002222,2002222,2002222,2002222,2002222,]
Date = ["10/30/2017","10/29/2017","10/28/2017","10/27/2017","10/26/2017","10/25/2017","1... | You can use a conditional statement combined with [`.shift()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.shift.html) to get previous row, and [`np.where`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) which AFAIK does *not* rely on loops as mentioned in a comment as s... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | Revised simpler:
```
df['expected'] = df.groupby(['ID',df.current.ne(0).cumsum()])['current']\
.transform(lambda x: x.eq(0).cumsum().mul(-1).add(x.iloc[0])).clip(0,np.inf)
```
Let's have a little fun:
```
df['expected'] = (df.groupby('ID')['current'].transform(lambda x: x.where(x.ne(0)).ffill()) +
df.groupby(['ID... | You can use a conditional statement combined with [`.shift()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.shift.html) to get previous row, and [`np.where`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) which AFAIK does *not* rely on loops as mentioned in a comment as s... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | So you can do this used `apply` and `nested functions`
```
import pandas as pd
ID = [2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2002222,2002222,2002222,2002222,2002222,2002222,2002222,2002222,]
Date = ["10/30/2017","10/29/2017","10/28/2017","10/27/2017","10/26/2017","10/25/2017","1... | Revised simpler:
```
df['expected'] = df.groupby(['ID',df.current.ne(0).cumsum()])['current']\
.transform(lambda x: x.eq(0).cumsum().mul(-1).add(x.iloc[0])).clip(0,np.inf)
```
Let's have a little fun:
```
df['expected'] = (df.groupby('ID')['current'].transform(lambda x: x.where(x.ne(0)).ffill()) +
df.groupby(['ID... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | So you can do this used `apply` and `nested functions`
```
import pandas as pd
ID = [2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2002222,2002222,2002222,2002222,2002222,2002222,2002222,2002222,]
Date = ["10/30/2017","10/29/2017","10/28/2017","10/27/2017","10/26/2017","10/25/2017","1... | EDIT: To address OP's concern about scaling up to millions of rows.
Yes, my original answer will not scale to very large dataframes. However, with minor edits, this easy-to-read solution will scale. The optimizations that follow take advantage of the JIT compiler in Numba. After importing Numba, I add the jit decorato... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | So you can do this used `apply` and `nested functions`
```
import pandas as pd
ID = [2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2002222,2002222,2002222,2002222,2002222,2002222,2002222,2002222,]
Date = ["10/30/2017","10/29/2017","10/28/2017","10/27/2017","10/26/2017","10/25/2017","1... | I believe @Tarun Lalwani had pointed you to one right direction. that is to save some critical information outside the DataFrame. the code can be simplified though, and there is nothing wrong with using global variables as long as you manage name properly. it's one of the design patterns which can often make things sim... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | So you can do this used `apply` and `nested functions`
```
import pandas as pd
ID = [2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2001980,2002222,2002222,2002222,2002222,2002222,2002222,2002222,2002222,]
Date = ["10/30/2017","10/29/2017","10/28/2017","10/27/2017","10/26/2017","10/25/2017","1... | Logic here should be work
```
lst=[]
for _, y in df.groupby('ID'):
z=[]
for i,(_, x) in enumerate(y.iterrows()):
print(x)
if x['current'] > 0:
z.append(x['current'])
else:
try:
z.append(max(z[i-1]-1,0))
except:
z.append(0... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | Revised simpler:
```
df['expected'] = df.groupby(['ID',df.current.ne(0).cumsum()])['current']\
.transform(lambda x: x.eq(0).cumsum().mul(-1).add(x.iloc[0])).clip(0,np.inf)
```
Let's have a little fun:
```
df['expected'] = (df.groupby('ID')['current'].transform(lambda x: x.where(x.ne(0)).ffill()) +
df.groupby(['ID... | EDIT: To address OP's concern about scaling up to millions of rows.
Yes, my original answer will not scale to very large dataframes. However, with minor edits, this easy-to-read solution will scale. The optimizations that follow take advantage of the JIT compiler in Numba. After importing Numba, I add the jit decorato... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | Revised simpler:
```
df['expected'] = df.groupby(['ID',df.current.ne(0).cumsum()])['current']\
.transform(lambda x: x.eq(0).cumsum().mul(-1).add(x.iloc[0])).clip(0,np.inf)
```
Let's have a little fun:
```
df['expected'] = (df.groupby('ID')['current'].transform(lambda x: x.where(x.ne(0)).ffill()) +
df.groupby(['ID... | I believe @Tarun Lalwani had pointed you to one right direction. that is to save some critical information outside the DataFrame. the code can be simplified though, and there is nothing wrong with using global variables as long as you manage name properly. it's one of the design patterns which can often make things sim... |
49,074,101 | This is the current dataframe:
```
> ID Date current
> 2001980 10/30/2017 1
> 2001980 10/29/2017 0
> 2001980 10/28/2017 0
> 2001980 10/27/2017 40
> 2001980 10/26/2017 39
> 2001980 10/25/2017 0
> 2001980 10/24/2017 0
> 2001980 10/23/2017 60
> 2001980 10/22/2017 ... | 2018/03/02 | [
"https://Stackoverflow.com/questions/49074101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6256904/"
] | Revised simpler:
```
df['expected'] = df.groupby(['ID',df.current.ne(0).cumsum()])['current']\
.transform(lambda x: x.eq(0).cumsum().mul(-1).add(x.iloc[0])).clip(0,np.inf)
```
Let's have a little fun:
```
df['expected'] = (df.groupby('ID')['current'].transform(lambda x: x.where(x.ne(0)).ffill()) +
df.groupby(['ID... | Logic here should be work
```
lst=[]
for _, y in df.groupby('ID'):
z=[]
for i,(_, x) in enumerate(y.iterrows()):
print(x)
if x['current'] > 0:
z.append(x['current'])
else:
try:
z.append(max(z[i-1]-1,0))
except:
z.append(0... |
8,143,471 | I realize that this question spans many technologies, but I am only looking for high-level contributions here.
I am currently tasked with exporting from a SQL Server proc into Excel, and then email the Excel file as attachment through SQL Agent. The SQL Agent job must be run daily.
What I have tried:
* SQL -> Excel ... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8143471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/844877/"
] | I'd definitely use SSIS. I'd have a Data Flow task reading the stored procedure output and writing to the Excel file, then a Send Mail task to handle the emailing of the resulting spreadsheet. (I've cleaned up Unicode vs. non-Unicode confusion in the past using Derived Column transformations in my Data Flows.)
SQL Age... | If you can write the export in .net, then in setting up the step for your job, one of the steps options is "Operating system (CmdExec)" which would allow you to point it to your .net application. |
8,143,471 | I realize that this question spans many technologies, but I am only looking for high-level contributions here.
I am currently tasked with exporting from a SQL Server proc into Excel, and then email the Excel file as attachment through SQL Agent. The SQL Agent job must be run daily.
What I have tried:
* SQL -> Excel ... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8143471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/844877/"
] | If you don't have SSIS on the server available to you, you can email attached CSV files using `sp_send_dbmail` with the right combination of parameters:
```
declare @tab char(1) = CHAR(9)
exec msdb.dbo.sp_send_dbmail @profile_name='dbProfile', @recipients='email@domain.com', @subject=@emailsubject, @attach_query_resu... | If you can write the export in .net, then in setting up the step for your job, one of the steps options is "Operating system (CmdExec)" which would allow you to point it to your .net application. |
8,143,471 | I realize that this question spans many technologies, but I am only looking for high-level contributions here.
I am currently tasked with exporting from a SQL Server proc into Excel, and then email the Excel file as attachment through SQL Agent. The SQL Agent job must be run daily.
What I have tried:
* SQL -> Excel ... | 2011/11/15 | [
"https://Stackoverflow.com/questions/8143471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/844877/"
] | I'd definitely use SSIS. I'd have a Data Flow task reading the stored procedure output and writing to the Excel file, then a Send Mail task to handle the emailing of the resulting spreadsheet. (I've cleaned up Unicode vs. non-Unicode confusion in the past using Derived Column transformations in my Data Flows.)
SQL Age... | If you don't have SSIS on the server available to you, you can email attached CSV files using `sp_send_dbmail` with the right combination of parameters:
```
declare @tab char(1) = CHAR(9)
exec msdb.dbo.sp_send_dbmail @profile_name='dbProfile', @recipients='email@domain.com', @subject=@emailsubject, @attach_query_resu... |
31,183,332 | When you open an image in a text editor you get some characters which don't really makes sense (at least not to me). Is there a way to add comments to that text, so the file would not apear damaged when opened with an image viewer.
So, something like this:

it seems there big hole there..
so you can use this to downgrade modifications to ver 2.0.1.1
[modification.ocmod.zip](https://drive.google.com/open?id=0B2-nzvg31rU7bU5zZWFaaEc4aGc)
this mod wi... |
31,183,332 | When you open an image in a text editor you get some characters which don't really makes sense (at least not to me). Is there a way to add comments to that text, so the file would not apear damaged when opened with an image viewer.
So, something like this:
:
`<file path="catalog/file-1.php,catalog/file-2.php,catalog/file-3.php">`
But this will work in 2.2.0.0:
`<file path="catalog/file-{1,2,3}.php">` | after i debug the code i found this
[error in modifications](https://drive.google.com/open?id=0B2-nzvg31rU7bUhRVlNKenRybDQ)
it seems there big hole there..
so you can use this to downgrade modifications to ver 2.0.1.1
[modification.ocmod.zip](https://drive.google.com/open?id=0B2-nzvg31rU7bU5zZWFaaEc4aGc)
this mod wi... |
31,183,332 | When you open an image in a text editor you get some characters which don't really makes sense (at least not to me). Is there a way to add comments to that text, so the file would not apear damaged when opened with an image viewer.
So, something like this:
:
`<file path="catalog/file-1.php,catalog/file-2.php,catalog/file-3.php">`
But this will work in 2.2.0.0:
`<file path="catalog/file-{1,2,3}.php">` | yes i find it, in file system/modification.xml
it was
```
<file path="system/{engine,library}/{action,loader,config,language}*.php">
```
now you can do it like this
```
<file path="system/engine/action.php,system/engine/loader.php,system/library/config.php,system/library/language.php">
``` |
38,066,209 | i want to show the image before inserting it to database after selecting an image from file, i want the image to show in the page. Can someone help me? im new to php and html and starting learn it. And if u know what will do can u explain it to me.
here is my php code.
```
<?php
session_start();
if(isset($_SESSION[... | 2016/06/28 | [
"https://Stackoverflow.com/questions/38066209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5438871/"
] | You can change the width and height of your imageview programmatically. Since vector drawables will preserve the original quality of the image, this will make the desired output happen.
```
ImageView iv = (ImageView) findViewById(R.id.imgview);
int width = 60;
int height = 60;
LinearLayout.LayoutParams params = new Li... | I'm currently facing the same problem.
I'm trying something like this, cause ViewParent has actually height set explicitly, so I use match\_parent and set margins. It doesn't work all the time though, cause I simply use this view in a viewholder for RecyclerView... Also I've noticed that sometimes I see scaled up vers... |
27,942,930 | We have a timestamp epoch column (BIGINT) stored in Hive.
We want to get Date 'yyyy-MM-dd' for this epoch.
Problem is my epoch is in milliseconds e.g. 1409535303522.
So select timestamp, from\_unixtime(timestamp,'yyyy-MM-dd') gives wrong results for date as it expects epoch in seconds.
So i tried dividing it by 1000. ... | 2015/01/14 | [
"https://Stackoverflow.com/questions/27942930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3322308/"
] | Solved it by following query:
```
select timestamp, from_unixtime(CAST(timestamp/1000 as BIGINT), 'yyyy-MM-dd') from Hadoop_V1_Main_text_archieved limit 10;
``` | **timestamp\_ms** is unixtime in milliseconds
>
> SELECT from\_unixtime(floor(CAST(timestamp\_ms AS BIGINT)/1000), 'yyyy-MM-dd HH:mm:ss.SSS') as created\_timestamp FROM table\_name;
>
>
> |
27,942,930 | We have a timestamp epoch column (BIGINT) stored in Hive.
We want to get Date 'yyyy-MM-dd' for this epoch.
Problem is my epoch is in milliseconds e.g. 1409535303522.
So select timestamp, from\_unixtime(timestamp,'yyyy-MM-dd') gives wrong results for date as it expects epoch in seconds.
So i tried dividing it by 1000. ... | 2015/01/14 | [
"https://Stackoverflow.com/questions/27942930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3322308/"
] | Solved it by following query:
```
select timestamp, from_unixtime(CAST(timestamp/1000 as BIGINT), 'yyyy-MM-dd') from Hadoop_V1_Main_text_archieved limit 10;
``` | In the original answer you'll get string, but if you'd like to get date you need to call extra cast with date:
```
select
timestamp,
cast(from_unixtime(CAST(timestamp/1000 as BIGINT), 'yyyy-MM-dd') as date) as date_col
from Hadoop_V1_Main_text_archieved
limit 10;
```
---
[Docs](https://cwiki.apache.org/... |
27,942,930 | We have a timestamp epoch column (BIGINT) stored in Hive.
We want to get Date 'yyyy-MM-dd' for this epoch.
Problem is my epoch is in milliseconds e.g. 1409535303522.
So select timestamp, from\_unixtime(timestamp,'yyyy-MM-dd') gives wrong results for date as it expects epoch in seconds.
So i tried dividing it by 1000. ... | 2015/01/14 | [
"https://Stackoverflow.com/questions/27942930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3322308/"
] | Solved it by following query:
```
select timestamp, from_unixtime(CAST(timestamp/1000 as BIGINT), 'yyyy-MM-dd') from Hadoop_V1_Main_text_archieved limit 10;
``` | The type should be `double` to ensure precision is not lost:
```
select from_unixtime(cast(1601256179170 as double)/1000.0, "yyyy-MM-dd hh:mm:ss.SSS") as event_timestamp
``` |
46,429,251 | I've recently programmed a lot in javascript and I was trying to use some shorthands in PHP.
Consider this statement:
```
$value = 1;
return $value == 1 ?
'a' : $value == 2 ? 'b' : 'c';
```
Could anyone explain me why this returns `'a'` in jQuery and `'b'` in php? | 2017/09/26 | [
"https://Stackoverflow.com/questions/46429251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1272001/"
] | In PHP, the ternary operator is [left-associative](http://phpsadness.com/sad/30) (or from [the manual](http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary), a little less clear).
>
> this is because ternary expressions are evaluated from left to right
>
>
>
In Javascri... | You need to wrap the "else" part of the condition in parantheses
```
$value = 1;
echo $value == 1 ? 'a' : ($value == 2 ? 'b' : 'c');
```
This would return 'a' in php |
46,429,251 | I've recently programmed a lot in javascript and I was trying to use some shorthands in PHP.
Consider this statement:
```
$value = 1;
return $value == 1 ?
'a' : $value == 2 ? 'b' : 'c';
```
Could anyone explain me why this returns `'a'` in jQuery and `'b'` in php? | 2017/09/26 | [
"https://Stackoverflow.com/questions/46429251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1272001/"
] | In PHP, the ternary operator is [left-associative](http://phpsadness.com/sad/30) (or from [the manual](http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary), a little less clear).
>
> this is because ternary expressions are evaluated from left to right
>
>
>
In Javascri... | Use parenthesis do define the correct order of evaluation :
```
$value == 1 ? 'a' : ($value == 2 ? 'b' : 'c')
``` |
17,084,128 | How to create a new `dm_document` object using document from local system using DQL? I have tried the following but it's not working:
```
create dm_document object
SET title = 'TEST',
SET subject = 'TRIAL',
set object_name = 'Test123',
SETFILE 'c:\test.txt' with CONTENT_FORMAT= 'msww'
``` | 2013/06/13 | [
"https://Stackoverflow.com/questions/17084128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2481709/"
] | How do you run this DQL?
If you're doing it via Documentum Administrator, Documentum looks for the file with path 'C:\test.txt' on an application server machine wherer DA runs. So if you want to upload it into documentum you must place this file into appserver machine or use another tool for execution DQL.
And could y... | **Your DQL works for me** (!) but after clean any line-warp, so try this
```
create dm_document object SET title = 'TEST', SET subject = 'TRIAL', set object_name = 'Test123', SETFILE 'c:\test.txt' with CONTENT_FORMAT= 'msww'
```
...and be sure there is a such file on Content Server (not local) file system
good luck |
39,026,100 | Say I want to `touch` six files
```
one.html
one.css
two.html
two.css
three.html
three.css
```
How can I use `xargs` for this? I'm looking at the man page but I'm not sure on the syntax for getting the stdin pipe.
```
$ echo one two three | xargs -n 1 touch $1.html $1.css // nope
``` | 2016/08/18 | [
"https://Stackoverflow.com/questions/39026100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4769440/"
] | It is easier to do via shell ist:
```
touch {one,two,three}.{css,html}
```
This will create 6 files:
```
one.css one.html two.css two.html three.css three.html
``` | alternative with for loop
```
for f in one two three; do touch $f.html $f.css; done
``` |
39,026,100 | Say I want to `touch` six files
```
one.html
one.css
two.html
two.css
three.html
three.css
```
How can I use `xargs` for this? I'm looking at the man page but I'm not sure on the syntax for getting the stdin pipe.
```
$ echo one two three | xargs -n 1 touch $1.html $1.css // nope
``` | 2016/08/18 | [
"https://Stackoverflow.com/questions/39026100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4769440/"
] | If it is important to use `xargs`:
```
printf "%s\n" one two three | xargs -I{} touch {}.html {}.css
``` | alternative with for loop
```
for f in one two three; do touch $f.html $f.css; done
``` |
51,561,839 | I am implementing the CORS protocol within a server, following the [CORS standard](https://fetch.spec.whatwg.org/#cors-protocol "CORS standard"). My question is how the server should respond when it wishes to deny a *particular* Origin.
I understand how to respond to simple and preflight requests when the Origin is al... | 2018/07/27 | [
"https://Stackoverflow.com/questions/51561839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1538270/"
] | >
> Is [a 403 error status] the correct way to respond to Origins that the server does not want to allow? It seems it could be misinterpreted by the client as "this server won't allow any cross origin requests" (when in reality, the problem is with this particular Origin, and the server would allow other Origins).
>
... | CORS is disabled by default so if you do not want a given host to get the response, do not add them to the CORS Access-Control-Allow-Origin header returned by the server
>
> Access-Control-Allow-Origin: <https://www.example.com>
>
>
>
If a host makes a request to your server and they are not listed in this header... |
27,264 | How can I find a Chevalley basis of a type $B\_2$ when the related Lie algebra is defined as a linear Lie algebra of elements of the form $$x= \begin{pmatrix} 0 & b\_1 & b\_2 \\ c\_1 & m & n \\ c\_2 & p & q \end{pmatrix},$$ where $c\_1=-b\_2^t$, $c\_2=-b\_1^t$, $q=-m^t$, $n^t=-n$, $p^t=-p$?
When trying to find such a ... | 2011/03/15 | [
"https://math.stackexchange.com/questions/27264",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/4736/"
] | Try
>
> Assuming[Element[b,Reals],~rest of your code~]
>
>
>
**EDIT** then how about
>
> b /. Solve[expr == 0, b]
>
>
> N[b]
>
>
> Select[%,Element[#,Reals] & ]
>
>
>
I tried this using a regular polynomial with complex solutions and it worked in my case, should work in yours.
i.e, Create a list of sol... | Look at the FullForm to see what pattern you need to match.
In[1]:= FullForm[(-1)^(1/5)]
Out[1]//FullForm= Power[-1,Rational[1,5]]
Use DeleteCases to discard the unwanted solutions.
In[2]:= DeleteCases[{(-1)^(1/5)\*p/q\*4,(-1)^(1/5)\*Pi,-p/q\*5Pi},Power[-1,Rational[1,5]]\*\_]
Out[2]= {-(5 p Pi)/q)}
That will work... |
27,264 | How can I find a Chevalley basis of a type $B\_2$ when the related Lie algebra is defined as a linear Lie algebra of elements of the form $$x= \begin{pmatrix} 0 & b\_1 & b\_2 \\ c\_1 & m & n \\ c\_2 & p & q \end{pmatrix},$$ where $c\_1=-b\_2^t$, $c\_2=-b\_1^t$, $q=-m^t$, $n^t=-n$, $p^t=-p$?
When trying to find such a ... | 2011/03/15 | [
"https://math.stackexchange.com/questions/27264",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/4736/"
] | Try
>
> Assuming[Element[b,Reals],~rest of your code~]
>
>
>
**EDIT** then how about
>
> b /. Solve[expr == 0, b]
>
>
> N[b]
>
>
> Select[%,Element[#,Reals] & ]
>
>
>
I tried this using a regular polynomial with complex solutions and it worked in my case, should work in yours.
i.e, Create a list of sol... | Method 1
```
roots = x /. Solve[x^5 == 1, x]
result1 = Select[roots, Im@# == 0 &]
```
Method 2
```
result2 = Solve[x^5 == 1, x, Reals]
```
Method 3
```
result3 = Reduce[x^5==1&&Element[x,Reals]]
```
Note that `result1` is a list of numbers, `result2` is list of lists of rules and `result3` is an expression |
27,264 | How can I find a Chevalley basis of a type $B\_2$ when the related Lie algebra is defined as a linear Lie algebra of elements of the form $$x= \begin{pmatrix} 0 & b\_1 & b\_2 \\ c\_1 & m & n \\ c\_2 & p & q \end{pmatrix},$$ where $c\_1=-b\_2^t$, $c\_2=-b\_1^t$, $q=-m^t$, $n^t=-n$, $p^t=-p$?
When trying to find such a ... | 2011/03/15 | [
"https://math.stackexchange.com/questions/27264",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/4736/"
] | Method 1
```
roots = x /. Solve[x^5 == 1, x]
result1 = Select[roots, Im@# == 0 &]
```
Method 2
```
result2 = Solve[x^5 == 1, x, Reals]
```
Method 3
```
result3 = Reduce[x^5==1&&Element[x,Reals]]
```
Note that `result1` is a list of numbers, `result2` is list of lists of rules and `result3` is an expression | Look at the FullForm to see what pattern you need to match.
In[1]:= FullForm[(-1)^(1/5)]
Out[1]//FullForm= Power[-1,Rational[1,5]]
Use DeleteCases to discard the unwanted solutions.
In[2]:= DeleteCases[{(-1)^(1/5)\*p/q\*4,(-1)^(1/5)\*Pi,-p/q\*5Pi},Power[-1,Rational[1,5]]\*\_]
Out[2]= {-(5 p Pi)/q)}
That will work... |
368,512 | [This answer](https://stackoverflow.com/a/50485404/3094533) was accepted as correct.
It contains only a line of code (that actually does what the OP is asking) without any explanation whatsoever. Another user commented with a link to a Wikipedia explaining the math behind it, and I've left a comment asking the autho... | 2018/05/24 | [
"https://meta.stackoverflow.com/questions/368512",
"https://meta.stackoverflow.com",
"https://meta.stackoverflow.com/users/3094533/"
] | >
> So after I've already asked nicely for an explanation, what else can I do about it? Should I do anything else?
>
>
>
You could always add an answer with an explanation if you are knowledgeable on the subject. Just because the answer is accepted by OP does not mean it is a good/helpful for others. Neither does ... | If the explanation is straightforward and obvious, and you are confident in your ability to write it in a clear way, editing it into the answer can be a reasonable thing to do -- if that is the case, you can be reasonably sure you won't end up accidentally changing the meaning of the answer.
A few things to keep in mi... |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try running the command `flutter pub get -v`.
It shows the log and can even solve the problem. | When all other command don't working (in my case is my antivirus block `flutter` command), I launch in my project folder:
>
> /flutter/bin/cache/dart-sdk/bin/dart
> \_\_deprecated\_pub --verbose get --no-precompile
>
>
>
the command stop on rename folder error.
I rename with `cp` command the folder and after the... |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try to disable your antivirus for like 5 minutes and then go to the flutter directory
**C:\src\flutter**
and run the command
>
> *flutter pub global activate devtools*
>
>
>
**Note:** The flutter path should be set in env variables before running this. | When all other command don't working (in my case is my antivirus block `flutter` command), I launch in my project folder:
>
> /flutter/bin/cache/dart-sdk/bin/dart
> \_\_deprecated\_pub --verbose get --no-precompile
>
>
>
the command stop on rename folder error.
I rename with `cp` command the folder and after the... |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try running the command `flutter pub get -v`.
It shows the log and can even solve the problem. | run flutter pub get -v
this will show you what folder it is trying to rename to what. Manually rename the folder and place it in the path it was trying to place. re-run flutter pub get -v, repeat until it says exit with 0. |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try running the command `flutter pub get -v`.
It shows the log and can even solve the problem. | Do "pub cache repair"
and try "pub get" |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try running the command `flutter pub get -v`.
It shows the log and can even solve the problem. | Try to disable your antivirus for like 5 minutes and then go to the flutter directory
**C:\src\flutter**
and run the command
>
> *flutter pub global activate devtools*
>
>
>
**Note:** The flutter path should be set in env variables before running this. |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Run the following command:
```
flutter pub global activate devtools
```
Then try to get the packages again.
I hope this helps fix the issue | run flutter pub get -v
this will show you what folder it is trying to rename to what. Manually rename the folder and place it in the path it was trying to place. re-run flutter pub get -v, repeat until it says exit with 0. |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try to disable your antivirus for like 5 minutes and then go to the flutter directory
**C:\src\flutter**
and run the command
>
> *flutter pub global activate devtools*
>
>
>
**Note:** The flutter path should be set in env variables before running this. | run flutter pub get -v
this will show you what folder it is trying to rename to what. Manually rename the folder and place it in the path it was trying to place. re-run flutter pub get -v, repeat until it says exit with 0. |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | I had the same issue. None of the answers worked. I deleted .dart\_tool folder in the project folder and it worked :) | Do "pub cache repair"
and try "pub get" |
63,324,647 | I am plotting countries on map using plotly and r shiny. I would like subset of data containing rows about the country to appear in the form of data table on clicking on country on a map. But I am unable to implement it. I get the table but there is not data displayed in the table. Any help would be appreciated!
```
M... | 2020/08/09 | [
"https://Stackoverflow.com/questions/63324647",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13017372/"
] | Try to disable your antivirus for like 5 minutes and then go to the flutter directory
**C:\src\flutter**
and run the command
>
> *flutter pub global activate devtools*
>
>
>
**Note:** The flutter path should be set in env variables before running this. | This is how I proceeded to resolve that problem:
First I had to run the command bellow to see in details what he is trying to rename:
```
flutter pub get -v
```
After that in the console I searched for the term "**renaming**" and I found this:
[](h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.