qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
42,746,339 | I very much new to Node JS and Express Framework & mongodb. I am working on a website which has multiple categories and when we click on category it goes to a view, where based on the category clicked, data gets loaded in the view.
please check the link for website [here](http://little-step.bitballoon.com/).
I am lo... | 2017/03/12 | [
"https://Stackoverflow.com/questions/42746339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7697614/"
] | It seems to me like you're just missing a bit of glue in between the front-end and the back-end database calls. Here's a rough idea of the sequence you might be after and an explanation of what I think you're missing.
If I'm wrong, please add a comment and update your question to include the new details and I'll see a... | Thank you @Elliot for your time to answer this. Yes I am using handlebars for templating. The solution I found is, because I am using static links, I am passing query string in anchor tag link.
eg. <http://localhost:8000/product?category=Toddler_Material>
and then using `req.query` for capturing the values (Toddler\_... |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | Try this,
```
require File.join(File.dirname(__FILE__),'MarkModule')
``` | ```
require 'MakModule'
``` |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | It is simply impossible that the code you posted here generates that error message. The error message says that you tried to `require` a file named `makRequire`, but that filename doesn't appear anywhere in the code you posted.
Without the actual code that is generating the actual error, it is impossible to answer you... | ```
require 'MakModule'
``` |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | Try `require './MakModule'`, because the `.` is the current directory. | ```
require 'MakModule'
``` |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | Try this,
```
require File.join(File.dirname(__FILE__),'MarkModule')
``` | You can require a file that is in the same directory. To use a module you would typically `include` the module inside a class definition. So you would never require `Display`, you would require the file that contains `Display` (without the .rb extension, usually). |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | It is simply impossible that the code you posted here generates that error message. The error message says that you tried to `require` a file named `makRequire`, but that filename doesn't appear anywhere in the code you posted.
Without the actual code that is generating the actual error, it is impossible to answer you... | Try this,
```
require File.join(File.dirname(__FILE__),'MarkModule')
``` |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | Try this,
```
require File.join(File.dirname(__FILE__),'MarkModule')
``` | Try `require './MakModule'`, because the `.` is the current directory. |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | It is simply impossible that the code you posted here generates that error message. The error message says that you tried to `require` a file named `makRequire`, but that filename doesn't appear anywhere in the code you posted.
Without the actual code that is generating the actual error, it is impossible to answer you... | You can require a file that is in the same directory. To use a module you would typically `include` the module inside a class definition. So you would never require `Display`, you would require the file that contains `Display` (without the .rb extension, usually). |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | Try `require './MakModule'`, because the `.` is the current directory. | You can require a file that is in the same directory. To use a module you would typically `include` the module inside a class definition. So you would never require `Display`, you would require the file that contains `Display` (without the .rb extension, usually). |
4,267,662 | I'm new to Ruby
MakModule.rb
```
module Display
class Multiply
def Multiply.mul(first, second)
return first * second
end
end
end
```
MakRequire1.rb
```
require "Display"
puts Multiply.mul 5,6
```
MakRequire2.rb
```
require "MakModule.rb"
puts Multiply.mul 5,6
```
both file give me the error ... | 2010/11/24 | [
"https://Stackoverflow.com/questions/4267662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/456218/"
] | It is simply impossible that the code you posted here generates that error message. The error message says that you tried to `require` a file named `makRequire`, but that filename doesn't appear anywhere in the code you posted.
Without the actual code that is generating the actual error, it is impossible to answer you... | Try `require './MakModule'`, because the `.` is the current directory. |
63,060,644 | I'm trying to create a 2x2 grid for displaying some info in cards. Disclaimer: I'm totally new to Dart and Flutter, so expect a lot of ignorance on the topic here.
These cards should have a fixed size, have an image, display some text... and be positioned from left to right, from top to bottom.
First, I tried to use ... | 2020/07/23 | [
"https://Stackoverflow.com/questions/63060644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2903610/"
] | The reason the gridview was not working is because you need to set the shrinkWrap property of theGridView to true, to make it take up as little space as possible. (by default, scrollable widgets like gridview and listview take up as much vertical space as possible, which gives you an error if you put that inside a colu... | Is this what you exactly want?
do let me know so that I can update the code for you
```
import 'package:flutter/material.dart';
class List extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
title: Text... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | The plywood of your roof is typically not as thick as your standard galvanized steel roofing nail, so it is expected for nails to show through this in your attic. The plywood can and is expected to take a bit of damage over time and this is okay as long as the shingle has something firm to hold itself down onto.
Over ... | In the lower areas with exposed boards, the roofing contractor should have used shorter nails or staples in that area. Exposed nail points would not be acceptable to me. They should be clipped off flush to prevent possible injury if working under the eves, such as painting etc. The exposed nails are also going to be su... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | It's Florida, you have hurricanes.
The lifting force generated by high winds over a roof can pull 3/4" nails out and peel off large sections of roofing, they used 1 1/4" or longer to ensure penetration through all the shingle layers, underlayment and deep enough into the sheeting to hold up to this abuse.
Unless you... | In the lower areas with exposed boards, the roofing contractor should have used shorter nails or staples in that area. Exposed nail points would not be acceptable to me. They should be clipped off flush to prevent possible injury if working under the eves, such as painting etc. The exposed nails are also going to be su... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | In the lower areas with exposed boards, the roofing contractor should have used shorter nails or staples in that area. Exposed nail points would not be acceptable to me. They should be clipped off flush to prevent possible injury if working under the eves, such as painting etc. The exposed nails are also going to be su... | 3/4" penetration is the law no matter the location on the roof. This is a common thing that CARPENTERS like to say the roofer did it wrong. They should read a code book sometime. The nails need to adequately penetrate for your roof to function properly and to get the full life out of it. If you dont want to see nails t... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | The plywood of your roof is typically not as thick as your standard galvanized steel roofing nail, so it is expected for nails to show through this in your attic. The plywood can and is expected to take a bit of damage over time and this is okay as long as the shingle has something firm to hold itself down onto.
Over ... | It's Florida, you have hurricanes.
The lifting force generated by high winds over a roof can pull 3/4" nails out and peel off large sections of roofing, they used 1 1/4" or longer to ensure penetration through all the shingle layers, underlayment and deep enough into the sheeting to hold up to this abuse.
Unless you... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | The plywood of your roof is typically not as thick as your standard galvanized steel roofing nail, so it is expected for nails to show through this in your attic. The plywood can and is expected to take a bit of damage over time and this is okay as long as the shingle has something firm to hold itself down onto.
Over ... | It is absolutely OK to see nails coming through in the attic. It would be More worrisome to see none. Then you have to be concerned about the nails being too short or possibly having Staples which are an inferior fastener. As to the chipping of trusses or decking/shearing. This is normal especially on older houses. If ... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | The plywood of your roof is typically not as thick as your standard galvanized steel roofing nail, so it is expected for nails to show through this in your attic. The plywood can and is expected to take a bit of damage over time and this is okay as long as the shingle has something firm to hold itself down onto.
Over ... | 3/4" penetration is the law no matter the location on the roof. This is a common thing that CARPENTERS like to say the roofer did it wrong. They should read a code book sometime. The nails need to adequately penetrate for your roof to function properly and to get the full life out of it. If you dont want to see nails t... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | It's Florida, you have hurricanes.
The lifting force generated by high winds over a roof can pull 3/4" nails out and peel off large sections of roofing, they used 1 1/4" or longer to ensure penetration through all the shingle layers, underlayment and deep enough into the sheeting to hold up to this abuse.
Unless you... | It is absolutely OK to see nails coming through in the attic. It would be More worrisome to see none. Then you have to be concerned about the nails being too short or possibly having Staples which are an inferior fastener. As to the chipping of trusses or decking/shearing. This is normal especially on older houses. If ... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | It's Florida, you have hurricanes.
The lifting force generated by high winds over a roof can pull 3/4" nails out and peel off large sections of roofing, they used 1 1/4" or longer to ensure penetration through all the shingle layers, underlayment and deep enough into the sheeting to hold up to this abuse.
Unless you... | 3/4" penetration is the law no matter the location on the roof. This is a common thing that CARPENTERS like to say the roofer did it wrong. They should read a code book sometime. The nails need to adequately penetrate for your roof to function properly and to get the full life out of it. If you dont want to see nails t... |
22,188 | Our home was built in 1954, and is a Florida ranch style home. We have about a two-foot overhanging soffit with trusses that show and with tongue and groove under whatever that’s called. Sorry, I don’t know the proper terms…
I had my roof redone. And nails have come through the plywood and show all over the attic and ... | 2013/01/08 | [
"https://diy.stackexchange.com/questions/22188",
"https://diy.stackexchange.com",
"https://diy.stackexchange.com/users/9976/"
] | It is absolutely OK to see nails coming through in the attic. It would be More worrisome to see none. Then you have to be concerned about the nails being too short or possibly having Staples which are an inferior fastener. As to the chipping of trusses or decking/shearing. This is normal especially on older houses. If ... | 3/4" penetration is the law no matter the location on the roof. This is a common thing that CARPENTERS like to say the roofer did it wrong. They should read a code book sometime. The nails need to adequately penetrate for your roof to function properly and to get the full life out of it. If you dont want to see nails t... |
15,110,149 | I am trying to export the Hive results to a file located on Amazon s3.
But the result file has some unrecognized characters like square etc.
The type of the result file format is binary/octet-stream and not csv.
I am not getting whey it is not able to create a csv file.
The version of hive used is hive-0.8.1.
I am... | 2013/02/27 | [
"https://Stackoverflow.com/questions/15110149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1954657/"
] | For I know, `INSERT OVERWRITE DIRECTORY` will always use ctrl-A('\001') as delimiter. Direct copy of file with your table data would be the best solution. GL. | Did you try opening the Hive warehouse directory in HDFS to your output so as to check how the data is stored there?
I think this line is not required to be executed
```
INSERT OVERWRITE DIRECTORY 's3n://<path_to_s3_bucket>' SELECT * from test_csv;
```
rather you can directly do a **"dfs -get"** |
15,110,149 | I am trying to export the Hive results to a file located on Amazon s3.
But the result file has some unrecognized characters like square etc.
The type of the result file format is binary/octet-stream and not csv.
I am not getting whey it is not able to create a csv file.
The version of hive used is hive-0.8.1.
I am... | 2013/02/27 | [
"https://Stackoverflow.com/questions/15110149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1954657/"
] | You can export data from Hive via the command line:
`hive -e 'select * from foo;' > foo.tsv`
You could probably pipe through sed or something to transform the tabs into commas, we just used TSVs for everything. | Did you try opening the Hive warehouse directory in HDFS to your output so as to check how the data is stored there?
I think this line is not required to be executed
```
INSERT OVERWRITE DIRECTORY 's3n://<path_to_s3_bucket>' SELECT * from test_csv;
```
rather you can directly do a **"dfs -get"** |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | You get on client side the drop down list, and check the index, your code will probably be as:
```
<script>
window.onbeforeunload= function()
{
if(document.getElementById('<%=cbOrderSpareCustomer.ClientID%>').selectedIndex > 0)
{
return "Custom message here";
}
else
... | I think...
```
window.onbeforeunload = function(e) {
if (document.getElementById('cbOrderSpareCustomer').selectedIndex > 0) {
if (!confirm('Are you sure')) {
return false;
}
}
}
``` |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | You get on client side the drop down list, and check the index, your code will probably be as:
```
<script>
window.onbeforeunload= function()
{
if(document.getElementById('<%=cbOrderSpareCustomer.ClientID%>').selectedIndex > 0)
{
return "Custom message here";
}
else
... | If you're using JQuery
```
<script type="text/javascript">
$(window).bind('beforeunload', function () {
if ($("select[name='cbOrderSpareCustomer'] option:selected").index() > 0) {
return 'Your data will be lost.';
}
});
</script>
```
You don't want else return true or it will stil... |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | You get on client side the drop down list, and check the index, your code will probably be as:
```
<script>
window.onbeforeunload= function()
{
if(document.getElementById('<%=cbOrderSpareCustomer.ClientID%>').selectedIndex > 0)
{
return "Custom message here";
}
else
... | My solution:
```
<script type="text/javascript"
function setDirty() {
window.onbeforeunload = function () {
return 'The data will be lost if you leave this page!'
}
}
</script>
```
With the attribute onCange="setDirty()" added to the dropdownlist.
Thanks all for helpi... |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | Follow the below steps to make this work
1. Add `onchange` attribute to the combobox on serve side using the code:
`<select id="cbOrderSpareCustomer" onchange="setDirty()">`
2. Define your javascript as below
`var isDirty = true;
function setDirty() {
isDirty = true;
}
window.onbeforeunload = function () {
if ... | I think...
```
window.onbeforeunload = function(e) {
if (document.getElementById('cbOrderSpareCustomer').selectedIndex > 0) {
if (!confirm('Are you sure')) {
return false;
}
}
}
``` |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | I think...
```
window.onbeforeunload = function(e) {
if (document.getElementById('cbOrderSpareCustomer').selectedIndex > 0) {
if (!confirm('Are you sure')) {
return false;
}
}
}
``` | If you're using JQuery
```
<script type="text/javascript">
$(window).bind('beforeunload', function () {
if ($("select[name='cbOrderSpareCustomer'] option:selected").index() > 0) {
return 'Your data will be lost.';
}
});
</script>
```
You don't want else return true or it will stil... |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | I think...
```
window.onbeforeunload = function(e) {
if (document.getElementById('cbOrderSpareCustomer').selectedIndex > 0) {
if (!confirm('Are you sure')) {
return false;
}
}
}
``` | My solution:
```
<script type="text/javascript"
function setDirty() {
window.onbeforeunload = function () {
return 'The data will be lost if you leave this page!'
}
}
</script>
```
With the attribute onCange="setDirty()" added to the dropdownlist.
Thanks all for helpi... |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | Follow the below steps to make this work
1. Add `onchange` attribute to the combobox on serve side using the code:
`<select id="cbOrderSpareCustomer" onchange="setDirty()">`
2. Define your javascript as below
`var isDirty = true;
function setDirty() {
isDirty = true;
}
window.onbeforeunload = function () {
if ... | If you're using JQuery
```
<script type="text/javascript">
$(window).bind('beforeunload', function () {
if ($("select[name='cbOrderSpareCustomer'] option:selected").index() > 0) {
return 'Your data will be lost.';
}
});
</script>
```
You don't want else return true or it will stil... |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | Follow the below steps to make this work
1. Add `onchange` attribute to the combobox on serve side using the code:
`<select id="cbOrderSpareCustomer" onchange="setDirty()">`
2. Define your javascript as below
`var isDirty = true;
function setDirty() {
isDirty = true;
}
window.onbeforeunload = function () {
if ... | My solution:
```
<script type="text/javascript"
function setDirty() {
window.onbeforeunload = function () {
return 'The data will be lost if you leave this page!'
}
}
</script>
```
With the attribute onCange="setDirty()" added to the dropdownlist.
Thanks all for helpi... |
23,958,772 | On my page I have a combobox called cbOrderSpareCustomer.
By default the selected index is set to 0.
when the user changes it, I consider the page containing data and when the user decides to leave the page I want to prompt him to let him know data will be lost.
I have seen many posts about this but I'm very new to j... | 2014/05/30 | [
"https://Stackoverflow.com/questions/23958772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1743873/"
] | If you're using JQuery
```
<script type="text/javascript">
$(window).bind('beforeunload', function () {
if ($("select[name='cbOrderSpareCustomer'] option:selected").index() > 0) {
return 'Your data will be lost.';
}
});
</script>
```
You don't want else return true or it will stil... | My solution:
```
<script type="text/javascript"
function setDirty() {
window.onbeforeunload = function () {
return 'The data will be lost if you leave this page!'
}
}
</script>
```
With the attribute onCange="setDirty()" added to the dropdownlist.
Thanks all for helpi... |
738,823 | Is there a place to find a list of the possible values for the PHP predefined constant `PHP_OS` ? I'd like to use this value for a system requirements check, but need to know how different operating systems are named in this variable.
Through some searching, so far I've compiled the following list:
* CYGWIN\_NT-5.1
*... | 2009/04/10 | [
"https://Stackoverflow.com/questions/738823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | PHP [passes through the uname](https://github.com/php/php-src/blob/0d51ebd1a54af59d915c551a240b56bb3f0e26a6/configure.in#L1300), [except on Windows (`WINNT`)](https://github.com/php/php-src/blob/0d51ebd1a54af59d915c551a240b56bb3f0e26a6/main/main.c#L2022) and [Netware (`Netware`)](https://github.com/php/php-src/blob/0d5... | I think a better solution to do a 'requirement check' would be to actually use things that you need to know work properly and see what happens.
For example, there are constants for directory separators, functions like realpath(), etc to deal with directories on different operating systems.
What, specifically, are you... |
738,823 | Is there a place to find a list of the possible values for the PHP predefined constant `PHP_OS` ? I'd like to use this value for a system requirements check, but need to know how different operating systems are named in this variable.
Through some searching, so far I've compiled the following list:
* CYGWIN\_NT-5.1
*... | 2009/04/10 | [
"https://Stackoverflow.com/questions/738823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | PHP [passes through the uname](https://github.com/php/php-src/blob/0d51ebd1a54af59d915c551a240b56bb3f0e26a6/configure.in#L1300), [except on Windows (`WINNT`)](https://github.com/php/php-src/blob/0d51ebd1a54af59d915c551a240b56bb3f0e26a6/main/main.c#L2022) and [Netware (`Netware`)](https://github.com/php/php-src/blob/0d5... | it seems like the `php_uname("s")` for non-Unix OSes would be a good start, since it looks to me like `uname("s")` and `php_uname("s")` are the same on Unix systems and posix sub systems, such as Cygwin, Mingw, UWin, EMX+GCC, and MKS. Below is a list of OSes that are not Posix-compliant out of the box and that run PHP.... |
738,823 | Is there a place to find a list of the possible values for the PHP predefined constant `PHP_OS` ? I'd like to use this value for a system requirements check, but need to know how different operating systems are named in this variable.
Through some searching, so far I've compiled the following list:
* CYGWIN\_NT-5.1
*... | 2009/04/10 | [
"https://Stackoverflow.com/questions/738823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5291/"
] | I think a better solution to do a 'requirement check' would be to actually use things that you need to know work properly and see what happens.
For example, there are constants for directory separators, functions like realpath(), etc to deal with directories on different operating systems.
What, specifically, are you... | it seems like the `php_uname("s")` for non-Unix OSes would be a good start, since it looks to me like `uname("s")` and `php_uname("s")` are the same on Unix systems and posix sub systems, such as Cygwin, Mingw, UWin, EMX+GCC, and MKS. Below is a list of OSes that are not Posix-compliant out of the box and that run PHP.... |
21,301,856 | I am following wpf mvvm . Here i want to display the primary key value + 1. ie, when the code executing , if the table is empty,then display the value of primary key as 1. If the table have 1 row,then display 2 and so on. so work this type., How to take the highest value of primary key in a table in wpf mvvm.
Can i us... | 2014/01/23 | [
"https://Stackoverflow.com/questions/21301856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3192678/"
] | In TCP, there's no way to tell that a connection has failed unless you try to send something on the connection. TCP doesn't perform active monitoring of the connection (actually, there are optional "keepalive" packets, but these are not normally sent until the connection has been idle for a couple of hours). When you s... | When the network is broken what happens is that you clients keep sending data and at some point the socket send buffer gets full (I understand from what you show that you are sending 1024 Bytes, 1024 times, 1MB in total). The default for send buffer could be 16KB (surely less than 1MB). Then when the client tries to wr... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I tried all of the connection types (charge, MTP, PTP) but perhaps not "Internet Connnection, modem"? You can change it by pulling down the system-wide drop down menu and touching "USB connection".
This is how I fixed it, but I thought I'd tried this already, so I can't guarantee it wasn't this in conjunction with on... | PTP seemed to do the trick. Never had to do that on any other device... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I tried all of the connection types (charge, MTP, PTP) but perhaps not "Internet Connnection, modem"? You can change it by pulling down the system-wide drop down menu and touching "USB connection".
This is how I fixed it, but I thought I'd tried this already, so I can't guarantee it wasn't this in conjunction with on... | I had the exact same problem. Selectin Internet Connection and then Ethernet as the USB connection type fixed it and everything is working as expected now. |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I tried all of the connection types (charge, MTP, PTP) but perhaps not "Internet Connnection, modem"? You can change it by pulling down the system-wide drop down menu and touching "USB connection".
This is how I fixed it, but I thought I'd tried this already, so I can't guarantee it wasn't this in conjunction with on... | I know this sounds like a stupid answer, but the same thing happened to me. It turns out the micro USB cord was just bad - which is weird, because it still charged the phone perfectly fine. After testing the bad cable unsuccessfully on a phone that had been recognized on my mac before, I switched to a different micro U... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I tried all of the connection types (charge, MTP, PTP) but perhaps not "Internet Connnection, modem"? You can change it by pulling down the system-wide drop down menu and touching "USB connection".
This is how I fixed it, but I thought I'd tried this already, so I can't guarantee it wasn't this in conjunction with on... | This is late in the game but I had an additional step to all the other suggestions. The phone was showing up in the System Profiler after I switched the usb mode to 'MTP' mode, but I didn't see any usb tethering options. After adding the phone's vendor ID to the usb ini file, enabling the developer and usb debugging, k... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | PTP seemed to do the trick. Never had to do that on any other device... | I had the exact same problem. Selectin Internet Connection and then Ethernet as the USB connection type fixed it and everything is working as expected now. |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | PTP seemed to do the trick. Never had to do that on any other device... | I know this sounds like a stupid answer, but the same thing happened to me. It turns out the micro USB cord was just bad - which is weird, because it still charged the phone perfectly fine. After testing the bad cable unsuccessfully on a phone that had been recognized on my mac before, I switched to a different micro U... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | PTP seemed to do the trick. Never had to do that on any other device... | This is late in the game but I had an additional step to all the other suggestions. The phone was showing up in the System Profiler after I switched the usb mode to 'MTP' mode, but I didn't see any usb tethering options. After adding the phone's vendor ID to the usb ini file, enabling the developer and usb debugging, k... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I had the exact same problem. Selectin Internet Connection and then Ethernet as the USB connection type fixed it and everything is working as expected now. | I know this sounds like a stupid answer, but the same thing happened to me. It turns out the micro USB cord was just bad - which is weird, because it still charged the phone perfectly fine. After testing the bad cable unsuccessfully on a phone that had been recognized on my mac before, I switched to a different micro U... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I had the exact same problem. Selectin Internet Connection and then Ethernet as the USB connection type fixed it and everything is working as expected now. | This is late in the game but I had an additional step to all the other suggestions. The phone was showing up in the System Profiler after I switched the usb mode to 'MTP' mode, but I didn't see any usb tethering options. After adding the phone's vendor ID to the usb ini file, enabling the developer and usb debugging, k... |
24,434,850 | When I run `adb devices` there are no devices showing as connected. My device is a LG Optimus Exceed 2 running 4.4.2
There are many of these posts around, so here's what I've done:
* I'm using the cord that came with the phone. It charges and tries to sync photos, so it isn't an issue here. Switching usb ports and try... | 2014/06/26 | [
"https://Stackoverflow.com/questions/24434850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2669009/"
] | I know this sounds like a stupid answer, but the same thing happened to me. It turns out the micro USB cord was just bad - which is weird, because it still charged the phone perfectly fine. After testing the bad cable unsuccessfully on a phone that had been recognized on my mac before, I switched to a different micro U... | This is late in the game but I had an additional step to all the other suggestions. The phone was showing up in the System Profiler after I switched the usb mode to 'MTP' mode, but I didn't see any usb tethering options. After adding the phone's vendor ID to the usb ini file, enabling the developer and usb debugging, k... |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | * newlines are browser dependent?
+ No. Use `<br>` to get a newline in a browser
* newlines are system dependent? (where php runs)
+ yes : `\n` on OSX, `\n` on Unix/Linux, `\r\n` on Windows
* will php apply some implicit conversion?
+ no
* will mysql apply some implicit conversion?
+ no | You may be interested in [nl2br](http://php.net/manual/en/function.nl2br.php "nl2br"), this takes new line characters like you described and replaces them with a HTML line break (`<br />`). |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | The system independent way is using PHP\_EOL constant.
New lines is not browser dependent, outer a tag with CSS [white-space:pre](http://www.w3schools.com/cssref/pr_text_white-space.asp) you must to execute [nl2br()](http://php.net/manual/en/function.nl2br.php) php function to convert newlines to BR tags. | You may be interested in [nl2br](http://php.net/manual/en/function.nl2br.php "nl2br"), this takes new line characters like you described and replaces them with a HTML line break (`<br />`). |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | The system independent way is using PHP\_EOL constant.
New lines is not browser dependent, outer a tag with CSS [white-space:pre](http://www.w3schools.com/cssref/pr_text_white-space.asp) you must to execute [nl2br()](http://php.net/manual/en/function.nl2br.php) php function to convert newlines to BR tags. | `<br>` is browser independent, `\n` should be too.
Don't know about `\r`
MySQL won't convert it |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | Generally, for browser `\r` and `\n` are whitespace chars, like `' '` (whitespace) of `\t` (tab). Inside some tags (script, pre etc.) they are treated as line break symbols. In this case browser will understand any of common line break sequences (`\r`, `\r\n`, `\n`).
When data comes from textarea, line breaks will [al... | You may be interested in [nl2br](http://php.net/manual/en/function.nl2br.php "nl2br"), this takes new line characters like you described and replaces them with a HTML line break (`<br />`). |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | The system independent way is using PHP\_EOL constant.
New lines is not browser dependent, outer a tag with CSS [white-space:pre](http://www.w3schools.com/cssref/pr_text_white-space.asp) you must to execute [nl2br()](http://php.net/manual/en/function.nl2br.php) php function to convert newlines to BR tags. | A big gotcha for me was that in single quoted strings `'like\nthis'` escape sequences (like `\n`) will not be interpreted. You have to use double quotes `"like\nthis"` to get an actual newline. |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | Generally, for browser `\r` and `\n` are whitespace chars, like `' '` (whitespace) of `\t` (tab). Inside some tags (script, pre etc.) they are treated as line break symbols. In this case browser will understand any of common line break sequences (`\r`, `\r\n`, `\n`).
When data comes from textarea, line breaks will [al... | The system independent way is using PHP\_EOL constant.
New lines is not browser dependent, outer a tag with CSS [white-space:pre](http://www.w3schools.com/cssref/pr_text_white-space.asp) you must to execute [nl2br()](http://php.net/manual/en/function.nl2br.php) php function to convert newlines to BR tags. |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | Generally, for browser `\r` and `\n` are whitespace chars, like `' '` (whitespace) of `\t` (tab). Inside some tags (script, pre etc.) they are treated as line break symbols. In this case browser will understand any of common line break sequences (`\r`, `\r\n`, `\n`).
When data comes from textarea, line breaks will [al... | `<br>` is browser independent, `\n` should be too.
Don't know about `\r`
MySQL won't convert it |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | Generally, for browser `\r` and `\n` are whitespace chars, like `' '` (whitespace) of `\t` (tab). Inside some tags (script, pre etc.) they are treated as line break symbols. In this case browser will understand any of common line break sequences (`\r`, `\r\n`, `\n`).
When data comes from textarea, line breaks will [al... | A big gotcha for me was that in single quoted strings `'like\nthis'` escape sequences (like `\n`) will not be interpreted. You have to use double quotes `"like\nthis"` to get an actual newline. |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | * newlines are browser dependent?
+ No. Use `<br>` to get a newline in a browser
* newlines are system dependent? (where php runs)
+ yes : `\n` on OSX, `\n` on Unix/Linux, `\r\n` on Windows
* will php apply some implicit conversion?
+ no
* will mysql apply some implicit conversion?
+ no | Generally, for browser `\r` and `\n` are whitespace chars, like `' '` (whitespace) of `\t` (tab). Inside some tags (script, pre etc.) they are treated as line break symbols. In this case browser will understand any of common line break sequences (`\r`, `\r\n`, `\n`).
When data comes from textarea, line breaks will [al... |
10,451,211 | I have some questions about `\r\n`:
* newlines are browser dependent? (not how they are displayed in a browser, but how `<textarea>` sends them to php via http request)
* newlines are system dependent? (where php runs)
* will php apply some implicit conversion?
* will mysql apply some implicit conversion?
Thanks in a... | 2012/05/04 | [
"https://Stackoverflow.com/questions/10451211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1252794/"
] | * newlines are browser dependent?
+ No. Use `<br>` to get a newline in a browser
* newlines are system dependent? (where php runs)
+ yes : `\n` on OSX, `\n` on Unix/Linux, `\r\n` on Windows
* will php apply some implicit conversion?
+ no
* will mysql apply some implicit conversion?
+ no | A big gotcha for me was that in single quoted strings `'like\nthis'` escape sequences (like `\n`) will not be interpreted. You have to use double quotes `"like\nthis"` to get an actual newline. |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | From the docs:
<http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming>
>
> Streaming Multiple Messages
>
>
> If you want to write multiple messages to a single file or stream, it
> is up to you to keep track of where one message ends and the next
> begins. The Protocol Buffer wire format is ... | Protobuf does not include a terminator per outermost record, so you need to do that yourself. The simplest approach is to prefix the data with the length of the record that follows. Personally, I tend to use the approach of writing a string-header (for an arbitrary field number), then the length as a "varint" - this me... |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | Protobuf does not include a terminator per outermost record, so you need to do that yourself. The simplest approach is to prefix the data with the length of the record that follows. Personally, I tend to use the approach of writing a string-header (for an arbitrary field number), then the length as a "varint" - this me... | An easier way is to base64 encode each message and store it as a record per line. |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | I would recommend using the `writeDelimitedTo(OutputStream)` and `parseDelimitedFrom(InputStream)` methods on `Message` objects. `writeDelimitedTo` writes the length of the message before the message itself; `parseDelimitedFrom` then uses that length to read only one message and no farther. This allows multiple message... | Protobuf does not include a terminator per outermost record, so you need to do that yourself. The simplest approach is to prefix the data with the length of the record that follows. Personally, I tend to use the approach of writing a string-header (for an arbitrary field number), then the length as a "varint" - this me... |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | From the docs:
<http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming>
>
> Streaming Multiple Messages
>
>
> If you want to write multiple messages to a single file or stream, it
> is up to you to keep track of where one message ends and the next
> begins. The Protocol Buffer wire format is ... | An easier way is to base64 encode each message and store it as a record per line. |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | I would recommend using the `writeDelimitedTo(OutputStream)` and `parseDelimitedFrom(InputStream)` methods on `Message` objects. `writeDelimitedTo` writes the length of the message before the message itself; `parseDelimitedFrom` then uses that length to read only one message and no farther. This allows multiple message... | From the docs:
<http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming>
>
> Streaming Multiple Messages
>
>
> If you want to write multiple messages to a single file or stream, it
> is up to you to keep track of where one message ends and the next
> begins. The Protocol Buffer wire format is ... |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | From the docs:
<http://code.google.com/apis/protocolbuffers/docs/techniques.html#streaming>
>
> Streaming Multiple Messages
>
>
> If you want to write multiple messages to a single file or stream, it
> is up to you to keep track of where one message ends and the next
> begins. The Protocol Buffer wire format is ... | If you're looking for a C++ solution, Kenton Varda [submitted a patch to protobuf around August 2015](https://stackoverflow.com/questions/2340730/are-there-c-equivalents-for-the-protocol-buffers-delimited-i-o-functions-in-ja/22927149#22927149) that adds support for writeDelimitedTo() and readDelimitedFrom() calls that ... |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | I would recommend using the `writeDelimitedTo(OutputStream)` and `parseDelimitedFrom(InputStream)` methods on `Message` objects. `writeDelimitedTo` writes the length of the message before the message itself; `parseDelimitedFrom` then uses that length to read only one message and no farther. This allows multiple message... | An easier way is to base64 encode each message and store it as a record per line. |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | If you're looking for a C++ solution, Kenton Varda [submitted a patch to protobuf around August 2015](https://stackoverflow.com/questions/2340730/are-there-c-equivalents-for-the-protocol-buffers-delimited-i-o-functions-in-ja/22927149#22927149) that adds support for writeDelimitedTo() and readDelimitedFrom() calls that ... | An easier way is to base64 encode each message and store it as a record per line. |
9,148,878 | I'm using google protocol buffer to serialize equity market data (ie. timestamp, bid,ask fields).
I can store one message into a file and deserialize it without issue.
How can I store multiple messages into a single file? Not sure how I can separate the messages. I need to be able to append new messages to the file on... | 2012/02/05 | [
"https://Stackoverflow.com/questions/9148878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/249571/"
] | I would recommend using the `writeDelimitedTo(OutputStream)` and `parseDelimitedFrom(InputStream)` methods on `Message` objects. `writeDelimitedTo` writes the length of the message before the message itself; `parseDelimitedFrom` then uses that length to read only one message and no farther. This allows multiple message... | If you're looking for a C++ solution, Kenton Varda [submitted a patch to protobuf around August 2015](https://stackoverflow.com/questions/2340730/are-there-c-equivalents-for-the-protocol-buffers-delimited-i-o-functions-in-ja/22927149#22927149) that adds support for writeDelimitedTo() and readDelimitedFrom() calls that ... |
116,399 | A year ago or so, I received a few expired films, among which this roll of Kodak Tri-X 400, expired in 2013. The film was shipped from the US to Europe. I stored the film in my freezer until I shot it last week, but it does not appear like it was stored cooled back in the US. As per the rule of thumb, I exposed for the... | 2020/04/04 | [
"https://photo.stackexchange.com/questions/116399",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/83099/"
] | Using the Godox TT350N as a means to control your other Godox speedlight is a perfectly viable option. If you later decide to buy a dedicated trigger, you can control both of them.
The only drawback is that the controls on the flashes themselves are not as straight forward as they are on the Godox X2 or Xpro. Plus you... | It's a perfectly viable plan to use a TT350-N (or li-on V350-N) as your iTTL transmitter, but it's not just smaller and less powerful than a V860II-N, it also lacks CLS/AWL capability, it only swivels 270º not 360º, it has no sync port, no external battery port, no recycle beep, and it is not designed to do cross-brand... |
116,399 | A year ago or so, I received a few expired films, among which this roll of Kodak Tri-X 400, expired in 2013. The film was shipped from the US to Europe. I stored the film in my freezer until I shot it last week, but it does not appear like it was stored cooled back in the US. As per the rule of thumb, I exposed for the... | 2020/04/04 | [
"https://photo.stackexchange.com/questions/116399",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/83099/"
] | Using the Godox TT350N as a means to control your other Godox speedlight is a perfectly viable option. If you later decide to buy a dedicated trigger, you can control both of them.
The only drawback is that the controls on the flashes themselves are not as straight forward as they are on the Godox X2 or Xpro. Plus you... | An alternative to using a trigger-slave arrangement, that might be cheaper, is to use a hotshoe extension cord. I have a wireless setup (though not for portraiture), but still often find that using the cord to get the flash off-camera is effective and easier than setting up master and slave wireless flashguns.
In shor... |
116,399 | A year ago or so, I received a few expired films, among which this roll of Kodak Tri-X 400, expired in 2013. The film was shipped from the US to Europe. I stored the film in my freezer until I shot it last week, but it does not appear like it was stored cooled back in the US. As per the rule of thumb, I exposed for the... | 2020/04/04 | [
"https://photo.stackexchange.com/questions/116399",
"https://photo.stackexchange.com",
"https://photo.stackexchange.com/users/83099/"
] | It's a perfectly viable plan to use a TT350-N (or li-on V350-N) as your iTTL transmitter, but it's not just smaller and less powerful than a V860II-N, it also lacks CLS/AWL capability, it only swivels 270º not 360º, it has no sync port, no external battery port, no recycle beep, and it is not designed to do cross-brand... | An alternative to using a trigger-slave arrangement, that might be cheaper, is to use a hotshoe extension cord. I have a wireless setup (though not for portraiture), but still often find that using the cord to get the flash off-camera is effective and easier than setting up master and slave wireless flashguns.
In shor... |
43,699,207 | I'm trying to write an `Eq` instance for an `EitherT` newtype given by:
```
newtype EitherT e m a = EitherT { runEitherT :: m (Either e a) }
```
I assumed the following `Eq` instance would work:
```
instance (Eq e, Eq a, Eq m) => Eq (EitherT e m a) where
a == b = (runEitherT a) == (runEitherT b)
```
However, I'... | 2017/04/29 | [
"https://Stackoverflow.com/questions/43699207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/173292/"
] | You're looking for `Eq1` which is in [`Data.Functor.Classes`](https://hackage.haskell.org/package/base-4.9.1.0/docs/Data-Functor-Classes.html) since base 4.9.0.0. Before that it was in one of the `-extras` packages or `transformers`? (it's [in transformers now since 0.4.0.0](https://hackage.haskell.org/package/transfor... | It might be worth noting that this instance already exists in current versions of the `either` package (though not the old `EitherT` package, which is considered obsolete):
```
instance Eq (m (Either e a)) => Eq (EitherT e m a) where
(==) = (==) on runEitherT
```
Of course, as @Alexis King has noted, it requires `... |
36,649,620 | I have a fixed tab layout with 3 tabs. I am trying to have a button in tab1 to add items into a listview in tab2 using `ArrayList`, both of them extends `Fragment`. The below code works only when the the activity extends Activity. Can anyone help me out with an answer to the fix of the problem.
I did some testing with... | 2016/04/15 | [
"https://Stackoverflow.com/questions/36649620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4900187/"
] | json\_encode from php can be accessed easily in a Javascript varible
There are many ways of doing this, however consider the simple way first if it works with the array you are sending.
in your example - assuming jquery:
```
var valu = [];
$.ajax(url: "url.php",
success: function(data){
... | I think you want change your code to something like this..
```
$.each(data.result, function(index,value){
$("ul").append("<li>Name:"+value.name+"</li>");
alert("kj");
});
``` |
36,649,620 | I have a fixed tab layout with 3 tabs. I am trying to have a button in tab1 to add items into a listview in tab2 using `ArrayList`, both of them extends `Fragment`. The below code works only when the the activity extends Activity. Can anyone help me out with an answer to the fix of the problem.
I did some testing with... | 2016/04/15 | [
"https://Stackoverflow.com/questions/36649620",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4900187/"
] | json\_encode from php can be accessed easily in a Javascript varible
There are many ways of doing this, however consider the simple way first if it works with the array you are sending.
in your example - assuming jquery:
```
var valu = [];
$.ajax(url: "url.php",
success: function(data){
... | Heres what I would do.
```
$.ajax({
url: "url.php",
type: "GET",
dataType: 'json'
}).done(function (data) {
$.each(codes, function(key,value){
$("ul").append('<option value="' + key + '">' + key + ' - ' + value + '</option>');
});
}).fail(function (jqXHR, textStatus, error) {
aler... |
14,735,666 | I am using CodeIgniter and trying to create thumbs of images. I was successful for some but failed for in some cases. I am getting this following error -
```
<< A PHP Error was encountered
Severity: Notice
Message: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file
Filename: libra... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14735666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972328/"
] | The problem is that [error suppression](http://php.net/manual/en/language.operators.errorcontrol.php) is not turned on for the function `imagecreatefromjpeg`
The best option is to extend the base library and overload the `image_create_gd` method
Create a new file `./application/libraries/MY_Image_lib.php`
```
<?php ... | I was having the exactly the same issue. I was first storing the image data on a local HDD before using the function **imagecreatefromjpeg()** to post-process the image further.
At certain times the locally stored image was corrupted during the store process and when called by **imagecreatefromjpeg($imagePath);** the... |
14,735,666 | I am using CodeIgniter and trying to create thumbs of images. I was successful for some but failed for in some cases. I am getting this following error -
```
<< A PHP Error was encountered
Severity: Notice
Message: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file
Filename: libra... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14735666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972328/"
] | The problem is that [error suppression](http://php.net/manual/en/language.operators.errorcontrol.php) is not turned on for the function `imagecreatefromjpeg`
The best option is to extend the base library and overload the `image_create_gd` method
Create a new file `./application/libraries/MY_Image_lib.php`
```
<?php ... | Try Adding @imagecreatefromjpeg($img) instead of imagecreatefromjpeg($img)
here @ is error suppressor |
14,735,666 | I am using CodeIgniter and trying to create thumbs of images. I was successful for some but failed for in some cases. I am getting this following error -
```
<< A PHP Error was encountered
Severity: Notice
Message: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file
Filename: libra... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14735666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972328/"
] | The problem is that [error suppression](http://php.net/manual/en/language.operators.errorcontrol.php) is not turned on for the function `imagecreatefromjpeg`
The best option is to extend the base library and overload the `image_create_gd` method
Create a new file `./application/libraries/MY_Image_lib.php`
```
<?php ... | I checked that my JPG file was corrupted when I got this error. Consider checking yours. |
14,735,666 | I am using CodeIgniter and trying to create thumbs of images. I was successful for some but failed for in some cases. I am getting this following error -
```
<< A PHP Error was encountered
Severity: Notice
Message: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file
Filename: libra... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14735666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972328/"
] | I was having the exactly the same issue. I was first storing the image data on a local HDD before using the function **imagecreatefromjpeg()** to post-process the image further.
At certain times the locally stored image was corrupted during the store process and when called by **imagecreatefromjpeg($imagePath);** the... | I checked that my JPG file was corrupted when I got this error. Consider checking yours. |
14,735,666 | I am using CodeIgniter and trying to create thumbs of images. I was successful for some but failed for in some cases. I am getting this following error -
```
<< A PHP Error was encountered
Severity: Notice
Message: imagecreatefromjpeg(): gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file
Filename: libra... | 2013/02/06 | [
"https://Stackoverflow.com/questions/14735666",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/972328/"
] | Try Adding @imagecreatefromjpeg($img) instead of imagecreatefromjpeg($img)
here @ is error suppressor | I checked that my JPG file was corrupted when I got this error. Consider checking yours. |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | If you really need an implementation that works, you could "cheat" your way arround by testing the second parameter against `undefined`, this also means you could use get to actually set parameter.
```
var foo = {
args: {},
__noSuchMethod__ : function(id, args) {
if(args === undefined) {
r... | This is not exactly an answer to the original question, however [this](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) and [this](https://stackoverflow.com/questions/1441005/pythons-getattr-in-javascript) questions are closed and redirect here, so here I am. I hop... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | `Proxy` can do it! I'm so happy this exists!! An answer is given here: [Is there a javascript equivalent of python's \_\_getattr\_\_ method?](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) . To rephrase in my own words:
```js
var x = new Proxy({}, {
get(targe... | If you're looking for something like PHP's [`__get()`](http://us3.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members) function, I don't think Javascript provides any such construct.
The best I can think of doing is looping through the object's non-function members and then creating a cor... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | If you're looking for something like PHP's [`__get()`](http://us3.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members) function, I don't think Javascript provides any such construct.
The best I can think of doing is looping through the object's non-function members and then creating a cor... | This is not exactly an answer to the original question, however [this](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) and [this](https://stackoverflow.com/questions/1441005/pythons-getattr-in-javascript) questions are closed and redirect here, so here I am. I hop... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | [Javascript 1.5](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference) does have [getter/setter](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/get_Operator) [syntactic sugar](http://en.wikipedia.org/wiki/Syntactic_sugar). It's explained very well by John Resig [her... | It is possible to get a similar result simply by wrapping the object in a getter function:
```js
const getProp = (key) => {
const dictionary = {
firstName: 'John',
lastName: 'Doe',
age: 42,
DEFAULT: 'there is no prop like this'
}
return (typeof dictionary[key] === 'undefined' ? dictionary.DEFAULT... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | You can combine proxy and class to have a **nice looking code like php**:
```
class Magic {
constructor () {
return new Proxy(this, this);
}
get (target, prop) {
return this[prop] || 'MAGIC';
}
}
```
this binds to the handler, so you can use this instead of target.
**Note: unlike PHP... | This is not exactly an answer to the original question, however [this](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) and [this](https://stackoverflow.com/questions/1441005/pythons-getattr-in-javascript) questions are closed and redirect here, so here I am. I hop... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | `Proxy` can do it! I'm so happy this exists!! An answer is given here: [Is there a javascript equivalent of python's \_\_getattr\_\_ method?](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) . To rephrase in my own words:
```js
var x = new Proxy({}, {
get(targe... | I ended up using a nickfs' answer to construct my own solution. My solution will automatically create get\_{propname} and set\_{propname} functions for all properties. It does check if the function already exists before adding them. This allows you to override the default get or set method with our own implementation w... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | `Proxy` can do it! I'm so happy this exists!! An answer is given here: [Is there a javascript equivalent of python's \_\_getattr\_\_ method?](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) . To rephrase in my own words:
```js
var x = new Proxy({}, {
get(targe... | The closest you can find is [\_\_noSuchMethod\_\_](https://web.archive.org/web/20210224190946/https://developer.mozilla.org/en-US/docs/Archive/Web/JavaScript/Object.noSuchMethod) ([\_\_noSuchMethod\_\_ is deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#obje... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | `Proxy` can do it! I'm so happy this exists!! An answer is given here: [Is there a javascript equivalent of python's \_\_getattr\_\_ method?](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) . To rephrase in my own words:
```js
var x = new Proxy({}, {
get(targe... | [Javascript 1.5](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference) does have [getter/setter](https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Operators/Special_Operators/get_Operator) [syntactic sugar](http://en.wikipedia.org/wiki/Syntactic_sugar). It's explained very well by John Resig [her... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | The closest you can find is [\_\_noSuchMethod\_\_](https://web.archive.org/web/20210224190946/https://developer.mozilla.org/en-US/docs/Archive/Web/JavaScript/Object.noSuchMethod) ([\_\_noSuchMethod\_\_ is deprecated](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Deprecated_and_obsolete_features#obje... | This is not exactly an answer to the original question, however [this](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) and [this](https://stackoverflow.com/questions/1441005/pythons-getattr-in-javascript) questions are closed and redirect here, so here I am. I hop... |
994,143 | Long story short: I'm in a situation where I'd like a PHP-style getter, but in JavaScript.
My JavaScript is running in Firefox only, so Mozilla specific JS is OK by me.
The only way I can find to make a JS getter requires specifying its name, but I'd like to define a getter for *all* possible names. I'm not sure if t... | 2009/06/15 | [
"https://Stackoverflow.com/questions/994143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/91238/"
] | `Proxy` can do it! I'm so happy this exists!! An answer is given here: [Is there a javascript equivalent of python's \_\_getattr\_\_ method?](https://stackoverflow.com/questions/1529496/is-there-a-javascript-equivalent-of-pythons-getattr-method) . To rephrase in my own words:
```js
var x = new Proxy({}, {
get(targe... | It is possible to get a similar result simply by wrapping the object in a getter function:
```js
const getProp = (key) => {
const dictionary = {
firstName: 'John',
lastName: 'Doe',
age: 42,
DEFAULT: 'there is no prop like this'
}
return (typeof dictionary[key] === 'undefined' ? dictionary.DEFAULT... |
65,578,085 | I am new to working on a MongoDB and Docker, I am working on an application and couldn't find a more subtle way to seed my database using an npm run command. First I created a file called seed.js and then associated it to npm run seed command on the package.json file.
On the seed.js file I import Mongoose and the mode... | 2021/01/05 | [
"https://Stackoverflow.com/questions/65578085",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14944005/"
] | Add redirection along with the `alert()` in js rather than doing in php.
```
echo "<script>alert('The profile has been deleted.'); window.location.href='logout.php';</script>";
```
This will show alert then redirect to logout.php | try change the following code:
From:
```
<?php
session_start();
session_unset();
session_destroy();
header("location: ../index.php");
exit();
```
To:
```
<?php
session_start();
session_unset();
session_destroy();
echo "<script>alert('The profile has been deleted.');</script>";
header("location: ../index.php");... |
214,469 | I tried filling a numpy array with the foreach\_get() method on an image, but get the following error:
*foreach\_get/set() takes exactly 1 argument (2 given)*
```
def read_pixels(img):
resolution = img.size[0] * img.size[1]
colors = np.zeros(resolution*4, dtype=np.float)
img.pixels.foreach_get("pixels... | 2021/03/09 | [
"https://blender.stackexchange.com/questions/214469",
"https://blender.stackexchange.com",
"https://blender.stackexchange.com/users/18208/"
] | **"The python console check"**
In case Markus is busy can get a lot of info using autocomplete `Tab` in the python console, with an image as `img`
```
>>> img.pixels.foreach_get(
foreach_get(seq)
.. method:: foreach_get(seq)
This is a function to give fast access to array data.
```
which is plainly different from, ... | as Markus von Broady pointed out, ommiting the attribute name and just passing the numpy array works. Thank you.
I was confused, because specifying the the attribute name worked in other areas, e.g.
```
sculpt_vertex_colors[name].data.foreach_get('color', colors)
```
But I guess that's a different structure.
Had... |
43,862,991 | ```
def letter_case_count(string)
char = new Hash
char[:lower] = 0
char[:upper] = 0
char[:neither] = 0
string.split("").each do |x|
if ('A'..'Z').include?(x)
char[:upper]++
elsif ('a'..'z').include?(x)
char[:lower]++
else
char[:neither]++
end
end
end
puts letter_case_c... | 2017/05/09 | [
"https://Stackoverflow.com/questions/43862991",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6571158/"
] | Ruby doesn't have `pre-increment` or `post-increment` operators. Use `+=1` and it should work.
```
def letter_case_count(string)
char = {}
char[:lower] = 0
char[:upper] = 0
char[:neither] = 0
string.split('').each do |x|
if ('A'..'Z').include?(x)
char[:upper] += 1
elsif ('a'..'z').include?(x... | There are bunch of syntax errors in your code.
```
def letter_case_count(string)
char = Hash.new # not new Hash
char[:lower] = 0
char[:upper] = 0
char[:neither] = 0
string.split("").each do |x|
if ('A'..'Z').include?(x)
char[:upper]+=1 # var++ is not valid ruby code
elsif ('a'..'z').include?... |
61,016,694 | I have the following
```
class Person
private String firstName;
private String familyName;
// Setters and Getters
```
And I have the following method
```
public String getFullName(Optional<Person> persons) {
return persons
.map(person -> (person.getFirstName() + " " + person.getFamilyName())).o... | 2020/04/03 | [
"https://Stackoverflow.com/questions/61016694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12051965/"
] | You are looking to [`Optional::filter`](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#filter-java.util.function.Predicate-), before the map:
```
return persons
.filter(person -> person.getFamilyName() != null && person.getFirstName() != null)
.map(person -> person.getFirstName() + "... | You can use filter for that:
```
public String getFullName(Optional<Person> persons) {
return persons
.filter(person -> Objects.nonNull(person.getFirstName()) && Objects.nonNull(person.getFamilyName()))
.map(person -> (person.getFirstName() + " " + person.getFamilyName())).orElse("Invalid");
}
... |
61,016,694 | I have the following
```
class Person
private String firstName;
private String familyName;
// Setters and Getters
```
And I have the following method
```
public String getFullName(Optional<Person> persons) {
return persons
.map(person -> (person.getFirstName() + " " + person.getFamilyName())).o... | 2020/04/03 | [
"https://Stackoverflow.com/questions/61016694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12051965/"
] | You are looking to [`Optional::filter`](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html#filter-java.util.function.Predicate-), before the map:
```
return persons
.filter(person -> person.getFamilyName() != null && person.getFirstName() != null)
.map(person -> person.getFirstName() + "... | Another functional approach.
First create a predicate builder method for required field validation:
```
public static <T, F> Predicate<T> hasRequiredValue(Function<T, F> fieldGetter) {
return fieldGetter.andThen(Objects::nonNull)::apply;
}
```
And modify the `getFullName` a little bit:
```
public Optional<Stri... |
34,228,552 | I want to generate an XML of the following format using XmlWriter class in C# -:
```
<?xml version="1.0" ?>
<root>
<data>
<entry Attrib1="" Attrib2="91.3467" Attrib3="95.3052" Attrib4="6.4722" />
<entry Attrib1="" Attrib2="91.3467" Attrib3="95.3052" Attrib4="6.4722" />
</data>
</root>
```
I am very new to XmlW... | 2015/12/11 | [
"https://Stackoverflow.com/questions/34228552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/862962/"
] | You've almost got it...
```
var xmlWriter = XmlWriter.Create(filename);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("root");
xmlWriter.WriteStartElement("data");
xmlWriter.WriteStartElement("entry");
xmlWriter.WriteAttributeString("attrib1", "... | Try XML Linq
```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
const string FILENAME = @"c:\temp\test.xml";
static void Main(string[] args)
... |
34,228,552 | I want to generate an XML of the following format using XmlWriter class in C# -:
```
<?xml version="1.0" ?>
<root>
<data>
<entry Attrib1="" Attrib2="91.3467" Attrib3="95.3052" Attrib4="6.4722" />
<entry Attrib1="" Attrib2="91.3467" Attrib3="95.3052" Attrib4="6.4722" />
</data>
</root>
```
I am very new to XmlW... | 2015/12/11 | [
"https://Stackoverflow.com/questions/34228552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/862962/"
] | You've almost got it...
```
var xmlWriter = XmlWriter.Create(filename);
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("root");
xmlWriter.WriteStartElement("data");
xmlWriter.WriteStartElement("entry");
xmlWriter.WriteAttributeString("attrib1", "... | Use object serialisation, then you don't have to have object to structure mapping code
```
using System.Xml.Serialization;
...
[XmlRoot("root")]
public class Example {
[XmlElement("data")]
public Entries Entries { get; set; }
}
public class Entries : List<List<string>>, IXmlSerializable {
public List<s... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | I tend to agree with the answer Val provided. The simplest way to deal with this is to talk to the person.
If talking to the person, for whatever reason, is out of the question or uncomfortable, you could try posting a sign on the door asking that people be cautious when closing the door so as not to disrupt the offic... | It's beyond simple: The phrase you're looking for is "Do you mind" or "Would you mind" not letting the door close so noisily.
The title of the question is asking for "the right way". This is it.
Absent other factors which haven't been mentioned here, like previous interactions which would make this a touchy or diffic... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | >
> excuse me "ColleagueName", the door banging so hard sometimes disturbs my concentration, could you please try and close it more softly? Thank you
>
>
>
if he doesn't do it on purpose probably you will have to remind it to him few times because it might happen again. | If you want to avoid conflict and don't mind taking ownership, I would suggest saying something like,
"Hi \_\_\_, would you be willing to help me out? Sometimes when you leave the room, and shut the door, the noise of is loud enough that it breaks my concentration and it is a while before I can refocus. Would you be ... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | >
> excuse me "ColleagueName", the door banging so hard sometimes disturbs my concentration, could you please try and close it more softly? Thank you
>
>
>
if he doesn't do it on purpose probably you will have to remind it to him few times because it might happen again. | Perhaps your colleague "looks really grumpy or depressed. ... talks very little" because of something at home or elsewhere, that's probably not your business.
>
> "... he has this habit of slamming the door real hard. Not like some people do out of negligence, letting the door fall shut behind them. It's a glass door... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | If he enters the room and slams the door, ask him immediately like "don't you think that was too hard?". Or if he isn't afraid to destroy the door.
Reminding someone of this shouldn't yet be offending. Start with a hint to make him think about that. If this doesn't help, slowly become more direct.
Try to not say th... | If you want to avoid conflict and don't mind taking ownership, I would suggest saying something like,
"Hi \_\_\_, would you be willing to help me out? Sometimes when you leave the room, and shut the door, the noise of is loud enough that it breaks my concentration and it is a while before I can refocus. Would you be ... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | >
> excuse me "ColleagueName", the door banging so hard sometimes disturbs my concentration, could you please try and close it more softly? Thank you
>
>
>
if he doesn't do it on purpose probably you will have to remind it to him few times because it might happen again. | If he enters the room and slams the door, ask him immediately like "don't you think that was too hard?". Or if he isn't afraid to destroy the door.
Reminding someone of this shouldn't yet be offending. Start with a hint to make him think about that. If this doesn't help, slowly become more direct.
Try to not say th... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | If you want to avoid conflict and don't mind taking ownership, I would suggest saying something like,
"Hi \_\_\_, would you be willing to help me out? Sometimes when you leave the room, and shut the door, the noise of is loud enough that it breaks my concentration and it is a while before I can refocus. Would you be ... | Perhaps your colleague "looks really grumpy or depressed. ... talks very little" because of something at home or elsewhere, that's probably not your business.
>
> "... he has this habit of slamming the door real hard. Not like some people do out of negligence, letting the door fall shut behind them. It's a glass door... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | If he enters the room and slams the door, ask him immediately like "don't you think that was too hard?". Or if he isn't afraid to destroy the door.
Reminding someone of this shouldn't yet be offending. Start with a hint to make him think about that. If this doesn't help, slowly become more direct.
Try to not say th... | It's beyond simple: The phrase you're looking for is "Do you mind" or "Would you mind" not letting the door close so noisily.
The title of the question is asking for "the right way". This is it.
Absent other factors which haven't been mentioned here, like previous interactions which would make this a touchy or diffic... |
14,929 | We have the following problem in the office: there is a colleague who, I think is nice enough once you get to know him a bit more closely. The thing is, most of the time he looks really grumpy or depressed. I don't really know how to read his face. He talks very little.
We could deal with that (there are seven persons... | 2018/05/25 | [
"https://interpersonal.stackexchange.com/questions/14929",
"https://interpersonal.stackexchange.com",
"https://interpersonal.stackexchange.com/users/18238/"
] | I tend to agree with the answer Val provided. The simplest way to deal with this is to talk to the person.
If talking to the person, for whatever reason, is out of the question or uncomfortable, you could try posting a sign on the door asking that people be cautious when closing the door so as not to disrupt the offic... | Perhaps your colleague "looks really grumpy or depressed. ... talks very little" because of something at home or elsewhere, that's probably not your business.
>
> "... he has this habit of slamming the door real hard. Not like some people do out of negligence, letting the door fall shut behind them. It's a glass door... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.