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 |
|---|---|---|---|---|---|
515,094 | How can we distinguish between the metric expansion of space and the speed of light slowing over time?
I understand that the universe is expanding. But it seems that our main measurement techniques involve assuming the speed of light is constant over time. I know that we *define* length in terms of a constant speed of... | 2019/11/20 | [
"https://physics.stackexchange.com/questions/515094",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/218022/"
] | Type 1a supernovae explode with a fixed luminosity, then fade over a fixed time.
If the speed of light varies over cosmic time, the light will be redshifted for more distant supernovae, but the duration of the fading will on average be the same. Cosmic expansion, on the other hand, will increase the wavelength of the... | I would just like to point out that Type 1a supernovae can not be
used to differentiate between cosmic expansion and variable speed
of light.
Since the the speed of light is a dimensionful constant, local
changes are not observable. Locally a supernova will not have a
redshift nor fade more slowly. However when observ... |
515,094 | How can we distinguish between the metric expansion of space and the speed of light slowing over time?
I understand that the universe is expanding. But it seems that our main measurement techniques involve assuming the speed of light is constant over time. I know that we *define* length in terms of a constant speed of... | 2019/11/20 | [
"https://physics.stackexchange.com/questions/515094",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/218022/"
] | Cosmological expansion has observable effects, such as redshifts.
A change in a dimensionful constant is unobservable. See [Is it possible to speak about changes in a physical constant which is not dimensionless?](https://physics.stackexchange.com/questions/78684/is-it-possible-to-speak-about-changes-in-a-physical-con... | I would just like to point out that Type 1a supernovae can not be
used to differentiate between cosmic expansion and variable speed
of light.
Since the the speed of light is a dimensionful constant, local
changes are not observable. Locally a supernova will not have a
redshift nor fade more slowly. However when observ... |
28,815,976 | I'm implementing a UITableView with text-views as the content view of my cells.
The data that the user enters is saved in a settings dictionary when the user hits the return key:
```
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
if (textField == _textFieldOne){
[settingsDictionary setObject: ... | 2015/03/02 | [
"https://Stackoverflow.com/questions/28815976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2317675/"
] | Check your `cellForRowAtIndexPath`, as cells are reused, you are probably not loading the cell property.
```
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
/*
* This is an important bit, it asks the table view if it has any available cells
* ... | Ok, it is as I suspected. Every time the cell is taken out out the reuse queue, you create a new instance of textfield and add it to the content view. So basically the content view is piling up with new textfields.
What you should do is
1) to have a custom cell and make the cell the sole class responsible for its in... |
12,834,017 | 
I have this spritesheet and I have to repeat each column horizontally to the left for different backgrounds. How can I achieve this? I played arround with background-position, background-repeat and background-size but I can´t achieve the desired behaviour. Anyone kno... | 2012/10/11 | [
"https://Stackoverflow.com/questions/12834017",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/635504/"
] | I better you can create sprite **vertical** instead of **horizontal** .
**Like this :**
 | Why don't you save each color seperately and dynamically build your background according to what you need?
So just repeat the color you want repeated and then append the others on the sides if you want them.
Also: Please be more specific as to the effect you want to achieve. |
3,495,133 | I would like to serve high quality video (H.264) between a server and a single Flash Player client with low latency (RTMFP). The single client will be controlling a robotic device and seeing the results through the video stream, so low latency is important.
Option A: The Flash Player supports low latency streaming of ... | 2010/08/16 | [
"https://Stackoverflow.com/questions/3495133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158850/"
] | Correct, currently the release version of the flash player doesn't encode outgoing (published) video in the h.264 format. However if you get the labs version of the flash player labs.adobe.com, the next version of flash is going to support live encoding (and publishing) of h.264. This will also work in your p2p scenari... | Try this one
<http://red5.org/>
or another new P2P technology
<http://labs.adobe.com/technologies/stratus/> |
3,495,133 | I would like to serve high quality video (H.264) between a server and a single Flash Player client with low latency (RTMFP). The single client will be controlling a robotic device and seeing the results through the video stream, so low latency is important.
Option A: The Flash Player supports low latency streaming of ... | 2010/08/16 | [
"https://Stackoverflow.com/questions/3495133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/158850/"
] | Flash now supports h.264
Set it up like this:
```
if (Camera.names.length > 0) {
h264Settings = new H264VideoStreamSettings();
h264Settings.setProfileLevel(H264Profile.BASELINE, H264Level.LEVEL_3_1);
cam = Camera.getCamera();
cam.setMode(384,288,16,true);
cam.setKeyFrameInterval(8);
cam.setQ... | Try this one
<http://red5.org/>
or another new P2P technology
<http://labs.adobe.com/technologies/stratus/> |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | There once was a guy named Ragnar from Denmark. He and a couple of his best pals built a sailboat without the use of any powered tools and without using any materials they didn't process themselves from natural resources. They then took them on a trip all the way from Denmark along the coast of Germany, the Netherlands... | **Simple:**
Boat from Dover-to-Calais (it's like, (edit:) twenty miles)
**Extreme:**
In the future, there's an ice-age sucking up a lot of the earth's oceanic mass; there's now a land-bridge like during the last ice-age (doggerland)
[](https://i.st... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | As it turns out, flooding does not matter. As you can see from the elevation map below, most of the land between the strait and Paris is higher than Paris itself. For Paris to still exist you need less than a 70 meter rise in sea level, but most of the land in between is 120-180 m above sea level. Even if you raise sea... | Boats? The Romans did it, sometimes with whole armies: <https://en.wikipedia.org/wiki/Roman_conquest_of_Britain> The Phoenecians did it much earlier, with cargos of tin: <https://en.wikipedia.org/wiki/Phoenicia> And if you're in really good shape, you could swim :-) <https://en.wikipedia.org/wiki/List_of_successful_Eng... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | Boats? The Romans did it, sometimes with whole armies: <https://en.wikipedia.org/wiki/Roman_conquest_of_Britain> The Phoenecians did it much earlier, with cargos of tin: <https://en.wikipedia.org/wiki/Phoenicia> And if you're in really good shape, you could swim :-) <https://en.wikipedia.org/wiki/List_of_successful_Eng... | Let's look at it obviously: We have a big water to cross. So we need a floating object, which usually is a boat. Boats are with humanity since the stoneage, starting with unihulls and canooes for fishing and then going to bigger rafts, outrigger-canoes and ships for netfishing, then pure transport vessels were develope... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | There once was a guy named Ragnar from Denmark. He and a couple of his best pals built a sailboat without the use of any powered tools and without using any materials they didn't process themselves from natural resources. They then took them on a trip all the way from Denmark along the coast of Germany, the Netherlands... | They only need a king on board. Why?
Kings Never Drown.
==================
One of the most interesting bits of British Isles mythology is that rulers (originally kings, but it got extended (no surprise) in the Elizabethan era) are rulers because of divine right. God put them on the throne, and God would not allow th... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | Boats? The Romans did it, sometimes with whole armies: <https://en.wikipedia.org/wiki/Roman_conquest_of_Britain> The Phoenecians did it much earlier, with cargos of tin: <https://en.wikipedia.org/wiki/Phoenicia> And if you're in really good shape, you could swim :-) <https://en.wikipedia.org/wiki/List_of_successful_Eng... | The short answer: it's not possible that no one in England would not know anyone is in France because of things in your very premise and in history.
1) As others have pointed out, much, much earlier than the 17th century with much, much earlier tech, people were aware and traveled to and fro. I'm talking Bronze age. I... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | The short answer: it's not possible that no one in England would not know anyone is in France because of things in your very premise and in history.
1) As others have pointed out, much, much earlier than the 17th century with much, much earlier tech, people were aware and traveled to and fro. I'm talking Bronze age. I... | **Simple:**
Boat from Dover-to-Calais (it's like, (edit:) twenty miles)
**Extreme:**
In the future, there's an ice-age sucking up a lot of the earth's oceanic mass; there's now a land-bridge like during the last ice-age (doggerland)
[](https://i.st... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | There is always the way they used to:
By Boat. Sail boat, Row Boat, viking longboat, doesn't really matter. The travelers are going to be the Same as smugglers from ages past.
France has a pretty long coastline, so all you really need to do is find a small out of the way cove and drop anchor then take a small rowboat... | **Simple:**
Boat from Dover-to-Calais (it's like, (edit:) twenty miles)
**Extreme:**
In the future, there's an ice-age sucking up a lot of the earth's oceanic mass; there's now a land-bridge like during the last ice-age (doggerland)
[](https://i.st... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | As it turns out, flooding does not matter. As you can see from the elevation map below, most of the land between the strait and Paris is higher than Paris itself. For Paris to still exist you need less than a 70 meter rise in sea level, but most of the land in between is 120-180 m above sea level. Even if you raise sea... | **Simple:**
Boat from Dover-to-Calais (it's like, (edit:) twenty miles)
**Extreme:**
In the future, there's an ice-age sucking up a lot of the earth's oceanic mass; there's now a land-bridge like during the last ice-age (doggerland)
[](https://i.st... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | As it turns out, flooding does not matter. As you can see from the elevation map below, most of the land between the strait and Paris is higher than Paris itself. For Paris to still exist you need less than a 70 meter rise in sea level, but most of the land in between is 120-180 m above sea level. Even if you raise sea... | There once was a guy named Ragnar from Denmark. He and a couple of his best pals built a sailboat without the use of any powered tools and without using any materials they didn't process themselves from natural resources. They then took them on a trip all the way from Denmark along the coast of Germany, the Netherlands... |
166,732 | This is a continuation of my last question about how long it would take the tunnel between the two countries to fall apart. So let's say that there's a group of people who have no more than 17th century technology; how would they get from England to France? I was originally planning for them to take the tunnel, but app... | 2020/01/27 | [
"https://worldbuilding.stackexchange.com/questions/166732",
"https://worldbuilding.stackexchange.com",
"https://worldbuilding.stackexchange.com/users/71919/"
] | There is always the way they used to:
By Boat. Sail boat, Row Boat, viking longboat, doesn't really matter. The travelers are going to be the Same as smugglers from ages past.
France has a pretty long coastline, so all you really need to do is find a small out of the way cove and drop anchor then take a small rowboat... | Let's look at it obviously: We have a big water to cross. So we need a floating object, which usually is a boat. Boats are with humanity since the stoneage, starting with unihulls and canooes for fishing and then going to bigger rafts, outrigger-canoes and ships for netfishing, then pure transport vessels were develope... |
52,256,652 | In my app I have some UITextFeilds but when I run my app and trying to write I can't see the keyboard.

I tried [this](https://stackoverflow.com/a/24497773/10326766) answer, but probably my xcode version isn't the same as there, I'm using xcode9.
![... | 2018/09/10 | [
"https://Stackoverflow.com/questions/52256652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10326766/"
] | You're already using the right options. `DOMDocument::$formatOutput` and `DOMDocument::$preserveWhiteSpace`:
### Format Output
`DOMDocument::$formatOutput` adds indentation whitespace nodes to an XML DOM if saved. (It is disabled by default.)
```
$document = new DOMDocument();
$body = $document->appendChild($documen... | Try this, you have to use saveXML() instead of save(),
```
<?php
$xml = new DOMDocument('1.0');
$xml->preserveWhiteSpace = false;
$xml->formatOutput = false;
$root = $xml->createElement('book');
$root = $xml->appendChild($root);
$title = $xml->createElement('title');
$title = $root->appendChild($title);
$text = ... |
1,150,289 | I need to render some formatted text (colours, different font sizes, underlines, bold, etc) however I'm not sure how to go about doing it. D3DXFont only allows text of a single font/size/weight/colour/etc to be rendered at once, and I cant see a practical way to "combine" multiple calls to ID3DXFont::DrawText to do suc... | 2009/07/19 | [
"https://Stackoverflow.com/questions/1150289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | You tagged this with Direct3D, so I'm going to assume that's the target environment. Otherwise, GDI can handle all this stuff.
Actually, looking at GDI is a good place to start, since it supports this as it stands. With GDI, there is only a single font selected at a time for drawing text. Similarly, there can only be ... | I suggest measuring the performance of rendering to a bitmap and uploading to a texture.
I suspect that this pretty much what D3DXFont has to do behing the scenes anyway.
You could probably cache letters / phrases etc. if needed |
1,150,289 | I need to render some formatted text (colours, different font sizes, underlines, bold, etc) however I'm not sure how to go about doing it. D3DXFont only allows text of a single font/size/weight/colour/etc to be rendered at once, and I cant see a practical way to "combine" multiple calls to ID3DXFont::DrawText to do suc... | 2009/07/19 | [
"https://Stackoverflow.com/questions/1150289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6266/"
] | In case of using Direct3D9 or early you really have big problems:
1. You always may use GDI, render your text in the HDC, copy it to the Direct3D dynamic texture and use shader to replace background to transparency by color key for example.
2. Take a look on [FreeType](http://freetype.org/) library may be you'll find ... | I suggest measuring the performance of rendering to a bitmap and uploading to a texture.
I suspect that this pretty much what D3DXFont has to do behing the scenes anyway.
You could probably cache letters / phrases etc. if needed |
55,724,189 | For a future use in a jupyter context, I want to try julia through a conda installation. To do so I did the following:
```
conda create -n test_julia
conda activate test_julia
conda install -c conda-forge julia
```
From there I can start julia. However when trying, for instance, the gadfly module for doing basic tes... | 2019/04/17 | [
"https://Stackoverflow.com/questions/55724189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/406014/"
] | before updating the state of the component you need to check does it mounted?? if not mounted then do not update to state of it,to do it you will need to maintain flag indicating the mount status of component
consiger the following code
```
constructor(props){
super(props);
this.state={
userData:""
};
... | The problem is that you are trying to set your state after your component has been unmounted (ex: navigating to another page). So to prevent it for happening try this one:
```
_isMounted = false;
componentDidMount(){
this._isMounted = true;
}
componentWillUnmount(){
this._isMounted = ... |
55,724,189 | For a future use in a jupyter context, I want to try julia through a conda installation. To do so I did the following:
```
conda create -n test_julia
conda activate test_julia
conda install -c conda-forge julia
```
From there I can start julia. However when trying, for instance, the gadfly module for doing basic tes... | 2019/04/17 | [
"https://Stackoverflow.com/questions/55724189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/406014/"
] | you need unsubscribe when component will unmount.
```
onAuthStatusChange = response => {
console.log("event",response);
if (response.authResponse) {
this.checkLoginState();
} else {
console.log('[FacebookLoginButton] User cancelled login or did not fully authorize.');
}
}
```
...
```
window.FB.Event... | The problem is that you are trying to set your state after your component has been unmounted (ex: navigating to another page). So to prevent it for happening try this one:
```
_isMounted = false;
componentDidMount(){
this._isMounted = true;
}
componentWillUnmount(){
this._isMounted = ... |
36,308,295 | Please show me how to drive the `stream-withdraw` function from SICP [section 3.5.5](https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-24.html#%_sec_3.5.5) correctly.
```
(define (stream-cons a b) (cons a (delay b)))
(define (stream-car s) (car s))
(define (stream-cdr s) (force (cdr s)))
(defi... | 2016/03/30 | [
"https://Stackoverflow.com/questions/36308295",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4453951/"
] | When a table name or column name contains a space or it is a [reserved word](https://support.office.com/en-us/article/Access-2007-reserved-words-and-symbols-e33eb3a9-8baa-4335-9f57-da237c63eabe?CorrelationId=f03e97a5-01d2-4ed7-aa40-48d2da9d5215&ui=en-US&rs=en-US&ad=US) you need to enclose that name in square brackets t... | Also, you must use the values of the DateTimePickers, not strings:
```
command.Parameters.AddWithValue("@Date", dateofdateTimePicker2.Value);
command.Parameters.AddWithValue("@DOB", dobdateTimePicker1.Value);
```
and to state the field names:
```
command.CommandText = "INSERT INTO [statement workers] (fielname1, fi... |
10,307,037 | what the `save()` and `restore()` methods in the [Camera](http://developer.android.com/reference/android/graphics/Camera.html)
class do ? can any one explain ? | 2012/04/24 | [
"https://Stackoverflow.com/questions/10307037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/838793/"
] | The Camera class that you linked to, android.hardware.Camera does not have a save() or restore() method.
Why do you think it does? Where are you seeing it?
Peter | I looked up the source to android.graphics.Camera. Those two methods are native methods. You might find these links to Android XRef useful (since I only know java, not C). [android.graphics.Camera native source](http://androidxref.com/source/xref/frameworks/base/core/jni/android/graphics/Camera.cpp), and [SkCamera](htt... |
10,307,037 | what the `save()` and `restore()` methods in the [Camera](http://developer.android.com/reference/android/graphics/Camera.html)
class do ? can any one explain ? | 2012/04/24 | [
"https://Stackoverflow.com/questions/10307037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/838793/"
] | android.graphics.Canvas and android.graphics.Camera classes help you to manipulate transformation matrix (3D transformations especially for android.graphics.Camera).
The top of matrix stack is applied for transformation, so if you want to manipulate new transformation matrix,
1. you should push the current matrix in... | I looked up the source to android.graphics.Camera. Those two methods are native methods. You might find these links to Android XRef useful (since I only know java, not C). [android.graphics.Camera native source](http://androidxref.com/source/xref/frameworks/base/core/jni/android/graphics/Camera.cpp), and [SkCamera](htt... |
52,319,714 | When I start the program, I can't see the *helloworld* and I looked at your answers about the issue, but it does not work at all.
Here's what it appears:

Does anyone have any suggestions? | 2018/09/13 | [
"https://Stackoverflow.com/questions/52319714",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10360078/"
] | You don't state your environment, but most likely it behaves similar to Eclipse (maybe it is Eclipse?) in that a line through the code is an indication that you're using a deprecated API. In this case, if you go to the Junit API documentation, you'll see that assertEquals for doubles like you are calling is deprecated ... | Line crossing out means the method is deprecated. <http://junit.sourceforge.net/javadoc/org/junit/Assert.html#assertEquals(double>, double)
The new method to use is below
public static void assertEquals(double expected,
double actual,
double delta)
The delta is how much difference the actual and expected can have. |
46,128 | I want to start developing emacs packages. I would like to use cask, so I did:
```
$ cask init --dev
```
It worked well, and generated the Cask file
```
tree -La 1
.
├── .git
├── .gitignore
├── Cask
└── README.org
```
Then when I try cask install, I always get the same error:
```
cask install ... | 2018/11/21 | [
"https://emacs.stackexchange.com/questions/46128",
"https://emacs.stackexchange.com",
"https://emacs.stackexchange.com/users/8892/"
] | ```el
(defface my-read-only '((default . (:background "beige")))
"Face for `my-read-only-region'")
(defun my-read-only-region (begin end)
"Make the marked region read-only. See also `my-writeable-region'.
Read-only text is given the face `my-read-only'."
(interactive "r")
(let ((inhibit-read-only t))
(wi... | @phils said how to deal with the problem programmatically.
Here is how to deal with it interactively:
* Select the region
* Menu `Edit` -> `Text Properties` -> `Special Properties` -> `Read-Only` |
19,783,606 | I've created a WPF vb.net form containing datagrid. Inside of datagrid I have two comboboxes and two textboxes, one combobox textbox pair for articles and another one for services. I should bind first combo to property of List(Of article) type and second to List(Of service) type where article is public class containing... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930100/"
] | Here is the problem:
```
// ...
stringstream ss;
// ...
return ss.str().c_str(); // woops! ss goes out of scope and string will be destroyed!
```
This can be easily solved by making your function return `std::string` instead of `char const*` and doing this:
```
return ss.str();
```
There is no reason to return `c... | There are two different problems. First you obviously can not return `const char *` from function which is stack-allocated. So you have to have it allocated at the heap. And this is the problem. It is problem of ownership. Where you have to `delete` this string? It can be easily solved by using `std::string`.
Second p... |
19,783,606 | I've created a WPF vb.net form containing datagrid. Inside of datagrid I have two comboboxes and two textboxes, one combobox textbox pair for articles and another one for services. I should bind first combo to property of List(Of article) type and second to List(Of service) type where article is public class containing... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930100/"
] | Here is the problem:
```
// ...
stringstream ss;
// ...
return ss.str().c_str(); // woops! ss goes out of scope and string will be destroyed!
```
This can be easily solved by making your function return `std::string` instead of `char const*` and doing this:
```
return ss.str();
```
There is no reason to return `c... | If you absolutly have to use null-terminated C-Strings, than rather use [sprintf](http://www.cplusplus.com/reference/cstdio/sprintf/) instead of std::stringstream. Mixing C and C++ like this is considered bad practice (like pointed out already: i.e. you have to manage memory manually). Also there are some other issues ... |
19,783,606 | I've created a WPF vb.net form containing datagrid. Inside of datagrid I have two comboboxes and two textboxes, one combobox textbox pair for articles and another one for services. I should bind first combo to property of List(Of article) type and second to List(Of service) type where article is public class containing... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930100/"
] | Here is the problem:
```
// ...
stringstream ss;
// ...
return ss.str().c_str(); // woops! ss goes out of scope and string will be destroyed!
```
This can be easily solved by making your function return `std::string` instead of `char const*` and doing this:
```
return ss.str();
```
There is no reason to return `c... | Thank you all for your answers.
However, none of them worked as I intended.(especially, it's not for outputting, but for making a string object.)
I ended up achieving what I wanted, but it's by no means good.
I attach my program, though, below. Feel free to comment.
Thank you.
```
void file_info(char*, stringstrea... |
19,783,606 | I've created a WPF vb.net form containing datagrid. Inside of datagrid I have two comboboxes and two textboxes, one combobox textbox pair for articles and another one for services. I should bind first combo to property of List(Of article) type and second to List(Of service) type where article is public class containing... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930100/"
] | To answer your iostream formatting question, you want std::setw
```
std::cout << "'" << std::setw(16) << "Hello" << "'" << std::endl;
```
<http://faculty.cs.niu.edu/~mcmahon/CS241/c241man/node83.html> | There are two different problems. First you obviously can not return `const char *` from function which is stack-allocated. So you have to have it allocated at the heap. And this is the problem. It is problem of ownership. Where you have to `delete` this string? It can be easily solved by using `std::string`.
Second p... |
19,783,606 | I've created a WPF vb.net form containing datagrid. Inside of datagrid I have two comboboxes and two textboxes, one combobox textbox pair for articles and another one for services. I should bind first combo to property of List(Of article) type and second to List(Of service) type where article is public class containing... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930100/"
] | To answer your iostream formatting question, you want std::setw
```
std::cout << "'" << std::setw(16) << "Hello" << "'" << std::endl;
```
<http://faculty.cs.niu.edu/~mcmahon/CS241/c241man/node83.html> | If you absolutly have to use null-terminated C-Strings, than rather use [sprintf](http://www.cplusplus.com/reference/cstdio/sprintf/) instead of std::stringstream. Mixing C and C++ like this is considered bad practice (like pointed out already: i.e. you have to manage memory manually). Also there are some other issues ... |
19,783,606 | I've created a WPF vb.net form containing datagrid. Inside of datagrid I have two comboboxes and two textboxes, one combobox textbox pair for articles and another one for services. I should bind first combo to property of List(Of article) type and second to List(Of service) type where article is public class containing... | 2013/11/05 | [
"https://Stackoverflow.com/questions/19783606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1930100/"
] | To answer your iostream formatting question, you want std::setw
```
std::cout << "'" << std::setw(16) << "Hello" << "'" << std::endl;
```
<http://faculty.cs.niu.edu/~mcmahon/CS241/c241man/node83.html> | Thank you all for your answers.
However, none of them worked as I intended.(especially, it's not for outputting, but for making a string object.)
I ended up achieving what I wanted, but it's by no means good.
I attach my program, though, below. Feel free to comment.
Thank you.
```
void file_info(char*, stringstrea... |
31,561,855 | All,
I have the following equation:
{=MEDIAN(IF(INDIRECT($F$80)=A87, INDIRECT($E$80))}
Where F80 = "input!Q2:Q545" and
where E80 = "input!B2:B545"
Basically this formula finds the median of one column where the other column is a set value (found in cell A87).
Can I write this as a non-array formula (without curly ... | 2015/07/22 | [
"https://Stackoverflow.com/questions/31561855",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/682355/"
] | If you have Excel 2010 or later:
`=AGGREGATE(16,6,INDIRECT($E$80)/(INDIRECT($F$80)=A87),1/2)`
If not:
`=MEDIAN(IF(MMULT(0+(INDIRECT($F$80)=A87),1),INDIRECT($E$80)))`
Regards | This formula will not work in 1 cell if it is not an array formula. This is because the IF statement is used against multiple cells. To write this without an array formula you would need to put an individual formula in each cell from R2:R545 which says:
```
=if(Q2=$A$47,B2)
```
And then a cell at the bottom that say... |
28,549,249 | I am trying start a clean 5.6 mysql install on RedHat AWS box. It hangs after printing the following in the logs. It eventually dies:
```
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp ser... | 2015/02/16 | [
"https://Stackoverflow.com/questions/28549249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2746418/"
] | In Python, invoking the superclass method must be done explicitly, via the `super` keyword. So it's up to you whether you do that or not, and where in your method you do it. If you don't, then your code will effectively replace the code from the parent class; if you do it at the start of the method, your code effective... | Try using super
```
class ABeautifulClass(GoodClass):
def __init__(self, **kw):
# some code that will override inherited code
def aNewMethod(self):
ret_val = super().aNewMethod() #The return value of the inherited method, you can remove it if the method returns None
# do something
```
... |
14,015,722 | Consider the JQuery object myDiv
```
myDiv = $('<div class="question"><b><span>MyText</span></b></div>');
```
How do I select the text with within the span tags so that I can do something like:
```
myElement.text = 'New text';
``` | 2012/12/24 | [
"https://Stackoverflow.com/questions/14015722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/835083/"
] | Like this:
```
$('span', myDiv).text('New text');
```
That selects the span *from within* your `myDiv` object, and sets the text accordingly.
Here's a [live demo](http://jsfiddle.net/vsCmU/) | Like this:
```
$('.question, span').text('new text');
``` |
14,015,722 | Consider the JQuery object myDiv
```
myDiv = $('<div class="question"><b><span>MyText</span></b></div>');
```
How do I select the text with within the span tags so that I can do something like:
```
myElement.text = 'New text';
``` | 2012/12/24 | [
"https://Stackoverflow.com/questions/14015722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/835083/"
] | Like this:
```
$('.question, span').text('new text');
``` | If you don't know beforehand what the element will be, but it will always be the most deeply-nested:
```
var myDiv = $('<div class="question"><b><span>MyText</span></b></div>'),
nested = myDiv.find(':last-child').last();
nested.text('my new text');
```
[JS Fiddle demo](http://jsfiddle.net/davidThomas/tGwaD/). |
14,015,722 | Consider the JQuery object myDiv
```
myDiv = $('<div class="question"><b><span>MyText</span></b></div>');
```
How do I select the text with within the span tags so that I can do something like:
```
myElement.text = 'New text';
``` | 2012/12/24 | [
"https://Stackoverflow.com/questions/14015722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/835083/"
] | Like this:
```
$('span', myDiv).text('New text');
```
That selects the span *from within* your `myDiv` object, and sets the text accordingly.
Here's a [live demo](http://jsfiddle.net/vsCmU/) | If you don't know beforehand what the element will be, but it will always be the most deeply-nested:
```
var myDiv = $('<div class="question"><b><span>MyText</span></b></div>'),
nested = myDiv.find(':last-child').last();
nested.text('my new text');
```
[JS Fiddle demo](http://jsfiddle.net/davidThomas/tGwaD/). |
7,292,269 | I do not have the link anymore as it was a few months back, but there was a great and detailed article about setting the charset of the body being sent to the user-agent.
The gist of the article was that when possible, send it via the content-type header since the user-agents parser will know before the body begins be... | 2011/09/03 | [
"https://Stackoverflow.com/questions/7292269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/815370/"
] | Yes, I always try to do this since it makes the document more portable. E.g. It will display the same way when viewing from a local file, as it does when delivered via a web server. | >
> my question is this, as a backup / failsafe / just incase, should we still send the charset meta tag?
>
>
>
Yes, it is always good practice to provide a meta tag in your markup which specifies the encoding. It should be the first tag after the `<head>`. |
41,894,625 | I have a REST Service that paginate my requests... I need to insert on my recyclerview 20 itens and keep the 20 itens before loaded.
This is my request...
```
VeiculoRequestHelper.veiculosPaginatedRequest(Request.Method.GET, url, null, new Response.Listener<VeiculoPaginated>() {
@Override
public void ... | 2017/01/27 | [
"https://Stackoverflow.com/questions/41894625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4175402/"
] | The old data will be cleared in `addItem(ArrayList<Veiculo> veiculosArray)`:
```
if (veiculos != null) {
veiculos.clear(); // here they will be cleared
veiculos.addAll(veiculosArray);
notifyItemInserted(veiculos.size() - 1);
}
```
Remove this line to keep the old items. | in your onResponse:
```
ArrayList<Veiculo> veiculoArrayList = new ArrayList<>();
veiculoArrayList.addAll(response.getContent());
veiculos = veiculoArrayList;
mAdapter.addItem(veiculos);
mRecyclerView.setAdapter(mAdapter);
```
see what is happening, `veiculoArrayLis... |
15,803,228 | Can i open custom keyboard instead of default keyboard.
I have an html file containing a textfield,when i start typing default keyboard gets open.
I can change type of keyboard in html file but i dont want to change anything in html file . | 2013/04/04 | [
"https://Stackoverflow.com/questions/15803228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1012693/"
] | 1. `WEB.CONFIG TIMEOUT` option is long time
2. IIS Application Pool `TIMEOUT` option is long time
3. (Current Page) `Request Header KeepAlive = true` setting | Try these,
1. Specify SQL Connection Timeout and Command Timeout properly.
2. Add index to the table on CardId
3. Selecting TOP 100 / 1000 records first and try to get the rest as and when required to improve the performance of the query |
15,803,228 | Can i open custom keyboard instead of default keyboard.
I have an html file containing a textfield,when i start typing default keyboard gets open.
I can change type of keyboard in html file but i dont want to change anything in html file . | 2013/04/04 | [
"https://Stackoverflow.com/questions/15803228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1012693/"
] | It sounds like you need to add an index to the column in the where clause of your query.
[check this out](http://msdn.microsoft.com/en-us/library/ms190457.aspx)
[this also](http://jahaines.blogspot.com/)
* And also think about **Stored Procedures**
* Coz stored procedures will help a lot to retrieve data in a shor... | 1. `WEB.CONFIG TIMEOUT` option is long time
2. IIS Application Pool `TIMEOUT` option is long time
3. (Current Page) `Request Header KeepAlive = true` setting |
15,803,228 | Can i open custom keyboard instead of default keyboard.
I have an html file containing a textfield,when i start typing default keyboard gets open.
I can change type of keyboard in html file but i dont want to change anything in html file . | 2013/04/04 | [
"https://Stackoverflow.com/questions/15803228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1012693/"
] | Besides update your connection and command timeout, if you add a non-cluster index on CardID and include column ID, Intime, OutTime, which is a covering index, your query will be faster, that will help.
```
CREATE NONCLUSTERED INDEX [IX_NCI_MasterLog_CardID] ON [dbo].[MasterLog]
(
[CardID] ASC
)
INCLUDE ( [ID]... | 1. `WEB.CONFIG TIMEOUT` option is long time
2. IIS Application Pool `TIMEOUT` option is long time
3. (Current Page) `Request Header KeepAlive = true` setting |
15,803,228 | Can i open custom keyboard instead of default keyboard.
I have an html file containing a textfield,when i start typing default keyboard gets open.
I can change type of keyboard in html file but i dont want to change anything in html file . | 2013/04/04 | [
"https://Stackoverflow.com/questions/15803228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1012693/"
] | It sounds like you need to add an index to the column in the where clause of your query.
[check this out](http://msdn.microsoft.com/en-us/library/ms190457.aspx)
[this also](http://jahaines.blogspot.com/)
* And also think about **Stored Procedures**
* Coz stored procedures will help a lot to retrieve data in a shor... | Try these,
1. Specify SQL Connection Timeout and Command Timeout properly.
2. Add index to the table on CardId
3. Selecting TOP 100 / 1000 records first and try to get the rest as and when required to improve the performance of the query |
15,803,228 | Can i open custom keyboard instead of default keyboard.
I have an html file containing a textfield,when i start typing default keyboard gets open.
I can change type of keyboard in html file but i dont want to change anything in html file . | 2013/04/04 | [
"https://Stackoverflow.com/questions/15803228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1012693/"
] | Besides update your connection and command timeout, if you add a non-cluster index on CardID and include column ID, Intime, OutTime, which is a covering index, your query will be faster, that will help.
```
CREATE NONCLUSTERED INDEX [IX_NCI_MasterLog_CardID] ON [dbo].[MasterLog]
(
[CardID] ASC
)
INCLUDE ( [ID]... | Try these,
1. Specify SQL Connection Timeout and Command Timeout properly.
2. Add index to the table on CardId
3. Selecting TOP 100 / 1000 records first and try to get the rest as and when required to improve the performance of the query |
15,803,228 | Can i open custom keyboard instead of default keyboard.
I have an html file containing a textfield,when i start typing default keyboard gets open.
I can change type of keyboard in html file but i dont want to change anything in html file . | 2013/04/04 | [
"https://Stackoverflow.com/questions/15803228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1012693/"
] | It sounds like you need to add an index to the column in the where clause of your query.
[check this out](http://msdn.microsoft.com/en-us/library/ms190457.aspx)
[this also](http://jahaines.blogspot.com/)
* And also think about **Stored Procedures**
* Coz stored procedures will help a lot to retrieve data in a shor... | Besides update your connection and command timeout, if you add a non-cluster index on CardID and include column ID, Intime, OutTime, which is a covering index, your query will be faster, that will help.
```
CREATE NONCLUSTERED INDEX [IX_NCI_MasterLog_CardID] ON [dbo].[MasterLog]
(
[CardID] ASC
)
INCLUDE ( [ID]... |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | You have a couple options here:
* `pd.infer_freq`
* `pd.tseries.frequencies.to_offset`
>
> I suspect that errors down the road are caused by the missing freq.
>
>
>
You are absolutely right. Here's what I use often:
```
def add_freq(idx, freq=None):
"""Add a frequency attribute to idx, through inference or ... | Similar to some of the other answers here, my problem was that my data had missing dates.
Instead of dealing with this issue in Python, I opted to change my SQL query that I was using to source the data. So instead of skipping dates, I wrote the query such that it would fill in missing dates with the value 0. |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | It could happen if for examples the dates you are passing aren't sorted.
Look at this example:
```
example_ts = pd.Series(data=range(10),
index=pd.date_range('2020-01-01', '2020-01-10', freq='D'))
example_ts.index = pd.DatetimeIndex(np.hstack([example_ts.index[-1:],
... | Similar to some of the other answers here, my problem was that my data had missing dates.
Instead of dealing with this issue in Python, I opted to change my SQL query that I was using to source the data. So instead of skipping dates, I wrote the query such that it would fill in missing dates with the value 0. |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | You have a couple options here:
* `pd.infer_freq`
* `pd.tseries.frequencies.to_offset`
>
> I suspect that errors down the road are caused by the missing freq.
>
>
>
You are absolutely right. Here's what I use often:
```
def add_freq(idx, freq=None):
"""Add a frequency attribute to idx, through inference or ... | I'm not sure if earlier versions of python have this, but 3.6 has this simple solution:
```
# 'b' stands for business days
# 'w' for weekly, 'd' for daily, and you get the idea...
df.index.freq = 'b'
``` |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | It seems to relate to missing dates as 3kt notes. You might be able to "fix" with `asfreq('D')` as EdChum suggests but that gives you a continuous index with missing data values. It works fine for some some sample data I made up:
```
df=pd.DataFrame({ 'x':[1,2,4] },
index=pd.to_datetime(['2003-01-02', '2003-01-03'... | It could happen if for examples the dates you are passing aren't sorted.
Look at this example:
```
example_ts = pd.Series(data=range(10),
index=pd.date_range('2020-01-01', '2020-01-10', freq='D'))
example_ts.index = pd.DatetimeIndex(np.hstack([example_ts.index[-1:],
... |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | It could happen if for examples the dates you are passing aren't sorted.
Look at this example:
```
example_ts = pd.Series(data=range(10),
index=pd.date_range('2020-01-01', '2020-01-10', freq='D'))
example_ts.index = pd.DatetimeIndex(np.hstack([example_ts.index[-1:],
... | It seems to be an issue with missing values in the index. I have simply re-build the index based on the original index in the frequency I needed:
```
df.index = pd.date_range(start=df.index[0], end=df.index[-1], freq="h")
``` |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | You have a couple options here:
* `pd.infer_freq`
* `pd.tseries.frequencies.to_offset`
>
> I suspect that errors down the road are caused by the missing freq.
>
>
>
You are absolutely right. Here's what I use often:
```
def add_freq(idx, freq=None):
"""Add a frequency attribute to idx, through inference or ... | It could happen if for examples the dates you are passing aren't sorted.
Look at this example:
```
example_ts = pd.Series(data=range(10),
index=pd.date_range('2020-01-01', '2020-01-10', freq='D'))
example_ts.index = pd.DatetimeIndex(np.hstack([example_ts.index[-1:],
... |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | It could happen if for examples the dates you are passing aren't sorted.
Look at this example:
```
example_ts = pd.Series(data=range(10),
index=pd.date_range('2020-01-01', '2020-01-10', freq='D'))
example_ts.index = pd.DatetimeIndex(np.hstack([example_ts.index[-1:],
... | I am not sure but I was having the same error. I was not able to resolve my issue by suggestions posted above but solved it using the below solution.
[Pandas DatetimeIndex + seasonal\_decompose = missing frequency](https://stackoverflow.com/questions/56246322/pandas-datetimeindex-seasonal-decompose-missing-frequency).... |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | You have a couple options here:
* `pd.infer_freq`
* `pd.tseries.frequencies.to_offset`
>
> I suspect that errors down the road are caused by the missing freq.
>
>
>
You are absolutely right. Here's what I use often:
```
def add_freq(idx, freq=None):
"""Add a frequency attribute to idx, through inference or ... | It seems to be an issue with missing values in the index. I have simply re-build the index based on the original index in the frequency I needed:
```
df.index = pd.date_range(start=df.index[0], end=df.index[-1], freq="h")
``` |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | I'm not sure if earlier versions of python have this, but 3.6 has this simple solution:
```
# 'b' stands for business days
# 'w' for weekly, 'd' for daily, and you get the idea...
df.index.freq = 'b'
``` | I am not sure but I was having the same error. I was not able to resolve my issue by suggestions posted above but solved it using the below solution.
[Pandas DatetimeIndex + seasonal\_decompose = missing frequency](https://stackoverflow.com/questions/56246322/pandas-datetimeindex-seasonal-decompose-missing-frequency).... |
46,217,529 | I created a DatetimeIndex from a "date" column:
```
sales.index = pd.DatetimeIndex(sales["date"])
```
Now the index looks as follows:
```
DatetimeIndex(['2003-01-02', '2003-01-03', '2003-01-04', '2003-01-06',
'2003-01-07', '2003-01-08', '2003-01-09', '2003-01-10',
'2003-01-11',... | 2017/09/14 | [
"https://Stackoverflow.com/questions/46217529",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/626537/"
] | I'm not sure if earlier versions of python have this, but 3.6 has this simple solution:
```
# 'b' stands for business days
# 'w' for weekly, 'd' for daily, and you get the idea...
df.index.freq = 'b'
``` | Similar to some of the other answers here, my problem was that my data had missing dates.
Instead of dealing with this issue in Python, I opted to change my SQL query that I was using to source the data. So instead of skipping dates, I wrote the query such that it would fill in missing dates with the value 0. |
13,277,253 | I have a MySQL table like this:
```
+----+------------+----------+
| id | instanceID | answerID |
+----+------------+----------+
| 1 | 1 | 10 |
| 2 | 1 | 12 |
| 3 | 1 | 20 |
| 4 | 2 | 12 |
| 5 | 2 | 20 |
| 6 | 2 | 22 |
| 7 ... | 2012/11/07 | [
"https://Stackoverflow.com/questions/13277253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1235821/"
] | How about something like this:
```
select instanceid
from yourtable
where answerid in (20, 25)
group by instanceid
having count(distinct answerID) > 1
```
See [SQL Fiddle with Demo](http://sqlfiddle.com/#!2/e571a/3)
Or even:
```
select instanceid
from yourtable
where answerid in (20, 25) -- list of values here
gro... | Another is by using a join, but based only on the first criteria being qualified as to not even bother looking through EVERY possible instance... such as...
```
select
YT.InstanceID
from
yourtable YT
JOIN yourTable YT2
on YT.InstanceID = YT2.InstanceID
AND YT2.AnswerID... |
37,621,028 | I am running into an issue with a select being displayed
I have a samplemodel value that is an interger in the database. As of right now, I want to do a select as below, but I want it to display the string. The value will be displayed in my two way binding markup but when I select a string of yes, no, or na in the se... | 2016/06/03 | [
"https://Stackoverflow.com/questions/37621028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5017379/"
] | Try using ng-options on your select. You can choose what you would like your model bound to that way.
Example:
```
$scope.myArray = [
{Val: 1, Display: 'Yes'},
{Val: 2, Display: 'No'},
{Val: 3, Display: 'NA'}
];
$scope.samplemodel = "Yes";
```
//Gives the Display string of the object
```
{{samplemodel}}
<s... | **Update** Please use @Ohjay44's method as it is more performant. I will leave this up as it is still a valid optin.
You would have to use a filter:
**HTML**
```
{{samplemodel | stringFromInt}}
```
**JS**
```
app.filter('stringFromInt', function(){
return function(input) {
if (!input){
return nu... |
3,621,328 | In my free time, I was messing around with some maths, which eventually led me to the question of finding a non-trivial zero of the following series:
$$\sum\_{n=1}^{\infty} \frac{nx^n}{1-x^n} $$
Does anybody maybe know a closed form (probably not)? Or does someone maybe know whether it has been studied before and has... | 2020/04/12 | [
"https://math.stackexchange.com/questions/3621328",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/771705/"
] | We can rewrite the sum as $$\sum\_{n=1}^{\infty}\sum\_{m=1}^{\infty}\left(nx^{mn}\right)$$
Switching the order of summation and evaluating, we get $$\sum\_{m=1}^{\infty}\frac{x^{m}}{\left(x^{m}-1\right)^{2}}$$
Now [WolframAlpha](https://www.wolframalpha.com/input/?i=Sum%5Bx%5Em%2F%28x%5Em+-+1%29%5E2%2C+%7Bm%2C+1%2C+I... | While I do not have a closed-form solution, I was able to solve it numerically using the Newton-Raphson method with the help of a Java program I coded. The answer is approximately
```
x = -0.4112484443599058
```
If this value is plugged into the function provided, the $y$ value... |
3,621,328 | In my free time, I was messing around with some maths, which eventually led me to the question of finding a non-trivial zero of the following series:
$$\sum\_{n=1}^{\infty} \frac{nx^n}{1-x^n} $$
Does anybody maybe know a closed form (probably not)? Or does someone maybe know whether it has been studied before and has... | 2020/04/12 | [
"https://math.stackexchange.com/questions/3621328",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/771705/"
] | While I do not have a closed-form solution, I was able to solve it numerically using the Newton-Raphson method with the help of a Java program I coded. The answer is approximately
```
x = -0.4112484443599058
```
If this value is plugged into the function provided, the $y$ value... | To have *approximations* of the solution of equation $$\psi\_x^{(1)}(1) = 0$$ we could build around $x=0$ the $[1,n]$ Padé approximant of
$$\frac{\psi\_x^{(1)}(1)}{x \, \log^2(x)}$$ this will generate for the *approximate* solution the sequence
$$-\frac{3}{5},-\frac{1}{2},-\frac{2}{5},-\frac{25}{64},-\frac{2}{5},-\frac... |
3,621,328 | In my free time, I was messing around with some maths, which eventually led me to the question of finding a non-trivial zero of the following series:
$$\sum\_{n=1}^{\infty} \frac{nx^n}{1-x^n} $$
Does anybody maybe know a closed form (probably not)? Or does someone maybe know whether it has been studied before and has... | 2020/04/12 | [
"https://math.stackexchange.com/questions/3621328",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/771705/"
] | We can rewrite the sum as $$\sum\_{n=1}^{\infty}\sum\_{m=1}^{\infty}\left(nx^{mn}\right)$$
Switching the order of summation and evaluating, we get $$\sum\_{m=1}^{\infty}\frac{x^{m}}{\left(x^{m}-1\right)^{2}}$$
Now [WolframAlpha](https://www.wolframalpha.com/input/?i=Sum%5Bx%5Em%2F%28x%5Em+-+1%29%5E2%2C+%7Bm%2C+1%2C+I... | To have *approximations* of the solution of equation $$\psi\_x^{(1)}(1) = 0$$ we could build around $x=0$ the $[1,n]$ Padé approximant of
$$\frac{\psi\_x^{(1)}(1)}{x \, \log^2(x)}$$ this will generate for the *approximate* solution the sequence
$$-\frac{3}{5},-\frac{1}{2},-\frac{2}{5},-\frac{25}{64},-\frac{2}{5},-\frac... |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | It's actually not so difficult. Using:
$$\frac{1}{1-x-y}=\sum\_{n,m\ge 0}{n + m\choose n}x^ny^m$$
You get
$$\frac{x}{1-x-x^3}=x\cdot\frac{1}{1-x-x^3}=x\cdot \sum\_{n,m\ge 0}{n + m\choose n}x^n(x^3)^m=\sum\_{n,m\ge 0}{n + m\choose n}x^{n+3m+1}$$
And after a last manipulation you can get a formal power series of the cla... | $f\_{n+3}=f\_{n+2}+f\_{n}; n\geq 1$ then $\sum^{\infty}\_{n=1}f\_{n+3}x^n = \sum^{\infty}\_{n=1}f\_{n+2}x^n+\sum^{\infty}\_{n=1}f\_{n}x^n$ with $f(x)=\sum^{\infty}\_{n=1}f\_{n}x^n$ then $\frac{f(x)-f\_1x-f\_2x^2-f\_3x^3}{x^3}= \frac{f(x)-f\_1x-f\_2x^2}{x^2}+f(x)$ then
$$\frac{f(x)-x-x^2-x^3}{x^3}= \frac{f(x)-x-x^2}{x^2... |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | To answer both your old and your new question *at the very same time*, we can consider a surprising relationship between power series and recurrence relations through [generating functions](http://en.wikipedia.org/wiki/Generating_function). As a simple example, consider representing $\frac{1}{1-x}$ as a power series. I... | $$x\left(\frac{1}{1-(x+x^3)}\right)$$ will do it. |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | To answer both your old and your new question *at the very same time*, we can consider a surprising relationship between power series and recurrence relations through [generating functions](http://en.wikipedia.org/wiki/Generating_function). As a simple example, consider representing $\frac{1}{1-x}$ as a power series. I... | $$\frac{1}{1-x}=1+x+x^2+x^3+x^4+...$$
$$x(\frac{1}{1-(x+x^3)})=x(1+(x+x^3)+(x+x^3)^2+(x+x^3)^3+.....)$$ |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | To answer both your old and your new question *at the very same time*, we can consider a surprising relationship between power series and recurrence relations through [generating functions](http://en.wikipedia.org/wiki/Generating_function). As a simple example, consider representing $\frac{1}{1-x}$ as a power series. I... | $x = (1-x-x^3) x + (x^2 + x^4)$
$x^2 + x^4 = (1-x-x^3) \* x^2 + (x^3 + x^4 + x^5)$
$(x^3 + x^4 + x^5) = (1-x-x^3) \* x^3 + (2\*x^2+x^5 + x^6)$
$(2\*x^2+x^5 + x^6) = (1-x-x^3) \* 2x^4 + (x^5+3\*x^6+x^7)$ then
$\frac{x}{1-x-x^3} = 1 + x + x^2 + x^3 + 2x^4 +\frac{(x^5+3\*x^6+x^7)}{1-x-x^3}$
if you continue you all the coe... |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | $x = (1-x-x^3) x + (x^2 + x^4)$
$x^2 + x^4 = (1-x-x^3) \* x^2 + (x^3 + x^4 + x^5)$
$(x^3 + x^4 + x^5) = (1-x-x^3) \* x^3 + (2\*x^2+x^5 + x^6)$
$(2\*x^2+x^5 + x^6) = (1-x-x^3) \* 2x^4 + (x^5+3\*x^6+x^7)$ then
$\frac{x}{1-x-x^3} = 1 + x + x^2 + x^3 + 2x^4 +\frac{(x^5+3\*x^6+x^7)}{1-x-x^3}$
if you continue you all the coe... | $$x\left(\frac{1}{1-(x+x^3)}\right)$$ will do it. |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | $f\_{n+3}=f\_{n+2}+f\_{n}; n\geq 1$ then $\sum^{\infty}\_{n=1}f\_{n+3}x^n = \sum^{\infty}\_{n=1}f\_{n+2}x^n+\sum^{\infty}\_{n=1}f\_{n}x^n$ with $f(x)=\sum^{\infty}\_{n=1}f\_{n}x^n$ then $\frac{f(x)-f\_1x-f\_2x^2-f\_3x^3}{x^3}= \frac{f(x)-f\_1x-f\_2x^2}{x^2}+f(x)$ then
$$\frac{f(x)-x-x^2-x^3}{x^3}= \frac{f(x)-x-x^2}{x^2... | $$x\left(\frac{1}{1-(x+x^3)}\right)$$ will do it. |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | $$\frac{1}{1-x}=1+x+x^2+x^3+x^4+...$$
$$x(\frac{1}{1-(x+x^3)})=x(1+(x+x^3)+(x+x^3)^2+(x+x^3)^3+.....)$$ | $$x\left(\frac{1}{1-(x+x^3)}\right)$$ will do it. |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | To answer both your old and your new question *at the very same time*, we can consider a surprising relationship between power series and recurrence relations through [generating functions](http://en.wikipedia.org/wiki/Generating_function). As a simple example, consider representing $\frac{1}{1-x}$ as a power series. I... | It's actually not so difficult. Using:
$$\frac{1}{1-x-y}=\sum\_{n,m\ge 0}{n + m\choose n}x^ny^m$$
You get
$$\frac{x}{1-x-x^3}=x\cdot\frac{1}{1-x-x^3}=x\cdot \sum\_{n,m\ge 0}{n + m\choose n}x^n(x^3)^m=\sum\_{n,m\ge 0}{n + m\choose n}x^{n+3m+1}$$
And after a last manipulation you can get a formal power series of the cla... |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | It's actually not so difficult. Using:
$$\frac{1}{1-x-y}=\sum\_{n,m\ge 0}{n + m\choose n}x^ny^m$$
You get
$$\frac{x}{1-x-x^3}=x\cdot\frac{1}{1-x-x^3}=x\cdot \sum\_{n,m\ge 0}{n + m\choose n}x^n(x^3)^m=\sum\_{n,m\ge 0}{n + m\choose n}x^{n+3m+1}$$
And after a last manipulation you can get a formal power series of the cla... | $$x\left(\frac{1}{1-(x+x^3)}\right)$$ will do it. |
1,249,107 | (Please see edit below; I originally asked how to find a power series expansion of a given function, but I now wanted to know how to do the reverse case.)
Can someone please explain how to find the power series expansion of the function in the title? Also, how would you do it in the reverse case? That is, given the po... | 2015/04/23 | [
"https://math.stackexchange.com/questions/1249107",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/155812/"
] | It's actually not so difficult. Using:
$$\frac{1}{1-x-y}=\sum\_{n,m\ge 0}{n + m\choose n}x^ny^m$$
You get
$$\frac{x}{1-x-x^3}=x\cdot\frac{1}{1-x-x^3}=x\cdot \sum\_{n,m\ge 0}{n + m\choose n}x^n(x^3)^m=\sum\_{n,m\ge 0}{n + m\choose n}x^{n+3m+1}$$
And after a last manipulation you can get a formal power series of the cla... | $x = (1-x-x^3) x + (x^2 + x^4)$
$x^2 + x^4 = (1-x-x^3) \* x^2 + (x^3 + x^4 + x^5)$
$(x^3 + x^4 + x^5) = (1-x-x^3) \* x^3 + (2\*x^2+x^5 + x^6)$
$(2\*x^2+x^5 + x^6) = (1-x-x^3) \* 2x^4 + (x^5+3\*x^6+x^7)$ then
$\frac{x}{1-x-x^3} = 1 + x + x^2 + x^3 + 2x^4 +\frac{(x^5+3\*x^6+x^7)}{1-x-x^3}$
if you continue you all the coe... |
61,471,679 | I am trying to setup ActionText for the first time on my `Article` model.
This is how my `Article` model looks:
```
class Article < ApplicationRecord
has_rich_text :body
end
```
I set up ActionText like so:
```
rails action_text:install
```
My `app/javascript/packs/application.js` looks like this:
```
// This... | 2020/04/28 | [
"https://Stackoverflow.com/questions/61471679",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91970/"
] | Not sure if you've resolved this, but I had this same issue and I also installed through `rails action_text:install`. And my app is using bootstrap for styling.
I was able to resolve this by adding `@import "trix/dist/trix";` in my `application.scss` file. This was the only addition I ended up needing. Hope this helps... | I figured it out....kinda.
The issue was that I am getting some errors in my JS.
So the hack I did was to simply comment out that JS file that was giving a problem.
The issue is that I am using a Bootstrap Template that comes with a lot of JS files. So I can't easily go in and fix the problem (especially since JS is... |
34,235,603 | Say I have a dataframe like such:
```
df= { 'class': ['A','A','A','A','A','B','B','B','B'],
'ID':[1,2,2,3,3,4,4,4,5]}
Class ID
A 1
A 2
A 2
A 3
A 3
B 4
B 4
B 4
B 5
```
I'd like to summarize the data as such:
```
Class count(distinct(ID))
A 3
B 2
``... | 2015/12/12 | [
"https://Stackoverflow.com/questions/34235603",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5225453/"
] | I think you're looking for [`nunique`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.nunique.html):
```
In [11]: df.groupby("Class")["ID"].nunique()
Out[11]:
Class
A 3
B 2
Name: ID, dtype: int64
``` | ```
(df[['Class','ID']]
.drop_duplicates()
.groupby('Class')
.count())
``` |
69,182,486 | I'm trying to get all button elements from a webpage using the code:
```
const test = await page.evaluate(() => {
return document.querySelectorAll("button")
})
console.log(test)
```
When I log the test variable it yields 'undefined', while when I run the following code on chrome's console:
```
document.que... | 2021/09/14 | [
"https://Stackoverflow.com/questions/69182486",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14181831/"
] | You need to do everything that works with the `HTMLElements` in the context of the website (so from within the `evaluate` callback).
At the end of `evaluate` you leave the context of the site you are very limited to what you can return from `evaluate`.
The data you return from `evaluate` has to be [Serializable](http... | The values returned from evaluate must be [serializable by JSON](https://github.com/puppeteer/puppeteer/issues/303#issuecomment-322919968) since puppeteer is returning chrome API calls, try this:
```
const test = await page.evaluate() => {
let elements = Array.from(document.querySelectorAll("button"));
let but... |
386,114 | Does there exist examples of $m \times n$ matrices with $m > n$ with the property that the determinant of every $n \times n$ submatrix is at least $1$ in absolute value? (The $1$ can be replaced by $1/\text{poly}(n,m)$).
An "almost" example are [totally unimodular](https://en.wikipedia.org/wiki/Unimodular_matrix#Total... | 2021/03/11 | [
"https://mathoverflow.net/questions/386114",
"https://mathoverflow.net",
"https://mathoverflow.net/users/83122/"
] | For any distinct integers $x\_1,\ldots,x\_m$ you can take the matrix whose
$i$-th row $(1 \leq i \leq m)$ is $(1,x\_i,x\_i^2,\ldots,x\_i^{n-1})$.
Each $n \times n$ submatrix is
[Vandermonde](https://en.wikipedia.org/wiki/Vandermonde_matrix)
with distinct rows, so has nonzero determinant, which being an integer
must hav... | Yes. Allow me to transpose your set-up, for reasons of my own dyslexia, and instead consider an $m \times n$ matrix $M$ with $m < n$. This matrix will have
block decomposition $M = \big( D \, \big| \, A \big)$ where
$\bullet$ $D$ is the $m \times m$ anti-diagonal matrix
whose $k$-th row entry is $(-1)^{k+1}$
$\bullet... |
5,868,346 | where can i find something like this? | 2011/05/03 | [
"https://Stackoverflow.com/questions/5868346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/678970/"
] | You can access the phoneboook through intents:
```
Intent newcontact_intent = new Intent(v.getContext(), Contact.class);
newcontact_intent.putExtra("partyid", partyid);
startActivityForResult(newcontact_intent, 1);
```
And It is true that the calendar feature is not officially supported ... | This will help with accessing calendar functionality. But be warned: it's not officially supported by google.
[Calendar Tutorial](http://android.arnodenhond.com/tutorials/calendar)
There are many similar tutorials available for accessing contacts, such as [this](http://mobile.tutsplus.com/tutorials/android/android-es... |
12,161,320 | I would like to store lines in a file such as
```
15 1 0 0 0 0
33 1 0 0 0 0
29 1 0 0 0 0
18 1 0 0 0 0
25 1 0 0 0 0
```
to become elements of an array. So if I do
```
#include <stdio.h>
#include <vector>
using namespace std
char* file = "somefile.txt"
FILE *fb_r = fopen(file,"r");
char line[100];
vector <char> lin... | 2012/08/28 | [
"https://Stackoverflow.com/questions/12161320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1599363/"
] | Change `lineArr` to:
```
vector<string> lineArr;
```
And your `sscanf` is broken too, you can't use it with a `std::string`. The whole thing should probably be:
```
lineArr.push_back(line);
``` | In addition to the previous good answers, please find a fully working program :
```
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() {
const char* file = "somefile.txt";
FILE *fb_r = fopen(file,"r");
char line[100];
vector<string> lineArr;
... |
12,161,320 | I would like to store lines in a file such as
```
15 1 0 0 0 0
33 1 0 0 0 0
29 1 0 0 0 0
18 1 0 0 0 0
25 1 0 0 0 0
```
to become elements of an array. So if I do
```
#include <stdio.h>
#include <vector>
using namespace std
char* file = "somefile.txt"
FILE *fb_r = fopen(file,"r");
char line[100];
vector <char> lin... | 2012/08/28 | [
"https://Stackoverflow.com/questions/12161320",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1599363/"
] | Well your vector contains single `char`s
```
vector <char> lineArr;
```
and it looks like you are trying to push an `std::string`? | In addition to the previous good answers, please find a fully working program :
```
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
int main() {
const char* file = "somefile.txt";
FILE *fb_r = fopen(file,"r");
char line[100];
vector<string> lineArr;
... |
46,074,863 | I'm training based on a sample code I found on the Internet. The accuracy in testing is at 92% and the checkpoints are saved in a directory. In parallel (the training is running for 3 days now) I want to create my prediction code so I can learn more instead of just waiting.
This is my third day of deep learning so I p... | 2017/09/06 | [
"https://Stackoverflow.com/questions/46074863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515697/"
] | In the repo you provided, the training and validation sentences are inverted before being fed into the model (as commonly done in seq2seq learning).
```
dataset = DataSet(DATASET_FILENAME)
```
As you can see, the default value for `inverted` is `True`, and the questions are inverted.
```
class DataSet(object):
... | When you generate model in your predict.py file:
```
model = generate_model(len(question), dataset['chars'])
```
is your first parameter the same as in your training file? Or is the question length dynamic? If so, you are generating different model, thus your saved checkpoint doesn't work. |
46,074,863 | I'm training based on a sample code I found on the Internet. The accuracy in testing is at 92% and the checkpoints are saved in a directory. In parallel (the training is running for 3 days now) I want to create my prediction code so I can learn more instead of just waiting.
This is my third day of deep learning so I p... | 2017/09/06 | [
"https://Stackoverflow.com/questions/46074863",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1515697/"
] | In the repo you provided, the training and validation sentences are inverted before being fed into the model (as commonly done in seq2seq learning).
```
dataset = DataSet(DATASET_FILENAME)
```
As you can see, the default value for `inverted` is `True`, and the questions are inverted.
```
class DataSet(object):
... | It can be the dimentionality of arrays/df passed not matching what is expected by the functions you call. When a single dimention is expected by the called method, try `ravel` on what you expect to be a single dimention |
13,943 | During the great depression the money supply in the US fell by about a third. It is my suspicion that any economy with a falling money supply will generally be doing badly but of course I could be wrong. So I was wondering if the were any examples in any countries (preferably not going back to ancient times) where an e... | 2016/10/26 | [
"https://economics.stackexchange.com/questions/13943",
"https://economics.stackexchange.com",
"https://economics.stackexchange.com/users/5081/"
] | The closes answer will be country with extremely low inflation such as Nordic countries, Kuwait, Brunei. But they are not a good example, as the money supply are "balance" with their heavy surplus from natural resources exploitation.
On the other hand, there is plenty of example for "Dutch disease" : excessive foreig... | Money supplies ebb and flow. And your supposition that a decrease in the money supply is necessarily bad is probably a bit off.
For example, the Fed might shrink the money supply with contractionary policy in an effort to slow and overheated economy. The shrinking of the money supply was triggered by the fact that th... |
13,943 | During the great depression the money supply in the US fell by about a third. It is my suspicion that any economy with a falling money supply will generally be doing badly but of course I could be wrong. So I was wondering if the were any examples in any countries (preferably not going back to ancient times) where an e... | 2016/10/26 | [
"https://economics.stackexchange.com/questions/13943",
"https://economics.stackexchange.com",
"https://economics.stackexchange.com/users/5081/"
] | Money supply accounts for all the 'money' in circulation in the economy and the money itself has many forms. However, in a nutshell we can understand it as the flow of all kinds of monetary assets in the economy (broad sense of money). The correlation of money supply with growth has been quite contentious. We just lost... | Money supplies ebb and flow. And your supposition that a decrease in the money supply is necessarily bad is probably a bit off.
For example, the Fed might shrink the money supply with contractionary policy in an effort to slow and overheated economy. The shrinking of the money supply was triggered by the fact that th... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | You'd need something like:
```
PropertyInfo addressProperty = typeof(Customer).GetProperty("Address");
ProportyInfo zipCodeProperty = addressProperty.PropertyType.GetProperty("ZipCode");
object address = addressProperty.GetValue(customer, null);
object zipCode = zipCodeProperty.GetValue(address, null);
```
Basicall... | **Problem: Weakly Typed Variables:**
@jonskeet's FollowPropertyPath(...) method *almost* met my needs exactly; except that
my property was weakly typed; therefore, `currentType = property.PropertyType` simply returned System.Object and failed on the next iteration of the foreach-loop.
**Solution:**
To use the runtim... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | The existing answers are fine; just an alternative perspective: in many scenarios it is desirable to use System.ComponentModel rather than direct reflection, as this allows for runtime property scenarios - i.e. how a DataTable's DataView exposes the columns as *properties*.
Performance wise - by default this is largel... | adabyron,
I created a version of your code for when you only need to grab the types, and if you don't have an actual object instance.
```
public static Type FollowPropertyPath<T>(string path)
{
if (path == null) throw new ArgumentNullException("path");
Type currentType = typeof(T);
f... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | The existing answers are fine; just an alternative perspective: in many scenarios it is desirable to use System.ComponentModel rather than direct reflection, as this allows for runtime property scenarios - i.e. how a DataTable's DataView exposes the columns as *properties*.
Performance wise - by default this is largel... | **Problem: Weakly Typed Variables:**
@jonskeet's FollowPropertyPath(...) method *almost* met my needs exactly; except that
my property was weakly typed; therefore, `currentType = property.PropertyType` simply returned System.Object and failed on the next iteration of the foreach-loop.
**Solution:**
To use the runtim... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | ```
typeof (Customer).GetProperty("Address").PropertyType.GetProperty("ZipCode")
``` | **Problem: Weakly Typed Variables:**
@jonskeet's FollowPropertyPath(...) method *almost* met my needs exactly; except that
my property was weakly typed; therefore, `currentType = property.PropertyType` simply returned System.Object and failed on the next iteration of the foreach-loop.
**Solution:**
To use the runtim... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | Jon Skeet's answer is fine, I had to extend his method a bit though, in order to account for derived instances within the property path:
```
public static class ReflectorUtil
{
public static object FollowPropertyPath(object value, string path)
{
if (value == null) throw new ArgumentNullException("value... | **Problem: Weakly Typed Variables:**
@jonskeet's FollowPropertyPath(...) method *almost* met my needs exactly; except that
my property was weakly typed; therefore, `currentType = property.PropertyType` simply returned System.Object and failed on the next iteration of the foreach-loop.
**Solution:**
To use the runtim... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | Jon Skeet's answer is fine, I had to extend his method a bit though, in order to account for derived instances within the property path:
```
public static class ReflectorUtil
{
public static object FollowPropertyPath(object value, string path)
{
if (value == null) throw new ArgumentNullException("value... | ```
typeof (Customer).GetProperty("Address").PropertyType.GetProperty("ZipCode")
``` |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | You'd need something like:
```
PropertyInfo addressProperty = typeof(Customer).GetProperty("Address");
ProportyInfo zipCodeProperty = addressProperty.PropertyType.GetProperty("ZipCode");
object address = addressProperty.GetValue(customer, null);
object zipCode = zipCodeProperty.GetValue(address, null);
```
Basicall... | adabyron,
I created a version of your code for when you only need to grab the types, and if you don't have an actual object instance.
```
public static Type FollowPropertyPath<T>(string path)
{
if (path == null) throw new ArgumentNullException("path");
Type currentType = typeof(T);
f... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | Jon Skeet's answer is fine, I had to extend his method a bit though, in order to account for derived instances within the property path:
```
public static class ReflectorUtil
{
public static object FollowPropertyPath(object value, string path)
{
if (value == null) throw new ArgumentNullException("value... | adabyron,
I created a version of your code for when you only need to grab the types, and if you don't have an actual object instance.
```
public static Type FollowPropertyPath<T>(string path)
{
if (path == null) throw new ArgumentNullException("path");
Type currentType = typeof(T);
f... |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | You'd need something like:
```
PropertyInfo addressProperty = typeof(Customer).GetProperty("Address");
ProportyInfo zipCodeProperty = addressProperty.PropertyType.GetProperty("ZipCode");
object address = addressProperty.GetValue(customer, null);
object zipCode = zipCodeProperty.GetValue(address, null);
```
Basicall... | ```
typeof (Customer).GetProperty("Address").PropertyType.GetProperty("ZipCode")
``` |
366,332 | ```
public class Address
{
public string ZipCode {get; set;}
}
public class Customer
{
public Address Address {get; set;}
}
```
how can I access eitther "ZipCode" or "Address.ZipCode" with reflection? For example:
```
Typeof(Customer).GetProperty("ZipCode")?
``` | 2008/12/14 | [
"https://Stackoverflow.com/questions/366332",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/31624/"
] | You'd need something like:
```
PropertyInfo addressProperty = typeof(Customer).GetProperty("Address");
ProportyInfo zipCodeProperty = addressProperty.PropertyType.GetProperty("ZipCode");
object address = addressProperty.GetValue(customer, null);
object zipCode = zipCodeProperty.GetValue(address, null);
```
Basicall... | The existing answers are fine; just an alternative perspective: in many scenarios it is desirable to use System.ComponentModel rather than direct reflection, as this allows for runtime property scenarios - i.e. how a DataTable's DataView exposes the columns as *properties*.
Performance wise - by default this is largel... |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | Using GCC -D option u can pass a value to a C program.
Eg:
```
int main()
{
printf("global decl %d\n", gvar);
}
```
>
> gcc -Dgvar=10 gcc.c
>
>
>
This may give a closest behaviour you are looking for though this is not equivalent to a global variable declaration. This is a macro substitution at compile time. | Ehm, no. Don't. Why would you want to? You can't use it.
The closest you can get is to define the variable in a new `.c` file and link it in separately, but it would still have to be declared (with `extern`) in `test.c` for `test.c` to use it. |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | I think you'll want to take a look at varpool\_add\_new\_variable() in varpool.c. You should be able to pass a declaration built with type VAR\_DECL to it. Similarly, take a look at add\_new\_static\_var(), but I think the former is what you want, as it was added specifically to allow declaring globals in the middle/ba... | Ehm, no. Don't. Why would you want to? You can't use it.
The closest you can get is to define the variable in a new `.c` file and link it in separately, but it would still have to be declared (with `extern`) in `test.c` for `test.c` to use it. |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | below there is an example of create a global integer var:
```
//add_new_static_var, in cgraph.h
tree global_var = add_new_static_var(integer_type_node);
//if you want to name the var:
tree name = get_identifier("my_global_name");
DECL_NAME(global_var) = name;
/*AND if you have thought to use in another subsequent comp... | Ehm, no. Don't. Why would you want to? You can't use it.
The closest you can get is to define the variable in a new `.c` file and link it in separately, but it would still have to be declared (with `extern`) in `test.c` for `test.c` to use it. |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | Using GCC -D option u can pass a value to a C program.
Eg:
```
int main()
{
printf("global decl %d\n", gvar);
}
```
>
> gcc -Dgvar=10 gcc.c
>
>
>
This may give a closest behaviour you are looking for though this is not equivalent to a global variable declaration. This is a macro substitution at compile time. | you can create a file that contains the code you want to add to the top of the input file and use the `-include yourfile` option.
that advises the preprocessor to assume an `#include "yourfile"` at the top of the input file.
see this question:
[Include header files using command line option?](https://stackoverflow... |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | I think you'll want to take a look at varpool\_add\_new\_variable() in varpool.c. You should be able to pass a declaration built with type VAR\_DECL to it. Similarly, take a look at add\_new\_static\_var(), but I think the former is what you want, as it was added specifically to allow declaring globals in the middle/ba... | you can create a file that contains the code you want to add to the top of the input file and use the `-include yourfile` option.
that advises the preprocessor to assume an `#include "yourfile"` at the top of the input file.
see this question:
[Include header files using command line option?](https://stackoverflow... |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | below there is an example of create a global integer var:
```
//add_new_static_var, in cgraph.h
tree global_var = add_new_static_var(integer_type_node);
//if you want to name the var:
tree name = get_identifier("my_global_name");
DECL_NAME(global_var) = name;
/*AND if you have thought to use in another subsequent comp... | you can create a file that contains the code you want to add to the top of the input file and use the `-include yourfile` option.
that advises the preprocessor to assume an `#include "yourfile"` at the top of the input file.
see this question:
[Include header files using command line option?](https://stackoverflow... |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | I think you'll want to take a look at varpool\_add\_new\_variable() in varpool.c. You should be able to pass a declaration built with type VAR\_DECL to it. Similarly, take a look at add\_new\_static\_var(), but I think the former is what you want, as it was added specifically to allow declaring globals in the middle/ba... | Using GCC -D option u can pass a value to a C program.
Eg:
```
int main()
{
printf("global decl %d\n", gvar);
}
```
>
> gcc -Dgvar=10 gcc.c
>
>
>
This may give a closest behaviour you are looking for though this is not equivalent to a global variable declaration. This is a macro substitution at compile time. |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | Using GCC -D option u can pass a value to a C program.
Eg:
```
int main()
{
printf("global decl %d\n", gvar);
}
```
>
> gcc -Dgvar=10 gcc.c
>
>
>
This may give a closest behaviour you are looking for though this is not equivalent to a global variable declaration. This is a macro substitution at compile time. | below there is an example of create a global integer var:
```
//add_new_static_var, in cgraph.h
tree global_var = add_new_static_var(integer_type_node);
//if you want to name the var:
tree name = get_identifier("my_global_name");
DECL_NAME(global_var) = name;
/*AND if you have thought to use in another subsequent comp... |
25,998,225 | I would like to know if it's possible to insert a global variable declaration with a gcc plugin. For example if I have the following code:
test.c:
```
int main(void) {
return 0;
}
```
and I want to transform it into:
```
int fake_var;
int main(void) {
return 0;
}
```
Is that possible?
If it's possible, in w... | 2014/09/23 | [
"https://Stackoverflow.com/questions/25998225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4000536/"
] | I think you'll want to take a look at varpool\_add\_new\_variable() in varpool.c. You should be able to pass a declaration built with type VAR\_DECL to it. Similarly, take a look at add\_new\_static\_var(), but I think the former is what you want, as it was added specifically to allow declaring globals in the middle/ba... | below there is an example of create a global integer var:
```
//add_new_static_var, in cgraph.h
tree global_var = add_new_static_var(integer_type_node);
//if you want to name the var:
tree name = get_identifier("my_global_name");
DECL_NAME(global_var) = name;
/*AND if you have thought to use in another subsequent comp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.