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 |
|---|---|---|---|---|---|
52,537,188 | I am writing code that needs to format a string, and I want to avoid buffer overruns.
I know that if `vsnprintf` is available (C99 onwards) we can do:
```
char* formatString(const char *format, ...)
{
char* result = NULL;
va_list ap;
va_start(ap, format);
/* Get the size of the formatted string by ge... | 2018/09/27 | [
"https://Stackoverflow.com/questions/52537188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2891462/"
] | Pre-C99 affords no simply solution to format strings with a high degree of safety of preventing buffer overruns.
It is those pesky `"%s"`, `"%[]"`, `"%f"` format specifiers that require so much careful consideration with their potential long output. Thus the need for such a function. [@Jonathan Leffler](https://stacko... | *Transferring [comments](https://stackoverflow.com/questions/52537188/format-strings-safely-when-vsnprintf-is-not-available?noredirect=1#comment92017411_52537188) to answer.*
>
> The main reason `vsnprintf()` was added to C99 was that it is hard to protect `vsprintf()` or similar. One workaround is to open `/dev/null... |
45,211,213 | We are using Google Charts within an MVC project.
We have managed to get the chart implemented however we are having a slight issue.
Whenever we slant the text 90 degrees the hAxis labels are repeating (see below).
[](https://i.stack.imgur.com/WBHnm.... | 2017/07/20 | [
"https://Stackoverflow.com/questions/45211213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4608024/"
] | when using a [continuous axis](https://developers.google.com/chart/interactive/docs/customizing_axes#discrete-vs-continuous),
provide your own `ticks` to ensure no repeats...
`ticks` takes an array of values of the same data type as the axis
each tick can be a raw value, such as a date --> `new Date(2017, 3, 2)`... | VICTORY!
So I finally got it working. WhiteHat you're an absolute genius! Thank you! EDIT 2 did the trick, however I added an extra property to the hAxis for it to display all labels (see below).
```
showTextEvery:1
```
Below is the full implementation for anyone else having this issue.
```
var data = new google.v... |
5,487,916 | I have a Rails 3 project that uses some java jar files. I'm putting these jars in the vendor/ directory and adding them to the git repo.
But these jars can be large (e.g. 22MB), and they are binaries. On the other hand, it's convenient to store them into the repo with the Ruby code since they work closely with the res... | 2011/03/30 | [
"https://Stackoverflow.com/questions/5487916",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/232417/"
] | You are opening a big can of worms regarding dependency management. Most projects including some of the [smaller ones](http://code.google.com/p/jaxb-collada/source/browse/#hg/extlib) I work on use the ball of mud, dependencies in a folder approach. As the project gets larger somebody serious comes along and typically d... | In my opinion if your app requires them to run then it makes sense to keep them in the git repo otherwise if you checked out the app on another machine you'd have to mess around sourcing the binaries again. 22MB isn't that huge and they aren't going to be modified, so I don't think this causes any problems. |
11,281,401 | We have an application that stores some configuration values from C/C++ in MongoDB and has the capability to be restarted (i.e. it runs for a while, someone interrupts the application, changes the configuration, then runs the app again, and it picks up where it left off). This works like a charm for boolean and string ... | 2012/07/01 | [
"https://Stackoverflow.com/questions/11281401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/535201/"
] | In the C/C++ "sense of the word", ints are [not actually guaranteed](https://stackoverflow.com/questions/589575/size-of-int-long-etc?answertab=votes#tab-top) to be 32-bit values. An `int` must be at least 16-bits, but generally matches the platform architecture (eg. 32 or 64bit).
As mentioned by @Jasd, JavaScript does... | MongoDB's shell is powered by a JavaScript Engine. And JavaScript has no type for `integer`. It knows only `Number`, which is a type for floating-point numbers.
You can try using the MongoDB type [`NumberLong`](http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiv... |
11,281,401 | We have an application that stores some configuration values from C/C++ in MongoDB and has the capability to be restarted (i.e. it runs for a while, someone interrupts the application, changes the configuration, then runs the app again, and it picks up where it left off). This works like a charm for boolean and string ... | 2012/07/01 | [
"https://Stackoverflow.com/questions/11281401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/535201/"
] | You can fix the types of all values for a certain field on the console with something like:
```
db.Statistic.find({kodoId: {$exists: true}}).forEach(function (x) {
x.kodoId = NumberInt(x.kodoId);
db.Statistic.save(x);
});
```
This will only load documents that have the `kodoId` field and convert them to int and ... | MongoDB's shell is powered by a JavaScript Engine. And JavaScript has no type for `integer`. It knows only `Number`, which is a type for floating-point numbers.
You can try using the MongoDB type [`NumberLong`](http://www.mongodb.org/display/DOCS/Overview+-+The+MongoDB+Interactive+Shell#Overview-TheMongoDBInteractiv... |
11,281,401 | We have an application that stores some configuration values from C/C++ in MongoDB and has the capability to be restarted (i.e. it runs for a while, someone interrupts the application, changes the configuration, then runs the app again, and it picks up where it left off). This works like a charm for boolean and string ... | 2012/07/01 | [
"https://Stackoverflow.com/questions/11281401",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/535201/"
] | In the C/C++ "sense of the word", ints are [not actually guaranteed](https://stackoverflow.com/questions/589575/size-of-int-long-etc?answertab=votes#tab-top) to be 32-bit values. An `int` must be at least 16-bits, but generally matches the platform architecture (eg. 32 or 64bit).
As mentioned by @Jasd, JavaScript does... | You can fix the types of all values for a certain field on the console with something like:
```
db.Statistic.find({kodoId: {$exists: true}}).forEach(function (x) {
x.kodoId = NumberInt(x.kodoId);
db.Statistic.save(x);
});
```
This will only load documents that have the `kodoId` field and convert them to int and ... |
5,339,339 | i have column named `postDate` defined as timestamp.
when i print it directly:
```
echo $result['postDate'];
```
i do get that what is stored(eg. `2011-03-16 16:48:24`)
on the other hand when i print it through date function:
```
echo date('F/j/Y',$result['postDate'])
```
i get `December/31/1969`
what am i doi... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5339339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653874/"
] | try this.
```
date('F/j/Y',strtotime($result['postDate']));
```
as timestamp is required, not formatted date as second parameter.
or you can also try
```
SELECT UNIX_TIMESTAMP(postDate) as postDateInt from myTable
```
instead of `SELECT postDate from myTable`
and then have this in your code.
```
date('F/j/Y',$re... | The PHP [date](http://us3.php.net/manual/en/function.date.php) function looks for an `int time()` as the 2nd param. Try using [strtotime()](http://us3.php.net/manual/en/function.strtotime.php)
```
echo date('F/j/Y', strtotime($result['postDate']) );
``` |
5,339,339 | i have column named `postDate` defined as timestamp.
when i print it directly:
```
echo $result['postDate'];
```
i do get that what is stored(eg. `2011-03-16 16:48:24`)
on the other hand when i print it through date function:
```
echo date('F/j/Y',$result['postDate'])
```
i get `December/31/1969`
what am i doi... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5339339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653874/"
] | try this.
```
date('F/j/Y',strtotime($result['postDate']));
```
as timestamp is required, not formatted date as second parameter.
or you can also try
```
SELECT UNIX_TIMESTAMP(postDate) as postDateInt from myTable
```
instead of `SELECT postDate from myTable`
and then have this in your code.
```
date('F/j/Y',$re... | The PHP `date()' function expects a number for the second parameter - ie a unix timestamp.
You can convert a SQL date string (or virtually any other date string) into a timestamp in PHP by using the `strtotime()` function. At least two other answers have already suggested this.
However, I would suggest that you'd be ... |
5,339,339 | i have column named `postDate` defined as timestamp.
when i print it directly:
```
echo $result['postDate'];
```
i do get that what is stored(eg. `2011-03-16 16:48:24`)
on the other hand when i print it through date function:
```
echo date('F/j/Y',$result['postDate'])
```
i get `December/31/1969`
what am i doi... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5339339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653874/"
] | try this.
```
date('F/j/Y',strtotime($result['postDate']));
```
as timestamp is required, not formatted date as second parameter.
or you can also try
```
SELECT UNIX_TIMESTAMP(postDate) as postDateInt from myTable
```
instead of `SELECT postDate from myTable`
and then have this in your code.
```
date('F/j/Y',$re... | Why not format the date as needed in your MySQL query?
```
SELECT DATE_FORMAT(postDate, '%M/%D/%Y') as date from table
``` |
5,339,339 | i have column named `postDate` defined as timestamp.
when i print it directly:
```
echo $result['postDate'];
```
i do get that what is stored(eg. `2011-03-16 16:48:24`)
on the other hand when i print it through date function:
```
echo date('F/j/Y',$result['postDate'])
```
i get `December/31/1969`
what am i doi... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5339339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653874/"
] | The PHP [date](http://us3.php.net/manual/en/function.date.php) function looks for an `int time()` as the 2nd param. Try using [strtotime()](http://us3.php.net/manual/en/function.strtotime.php)
```
echo date('F/j/Y', strtotime($result['postDate']) );
``` | The PHP `date()' function expects a number for the second parameter - ie a unix timestamp.
You can convert a SQL date string (or virtually any other date string) into a timestamp in PHP by using the `strtotime()` function. At least two other answers have already suggested this.
However, I would suggest that you'd be ... |
5,339,339 | i have column named `postDate` defined as timestamp.
when i print it directly:
```
echo $result['postDate'];
```
i do get that what is stored(eg. `2011-03-16 16:48:24`)
on the other hand when i print it through date function:
```
echo date('F/j/Y',$result['postDate'])
```
i get `December/31/1969`
what am i doi... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5339339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653874/"
] | The PHP [date](http://us3.php.net/manual/en/function.date.php) function looks for an `int time()` as the 2nd param. Try using [strtotime()](http://us3.php.net/manual/en/function.strtotime.php)
```
echo date('F/j/Y', strtotime($result['postDate']) );
``` | Why not format the date as needed in your MySQL query?
```
SELECT DATE_FORMAT(postDate, '%M/%D/%Y') as date from table
``` |
5,339,339 | i have column named `postDate` defined as timestamp.
when i print it directly:
```
echo $result['postDate'];
```
i do get that what is stored(eg. `2011-03-16 16:48:24`)
on the other hand when i print it through date function:
```
echo date('F/j/Y',$result['postDate'])
```
i get `December/31/1969`
what am i doi... | 2011/03/17 | [
"https://Stackoverflow.com/questions/5339339",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/653874/"
] | Why not format the date as needed in your MySQL query?
```
SELECT DATE_FORMAT(postDate, '%M/%D/%Y') as date from table
``` | The PHP `date()' function expects a number for the second parameter - ie a unix timestamp.
You can convert a SQL date string (or virtually any other date string) into a timestamp in PHP by using the `strtotime()` function. At least two other answers have already suggested this.
However, I would suggest that you'd be ... |
33,930,758 | I'm using a combination of Jquery and Bootstrap. I'm trying to target only visible panels. If I get rid of the first line, of code, the function work, but targets all panels in my HTML, which I don't want. If I keep the first line of code, the function doesn't carry through at all.
```
$(".panel:visible").each(functio... | 2015/11/26 | [
"https://Stackoverflow.com/questions/33930758",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5510690/"
] | Javascript that accesses the DOM must not execute UNTIL the DOM has been loaded.
Code that runs in the `<head>` section of the document will execute BEFORE the DOM has been loaded and thus if it tries to operate on the DOM, the DOM will simply be empty.
Code that runs in the `<body>` section of the document will exec... | **`<head>`** contains all the information regarding the Page properties, CSS and JavaScript. Though CSS and JavaScript can be included in the body as well. Head will include Page's meta information, Title, base URL etc.
**`<body>`** contains the actual content of the body. Which users visiting the website actually see... |
2,894,560 | I have extra retain counts after calling initWithNib.
What could cause this? (There are no referencing outlets in the nib)
```
StepViewController *stepViewController = [[StepViewController alloc] initWithNibName:@"StepViewController" bundle:nil];
[self.navigationController pushViewController:stepViewController animate... | 2010/05/24 | [
"https://Stackoverflow.com/questions/2894560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/57254/"
] | What are you troubleshooting? There is nothing wrong here. -retainCount is not your business and tells you almost nothing about the system. Every object that is autoreleased will have an apparent retainCount higher than you think it will be. If internal objects are interested in this object, they will have their own re... | You would have to look into the source code or API documentation to find out. But it would seem logical that the nvaigation controller has one and the view loaded out of the xib has one, so that's probably another being done by something in the naviation controller would be my guess. |
25,225,182 | I'm trying to build a searchable database that will allow a user to type in the name of a state and see a small subset of that state's laws (traffic laws, age of consent, conceal and carry laws, etc.). I'm getting confused on how a user submitted string will interact with my Javascript objects. I have seen people submi... | 2014/08/10 | [
"https://Stackoverflow.com/questions/25225182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3788480/"
] | here you go I implemented this fiddle for you with how I'd handle what you need. I changed the data structure so that the state names are the keys...
<http://jsfiddle.net/yc7w364t/>
```
var stateData = {
"minnesota" : {
consent: 18,
openBottle: true,
deathPen: false,
conceal: "Conceal & Ca... | The keys in your object should be the name of the state. Then you can do this:
```
var states = {
"Minnesota": {
consent: 18,
openBottle: true,
deathPen: false,
conceal: "Conceal & Carry",
txtDriveBan: true,
talkDriveBan: false
}
}
$(document).ready(function() {... |
25,373,273 | First of all, I come from Obj-C and Python, so feel free to edit any faults in my JavaScript teminology.
I am looking for an efficient way of joining multiple dictionaries in JavaScript, where each key can exist in more than one dictionary and its values are arrays.
For example, I have:
```
{foo: [1,2], bar: [3,4]}
... | 2014/08/18 | [
"https://Stackoverflow.com/questions/25373273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1373572/"
] | With [Lo-Dash](http://lodash.com/):
```
var data = [
{foo: [1,2], bar: [3,4]},
{foo: [5,6]},
];
_.reduce(data, function (result, obj) {
_.each(obj, function (array, key) {
result[key] = (result[key] || []).concat(array)
})
return result
}, {})
```
See this [fiddle](http://jsfiddle.net/80... | This code works:
```
var joinManyObjects = function joinManyObjects (arrayA, arrayB)
{
var i, j;
for(i = 0; i < arrayB.length; i++)
{
for(j = 0; j < arrayA.length; j++)
{
var k = Object.keys(arrayB[i]);
console.log("Common keys: "+k);
if(k in arrayA[j])
{
arrayA[j][k] = a... |
4,060 | Speaking with a large group about Bitcoins lately, I noticed that most people there came to like Bitcoins for different reasons. The shady ppl wanted drugs, the accountants wanted to avoid taxes, the Ron Paul people wanted more personal liberty and to end the Fed, The traders wanted new Forex opportunities, and the com... | 2012/06/25 | [
"https://bitcoin.stackexchange.com/questions/4060",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/1519/"
] | I can't think of any known data about real demographics.
But here are some things you can consider to get an idea:
* [BitcoinCharts' currency distribution](http://bitcoincharts.com/charts/volumepie/): Gives you a view on what currencies are traded the most, most currencies are country- or region-specific so this can ... | A recent survey solicited to BitcoinTalk forum members:
* <http://bitcointalk.org/index.php?topic=88927.0> |
4,060 | Speaking with a large group about Bitcoins lately, I noticed that most people there came to like Bitcoins for different reasons. The shady ppl wanted drugs, the accountants wanted to avoid taxes, the Ron Paul people wanted more personal liberty and to end the Fed, The traders wanted new Forex opportunities, and the com... | 2012/06/25 | [
"https://bitcoin.stackexchange.com/questions/4060",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/1519/"
] | I can't think of any known data about real demographics.
But here are some things you can consider to get an idea:
* [BitcoinCharts' currency distribution](http://bitcoincharts.com/charts/volumepie/): Gives you a view on what currencies are traded the most, most currencies are country- or region-specific so this can ... | There was a Bitcoin survey recently: <https://bitcointalk.org/index.php?topic=88927.0>. |
4,060 | Speaking with a large group about Bitcoins lately, I noticed that most people there came to like Bitcoins for different reasons. The shady ppl wanted drugs, the accountants wanted to avoid taxes, the Ron Paul people wanted more personal liberty and to end the Fed, The traders wanted new Forex opportunities, and the com... | 2012/06/25 | [
"https://bitcoin.stackexchange.com/questions/4060",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/1519/"
] | A recent survey solicited to BitcoinTalk forum members:
* <http://bitcointalk.org/index.php?topic=88927.0> | There was a Bitcoin survey recently: <https://bitcointalk.org/index.php?topic=88927.0>. |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | Assuming the file is sorted numerically on the first column you can use `awk` for this in the following way
```
awk 'NR==1 {max=$1} {if($1==max){print $0}}'
```
this grabs the first field of the first line and stores that in variable `max` and only the lines that match this number are printed subsequently | You may first retrieve the number of max occurence, and then grep on that file:
```
NB=$(head -n1 error.dat | cut -d ' ' -f 1)
egrep ^$NB error.dat
```
Here `egrep` means that `grep` should interpret the pattern as a regex; and `^` represents the beginning of a line |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | Assuming the file is sorted numerically on the first column you can use `awk` for this in the following way
```
awk 'NR==1 {max=$1} {if($1==max){print $0}}'
```
this grabs the first field of the first line and stores that in variable `max` and only the lines that match this number are printed subsequently | You can use this `awk`:
```
awk 'NR==FNR{if ($1>max) max=$1; next} $1==max' file file
19 prob561493
19 prob564972
19 prob561564
```
In the 1st pass we are getting max value from `$1` stored in variable `max` and in 2nd pass we just print all the records that have first field same as `max`. |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | Assuming the file is sorted numerically on the first column you can use `awk` for this in the following way
```
awk 'NR==1 {max=$1} {if($1==max){print $0}}'
```
this grabs the first field of the first line and stores that in variable `max` and only the lines that match this number are printed subsequently | Use awk to extract the '19' and grep+regex to get the lines that start with `19\b`. Assuming your file-name is "output":
```
grep -E "$(head -n1 output | awk '{print $1}')\b" output
``` |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | You asked how to do this in bash. I have to say that awk may provide the clearest method to achieve what you want:
```
awk 'NR==1{n=$1} $1==n{print;next} {exit}'
```
This gets the count from the first field, then prints each line with that first field, and exits when the field doesn't match. It assumes sorted input.... | Assuming the file is sorted numerically on the first column you can use `awk` for this in the following way
```
awk 'NR==1 {max=$1} {if($1==max){print $0}}'
```
this grabs the first field of the first line and stores that in variable `max` and only the lines that match this number are printed subsequently |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | You asked how to do this in bash. I have to say that awk may provide the clearest method to achieve what you want:
```
awk 'NR==1{n=$1} $1==n{print;next} {exit}'
```
This gets the count from the first field, then prints each line with that first field, and exits when the field doesn't match. It assumes sorted input.... | You may first retrieve the number of max occurence, and then grep on that file:
```
NB=$(head -n1 error.dat | cut -d ' ' -f 1)
egrep ^$NB error.dat
```
Here `egrep` means that `grep` should interpret the pattern as a regex; and `^` represents the beginning of a line |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | You asked how to do this in bash. I have to say that awk may provide the clearest method to achieve what you want:
```
awk 'NR==1{n=$1} $1==n{print;next} {exit}'
```
This gets the count from the first field, then prints each line with that first field, and exits when the field doesn't match. It assumes sorted input.... | You can use this `awk`:
```
awk 'NR==FNR{if ($1>max) max=$1; next} $1==max' file file
19 prob561493
19 prob564972
19 prob561564
```
In the 1st pass we are getting max value from `$1` stored in variable `max` and in 2nd pass we just print all the records that have first field same as `max`. |
29,614,964 | I have an output of the following format in bash, from a script I wrote that returns the number of duplicate file names and the file name itself within a particular directory.
```
19 prob561493
19 prob564972
19 prob561564
11 prob561965
8 prob562172
7 prob564449
6 prob564155
6 prob562925
6 prob562739
``... | 2015/04/13 | [
"https://Stackoverflow.com/questions/29614964",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1913389/"
] | You asked how to do this in bash. I have to say that awk may provide the clearest method to achieve what you want:
```
awk 'NR==1{n=$1} $1==n{print;next} {exit}'
```
This gets the count from the first field, then prints each line with that first field, and exits when the field doesn't match. It assumes sorted input.... | Use awk to extract the '19' and grep+regex to get the lines that start with `19\b`. Assuming your file-name is "output":
```
grep -E "$(head -n1 output | awk '{print $1}')\b" output
``` |
59,401 | Is it because of the inherent limitations of cooling the cylinder walls, only 2 valves per cylinder, relative ease of scaling up instead of dialing up the boost, or some other reason? | 2019/01/24 | [
"https://aviation.stackexchange.com/questions/59401",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/36532/"
] | I read somewhere once, maybe I can find it again, but it is because of the inherent limitations of cooling the cylinder walls. Air cooling is not as controllable, because the temperature of the air varies with altitude and season. Hence, the temperature of the cylinders in an air cooled engine are not as tightly contro... | A liquid cooled engine doesn't necessarily expose all its cylinders to the airflow, which reduces drag in comparison to a radial engine. Also, water is a much better medium for distributing heat from an engine so it takes much more heat to have a detrimental effect on LC engines (aka temperature above operating levels)... |
7,878,334 | i am trying to configure nginx to proxy pass the request to another server,
only if the $request\_body variable matches on a specific regular expression.
My problem now is, that I don't how to configure this behaviour exactly.
I am currently down to this one:
```
server {
listen 80 default;
server_name te... | 2011/10/24 | [
"https://Stackoverflow.com/questions/7878334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/671116/"
] | Nginx routing is based on the location directive which matches on the Request URI. The solution is to temporarily modify this in order to forward the request to different endpoints.
```
server {
listen 80 default;
server_name test.local;
if ($request_body ~* ^(.*)\.test) {
rewrite ^(.*)$ /istest... | try this:
```
server {
listen 80 default;
server_name test.local;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
if ($request_body ~* ^(.*)\.test) {
proxy_pass http://www.go... |
39,947,606 | Hi i am trying to build my first project using Android support libraries in order to support material design for all of the devices on market. At the very begining of my journey i create a project from scratch and when i build from graddle using this module configuration:
```
apply plugin: 'com.android.application... | 2016/10/09 | [
"https://Stackoverflow.com/questions/39947606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1029631/"
] | Try this in build.gradle
```
aaptOptions {
ignoreAssetsPattern "!values-b+sr+Latn"
}
``` | To expand on powder366's answer, and the comment, since I don't have the rep to comment myself.
Inside the Gradle Script called 'build.gradle' for the Project:Name, there is an 'android' section with brackets. Inside those brackets you can add
>
> aaptOptions {
> ignoreAssetsPattern "!values-b+sr+Latn"
> }
>
>
... |
39,947,606 | Hi i am trying to build my first project using Android support libraries in order to support material design for all of the devices on market. At the very begining of my journey i create a project from scratch and when i build from graddle using this module configuration:
```
apply plugin: 'com.android.application... | 2016/10/09 | [
"https://Stackoverflow.com/questions/39947606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1029631/"
] | Try this in build.gradle
```
aaptOptions {
ignoreAssetsPattern "!values-b+sr+Latn"
}
``` | ### Some background
>
> Android 7.0 (API level 24) introduced support for BCP 47 language tags, which you can use to qualify language- and region-specific resources. A language tag is composed from a sequence of one or more subtags, each of which refines or narrows the range of language identified by the overall tag.... |
33,071,718 | I have the below code to perform CRUD operations in my MVC program.
```
if (ModelState.IsValid)
{
CustomerDal dal = new CustomerDal();
dal.Customers.Add(obj);
dal.Entry(obj).State = EntityState.Modified;//added this line to resolve issue but still no change... | 2015/10/12 | [
"https://Stackoverflow.com/questions/33071718",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/833985/"
] | First off you should fix the issues which Alde has mentioned. Next off what's up with the `while (true)` statement? You should probably replace it with `while (attempts != 0)` and set the:
```
if (attempts == 0) {
cout << "Sorry, no guesses remain. The random number was... " << RandomNumber
<< "!";//so th... | I see multiple issues:
* you are missing a ending '}' at the end of PlayGame and Again functions
* in the latter one the return is optional and should have a ';' at the end
* you are comparing 'decision' with unitialized variables y, Y, n, and N... I guess you wanted compare its value with the chars 'y', 'Y', 'n', 'N'... |
25,484,744 | I have a quicksort program which executes as shown. But the last element is not getting sorted. Can anyone tell me how to modify the program to obtain the correct result.
```
#include <stdlib.h>
#include <stdio.h>
static void swap(void *x, void *y, size_t l)
{
char *a = x, *b = y, c;
while(l--)
{
... | 2014/08/25 | [
"https://Stackoverflow.com/questions/25484744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3847567/"
] | The problem comes from this line:
```
sort(array, size, cmp, 0, (nitems-1)*size);
```
nitems is your number of items, here 5, you're substracting one so your quick sort will only sort the 4 first elements. Remove the -1 and it will work.
```
sort(array, size, cmp, 0, nitems*size);
``` | 2 mistakes here...
First change `qsort()` function names to `qsort_user()` or any other name then the `qsort()` because `qsort()` is the standard function defined in `stdlib.h`
---
Then change this line
```
sort(array, size, cmp, 0, (nitems-1)*size);
```
to
```
sort(array, size, cmp, 0, (nitems)*size);
``` |
3,329,958 | I am a newbie to Android and the Eclipse development environment and would like some advice on best practices for debugging my apps when they throw a Force Close.
I have researched ADB, however, I can not get this to interact with my phone even though I have explicitly turned debug mode to true on my test handset.
Ob... | 2010/07/25 | [
"https://Stackoverflow.com/questions/3329958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/459095/"
] | To debug using your device, you will need to have debug mode turned on (which it sounds like you do), you will then need to have the phone plugged in with the USB connector. From here, you can tell Eclipse to run/debug.
Eclipse should ask which device to use (this is done because there should be multiple devices avail... | As I have never been able to get Eclipse to refresh the LogCat when I'm debugging on device, I will add this :
You can also debug from command line like this :
"adb -d logcat"
However, as the windows command line is awfully basic, the line are cut in 2 most of the time.
And my asking about your OS does help be... |
78,084 | I have created a VF page rendered as pdf for QuoteLineItems in which I have added the list inside `<apex:repeat>` tags inside a html table row which again is inside another table.The problem however is that when the list includes more elements than the page can hold, the table borders gets streched and the remaining ro... | 2015/05/31 | [
"https://salesforce.stackexchange.com/questions/78084",
"https://salesforce.stackexchange.com",
"https://salesforce.stackexchange.com/users/20324/"
] | I found an easy solution for the problem, no need to implement any logic for the same just included the following attribute `-fs-table-paginate: paginate;` in tables style tag and worked like a miracle. | What you want to do typically requires a custom controller. There's an excellent tutorial in the Technical Library titled [Creating Professional PDF Documents with CSS and Visualforce](https://developer.salesforce.com/page/Creating_Professional_PDF_Documents_with_CSS_and_Visualforce) that describes exactly how how to d... |
14,772,115 | I'm using the Javascript SDK for facebook to login a user with Facebook:
Documentation FB.Login: [link](http://developers.facebook.com/docs/reference/javascript/FB.login/)
Unfortunatly this dialog is always in English.
FB.Dialog will trigger a popup window with url:
```
https://www.facebook.com/login.php?PARAMETER... | 2013/02/08 | [
"https://Stackoverflow.com/questions/14772115",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/681803/"
] | It might be something to do with the SDK source you are using
From <http://developers.facebook.com/docs/reference/javascript/>
```
js.src = "//connect.facebook.net/en_US/all.js";
```
Change **en\_US** to your language locale **es\_ES** and that might fix it. | You can set locale while loading Facebook SDK:
```
// Load the SDK Asynchronously
(function (d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src =... |
53,816,702 | I looked into `stackoverflow`, and found a solution on how to remove animation from the default `bottom navigation.`
Now i need to remove the title from bottom navigation. I set empty string in title of bottom navigation xml file, but it does not change the position of images. **I'm working with v27**
I need to cente... | 2018/12/17 | [
"https://Stackoverflow.com/questions/53816702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4977669/"
] | You could try to add the app:labelVisibilityMode to "unlabeled"
```
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:labelVisibilityMode="unlabeled"/>
``` | I use variations of the below code to customize the labels of `BottomNavigationView` which are essentially TextViews:
```
private void removeBottomNavigationLabels(BottomNavigationView bottomNavigationView) {
for (int i = 0; i < bottomNavigationView.getChildCount(); i++) {
View item = bottomNavigationView.... |
53,816,702 | I looked into `stackoverflow`, and found a solution on how to remove animation from the default `bottom navigation.`
Now i need to remove the title from bottom navigation. I set empty string in title of bottom navigation xml file, but it does not change the position of images. **I'm working with v27**
I need to cente... | 2018/12/17 | [
"https://Stackoverflow.com/questions/53816702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4977669/"
] | You could try to add the app:labelVisibilityMode to "unlabeled"
```
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:labelVisibilityMode="unlabeled"/>
``` | try using these attributes:
```
showUnselectedLabels: false
showSelectedLabels: false
``` |
53,816,702 | I looked into `stackoverflow`, and found a solution on how to remove animation from the default `bottom navigation.`
Now i need to remove the title from bottom navigation. I set empty string in title of bottom navigation xml file, but it does not change the position of images. **I'm working with v27**
I need to cente... | 2018/12/17 | [
"https://Stackoverflow.com/questions/53816702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4977669/"
] | I use variations of the below code to customize the labels of `BottomNavigationView` which are essentially TextViews:
```
private void removeBottomNavigationLabels(BottomNavigationView bottomNavigationView) {
for (int i = 0; i < bottomNavigationView.getChildCount(); i++) {
View item = bottomNavigationView.... | try using these attributes:
```
showUnselectedLabels: false
showSelectedLabels: false
``` |
3,125,692 | I have a list of objects, each with a bool ShouldRun() method on them.
I am currently iterating over the list of objects, and checking ShouldRun() on each object, and calling Run() on the first one to return true
```
foreach (child in Children)
{
if (child.ShouldRun())
{
child.Run();
break;
}
}... | 2010/06/26 | [
"https://Stackoverflow.com/questions/3125692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56472/"
] | I'm not a PLINQ genius, but wouldn't this simpler answer suffice?
```
var childToRun = Children.AsParallel().AsOrdered()
.Where(x => x.ShouldRun()).FirstOrDefault();
childToRun.Run();
``` | Just a concept of way I would try to do it.
Run all `ShouldRun()`'s in parallel. Put the results to the ordered list along with the items and indexes of the items (e.g. ShouldRun() of third item ends with false, the list would contain something like: 2,false,item).
In another thread, keep current index starting with... |
3,125,692 | I have a list of objects, each with a bool ShouldRun() method on them.
I am currently iterating over the list of objects, and checking ShouldRun() on each object, and calling Run() on the first one to return true
```
foreach (child in Children)
{
if (child.ShouldRun())
{
child.Run();
break;
}
}... | 2010/06/26 | [
"https://Stackoverflow.com/questions/3125692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56472/"
] | I'm not a PLINQ genius, but wouldn't this simpler answer suffice?
```
var childToRun = Children.AsParallel().AsOrdered()
.Where(x => x.ShouldRun()).FirstOrDefault();
childToRun.Run();
``` | You should be able to do a parallel select with the indices attached, then sort the result based on index and pick the first which returned `true`. I don't have an IDE on this machine so this is untested, but something like:
```
var runnables = Children.AsParallel()
.Select(child, index =>
... |
3,125,692 | I have a list of objects, each with a bool ShouldRun() method on them.
I am currently iterating over the list of objects, and checking ShouldRun() on each object, and calling Run() on the first one to return true
```
foreach (child in Children)
{
if (child.ShouldRun())
{
child.Run();
break;
}
}... | 2010/06/26 | [
"https://Stackoverflow.com/questions/3125692",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56472/"
] | I'm not a PLINQ genius, but wouldn't this simpler answer suffice?
```
var childToRun = Children.AsParallel().AsOrdered()
.Where(x => x.ShouldRun()).FirstOrDefault();
childToRun.Run();
``` | I'm puzzled as to why you have a "ShouldRun" flag on each child, rather than having earlier placed each child that you would mark as "ShouldRun" into a "RunThese" set.
Then you only have to ask if the RunThese set size is zero or not, and if not zero, run them all.
[Of course, if you are going to run them, why even m... |
34,220,398 | I'm attempting to install a custom build on heroku, so I'm using a variety of ways to attempt a third part installing using the buildpacks. In my .buildpacks file I have:
```
https://github.com/ddollar/heroku-buildpack-apt
https://github.com/heroku/heroku-buildpack-python.git
```
and in my `Aptfile` I have the follo... | 2015/12/11 | [
"https://Stackoverflow.com/questions/34220398",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/673600/"
] | <https://github.com/heroku/heroku-buildpack-python/blob/master/bin/compile#L99-L107>
```
# Prepend proper path buildpack use.
export PATH=$BUILD_DIR/.heroku/python/bin:$BUILD_DIR/.heroku/vendor/bin:$PATH
export PYTHONUNBUFFERED=1
export LANG=en_US.UTF-8
export C_INCLUDE_PATH=/app/.heroku/vendor/include:$BUILD_DIR/.her... | I naively solved a similar problem by modifying heroku-buildpack-python's compile script to not unset LD\_LIBRARY\_PATH and INCLUDE\_PATH, as well as to append the current LD\_LIBRARY\_PATH and INCLUDE\_PATH variables during their export so as to not overwrite them.
Here is my fork: <https://github.com/jasrusable/hero... |
45,336 | While playing Phase Ten, is it legal to pick up the top card of the discard pile and then immediately discard that exact card? | 2019/02/28 | [
"https://boardgames.stackexchange.com/questions/45336",
"https://boardgames.stackexchange.com",
"https://boardgames.stackexchange.com/users/26637/"
] | Yes. You draw the card, put it into your hand, and then discard **any** card from your hand (which may be the card you just drew). | Yes. You should rather pick up a card from the pile to get a chance to help you. But if you want to do that yes you can. |
37,589 | Is there any McAfee API [ or command line utility ] that can be integrated with ASP.Net to scan for viruses in uploaded files.
**Edit:**
I was about to ask the question in stackoverflow but thought since it is related to McAfee only it would be better to put this question in here.
***Edit:***
I don't need a 3rd par... | 2009/09/08 | [
"https://superuser.com/questions/37589",
"https://superuser.com",
"https://superuser.com/users/2959/"
] | After doing a little digging for you, it doesn't look like the Mcafee API is commonly available.
You need to get in contact directly with them if you want samples, however there are third party tools that can plugin to many other AV scanners such as those available from [Opswat](http://www.opswat.com/) which comes wit... | You could try using the [Microsoft Antivirus API](http://msdn.microsoft.com/en-us/library/ms537365%28VS.85%29.aspx). It is a COM API that can be used to scan files. This is the same API that Internet Explorer and Outlook use to scan downloaded files. |
37,589 | Is there any McAfee API [ or command line utility ] that can be integrated with ASP.Net to scan for viruses in uploaded files.
**Edit:**
I was about to ask the question in stackoverflow but thought since it is related to McAfee only it would be better to put this question in here.
***Edit:***
I don't need a 3rd par... | 2009/09/08 | [
"https://superuser.com/questions/37589",
"https://superuser.com",
"https://superuser.com/users/2959/"
] | After doing a little digging for you, it doesn't look like the Mcafee API is commonly available.
You need to get in contact directly with them if you want samples, however there are third party tools that can plugin to many other AV scanners such as those available from [Opswat](http://www.opswat.com/) which comes wit... | Yes, you can look at [McAfee VirusScan Command Line Reference](https://kc.mcafee.com/resources/sites/MCAFEE/content/live/PRODUCT_DOCUMENTATION/20000/PD20010/en_US/e5200wpg.pdf). |
37,589 | Is there any McAfee API [ or command line utility ] that can be integrated with ASP.Net to scan for viruses in uploaded files.
**Edit:**
I was about to ask the question in stackoverflow but thought since it is related to McAfee only it would be better to put this question in here.
***Edit:***
I don't need a 3rd par... | 2009/09/08 | [
"https://superuser.com/questions/37589",
"https://superuser.com",
"https://superuser.com/users/2959/"
] | Yes, you can look at [McAfee VirusScan Command Line Reference](https://kc.mcafee.com/resources/sites/MCAFEE/content/live/PRODUCT_DOCUMENTATION/20000/PD20010/en_US/e5200wpg.pdf). | You could try using the [Microsoft Antivirus API](http://msdn.microsoft.com/en-us/library/ms537365%28VS.85%29.aspx). It is a COM API that can be used to scan files. This is the same API that Internet Explorer and Outlook use to scan downloaded files. |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | There are a few different ways to attack this - note that the tool instructions will vary a bit, based on what version of Windows CE / Windows Mobile you are using.
Some questions to answer:
**1. Is your application leaking memory, leading to this low memory condition?**
**2. Does your application simply use too mu... | There are lots of good things in the other answers, but I did think it worth adding that if all the threads get in a similar loop, then the program will be deadlocked.
The "correct" answer to this situation is probably to have strict limits for the different parts of the program to ensure that they don't over consume ... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | A few points:
* Embedded programs often allocate all memory at startup or use only static memory to avoid situations like this.
* Unless there is something else running on the device that frees memory on a regular basis your solution isn't likely to be effective.
* The Viper I have has 64MB RAM, I don't think they com... | Surely it would depend on whether you have a reasonable expectation of memory becoming available in the 100 (millisecond?) sleep? Certainly, you should limit the number of times it attempts.
To me something doesn't smell right here. Hmmm...
Embedded systems typically need to be extremely deterministic - perhaps you s... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | There are lots of good things in the other answers, but I did think it worth adding that if all the threads get in a similar loop, then the program will be deadlocked.
The "correct" answer to this situation is probably to have strict limits for the different parts of the program to ensure that they don't over consume ... | As others have mentioned, ideally, you would avoid this problem by up-front design and software architecture, but I’m assuming at this point that really isn’t an option.
As another post mentions, it would be good to wrap the logic in some utility functions so that you don’t end up writing the out-of-memory code all of... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | You are trying to solve a global problem through local reasoning. The global problem is that the entire device has a limited amount of RAM (and possibly backing store) for the operating system and all of the applications. To make sure this amount of RAM is not exceeded, you have a few options:
* Each process operates ... | You use C++. So you can make use of some C++ utilities to make your life easier. For example, why not use new\_handler?
```
void my_new_handler() {
// make room for memory, then return, or throw bad_alloc if
// nothing can be freed.
}
int main() {
std::set_new_handler(&my_new_handler);
// every alloc... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | I second that the most sensible thing to do is to use static allocation of memory, so you have some idea of what is going on. Dynamic memory allocation is a bad habit from desktop programming that is not suited on restricted-resource machines (unless you spend a fair bit of time and effort creating a good managed and c... | Surely it would depend on whether you have a reasonable expectation of memory becoming available in the 100 (millisecond?) sleep? Certainly, you should limit the number of times it attempts.
To me something doesn't smell right here. Hmmm...
Embedded systems typically need to be extremely deterministic - perhaps you s... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | Based on your question, I'm assuming that your heap is shared between multiple threads.
If it isn't then the code above won't work, because nothing will be freed from the heap while the loop is running.
If the heap is shared, then the above would probably work. However, if you have a shared heap, then calling "new" w... | Surely it would depend on whether you have a reasonable expectation of memory becoming available in the 100 (millisecond?) sleep? Certainly, you should limit the number of times it attempts.
To me something doesn't smell right here. Hmmm...
Embedded systems typically need to be extremely deterministic - perhaps you s... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | You use C++. So you can make use of some C++ utilities to make your life easier. For example, why not use new\_handler?
```
void my_new_handler() {
// make room for memory, then return, or throw bad_alloc if
// nothing can be freed.
}
int main() {
std::set_new_handler(&my_new_handler);
// every alloc... | Surely it would depend on whether you have a reasonable expectation of memory becoming available in the 100 (millisecond?) sleep? Certainly, you should limit the number of times it attempts.
To me something doesn't smell right here. Hmmm...
Embedded systems typically need to be extremely deterministic - perhaps you s... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | You are trying to solve a global problem through local reasoning. The global problem is that the entire device has a limited amount of RAM (and possibly backing store) for the operating system and all of the applications. To make sure this amount of RAM is not exceeded, you have a few options:
* Each process operates ... | As others have mentioned, ideally, you would avoid this problem by up-front design and software architecture, but I’m assuming at this point that really isn’t an option.
As another post mentions, it would be good to wrap the logic in some utility functions so that you don’t end up writing the out-of-memory code all of... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | You are trying to solve a global problem through local reasoning. The global problem is that the entire device has a limited amount of RAM (and possibly backing store) for the operating system and all of the applications. To make sure this amount of RAM is not exceeded, you have a few options:
* Each process operates ... | A few points:
* Embedded programs often allocate all memory at startup or use only static memory to avoid situations like this.
* Unless there is something else running on the device that frees memory on a regular basis your solution isn't likely to be effective.
* The Viper I have has 64MB RAM, I don't think they com... |
367,310 | I'm working on an embedded processor (400 MHz Intel PXA255 XScale), and I thought I saw one case where there wasn't enough memory to satisfy a 'new' operation. The program didn't crash, so I assumed other threads had freed their memory and it was just a transient thing. This is some pretty critical code, so exiting is ... | 2008/12/15 | [
"https://Stackoverflow.com/questions/367310",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/34910/"
] | You are trying to solve a global problem through local reasoning. The global problem is that the entire device has a limited amount of RAM (and possibly backing store) for the operating system and all of the applications. To make sure this amount of RAM is not exceeded, you have a few options:
* Each process operates ... | I second that the most sensible thing to do is to use static allocation of memory, so you have some idea of what is going on. Dynamic memory allocation is a bad habit from desktop programming that is not suited on restricted-resource machines (unless you spend a fair bit of time and effort creating a good managed and c... |
15,572,947 | I want to evaluate an instance of some class in a boolean context. Or to be clearer, i want to define how the object reacts if its used directly in a boolean context.
Here an example:
```
class Foo
{
int state;
Foo(): state(1) {}
bool checkState()
{
return (state >= 0);
}
void doWork()
{
/*... | 2013/03/22 | [
"https://Stackoverflow.com/questions/15572947",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2165729/"
] | Use an explicit conversion operator to bool:
```
explicit operator bool() const { return (state >= 0); }
```
This does *exactly* what you want: define what happens when the object is evaluated in a boolean context.
If you have an older compiler, you cannot use `explicit`, and that is bad because `operator bool()` (... | You can use `operator bool()`:
```
explicit operator bool() const
{
return (state >=0) ;
}
```
As pointed out you want to use `explicit` to prevent this being used in an integer context. Also [main should return an int](https://stackoverflow.com/questions/204476/what-should-main-return-in-c-c). |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | I think I know this one...
Try sending your JSON as JSON by using PHP's [header()](http://php.net/header/) function:
```
/**
* Send as JSON
*/
header("Content-Type: application/json", true);
```
Though you are passing valid JSON, jQuery's $.ajax doesn't think so because it's missing the header.
jQuery used to be... | Well, it might help someone. I was stupid enough to put `var_dump('testing');` in the function I was requesting JSON from to be sure the request was actually received. This obviously also echo's as part for the expected `json` response, and with `dataType` set to `json` defined, the request fails. |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | Try using jQuery.parseJSON when you get the data back.
```
type: "POST",
dataType: "json",
url: url,
data: { get_member: id },
success: function(data) {
response = jQuery.parseJSON(data);
$("input[ name = type ]:eq(" + response.type + " )")
.attr("checked", "checked");
$("input[ name = name ]").va... | If you are using a newer version (over 1.3.x) you should learn more about the function parseJSON! I experienced the same problem. Use an old version or change your code
```
success=function(data){
//something like this
jQuery.parseJSON(data)
}
``` |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | The `$.ajax` `error` function takes three arguments, not one:
```
error: function(xhr, status, thrown)
```
You need to dump the 2nd and 3rd parameters to find your cause, not the first one. | Well, it might help someone. I was stupid enough to put `var_dump('testing');` in the function I was requesting JSON from to be sure the request was actually received. This obviously also echo's as part for the expected `json` response, and with `dataType` set to `json` defined, the request fails. |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | The `$.ajax` `error` function takes three arguments, not one:
```
error: function(xhr, status, thrown)
```
You need to dump the 2nd and 3rd parameters to find your cause, not the first one. | ```
Try this...
<script type="text/javascript">
$(document).ready(function(){
$("#find").click(function(){
var username = $("#username").val();
$.ajax({
type: 'POST',
dataType: 'json',
url: 'includes/find.php',
data: 'username='+username... |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | In addition to McHerbie's note, try `json_encode( $json_arr, JSON_FORCE_OBJECT );` if you are on PHP 5.3... | ```
Try this...
<script type="text/javascript">
$(document).ready(function(){
$("#find").click(function(){
var username = $("#username").val();
$.ajax({
type: 'POST',
dataType: 'json',
url: 'includes/find.php',
data: 'username='+username... |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | Try using jQuery.parseJSON when you get the data back.
```
type: "POST",
dataType: "json",
url: url,
data: { get_member: id },
success: function(data) {
response = jQuery.parseJSON(data);
$("input[ name = type ]:eq(" + response.type + " )")
.attr("checked", "checked");
$("input[ name = name ]").va... | ```
Try this...
<script type="text/javascript">
$(document).ready(function(){
$("#find").click(function(){
var username = $("#username").val();
$.ajax({
type: 'POST',
dataType: 'json',
url: 'includes/find.php',
data: 'username='+username... |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | The `$.ajax` `error` function takes three arguments, not one:
```
error: function(xhr, status, thrown)
```
You need to dump the 2nd and 3rd parameters to find your cause, not the first one. | In addition to McHerbie's note, try `json_encode( $json_arr, JSON_FORCE_OBJECT );` if you are on PHP 5.3... |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | ```
session_start();
include('connection.php');
/* function msg($subjectname,$coursename,$sem)
{
return '{"subjectname":'.$subjectname.'"coursename":'.$coursename.'"sem":'.$sem.'}';
}*/
$title_id=$_POST['title_id'];
$result=mysql_query("SELECT * FROM `video` WHERE id='$title_id'") or die(mysql_error());... | If you are using a newer version (over 1.3.x) you should learn more about the function parseJSON! I experienced the same problem. Use an old version or change your code
```
success=function(data){
//something like this
jQuery.parseJSON(data)
}
``` |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | In addition to McHerbie's note, try `json_encode( $json_arr, JSON_FORCE_OBJECT );` if you are on PHP 5.3... | If you are using a newer version (over 1.3.x) you should learn more about the function parseJSON! I experienced the same problem. Use an old version or change your code
```
success=function(data){
//something like this
jQuery.parseJSON(data)
}
``` |
5,147,522 | I've been looking all over for the solution but I cannot find anything that works.
I am trying to get a bunch of data from the database and then via AJAX autocomplete input fields in a form. To do this I've decided to use json, because why not, right? Alternatively I've been thinking to just send back a delimited strin... | 2011/02/28 | [
"https://Stackoverflow.com/questions/5147522",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/638369/"
] | I think I know this one...
Try sending your JSON as JSON by using PHP's [header()](http://php.net/header/) function:
```
/**
* Send as JSON
*/
header("Content-Type: application/json", true);
```
Though you are passing valid JSON, jQuery's $.ajax doesn't think so because it's missing the header.
jQuery used to be... | In addition to McHerbie's note, try `json_encode( $json_arr, JSON_FORCE_OBJECT );` if you are on PHP 5.3... |
1,539,915 | Why does Swing `JComponent` class implement the interface `Serializable`? The way I've implemented my views, they are stateless, all the state data is stored in a Presentation Model. So I don't need to serialize my views. I've used a `@SuppressWarnings("serial")` annotation to remove the warnings. Are there better ways... | 2009/10/08 | [
"https://Stackoverflow.com/questions/1539915",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/56297/"
] | In the beginning GUI builders were going to save the UI in serialised format. The `applet` tag even has an attribute to load from serialised form (I don't know anyone else who has used that, and I've only used it to be malicious). Unfortunately using the serialisation mechanism for GUIs doesn't really work. Swing only ... | >
> Why does Swing JComponent class implement the interface Serializable?
>
>
>
Although this allows you to serialize classes and send them to and from the client and the server, this does not seem to be an intuitive scenario. There is a better chance, still slim, that someone might want to serialize components to... |
46,377,880 | i don't know much about `class` and their `member variables`.
What my doubt is, can we declare and initialize a member variable from another member variable in same class?
like this
```
class newClass {
private $variable1 = 'new1';
private $variable2 = $variable1.'new2';
}
```
If can't, please help me find... | 2017/09/23 | [
"https://Stackoverflow.com/questions/46377880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4049258/"
] | Always initialize member variable in constructor. You can assign dynamic value in constructor.
Try this code:
```
<?php
class newClass {
private $variable1 ;
private $variable2;
function __construct()
{
$this->variable1 = 'new1';
$this->variable2 = $this->variable1.'new2';
}
functio... | No. You can't do that.
What you could do instead is do the initialization in the constructor:
```
class Foo
{
private $a = 'something';
private $b;
public function __construct()
{
$this->b = $this->a . 'foobar';
}
}
```
Buuuut, this would actually be a somewhat questionable practice,... |
55,821,361 | I am trying to put together a useable set of data about glaciers. Our original data comes from an ArcGIS dataset, and latitude/longitude values were stored in a separate file, now detached from the CSV with all of our data. I am attempting to merge the latitude/longitude files with our data set. Heres a preview of what... | 2019/04/24 | [
"https://Stackoverflow.com/questions/55821361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5352542/"
] | On the form parent of the input elements (add one if there isnt one already) add this `autocomplete='off'` and then on the inputs add `autocomplete='false'`.
And to answer your question, 'can individual fields be disabled without the whole form' Yes. But you would need to add another form onto the child element.
Che... | autocomplete="off" is the right solution. In your case I think there is some problem with Chrome browser. Update chrome or reinstall. That might solve your problem. |
55,821,361 | I am trying to put together a useable set of data about glaciers. Our original data comes from an ArcGIS dataset, and latitude/longitude values were stored in a separate file, now detached from the CSV with all of our data. I am attempting to merge the latitude/longitude files with our data set. Heres a preview of what... | 2019/04/24 | [
"https://Stackoverflow.com/questions/55821361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5352542/"
] | On the form parent of the input elements (add one if there isnt one already) add this `autocomplete='off'` and then on the inputs add `autocomplete='false'`.
And to answer your question, 'can individual fields be disabled without the whole form' Yes. But you would need to add another form onto the child element.
Che... | You can deactivate the autocomplete with `autocomplete="new-password"`
`autocomplete="off"` or `autocomplete="false"` is not working anymore |
55,821,361 | I am trying to put together a useable set of data about glaciers. Our original data comes from an ArcGIS dataset, and latitude/longitude values were stored in a separate file, now detached from the CSV with all of our data. I am attempting to merge the latitude/longitude files with our data set. Heres a preview of what... | 2019/04/24 | [
"https://Stackoverflow.com/questions/55821361",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5352542/"
] | You can deactivate the autocomplete with `autocomplete="new-password"`
`autocomplete="off"` or `autocomplete="false"` is not working anymore | autocomplete="off" is the right solution. In your case I think there is some problem with Chrome browser. Update chrome or reinstall. That might solve your problem. |
4,238,058 | When answering general topology questions which ask to show a statement is true, I struggle to be able to formulate a sufficient proof, linking the information I know together. As the title is put, this particular question asks me to 'show that the only dense subset of $\mathbb{Z}$ is $\mathbb{Z}$' and to consider '$\m... | 2021/09/01 | [
"https://math.stackexchange.com/questions/4238058",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/962766/"
] | Your proof is incomplete, because it is false that the existence of a $x\in\Bbb Z\setminus B$ is incompatible with the fact that $B$ is dense. It is true in your case, but you did not explain why. But, for instance, $\Bbb Q$ is dense in $\Bbb R$ (with respect to the usual distance), in spite of the fact that $\sqrt2\in... | Let $A$ dense in $\Bbb Z$, then $\Bbb Z =\bar A = A$ |
244,957 | I want to get a list of products from only pending orders!
i have this is code but works only for register customers i need to show product for all orders even for guests and multi store.
```
<?php
require_once 'app/Mage.php';
Mage::app();
//Get All Users/Customers
$users = mage::getModel('customer/customer')->getColl... | 2018/10/03 | [
"https://magento.stackexchange.com/questions/244957",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/65887/"
] | For anyone seeing this error recurring and having to di:compile and rm -rf generated their way out of it repeatedly, check your layout XML files for any blocks using an Abstract class.
In my case, I had used:
```
class="Magento\Catalog\Block\Product\View\AbstractView"
```
When it should have just been:
```
class="... | please replace your consturct code in below file **/home1/dukaania/public\_html/testing2/app/code/Sugarcode/Test/Model/Total/Fee.php**
```
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Sugarcode\Test\Model\Total\FeeFactory $feeFactor... |
244,957 | I want to get a list of products from only pending orders!
i have this is code but works only for register customers i need to show product for all orders even for guests and multi store.
```
<?php
require_once 'app/Mage.php';
Mage::app();
//Get All Users/Customers
$users = mage::getModel('customer/customer')->getColl... | 2018/10/03 | [
"https://magento.stackexchange.com/questions/244957",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/65887/"
] | This issue is particularly related to the optional parameter that you are setting in the `public function __construct`.
In this particular case the original constructor parameters are like this (which is incorrect and not allowed anymore):
```
public function __construct(
\Magento\Framework\Model\Context $con... | please replace your consturct code in below file **/home1/dukaania/public\_html/testing2/app/code/Sugarcode/Test/Model/Total/Fee.php**
```
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Sugarcode\Test\Model\Total\FeeFactory $feeFactor... |
244,957 | I want to get a list of products from only pending orders!
i have this is code but works only for register customers i need to show product for all orders even for guests and multi store.
```
<?php
require_once 'app/Mage.php';
Mage::app();
//Get All Users/Customers
$users = mage::getModel('customer/customer')->getColl... | 2018/10/03 | [
"https://magento.stackexchange.com/questions/244957",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/65887/"
] | For anyone seeing this error recurring and having to di:compile and rm -rf generated their way out of it repeatedly, check your layout XML files for any blocks using an Abstract class.
In my case, I had used:
```
class="Magento\Catalog\Block\Product\View\AbstractView"
```
When it should have just been:
```
class="... | Please replace your this "Sugarcode/Test/Model/Total/Fee.php" model file function \_construct.
```
protected function _construct()
{
$this->_init('Sugarcode\Test\Model\ResourceModel\Fee');
}
```
and check after that. |
244,957 | I want to get a list of products from only pending orders!
i have this is code but works only for register customers i need to show product for all orders even for guests and multi store.
```
<?php
require_once 'app/Mage.php';
Mage::app();
//Get All Users/Customers
$users = mage::getModel('customer/customer')->getColl... | 2018/10/03 | [
"https://magento.stackexchange.com/questions/244957",
"https://magento.stackexchange.com",
"https://magento.stackexchange.com/users/65887/"
] | This issue is particularly related to the optional parameter that you are setting in the `public function __construct`.
In this particular case the original constructor parameters are like this (which is incorrect and not allowed anymore):
```
public function __construct(
\Magento\Framework\Model\Context $con... | Please replace your this "Sugarcode/Test/Model/Total/Fee.php" model file function \_construct.
```
protected function _construct()
{
$this->_init('Sugarcode\Test\Model\ResourceModel\Fee');
}
```
and check after that. |
5,195,419 | I have some xml like this:
```
<animal name="Bow Wow" type="dog">
<birthDate>May 17,2001</birthDate>
<descirption>Bla bla bla bla</description>
</animal>
```
The xml is being processed and displayed on the screen.
I need to provide a longer multi-paragraph description of the dog but I am running into some... | 2011/03/04 | [
"https://Stackoverflow.com/questions/5195419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/251589/"
] | static can be a little confusing because of its slightly different meaning depending upon where it is used.
A static variable, declared globally, will only be visible in that source file.
A static variable, declared locally, will keep its value over successive calls to that function (as in netrom's example)
A static... | The static keyword specifies that the life-time of the given the variable, function or class is application-wide. Like having a single instance.
This example might illustrate it:
```
#include <iostream>
using namespace std;
void test() {
static int i = 123;
if (i == 123) {
i = 321;
}
cout << i << endl;
}... |
5,195,419 | I have some xml like this:
```
<animal name="Bow Wow" type="dog">
<birthDate>May 17,2001</birthDate>
<descirption>Bla bla bla bla</description>
</animal>
```
The xml is being processed and displayed on the screen.
I need to provide a longer multi-paragraph description of the dog but I am running into some... | 2011/03/04 | [
"https://Stackoverflow.com/questions/5195419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/251589/"
] | The static keyword specifies that the life-time of the given the variable, function or class is application-wide. Like having a single instance.
This example might illustrate it:
```
#include <iostream>
using namespace std;
void test() {
static int i = 123;
if (i == 123) {
i = 321;
}
cout << i << endl;
}... | >
>
> >
> > why do we have to declare static in class and then assign the value outside the class!!!
> >
> >
> >
>
>
>
Because it's merely DECLARED in the class, it is not DEFINED.
The class declaration is merely a description of the class, no memory is allocated until of object of that class is defined.
... |
5,195,419 | I have some xml like this:
```
<animal name="Bow Wow" type="dog">
<birthDate>May 17,2001</birthDate>
<descirption>Bla bla bla bla</description>
</animal>
```
The xml is being processed and displayed on the screen.
I need to provide a longer multi-paragraph description of the dog but I am running into some... | 2011/03/04 | [
"https://Stackoverflow.com/questions/5195419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/251589/"
] | static can be a little confusing because of its slightly different meaning depending upon where it is used.
A static variable, declared globally, will only be visible in that source file.
A static variable, declared locally, will keep its value over successive calls to that function (as in netrom's example)
A static... | >
>
> >
> > why do we have to declare static in class and then assign the value outside the class!!!
> >
> >
> >
>
>
>
Because it's merely DECLARED in the class, it is not DEFINED.
The class declaration is merely a description of the class, no memory is allocated until of object of that class is defined.
... |
89,452 | Just wondering following from [this](https://scifi.stackexchange.com/questions/31796/do-droids-have-consciousness) and [this](https://scifi.stackexchange.com/questions/71582/are-the-b1-battle-droids-in-star-wars-self-aware?lq=1) question, do we actually ever see (or have evidence of) Jedi successfully (or even attempti... | 2015/05/10 | [
"https://scifi.stackexchange.com/questions/89452",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/22917/"
] | In the Star Wars novel *The Truce at Bakura*, Luke Skywalker is able to extract a deadly parasite he was poisoned with with from his lungs using the Force. In the Clone Wars cartoon series, several of the Jedi Masters are able to dismantle droids and use their nuts and bolts to rip through them.
A Jedi cannot manipula... | Droids dont have a conscious mind. I think its common knowledge that robots have computers, not brains. It is shown throught the series that ind tricks only work on the weak MINDED. This is shown when Luke attempts a mind trick on Jabba The Hut. You could see an example prooving this too when Ben Kenobi tricked the Sto... |
89,452 | Just wondering following from [this](https://scifi.stackexchange.com/questions/31796/do-droids-have-consciousness) and [this](https://scifi.stackexchange.com/questions/71582/are-the-b1-battle-droids-in-star-wars-self-aware?lq=1) question, do we actually ever see (or have evidence of) Jedi successfully (or even attempti... | 2015/05/10 | [
"https://scifi.stackexchange.com/questions/89452",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/22917/"
] | In the Star Wars novel *The Truce at Bakura*, Luke Skywalker is able to extract a deadly parasite he was poisoned with with from his lungs using the Force. In the Clone Wars cartoon series, several of the Jedi Masters are able to dismantle droids and use their nuts and bolts to rip through them.
A Jedi cannot manipula... | Droids can be Jedi as seen in the comic *Skippy the Jedi Droid*, therefore, that makes droids one with the force just as all living things. So I think a Jedi mind trick could work on a droid |
89,452 | Just wondering following from [this](https://scifi.stackexchange.com/questions/31796/do-droids-have-consciousness) and [this](https://scifi.stackexchange.com/questions/71582/are-the-b1-battle-droids-in-star-wars-self-aware?lq=1) question, do we actually ever see (or have evidence of) Jedi successfully (or even attempti... | 2015/05/10 | [
"https://scifi.stackexchange.com/questions/89452",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/22917/"
] | In the Star Wars novel *The Truce at Bakura*, Luke Skywalker is able to extract a deadly parasite he was poisoned with with from his lungs using the Force. In the Clone Wars cartoon series, several of the Jedi Masters are able to dismantle droids and use their nuts and bolts to rip through them.
A Jedi cannot manipula... | Yes. In the (canon) junior novelisation for Return of the Jedi, we see Luke tricking the [TT-8L gate guard droid](https://starwars.fandom.com/wiki/TT-8L/Y7_gatekeeper_droid) with mind powers.
>
> The way in turns out to be easy enough. An electronic eyeball barely
> has time to pop out before Luke has said, “You will... |
89,452 | Just wondering following from [this](https://scifi.stackexchange.com/questions/31796/do-droids-have-consciousness) and [this](https://scifi.stackexchange.com/questions/71582/are-the-b1-battle-droids-in-star-wars-self-aware?lq=1) question, do we actually ever see (or have evidence of) Jedi successfully (or even attempti... | 2015/05/10 | [
"https://scifi.stackexchange.com/questions/89452",
"https://scifi.stackexchange.com",
"https://scifi.stackexchange.com/users/22917/"
] | In the Star Wars novel *The Truce at Bakura*, Luke Skywalker is able to extract a deadly parasite he was poisoned with with from his lungs using the Force. In the Clone Wars cartoon series, several of the Jedi Masters are able to dismantle droids and use their nuts and bolts to rip through them.
A Jedi cannot manipula... | Legends: Yes, by another name
-----------------------------
In Legends, a Force ability was known by the name of "[mechu-deru](https://starwars.fandom.com/wiki/Mechu-deru)" that allowed the user to not only influence droids, but to control or reprogram them entirely. From a now-deleted Hyperspace article on starwars.c... |
11,533,613 | Halo, the first i want to know the idle time at my android application. after that, i will do something if it is a idle time mode.
I follow this link.
[Application idle time](https://stackoverflow.com/questions/4075180/application-idle-time)
my program work properly, but suddenly the problem show up. I can't move to ... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11533613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1533435/"
] | Like this:
```
responseData[0].diccioDatosForm.errorMessage
```
`responseData` itself is an array contains of 2 elements | It is because you are alerting the array that is being returned.
To access the field you want, you should do:
```
responseData[0].diccioDatosForm.diccioDatosForm
```
I know that what I will say is not part of your question, but I suggest that you review your JSON structure, because its strange to have an array of tw... |
11,533,613 | Halo, the first i want to know the idle time at my android application. after that, i will do something if it is a idle time mode.
I follow this link.
[Application idle time](https://stackoverflow.com/questions/4075180/application-idle-time)
my program work properly, but suddenly the problem show up. I can't move to ... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11533613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1533435/"
] | Like this:
```
responseData[0].diccioDatosForm.errorMessage
```
`responseData` itself is an array contains of 2 elements | It looks like you're trying to find the value of a parameter that's in an object that's the first element of an array in your JSON. In plain Javascript, that means:
```
var data = [{"diccioDatosForm": {"errorMessage": /* ... */]
// grab diccioDatosForm from first array element:
var diccioDatosForm = data[0].diccioDat... |
11,533,613 | Halo, the first i want to know the idle time at my android application. after that, i will do something if it is a idle time mode.
I follow this link.
[Application idle time](https://stackoverflow.com/questions/4075180/application-idle-time)
my program work properly, but suddenly the problem show up. I can't move to ... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11533613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1533435/"
] | Like this:
```
responseData[0].diccioDatosForm.errorMessage
```
`responseData` itself is an array contains of 2 elements | Your `responseData` object is an array with objects within. As a result you must use an index when referencing the internal objects.
```
responseData[0].diccioDatosForm.errorMessage
``` |
11,533,613 | Halo, the first i want to know the idle time at my android application. after that, i will do something if it is a idle time mode.
I follow this link.
[Application idle time](https://stackoverflow.com/questions/4075180/application-idle-time)
my program work properly, but suddenly the problem show up. I can't move to ... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11533613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1533435/"
] | Your `responseData` object is an array with objects within. As a result you must use an index when referencing the internal objects.
```
responseData[0].diccioDatosForm.errorMessage
``` | It is because you are alerting the array that is being returned.
To access the field you want, you should do:
```
responseData[0].diccioDatosForm.diccioDatosForm
```
I know that what I will say is not part of your question, but I suggest that you review your JSON structure, because its strange to have an array of tw... |
11,533,613 | Halo, the first i want to know the idle time at my android application. after that, i will do something if it is a idle time mode.
I follow this link.
[Application idle time](https://stackoverflow.com/questions/4075180/application-idle-time)
my program work properly, but suddenly the problem show up. I can't move to ... | 2012/07/18 | [
"https://Stackoverflow.com/questions/11533613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1533435/"
] | Your `responseData` object is an array with objects within. As a result you must use an index when referencing the internal objects.
```
responseData[0].diccioDatosForm.errorMessage
``` | It looks like you're trying to find the value of a parameter that's in an object that's the first element of an array in your JSON. In plain Javascript, that means:
```
var data = [{"diccioDatosForm": {"errorMessage": /* ... */]
// grab diccioDatosForm from first array element:
var diccioDatosForm = data[0].diccioDat... |
69,597,781 | So, I'm working in this project with a professor. As of now, it encompasses several own-made packages and modules. I sent him a .rar file with the whole project for revision, which he readily opened up in his pc using Spyder (the same IDE I use). We jointly made some corrections to it over a videocall, after which he s... | 2021/10/16 | [
"https://Stackoverflow.com/questions/69597781",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16734032/"
] | (*Spyder maintainer here*) I'm sorry for the inconveniences this could have caused you. This was a bug in Spyder and it was fixed in our **5.1.5** version. | First: I saw on Stackoverflow many questions with similar problem and if you would use Google `UnicodeDecodeError: 'utf-8' codec can't decode byte` then you should find them few hours ago and you could resolve this problem few hours ago - without asking question.
---
Error shows problem with `0xe9` - if I run `b'\xe9... |
23,967,843 | This is very tricky for me.
Given a very long list,
>
> [[100,11,1,0,40,1],[100,12,3,1,22,23],[101,11,1,0,45,1],[101,12,3,1,28,30],[102,11,1,0,50,1],[102,12,3,1,50,50],[103,11,1,0,50,1],[103,12,3,1,50,50],[104,11,1,0,50,25],[104,12,3,1,50,50],[105,11,1,0,50,49],[105,12,3,0,30,30],[106,11,1,0,50,49],[106,12,3,0,25,26... | 2014/05/31 | [
"https://Stackoverflow.com/questions/23967843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3689497/"
] | If you need to compact a list by merging all items with same tail, try this code.
```
compactList:: [[Int]] -> [[Int]]
compactList list = reverse $ compactList' list []
compactList':: [[Int]] -> [[Int]] -> [[Int]]
compactList' [] res = res
compactList' (l:ls) res
| inList l res
= compactList' ls res
| ot... | You can just find the Euclidian distance between 2 vectors. For example, if you have two lists [a0, a1, ... , an] and [b0, b1, ..., bn], then the square of the Euclidian distance between them would be
```
sum [ (a - b) ^ 2 | (a, b) <- zip as bs ]
```
This can give you an idea of how *close* one list is to another. ... |
23,967,843 | This is very tricky for me.
Given a very long list,
>
> [[100,11,1,0,40,1],[100,12,3,1,22,23],[101,11,1,0,45,1],[101,12,3,1,28,30],[102,11,1,0,50,1],[102,12,3,1,50,50],[103,11,1,0,50,1],[103,12,3,1,50,50],[104,11,1,0,50,25],[104,12,3,1,50,50],[105,11,1,0,50,49],[105,12,3,0,30,30],[106,11,1,0,50,49],[106,12,3,0,25,26... | 2014/05/31 | [
"https://Stackoverflow.com/questions/23967843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3689497/"
] | From your description, I take it you want to get a list of the last lists to possess each of the unique tails. You can do it like this:
```
lastUniqueByTail :: Eq a => [[a]] -> [[a]]
lastUniqueByTail = reverse . nubBy ((==) `on` tail) . reverse
```
***Note*** this only works for finite lists of non-empty lists
You... | You can just find the Euclidian distance between 2 vectors. For example, if you have two lists [a0, a1, ... , an] and [b0, b1, ..., bn], then the square of the Euclidian distance between them would be
```
sum [ (a - b) ^ 2 | (a, b) <- zip as bs ]
```
This can give you an idea of how *close* one list is to another. ... |
23,967,843 | This is very tricky for me.
Given a very long list,
>
> [[100,11,1,0,40,1],[100,12,3,1,22,23],[101,11,1,0,45,1],[101,12,3,1,28,30],[102,11,1,0,50,1],[102,12,3,1,50,50],[103,11,1,0,50,1],[103,12,3,1,50,50],[104,11,1,0,50,25],[104,12,3,1,50,50],[105,11,1,0,50,49],[105,12,3,0,30,30],[106,11,1,0,50,49],[106,12,3,0,25,26... | 2014/05/31 | [
"https://Stackoverflow.com/questions/23967843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3689497/"
] | From your description, I take it you want to get a list of the last lists to possess each of the unique tails. You can do it like this:
```
lastUniqueByTail :: Eq a => [[a]] -> [[a]]
lastUniqueByTail = reverse . nubBy ((==) `on` tail) . reverse
```
***Note*** this only works for finite lists of non-empty lists
You... | If you need to compact a list by merging all items with same tail, try this code.
```
compactList:: [[Int]] -> [[Int]]
compactList list = reverse $ compactList' list []
compactList':: [[Int]] -> [[Int]] -> [[Int]]
compactList' [] res = res
compactList' (l:ls) res
| inList l res
= compactList' ls res
| ot... |
55,808 | It is quite well known that the airplane hijackers on 9/11 were not professional pilots. So, my question is how some people who didn't have any experience of navigating the airplanes could find their way, for example from Boston to New York City?
I read somewhere that some natural signs like the Hudson River (for exam... | 2018/10/07 | [
"https://aviation.stackexchange.com/questions/55808",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/34754/"
] | Several of the hijackers, including [Mohamed Atta](https://en.wikipedia.org/wiki/Mohamed_Atta), held at least private pilot certificates and had undergone ATP level jet training in DC9 and 737 full motion simulators in December of 2000. Atta himself held a commercial license with instrument and multi engine ratings. Th... | All of the hijacked flights were going in different directions and had to be piloted to a different destination. The hijacker pilots had different degrees of success in doing this. The flight paths they took are shown in this map [published by the FBI](https://archives.fbi.gov/archives/about-us/ten-years-after-the-fbi-... |
55,808 | It is quite well known that the airplane hijackers on 9/11 were not professional pilots. So, my question is how some people who didn't have any experience of navigating the airplanes could find their way, for example from Boston to New York City?
I read somewhere that some natural signs like the Hudson River (for exam... | 2018/10/07 | [
"https://aviation.stackexchange.com/questions/55808",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/34754/"
] | Several of the hijackers, including [Mohamed Atta](https://en.wikipedia.org/wiki/Mohamed_Atta), held at least private pilot certificates and had undergone ATP level jet training in DC9 and 737 full motion simulators in December of 2000. Atta himself held a commercial license with instrument and multi engine ratings. Th... | The Hudson River will take you straight to Manhattan. On a clear day, such as September 11 was, you could see the WTC for 100 miles or more (I had seen it from 160 miles away at Montauk Point on clear days, but you had to know where to look).
AA77 would have had a problem navigating eastbound with such an amateur as H... |
55,808 | It is quite well known that the airplane hijackers on 9/11 were not professional pilots. So, my question is how some people who didn't have any experience of navigating the airplanes could find their way, for example from Boston to New York City?
I read somewhere that some natural signs like the Hudson River (for exam... | 2018/10/07 | [
"https://aviation.stackexchange.com/questions/55808",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/34754/"
] | Several of the hijackers, including [Mohamed Atta](https://en.wikipedia.org/wiki/Mohamed_Atta), held at least private pilot certificates and had undergone ATP level jet training in DC9 and 737 full motion simulators in December of 2000. Atta himself held a commercial license with instrument and multi engine ratings. Th... | [The 9/11 Commission Report](https://www.9-11commission.gov/report/911Report.pdf) goes into some detail on the hijackers' planning and preparation, including a (not entirely successful) attempt to obtain aviation GPS units:
>
> Moussaoui also purchased two knives and inquired of two manufacturers of GPS equipment whe... |
55,808 | It is quite well known that the airplane hijackers on 9/11 were not professional pilots. So, my question is how some people who didn't have any experience of navigating the airplanes could find their way, for example from Boston to New York City?
I read somewhere that some natural signs like the Hudson River (for exam... | 2018/10/07 | [
"https://aviation.stackexchange.com/questions/55808",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/34754/"
] | All of the hijacked flights were going in different directions and had to be piloted to a different destination. The hijacker pilots had different degrees of success in doing this. The flight paths they took are shown in this map [published by the FBI](https://archives.fbi.gov/archives/about-us/ten-years-after-the-fbi-... | The Hudson River will take you straight to Manhattan. On a clear day, such as September 11 was, you could see the WTC for 100 miles or more (I had seen it from 160 miles away at Montauk Point on clear days, but you had to know where to look).
AA77 would have had a problem navigating eastbound with such an amateur as H... |
55,808 | It is quite well known that the airplane hijackers on 9/11 were not professional pilots. So, my question is how some people who didn't have any experience of navigating the airplanes could find their way, for example from Boston to New York City?
I read somewhere that some natural signs like the Hudson River (for exam... | 2018/10/07 | [
"https://aviation.stackexchange.com/questions/55808",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/34754/"
] | All of the hijacked flights were going in different directions and had to be piloted to a different destination. The hijacker pilots had different degrees of success in doing this. The flight paths they took are shown in this map [published by the FBI](https://archives.fbi.gov/archives/about-us/ten-years-after-the-fbi-... | [The 9/11 Commission Report](https://www.9-11commission.gov/report/911Report.pdf) goes into some detail on the hijackers' planning and preparation, including a (not entirely successful) attempt to obtain aviation GPS units:
>
> Moussaoui also purchased two knives and inquired of two manufacturers of GPS equipment whe... |
55,808 | It is quite well known that the airplane hijackers on 9/11 were not professional pilots. So, my question is how some people who didn't have any experience of navigating the airplanes could find their way, for example from Boston to New York City?
I read somewhere that some natural signs like the Hudson River (for exam... | 2018/10/07 | [
"https://aviation.stackexchange.com/questions/55808",
"https://aviation.stackexchange.com",
"https://aviation.stackexchange.com/users/34754/"
] | [The 9/11 Commission Report](https://www.9-11commission.gov/report/911Report.pdf) goes into some detail on the hijackers' planning and preparation, including a (not entirely successful) attempt to obtain aviation GPS units:
>
> Moussaoui also purchased two knives and inquired of two manufacturers of GPS equipment whe... | The Hudson River will take you straight to Manhattan. On a clear day, such as September 11 was, you could see the WTC for 100 miles or more (I had seen it from 160 miles away at Montauk Point on clear days, but you had to know where to look).
AA77 would have had a problem navigating eastbound with such an amateur as H... |
70,417,075 | I was creating a war game and I have this dictionary of weapons and the damage they do on another type of troops.
also, I have a list which has the keys from the dictionary stored in it.
```
weapon_specs = {
'rifle': {'air': 1, 'ground': 2, 'human': 5},
'pistol': {'air': 0, 'ground': 1, 'human': 3},
'rpg': {'air':... | 2021/12/20 | [
"https://Stackoverflow.com/questions/70417075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17411307/"
] | You can use `collections.Counter`:
```
from collections import Counter
count = Counter()
for counter in [weapon_specs[weapon] for weapon in inv]:
count += counter
out = dict(count)
```
If you don't want to use `collections` library, you can also do:
```
out = {}
for weapon in inv:
for k,v in weapon_specs[we... | Without having to import anything. You can just map the dictionary with two loops.
```
out = {'air': 0, 'ground': 0, 'human': 0}
for weapon in inv:
for k, v in weapon_specs[weapon].items():
out[k] += v
print(out)
```
Output:
```
{'air': 4, 'ground': 6, 'human': 18}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.