qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
645,303
**How should I design a "Proper" OO Pong?** The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle". The two more pressing questions, right now, are: * Who checks for colissions? and * ...
2009/03/14
[ "https://Stackoverflow.com/questions/645303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77542/" ]
I imagine you could make a physics engine object that you update continuously at given time intervals. It would check for collisions, move the ball, compute bounce angles, etc. EDIT #1: To add a little more detail, the "game physics" object would store, among other things, references to other game objects like the bal...
Seems to me like the court would be the appropriate object to do the checking, or depending on how complex the logic is, a separate class for dealing with collisions (i.e. some kind of physics engine like gnovice said). The balls and paddles shouldn't have to know about each other since they're not directly related i...
645,303
**How should I design a "Proper" OO Pong?** The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle". The two more pressing questions, right now, are: * Who checks for colissions? and * ...
2009/03/14
[ "https://Stackoverflow.com/questions/645303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77542/" ]
I imagine you could make a physics engine object that you update continuously at given time intervals. It would check for collisions, move the ball, compute bounce angles, etc. EDIT #1: To add a little more detail, the "game physics" object would store, among other things, references to other game objects like the bal...
In a typical setting like this. Each object gets a chance to respond to the event of colliding with every other object they happen to be interacting with. In some kind of psuedo(python)code: ``` class Moveable: def Update(self): self.move() class Ball(Moveable): def Collide(self, target): ...
645,303
**How should I design a "Proper" OO Pong?** The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle". The two more pressing questions, right now, are: * Who checks for colissions? and * ...
2009/03/14
[ "https://Stackoverflow.com/questions/645303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77542/" ]
I imagine you could make a physics engine object that you update continuously at given time intervals. It would check for collisions, move the ball, compute bounce angles, etc. EDIT #1: To add a little more detail, the "game physics" object would store, among other things, references to other game objects like the bal...
I like to use Model-View-Controller methodology so in that case you would have a game controller that would handle controlling the collision but in drilling down it would just be controlling a controller... it's way too complicated to explain here and I'm not that smart so check it: <http://en.wikipedia.org/wiki/Model...
645,303
**How should I design a "Proper" OO Pong?** The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle". The two more pressing questions, right now, are: * Who checks for colissions? and * ...
2009/03/14
[ "https://Stackoverflow.com/questions/645303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77542/" ]
Seems to me like the court would be the appropriate object to do the checking, or depending on how complex the logic is, a separate class for dealing with collisions (i.e. some kind of physics engine like gnovice said). The balls and paddles shouldn't have to know about each other since they're not directly related i...
In a typical setting like this. Each object gets a chance to respond to the event of colliding with every other object they happen to be interacting with. In some kind of psuedo(python)code: ``` class Moveable: def Update(self): self.move() class Ball(Moveable): def Collide(self, target): ...
645,303
**How should I design a "Proper" OO Pong?** The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle". The two more pressing questions, right now, are: * Who checks for colissions? and * ...
2009/03/14
[ "https://Stackoverflow.com/questions/645303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77542/" ]
Seems to me like the court would be the appropriate object to do the checking, or depending on how complex the logic is, a separate class for dealing with collisions (i.e. some kind of physics engine like gnovice said). The balls and paddles shouldn't have to know about each other since they're not directly related i...
I like to use Model-View-Controller methodology so in that case you would have a game controller that would handle controlling the collision but in drilling down it would just be controlling a controller... it's way too complicated to explain here and I'm not that smart so check it: <http://en.wikipedia.org/wiki/Model...
645,303
**How should I design a "Proper" OO Pong?** The idea of Proper being that any element can be changed: The shape of the ball, the court, and the paddles, adding obstacles, and even "powerups", like "can stick the ball to the paddle". The two more pressing questions, right now, are: * Who checks for colissions? and * ...
2009/03/14
[ "https://Stackoverflow.com/questions/645303", "https://Stackoverflow.com", "https://Stackoverflow.com/users/77542/" ]
In a typical setting like this. Each object gets a chance to respond to the event of colliding with every other object they happen to be interacting with. In some kind of psuedo(python)code: ``` class Moveable: def Update(self): self.move() class Ball(Moveable): def Collide(self, target): ...
I like to use Model-View-Controller methodology so in that case you would have a game controller that would handle controlling the collision but in drilling down it would just be controlling a controller... it's way too complicated to explain here and I'm not that smart so check it: <http://en.wikipedia.org/wiki/Model...
33,765,939
I'm learning Laravel 5 and trying to validate if an email exists in database yet then add some custom message if it fails. I found the After Validation Hook in Laravel's documentation ``` $validator = Validator::make(...); $validator->after(function($validator) use ($email) { if (emailExist($email)) { $va...
2015/11/17
[ "https://Stackoverflow.com/questions/33765939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2945428/" ]
The point of the first method is just to keep everything contained inside of that `Validator` object to make it more reusable. Yes, in your case it does the exact same thing. But imagine if you wanted to validate multiple items. ```php foreach ($inputs as $input) { $validator->setData($input); if ($validator...
There may be many scenarios where you may feel it's requirement. Just assume that you are trying to build REST api for a project. And you have decided that update request method will not have any required rule validation for any field in request (as there maybe many parameters and you do not want to pass them all jus...
33,765,939
I'm learning Laravel 5 and trying to validate if an email exists in database yet then add some custom message if it fails. I found the After Validation Hook in Laravel's documentation ``` $validator = Validator::make(...); $validator->after(function($validator) use ($email) { if (emailExist($email)) { $va...
2015/11/17
[ "https://Stackoverflow.com/questions/33765939", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2945428/" ]
The point of the first method is just to keep everything contained inside of that `Validator` object to make it more reusable. Yes, in your case it does the exact same thing. But imagine if you wanted to validate multiple items. ```php foreach ($inputs as $input) { $validator->setData($input); if ($validator...
`passedValidation` method will trigger if the validation passes in FormRequest class. Actually this method is rename of `afterValidation` method. [See: method rename Commit](https://github.com/laravel/framework/commit/38b124676a209304310f081d1a077d475ce45f0f#diff-5e7ee98f50ffbd604860bb7a6fc526c81862c2c362c03541b478e27a...
41,479,661
``` SELECT Column1 FROM Table1 WHERE PKColumn = SomeValue ``` I am selecting just *one* column, my query will return only 0 or 1 row for sure. I want to select some default values like `Some Default` if no row returned otherwise the returned value. I tried something like ``` SELECT CASE WHEN COUNT(1) = 1 THEN Co...
2017/01/05
[ "https://Stackoverflow.com/questions/41479661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3664659/" ]
I think you can use a query like this: ``` SELECT TOP(1) CASE WHEN EXISTS(SELECT 1 FROM t WHERE PKColumn = SomeValue) THEN Column1 ELSE 'Some Default' END AS Column1 FROM t; ``` --- Or using `EXISTS` with `UNION`: ``` SELECT 'Some Default' As Column1 WHERE NOT EXISTS(SELECT 1 FROM t WHERE PKColumn =...
``` SELECT [Column1] = ISNULL([t2].[Column1], 'Some Default') FROM [Table1] AS [t1] OUTER APPLY ( SELECT [Column1] FROM [Table1] WHERE [PKColumn] = [t1].[PKColumn] ) AS [t2] WHERE [t1].[PKC...
41,479,661
``` SELECT Column1 FROM Table1 WHERE PKColumn = SomeValue ``` I am selecting just *one* column, my query will return only 0 or 1 row for sure. I want to select some default values like `Some Default` if no row returned otherwise the returned value. I tried something like ``` SELECT CASE WHEN COUNT(1) = 1 THEN Co...
2017/01/05
[ "https://Stackoverflow.com/questions/41479661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3664659/" ]
You can use `COALESCE` > > Evaluates the arguments in order and returns the current value of the > first expression that initially does not evaluate to NULL. > > > ``` SELECT COALESCE((SELECT TOP 1 Column1 FROM Table1 WHERE PK = SomeValue), 'DefaultValue') ``` or like this: ``` DECLARE @ReturnValue INT = 3 --...
``` SELECT [Column1] = ISNULL([t2].[Column1], 'Some Default') FROM [Table1] AS [t1] OUTER APPLY ( SELECT [Column1] FROM [Table1] WHERE [PKColumn] = [t1].[PKColumn] ) AS [t2] WHERE [t1].[PKC...
41,479,661
``` SELECT Column1 FROM Table1 WHERE PKColumn = SomeValue ``` I am selecting just *one* column, my query will return only 0 or 1 row for sure. I want to select some default values like `Some Default` if no row returned otherwise the returned value. I tried something like ``` SELECT CASE WHEN COUNT(1) = 1 THEN Co...
2017/01/05
[ "https://Stackoverflow.com/questions/41479661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3664659/" ]
I think you can use a query like this: ``` SELECT TOP(1) CASE WHEN EXISTS(SELECT 1 FROM t WHERE PKColumn = SomeValue) THEN Column1 ELSE 'Some Default' END AS Column1 FROM t; ``` --- Or using `EXISTS` with `UNION`: ``` SELECT 'Some Default' As Column1 WHERE NOT EXISTS(SELECT 1 FROM t WHERE PKColumn =...
Perhaps can try using LEN instead of COUNT to check if Column1 has value? ``` SELECT CASE WHEN LEN(Column1) > 0 THEN Column1 ELSE 'Some Default' END AS Column1 FROM Table1 WHERE PKColumn = SomeValue GROUP BY Column1 ```
41,479,661
``` SELECT Column1 FROM Table1 WHERE PKColumn = SomeValue ``` I am selecting just *one* column, my query will return only 0 or 1 row for sure. I want to select some default values like `Some Default` if no row returned otherwise the returned value. I tried something like ``` SELECT CASE WHEN COUNT(1) = 1 THEN Co...
2017/01/05
[ "https://Stackoverflow.com/questions/41479661", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3664659/" ]
You can use `COALESCE` > > Evaluates the arguments in order and returns the current value of the > first expression that initially does not evaluate to NULL. > > > ``` SELECT COALESCE((SELECT TOP 1 Column1 FROM Table1 WHERE PK = SomeValue), 'DefaultValue') ``` or like this: ``` DECLARE @ReturnValue INT = 3 --...
Perhaps can try using LEN instead of COUNT to check if Column1 has value? ``` SELECT CASE WHEN LEN(Column1) > 0 THEN Column1 ELSE 'Some Default' END AS Column1 FROM Table1 WHERE PKColumn = SomeValue GROUP BY Column1 ```
32,311,174
I have some problems with Highcharts Maps library. How can I remove the black dataLabels border? Here are my settings: ``` var Map = $('#container').highcharts('Map', { mapNavigation: { enabled: true, buttonOptions: { verticalAlign: 'bottom' } }, colorAxis: { m...
2015/08/31
[ "https://Stackoverflow.com/questions/32311174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366023/" ]
You sure can. See the API docs here regarding [dataLabels](http://api.highcharts.com/highcharts#plotOptions.series.dataLabels). To remove the border set: ``` dataLabels: { ... borderWidth: 0, ... }, ``` If you are talking about the text shadows you can do this in your dataLabel as well: ``` ...
I had the same problem with a column chart. I've solved the issue by using this in my `plotOptions.column`: ``` dataLabels: { /* ... */, style: { textShadow: null } } ``` Does it work for you ?
32,311,174
I have some problems with Highcharts Maps library. How can I remove the black dataLabels border? Here are my settings: ``` var Map = $('#container').highcharts('Map', { mapNavigation: { enabled: true, buttonOptions: { verticalAlign: 'bottom' } }, colorAxis: { m...
2015/08/31
[ "https://Stackoverflow.com/questions/32311174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366023/" ]
Highcharts V5 code for fixing this is ``` dataLabels: { style: { textOutline: 0 }, } ```
You sure can. See the API docs here regarding [dataLabels](http://api.highcharts.com/highcharts#plotOptions.series.dataLabels). To remove the border set: ``` dataLabels: { ... borderWidth: 0, ... }, ``` If you are talking about the text shadows you can do this in your dataLabel as well: ``` ...
32,311,174
I have some problems with Highcharts Maps library. How can I remove the black dataLabels border? Here are my settings: ``` var Map = $('#container').highcharts('Map', { mapNavigation: { enabled: true, buttonOptions: { verticalAlign: 'bottom' } }, colorAxis: { m...
2015/08/31
[ "https://Stackoverflow.com/questions/32311174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366023/" ]
Highcharts V5 code for fixing this is ``` dataLabels: { style: { textOutline: 0 }, } ```
I had the same problem with a column chart. I've solved the issue by using this in my `plotOptions.column`: ``` dataLabels: { /* ... */, style: { textShadow: null } } ``` Does it work for you ?
32,311,174
I have some problems with Highcharts Maps library. How can I remove the black dataLabels border? Here are my settings: ``` var Map = $('#container').highcharts('Map', { mapNavigation: { enabled: true, buttonOptions: { verticalAlign: 'bottom' } }, colorAxis: { m...
2015/08/31
[ "https://Stackoverflow.com/questions/32311174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366023/" ]
This did the job for me: ``` plotOptions: { series: { dataLabels: { style: { textOutline: 0, } } } } ```
I had the same problem with a column chart. I've solved the issue by using this in my `plotOptions.column`: ``` dataLabels: { /* ... */, style: { textShadow: null } } ``` Does it work for you ?
32,311,174
I have some problems with Highcharts Maps library. How can I remove the black dataLabels border? Here are my settings: ``` var Map = $('#container').highcharts('Map', { mapNavigation: { enabled: true, buttonOptions: { verticalAlign: 'bottom' } }, colorAxis: { m...
2015/08/31
[ "https://Stackoverflow.com/questions/32311174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1366023/" ]
Highcharts V5 code for fixing this is ``` dataLabels: { style: { textOutline: 0 }, } ```
This did the job for me: ``` plotOptions: { series: { dataLabels: { style: { textOutline: 0, } } } } ```
7,249,016
This works but is uglier than hell, basically it's iterating through two separate portions of a sub array, seeing if there's a greatest common denominator besides 1 in the values of both sub arrays, and if there is, multiplying the base value by 1.5 Sorry for the sloppy code ahead of time. ``` error_reporting(E_ALL);...
2011/08/30
[ "https://Stackoverflow.com/questions/7249016", "https://Stackoverflow.com", "https://Stackoverflow.com/users/411141/" ]
I have to agree with everyone else here... but I'd like to add: **Instead searching for how to traverse** `$this->digits` **more simply, you should strongly consider rethinking the structure of the data in** `$this->digits`**.** Furthermore, lumping everything into a single array doesn't always make sense. But when i...
If it works why are you changing it? Performance? Refactor? Business changed? Requirements changed? Clean code Samaritan? Boy Scout rule? When I come across "spaghetti code" I leave it alone unless I absolutely must change it. That said, I would write a couple of unit tests verifying the output of the "spaghetti code"...
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Use `trim()` to remove spaces at the ends of the strings, and regexp replacement to replace multiple spaces in the middle. ``` str = str.trim().replace(/\s{2,}/g, ' '); ```
Use `split`, `filter` and `join`. This will split the string, filter out the extra empty array entries then rejoin them with a space: ``` variable.split(" ").filter(Boolean).join(" "); ```
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Use `split`, `filter` and `join`. This will split the string, filter out the extra empty array entries then rejoin them with a space: ``` variable.split(" ").filter(Boolean).join(" "); ```
Do it manually ``` var strArr = ["a b c d", " a b c d ", "a b c d"]; for (var i = 0; i < strArr.length; i++) { console.log(removeSpaces(strArr[i])); } function removeSpaces(str) { str = str.replace(/ +/g, ' '); str = str.trim(); return str; } ```
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Use `split`, `filter` and `join`. This will split the string, filter out the extra empty array entries then rejoin them with a space: ``` variable.split(" ").filter(Boolean).join(" "); ```
Perfectly possible. The first regex replaces 1 or more `\s` characters with a single space. This includes spaces, tabs, and new-lines. ``` str.replace(/\s+/g, ' '); ``` If you just want spaces, use ``` str.replace(/ +/g, ' '); ``` This is also [more than 5x faster](http://jsperf.com/extraneous-spaces) than using ...
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Use `trim()` to remove spaces at the ends of the strings, and regexp replacement to replace multiple spaces in the middle. ``` str = str.trim().replace(/\s{2,}/g, ' '); ```
This should work in ES 3 enabled browsers as well. ``` function deleteUnwantedWhitespace (searchstring) { searchstring = searchstring.trim().split(" "); var tempArray = []; for (var i = 0; i < searchstring.length; i++) { if (searchstring[i]) { tempArray.push(searchstring[i]); } } r...
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Use `trim()` to remove spaces at the ends of the strings, and regexp replacement to replace multiple spaces in the middle. ``` str = str.trim().replace(/\s{2,}/g, ' '); ```
Do it manually ``` var strArr = ["a b c d", " a b c d ", "a b c d"]; for (var i = 0; i < strArr.length; i++) { console.log(removeSpaces(strArr[i])); } function removeSpaces(str) { str = str.replace(/ +/g, ' '); str = str.trim(); return str; } ```
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Use `trim()` to remove spaces at the ends of the strings, and regexp replacement to replace multiple spaces in the middle. ``` str = str.trim().replace(/\s{2,}/g, ' '); ```
Perfectly possible. The first regex replaces 1 or more `\s` characters with a single space. This includes spaces, tabs, and new-lines. ``` str.replace(/\s+/g, ' '); ``` If you just want spaces, use ``` str.replace(/ +/g, ' '); ``` This is also [more than 5x faster](http://jsperf.com/extraneous-spaces) than using ...
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
This should work in ES 3 enabled browsers as well. ``` function deleteUnwantedWhitespace (searchstring) { searchstring = searchstring.trim().split(" "); var tempArray = []; for (var i = 0; i < searchstring.length; i++) { if (searchstring[i]) { tempArray.push(searchstring[i]); } } r...
Do it manually ``` var strArr = ["a b c d", " a b c d ", "a b c d"]; for (var i = 0; i < strArr.length; i++) { console.log(removeSpaces(strArr[i])); } function removeSpaces(str) { str = str.replace(/ +/g, ' '); str = str.trim(); return str; } ```
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
This should work in ES 3 enabled browsers as well. ``` function deleteUnwantedWhitespace (searchstring) { searchstring = searchstring.trim().split(" "); var tempArray = []; for (var i = 0; i < searchstring.length; i++) { if (searchstring[i]) { tempArray.push(searchstring[i]); } } r...
Perfectly possible. The first regex replaces 1 or more `\s` characters with a single space. This includes spaces, tabs, and new-lines. ``` str.replace(/\s+/g, ' '); ``` If you just want spaces, use ``` str.replace(/ +/g, ' '); ``` This is also [more than 5x faster](http://jsperf.com/extraneous-spaces) than using ...
32,363,507
I would like to remove all the "unnecessary" spaces from a string. Specifically: ``` "a b c d" => "a b c d" // spaces between two words are left in " a b c d " => "a b c d" // spaces not between two words are removed "a b c d" => "a b c d" // as are duplicate spaces ``` Is there any regex out there that I can put...
2015/09/02
[ "https://Stackoverflow.com/questions/32363507", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1175276/" ]
Do it manually ``` var strArr = ["a b c d", " a b c d ", "a b c d"]; for (var i = 0; i < strArr.length; i++) { console.log(removeSpaces(strArr[i])); } function removeSpaces(str) { str = str.replace(/ +/g, ' '); str = str.trim(); return str; } ```
Perfectly possible. The first regex replaces 1 or more `\s` characters with a single space. This includes spaces, tabs, and new-lines. ``` str.replace(/\s+/g, ' '); ``` If you just want spaces, use ``` str.replace(/ +/g, ' '); ``` This is also [more than 5x faster](http://jsperf.com/extraneous-spaces) than using ...
179,832
Consider this example > > Having switched off the lights, I went to bed. > > > It implies that I went to bed after I had switched off the lights. The action of switching off the lights happened prior to going to bed, which was in the past. Although I understand Perfect aspect of participles, I don't quite get why...
2018/09/15
[ "https://ell.stackexchange.com/questions/179832", "https://ell.stackexchange.com", "https://ell.stackexchange.com/users/82266/" ]
We often call the *-ing* form a "present" participle and the *-en/-ed* form a "past" participle; but these are very misleading terms. The combination of the *-ing* form of *HAVE* and the *-ed* form of *SWITCH* does not create either a "present" or a "past" perfect. Present Perfect and Past Perfect require that *HAVE* ...
If you are telling a story, you can use present simple here instead of simple past. That is the only explanation that would make sense. It's called narrative past or historical present. Having switched off the lights, I went to bed. [normal usage for a finished action] Having switched off the lights, I go to bed. [...
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
Rather than the coding error, it could be related to IDE. Since the "Run File" runs okay, but 'Run Project" does not, I believe you have something to set up in IDE itself. Right click the project, and select "Set is as Main", now run the project. I am just giving it a guess, may not help you. But it worth a shot.If it ...
This message can also appear in Eclipse (Juno 4.2.2 in my case) and I have found two potential causes for it. In my cases: 1. a DTD was in error. I deleted the file and that solved the issue\*. 2. having cleaned the project, an external Jar that I had built externally had been deleted as could be seen from Properties ...
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
Your class needs a `public static void main(String[] args)` function. And moreover I suspect that the error could be in the package. If you want your class in `<main_package>.<sub_package>`, The directory structure is ``` - main_package - sub_package -HelloWorld.java ``` And be sure to write your class ...
This message can also appear in Eclipse (Juno 4.2.2 in my case) and I have found two potential causes for it. In my cases: 1. a DTD was in error. I deleted the file and that solved the issue\*. 2. having cleaned the project, an external Jar that I had built externally had been deleted as could be seen from Properties ...
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
Rather than the coding error, it could be related to IDE. Since the "Run File" runs okay, but 'Run Project" does not, I believe you have something to set up in IDE itself. Right click the project, and select "Set is as Main", now run the project. I am just giving it a guess, may not help you. But it worth a shot.If it ...
You need to run the `.class` file containing the `public static void main(String[] args)` method.. Here, your `HelloWorld.java file` might contain a `class` with `main()` method.. So, you can run it.. This is because, execution of any Java program starts with the invocation of `main()`.. **`JVM`** needs an entry poi...
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
You need to run the `.class` file containing the `public static void main(String[] args)` method.. Here, your `HelloWorld.java file` might contain a `class` with `main()` method.. So, you can run it.. This is because, execution of any Java program starts with the invocation of `main()`.. **`JVM`** needs an entry poi...
This message can also appear in Eclipse (Juno 4.2.2 in my case) and I have found two potential causes for it. In my cases: 1. a DTD was in error. I deleted the file and that solved the issue\*. 2. having cleaned the project, an external Jar that I had built externally had been deleted as could be seen from Properties ...
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
You need to run the `.class` file containing the `public static void main(String[] args)` method.. Here, your `HelloWorld.java file` might contain a `class` with `main()` method.. So, you can run it.. This is because, execution of any Java program starts with the invocation of `main()`.. **`JVM`** needs an entry poi...
Make sure you call looks like below: ``` public class HelloWorld { public static void main(String[] args) { System.out.println("hello user"); } } ``` To run a Java class in stand alone mode, `public static void main(String[] args)` is the entry method, which is must.
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
Your class needs a `public static void main(String[] args)` function. And moreover I suspect that the error could be in the package. If you want your class in `<main_package>.<sub_package>`, The directory structure is ``` - main_package - sub_package -HelloWorld.java ``` And be sure to write your class ...
Make sure you call looks like below: ``` public class HelloWorld { public static void main(String[] args) { System.out.println("hello user"); } } ``` To run a Java class in stand alone mode, `public static void main(String[] args)` is the entry method, which is must.
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
Rather than the coding error, it could be related to IDE. Since the "Run File" runs okay, but 'Run Project" does not, I believe you have something to set up in IDE itself. Right click the project, and select "Set is as Main", now run the project. I am just giving it a guess, may not help you. But it worth a shot.If it ...
Your class needs a `public static void main(String[] args)` function. And moreover I suspect that the error could be in the package. If you want your class in `<main_package>.<sub_package>`, The directory structure is ``` - main_package - sub_package -HelloWorld.java ``` And be sure to write your class ...
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
if you are using intellij idea then just rebuilding (clean and build) project might solve your problem . because intellij might be still trying to load the old classes which are not there or changed
Make sure you call looks like below: ``` public class HelloWorld { public static void main(String[] args) { System.out.println("hello user"); } } ``` To run a Java class in stand alone mode, `public static void main(String[] args)` is the entry method, which is must.
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
You need to run the `.class` file containing the `public static void main(String[] args)` method.. Here, your `HelloWorld.java file` might contain a `class` with `main()` method.. So, you can run it.. This is because, execution of any Java program starts with the invocation of `main()`.. **`JVM`** needs an entry poi...
if you are using intellij idea then just rebuilding (clean and build) project might solve your problem . because intellij might be still trying to load the old classes which are not there or changed
12,765,201
I am trying to run this project called "hello user". I am new to Java, so wrote a simple program that takes your name, and displays "Hello ". while Running it, I get the following error: ``` run: Error: Could not find or load main class hello.world.HelloWorld Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) ``...
2012/10/07
[ "https://Stackoverflow.com/questions/12765201", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1725974/" ]
Your class needs a `public static void main(String[] args)` function. And moreover I suspect that the error could be in the package. If you want your class in `<main_package>.<sub_package>`, The directory structure is ``` - main_package - sub_package -HelloWorld.java ``` And be sure to write your class ...
if you are using intellij idea then just rebuilding (clean and build) project might solve your problem . because intellij might be still trying to load the old classes which are not there or changed
97,381
I need this result for something else. It seems fairly hard, but I may be missing something obvious. Just one non-trivial solution for any given $c$ would be fine (for my application).
2012/05/19
[ "https://mathoverflow.net/questions/97381", "https://mathoverflow.net", "https://mathoverflow.net/users/10454/" ]
Many thanks for your replies. I thought I'd cracked it, but after posting noticed a mistake at the end. However, I'll leave the following, as far as it goes, in case it suggests any alternative angles to others. Firstly, note that the equation can be expressed as: $\dfrac{x - 1}{z} \dfrac{x + 1}{z} \dfrac{y - 1}{z} \...
Here are some thoughts, too long for a comment. We can assume that $c$ is not a rational square, otherwise we have many solutions with $x=y$ and $z\neq 0$. We have $x^2-1=c\_1 z^2$ and $y^2-1=c\_2 z^2$ with $c\_1 c\_2=c$. Hence $(x,y,z)$ lies on the intersection of two space quadrics. As $c\_1\neq c\_2$, the intersect...
97,381
I need this result for something else. It seems fairly hard, but I may be missing something obvious. Just one non-trivial solution for any given $c$ would be fine (for my application).
2012/05/19
[ "https://mathoverflow.net/questions/97381", "https://mathoverflow.net", "https://mathoverflow.net/users/10454/" ]
If you take the projective closure of your surface in $\mathbb{P}^3$ you find a singular quartic. This quartic has six singular points. Namely the two points found by Daniel and four points of the form $(\pm 1,\pm 1,0,1)$. Each of these points is an $A\_1$ singularity. This implies that the resolution of the surface is...
Here are some thoughts, too long for a comment. We can assume that $c$ is not a rational square, otherwise we have many solutions with $x=y$ and $z\neq 0$. We have $x^2-1=c\_1 z^2$ and $y^2-1=c\_2 z^2$ with $c\_1 c\_2=c$. Hence $(x,y,z)$ lies on the intersection of two space quadrics. As $c\_1\neq c\_2$, the intersect...
97,381
I need this result for something else. It seems fairly hard, but I may be missing something obvious. Just one non-trivial solution for any given $c$ would be fine (for my application).
2012/05/19
[ "https://mathoverflow.net/questions/97381", "https://mathoverflow.net", "https://mathoverflow.net/users/10454/" ]
*[edited again mainly to add the Euler link, see last paragraph]* Yes, and indeed there are infinitely many rational points: the birationally equivalent Diophantine equation given by J.Ramsden in his partial answer to his own question, $$ X + Y = Z + T, \phantom{and} XYZT = c, $$ was already studied by Euler (in the e...
Here are some thoughts, too long for a comment. We can assume that $c$ is not a rational square, otherwise we have many solutions with $x=y$ and $z\neq 0$. We have $x^2-1=c\_1 z^2$ and $y^2-1=c\_2 z^2$ with $c\_1 c\_2=c$. Hence $(x,y,z)$ lies on the intersection of two space quadrics. As $c\_1\neq c\_2$, the intersect...
97,381
I need this result for something else. It seems fairly hard, but I may be missing something obvious. Just one non-trivial solution for any given $c$ would be fine (for my application).
2012/05/19
[ "https://mathoverflow.net/questions/97381", "https://mathoverflow.net", "https://mathoverflow.net/users/10454/" ]
*[edited again mainly to add the Euler link, see last paragraph]* Yes, and indeed there are infinitely many rational points: the birationally equivalent Diophantine equation given by J.Ramsden in his partial answer to his own question, $$ X + Y = Z + T, \phantom{and} XYZT = c, $$ was already studied by Euler (in the e...
Many thanks for your replies. I thought I'd cracked it, but after posting noticed a mistake at the end. However, I'll leave the following, as far as it goes, in case it suggests any alternative angles to others. Firstly, note that the equation can be expressed as: $\dfrac{x - 1}{z} \dfrac{x + 1}{z} \dfrac{y - 1}{z} \...
97,381
I need this result for something else. It seems fairly hard, but I may be missing something obvious. Just one non-trivial solution for any given $c$ would be fine (for my application).
2012/05/19
[ "https://mathoverflow.net/questions/97381", "https://mathoverflow.net", "https://mathoverflow.net/users/10454/" ]
*[edited again mainly to add the Euler link, see last paragraph]* Yes, and indeed there are infinitely many rational points: the birationally equivalent Diophantine equation given by J.Ramsden in his partial answer to his own question, $$ X + Y = Z + T, \phantom{and} XYZT = c, $$ was already studied by Euler (in the e...
If you take the projective closure of your surface in $\mathbb{P}^3$ you find a singular quartic. This quartic has six singular points. Namely the two points found by Daniel and four points of the form $(\pm 1,\pm 1,0,1)$. Each of these points is an $A\_1$ singularity. This implies that the resolution of the surface is...
5,501,098
I'm working on a system of applications for processing sound data. The first application simply reads from a microphone jack and sends the data to the next application. The main loop repeatedly performs this code: ``` 0 : Globals.mySleep(waitTime); // tells the thread to sleep for the proper amount of time for a given...
2011/03/31
[ "https://Stackoverflow.com/questions/5501098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592459/" ]
It's fixed. Whenever I want to get the sound stream going (whenever I press play), I close the current stream and open a new one. I didn't realize the TargetDataLine actually held a buffer of sound data that just gets picked from whenever the read method is called. It looks like when I ran the application from Eclips...
I find the best thing to do in situations like this, where your code is slow but you dont know why is to use a profiler, <http://www.quest.com/jprobe/software_download.aspx> you can get a free trail of this java profiler and it will tell you line by line how much time is spent and how many times it is executed, you sho...
5,501,098
I'm working on a system of applications for processing sound data. The first application simply reads from a microphone jack and sends the data to the next application. The main loop repeatedly performs this code: ``` 0 : Globals.mySleep(waitTime); // tells the thread to sleep for the proper amount of time for a given...
2011/03/31
[ "https://Stackoverflow.com/questions/5501098", "https://Stackoverflow.com", "https://Stackoverflow.com/users/592459/" ]
It's fixed. Whenever I want to get the sound stream going (whenever I press play), I close the current stream and open a new one. I didn't realize the TargetDataLine actually held a buffer of sound data that just gets picked from whenever the read method is called. It looks like when I ran the application from Eclips...
> > Globals.mySleep(waitTime); // tells the thread to sleep for the proper amount of time for a given data format > > > I **suspect** the 'proper' `waitTime` here is '0'. If you want something more than suspicions, I recommend you post an [SSCCE](http://pscode.org/sscce.html) (without the line numbers).
76,246
This script is not working the way I thought it would . I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5 ``` #!/bin/bash # the / makes find inclusive for file in `find . -perm /007 ` do permissions=`stat -c %a $file` permissions=${permissions:0:2}5 echo $p...
2013/05/17
[ "https://unix.stackexchange.com/questions/76246", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/9110/" ]
``` chmod -R o-w . ``` Will remove write permissions to *others* for every file in a safe way. It will however update the ctime of every file including the ones for which *others* already didn't have write access. With GNU `chmod`, you can make it show which files needed updated with the -c option: ``` $ chmod -cR ...
`/007` will show your only files that have no permissions for `owner` and `group`, and all permissiosn (rwx) for `other`. You might have more luck with `/o=rwx`. That will match only the `other` permissions for the file. **EDIT FOR CORRECTNESS:** Apparently, you'll need to use `-perm -o=rwx`, because the `/o` is an ...
76,246
This script is not working the way I thought it would . I though it would find all the scripts that have every one rwx permissions changed to the permissions of xx5 ``` #!/bin/bash # the / makes find inclusive for file in `find . -perm /007 ` do permissions=`stat -c %a $file` permissions=${permissions:0:2}5 echo $p...
2013/05/17
[ "https://unix.stackexchange.com/questions/76246", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/9110/" ]
``` chmod -R o-w . ``` Will remove write permissions to *others* for every file in a safe way. It will however update the ctime of every file including the ones for which *others* already didn't have write access. With GNU `chmod`, you can make it show which files needed updated with the -c option: ``` $ chmod -cR ...
Your approach is a performance nightmare: You create two processes for every file! One completely uselessly because `find` already has this information and can easily print it. This is a better solution: ``` find . -perm -o=rwx -printf "%m %p_\0" 2>/dev/null | while read -r -d '' perms path; do path="${path%_}"...
138,720
I was running alter column from INT to BIGINT, my table size is 250 GB and after 1 hour I got the version store error because tempdb was full. As far as I know it only takes your memory pages and log files but I am not sure about Tempdb. Can someone please explain this internals? I am using read committed isolation. ...
2016/05/17
[ "https://dba.stackexchange.com/questions/138720", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/92566/" ]
Assuming we're talking about a plain `ALTER TABLE`, not an operation done through some wizard that does temp table and rename tricks or anything similar. A straight column data type change *may* result in update of *every* row in the table. It depends on the types involved. You have to consider this: the row image in ...
I believe that the db engine is creating a new temporary table and filling it. Looking at your execution plan might provide clues. You can see the quote in the following article but after searching I did not see anything official in MS documentation. Also, if you are running this using SSMS designer it may have diffe...
138,720
I was running alter column from INT to BIGINT, my table size is 250 GB and after 1 hour I got the version store error because tempdb was full. As far as I know it only takes your memory pages and log files but I am not sure about Tempdb. Can someone please explain this internals? I am using read committed isolation. ...
2016/05/17
[ "https://dba.stackexchange.com/questions/138720", "https://dba.stackexchange.com", "https://dba.stackexchange.com/users/92566/" ]
Assuming we're talking about a plain `ALTER TABLE`, not an operation done through some wizard that does temp table and rename tricks or anything similar. A straight column data type change *may* result in update of *every* row in the table. It depends on the types involved. You have to consider this: the row image in ...
I am quoting a paragraph **Appendix A: Using Management Studio to Change Data Types** from SQL Server 2005 document on [Impact Of Changing Collation and Data types](https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjA19rOpejMAhVkYKYKHUK0Co8QFggcMAA&url=http%3A%2F%2Fdownload.m...
48,514,515
**I am trying to render the dynamic values to textarea while the selectbox change. but i am not able to render in textarea but values change in form.value.** I tried to assign value to textarea dynamically when changing the selectbox, But textarea value not changing. Form values are changing when i am checking with {{...
2018/01/30
[ "https://Stackoverflow.com/questions/48514515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4586968/" ]
You need to use `controls` instead of `value`, so something like this: ``` // to avoid error of controls doesn't exist on abstractcontrol: let arr = <FormArray>this.myForm.controls.users; arr.controls[0].patchValue({...}) ```
try this : ``` var test = this.myForm.get('users[0].street'); test.setValue('mtmmm'); ```
186,340
Using REST API call, i am trying to get the list of available subsites for the current user, below is the endpoint uri used ``` /_api/web/Webs$select=Title,URL,effectivebasepermissions&$filter=effectivebasepermissions/high%20gt%2032 ``` Why is a `filter gt 32` used?
2016/07/12
[ "https://sharepoint.stackexchange.com/questions/186340", "https://sharepoint.stackexchange.com", "https://sharepoint.stackexchange.com/users/53493/" ]
SPBasePermissions is implemented as a bitmask, which allows a number of values to be stored in a single integer. This concept is commonly used in security scenarios. The number 32 represents the minimum permission needed to view the site. A general intro to bitmasks: <https://en.wikipedia.org/wiki/Mask_(computing)> J...
It turned out that there is an existing SharePoint method that gets subsites that are only accessible by current user - [GetSubwebsFilteredForCurrentUser](https://msdn.microsoft.com/en-us/library/hh630700(v=office.12).aspx). It is more appropriate rather than using "$filter=effectivebasepermissions/high%20gt%2032".
321,176
I'm trying to use a command that will testfor @p but exclude a specific player. This is the command I tried but it does not function: ``` /testfor @p[r=3,!name=name here] ``` The commands need to function with version 1.12.2
2017/11/10
[ "https://gaming.stackexchange.com/questions/321176", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/198585/" ]
Looks like a third party SNES controller. First party ones look like this: [![Real controller](https://i.stack.imgur.com/1vhjw.jpg)](https://i.stack.imgur.com/1vhjw.jpg) The port that it plugs into looks like this: [![Controller port](https://i.stack.imgur.com/LQZ9F.jpg)](https://i.stack.imgur.com/LQZ9F.jpg)
This is a third party controller that - if I remember correctly - was designed for the SNES but also worked for the Sega Genesis (megadrive). The switches in the middle were autofire cheats. If the switch was on, then the controller would automatically and repeatedly trigger the corresponding button, so you didn't hav...
321,176
I'm trying to use a command that will testfor @p but exclude a specific player. This is the command I tried but it does not function: ``` /testfor @p[r=3,!name=name here] ``` The commands need to function with version 1.12.2
2017/11/10
[ "https://gaming.stackexchange.com/questions/321176", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/198585/" ]
It's a "Blockbuster brand" SNES controller. They're apparently very rare. Unfortunately there doesn't seem to be much information online besides that. [![Blockbuster SNES Controller 1](https://i.stack.imgur.com/hXyUR.jpg)](https://i.stack.imgur.com/hXyUR.jpg) *([forum thread this came from](http://nintendoage.com/f...
Looks like a third party SNES controller. First party ones look like this: [![Real controller](https://i.stack.imgur.com/1vhjw.jpg)](https://i.stack.imgur.com/1vhjw.jpg) The port that it plugs into looks like this: [![Controller port](https://i.stack.imgur.com/LQZ9F.jpg)](https://i.stack.imgur.com/LQZ9F.jpg)
321,176
I'm trying to use a command that will testfor @p but exclude a specific player. This is the command I tried but it does not function: ``` /testfor @p[r=3,!name=name here] ``` The commands need to function with version 1.12.2
2017/11/10
[ "https://gaming.stackexchange.com/questions/321176", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/198585/" ]
It's a "Blockbuster brand" SNES controller. They're apparently very rare. Unfortunately there doesn't seem to be much information online besides that. [![Blockbuster SNES Controller 1](https://i.stack.imgur.com/hXyUR.jpg)](https://i.stack.imgur.com/hXyUR.jpg) *([forum thread this came from](http://nintendoage.com/f...
This is a third party controller that - if I remember correctly - was designed for the SNES but also worked for the Sega Genesis (megadrive). The switches in the middle were autofire cheats. If the switch was on, then the controller would automatically and repeatedly trigger the corresponding button, so you didn't hav...
22,844
I am working on a 2D side-scroller using Farseer Physics Engine v3.3.1. In order to create a realistic physical skeleton for the player, I am using a method similar to the one explained [here](https://github.com/Genbox/VelcroPhysics) (See "Texture to polygon" section). Below is my code for creating the player body: ...
2012/01/24
[ "https://gamedev.stackexchange.com/questions/22844", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/12860/" ]
You can have more than one `b2World` (i.e. standalone Box2D simulation) in place at a given time... this is also used to implement wrap-around worlds. You could store spare bodies there. If you disable/sleep them all, it won't cost much, just a bit of memory. The other alternative is to create the spare bodies (yech!)...
Your sprites are drawn separate from your physics engine, so unless you need to provide proper collision detection when crouching, you shouldn't have to swap the body. Just draw the crouched texture on top of it. If you really need to replace the body, you can consider creating all the bodies you need, and then set th...
22,844
I am working on a 2D side-scroller using Farseer Physics Engine v3.3.1. In order to create a realistic physical skeleton for the player, I am using a method similar to the one explained [here](https://github.com/Genbox/VelcroPhysics) (See "Texture to polygon" section). Below is my code for creating the player body: ...
2012/01/24
[ "https://gamedev.stackexchange.com/questions/22844", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/12860/" ]
It is actually really easy ``` for (int i = 0; i < origin.body.FixtureList.Count; i++) { origin.body.DestroyFixture(origin.body.FixtureList[i]); } FixtureFactory.AttachCompoundPolygon(verticeslist, 1f, origin.body, null); return origin.body; ```
Your sprites are drawn separate from your physics engine, so unless you need to provide proper collision detection when crouching, you shouldn't have to swap the body. Just draw the crouched texture on top of it. If you really need to replace the body, you can consider creating all the bodies you need, and then set th...
65,645,489
Would like use powershell to do some monitoring of a VPN tunnel and if outage detected, auto reset the tunnel. Can Windows powershell SSH into a Cisco ASA firewall for issuing a firewall command?
2021/01/09
[ "https://Stackoverflow.com/questions/65645489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2368632/" ]
Here, `sizeof` evaluates the return type of `printf`. (Here an `int`)
printf() returns no. of char like "lol!" has four character + null char(1) so it will return value 5(an int). And then sizeof() will return sizeof(int) i.e. 4
22,375,306
I'm wondering that how API results can load as response comes. [similar functionality](http://flight.yatra.com/air-search/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=BLR&destination=MAA&flight_depart_date=21/04/2014&originCountry=IN&destinationCountry=IN&ADT=1&CHD=0&INF=0&class=Economy) I think ...
2014/03/13
[ "https://Stackoverflow.com/questions/22375306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1931887/" ]
Try setting dataType as `xml` and processData as `false` and check. ``` $.ajax({ type: "get", url: "<?=base_url()?>search/showresults", cache: false, data:datastring, processData: false, dataType:"xml", beforeSend:function(){ $('#resultloader').show(); }, s...
try use this one ``` formData = { param1: param1 } $.ajax({ type: "get", url: "<?=base_url()?>search/showresults", cache: false, data: formData, dataType: "xml", beforeSend:function(){ $('#resultloader').show(); }, success: function(data){ $('#resul...
22,375,306
I'm wondering that how API results can load as response comes. [similar functionality](http://flight.yatra.com/air-search/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=BLR&destination=MAA&flight_depart_date=21/04/2014&originCountry=IN&destinationCountry=IN&ADT=1&CHD=0&INF=0&class=Economy) I think ...
2014/03/13
[ "https://Stackoverflow.com/questions/22375306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1931887/" ]
try use this one ``` formData = { param1: param1 } $.ajax({ type: "get", url: "<?=base_url()?>search/showresults", cache: false, data: formData, dataType: "xml", beforeSend:function(){ $('#resultloader').show(); }, success: function(data){ $('#resul...
What I do is process and store the results on the server in a background thread that reads from a message queue. In our case, this is for insurance quotes. As each carrier's insurance quote is finished, its premium is stored in our database. On the client side, we call the server using a timer loop. See [Ben Alman - d...
22,375,306
I'm wondering that how API results can load as response comes. [similar functionality](http://flight.yatra.com/air-search/dom2/trigger?type=O&viewName=normal&flexi=0&noOfSegments=1&origin=BLR&destination=MAA&flight_depart_date=21/04/2014&originCountry=IN&destinationCountry=IN&ADT=1&CHD=0&INF=0&class=Economy) I think ...
2014/03/13
[ "https://Stackoverflow.com/questions/22375306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1931887/" ]
Try setting dataType as `xml` and processData as `false` and check. ``` $.ajax({ type: "get", url: "<?=base_url()?>search/showresults", cache: false, data:datastring, processData: false, dataType:"xml", beforeSend:function(){ $('#resultloader').show(); }, s...
What I do is process and store the results on the server in a background thread that reads from a message queue. In our case, this is for insurance quotes. As each carrier's insurance quote is finished, its premium is stored in our database. On the client side, we call the server using a timer loop. See [Ben Alman - d...
52,693,273
I have troubles using to implement ssh and rsync including a private key in python, including Popen (subprocess). Basically the rsync syntax to use should be: ``` $ rsync -az -e --log-file=$logdir/logfile.out \ 'ssh -e /home/user/.ssh/id_rsa' user@server:/target-directory ``` What I have is this: ``` import subpro...
2018/10/07
[ "https://Stackoverflow.com/questions/52693273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8559579/" ]
Here's a relatively simple solution using [`array_reduce`](http://php.net/manual/en/function.array-reduce.php): ``` $rows = array( array(1, 30, 40, 22, 12, 14, 55, 68, 91, 80, 99, 23, 63, 61, 83), array(8, 17, 59, 14, 93, 31, 57, 91, 29, 38, 54, 47, 28, 12, 15) ); // replace this line with your while($row...
Here's a code snippet that does what I think you want to acomplish. There might be quicker ways (with less loops), but it does it's job. ``` <?php $borders = [20,40,60,80]; // some test data $rows[] = ["Rpa" => 30, "Rpb" => 14, "Rpc" => 1, "Rpd" => 24]; $rows[] = ["Rpa" => 41, "Rpb" => 33, "Rpc" => 20, "Rpd" => 79]; ...
52,693,273
I have troubles using to implement ssh and rsync including a private key in python, including Popen (subprocess). Basically the rsync syntax to use should be: ``` $ rsync -az -e --log-file=$logdir/logfile.out \ 'ssh -e /home/user/.ssh/id_rsa' user@server:/target-directory ``` What I have is this: ``` import subpro...
2018/10/07
[ "https://Stackoverflow.com/questions/52693273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8559579/" ]
Here's a relatively simple solution using [`array_reduce`](http://php.net/manual/en/function.array-reduce.php): ``` $rows = array( array(1, 30, 40, 22, 12, 14, 55, 68, 91, 80, 99, 23, 63, 61, 83), array(8, 17, 59, 14, 93, 31, 57, 91, 29, 38, 54, 47, 28, 12, 15) ); // replace this line with your while($row...
Ok so based on my understanding of your question you want to fetch all numbers(data's) from all of your columns in your database and order them into your table, so this is an example on how to do this:- ``` ... $num_list = array(); if ($result->num_rows > 0) while($row = $result->fetch_assoc()) foreach ($ro...
52,693,273
I have troubles using to implement ssh and rsync including a private key in python, including Popen (subprocess). Basically the rsync syntax to use should be: ``` $ rsync -az -e --log-file=$logdir/logfile.out \ 'ssh -e /home/user/.ssh/id_rsa' user@server:/target-directory ``` What I have is this: ``` import subpro...
2018/10/07
[ "https://Stackoverflow.com/questions/52693273", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8559579/" ]
Here's a relatively simple solution using [`array_reduce`](http://php.net/manual/en/function.array-reduce.php): ``` $rows = array( array(1, 30, 40, 22, 12, 14, 55, 68, 91, 80, 99, 23, 63, 61, 83), array(8, 17, 59, 14, 93, 31, 57, 91, 29, 38, 54, 47, 28, 12, 15) ); // replace this line with your while($row...
this has been untested and off the cusp, however the base logic of what i think you're trying to achieve is there. Let me know if there's any issues and i'll amend the answer. ``` $row_nums = array_values($row); asort($row_nums); $grouped_scores = []; foreach($row_nums as $num){ switch (true) { case ($nu...
28,243,389
I just bought SSL for my domain and the host installed it and now all pages are requiring "HTTPS". Is there a way to fix this globally and only display the https pages when I call for them? Example: example.com - wont work <https://example.com> - works I know I have to link to the pages I want secure with https, non...
2015/01/30
[ "https://Stackoverflow.com/questions/28243389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4478313/" ]
it’s important to avoid this by ensuring that every image, CSS and Javscript file on a secure page is accessed using HTTPS. For content on the same domain it’s quite straightforward – you just need to use relative URLs. A relative URL contains the ‘offset’ URL that needs to be applied to the page’s absolute URL in orde...
You can force https acces with htaccess. Try the following: ``` RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L] ``` Please replace `www.yourdomain.com` with that of yours' **Note:** Please do remeber to get your mod\_rewrite ON for the server
28,243,389
I just bought SSL for my domain and the host installed it and now all pages are requiring "HTTPS". Is there a way to fix this globally and only display the https pages when I call for them? Example: example.com - wont work <https://example.com> - works I know I have to link to the pages I want secure with https, non...
2015/01/30
[ "https://Stackoverflow.com/questions/28243389", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4478313/" ]
Redirect from http to https This bit will help you tremendously when you’ve not updated every single link in your site yet. You can just add a straight server level redirect from http to https. In Apache you’d do something like this: ``` RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_...
You can force https acces with htaccess. Try the following: ``` RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L] ``` Please replace `www.yourdomain.com` with that of yours' **Note:** Please do remeber to get your mod\_rewrite ON for the server
47,755,173
I know it may sound a silly question, but I'm trying to make this PHP code as one line: ``` $value = result_from_a_function(); if ($value > $maximum) { $value = $maximum; } ``` Is it possible to make it one line in PHP? Something like ``` $value = result_from_a_function() [obscure operator] $maximum; ```
2017/12/11
[ "https://Stackoverflow.com/questions/47755173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1037567/" ]
The magic function is `MIN` ``` $value = min($value, $maximum) ```
Yes, use a [ternary operator](http://php.net/manual/en/language.operators.comparison.php): ``` $value = (result_from_a_function() > $maximum) ? $maximum : $something_else; ```
47,755,173
I know it may sound a silly question, but I'm trying to make this PHP code as one line: ``` $value = result_from_a_function(); if ($value > $maximum) { $value = $maximum; } ``` Is it possible to make it one line in PHP? Something like ``` $value = result_from_a_function() [obscure operator] $maximum; ```
2017/12/11
[ "https://Stackoverflow.com/questions/47755173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1037567/" ]
The magic function is `MIN` ``` $value = min($value, $maximum) ```
Ternary Operators make code shorter in one line thats why i suggest using ternary operators like ``` $message = 'Hello '.($user->is_logged_in() ? $user->get('first_name') : 'Guest'); ``` or according to your code sample ``` $value = (result_from_a_function() > $max) ? $max: $false_Sataments; ```
47,755,173
I know it may sound a silly question, but I'm trying to make this PHP code as one line: ``` $value = result_from_a_function(); if ($value > $maximum) { $value = $maximum; } ``` Is it possible to make it one line in PHP? Something like ``` $value = result_from_a_function() [obscure operator] $maximum; ```
2017/12/11
[ "https://Stackoverflow.com/questions/47755173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1037567/" ]
Yes, use a [ternary operator](http://php.net/manual/en/language.operators.comparison.php): ``` $value = (result_from_a_function() > $maximum) ? $maximum : $something_else; ```
Ternary Operators make code shorter in one line thats why i suggest using ternary operators like ``` $message = 'Hello '.($user->is_logged_in() ? $user->get('first_name') : 'Guest'); ``` or according to your code sample ``` $value = (result_from_a_function() > $max) ? $max: $false_Sataments; ```
55,193,870
I am trying to deploy a dash app ( which is based on flask ) on elastic beanstalk. The code was deployed successfully but it is showing 502 bad gateway error. [This is the image I am getting upon deploying the code](https://i.stack.imgur.com/2cjwm.png) [This is the error I get when I click the link](https://i.stack.i...
2019/03/16
[ "https://Stackoverflow.com/questions/55193870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11183346/" ]
First of I would check 2 things: * That the server is really running, thats mostly the cause of 502 * I would check that load balancer (and its security group) uses to the same port where the server is running <https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html> But there are many...
was facing same issue .just Realized that nginx is connecting to node on 8081. Changed node port to 8081 and all is good now..
20,240,983
I'm wanting to do this transition effect, but it only works on the first div, on Monday that aims to affect the first, nothing happens. ``` <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test</title> <style type="text/css"> #firstElement:hover + #secondElement { ...
2013/11/27
[ "https://Stackoverflow.com/questions/20240983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2576284/" ]
first you need to set `transition` (if you mean transition and not hover) to the elements like this: ``` #firstElement:hover + #secondElement { color:red; transition:color 0.5s ease; /* this is an example */ } #secondElement:hover + #firstElement { /* this is not right selector */ color:blue; tr...
the psuedo hover effect only works on parent-child relationships. so if you have a menu where Toys is the parent, and barbie dolls, car trucks, and legos are the 3 child elements, you can do psuedo classes. For example if you did ``` #toys:hover #barbiedolls { background: red; } ``` that would work. But if you ...
20,240,983
I'm wanting to do this transition effect, but it only works on the first div, on Monday that aims to affect the first, nothing happens. ``` <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test</title> <style type="text/css"> #firstElement:hover + #secondElement { ...
2013/11/27
[ "https://Stackoverflow.com/questions/20240983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2576284/" ]
first you need to set `transition` (if you mean transition and not hover) to the elements like this: ``` #firstElement:hover + #secondElement { color:red; transition:color 0.5s ease; /* this is an example */ } #secondElement:hover + #firstElement { /* this is not right selector */ color:blue; tr...
From [Adjacent sibling selectors](http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors) > > Adjacent sibling selectors have the following syntax: E1 + E2, where E2 is the subject of the selector. The selector matches if E1 and E2 share the same parent in the document tree and **E1 immediately precedes E2**, ig...
20,240,983
I'm wanting to do this transition effect, but it only works on the first div, on Monday that aims to affect the first, nothing happens. ``` <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test</title> <style type="text/css"> #firstElement:hover + #secondElement { ...
2013/11/27
[ "https://Stackoverflow.com/questions/20240983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2576284/" ]
Why this doesn't work should be clear from the other answers. Here's a solution. ``` <div id="elements"> <p id="firstElement">Hover</p> <p id="secondElement">Hello</p> </div> ``` CSS ``` #elements:hover #secondElement:not(:hover) { color:red; } #elements:hover #firstElement:not(:hover) { color:blue; } ...
first you need to set `transition` (if you mean transition and not hover) to the elements like this: ``` #firstElement:hover + #secondElement { color:red; transition:color 0.5s ease; /* this is an example */ } #secondElement:hover + #firstElement { /* this is not right selector */ color:blue; tr...
20,240,983
I'm wanting to do this transition effect, but it only works on the first div, on Monday that aims to affect the first, nothing happens. ``` <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test</title> <style type="text/css"> #firstElement:hover + #secondElement { ...
2013/11/27
[ "https://Stackoverflow.com/questions/20240983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2576284/" ]
Why this doesn't work should be clear from the other answers. Here's a solution. ``` <div id="elements"> <p id="firstElement">Hover</p> <p id="secondElement">Hello</p> </div> ``` CSS ``` #elements:hover #secondElement:not(:hover) { color:red; } #elements:hover #firstElement:not(:hover) { color:blue; } ...
the psuedo hover effect only works on parent-child relationships. so if you have a menu where Toys is the parent, and barbie dolls, car trucks, and legos are the 3 child elements, you can do psuedo classes. For example if you did ``` #toys:hover #barbiedolls { background: red; } ``` that would work. But if you ...
20,240,983
I'm wanting to do this transition effect, but it only works on the first div, on Monday that aims to affect the first, nothing happens. ``` <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>test</title> <style type="text/css"> #firstElement:hover + #secondElement { ...
2013/11/27
[ "https://Stackoverflow.com/questions/20240983", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2576284/" ]
Why this doesn't work should be clear from the other answers. Here's a solution. ``` <div id="elements"> <p id="firstElement">Hover</p> <p id="secondElement">Hello</p> </div> ``` CSS ``` #elements:hover #secondElement:not(:hover) { color:red; } #elements:hover #firstElement:not(:hover) { color:blue; } ...
From [Adjacent sibling selectors](http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors) > > Adjacent sibling selectors have the following syntax: E1 + E2, where E2 is the subject of the selector. The selector matches if E1 and E2 share the same parent in the document tree and **E1 immediately precedes E2**, ig...
2,790,721
Given two integers $n$ and $k$ such that $n\geq k+1$. Can we find any relation between $\left\lfloor\dfrac{n}{k}\right\rfloor$ and $\left\lfloor \dfrac{n}{k+1}\right\rfloor$? At first, I thought that $\left\lfloor \dfrac{n}{k+1}\right\rfloor=\left\lfloor\dfrac{n}{k}\right\rfloor-1,$ but then I found that, for $k=1$,...
2018/05/21
[ "https://math.stackexchange.com/questions/2790721", "https://math.stackexchange.com", "https://math.stackexchange.com/users/525854/" ]
The floor function satisfies > > * $\lfloor x\rfloor\leq x$ > * $\lfloor\lfloor x\rfloor\rfloor=\lfloor x\rfloor$ > * From those two one can easily prove that > $$ > \lfloor x\rfloor +\lfloor y\rfloor\leq \lfloor x+y\rfloor > $$ > * If we subtract $\lfloor y\rfloor$ from both sides and consider $x=a$ and $y=b-a$ we ...
First let's consider that $$ \eqalign{ & \left\lfloor {x + y} \right\rfloor = \cr & = \left\lfloor x \right\rfloor + \left\lfloor y \right\rfloor + \left\lfloor {\left\{ x \right\} + \left\{ y \right\}} \right\rfloor = \cr & = \left\lfloor x \right\rfloor + \left\lfloor y \right\rfloor + \left[ {1 - \left\{ x \rig...
32,315,829
I am using the Console as an input source. I looked for a way qi would parse a line and then it'd wait for the next line and continue parsing from that point. for example take the following grammar ``` start = MultiLine | Line; Multiline = "{" *(Line) "}"; Line = *(char_("A-Za-z0-9")); ``` As an input ``` { AAAA ...
2015/08/31
[ "https://Stackoverflow.com/questions/32315829", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5285450/" ]
If you want to change the Android Beacon Library's default scan interval to 100ms, you can do so with code like this: ``` try { beaconManager.setForegroundScanPeriod(100l); // 100 mS beaconManager.setForegroundBetweenScanPeriod(0l); // 0ms beaconManager.updateScanPeriods(); } catch (RemoteException...
``` RangedBeacon.setSampleExpirationMilliseconds(5000); // default is 20000 beaconManager.setForegroundScanPeriod(100l); // 100 mS beaconManager.setForegroundBetweenScanPeriod(0l); // 0ms try { beaconManager.updateScanPeriods(); } catch (RemoteException e) { e.printStackTrace(); ...
2,225,173
Some authors define a manifold as a paracompact Hausdorff space that is locally Euclidean. Also it is said that a product of two manifolds is a manifold. However, we know that product of a two paracompact spaces is not necessarily paracompact. So how can we be sure that a product of two manifolds is also paracompact an...
2017/04/08
[ "https://math.stackexchange.com/questions/2225173", "https://math.stackexchange.com", "https://math.stackexchange.com/users/434869/" ]
By the Smirnov metrization theorem, a paracompact Hausdorff space that is locally metrizable is metrizable. Therefore every manifold is metrizable, and hence so is the product of two manifolds. In particular the product is paracompact.
A connected manifold is paracompact iff it is second-countable, so a general paracompact manifold is just a (possibly uncountable) disjoint union of second-countable manifolds. So, if you take a product of two such spaces, you get a disjoint union of products of two second-countable manifolds. A product of two second-c...
4,413,007
I want to use an ArrayList (or some other collection) like how I would use a standard array. Specifically, I want it to start with an intial size (say, SIZE), and be able to set elements explicitly right off the bat, e.g. ``` array[4] = "stuff"; ``` could be written ``` array.set(4, "stuff"); ``` However, the...
2010/12/10
[ "https://Stackoverflow.com/questions/4413007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59931/" ]
The initial capacity means how big the array is. It does not mean there are elements there. So size != capacity. In fact, you *can* use an array, and then use `Arrays.asList(array)` to get a collection.
I recomend a HashMap ``` HashMap hash = new HasMap(); hash.put(4,"Hi"); ```
4,413,007
I want to use an ArrayList (or some other collection) like how I would use a standard array. Specifically, I want it to start with an intial size (say, SIZE), and be able to set elements explicitly right off the bat, e.g. ``` array[4] = "stuff"; ``` could be written ``` array.set(4, "stuff"); ``` However, the...
2010/12/10
[ "https://Stackoverflow.com/questions/4413007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59931/" ]
The initial capacity means how big the array is. It does not mean there are elements there. So size != capacity. In fact, you *can* use an array, and then use `Arrays.asList(array)` to get a collection.
Yes, hashmap would be a great ideia. Other way, you could just start the array with a big capacity for you purpose.
4,413,007
I want to use an ArrayList (or some other collection) like how I would use a standard array. Specifically, I want it to start with an intial size (say, SIZE), and be able to set elements explicitly right off the bat, e.g. ``` array[4] = "stuff"; ``` could be written ``` array.set(4, "stuff"); ``` However, the...
2010/12/10
[ "https://Stackoverflow.com/questions/4413007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59931/" ]
The initial capacity means how big the array is. It does not mean there are elements there. So size != capacity. In fact, you *can* use an array, and then use `Arrays.asList(array)` to get a collection.
Considering that your main point is memory. Then you could manually do what the Java arraylist do, but it doesn't allow you to resize as much you want. So you can do the following: ``` 1) Create a vector. 2) If the vector is full, create a vector with the old vector size + as much you want. 3) Copy all items from the...
4,413,007
I want to use an ArrayList (or some other collection) like how I would use a standard array. Specifically, I want it to start with an intial size (say, SIZE), and be able to set elements explicitly right off the bat, e.g. ``` array[4] = "stuff"; ``` could be written ``` array.set(4, "stuff"); ``` However, the...
2010/12/10
[ "https://Stackoverflow.com/questions/4413007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59931/" ]
I recomend a HashMap ``` HashMap hash = new HasMap(); hash.put(4,"Hi"); ```
Yes, hashmap would be a great ideia. Other way, you could just start the array with a big capacity for you purpose.
4,413,007
I want to use an ArrayList (or some other collection) like how I would use a standard array. Specifically, I want it to start with an intial size (say, SIZE), and be able to set elements explicitly right off the bat, e.g. ``` array[4] = "stuff"; ``` could be written ``` array.set(4, "stuff"); ``` However, the...
2010/12/10
[ "https://Stackoverflow.com/questions/4413007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59931/" ]
I recomend a HashMap ``` HashMap hash = new HasMap(); hash.put(4,"Hi"); ```
Considering that your main point is memory. Then you could manually do what the Java arraylist do, but it doesn't allow you to resize as much you want. So you can do the following: ``` 1) Create a vector. 2) If the vector is full, create a vector with the old vector size + as much you want. 3) Copy all items from the...
4,413,007
I want to use an ArrayList (or some other collection) like how I would use a standard array. Specifically, I want it to start with an intial size (say, SIZE), and be able to set elements explicitly right off the bat, e.g. ``` array[4] = "stuff"; ``` could be written ``` array.set(4, "stuff"); ``` However, the...
2010/12/10
[ "https://Stackoverflow.com/questions/4413007", "https://Stackoverflow.com", "https://Stackoverflow.com/users/59931/" ]
Considering that your main point is memory. Then you could manually do what the Java arraylist do, but it doesn't allow you to resize as much you want. So you can do the following: ``` 1) Create a vector. 2) If the vector is full, create a vector with the old vector size + as much you want. 3) Copy all items from the...
Yes, hashmap would be a great ideia. Other way, you could just start the array with a big capacity for you purpose.
70,436,576
I'm trying to delete `id` that doesn't contain all 3 months in month. For example, we have `df` as: ``` id month 100 1 100 2 100 3 101 2 102 3 ``` Then I would like to have the new df as just with the `id` 100 like this: ``` id month 100 1 100 2 100...
2021/12/21
[ "https://Stackoverflow.com/questions/70436576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8936041/" ]
You can use `groupby`+`transform('nunique')` and slice on the boolean output after comparison with `3`: ``` df[df.groupby('id')['month'].transform('nunique').eq(3)] ``` output: ``` id month 0 100 1 1 100 2 2 100 3 ``` *NB. if you are sure there are no duplicated months, `transform('count')`...
I think you are close, but you need to modify your code a bit. Use your code but swap `count` with `nunique` which will return a `series` showing your ID's with `True` or `False` depending whether they have all the months. Then, you can filter: ``` t = (df.groupby(['id']).month.nunique() == 3) print(df.loc[df.id.isin(...
54,403
I have a Nexus S running Cyanogen 10.1.2 (Android 4.2.2). I require adb authorization, but I accidentally "permanently" authorized a device. How do I remove the "permanent" authorization, so that every time it asks me again?
2013/10/03
[ "https://android.stackexchange.com/questions/54403", "https://android.stackexchange.com", "https://android.stackexchange.com/users/2665/" ]
If your device is rooted, as it probably is with CM, you can also do this via adb: ``` adb shell rm /data/misc/adb/adb_keys ``` Depending on your build you probably have to run adb as root(1) or call the su binary(2). (1) `adb root` or `adb kill-server; sudo $(which adb) start-server` --> `adb shell rm /data/misc/a...
Go to `Settings -> Developer options` and under the "Debugging" section tap on the `Revoke USB debugging authorizations` option. Keep in mind that it will remove **all** of the devices you're authorized, and you'll need to re-authorize them again.
54,403
I have a Nexus S running Cyanogen 10.1.2 (Android 4.2.2). I require adb authorization, but I accidentally "permanently" authorized a device. How do I remove the "permanent" authorization, so that every time it asks me again?
2013/10/03
[ "https://android.stackexchange.com/questions/54403", "https://android.stackexchange.com", "https://android.stackexchange.com/users/2665/" ]
Go to `Settings -> Developer options` and under the "Debugging" section tap on the `Revoke USB debugging authorizations` option. Keep in mind that it will remove **all** of the devices you're authorized, and you'll need to re-authorize them again.
I found it. Eventually, I checked my system variable for `ANDROID_SDK` and it was wrong (changed with the last update of Android Studio).
54,403
I have a Nexus S running Cyanogen 10.1.2 (Android 4.2.2). I require adb authorization, but I accidentally "permanently" authorized a device. How do I remove the "permanent" authorization, so that every time it asks me again?
2013/10/03
[ "https://android.stackexchange.com/questions/54403", "https://android.stackexchange.com", "https://android.stackexchange.com/users/2665/" ]
If your device is rooted, as it probably is with CM, you can also do this via adb: ``` adb shell rm /data/misc/adb/adb_keys ``` Depending on your build you probably have to run adb as root(1) or call the su binary(2). (1) `adb root` or `adb kill-server; sudo $(which adb) start-server` --> `adb shell rm /data/misc/a...
I found it. Eventually, I checked my system variable for `ANDROID_SDK` and it was wrong (changed with the last update of Android Studio).
9,954,652
I am using the following code to get a candle stick graph following the tutorial from rose india. However when i try to populate my array it throws a null pointer at create dataset . ``` public class CandleStickChart extends ApplicationFrame { static String date[]=new String[2000]; static double open[]=new ...
2012/03/31
[ "https://Stackoverflow.com/questions/9954652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1092042/" ]
You are not providing any data, only emtpy arrays (default initialized). Thus your date array contains null values, which cause the NullPointerException. I cannot see (from your code) how printing the date array can give you such a result. I tried your code and the date (d to be more exactly) contains only null values....
> > The time may be zero but does that mean it has to throw a null pointer > exception. It do throws a null pointer exception means your dataset itself is not null but when it do createCandlestickChart method with a specify data in your dataset the specify data may be null. I guess you should focus on some X value of...
991,220
Suddenly after a power failure which caused my PC to shutdown abruptly, I noticed that the mouse pointer was missing after I started the PC. When I went to see the device status, the device was showing a yellow triangle and the following message was displaying in the device status. ``` Windows cannot load the device d...
2015/10/24
[ "https://superuser.com/questions/991220", "https://superuser.com", "https://superuser.com/users/108333/" ]
There are a lot of things you can try (of course you will need another mouse or use MouseKeys to perform some actions): 1. Enable `F8` during boot by opening a console as an administrator and typing: ``` bcdedit /set {default} bootmenupolicy legacy ``` 2. Press the `F8` key during boot and then choose the option *La...
1. Go to your Windows Search, type in "drivers" and "update device drivers" should come up. 2. Click on it then go to "Mice and other pointing devices". 3. Click into it then go to your mouse (will pop up if plugged in), right click on it then "Update driver software". 4. Choose "Search automatically" and it should dow...
991,220
Suddenly after a power failure which caused my PC to shutdown abruptly, I noticed that the mouse pointer was missing after I started the PC. When I went to see the device status, the device was showing a yellow triangle and the following message was displaying in the device status. ``` Windows cannot load the device d...
2015/10/24
[ "https://superuser.com/questions/991220", "https://superuser.com", "https://superuser.com/users/108333/" ]
Use System Restore to restore your system (and the driver) back to a working state.
1. Go to your Windows Search, type in "drivers" and "update device drivers" should come up. 2. Click on it then go to "Mice and other pointing devices". 3. Click into it then go to your mouse (will pop up if plugged in), right click on it then "Update driver software". 4. Choose "Search automatically" and it should dow...
991,220
Suddenly after a power failure which caused my PC to shutdown abruptly, I noticed that the mouse pointer was missing after I started the PC. When I went to see the device status, the device was showing a yellow triangle and the following message was displaying in the device status. ``` Windows cannot load the device d...
2015/10/24
[ "https://superuser.com/questions/991220", "https://superuser.com", "https://superuser.com/users/108333/" ]
Apparently the power failure caused some damage to Windows, which you need to repair. * Check the state of the hard drive and correct any errors [using chkdsk](https://windowsinstructed.com/run-chkdsk-windows/) * Check Windows integrity by [sfc /scannow](http://www.tenforums.com/tutorials/2895-sfc-command-run-windows-...
1. Go to your Windows Search, type in "drivers" and "update device drivers" should come up. 2. Click on it then go to "Mice and other pointing devices". 3. Click into it then go to your mouse (will pop up if plugged in), right click on it then "Update driver software". 4. Choose "Search automatically" and it should dow...
991,220
Suddenly after a power failure which caused my PC to shutdown abruptly, I noticed that the mouse pointer was missing after I started the PC. When I went to see the device status, the device was showing a yellow triangle and the following message was displaying in the device status. ``` Windows cannot load the device d...
2015/10/24
[ "https://superuser.com/questions/991220", "https://superuser.com", "https://superuser.com/users/108333/" ]
There are a lot of things you can try (of course you will need another mouse or use MouseKeys to perform some actions): 1. Enable `F8` during boot by opening a console as an administrator and typing: ``` bcdedit /set {default} bootmenupolicy legacy ``` 2. Press the `F8` key during boot and then choose the option *La...
Use System Restore to restore your system (and the driver) back to a working state.
991,220
Suddenly after a power failure which caused my PC to shutdown abruptly, I noticed that the mouse pointer was missing after I started the PC. When I went to see the device status, the device was showing a yellow triangle and the following message was displaying in the device status. ``` Windows cannot load the device d...
2015/10/24
[ "https://superuser.com/questions/991220", "https://superuser.com", "https://superuser.com/users/108333/" ]
There are a lot of things you can try (of course you will need another mouse or use MouseKeys to perform some actions): 1. Enable `F8` during boot by opening a console as an administrator and typing: ``` bcdedit /set {default} bootmenupolicy legacy ``` 2. Press the `F8` key during boot and then choose the option *La...
Apparently the power failure caused some damage to Windows, which you need to repair. * Check the state of the hard drive and correct any errors [using chkdsk](https://windowsinstructed.com/run-chkdsk-windows/) * Check Windows integrity by [sfc /scannow](http://www.tenforums.com/tutorials/2895-sfc-command-run-windows-...
42,727,730
In Visual Studio 2017 we can use .editorconfig file in our project to set code style rules for the project. There is also a list of settings for Visual Studio itself presumably used when there is no editorconfig in the project. Is there a default editorconfig somewhere in Visual Studio that I can replace to set these s...
2017/03/10
[ "https://Stackoverflow.com/questions/42727730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122507/" ]
As pointed out by @gunr2171 there is no .editorconfig file in the Visual Studio settings. However as pointed out by @Hans Passant you could work around the issue by placing an .editorconfig file in the directory where you keep your projects. Because Visual Studio looks up the directory tree to find an .editorconfig wit...
Visual Studio doesn't have a machine-level `.editorconfig` file, but it does have machine-level style settings. If you have a `.editorconfig` file in your solution it will override those particular settings. From the [VS 2017 release notes](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes#coding-co...
42,727,730
In Visual Studio 2017 we can use .editorconfig file in our project to set code style rules for the project. There is also a list of settings for Visual Studio itself presumably used when there is no editorconfig in the project. Is there a default editorconfig somewhere in Visual Studio that I can replace to set these s...
2017/03/10
[ "https://Stackoverflow.com/questions/42727730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122507/" ]
Visual Studio doesn't have a machine-level `.editorconfig` file, but it does have machine-level style settings. If you have a `.editorconfig` file in your solution it will override those particular settings. From the [VS 2017 release notes](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes#coding-co...
Yes, you can do it!, and the best way to do it now is using the [EditorConfig Language Service](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.EditorConfig) extension. From the extension's description: > > The EditorConfig Project helps developers define and maintain > consistent coding styles b...
42,727,730
In Visual Studio 2017 we can use .editorconfig file in our project to set code style rules for the project. There is also a list of settings for Visual Studio itself presumably used when there is no editorconfig in the project. Is there a default editorconfig somewhere in Visual Studio that I can replace to set these s...
2017/03/10
[ "https://Stackoverflow.com/questions/42727730", "https://Stackoverflow.com", "https://Stackoverflow.com/users/122507/" ]
As pointed out by @gunr2171 there is no .editorconfig file in the Visual Studio settings. However as pointed out by @Hans Passant you could work around the issue by placing an .editorconfig file in the directory where you keep your projects. Because Visual Studio looks up the directory tree to find an .editorconfig wit...
Yes, you can do it!, and the best way to do it now is using the [EditorConfig Language Service](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.EditorConfig) extension. From the extension's description: > > The EditorConfig Project helps developers define and maintain > consistent coding styles b...
52,598,605
This is the cmd output I get. It varies with how many steps it does before the error but is always less than 20. ``` C:\Users\edupt\Documents\GitHub\Project>python object_detection/train.py \ --logtostderr \ --train_dir=train \ --pipeline_config_path=faster_rcnn_resnet101.config INFO:tensorflow:Scale of 0 disables reg...
2018/10/01
[ "https://Stackoverflow.com/questions/52598605", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9192218/" ]
I just seen this as i had the same issue. I changed my generate\_tfrecord.py with these changes: ``` for index, row in group.object.iterrows(): if (row['xmin'] / width) >= (row['xmax'] / width): pass elif (row['ymin'] / height) >= (row['ymax'] / height): pass else: ...
Turns out the issue was my annotations after all. This became clear when I noticed it crashing on the same step but changing this position when I would recreate the random ordered TF Record files. The error with was with some of my annotaiton files having the Maximums and Minimums the wrong way around.
37,479,285
I'm installing Ruby on Windows 10. I already installed Ruby 2.3 When I tried to install Rails 4.2.6 I had problems with nokogiri. Thanks to this [questions and answers](https://github.com/sparklemotion/nokogiri/issues/1456) I was able to solve by installing nokogiri version 1.6.6.4 then rails then version 1.6.8.rc3 li...
2016/05/27
[ "https://Stackoverflow.com/questions/37479285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6243793/" ]
Make sure that 'm\_lpfnCustomDeleter' is never NULL or better nullptr. You can make sure of this by falling back to a default 'deleter' if the user does not provide with any custom deleter. I would prefer something like below. ``` #include <iostream> template <typename PointerType> struct DefaultDeleter { void ope...
Separate the code doing the deleting from the rest: ``` if (m_pList[m_nListLastUsed]) { if (m_lpfnCustomDeleter == NULL) delete m_pList[m_nListLastUsed]; // COMPILE ERROR HERE BECAUSE Search destructor is private BUT I won't use that instruction since ...
54,663,213
I want to change the background color of value selected. I have tried it using ng class and ngmodel but is not working as per expectations. Below is my parent ts file. ``` users = USERS; selectedUser = 0; isSelected = false; constructor() { } ngOnInit() { } onSelect(index): void { this.selectedUser = index; console...
2019/02/13
[ "https://Stackoverflow.com/questions/54663213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10994151/" ]
try like this ``` <tr *ngFor="let user of users; let i = index" (click)="onSelect(i)" [class.selected]="i==selectedUser"> <td>{{ user.name }}</td> ``` Basically you need to match selected row index value with `selecteduser` value that you are setting in your `onSelect` method note : you can use `ngClas...
There's no correct binding for `isSelected`. This may what you intended: ``` <tr *ngFor="let user of users; let i = index" (click)="onSelect(i)" [ngClass]="{'select': selectedUser == i}"> ... ```
54,663,213
I want to change the background color of value selected. I have tried it using ng class and ngmodel but is not working as per expectations. Below is my parent ts file. ``` users = USERS; selectedUser = 0; isSelected = false; constructor() { } ngOnInit() { } onSelect(index): void { this.selectedUser = index; console...
2019/02/13
[ "https://Stackoverflow.com/questions/54663213", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10994151/" ]
try like this ``` <tr *ngFor="let user of users; let i = index" (click)="onSelect(i)" [class.selected]="i==selectedUser"> <td>{{ user.name }}</td> ``` Basically you need to match selected row index value with `selecteduser` value that you are setting in your `onSelect` method note : you can use `ngClas...
Corrected syntax will be - ``` [ngClass]="{'select': isSelected}" ```