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 |
|---|---|---|---|---|---|
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | If I understand correctly you want to factor out some 'stable' settings
1. The config system is hierarchical, you can store default settings in
`C:\Windows\Micorsoft.NET\<version>\Machine.config` or `Web.config`
That is a pretty heavy tool though. Make an error and most .NET apps will fail to start
2. Use [Confi... | You can include external xml files into your web.config.
[See this question](https://stackoverflow.com/questions/480538/use-xml-includes-or-config-references-in-app-config-to-include-other-config-files)
```
<!-- SomeProgram.exe.config -->
<configuration>
<connectionStrings configSource="externalConfig/connectionSt... |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | You can use the `configSource` attribute in the `connectionStrings`section to include an external connection strings file:
Application web.config
```
<configuration>
<connectionStrings configSource="connectionStrings.config" />
</configuration>
```
connectionStrings.config
```
<connectionStrings>
<add name="co... | If I understand correctly you want to factor out some 'stable' settings
1. The config system is hierarchical, you can store default settings in
`C:\Windows\Micorsoft.NET\<version>\Machine.config` or `Web.config`
That is a pretty heavy tool though. Make an error and most .NET apps will fail to start
2. Use [Confi... |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | If I understand correctly you want to factor out some 'stable' settings
1. The config system is hierarchical, you can store default settings in
`C:\Windows\Micorsoft.NET\<version>\Machine.config` or `Web.config`
That is a pretty heavy tool though. Make an error and most .NET apps will fail to start
2. Use [Confi... | Here is another idea (actually how we solve our config problem). Maybe this fits your needs better.
Our config files are rather big too but the only thing that really changes are the configuration strings.
We have a file for each configuration which contains the specific configuration string (database for developmen... |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | You can include external xml files into your web.config.
[See this question](https://stackoverflow.com/questions/480538/use-xml-includes-or-config-references-in-app-config-to-include-other-config-files)
```
<!-- SomeProgram.exe.config -->
<configuration>
<connectionStrings configSource="externalConfig/connectionSt... | You could centralize parts of the configuration and dynamically load that file. See this [codeproject article](http://www.codeproject.com/KB/cs/runtimeconsoleconfigfile.aspx) |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | You can use the `configSource` attribute in the `connectionStrings`section to include an external connection strings file:
Application web.config
```
<configuration>
<connectionStrings configSource="connectionStrings.config" />
</configuration>
```
connectionStrings.config
```
<connectionStrings>
<add name="co... | You could centralize parts of the configuration and dynamically load that file. See this [codeproject article](http://www.codeproject.com/KB/cs/runtimeconsoleconfigfile.aspx) |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | Here is another idea (actually how we solve our config problem). Maybe this fits your needs better.
Our config files are rather big too but the only thing that really changes are the configuration strings.
We have a file for each configuration which contains the specific configuration string (database for developmen... | You could centralize parts of the configuration and dynamically load that file. See this [codeproject article](http://www.codeproject.com/KB/cs/runtimeconsoleconfigfile.aspx) |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | You can use the `configSource` attribute in the `connectionStrings`section to include an external connection strings file:
Application web.config
```
<configuration>
<connectionStrings configSource="connectionStrings.config" />
</configuration>
```
connectionStrings.config
```
<connectionStrings>
<add name="co... | You can include external xml files into your web.config.
[See this question](https://stackoverflow.com/questions/480538/use-xml-includes-or-config-references-in-app-config-to-include-other-config-files)
```
<!-- SomeProgram.exe.config -->
<configuration>
<connectionStrings configSource="externalConfig/connectionSt... |
1,692,800 | In my production environment I have several Web applications installed in the same machine. These applications access various web services and two SQL Server databases this means that my web.config files are very big and full of details. Besides this I also have windows services that consume the same web services and a... | 2009/11/07 | [
"https://Stackoverflow.com/questions/1692800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/71666/"
] | You can use the `configSource` attribute in the `connectionStrings`section to include an external connection strings file:
Application web.config
```
<configuration>
<connectionStrings configSource="connectionStrings.config" />
</configuration>
```
connectionStrings.config
```
<connectionStrings>
<add name="co... | Here is another idea (actually how we solve our config problem). Maybe this fits your needs better.
Our config files are rather big too but the only thing that really changes are the configuration strings.
We have a file for each configuration which contains the specific configuration string (database for developmen... |
48,722,340 | Write a function that normalizes a vector (finds the unit vector). A vector can be normalized by dividing each individual component of the vector by its magnitude. Your input for this function will be a vector i.e. 1 dimensional list containing 3 integers.
According to the solution devised, I have considered a predefi... | 2018/02/10 | [
"https://Stackoverflow.com/questions/48722340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3254547/"
] | Also, you can use high order functions in `Python` like `map`:
```
vec = [1,2,3]
magnitude = sqrt(sum(map(lambda x: x**2, vec)))
normalized_vec = list(map(lambda x: x/magnitude, vec))
```
So `normalized_vec` becomes:
```
[0.2672612419124244, 0.5345224838248488, 0.8017837257372732]
```
Or using `Numpy`:
```
impor... | Please try the following code,
```
vector = [1,2,4]
y=0
for x in vector:
y+=x**2
y = y**0.5
unit_vector = []
for x in vector:
unit_vector.append(x/y)
```
Hope this helps. |
48,722,340 | Write a function that normalizes a vector (finds the unit vector). A vector can be normalized by dividing each individual component of the vector by its magnitude. Your input for this function will be a vector i.e. 1 dimensional list containing 3 integers.
According to the solution devised, I have considered a predefi... | 2018/02/10 | [
"https://Stackoverflow.com/questions/48722340",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3254547/"
] | Also, you can use high order functions in `Python` like `map`:
```
vec = [1,2,3]
magnitude = sqrt(sum(map(lambda x: x**2, vec)))
normalized_vec = list(map(lambda x: x/magnitude, vec))
```
So `normalized_vec` becomes:
```
[0.2672612419124244, 0.5345224838248488, 0.8017837257372732]
```
Or using `Numpy`:
```
impor... | ```
def vector_normalization(vec):
result = 0
for x in vec:
result = result + (x**2)
magnitude = (result)**0.5
x = vec[0]/magnitude
y = vec[1]/magnitude
z = vec[2]/magnitude
vec = [x,y,z]
return vec
``` |
30,192,597 | I need to find a password key. The length of the key is **10** characters and the order of the letters in the key is **3,7,2,1,4,5,6,10,8,9**. I also know the md5 of the key.
So I wrote
```
mystring = "abcdefghijklmnopqrstuvwxyz"
for letter3 in mystring:
for letter7 in mystring[mystring.index(letter3):]:
... | 2015/05/12 | [
"https://Stackoverflow.com/questions/30192597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4237058/"
] | **The solution is at the bottom**
---
You're very close. What you want is this...
```
mystring = "abcdefghijklmnopqrstuvwxyz"
for letter1 in mystring:
for letter2 in mystring[mystring.index(letter1):]:
for letter3 in mystring[mystring.index(letter2):]:
for letter4 in mystring[mystring.index(l... | If you compile it down to machine code, you find that for loop amounts to four parts. First the current iteration integer is loaded from memory, and the letter from the given array is loaded. Then whatever is within your for loop executes, and finally the index is incremented and a conditional jump is performed back to... |
23,650,936 | It is the first time I am trying to `deploy` artifacts using maven, and having some trouble understanding how does maven decide whether the artifact are to be uploaded to Central repository or Snapshot repository?
Is there any tag (or some other indicator) which I can use in pom.xml indicating that the artifact is fi... | 2014/05/14 | [
"https://Stackoverflow.com/questions/23650936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1242054/"
] | When the page is created, your button is not yet existed so all the events will not be available for this element, in this case you need to use **[event delegation](https://learn.jquery.com/events/event-delegation/)** to attach those events such as click in your case to this newly added button:
```
$('#a').on('click',... | Adding a click handler for an element that is loaded dynamically you should set the event handler on a parent object (your anchor that is not loaded dynamically) and give it a selector that matches your dynamic object like the code here:
```
$('#a').on("click", ".confirm", function() {});
``` |
10,774,239 | I'm having a hard time trying to get my task to stay persistent and run indefinitely from a WCF service. I may be doing this the wrong way and am willing to take suggestions.
I have a task that starts to process any incoming requests that are dropped into a BlockingCollection. From what I understand, the GetConsuming... | 2012/05/27 | [
"https://Stackoverflow.com/questions/10774239",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1155404/"
] | The code you have shown is correct by itself.
However there are a few things that can go wrong:
* If an exception occurs, your task stops (of course). Try adding a try-catch and log the exception.
* If you start worker threads in a hosted environment (ASP.NET, WCF, SQL Server) the host can decide arbitrarily (without... | It turns out the cause of this issue was with the WCF Binding Configuration. The task suddenly stopped becasue the WCF killed the connection due to a open timeout. The open timeout setting is the time that a request will wait for the service to open a connection before timing out. In certain situations, it reached the ... |
2,963,847 | I have an AJAX call which loads an Dialog page, now depending upon the content of the data returned on the AJAX call, I want to change the title of the Window, how do I do that.
Here is the snippet of code:
```
var divid = "brHistoryForm";
var url = "getRestoreFiles.action?profileName="+profileName;
// C... | 2010/06/03 | [
"https://Stackoverflow.com/questions/2963847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/185412/"
] | try
```
// The code...
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4){
document.getElementById(divid).innerHTML=xmlHttp.responseText;
document.getElementById('pageTitle').innerHTML = "<h2>"+profileName+" - B&R History</h2>";
}
}
``` | javascript and jquery
```
function changewindow(url,userdata){
$.ajax({
type: "POST",
url: url,
data: userdata,
dataType: "html",
success: function(html){
$("#bodycontent").html(html);
},
error: function(html){
alert(html);
}
});}
``` |
1,738,250 | Anyone happen to use this combination in their web application? I'm having a bit of trouble finding some sort of tutorial or guideline for configuring this. Also seeing as how I started using Pylons recently I'm not familiar so please keep the advice very newbie friendly ( I haven't even used modules like Beaker all th... | 2009/11/15 | [
"https://Stackoverflow.com/questions/1738250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/145190/"
] | `memcached` is nice and framework-agnostic, and you just have to write a bit of code to interact with it. The general idea of memcached is:
```
object = try_memcached()
if not object:
object = real_query()
put_in_memcached(object)
```
That will likely be done in your SQLAlchemy abstraction, in your case. Sin... | Pylons recommends Beaker for caching and it has a Memcache backend. See [here](http://pylonshq.com/docs/en/0.9.7/thirdparty/beaker/) |
12,813,075 | I am new to hibernate. I am confused with criteria's `setFirstResult` method.
From the documentation it seems hibernate returns rows from the the given number.
Since SQL query does not guarantee the ordering of rows without order by clause,
how `setFirstQuery` works in this case(without orderBy clause)?
Does hiber... | 2012/10/10 | [
"https://Stackoverflow.com/questions/12813075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1677236/"
] | Hibernate can not do something by its own unless its supported by underlying databases. Because Hibernate queries finally get transformed to `Sql` only.
Having said that it uses underlying databases capabilities like for PostgresSQL and MySQL it will generate query like `limit ? offset ?` .
You can add custom order u... | It is your task to add an order by, the function as you noticed won't guarantee same results if executed several times over the same set of data.
`setFirstResult` is typically used in pagination. |
58,703,461 | for example
```
> SETBIT bitmapsarestrings 2 1
> SETBIT bitmapsarestrings 3 1
> SETBIT bitmapsarestrings 5 1
> SETBIT bitmapsarestrings 10 1
> SETBIT bitmapsarestrings 11 1
> SETBIT bitmapsarestrings 14 1
> GET bitmapsarestrings
"42"
```
Binary storage should not like this: **0010 0110 0001 1100** ?
stored in this ... | 2019/11/05 | [
"https://Stackoverflow.com/questions/58703461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4741313/"
] | These `SETBIT` operations will make the value as a binary string, whose length is 2 bytes or 16 bits. After the settings, the value will be `0b 00110100 00110010` in binary format.
The first byte (`0b 00110100`) is `52`, which is the ascii code of '4', and the second byte (`0b 00110010`) is `50`, which is the ascii co... | What @for\_stack said, or just refer to the lines immediately above that example (<https://redis.io/commands/setbit>):
>
> Bitmaps are not an actual data type, but a set of bit-oriented operations defined on the String type (for more information refer to the Bitmaps section of the Data Types Introduction page). This ... |
28,576,851 | I have a tab separated file (tsv) whose schema is not known to me and i want to remove the first column from every row using "Scalding".
I know that if the schema is known then i can use
```
val dataControlSchema = List('a,'b,'c,'d,'e,'f)
Tsv("abc.tsv").read
.discard('a)
.write(Tsv("output1.tsv"))
```
but t... | 2015/02/18 | [
"https://Stackoverflow.com/questions/28576851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574307/"
] | >
> What I need to know is the possibility of this. Can I set my variables into the fields in my jrxml file?
>
>
>
Basically, yes.
You need to define the parameter as a "Parameter" type in the report, then supply the parameter as the "Text Field Expression" on the form in the format `$P{...}`
;
para.put(<key>,<value>);
para.put(<key>,<value>);
JasperFillManager.fillReportToFile(jr, para, new JRemptyDataSource());
```
if you don't write new JRemptyDataSource() a message will appear that the document has no pages
and inside your report create a field and in fiel... |
28,576,851 | I have a tab separated file (tsv) whose schema is not known to me and i want to remove the first column from every row using "Scalding".
I know that if the schema is known then i can use
```
val dataControlSchema = List('a,'b,'c,'d,'e,'f)
Tsv("abc.tsv").read
.discard('a)
.write(Tsv("output1.tsv"))
```
but t... | 2015/02/18 | [
"https://Stackoverflow.com/questions/28576851",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574307/"
] | >
> What I need to know is the possibility of this. Can I set my variables into the fields in my jrxml file?
>
>
>
Basically, yes.
You need to define the parameter as a "Parameter" type in the report, then supply the parameter as the "Text Field Expression" on the form in the format `$P{...}`
;
parameters.put("Author", "Prepared By Manisha");
JasperPrint print = JasperFillManager.fillReport(sourceFileName, parameters, new JREmptyDataSource());
JRPdfExporter exporter = new JRPdfExporter();
exporter.setExporterInput... |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | ```
from lxml import etree
print(etree.tostring(root, pretty_print=True))
```
you may see more examples here: <http://lxml.de/tutorial.html> | After right clicking (copy, copy xpath) on the specific field you want (in chrome's inspector), you might get something like this:
```
//*[@id="specialID"]/div[12]/div[2]/h4/text()[1]
```
If you wanted that text element for each "specialID"
```
//*[@id="specialID"]/div/div[2]/h4/text()[1]
```
You could select ano... |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | ```
from lxml import etree
print(etree.tostring(root, pretty_print=True))
```
you may see more examples here: <http://lxml.de/tutorial.html> | I believe you want to use the `tostring()` method:
```
from lxml import etree
tree = etree.fromstring('<html><head><title>foo</title></head><body><div class="name"><p>foo</p></div><div class="name"><ul><li>bar</li></ul></div></body></html>')
for elem in tree.xpath("//div[@class='name']"):
# pretty_print ensures ... |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | I believe you want to use the `tostring()` method:
```
from lxml import etree
tree = etree.fromstring('<html><head><title>foo</title></head><body><div class="name"><p>foo</p></div><div class="name"><ul><li>bar</li></ul></div></body></html>')
for elem in tree.xpath("//div[@class='name']"):
# pretty_print ensures ... | After right clicking (copy, copy xpath) on the specific field you want (in chrome's inspector), you might get something like this:
```
//*[@id="specialID"]/div[12]/div[2]/h4/text()[1]
```
If you wanted that text element for each "specialID"
```
//*[@id="specialID"]/div/div[2]/h4/text()[1]
```
You could select ano... |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | Simple function to get **innerHTML or innerXML**
.
Try it out directly <https://pyfiddle.io/fiddle/631aa049-2785-4c58-bf82-eff4e2f8bedb/>
.
**function**
```py
def innerXML(elem):
elemName = elem.xpath('name(/*)')
resultStr = ''
for e in elem.xpath('/'+ elemName + '/node()'):
if(isinstan... | You can use `product.text_content()` if what you are looking for is the text content rather than the HTML. |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | I believe you want to use the `tostring()` method:
```
from lxml import etree
tree = etree.fromstring('<html><head><title>foo</title></head><body><div class="name"><p>foo</p></div><div class="name"><ul><li>bar</li></ul></div></body></html>')
for elem in tree.xpath("//div[@class='name']"):
# pretty_print ensures ... | another way to do this
```
x=doc.xpath("//div[@class='name']/parent::*")
print(map(etree.tostring,x))
``` |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | ```
from lxml import etree
print(etree.tostring(root, pretty_print=True))
```
you may see more examples here: <http://lxml.de/tutorial.html> | Simple function to get **innerHTML or innerXML**
.
Try it out directly <https://pyfiddle.io/fiddle/631aa049-2785-4c58-bf82-eff4e2f8bedb/>
.
**function**
```py
def innerXML(elem):
elemName = elem.xpath('name(/*)')
resultStr = ''
for e in elem.xpath('/'+ elemName + '/node()'):
if(isinstan... |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | Simple function to get **innerHTML or innerXML**
.
Try it out directly <https://pyfiddle.io/fiddle/631aa049-2785-4c58-bf82-eff4e2f8bedb/>
.
**function**
```py
def innerXML(elem):
elemName = elem.xpath('name(/*)')
resultStr = ''
for e in elem.xpath('/'+ elemName + '/node()'):
if(isinstan... | After right clicking (copy, copy xpath) on the specific field you want (in chrome's inspector), you might get something like this:
```
//*[@id="specialID"]/div[12]/div[2]/h4/text()[1]
```
If you wanted that text element for each "specialID"
```
//*[@id="specialID"]/div/div[2]/h4/text()[1]
```
You could select ano... |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | I believe you want to use the `tostring()` method:
```
from lxml import etree
tree = etree.fromstring('<html><head><title>foo</title></head><body><div class="name"><p>foo</p></div><div class="name"><ul><li>bar</li></ul></div></body></html>')
for elem in tree.xpath("//div[@class='name']"):
# pretty_print ensures ... | You can use `product.text_content()` if what you are looking for is the text content rather than the HTML. |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | Simple function to get **innerHTML or innerXML**
.
Try it out directly <https://pyfiddle.io/fiddle/631aa049-2785-4c58-bf82-eff4e2f8bedb/>
.
**function**
```py
def innerXML(elem):
elemName = elem.xpath('name(/*)')
resultStr = ''
for e in elem.xpath('/'+ elemName + '/node()'):
if(isinstan... | another way to do this
```
x=doc.xpath("//div[@class='name']/parent::*")
print(map(etree.tostring,x))
``` |
14,896,302 | I am trying to get the HTML content of child node with lxml and xpath in Python. As shown in code below, I want to find the html content of the each of product nodes. Does it have any methods like product.html?
```
productGrids = tree.xpath("//div[@class='name']/parent::*")
for product in productGrids:
print #html... | 2013/02/15 | [
"https://Stackoverflow.com/questions/14896302",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159766/"
] | ```
from lxml import etree
print(etree.tostring(root, pretty_print=True))
```
you may see more examples here: <http://lxml.de/tutorial.html> | You can use `product.text_content()` if what you are looking for is the text content rather than the HTML. |
2,987 | I've seen many Russians write *"на хуй"* separately, or *"нахуй"* as one word, although I'm 99 % sure it should be written separately. Why is it so often written as one word? (Because the stress on на confuses them?) And is the spelling with a space the correct version? | 2014/01/04 | [
"https://russian.stackexchange.com/questions/2987",
"https://russian.stackexchange.com",
"https://russian.stackexchange.com/users/2360/"
] | Both spelling are correct since they stand for at least two different parts of speech.
As an adverb, *нахуй* should be written as one word like any other adverb in Russian.
It can mean *totally, entirely*.
>
> Как ты заебала, заткни на́хуй свое ебало! (song by the band Evil Not Alone)
>
>
>
Or as a variant of *... | I decided to add my answer since I completely disagree with the accepted answer (Dmitry). The expression should be written separately — this is the grammatically correct form. If Dmitry could substantiate his answer, that would be interesting. The reference to the song can't be considered legitimate proof of the expres... |
2,987 | I've seen many Russians write *"на хуй"* separately, or *"нахуй"* as one word, although I'm 99 % sure it should be written separately. Why is it so often written as one word? (Because the stress on на confuses them?) And is the spelling with a space the correct version? | 2014/01/04 | [
"https://russian.stackexchange.com/questions/2987",
"https://russian.stackexchange.com",
"https://russian.stackexchange.com/users/2360/"
] | Both spelling are correct since they stand for at least two different parts of speech.
As an adverb, *нахуй* should be written as one word like any other adverb in Russian.
It can mean *totally, entirely*.
>
> Как ты заебала, заткни на́хуй свое ебало! (song by the band Evil Not Alone)
>
>
>
Or as a variant of *... | Следует улавливать тонкую грань в использовании вариантов «нахуй» и «на хуй». Существует наречие «нахуй». Оно имеет смысл «зачем»/«прочь». Также есть одноимённое междометие, которое используется просто в качестве связки слов в предложении.
Надень шапку, нахуй, а то простудишься
В отличие от наречия, «на хуй» надо поним... |
2,987 | I've seen many Russians write *"на хуй"* separately, or *"нахуй"* as one word, although I'm 99 % sure it should be written separately. Why is it so often written as one word? (Because the stress on на confuses them?) And is the spelling with a space the correct version? | 2014/01/04 | [
"https://russian.stackexchange.com/questions/2987",
"https://russian.stackexchange.com",
"https://russian.stackexchange.com/users/2360/"
] | Следует улавливать тонкую грань в использовании вариантов «нахуй» и «на хуй». Существует наречие «нахуй». Оно имеет смысл «зачем»/«прочь». Также есть одноимённое междометие, которое используется просто в качестве связки слов в предложении.
Надень шапку, нахуй, а то простудишься
В отличие от наречия, «на хуй» надо поним... | I decided to add my answer since I completely disagree with the accepted answer (Dmitry). The expression should be written separately — this is the grammatically correct form. If Dmitry could substantiate his answer, that would be interesting. The reference to the song can't be considered legitimate proof of the expres... |
22,856,280 | I am new to D3 and i'm stuck on a case.
I have a button that adds circles to my svg.
```
d3.select("button#add").on("click", function()
{
svg.append('circle')
.attr('class', 'little')
.attr("cx", Math.random()*280+10)
.attr("cy",Math.random()*280+10)
.attr("r", 12);
});
```
... | 2014/04/04 | [
"https://Stackoverflow.com/questions/22856280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1071430/"
] | Here is a [FIDDLE](http://jsfiddle.net/cRV7G/1/) to help you out.
```
...
function paintCircle(d) {
d3.select(this)
.style("fill", "red");
};
``` | The issue lies in the fact that this:
```
d3.selectAll(".little").on('click', function() {
d3.select(this).style("fill", "red");
});
```
only runs once. But when the button click creates a new circle, it creates it without adding the onclick property, and since the above code isn't run again, the new circle ... |
542,983 | Given a list of readings in the following format:
```
1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0
1 1 0 0 2 2 23104 23104 0 0 1 0 5 1 0 0
```
What would be an approriate (and clean !) way to map them to their labels (the labels are not in a fixed format, I just know from the documentation that column 1 maps to X, column... | 2019/09/21 | [
"https://unix.stackexchange.com/questions/542983",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102456/"
] | With `awk`:
```
LABELS='name_of_label_1 name_of_label_2 ...' awk '
BEGIN{split(ENVIRON["LABELS"], label)}
{
for (i = 1; i <= NF; i++)
print "# TYPE", label[i], "counter\n"label[i], $i
}' < input-file
``` | Let me know if this does what you need.
* the `labels.txt` file used for testing:
```none
label_zero
label_one
label_two
label_three
label_four
```
* the Perl script to apply a label to each column (until they are depleted):
```bsh
echo "1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0" |
perl -e 'open($lf, "<", "labels.... |
542,983 | Given a list of readings in the following format:
```
1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0
1 1 0 0 2 2 23104 23104 0 0 1 0 5 1 0 0
```
What would be an approriate (and clean !) way to map them to their labels (the labels are not in a fixed format, I just know from the documentation that column 1 maps to X, column... | 2019/09/21 | [
"https://unix.stackexchange.com/questions/542983",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102456/"
] | Let me know if this does what you need.
* the `labels.txt` file used for testing:
```none
label_zero
label_one
label_two
label_three
label_four
```
* the Perl script to apply a label to each column (until they are depleted):
```bsh
echo "1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0" |
perl -e 'open($lf, "<", "labels.... | Done by below command
```
echo "1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0"| sed "s/ /\n/g"| awk '{print "# TYPE name_of_label_1 counter"NR}{print "name_of_label_"NR " " $0}'
```
output
```
# TYPE name_of_label_1 counter1
name_of_label_1 1
# TYPE name_of_label_1 counter2
name_of_label_2 1
# TYPE name_of_label_1 counte... |
542,983 | Given a list of readings in the following format:
```
1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0
1 1 0 0 2 2 23104 23104 0 0 1 0 5 1 0 0
```
What would be an approriate (and clean !) way to map them to their labels (the labels are not in a fixed format, I just know from the documentation that column 1 maps to X, column... | 2019/09/21 | [
"https://unix.stackexchange.com/questions/542983",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/102456/"
] | With `awk`:
```
LABELS='name_of_label_1 name_of_label_2 ...' awk '
BEGIN{split(ENVIRON["LABELS"], label)}
{
for (i = 1; i <= NF; i++)
print "# TYPE", label[i], "counter\n"label[i], $i
}' < input-file
``` | Done by below command
```
echo "1 1 0 0 2 3 23101 23101 0 0 2 0 5 2 0 0"| sed "s/ /\n/g"| awk '{print "# TYPE name_of_label_1 counter"NR}{print "name_of_label_"NR " " $0}'
```
output
```
# TYPE name_of_label_1 counter1
name_of_label_1 1
# TYPE name_of_label_1 counter2
name_of_label_2 1
# TYPE name_of_label_1 counte... |
38,952,170 | I have some string as follows:
```
String str = "Data[tableName=hello,schemaName=test,columns=[column[name=h1,key=true],column[name=h2,keys=false]]]";
```
How to divide the string using regex like (),(),() to get:
1. tableName=hello
2. schemaName=test
3. columns=[column[name=h1,key=true],column[name=h2,keys=false]]... | 2016/08/15 | [
"https://Stackoverflow.com/questions/38952170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2356917/"
] | If you want to record the results in some file (work with IO redirection inside of the `nohup`), you need to enclose all the pipeline in the `nohup`. It does not use shell expansions, since argument is only `COMMAND` `ARGS`, so using a `sh` is a good way:
```
ssh user@host2 'nohup sh -c "/path/run |& tee myFile.txt" &... | use nohup, screen or tmux for backgrounding a process. |
43,899,190 | Using .Net Core MVC. I need to setup my model so that EntityFrameworkCore will auto generate the ID property. I thought that just adding the `[Key]` annotation would do this, but it doesn't. As a matter of fact, it produces an error when the ID field is left blank, which is always because I'm hiding it from the user.
... | 2017/05/10 | [
"https://Stackoverflow.com/questions/43899190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5158272/"
] | You need to change your data annotations for your `ExampleModel` so that it auto generates a unique ID.
**ExampleModel**
```
public class ExampleModel
{
[ScaffoldColumn(false)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
public string SomeData { get; set; }
}
``... | To auto generate a key, you must define a DEFAULT constraint pointing to "NewId()". `[Key]` will only create a Primary Key constraint.
You can do this on the database itself or in the model generation |
43,899,190 | Using .Net Core MVC. I need to setup my model so that EntityFrameworkCore will auto generate the ID property. I thought that just adding the `[Key]` annotation would do this, but it doesn't. As a matter of fact, it produces an error when the ID field is left blank, which is always because I'm hiding it from the user.
... | 2017/05/10 | [
"https://Stackoverflow.com/questions/43899190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5158272/"
] | I guess another way to pass by ModelState validation is to remove it from ModelState.
```
ModelState.Remove("ID");
``` | To auto generate a key, you must define a DEFAULT constraint pointing to "NewId()". `[Key]` will only create a Primary Key constraint.
You can do this on the database itself or in the model generation |
43,899,190 | Using .Net Core MVC. I need to setup my model so that EntityFrameworkCore will auto generate the ID property. I thought that just adding the `[Key]` annotation would do this, but it doesn't. As a matter of fact, it produces an error when the ID field is left blank, which is always because I'm hiding it from the user.
... | 2017/05/10 | [
"https://Stackoverflow.com/questions/43899190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5158272/"
] | You need to change your data annotations for your `ExampleModel` so that it auto generates a unique ID.
**ExampleModel**
```
public class ExampleModel
{
[ScaffoldColumn(false)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
public string SomeData { get; set; }
}
``... | I figured it out. All I needed to do was add the Data Anotation `[ScaffoldColumn(false)]` And now it works. |
43,899,190 | Using .Net Core MVC. I need to setup my model so that EntityFrameworkCore will auto generate the ID property. I thought that just adding the `[Key]` annotation would do this, but it doesn't. As a matter of fact, it produces an error when the ID field is left blank, which is always because I'm hiding it from the user.
... | 2017/05/10 | [
"https://Stackoverflow.com/questions/43899190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5158272/"
] | I guess another way to pass by ModelState validation is to remove it from ModelState.
```
ModelState.Remove("ID");
``` | I figured it out. All I needed to do was add the Data Anotation `[ScaffoldColumn(false)]` And now it works. |
43,899,190 | Using .Net Core MVC. I need to setup my model so that EntityFrameworkCore will auto generate the ID property. I thought that just adding the `[Key]` annotation would do this, but it doesn't. As a matter of fact, it produces an error when the ID field is left blank, which is always because I'm hiding it from the user.
... | 2017/05/10 | [
"https://Stackoverflow.com/questions/43899190",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5158272/"
] | You need to change your data annotations for your `ExampleModel` so that it auto generates a unique ID.
**ExampleModel**
```
public class ExampleModel
{
[ScaffoldColumn(false)]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }
public string SomeData { get; set; }
}
``... | I guess another way to pass by ModelState validation is to remove it from ModelState.
```
ModelState.Remove("ID");
``` |
15,072,812 | I just can't figure out how to accomplish the following;
I'd like to display the "human readable form" (`refresh_interval_entries`), for example in a `Log.d()`, corresponding to what has been selected in `refresh_interval_values`.
* I have two arrays defined in `values\arrays.xml`:
```
<string-array name="refresh_in... | 2013/02/25 | [
"https://Stackoverflow.com/questions/15072812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1086552/"
] | How about on start of your application, you make a `HashMap` out of the two `arrays`:
```
HashMap<String, String> dictionary = new HashMap<String, String>();
String[] mEntries = getResources().getStringArray(R.array.refresh_interval_entries);
String[] mValues = getResources().getStringArray(R.array.refresh_interval_v... | Do something like this:
```
{
...
String[] mEntries = getResources().getStringArray(R.array.refresh_interval_entries);
String[] mValues = getResources().getStringArray(R.array.refresh_interval_values);
Log.d(TAG, "120=" + getEntryFromValue("120", mEntries, mValues));
}
private ... |
14,727,590 | I have some HTML5 tags in my webpage. i have used `<!DOCTYPE html>` for the same webpage... But i'm facing some spacing issues. I have tried `line-height:0px; and vertical-align` also... But by this some other issue opens up...so i can't use line-height:0;...
I have tried to change `<!DOCTYPE html>` to
```
<!DOCTYPE... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14727590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1679558/"
] | The XHTML 1.0 Transitional doctype puts many browsers into [Quirks Mode](http://www.cs.tut.fi/~jkorpela/quirks-mode.html), which means an intentionally broken mode where the browser more or less emulates extinct versions of IE, with many bugs and oddities, or into [Almost Standards Mode](http://hsivonen.iki.fi/doctype/... | By adding this you are changing the doctype. See [link on Doc Types](http://www.w3schools.com/tags/tag_doctype.asp)
You should look to change the relevant CSS/HTML if you are having styling issues within the actual page, you should create a new question including code if that is the case |
241,590 | I have a signal that changes from high state to low every few minutes, after changing state it will remain constant, all level changes are clean.
I'm looking for the smallest possible circuit that can detect a rising edge and falling edge (could be two different circuits) and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | Search for flip flops. They do exactly what you want and can be very small and cheap.
If you put 5V on the D wire, your signal that changes every few minutes on the clk and Q on the reset, Q will give a 5V pulse when a rising edge has been detected.
That is ofcourse if your signal is around 5V.
[ and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | Search for flip flops. They do exactly what you want and can be very small and cheap.
If you put 5V on the D wire, your signal that changes every few minutes on the clk and Q on the reset, Q will give a 5V pulse when a rising edge has been detected.
That is ofcourse if your signal is around 5V.
[
[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fDqTSs.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) |
241,590 | I have a signal that changes from high state to low every few minutes, after changing state it will remain constant, all level changes are clean.
I'm looking for the smallest possible circuit that can detect a rising edge and falling edge (could be two different circuits) and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | A [CD4098](http://www.ti.com/lit/ds/symlink/cd4098b.pdf) dual one-shot will meet all your stated requirements and is very cheap and available. It can operate from 9V, trigger on either the rising or falling edge, and provides positive or negative going pulses. An R-C pair sets the pulse duration for each half of the ch... | Search for flip flops. They do exactly what you want and can be very small and cheap.
If you put 5V on the D wire, your signal that changes every few minutes on the clk and Q on the reset, Q will give a 5V pulse when a rising edge has been detected.
That is ofcourse if your signal is around 5V.
[ and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | The simplest circuit that meets the stated requirements is an R-C differentiator:

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fIaSG4.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/)
[ and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | A [CD4098](http://www.ti.com/lit/ds/symlink/cd4098b.pdf) dual one-shot will meet all your stated requirements and is very cheap and available. It can operate from 9V, trigger on either the rising or falling edge, and provides positive or negative going pulses. An R-C pair sets the pulse duration for each half of the ch... | You could use a flip flop of course but if you want a "pulse" you can try a high-pass circuit in series with a monostable multivibrator implemented with a schmitt trigger. |
241,590 | I have a signal that changes from high state to low every few minutes, after changing state it will remain constant, all level changes are clean.
I'm looking for the smallest possible circuit that can detect a rising edge and falling edge (could be two different circuits) and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | The simplest circuit that meets the stated requirements is an R-C differentiator:

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fIaSG4.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/)
[![input and output wav... | You could use a flip flop of course but if you want a "pulse" you can try a high-pass circuit in series with a monostable multivibrator implemented with a schmitt trigger. |
241,590 | I have a signal that changes from high state to low every few minutes, after changing state it will remain constant, all level changes are clean.
I'm looking for the smallest possible circuit that can detect a rising edge and falling edge (could be two different circuits) and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | A [CD4098](http://www.ti.com/lit/ds/symlink/cd4098b.pdf) dual one-shot will meet all your stated requirements and is very cheap and available. It can operate from 9V, trigger on either the rising or falling edge, and provides positive or negative going pulses. An R-C pair sets the pulse duration for each half of the ch... | Positive edge with relay.

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fDqTSs.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) |
241,590 | I have a signal that changes from high state to low every few minutes, after changing state it will remain constant, all level changes are clean.
I'm looking for the smallest possible circuit that can detect a rising edge and falling edge (could be two different circuits) and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | The simplest circuit that meets the stated requirements is an R-C differentiator:

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fIaSG4.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/)
[
[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fDqTSs.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/) |
241,590 | I have a signal that changes from high state to low every few minutes, after changing state it will remain constant, all level changes are clean.
I'm looking for the smallest possible circuit that can detect a rising edge and falling edge (could be two different circuits) and will output a pulse when the edge is detec... | 2016/06/18 | [
"https://electronics.stackexchange.com/questions/241590",
"https://electronics.stackexchange.com",
"https://electronics.stackexchange.com/users/34920/"
] | A [CD4098](http://www.ti.com/lit/ds/symlink/cd4098b.pdf) dual one-shot will meet all your stated requirements and is very cheap and available. It can operate from 9V, trigger on either the rising or falling edge, and provides positive or negative going pulses. An R-C pair sets the pulse duration for each half of the ch... | The simplest circuit that meets the stated requirements is an R-C differentiator:

[simulate this circuit](/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fIaSG4.png) – Schematic created using [CircuitLab](https://www.circuitlab.com/)
[![input and output wav... |
21,790,191 | code that gives my sessions username: works perfectly after login and gives the username
```
<?php echo $_SESSION['userName']; ?>
```
Now I want to count all files in a folder, the folder's name is the username of the person logged in. But I can't get it to work somehow...
```
<?php $pm = 0;
$dir = './bericht... | 2014/02/14 | [
"https://Stackoverflow.com/questions/21790191",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3090697/"
] | Your string formatting was a bit off, try this:
```
$dir = './berichten/' . $_SESSION['userName'] . '/';
```
These kind of notations (`<?php echo $_SESSION['userName']; ?>`) are usually found outside of PHP-code, for example HTML. You don't need to open PHP tags or echo's inside a PHP echo :) | I can't recall if `readdir` can handle a directory path with the trailing slash. Besides [Aquillo's answer](https://stackoverflow.com/a/21790212/198536), try removing the trailing slash.
```
$dir = './berichten/' . $_SESSION['userName'];
``` |
5,701,228 | The question regards .Net specifically.
Suppose a base class A has 2 derived classes B and C. Further, suppose base class A has a static variable called 's'. Is this static variable values shared between 'B' and 'C', or does each get its own copy of the static variable.
My current knowledge says that normally the sta... | 2011/04/18 | [
"https://Stackoverflow.com/questions/5701228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/172396/"
] | Could you show some code?
>
>
> ```
> public class A
> {
> private static string test;
> public string Test { get { return test; } set { test = value; } }
>
> public override string ToString()
> {
> return Test;
> }
> }
>
> public class B : A
> {
> public override string ToString()
... | the static member in base class is shared between the derived classes. The value you would see for the variable should be consistent across different derived classes you use to access it. |
16,061,134 | I'm using the ginjo-RFM gem for connecting to a Filemaker Database, and want to use Devise for authentication. The problem with this is the fact that Devise requires my User model to inherit from ActiveRecord::Base - and RFM requires, for it to access the database at all, to inherit from Rfm::Base. Is it possible to le... | 2013/04/17 | [
"https://Stackoverflow.com/questions/16061134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1792207/"
] | Devise actually relies on [orm\_adapter](https://github.com/ianwhite/orm_adapter) rather than directly on ActiveRecord. (Take a look [here](https://github.com/plataformatec/devise/tree/master/lib/devise/orm).) So in theory, it would be trivial to use Devise with any class that has an OrmAdapter implemented.
Since [gin... | Your best bet might be to create a new class that you can delegate the filemaker calls to.
The User class is how they auth to your website, and you manage roles.
```
class User < ActiveRecord::Base
rolify
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
... |
48,488,249 | My team/company tried out SSDT for a few small projects and we were quite impressed.
Recently we investigated use of SSDT for one of our larger existing applications and got FLOODED with SQL71501 errors for external database references.
There is quite a web of database coupling for the application, so that is underst... | 2018/01/28 | [
"https://Stackoverflow.com/questions/48488249",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5855178/"
] | I was just about to cleanup a few of these in my solution after upgrading to a new version of sql server. I'm on VS2017 but I think this was the same.
If you have database projects in the solution already for the referenced databases, then you can just add database references to the project throwing the errors. If you... | I had success with Visual Studio 2017 by adding the exact warning code against the file that was having the trouble, in my case it was "un resolved reference" I didnt want to add a reference to the master DB to my project.
Right click on File, Properties, Suppress TSql Warnings : 71502 |
65,022,186 | Suppose we have a data set, a snippet looks like:
```
count party gender
0 Rep F
2 Rep M
3 Rep F
```
I'm trying to calculate the average value of the `count` column if `party = Rep` and `gender = F`. I.e. it should be 1.5 here. How can this be written in R code? | 2020/11/26 | [
"https://Stackoverflow.com/questions/65022186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14516614/"
] | Does this work:
```
library(dplyr)
dat %>% filter(party == 'Rep' & gender == 'F') %>% summarise(avg = mean(count))
# A tibble: 1 x 1
avg
<dbl>
1 1.5
``` | If you want to use base R:
```
mean(df[(df$party == 'Rep' & df$gender == 'F'),]$count)
``` |
65,022,186 | Suppose we have a data set, a snippet looks like:
```
count party gender
0 Rep F
2 Rep M
3 Rep F
```
I'm trying to calculate the average value of the `count` column if `party = Rep` and `gender = F`. I.e. it should be 1.5 here. How can this be written in R code? | 2020/11/26 | [
"https://Stackoverflow.com/questions/65022186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14516614/"
] | Does this work:
```
library(dplyr)
dat %>% filter(party == 'Rep' & gender == 'F') %>% summarise(avg = mean(count))
# A tibble: 1 x 1
avg
<dbl>
1 1.5
``` | Using `data.table`:
```
setDT(dt)
dt[, mean(count), .(party, gender)]
```
Output:
```
party gender V1
1: Rep F 1.5
2: Rep M 2.0
```
This will calculate the `mean` of `count` for all `party`-`gender` pairs, in the case that you want to include all combinations (not just only `Rep`/`F`).
Data:
`... |
65,022,186 | Suppose we have a data set, a snippet looks like:
```
count party gender
0 Rep F
2 Rep M
3 Rep F
```
I'm trying to calculate the average value of the `count` column if `party = Rep` and `gender = F`. I.e. it should be 1.5 here. How can this be written in R code? | 2020/11/26 | [
"https://Stackoverflow.com/questions/65022186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14516614/"
] | If you want to use base R:
```
mean(df[(df$party == 'Rep' & df$gender == 'F'),]$count)
``` | Using `data.table`:
```
setDT(dt)
dt[, mean(count), .(party, gender)]
```
Output:
```
party gender V1
1: Rep F 1.5
2: Rep M 2.0
```
This will calculate the `mean` of `count` for all `party`-`gender` pairs, in the case that you want to include all combinations (not just only `Rep`/`F`).
Data:
`... |
2,824,749 | How can I change the view in the Details pane of the `UISplitView` so that its a completely different view?
Im having a fair amount of trouble understanding how its all wired up and where things should go at the moment, could someone please enlighten me?
What I would love to be able to do is to show a specific view b... | 2010/05/13 | [
"https://Stackoverflow.com/questions/2824749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26310/"
] | you can create split view programmitically and add view controller in viewcontroller array of UISplit view .
So changing view controller in split view is possible.
```
self.splitViewController =[[UISplitViewController alloc]init];
self.rootViewController=[[RootViewController alloc]init];
self.detailViewControl... | >
> Change the view of the
> DetailViewController how should I do
> this?
>
>
>
In Simple, you can make another UIViewController (ex named as MyCostomViewController) with corresponding nib file. Then do the following inside the method under rootViewController
```
- (void)tableView:(UITableView *)aTableView didS... |
10,215,250 | I have a closed-source 3rd-party shared library I need to link against. Unfortunately, the creators of the 3rd-party library didn't bother to limit which symbols are exported and exported all symbols. The 3rd-party library internally uses an incompatible version of a popular library that I am using in my code but expor... | 2012/04/18 | [
"https://Stackoverflow.com/questions/10215250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1342146/"
] | I found a solution that works... I created a shim library that redirects calls to the third-party library allowing code outside the library to see protbuf v2.4 symbols while code inside the third-party library sees protobuf v2.3 symbols. This workaround was based on the idea posted here: <http://www.linuxjournal.com/ar... | It might help to change the order of libraries you pass to the linker. If several libraries export the same symbol the linker should use the one from the first library. But, not all linkers are according to that, so have a look into its documentation. |
688,503 | $$f(x)=x-3x^{1/3}$$
$$f'(x)=1-x^{-2/3}$$
$$f''(x)=\frac{2}{3}x^{-5/3}$$
$f ''(x)=0$ has no solution. Does that mean f has no inflection point? If $x > 0$ then $f$ is concave up and if $x < 0$ then $f$ is concave down. Where $f$ changes concavity?
Inflection point is where the function changes concavity or where the se... | 2014/02/24 | [
"https://math.stackexchange.com/questions/688503",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/129429/"
] | There are certainly normal forms of propositional formulae, e.g. [CNF](http://en.wikipedia.org/wiki/Conjunctive_normal_form), but I don't think that any *particular* normal form can claim to be the "unique underlying deep structure of the formulae to which it is equivalent." After all, how simple a formula appears depe... | "Is there eventually a simple rule to single out a distinguished representative among all equivalent formulas that represents the type of a formula ϕ? Might this rule be as simple as "the formula with minimal numbers of variables, connectives and occurrences thereof"? "
No. The law of commutation is a logical truth. T... |
688,503 | $$f(x)=x-3x^{1/3}$$
$$f'(x)=1-x^{-2/3}$$
$$f''(x)=\frac{2}{3}x^{-5/3}$$
$f ''(x)=0$ has no solution. Does that mean f has no inflection point? If $x > 0$ then $f$ is concave up and if $x < 0$ then $f$ is concave down. Where $f$ changes concavity?
Inflection point is where the function changes concavity or where the se... | 2014/02/24 | [
"https://math.stackexchange.com/questions/688503",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/129429/"
] | There are certainly normal forms of propositional formulae, e.g. [CNF](http://en.wikipedia.org/wiki/Conjunctive_normal_form), but I don't think that any *particular* normal form can claim to be the "unique underlying deep structure of the formulae to which it is equivalent." After all, how simple a formula appears depe... | If you think to a "canonical representation of a formula", following @Doug Spoonwood refernce to [*polish notation*](http://en.wikipedia.org/wiki/Polish_notation) and @Peter Smith reference to Wittgenstein, we can use the [Sheffer stroke](http://en.wikipedia.org/wiki/Sheffer_stroke).
We have two possibilities :
*(i)*... |
688,503 | $$f(x)=x-3x^{1/3}$$
$$f'(x)=1-x^{-2/3}$$
$$f''(x)=\frac{2}{3}x^{-5/3}$$
$f ''(x)=0$ has no solution. Does that mean f has no inflection point? If $x > 0$ then $f$ is concave up and if $x < 0$ then $f$ is concave down. Where $f$ changes concavity?
Inflection point is where the function changes concavity or where the se... | 2014/02/24 | [
"https://math.stackexchange.com/questions/688503",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/129429/"
] | [Game semantics](http://en.wikipedia.org/wiki/Game_semantics) might be something like what you're looking for. If you have a formula and take all valid game traces for it, and then remove plays that correspond only to the visible *connectives* of the formula, keeping those that correspond to the *atoms*, then conceivab... | "Is there eventually a simple rule to single out a distinguished representative among all equivalent formulas that represents the type of a formula ϕ? Might this rule be as simple as "the formula with minimal numbers of variables, connectives and occurrences thereof"? "
No. The law of commutation is a logical truth. T... |
688,503 | $$f(x)=x-3x^{1/3}$$
$$f'(x)=1-x^{-2/3}$$
$$f''(x)=\frac{2}{3}x^{-5/3}$$
$f ''(x)=0$ has no solution. Does that mean f has no inflection point? If $x > 0$ then $f$ is concave up and if $x < 0$ then $f$ is concave down. Where $f$ changes concavity?
Inflection point is where the function changes concavity or where the se... | 2014/02/24 | [
"https://math.stackexchange.com/questions/688503",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/129429/"
] | [Game semantics](http://en.wikipedia.org/wiki/Game_semantics) might be something like what you're looking for. If you have a formula and take all valid game traces for it, and then remove plays that correspond only to the visible *connectives* of the formula, keeping those that correspond to the *atoms*, then conceivab... | If you think to a "canonical representation of a formula", following @Doug Spoonwood refernce to [*polish notation*](http://en.wikipedia.org/wiki/Polish_notation) and @Peter Smith reference to Wittgenstein, we can use the [Sheffer stroke](http://en.wikipedia.org/wiki/Sheffer_stroke).
We have two possibilities :
*(i)*... |
688,503 | $$f(x)=x-3x^{1/3}$$
$$f'(x)=1-x^{-2/3}$$
$$f''(x)=\frac{2}{3}x^{-5/3}$$
$f ''(x)=0$ has no solution. Does that mean f has no inflection point? If $x > 0$ then $f$ is concave up and if $x < 0$ then $f$ is concave down. Where $f$ changes concavity?
Inflection point is where the function changes concavity or where the se... | 2014/02/24 | [
"https://math.stackexchange.com/questions/688503",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/129429/"
] | You seem to be talking about a way to choose a particular surface structure to be the canonical representation of the formula.
But... Is it really necessary that the deep structure "look and feel" like a surface structure? If not, every formula in (classical) propositional logic can be reduced to an unambiguous deep s... | "Is there eventually a simple rule to single out a distinguished representative among all equivalent formulas that represents the type of a formula ϕ? Might this rule be as simple as "the formula with minimal numbers of variables, connectives and occurrences thereof"? "
No. The law of commutation is a logical truth. T... |
688,503 | $$f(x)=x-3x^{1/3}$$
$$f'(x)=1-x^{-2/3}$$
$$f''(x)=\frac{2}{3}x^{-5/3}$$
$f ''(x)=0$ has no solution. Does that mean f has no inflection point? If $x > 0$ then $f$ is concave up and if $x < 0$ then $f$ is concave down. Where $f$ changes concavity?
Inflection point is where the function changes concavity or where the se... | 2014/02/24 | [
"https://math.stackexchange.com/questions/688503",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/129429/"
] | You seem to be talking about a way to choose a particular surface structure to be the canonical representation of the formula.
But... Is it really necessary that the deep structure "look and feel" like a surface structure? If not, every formula in (classical) propositional logic can be reduced to an unambiguous deep s... | If you think to a "canonical representation of a formula", following @Doug Spoonwood refernce to [*polish notation*](http://en.wikipedia.org/wiki/Polish_notation) and @Peter Smith reference to Wittgenstein, we can use the [Sheffer stroke](http://en.wikipedia.org/wiki/Sheffer_stroke).
We have two possibilities :
*(i)*... |
10,366,925 | Please help my knowledge is limited and I have been struggling with this for almost a week now.
I have a table which allows the user to post to it. I want to display each month that has a post in it e.g.
DEC
OCT
SEPT
AUG
FEB
However, if there has been multiple post in a single month, I only want that month to be dis... | 2012/04/28 | [
"https://Stackoverflow.com/questions/10366925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363329/"
] | A Singleton is bad, but at the very least you could use a simpler implementation:
```
class porter {
public:
static porter& instance() { static porter P; return P; }
template <typename T, size_t N>
void portit(T (&array)[N]) {
std::sort(array, array + N);
}
private:
porter() = default;
... | You could use function templates
Something like
```
...
template <typename T>
void portit(T theArray[])
{
//sort array someway
}
...
``` |
10,366,925 | Please help my knowledge is limited and I have been struggling with this for almost a week now.
I have a table which allows the user to post to it. I want to display each month that has a post in it e.g.
DEC
OCT
SEPT
AUG
FEB
However, if there has been multiple post in a single month, I only want that month to be dis... | 2012/04/28 | [
"https://Stackoverflow.com/questions/10366925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363329/"
] | You could use function templates
Something like
```
...
template <typename T>
void portit(T theArray[])
{
//sort array someway
}
...
``` | So something like...
```
template <typename T>
class porter<T> {
public:
template <typename T>
static porter<T> * getInstance() {
}
private:
static porter<T> * instance;
}
```
??? Note: this might not compile. It's been a while since I've dabbled in templates.
... |
10,366,925 | Please help my knowledge is limited and I have been struggling with this for almost a week now.
I have a table which allows the user to post to it. I want to display each month that has a post in it e.g.
DEC
OCT
SEPT
AUG
FEB
However, if there has been multiple post in a single month, I only want that month to be dis... | 2012/04/28 | [
"https://Stackoverflow.com/questions/10366925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1363329/"
] | A Singleton is bad, but at the very least you could use a simpler implementation:
```
class porter {
public:
static porter& instance() { static porter P; return P; }
template <typename T, size_t N>
void portit(T (&array)[N]) {
std::sort(array, array + N);
}
private:
porter() = default;
... | So something like...
```
template <typename T>
class porter<T> {
public:
template <typename T>
static porter<T> * getInstance() {
}
private:
static porter<T> * instance;
}
```
??? Note: this might not compile. It's been a while since I've dabbled in templates.
... |
53,042,335 | I have found many answers to this similar questions and yet I cannot get this formula to work.
I have a code in Cell B2 which i need to look up on another sheet. The name of this sheet is in Cell A2, and the information I need to copy is in column E of the other sheet. Here is the formula that I am trying to use howev... | 2018/10/29 | [
"https://Stackoverflow.com/questions/53042335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5736199/"
] | The error is clear react-cookie doesn’t have default export so you cannot import it like
```
import Cookie from 'react-cookie';
```
You need to import it like below
```
import { Cookies } from 'react-cookie';
```
Also it's not Cookie but Cookies. You are importing it wrongly
When it is default export then ... | You need to import like `import { withCookies, Cookies } from 'react-cookie';` and then `cookies.get('selected')`, refer the code below
**Read the [package readme](https://github.com/reactivestack/cookies/tree/master/packages/react-cookie/#readme) carefully.**
```
// App.jsx
import React, { Component } from 'react';... |
73,919,146 | I have an array `arr100 = np.ones(100)`. I need to replace these values with decimals,
where `arr100[0]` has a value `1`, `arr100[1] = 1/2`, `arr100[2] = 1/3`,
and so on until `arr100[99] = 1/100`.
How to do this using a `for` loop in Python? | 2022/10/01 | [
"https://Stackoverflow.com/questions/73919146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20137944/"
] | You can do something like this:
```
arr100 = np.ones(100)
for n in range(1, 101):
arr100[n-1] /= n
```
which changes `arr100` to:
```
array([1. , 0.5 , 0.33333333, 0.25 , 0.2 ,
0.16666667, 0.14285714, 0.125 , 0.11111111, 0.1 ,
[....]
``` | You dont actually need an imported module (numpy) to do this. It can be done in a natural python list.
so you can just do this:
```py
result = [1/(i+1) for i in range(100)]
print(result)
```
which returns this:
```
[1.0, 0.5, 0.3333333333333333, 0.25, 0.2, 0.16666666666666666, 0.14285714285714285, 0.125, 0.1111111... |
73,919,146 | I have an array `arr100 = np.ones(100)`. I need to replace these values with decimals,
where `arr100[0]` has a value `1`, `arr100[1] = 1/2`, `arr100[2] = 1/3`,
and so on until `arr100[99] = 1/100`.
How to do this using a `for` loop in Python? | 2022/10/01 | [
"https://Stackoverflow.com/questions/73919146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20137944/"
] | You can do something like this:
```
arr100 = np.ones(100)
for n in range(1, 101):
arr100[n-1] /= n
```
which changes `arr100` to:
```
array([1. , 0.5 , 0.33333333, 0.25 , 0.2 ,
0.16666667, 0.14285714, 0.125 , 0.11111111, 0.1 ,
[....]
``` | ```
for i in range(101):
arr100[i] = 1/arr100[i]
``` |
1,424,613 | I understand that there should be $\sum\_{k=0}^n {n \choose k}$ subsets but I don't understand how that expression simplifies to $(1+1)^n$ or $2^n$
Namely, I don't understand this equation:
$$ \sum\_{k=0}^n {n \choose k} = (1+1)^n = 2^n$$
Please explain in detail, thanks! | 2015/09/06 | [
"https://math.stackexchange.com/questions/1424613",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/222013/"
] | The [binomial theorem](https://en.wikipedia.org/wiki/Binomial_theorem#Statement_of_the_theorem) states that
$$(x+y)^n=\sum\_{k=0}^n {n \choose k}x^{n-k}y^k$$
for a natural number $n$. Using that equation, from right to left,
$$\begin{align}
\sum\_{k=0}^n {n \choose k} &= \sum\_{k=0}^n {n \choose k}1^{n-k}1^k \\[2 ex... | $$ \sum\_{k=0}^n {n \choose k} =\sum\_{k=0}^n {n \choose k}\cdot 1^k\cdot 1^{n-k}= (1+1)^n = 2^n$$ |
1,424,613 | I understand that there should be $\sum\_{k=0}^n {n \choose k}$ subsets but I don't understand how that expression simplifies to $(1+1)^n$ or $2^n$
Namely, I don't understand this equation:
$$ \sum\_{k=0}^n {n \choose k} = (1+1)^n = 2^n$$
Please explain in detail, thanks! | 2015/09/06 | [
"https://math.stackexchange.com/questions/1424613",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/222013/"
] | I like the combinatorial argument:
When building a subset, we are choosing among $n$ elements. Each element may either be in the subset, or not in the subset. Thus there are $2^n$ ways to build a subset. | $$ \sum\_{k=0}^n {n \choose k} =\sum\_{k=0}^n {n \choose k}\cdot 1^k\cdot 1^{n-k}= (1+1)^n = 2^n$$ |
1,424,613 | I understand that there should be $\sum\_{k=0}^n {n \choose k}$ subsets but I don't understand how that expression simplifies to $(1+1)^n$ or $2^n$
Namely, I don't understand this equation:
$$ \sum\_{k=0}^n {n \choose k} = (1+1)^n = 2^n$$
Please explain in detail, thanks! | 2015/09/06 | [
"https://math.stackexchange.com/questions/1424613",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/222013/"
] | The [binomial theorem](https://en.wikipedia.org/wiki/Binomial_theorem#Statement_of_the_theorem) states that
$$(x+y)^n=\sum\_{k=0}^n {n \choose k}x^{n-k}y^k$$
for a natural number $n$. Using that equation, from right to left,
$$\begin{align}
\sum\_{k=0}^n {n \choose k} &= \sum\_{k=0}^n {n \choose k}1^{n-k}1^k \\[2 ex... | I like the combinatorial argument:
When building a subset, we are choosing among $n$ elements. Each element may either be in the subset, or not in the subset. Thus there are $2^n$ ways to build a subset. |
59,652,386 | I'm making a program in quasar framework (who works on vue and can be compiled on mobile by cordova). And i'm having some issues to run it on mobile. here's the function:
```
activateAudio: function(){
try{
speechSynthesis.speak(new SpeechSynthesisUtterance('hey'))
}catch(e){
al... | 2020/01/08 | [
"https://Stackoverflow.com/questions/59652386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12060159/"
] | It looks like you're attempting to use the Web Speech API in a non-browser JS environment. Unless your JS environment implements the Web Speech API, you need to find some alternative API that *is* supported by your JS environment.
Given that you're using Cordova, you should probably try using something like this: [cor... | replace this `SpeechSynthesis.speak(utterance)` with `speechSynthesis.speak(utterance)` then it work |
59,652,386 | I'm making a program in quasar framework (who works on vue and can be compiled on mobile by cordova). And i'm having some issues to run it on mobile. here's the function:
```
activateAudio: function(){
try{
speechSynthesis.speak(new SpeechSynthesisUtterance('hey'))
}catch(e){
al... | 2020/01/08 | [
"https://Stackoverflow.com/questions/59652386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12060159/"
] | **Try this I hope it will fix...**
```
let utterance = new SpeechSynthesisUtterance(`Hey`);
SpeechSynthesis.speak(utterance);
``` | replace this `SpeechSynthesis.speak(utterance)` with `speechSynthesis.speak(utterance)` then it work |
17,083,542 | I'm developing an online chess board where you can play with others humans. At the moment users are notified about new moves by email.
Is there any elegant way to push new moves instantly to the opponents browser?
Please recommend a solution for my environment: Spring, JSF 2, PrimeFaces, Tomcat 6. | 2013/06/13 | [
"https://Stackoverflow.com/questions/17083542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/113252/"
] | Going through [the Developer Guide](https://developers.google.com/maps/documentation/android/) really helps tou get started.
Anyway, what you need here is a [`Polyline`](https://developers.google.com/maps/documentation/android/shapes#polylines). | I hope this may help you:-
Create new Overlay class as RoutePathOverlay:-
```
public class RoutePathOverlay extends Overlay {
private int _pathColor;
private final List<GeoPoint> _points;
private boolean _drawStartEnd;
public RoutePathOverlay(List<GeoPoint> points) {
t... |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | [This code](http://ideone.com/X4vZa) indeed will not compile. You have to add `main()` call also.
```
#include <stdlib.h>
int main()
{
char* ptr = new char;
free( ptr );
return 0;
}
``` | Did you include `<stdlib.h>`? It could be that the compiler doesn't recognize `free` |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | The proper code should be this one:
```
#include <stdlib.h>
int main()
{
char* ptr = new char;
free( ptr );
}
```
The error depends on the fact that free(ptr) at global scope is not seen as a function call, but as a declaration of an object of `class free` :-o .
By the way, consider also that the opposite of... | Because it's c++, so you need to use g++ instead of gcc. |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | [This code](http://ideone.com/X4vZa) indeed will not compile. You have to add `main()` call also.
```
#include <stdlib.h>
int main()
{
char* ptr = new char;
free( ptr );
return 0;
}
``` | You can only call a function without a visible declaration in C. In C++ it is an error that must be diagnosed at compile time, it's not *undefined behavior*.
To call `free` you must include the `stdlib.h` header. |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | Here is your code (from [your link](http://ideone.com/ser2G)):
```
#include <stdlib.h>
char* ptr = new char;
free( ptr );
```
`free()` is a function, and at the namespace scope,you cannot write function-call-statement.
At namespace scope, you can only *declare* and *define* variables, and types. You can call a fu... | You can only call a function without a visible declaration in C. In C++ it is an error that must be diagnosed at compile time, it's not *undefined behavior*.
To call `free` you must include the `stdlib.h` header. |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | You can only call a function without a visible declaration in C. In C++ it is an error that must be diagnosed at compile time, it's not *undefined behavior*.
To call `free` you must include the `stdlib.h` header. | Because it's c++, so you need to use g++ instead of gcc. |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | Here is your code (from [your link](http://ideone.com/ser2G)):
```
#include <stdlib.h>
char* ptr = new char;
free( ptr );
```
`free()` is a function, and at the namespace scope,you cannot write function-call-statement.
At namespace scope, you can only *declare* and *define* variables, and types. You can call a fu... | Because it's c++, so you need to use g++ instead of gcc. |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | Did you include `<stdlib.h>`? It could be that the compiler doesn't recognize `free` | Because it's c++, so you need to use g++ instead of gcc. |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | You can only call a function without a visible declaration in C. In C++ it is an error that must be diagnosed at compile time, it's not *undefined behavior*.
To call `free` you must include the `stdlib.h` header. | Did you include `<stdlib.h>`? It could be that the compiler doesn't recognize `free` |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | [This code](http://ideone.com/X4vZa) indeed will not compile. You have to add `main()` call also.
```
#include <stdlib.h>
int main()
{
char* ptr = new char;
free( ptr );
return 0;
}
``` | The proper code should be this one:
```
#include <stdlib.h>
int main()
{
char* ptr = new char;
free( ptr );
}
```
The error depends on the fact that free(ptr) at global scope is not seen as a function call, but as a declaration of an object of `class free` :-o .
By the way, consider also that the opposite of... |
7,443,997 | I tried the following code on both codepad.org and [ideone.com](http://ideone.com/ser2G):
```
char* ptr = new char;
free( ptr );
```
Yes, I know it's undefined behavior, but I want to compile it and run it to see what happens.
Visual C++ 10 compiles it, but gcc which is used on the abovementioned sites says
>
> e... | 2011/09/16 | [
"https://Stackoverflow.com/questions/7443997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57428/"
] | Here is your code (from [your link](http://ideone.com/ser2G)):
```
#include <stdlib.h>
char* ptr = new char;
free( ptr );
```
`free()` is a function, and at the namespace scope,you cannot write function-call-statement.
At namespace scope, you can only *declare* and *define* variables, and types. You can call a fu... | The proper code should be this one:
```
#include <stdlib.h>
int main()
{
char* ptr = new char;
free( ptr );
}
```
The error depends on the fact that free(ptr) at global scope is not seen as a function call, but as a declaration of an object of `class free` :-o .
By the way, consider also that the opposite of... |
44,333,448 | I'm trying to replace characters in a SQL query string `OR NOT "[low_level_rand_num]"="[rand_num]"` with keys in a dict:
```
replacements = {
'"[low_level_rand_num]"': str(random.randint(1, 13)),
'"[rand_num]"': str(random.randint(13, 26)),
'"[comment]"': random.choice(["--", "/*", "#", "*/", "'", '"', "`"... | 2017/06/02 | [
"https://Stackoverflow.com/questions/44333448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8049647/"
] | I've resolve it do that:
```
$filename = $_FILES["userfile"]["name"];
$source = $_FILES["userfile"]["tmp_name"];
$name = explode(".", $filename);
$target_path = "Apps/" . $username . "/" . $name[0]. "." .$name[1];
if(move_uploaded_file($source, $target_path))
{
$zip = new ZipArchive();
$x = $zip->... | this is your path problem so update your path then it will work perfectly and this is demo code which help you to upload zip file and extract this zip in same file with zip folder also.
```
<?php
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) continu... |
166,698 | So I was messing around on my computer (it has a 250 gigabyte hard drive) and thought,"hmm I wonder what happens if I partition off 75 gigs of this". believe it or not, it partitioned off 75 gigabytes on my hard drive, so what's the problem? well I have no idea how to make it one big single 250 gigabyte partition again... | 2015/01/10 | [
"https://apple.stackexchange.com/questions/166698",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/105585/"
] | Just in case anybody else comes across this question, the steps to solve the system time/date issue mentioned above are as follows.
1. Click on Utilities –> Terminal
2. When the terminal window opens, type date and hit enter. What you will notice is that the date listed will be wrong. That wrong date is what is causin... | This is a problem that [quite](https://discussions.apple.com/thread/3193401?tstart=0) a [few](https://discussions.apple.com/thread/5467959?tstart=0) people have experienced in the past and it seems to come about for a variety of reasons and hence has a variety of solutions, here's a few you should try:
1. FIRST - try ... |
166,698 | So I was messing around on my computer (it has a 250 gigabyte hard drive) and thought,"hmm I wonder what happens if I partition off 75 gigs of this". believe it or not, it partitioned off 75 gigabytes on my hard drive, so what's the problem? well I have no idea how to make it one big single 250 gigabyte partition again... | 2015/01/10 | [
"https://apple.stackexchange.com/questions/166698",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/105585/"
] | This is a problem that [quite](https://discussions.apple.com/thread/3193401?tstart=0) a [few](https://discussions.apple.com/thread/5467959?tstart=0) people have experienced in the past and it seems to come about for a variety of reasons and hence has a variety of solutions, here's a few you should try:
1. FIRST - try ... | If none of the above work, Go to the Disk Utility, Repair the disk permissions and verify the disk. Backup and Erase the disk, If any error occurs during the verification process. |
166,698 | So I was messing around on my computer (it has a 250 gigabyte hard drive) and thought,"hmm I wonder what happens if I partition off 75 gigs of this". believe it or not, it partitioned off 75 gigabytes on my hard drive, so what's the problem? well I have no idea how to make it one big single 250 gigabyte partition again... | 2015/01/10 | [
"https://apple.stackexchange.com/questions/166698",
"https://apple.stackexchange.com",
"https://apple.stackexchange.com/users/105585/"
] | Just in case anybody else comes across this question, the steps to solve the system time/date issue mentioned above are as follows.
1. Click on Utilities –> Terminal
2. When the terminal window opens, type date and hit enter. What you will notice is that the date listed will be wrong. That wrong date is what is causin... | If none of the above work, Go to the Disk Utility, Repair the disk permissions and verify the disk. Backup and Erase the disk, If any error occurs during the verification process. |
44,240 | This year is the 20th anniversary of the [NATO bombing of Yugoslavia/Serbia](https://en.wikipedia.org/wiki/NATO_bombing_of_Yugoslavia). At the moment, Serbian media outlets are focused on claims that depleted uranium in NATO bombs used during the bombardment might be causing an increase in the number of cancer cases in... | 2019/06/24 | [
"https://skeptics.stackexchange.com/questions/44240",
"https://skeptics.stackexchange.com",
"https://skeptics.stackexchange.com/users/50298/"
] | There are several points to consider here.
**1) Depleted Uranium is not *that* much "depleted".**
>
> "Depleted uranium," the byproduct of the enrichment process, has about 0.002 percent 234U, 0.2 percent 235U and 99.8 percent 238U, and **about 60 percent of natural uranium's radioactivity**.
>
>
>
-- [U.S. Offi... | Check out this paper: [Cancer mortality in Serbia, 1991–2015](https://cancercommun.biomedcentral.com/articles/10.1186/s40880-018-0282-3), published in 2018. The study is based on official data on cancer-related deaths. The conclusions drawn by the authors are:
* Overall cancer mortality rate (ASR - age-standartized ra... |
63,402,339 | How does `__contains__` work? For example I have a class `MyClass` and an instance of this class called `a`, when I write `if val in a:` I'm basically invoking `__contains__`, from my understanding, if `__contains__` is not implemented in the class then `__iter__` is invoked, which iterates between the list returned by... | 2020/08/13 | [
"https://Stackoverflow.com/questions/63402339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14095422/"
] | I think the [`__contains__`](https://docs.python.org/3/reference/datamodel.html#object.__contains__) document is clear enough,
```
> Called to implement membership test operators. Should return true if
> item is in self, false otherwise. For mapping objects, this should
> consider the keys of the mapping rather than t... | That's exactly right. More specifics [here](https://docs.python.org/3/reference/expressions.html#membership-test-operations):
>
> For user-defined classes which define the **contains**() method, x in
> y returns True if y.**contains**(x) returns a true value, and False
> otherwise.
>
>
> For user-defined classes wh... |
350,961 | I am using scrbook class and have not configured it much. I don't intend to.
By default, the header for non-chapter pages is the section title, left-aligned on even pages and right-aligned on odd pages. Similarly, the footer is just the page number.
I simply want to add text to the footer (let's say it should now rea... | 2017/01/28 | [
"https://tex.stackexchange.com/questions/350961",
"https://tex.stackexchange.com",
"https://tex.stackexchange.com/users/69067/"
] | You can redefine `\pagemark` to add the additional information:
```
\documentclass{scrbook}
\renewcommand\pagemark{{%
\usekomafont{pagenumber}Draft v1.1 Page \thepage
}}
\usepackage{blindtext}% only for the dummy text in this example
\begin{document}
\Blinddocument
\end{document}
```
[![enter image description h... | ```
\documentclass{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{lipsum}
\pagestyle{scrheadings}
\renewcommand\chapterpagestyle{scrheadings} % ensures that the first page of chapters is formatted the same
\ofoot{Draft v1.1 Page \pagemark}
\begin{document}
\chapter{First Chapter}
\lipsum\lipsum
\chapter{Second Chap... |
49,205,128 | I am new in python and I want to print a range, but when I run the program dosent print anything.
```
dec_value=int(input("ENTER THE DECREMENTED VALUE"))
for i in range(100,0,dec_value):
print(i)
```
Can someone please tell me what I am doing wrong? | 2018/03/10 | [
"https://Stackoverflow.com/questions/49205128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9459576/"
] | `dec_value` (the step of the range) needs to be negative if the start number is larger than the end number, or it will return an empty range. If it returns an empty range, the loop won't run since there's nothing to iterate over.
If start < end, the step should be positive, else, it should be negative. | Do the following to normalize negative or positive inputs:
```
dec_value = int(input("ENTER THE DECREMENTED VALUE: "))
for i in range(10, 0, -abs(dec_value)):
print(i)
>>> ENTER THE DECREMENTED VALUE: -5
10
5
>>> ENTER THE DECREMENTED VALUE: 5
10
5
``` |
24,412,696 | I have some running code and I would like to add a conditional breakpoint, but I only know how to add conditions to existing breakpoints. For example if I add a breakpoint to a line of my C# code, using for example `F9`, I can then right-click on the breakpoint's red dot in the left gutter which gives me this menu
![... | 2014/06/25 | [
"https://Stackoverflow.com/questions/24412696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/575530/"
] | I work on [OzCode, a commercial extension to Visual Studio](http://www.oz-code.com) that has two ways of adding a Conditional Breakpoint in one click -
1. As QuickAction (similar to Alt+Enter in Resharper). This will suggest relevant conditions for your Conditional Breakpoint, based on the type of the variable (ie, `>... | I haven't tested this in a multi-threaded scenario like you have, but what if you "break all" (using the little pause button or `Ctrl` + `Break`) and then set your conditional breakpoint? |
24,412,696 | I have some running code and I would like to add a conditional breakpoint, but I only know how to add conditions to existing breakpoints. For example if I add a breakpoint to a line of my C# code, using for example `F9`, I can then right-click on the breakpoint's red dot in the left gutter which gives me this menu
![... | 2014/06/25 | [
"https://Stackoverflow.com/questions/24412696",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/575530/"
] | >
> *I do not want to stop the code debugging […].*
> *When I first insert the breakpoint, but before I have had a chance to add its condition, it will fire and the program will 'break'.*
>
>
>
You can prevent this by making sure that the debugger isn't attached to the running process at that time:
1. **Detach th... | I haven't tested this in a multi-threaded scenario like you have, but what if you "break all" (using the little pause button or `Ctrl` + `Break`) and then set your conditional breakpoint? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.