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
25,932,257
I would like to show a different **div** depending on what class my 3 **span** elems contain. If all **span** hasClass *up* or *up1* the code would show a **div** with class *allUp* . If it hasClass *up* *up1* and *down* then it would show a **div** with class *twoUp*. I wrote the following, but of course it doesn't w...
2014/09/19
[ "https://Stackoverflow.com/questions/25932257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3246460/" ]
Through my substantial searches on Mockito I found there are two types of mocking: 1. Proxy Mocking (Usual stubbing) 2. Class remapping(Only Jmockit supports) You can read about "How Mock Objects Work" [here](http://java.dzone.com/articles/the-concept-mocking). For my question, Class Remapping was the solution Anot...
I think your tests are telling you that database records are hard to implement as unmodifiable objects. How about adding ``` Person updateName(String name); ``` to Person class?
25,932,257
I would like to show a different **div** depending on what class my 3 **span** elems contain. If all **span** hasClass *up* or *up1* the code would show a **div** with class *allUp* . If it hasClass *up* *up1* and *down* then it would show a **div** with class *twoUp*. I wrote the following, but of course it doesn't w...
2014/09/19
[ "https://Stackoverflow.com/questions/25932257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3246460/" ]
Just for the record, here is what the test class looks like with JMockit 1.12: ``` public class PersonServiceTest { @Tested PersonService personService; @Mocked PersonDao personDAO; @Test public void shouldUpdatePersonName() { final Person person = new Person(1, "Phillip"); new No...
I think your tests are telling you that database records are hard to implement as unmodifiable objects. How about adding ``` Person updateName(String name); ``` to Person class?
25,932,257
I would like to show a different **div** depending on what class my 3 **span** elems contain. If all **span** hasClass *up* or *up1* the code would show a **div** with class *allUp* . If it hasClass *up* *up1* and *down* then it would show a **div** with class *twoUp*. I wrote the following, but of course it doesn't w...
2014/09/19
[ "https://Stackoverflow.com/questions/25932257", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3246460/" ]
Through my substantial searches on Mockito I found there are two types of mocking: 1. Proxy Mocking (Usual stubbing) 2. Class remapping(Only Jmockit supports) You can read about "How Mock Objects Work" [here](http://java.dzone.com/articles/the-concept-mocking). For my question, Class Remapping was the solution Anot...
Just for the record, here is what the test class looks like with JMockit 1.12: ``` public class PersonServiceTest { @Tested PersonService personService; @Mocked PersonDao personDAO; @Test public void shouldUpdatePersonName() { final Person person = new Person(1, "Phillip"); new No...
62,271
During the Punk Hazard arc, Trafalgar Law swaps Sanji into Nami's body and Smoker into Tashigi's. In spite of them being in bodies not addicted to nicotine, it seems they both still need to smoke. Nami (in Franky's body) even offers Sanji a pack of cigarettes saying something to the effect, "You need them, right?" Whe...
2021/03/23
[ "https://anime.stackexchange.com/questions/62271", "https://anime.stackexchange.com", "https://anime.stackexchange.com/users/19307/" ]
If you ask any smoker, he will tell you that most of the addiction comes from the brain as it gives the neuro-signals for pleasure when smoking. Most smokers can't quit not because the body demands nicotine, but because of the apparent relaxating effect that is produced by smoking and the habbit that results from it. ...
Simple Answer: Law's DF is wired (even kadio annoyed by that), and even a mystery to that point. It was stated, one of the most usable, power devil fruit in the world. So, How law can change someone's mind(brain) to another person by swiping their hearts! It ven does seems, it's only the conscious state. And sub part...
62,271
During the Punk Hazard arc, Trafalgar Law swaps Sanji into Nami's body and Smoker into Tashigi's. In spite of them being in bodies not addicted to nicotine, it seems they both still need to smoke. Nami (in Franky's body) even offers Sanji a pack of cigarettes saying something to the effect, "You need them, right?" Whe...
2021/03/23
[ "https://anime.stackexchange.com/questions/62271", "https://anime.stackexchange.com", "https://anime.stackexchange.com/users/19307/" ]
If you ask any smoker, he will tell you that most of the addiction comes from the brain as it gives the neuro-signals for pleasure when smoking. Most smokers can't quit not because the body demands nicotine, but because of the apparent relaxating effect that is produced by smoking and the habbit that results from it. ...
I don't think this question can be fully answered, so I'll just list out some possibilities, as well as some evidence for and against. **First Possibility**: Law actually swapped not only their brains, but a lot of their internals as well. Sanji in Nami's body claims to be the best swimmer on the crew and thus he has ...
29,794,536
Hi i m using datepicker to get the date. I had done the jquery datepicker but **its returns undefined value**. please help me. HTML CODE ``` <input type="text" class="form-control fromdate" id="datepicker" name="from_date" placeholder="From date" value="<?php echo set_value('from_date'); ?>" > ``` script ``` var f...
2015/04/22
[ "https://Stackoverflow.com/questions/29794536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4809070/" ]
When you are using a jQuery UI widget, you first have to instantiate the widget before calling any functions on it: ``` $(function() { //Instanciate the widget $( ".fromdate" ).datepicker(); //Access to widget's functions alert($( ".fromdate" ).datepicker('getDate')) }); ``` [jsFiddle](http://jsfiddl...
Without your full page/code this is guesswork, but using `datepicker` is pretty simple. You need to "turn it on first", then use it: ``` $('.fromdate').datepicker({ onSelect: function (dateText) { var fromdate = $('.fromdate').datepicker('getDate'); alert(fromdate); } }); ``` **JSFiddle:** <h...
29,794,536
Hi i m using datepicker to get the date. I had done the jquery datepicker but **its returns undefined value**. please help me. HTML CODE ``` <input type="text" class="form-control fromdate" id="datepicker" name="from_date" placeholder="From date" value="<?php echo set_value('from_date'); ?>" > ``` script ``` var f...
2015/04/22
[ "https://Stackoverflow.com/questions/29794536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4809070/" ]
When you are using datepicker we need to initalize it first ``` <input type="text" class="form-control fromdate" id="datepicker" name="from_date" value="2015-4-10" /> <script> $(document).ready(function(){ $('.fromdate').datepicker({ dateFormat: 'yy-m-d', inline: true, onSelect: function(dateText, ...
When you are using a jQuery UI widget, you first have to instantiate the widget before calling any functions on it: ``` $(function() { //Instanciate the widget $( ".fromdate" ).datepicker(); //Access to widget's functions alert($( ".fromdate" ).datepicker('getDate')) }); ``` [jsFiddle](http://jsfiddl...
29,794,536
Hi i m using datepicker to get the date. I had done the jquery datepicker but **its returns undefined value**. please help me. HTML CODE ``` <input type="text" class="form-control fromdate" id="datepicker" name="from_date" placeholder="From date" value="<?php echo set_value('from_date'); ?>" > ``` script ``` var f...
2015/04/22
[ "https://Stackoverflow.com/questions/29794536", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4809070/" ]
When you are using datepicker we need to initalize it first ``` <input type="text" class="form-control fromdate" id="datepicker" name="from_date" value="2015-4-10" /> <script> $(document).ready(function(){ $('.fromdate').datepicker({ dateFormat: 'yy-m-d', inline: true, onSelect: function(dateText, ...
Without your full page/code this is guesswork, but using `datepicker` is pretty simple. You need to "turn it on first", then use it: ``` $('.fromdate').datepicker({ onSelect: function (dateText) { var fromdate = $('.fromdate').datepicker('getDate'); alert(fromdate); } }); ``` **JSFiddle:** <h...
1,069,433
Below is the sample code. ``` - (void) keyDown: (NSEvent *) event { NSString *chars = [event characters]; unichar character = [chars characterAtIndex: 0]; if (character == 27) { NSLog (@"ESCAPE!"); } } ``` Should I need to set any delegate in InterfaceBuilder or any kinda binding?? Help ...
2009/07/01
[ "https://Stackoverflow.com/questions/1069433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
`keyDown` needs to be overridden in an `NSView` subclass whose object is set as first responder. The responder chain *should* pass down the event, but to be sure you get it, make sure that your object is first responder.
In cocoa only views participate in responder chain for this event. So you should override a some view method. The easy way is to find out what view is first responder for particular event you want to handle and use it. window sends `keyDown(with: )` stright to first responder which could handle it or pass up to respon...
18,710,548
I run node with ``` node --debug app OR node --debug-brk app ``` it responds ``` debugger listening on port 5858 Express server listening on port 1338 ``` I now start node-inspector ``` node-inspector --web-port=5859 ``` It responds with ``` Node Inspector v0.3.2 info - socket.io started Visit http://127.0...
2013/09/10
[ "https://Stackoverflow.com/questions/18710548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/529273/" ]
With your first attempt, you're telling node-inspector to try to connect to the debugger on 5859 (not default), then telling node debugger to listen on the default 5858. Start node: `node --debug-brk app.js` and it will run the debugger on 5858. Start node-inspector: `node-inspector` and it will try to connect to 585...
This are some steps may help you. * Try to visit `chrome`. * Open New Tab * Type `chrome://inspect` * This will open a Window, where you find the `Remote Target #LOCALHOST` * You will find your node file name below `target` header. * Click the link, This will open a debugger window for you. That's It. Happy debugging...
4,087,996
Assume that I have a project that contains two buttons on it. Each buttons generate a custom form. I wrote both forms manually. But I wonder, is there a way that I can make these forms by using toolbox in different projects and combine them in one solution. I mean, when I press a button I want to call another project. ...
2010/11/03
[ "https://Stackoverflow.com/questions/4087996", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235174/" ]
You can call a form from another project (if we are talking about VS project) if it is public. You need to add reference to the project where this form is "placed" to the project where the call is made. Of course, you can create forms manually, but you can as well create new windows form and add controls to it via des...
Yes you can invoke the forms even if they are in different projects. But you need to have references to that projects and to have defined a proper using statements.
4,383,958
I am having trouble with a part of my assignment. I need to show that $||x - P\_Ex||^2$ = $||x||^2 - \sum\_{j=1}^n |\langle e\_j,x \rangle|^2$ where $e\_j$ is in a hilbert space and an orthonormal set, and $P\_Ex$ is the orthogonal projection of x onto E and is defined as $P\_Ex = \sum\_{i=1}^n \langle e\_i,x \rangl...
2022/02/16
[ "https://math.stackexchange.com/questions/4383958", "https://math.stackexchange.com", "https://math.stackexchange.com/users/1026361/" ]
Use uniqueness. Let $z(x) := -y(-x)$. Then $$ z'(x) = y'(-x) = x^2 + y(-x)^2 + 1 = x^2 + z^2(x) + 1 $$ as $z(0) = 0$, by uniqueness, $z = y$ and $y$ is odd.
(C) is also correct. By implicit differentiation, $\frac12(y^2)' = yy' = y(x^2+y^2+1)$. So $\frac12(y^2)'' = y'(x^2+y^2+1) + y(2x+2yy')$. From this we deduce that $(y^2)' = 0$ at $x=0$ and $(y^2)'' = 1$ at $x=0$, and so $y^2$ has a local minimum at $0$.
25,422,407
I had a problem when parse my json data with php in select html element This my [JSON DATA](http://en.textsave.org/WjQ) This my [PHP CODE](http://txs.io/Yfqb) Error message : ``` Notice: Trying to get property of non-object in C:\xampp\htdocs\test\index.php on line 6 ``` This line 6 : ``` $provider = $jfo->prod...
2014/08/21
[ "https://Stackoverflow.com/questions/25422407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2746365/" ]
product is not an object, it is an array: ``` $jfo->product['provider']; ```
It appears that `product` is not an object. Have you tried dumping $jfo->product? My guess is that it is an array.
25,422,407
I had a problem when parse my json data with php in select html element This my [JSON DATA](http://en.textsave.org/WjQ) This my [PHP CODE](http://txs.io/Yfqb) Error message : ``` Notice: Trying to get property of non-object in C:\xampp\htdocs\test\index.php on line 6 ``` This line 6 : ``` $provider = $jfo->prod...
2014/08/21
[ "https://Stackoverflow.com/questions/25422407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2746365/" ]
product is an array, containing multiple products. ``` $jfo->product[0]->provider; ``` You'll need to loop through the products. ``` for ($i = 0; $i < sizeof($jfo->product); $i++) { $provider = $jfo->product[$i]->provider; } ```
It appears that `product` is not an object. Have you tried dumping $jfo->product? My guess is that it is an array.
1,544,160
I have written an authentication class controller containing a method to check login status of user, and redirect him to login page if he/she is not logged in. I need to call this function from other controller methods to authenticate the user. What is a good way to do that?
2009/10/09
[ "https://Stackoverflow.com/questions/1544160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6561/" ]
Take that method out of that controller. Assuming you have a User model, that is a great place to put it if it is authenticating a user and logging them in. Other places that you may put repeatable code is in helpers (static functions) and libraries (classes).
Take the function to a Model or code it in a library. Helpers I won't recommend as you are not advised to access the database from Helpers. Easy way out is put it in a model say user\_model and call it by any controller anywhere.
1,544,160
I have written an authentication class controller containing a method to check login status of user, and redirect him to login page if he/she is not logged in. I need to call this function from other controller methods to authenticate the user. What is a good way to do that?
2009/10/09
[ "https://Stackoverflow.com/questions/1544160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6561/" ]
Take that method out of that controller. Assuming you have a User model, that is a great place to put it if it is authenticating a user and logging them in. Other places that you may put repeatable code is in helpers (static functions) and libraries (classes).
I put a check login method in base controller, which is extended by all controllers. Now if a controller's action requires users to be logged in, I call it there like `parent::_check_login()`, if the whole controller requires it I call it from the constructor of that controller, that's all.
1,544,160
I have written an authentication class controller containing a method to check login status of user, and redirect him to login page if he/she is not logged in. I need to call this function from other controller methods to authenticate the user. What is a good way to do that?
2009/10/09
[ "https://Stackoverflow.com/questions/1544160", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6561/" ]
Take that method out of that controller. Assuming you have a User model, that is a great place to put it if it is authenticating a user and logging them in. Other places that you may put repeatable code is in helpers (static functions) and libraries (classes).
sumanchalki is correct but he might not be giving quite enough information on how to do it. [CodeIgniter Base Classes: Keeping it DRY](http://philsturgeon.co.uk/news/2010/02/CodeIgniter-Base-Classes-Keeping-it-DRY) This will show you how to make named base controllers such as a Admin Controller which could contain yo...
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Consider using comprehension ```py usernames: dict = {idx: "" for idx in range(1001)} ```
Try this. ``` usernames = {} for i in range(0, 100): usernames[i] = "" ```
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Consider using comprehension ```py usernames: dict = {idx: "" for idx in range(1001)} ```
Assuming your use-case: > > want to use this dict as a "database" to store hardcoded data > > > ### The database approach Most databases don't reserve space upfront and create something like dummy-records. Nor do they create and reserve keys in advance. What a typical database and the setup for a collection or ...
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
This looks like the kind of thing you should do programmatically rather than manually editing a file. For sequential numeric keys, consider using a list instead of a dict. If you really need a dict, then use a dict comprehension as Demitri shows or `defaultdict` which allows you to provide a default value for any key ...
Try this. ``` usernames = {} for i in range(0, 100): usernames[i] = "" ```
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Start by creating a dictionary: ``` dictionary = {} ``` Now you can use a for loop to create the keys: ``` for num in range(1001): dictionary[num] = "" ```
Try this. ``` usernames = {} for i in range(0, 100): usernames[i] = "" ```
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Use the classmethod factory [`fromkeys`](https://docs.python.org/3/library/stdtypes.html#dict.fromkeys): ``` dict.fromkeys(range(1001), "") ``` And perhaps consider using a list. This is more memory efficient than using a dict with consecutive integer keys. ``` [""] * 1001 ```
Try this. ``` usernames = {} for i in range(0, 100): usernames[i] = "" ```
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Assuming your use-case: > > want to use this dict as a "database" to store hardcoded data > > > ### The database approach Most databases don't reserve space upfront and create something like dummy-records. Nor do they create and reserve keys in advance. What a typical database and the setup for a collection or ...
Try this. ``` usernames = {} for i in range(0, 100): usernames[i] = "" ```
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
This looks like the kind of thing you should do programmatically rather than manually editing a file. For sequential numeric keys, consider using a list instead of a dict. If you really need a dict, then use a dict comprehension as Demitri shows or `defaultdict` which allows you to provide a default value for any key ...
Assuming your use-case: > > want to use this dict as a "database" to store hardcoded data > > > ### The database approach Most databases don't reserve space upfront and create something like dummy-records. Nor do they create and reserve keys in advance. What a typical database and the setup for a collection or ...
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Start by creating a dictionary: ``` dictionary = {} ``` Now you can use a for loop to create the keys: ``` for num in range(1001): dictionary[num] = "" ```
Assuming your use-case: > > want to use this dict as a "database" to store hardcoded data > > > ### The database approach Most databases don't reserve space upfront and create something like dummy-records. Nor do they create and reserve keys in advance. What a typical database and the setup for a collection or ...
73,378,056
I am working on a simple simulator for a radio frequency application and have to deal with very low complex numbers. During the process I have a Matrix like `np.array([[A,B],[C,D]], dtype=np.clongdouble)` which ensures the necessary "resolution(?)". However, I have to do stuff like ``` den = A+B/z0+C*z0+D s11 = A+B/z0...
2022/08/16
[ "https://Stackoverflow.com/questions/73378056", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5962420/" ]
Use the classmethod factory [`fromkeys`](https://docs.python.org/3/library/stdtypes.html#dict.fromkeys): ``` dict.fromkeys(range(1001), "") ``` And perhaps consider using a list. This is more memory efficient than using a dict with consecutive integer keys. ``` [""] * 1001 ```
Assuming your use-case: > > want to use this dict as a "database" to store hardcoded data > > > ### The database approach Most databases don't reserve space upfront and create something like dummy-records. Nor do they create and reserve keys in advance. What a typical database and the setup for a collection or ...
30,217,446
I have the following Activity that throws an exception if something is configured wrong. ``` public class MyActivity extends AppCompatActivity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); throw new IllegalStateException("something w...
2015/05/13
[ "https://Stackoverflow.com/questions/30217446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/669294/" ]
You are throwing `IllegalArgumentException` and catching `IllegalStateException`. You can add another catch block with catching `Exception` - it will work.
Why do you mock the class you are trying to test? You should mock dependencies of `MyActivity` to test that its methods are correctly using the mocks. For example if you want to test class `A` which depends on `B` and `C`, then you want to create 2 mocks for `B` and `C` and a concrete object of `A`. Then you inject th...
30,217,446
I have the following Activity that throws an exception if something is configured wrong. ``` public class MyActivity extends AppCompatActivity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); throw new IllegalStateException("something w...
2015/05/13
[ "https://Stackoverflow.com/questions/30217446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/669294/" ]
You are throwing `IllegalArgumentException` and catching `IllegalStateException`. You can add another catch block with catching `Exception` - it will work.
`getActivity` is indeed calling `onCreate` method, so it is failing with your programmed exception and it throws another one (`RuntimeException`) with your generated one as the root cause.
30,217,446
I have the following Activity that throws an exception if something is configured wrong. ``` public class MyActivity extends AppCompatActivity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); throw new IllegalStateException("something w...
2015/05/13
[ "https://Stackoverflow.com/questions/30217446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/669294/" ]
Why do you mock the class you are trying to test? You should mock dependencies of `MyActivity` to test that its methods are correctly using the mocks. For example if you want to test class `A` which depends on `B` and `C`, then you want to create 2 mocks for `B` and `C` and a concrete object of `A`. Then you inject th...
`getActivity` is indeed calling `onCreate` method, so it is failing with your programmed exception and it throws another one (`RuntimeException`) with your generated one as the root cause.
27,711,766
I am using **Page** classes to its **NavigationService.Navigate** API to create navigation between few pages. In the page I have provided buttons for navigation but I am getting following control for free. ![enter image description here](https://i.stack.imgur.com/tYtRh.png) Is there someway to hide this control so th...
2014/12/30
[ "https://Stackoverflow.com/questions/27711766", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4059893/" ]
Is your page rendered inside of a frame? A frame by default supports Navigation. If this is the case you have to set the navigation visibility property of the frame control to hidden. ``` <Frame Name="Frame1" NavigationUIVisibility="Hidden" > ```
Yes, `Page` object has `ShowsNavigationUI` property that you can use. ``` <Page ... ShowsNavigationUI="False"> <Grid Background="LightBlue" /> </Page> ```
46,707,234
Here is my code: ``` using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine; using System; using System.IO; public class CarMove : MonoBehaviour { public unsafe struct TrafficRoadSystem { }; public unsafe struct CarsSimulation { }; public unsafe struct CarP...
2017/10/12
[ "https://Stackoverflow.com/questions/46707234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8764416/" ]
Making a C or C++ plugin in Unity requires extensive knowledge of these languages. This means you should spend time learning pointers before attempting to use raw pointer in Unity. Because even if you get it to compile, you may also run into hard to fix crashes. You have: ``` unsafe TrafficRoadSystem* trafficRoadSyst...
An alternative to using raw Pointers is to use Marshalling. Marshalling allows you to take C# data structures and transform them to C-understandable data without the need of any unsafe-keywords. Mono has a [document](http://www.mono-project.com/docs/advanced/pinvoke/) describing how to properly interact with native li...
35,274
There's a dead, gnarly old tree in the courtyard outside of Denethor's 'throne room' on the top level of Minas Tirith. Gandalf told Pippin that it's called the White Tree of Gondor. We see it several times in 'Return of the King' and it's obviously dried-up dead. Yet after they defeat Sauron and Aragorn is crowned King...
2013/05/07
[ "https://scifi.stackexchange.com/questions/35274", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/13090/" ]
One word: Jackson. A second word: nonsense. The story is different in the books - Aragorn finds a sapling of the dead tree and plants it, which becomes the new White Tree: > > Then Aragorn turned, and there was a stony slope behind him running down from the skirts of the snow; and as he looked he was aware that alon...
Indeed, Peter Jackson did somewhat over-dramatise this part, though I find the original fairly dramatic/moving in of itself. Further to Jimmy S's point, Tolkien describes the history of Minas Tirith, where the White Tree would regularly start to die but the King/Stewards would plant a new sapling: > > When King Tele...
35,274
There's a dead, gnarly old tree in the courtyard outside of Denethor's 'throne room' on the top level of Minas Tirith. Gandalf told Pippin that it's called the White Tree of Gondor. We see it several times in 'Return of the King' and it's obviously dried-up dead. Yet after they defeat Sauron and Aragorn is crowned King...
2013/05/07
[ "https://scifi.stackexchange.com/questions/35274", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/13090/" ]
One word: Jackson. A second word: nonsense. The story is different in the books - Aragorn finds a sapling of the dead tree and plants it, which becomes the new White Tree: > > Then Aragorn turned, and there was a stony slope behind him running down from the skirts of the snow; and as he looked he was aware that alon...
Others have answered in terms of the books, but another answer is possible if we ignore the books (I can't believe I just said those words!), and look only for movie-logic Basically the answer is, "it's magic". But it's not completely abrupt. There's a moment in the movie (when Denethor is *en route* to immolating him...
71,416,848
Is there anyway to use the reference funtion in an ARM parameter file? I understand the following can be used to retrieve the intrumentation key of an app insights instance but this doesnt seem to work in a parameter file. ``` "[reference('microsoft.insights/components/web-app-name-01', '2015-05-01').InstrumentationKe...
2022/03/09
[ "https://Stackoverflow.com/questions/71416848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13283222/" ]
Not in a param file... it's possible to simulate what you want by nested a deployment if that's an option. So your param file can contain the resourceId of the insights resource and then a nested deployment can make the reference call - but TBH, probably easier to fetch the key as a pipeline step (or similar). ```json...
### Way 1 Use the **reference** function in your parameter file for resources that are already deployed in another template. For that you have to pass the **ApiVersion** parameter. Refer [MsDoc](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#reference). which follo...
71,416,848
Is there anyway to use the reference funtion in an ARM parameter file? I understand the following can be used to retrieve the intrumentation key of an app insights instance but this doesnt seem to work in a parameter file. ``` "[reference('microsoft.insights/components/web-app-name-01', '2015-05-01').InstrumentationKe...
2022/03/09
[ "https://Stackoverflow.com/questions/71416848", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13283222/" ]
Unfortunately, no. Reference function only works at runtime. It can't be used in the parameters or variables sections because both are resolved during the initial parsing phase of the template. Here is an excerpt from [the docs](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/best-practices) ...
### Way 1 Use the **reference** function in your parameter file for resources that are already deployed in another template. For that you have to pass the **ApiVersion** parameter. Refer [MsDoc](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-resource#reference). which follo...
9,844,499
I am looking for a script that shows my logo while loading the game and shows the loading percentage or a bar representing how much of the game is loaded, and then makes my logo disappear once the game is loaded. e-g like this site has used <http://www.gamegape.com/en-2095-elemental-battles.html> If something like th...
2012/03/23
[ "https://Stackoverflow.com/questions/9844499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1303767/" ]
This might help. Its a JavaScript Preloader for HTML5 Apps <http://thinkpixellab.com/pxloader/> have alook at the smples page.
The site you have mentioned is using flash, well this can easily be achieved by js or css3 itself. Check this eaxample out for a progress bar <http://ivanvanderbyl.com/>. You can either add animations using jquery or by css3.
65,651,835
```java public class Second_Largest_Number_In_Array_with_Dupes { public static void main(String[] args) { int[] a = {6,8,2,4,3,1,5,7}; int temp ; for (int i = 0; i < a.length; i++){ for (int j = i + 1; j < a.length; j++){ if (a[i] < a[j]){ ...
2021/01/10
[ "https://Stackoverflow.com/questions/65651835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3813730/" ]
Solution -------- * Initialize max and second\_max with the lowest possible value `Integer.MIN_Value` * Then go through your array and check for each element if it is greater then the `max_value` -> When yes reassign your max\_value with a[i] and reassign your second\_max\_value with max\_malue --- ``` if (a[i] > m...
You could take advantage of java inbuild collection. For that you need a structure that retain values with no duplicates and also store values in order (eg: natural-order, ascending this case). ``` import java.util.SortedSet; import java.util.TreeSet; public class MinArr { public static void main(String[] ...
65,651,835
```java public class Second_Largest_Number_In_Array_with_Dupes { public static void main(String[] args) { int[] a = {6,8,2,4,3,1,5,7}; int temp ; for (int i = 0; i < a.length; i++){ for (int j = i + 1; j < a.length; j++){ if (a[i] < a[j]){ ...
2021/01/10
[ "https://Stackoverflow.com/questions/65651835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3813730/" ]
Solution -------- * Initialize max and second\_max with the lowest possible value `Integer.MIN_Value` * Then go through your array and check for each element if it is greater then the `max_value` -> When yes reassign your max\_value with a[i] and reassign your second\_max\_value with max\_malue --- ``` if (a[i] > m...
The best way to get k highest number in the array if space is not a constraint then we can use priority queue. ``` int[] a = {6,8,2,4,3,1,5,7}; PriorityQueue<Integer> pr = new PriorityQueue<Integer>(Collections.reverseOrder()); for (int i = 0; i < a.length; i++) { pr.add(a[i]); }...
65,651,835
```java public class Second_Largest_Number_In_Array_with_Dupes { public static void main(String[] args) { int[] a = {6,8,2,4,3,1,5,7}; int temp ; for (int i = 0; i < a.length; i++){ for (int j = i + 1; j < a.length; j++){ if (a[i] < a[j]){ ...
2021/01/10
[ "https://Stackoverflow.com/questions/65651835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3813730/" ]
Alternatively to the correct answer, one can also use the following algorithm: ``` public static void main(String[] args) { int [] a= {6,8,2,4,3,1,5,7,8} ; SortedSet<Integer> sortedSet = new TreeSet<Integer>(); Arrays.stream(a).forEach(sortedSet::add); sortedSet.remove(sortedSet.last()); System.out...
You could take advantage of java inbuild collection. For that you need a structure that retain values with no duplicates and also store values in order (eg: natural-order, ascending this case). ``` import java.util.SortedSet; import java.util.TreeSet; public class MinArr { public static void main(String[] ...
65,651,835
```java public class Second_Largest_Number_In_Array_with_Dupes { public static void main(String[] args) { int[] a = {6,8,2,4,3,1,5,7}; int temp ; for (int i = 0; i < a.length; i++){ for (int j = i + 1; j < a.length; j++){ if (a[i] < a[j]){ ...
2021/01/10
[ "https://Stackoverflow.com/questions/65651835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3813730/" ]
Alternatively to the correct answer, one can also use the following algorithm: ``` public static void main(String[] args) { int [] a= {6,8,2,4,3,1,5,7,8} ; SortedSet<Integer> sortedSet = new TreeSet<Integer>(); Arrays.stream(a).forEach(sortedSet::add); sortedSet.remove(sortedSet.last()); System.out...
The best way to get k highest number in the array if space is not a constraint then we can use priority queue. ``` int[] a = {6,8,2,4,3,1,5,7}; PriorityQueue<Integer> pr = new PriorityQueue<Integer>(Collections.reverseOrder()); for (int i = 0; i < a.length; i++) { pr.add(a[i]); }...
54,983,334
I'm trying to create a UI test for my android application using Espresso. My activities are extending `AppCompatActivity` and I'm using `ActivityTestRule` to launch the activity but it gives this exception: ``` Type parameter bound for T in constructor ActivityTestRule<T : Activity (activityClass: Class<T!>!)is not s...
2019/03/04
[ "https://Stackoverflow.com/questions/54983334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1754112/" ]
This was happening to me on a separate module I created for my tests. I have a `base-android` module that hold my `BaseActivity` and did not import it on my tests module. As it cannot see the imported base activity, the test cannot see its super type. Importing the `base-android` module on my `tests` module fixed the i...
This can happen in a `com.android.test` module, when the versions of appcompat were different between the main app, and the test module. Fix is to explicitly declare the appcompat dependency with version number in both `app/build.gradle` and `testmodule/build.gradle`, so you get the same version in both.
280,901
I made a bone-headed mistake in one of my init.d scripts which gets stuck in an infinite loop during the boot process and blocks the completion. I therefore can not get to a shell and fix it. How can I boot and not perform all the boot scripts? I have root if necessary.
2011/06/16
[ "https://serverfault.com/questions/280901", "https://serverfault.com", "https://serverfault.com/users/20943/" ]
You can't. Quote from [SQL Azure Overview (http://msdn.microsoft.com/en-us/library/ee336241.aspx)](http://msdn.microsoft.com/en-us/library/ee336241.aspx) > > For example, you cannot specify the > physical hard drive or file group > where a database or index will reside. > Because the computer file system is > n...
Not 100% sure, but I know that Azure is a subset of SQL so they might not allow restoration of a backup in case you're using functionality and features that are not included in Azure. You're discovering the biggest issue (in my mind) of working with SQL Azure, there aren't "simple" ways to sync between a local databas...
280,901
I made a bone-headed mistake in one of my init.d scripts which gets stuck in an infinite loop during the boot process and blocks the completion. I therefore can not get to a shell and fix it. How can I boot and not perform all the boot scripts? I have root if necessary.
2011/06/16
[ "https://serverfault.com/questions/280901", "https://serverfault.com", "https://serverfault.com/users/20943/" ]
Backup and Restore aren't current supports by SQL Azure. There are various ways to backup data including using BCP, Data Sync Services. I wrote a small (currently free) tool that creates a backup of a SQL Azure database on a local SQL Server, cunningly called SQL Azure Backup. Really interested in getting feedback on ...
Not 100% sure, but I know that Azure is a subset of SQL so they might not allow restoration of a backup in case you're using functionality and features that are not included in Azure. You're discovering the biggest issue (in my mind) of working with SQL Azure, there aren't "simple" ways to sync between a local databas...
280,901
I made a bone-headed mistake in one of my init.d scripts which gets stuck in an infinite loop during the boot process and blocks the completion. I therefore can not get to a shell and fix it. How can I boot and not perform all the boot scripts? I have root if necessary.
2011/06/16
[ "https://serverfault.com/questions/280901", "https://serverfault.com", "https://serverfault.com/users/20943/" ]
You can't. Quote from [SQL Azure Overview (http://msdn.microsoft.com/en-us/library/ee336241.aspx)](http://msdn.microsoft.com/en-us/library/ee336241.aspx) > > For example, you cannot specify the > physical hard drive or file group > where a database or index will reside. > Because the computer file system is > n...
Backup and Restore aren't current supports by SQL Azure. There are various ways to backup data including using BCP, Data Sync Services. I wrote a small (currently free) tool that creates a backup of a SQL Azure database on a local SQL Server, cunningly called SQL Azure Backup. Really interested in getting feedback on ...
52,417,327
I am using a regular expression to capture a URL string, but it's not working out. Here's my code, which is coming from an external JavaScript document, linked to the HTML file: ``` var url = 'The URL was www.google.com'; var urlRegEx = /((\bhttps?:\/\/)|(\bwww\.))\S*/; var urlRegMatch = url.match(urlRegEx); document...
2018/09/20
[ "https://Stackoverflow.com/questions/52417327", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10109002/" ]
Your regex works fine, what happens is that according to the match function you are getting one extra result for each group (defined by these parenthesis) that you have in your regex. to access the whole match you can access to the first item of the match return like the following: ``` var url = 'The URL was www.googl...
I'd like to thank @Dknacht and @Tressa for directing me to the correct answer, since the first value of the array, 0, is the matched text. This code works for what I want to do: ``` var url = 'The URL was www.google.com'; var urlRegEx = /((\bhttps?:\/\/)|(\bwww\.))\S*/ var urlRegMatch = url.match(urlRegEx); document...
16,844,356
In my project I have 5-6 Activities. Now I want to set a `Spinner` at the top of an activity, i.e. in the top corner, in front of the title. Suppose we are in Activity 1: then by using Spinner, in front of the title name, we can go to any of the other activities. Same thing should happen in all activities. Please ...
2013/05/30
[ "https://Stackoverflow.com/questions/16844356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2126417/" ]
In all likelihood, the intermediate assigment will be optimized away by the JVM, and they will have exactly the same performance. In either case, the possible performance hits for these things are hardly ever noticeable. You shouldn't worry about performance unless in extreme circumstances. Always opt for readability...
you could profile both implementations with a tool like JVisualVM to see the exact difference. In case you want to test with high volume you could use a tool like Contiperf <http://databene.org/contiperf> And then share the results for all of us :)
16,844,356
In my project I have 5-6 Activities. Now I want to set a `Spinner` at the top of an activity, i.e. in the top corner, in front of the title. Suppose we are in Activity 1: then by using Spinner, in front of the title name, we can go to any of the other activities. Same thing should happen in all activities. Please ...
2013/05/30
[ "https://Stackoverflow.com/questions/16844356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2126417/" ]
In all likelihood, the intermediate assigment will be optimized away by the JVM, and they will have exactly the same performance. In either case, the possible performance hits for these things are hardly ever noticeable. You shouldn't worry about performance unless in extreme circumstances. Always opt for readability...
I agree with Keppil that the performance is probably exactly the same. If there is a slight difference, and if you care about such a small improvement in performance, then you probably shouldn't be using Java in the first place.
16,844,356
In my project I have 5-6 Activities. Now I want to set a `Spinner` at the top of an activity, i.e. in the top corner, in front of the title. Suppose we are in Activity 1: then by using Spinner, in front of the title name, we can go to any of the other activities. Same thing should happen in all activities. Please ...
2013/05/30
[ "https://Stackoverflow.com/questions/16844356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2126417/" ]
you could profile both implementations with a tool like JVisualVM to see the exact difference. In case you want to test with high volume you could use a tool like Contiperf <http://databene.org/contiperf> And then share the results for all of us :)
I agree with Keppil that the performance is probably exactly the same. If there is a slight difference, and if you care about such a small improvement in performance, then you probably shouldn't be using Java in the first place.
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
``` Object o = new Student(); //upcasting - Implicit cast Student x = (Student) o; //downcasting -Explicit cast ``` **Upcasting**: We're narrowing the reference conversion (moving up the inheritance hierarchy). Since a Student `IS-A` Object, it does not require an explicit cast **Downcasting**: We're are widening...
``` Object o; if (Math.random < 0.5) { o = new Student(); } else { o = new Dog(); } ``` You can't have `Student x = o;` obviously Unless the dog is also a student, but that's a different story.
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
There is no casting going on here. As you say, `Object` is a base class of `Student`. This means that every instance of `Student` is also an `Object`, and we can always treat it as one. ``` Object o = new Student(); // A Student is an Object ``` The opposite relation does not hold, however - not all instances of...
You basically have to see if it passes the `IS-A` test, you can say `Student IS-A Object` (as every class in Java is a subclass of class Object) which is why the first implicit cast works. However you cannot say an `Object IS-A Student` because it might not be. Unless you know for a fact that it will be a `Student` th...
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
There is no casting going on here. As you say, `Object` is a base class of `Student`. This means that every instance of `Student` is also an `Object`, and we can always treat it as one. ``` Object o = new Student(); // A Student is an Object ``` The opposite relation does not hold, however - not all instances of...
You need to explicitly cast this to Student ``` Student x = (Student) o; ``` The reason for this is because the compiler doesn't know if this is correct, so you need to cast this as if to say **"I am confident that this will work. Please trust me"**.
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
There is no casting going on here. As you say, `Object` is a base class of `Student`. This means that every instance of `Student` is also an `Object`, and we can always treat it as one. ``` Object o = new Student(); // A Student is an Object ``` The opposite relation does not hold, however - not all instances of...
Java only allows implicit upcasting, not implicit downcasting. Upcasting in Java is also called widening conversion, and downcasting is called narrowing conversion. Objects can be implicitly or explicitly cast to a supertype. In this example, `Object` is a supertype of `Student`. ``` Object o = new Student(); Object...
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
``` Object o; if (Math.random < 0.5) { o = new Student(); } else { o = new Dog(); } ``` You can't have `Student x = o;` obviously Unless the dog is also a student, but that's a different story.
You can assign the instance of Student to a variable declared to be of type Object, because every Student is a kind of (or specialization of) Object. Since not every object IS A Student, the compiler balks at the assignment of something it knows only to be an instance of Object to any specialization of Object, such as ...
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
``` Object o = new Student(); //upcasting - Implicit cast Student x = (Student) o; //downcasting -Explicit cast ``` **Upcasting**: We're narrowing the reference conversion (moving up the inheritance hierarchy). Since a Student `IS-A` Object, it does not require an explicit cast **Downcasting**: We're are widening...
You basically have to see if it passes the `IS-A` test, you can say `Student IS-A Object` (as every class in Java is a subclass of class Object) which is why the first implicit cast works. However you cannot say an `Object IS-A Student` because it might not be. Unless you know for a fact that it will be a `Student` th...
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
``` Object o = new Student(); //upcasting - Implicit cast Student x = (Student) o; //downcasting -Explicit cast ``` **Upcasting**: We're narrowing the reference conversion (moving up the inheritance hierarchy). Since a Student `IS-A` Object, it does not require an explicit cast **Downcasting**: We're are widening...
You need to explicitly cast this to Student ``` Student x = (Student) o; ``` The reason for this is because the compiler doesn't know if this is correct, so you need to cast this as if to say **"I am confident that this will work. Please trust me"**.
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
``` Object o; if (Math.random < 0.5) { o = new Student(); } else { o = new Dog(); } ``` You can't have `Student x = o;` obviously Unless the dog is also a student, but that's a different story.
You need to explicitly cast this to Student ``` Student x = (Student) o; ``` The reason for this is because the compiler doesn't know if this is correct, so you need to cast this as if to say **"I am confident that this will work. Please trust me"**.
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
``` Object o = new Student(); //upcasting - Implicit cast Student x = (Student) o; //downcasting -Explicit cast ``` **Upcasting**: We're narrowing the reference conversion (moving up the inheritance hierarchy). Since a Student `IS-A` Object, it does not require an explicit cast **Downcasting**: We're are widening...
You can assign the instance of Student to a variable declared to be of type Object, because every Student is a kind of (or specialization of) Object. Since not every object IS A Student, the compiler balks at the assignment of something it knows only to be an instance of Object to any specialization of Object, such as ...
27,568,979
I have a EF code first database, to populate the initial tables, I am using sql scripts (are far easier to handle and update that the seed methods). The problem is, that the scripts are inserting wihtout special characters.... The database collation is: **SQL\_Latin1\_General\_CP1\_CI\_AS** The seed is reading the s...
2014/12/19
[ "https://Stackoverflow.com/questions/27568979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3351423/" ]
There is no casting going on here. As you say, `Object` is a base class of `Student`. This means that every instance of `Student` is also an `Object`, and we can always treat it as one. ``` Object o = new Student(); // A Student is an Object ``` The opposite relation does not hold, however - not all instances of...
``` Object o; if (Math.random < 0.5) { o = new Student(); } else { o = new Dog(); } ``` You can't have `Student x = o;` obviously Unless the dog is also a student, but that's a different story.
29,253,624
I have the following list of pointers: (here is a simple example, but in reality, my list could be componed by hundreds of entries) ``` {0xae5c4e8, 0xa09d4e8, 0xa753458, 0xae554e8} ``` I successfully print pointers content, one by one, by using : ``` p *(const Point *) 0xae5c4e8 ``` How can I print contents of ...
2015/03/25
[ "https://Stackoverflow.com/questions/29253624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463398/" ]
I don't think there is a simple way to show all the list elements at once. You could try to iterate through the items using: ``` set $it=mylist.begin()._M_node print *(*(std::_List_node<const Point *>*)$it)._M_data set $it=(*$it)._M_next ... ``` In the batch way. The problem is that the list items do not need to be ...
> > I have the following list of pointers: > > > You don't appear to have a *list*, you appear to have an array. Let's assume that it looks something like: ``` void *array[10] = {0xae5c4e8, 0xa09d4e8, 0xa753458, 0xae554e8}; ``` You can print the first 4 dereferenced elements of that array like so: ``` (gdb) p...
29,253,624
I have the following list of pointers: (here is a simple example, but in reality, my list could be componed by hundreds of entries) ``` {0xae5c4e8, 0xa09d4e8, 0xa753458, 0xae554e8} ``` I successfully print pointers content, one by one, by using : ``` p *(const Point *) 0xae5c4e8 ``` How can I print contents of ...
2015/03/25
[ "https://Stackoverflow.com/questions/29253624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463398/" ]
There is no canned way to do this. It would be cool if you could type `print *(*p @ 23)` -- using the `@` extension inside another expression, resulting in an implicit loop -- but you can't. However, there are two decent ways to do this. One way to do it is to use Python. Something like: ``` (gdb) python x = gdb.par...
I don't think there is a simple way to show all the list elements at once. You could try to iterate through the items using: ``` set $it=mylist.begin()._M_node print *(*(std::_List_node<const Point *>*)$it)._M_data set $it=(*$it)._M_next ... ``` In the batch way. The problem is that the list items do not need to be ...
29,253,624
I have the following list of pointers: (here is a simple example, but in reality, my list could be componed by hundreds of entries) ``` {0xae5c4e8, 0xa09d4e8, 0xa753458, 0xae554e8} ``` I successfully print pointers content, one by one, by using : ``` p *(const Point *) 0xae5c4e8 ``` How can I print contents of ...
2015/03/25
[ "https://Stackoverflow.com/questions/29253624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1463398/" ]
There is no canned way to do this. It would be cool if you could type `print *(*p @ 23)` -- using the `@` extension inside another expression, resulting in an implicit loop -- but you can't. However, there are two decent ways to do this. One way to do it is to use Python. Something like: ``` (gdb) python x = gdb.par...
> > I have the following list of pointers: > > > You don't appear to have a *list*, you appear to have an array. Let's assume that it looks something like: ``` void *array[10] = {0xae5c4e8, 0xa09d4e8, 0xa753458, 0xae554e8}; ``` You can print the first 4 dereferenced elements of that array like so: ``` (gdb) p...
8,840,219
I'm modifying a C source file (`libape-spidermonkey.c`). I include a lib header file that uses some C++ features (such as, `class definitions`, `STL string vector`), so I have to compile `libape-spidermonkey.c` using `g++` instead of `gcc`. However, because of the type-checking in C++, I got a lot of errors (NOT warni...
2012/01/12
[ "https://Stackoverflow.com/questions/8840219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/301336/" ]
Compile that file as a C file, rather than a C++ file. C and C++ objects can be linked together without problems.
It is a good practice (even for C developers) to try to compile their C codes using a C++ compiler. The errors found by the C++ compiler will help you to improve your code quality. So I'd recommend you to fix the errors in your libape-spidermonkey.c using C style casting (and not the C++ static\_casts). That will gara...
38,230,342
I've been working on an endless runner game using unity 5 engine studying some examples. I applied jump action to my character. It did work fine but I wanted it to be bit perfect so I implanted the jump using curves with this [example](https://i.stack.imgur.com/asx0r.png), came across this issue. That is after applying...
2016/07/06
[ "https://Stackoverflow.com/questions/38230342", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4225618/" ]
Your bit of code that adjusts the controller based on the curves is inside the if statement asking if the character is grounded. ``` if (controller.isGrounded) { ... } ``` that way it will adjust only when the character is touching the ground.
Does your gameobject has rigidbody ? if not then try to add and make rigidbody to iskinematic because when you move an object with a collider and without a rigidbody, the complete static collision data needs to be recalculated, which is slow. Or, may be ,try playing with animation jump frame rate don't make it too smal...
64,205,692
I am using UiPath to create a robot to get files from email. Some files are password protected and some files are not protected. The password-protected files are sent in with a password in email body. ``` Example email From: ABC <abc@outlook.com> Sent: Monday, 5 October 2020 10:54 AM To: BCD <bcd@outlook.com> Subject...
2020/10/05
[ "https://Stackoverflow.com/questions/64205692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14393022/" ]
You have to save the object first then split the tag values by comma and then add the tags into the field of your object this way. I have added the comments for your understanding. **Views.py Uploading Posts( views.py )** ```py @login_required(login_url="/login/") def post_upload(request): index1 = Blog.objects.al...
You have to call **form.save\_m2m()** to save tags when using django-taggit library like this: ``` post_form = PostUpload(request.POST, request.FILES, instance=request.user) if post_form.is_valid(): obj = post_form.save(commit=False) obj.save() # Without this next line the tags won't be...
64,205,692
I am using UiPath to create a robot to get files from email. Some files are password protected and some files are not protected. The password-protected files are sent in with a password in email body. ``` Example email From: ABC <abc@outlook.com> Sent: Monday, 5 October 2020 10:54 AM To: BCD <bcd@outlook.com> Subject...
2020/10/05
[ "https://Stackoverflow.com/questions/64205692", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14393022/" ]
You have to save the object first then split the tag values by comma and then add the tags into the field of your object this way. I have added the comments for your understanding. **Views.py Uploading Posts( views.py )** ```py @login_required(login_url="/login/") def post_upload(request): index1 = Blog.objects.al...
Inside `post_upload` method, are you sure you need `instance=request.user` to create a `post_form` object?
37,460,746
I am currently trying to handle exceptions and errors in a NodeJS app which will be used for critical information. I need a clean error management ! I've been wondering if there is something similar to Java Exceptions encapsulation. I'm explaning. In Java you can do something like that : ``` try { // something t...
2016/05/26
[ "https://Stackoverflow.com/questions/37460746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2520098/" ]
You should look at this module : <https://www.npmjs.com/package/verror> Joyent quote it on his error management best pratices : <https://www.joyent.com/developers/node/design/errors> > > At Joyent, we use the verror module to wrap errors since it's > syntactically concise. As of this writing, it doesn't quite do al...
You should be able to do something like: ``` funtion exception(message, error) { this.message = message; this.stacktrace = error.stack; } try { if(someData == false) throw new exception("something went wrong!", new Error()); } catch(ex) { console.log(ex.message); console.log(ex.stacktrace); }...
37,460,746
I am currently trying to handle exceptions and errors in a NodeJS app which will be used for critical information. I need a clean error management ! I've been wondering if there is something similar to Java Exceptions encapsulation. I'm explaning. In Java you can do something like that : ``` try { // something t...
2016/05/26
[ "https://Stackoverflow.com/questions/37460746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2520098/" ]
I answer my own question to explain what i finaly did to have the wanted encapsulation. I used <https://www.npmjs.com/package/verror> as Sachacr suggested. Then I extended it that way : my\_error.js : ``` var VError = require('verror'); var _ = require('lodash'); function MyError() { var ...
You should be able to do something like: ``` funtion exception(message, error) { this.message = message; this.stacktrace = error.stack; } try { if(someData == false) throw new exception("something went wrong!", new Error()); } catch(ex) { console.log(ex.message); console.log(ex.stacktrace); }...
37,460,746
I am currently trying to handle exceptions and errors in a NodeJS app which will be used for critical information. I need a clean error management ! I've been wondering if there is something similar to Java Exceptions encapsulation. I'm explaning. In Java you can do something like that : ``` try { // something t...
2016/05/26
[ "https://Stackoverflow.com/questions/37460746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2520098/" ]
I answer my own question to explain what i finaly did to have the wanted encapsulation. I used <https://www.npmjs.com/package/verror> as Sachacr suggested. Then I extended it that way : my\_error.js : ``` var VError = require('verror'); var _ = require('lodash'); function MyError() { var ...
You should look at this module : <https://www.npmjs.com/package/verror> Joyent quote it on his error management best pratices : <https://www.joyent.com/developers/node/design/errors> > > At Joyent, we use the verror module to wrap errors since it's > syntactically concise. As of this writing, it doesn't quite do al...
6,538
I'm studying for my Technician license, and listening in to HF, VHF and UHF bands just to get a feel for how to work with frequencies, squelch, antennas, etc. Had something happen today that I couldn't explain. I was doing a scan through the 70cm band, running from 400MHz to 480MHz, and at 450.040 I picked up a local A...
2016/08/14
[ "https://ham.stackexchange.com/questions/6538", "https://ham.stackexchange.com", "https://ham.stackexchange.com/users/8164/" ]
> > at 450.040 I picked up a local AM radio station > > > I am sure you picked up a transmission > > just a Baofeng UV5R > > > But not with that radio, or at least not AM You either: * Picked up a signal which is indeed AM, but then it would not be very distorted as the radio you are using only has FM (de)...
The 450-451 MHz band is often used by news media, broadcast TV and AM radio. They use it for communications between the station and the news vans, or between the station and the traffic helicopters. In addition, they use it for something called [Interruptible foldback](https://en.wikipedia.org/wiki/Interruptible_foldba...
6,538
I'm studying for my Technician license, and listening in to HF, VHF and UHF bands just to get a feel for how to work with frequencies, squelch, antennas, etc. Had something happen today that I couldn't explain. I was doing a scan through the 70cm band, running from 400MHz to 480MHz, and at 450.040 I picked up a local A...
2016/08/14
[ "https://ham.stackexchange.com/questions/6538", "https://ham.stackexchange.com", "https://ham.stackexchange.com/users/8164/" ]
I was trying to research some info and I came across your thread. My guess is they took the audio output from the 1520 kHz tuner and fed it in the input of a 450.040 MHz transmitter. That's why it can be heard in the UHF region. In this way, FM or AM or frequency doesn't matter, because its only an audio feed from an ...
The 450-451 MHz band is often used by news media, broadcast TV and AM radio. They use it for communications between the station and the news vans, or between the station and the traffic helicopters. In addition, they use it for something called [Interruptible foldback](https://en.wikipedia.org/wiki/Interruptible_foldba...
12,149,070
I am writing a script to launch remote desktop sessions using rdesktop. The relevant portion of the code looks like this: ``` subprocess.call(["rdesktop", "-a 16", "-u user", "-g 1280x1024",, server]) ``` When this happens, the terminal is locked up until I exit the rdesktop session. Would it be possible to launch m...
2012/08/27
[ "https://Stackoverflow.com/questions/12149070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1290192/" ]
`subprocess.Popen` ([py2 docs](https://docs.python.org/2/library/subprocess.html#subprocess.Popen), [py3 docs](https://docs.python.org/3/library/subprocess.html#subprocess.Popen)) is the correct answer here. `subprocess.call` waits for the command to complete, while `subprocess.Popen` calls it in the background, and i...
You can fork the python process or use threads, or run the process in the background.
42,256,412
I'd like to use Entity Framework to return data from 2 tables, and a selection of columns of the 2 tables, at first I was not having much luck with something simple, like returning int's and strings (ie. `select new { id = t1.ID, other = t2.OtherData }`, as casting that anonymous type was cumbersome at the destination ...
2017/02/15
[ "https://Stackoverflow.com/questions/42256412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/858282/" ]
In C# anonymous types are best used in the scope of the same method where you project them. As you have seen for your self **they can't be used outside of the defining method**. So you can't return anonymous types from methods (and keep their structure, you can always return them as objects, but this is not good idea) ...
1)Create a specific class that describes you result. 2)See 1
42,256,412
I'd like to use Entity Framework to return data from 2 tables, and a selection of columns of the 2 tables, at first I was not having much luck with something simple, like returning int's and strings (ie. `select new { id = t1.ID, other = t2.OtherData }`, as casting that anonymous type was cumbersome at the destination ...
2017/02/15
[ "https://Stackoverflow.com/questions/42256412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/858282/" ]
1)Create a specific class that describes you result. 2)See 1
I wanted to avoid creating a specific class or a struct. The below is a lengthy way that avoids creating a struct/class. So I did this in my service class:- ``` List<KeyValuePair<string,int>> IWorkflowService.GetServiceRetention() { var serviceRetention = from y in _context.SERVICES ...
42,256,412
I'd like to use Entity Framework to return data from 2 tables, and a selection of columns of the 2 tables, at first I was not having much luck with something simple, like returning int's and strings (ie. `select new { id = t1.ID, other = t2.OtherData }`, as casting that anonymous type was cumbersome at the destination ...
2017/02/15
[ "https://Stackoverflow.com/questions/42256412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/858282/" ]
In C# anonymous types are best used in the scope of the same method where you project them. As you have seen for your self **they can't be used outside of the defining method**. So you can't return anonymous types from methods (and keep their structure, you can always return them as objects, but this is not good idea) ...
I wanted to avoid creating a specific class or a struct. The below is a lengthy way that avoids creating a struct/class. So I did this in my service class:- ``` List<KeyValuePair<string,int>> IWorkflowService.GetServiceRetention() { var serviceRetention = from y in _context.SERVICES ...
21,466,277
I have this code: ``` var json = Newtonsoft.Json.Linq.JObject.Parse("{items:"+response.Content+"}"); Console.WriteLine(json.Count); var items = (JArray)json["items"]; for (int i = 0; i < items.Count; i++) { Console.WriteLine("ae"); Console.WriteLine((JObject)items[i]); } ``` Here is the response.Content i have...
2014/01/30
[ "https://Stackoverflow.com/questions/21466277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3120770/" ]
How about this way (XSLT 1.0): ``` <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:variable name="file2" select="document('b.xml')" /> <xsl:variable name="IDs1" select="/...
If you websearch "xml diff", you'll find past versions of tools that compare XML documents and output their differences as an XML document See also <https://stackoverflow.com/questions/1871076/are-there-any-free-xml-diff-merge-tools-available>
21,466,277
I have this code: ``` var json = Newtonsoft.Json.Linq.JObject.Parse("{items:"+response.Content+"}"); Console.WriteLine(json.Count); var items = (JArray)json["items"]; for (int i = 0; i < items.Count; i++) { Console.WriteLine("ae"); Console.WriteLine((JObject)items[i]); } ``` Here is the response.Content i have...
2014/01/30
[ "https://Stackoverflow.com/questions/21466277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3120770/" ]
If you websearch "xml diff", you'll find past versions of tools that compare XML documents and output their differences as an XML document See also <https://stackoverflow.com/questions/1871076/are-there-any-free-xml-diff-merge-tools-available>
If I need to compare 2 XML files and see quickly the differences between them I sort the files using XSLT and then compare the two xml files manually by using WinMerge for example (a simple unix diff can also do the job). If you want to output the differences you can follow the method given by @keshlam Here is the XSL...
21,466,277
I have this code: ``` var json = Newtonsoft.Json.Linq.JObject.Parse("{items:"+response.Content+"}"); Console.WriteLine(json.Count); var items = (JArray)json["items"]; for (int i = 0; i < items.Count; i++) { Console.WriteLine("ae"); Console.WriteLine((JObject)items[i]); } ``` Here is the response.Content i have...
2014/01/30
[ "https://Stackoverflow.com/questions/21466277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3120770/" ]
How about this way (XSLT 1.0): ``` <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/> <xsl:variable name="file2" select="document('b.xml')" /> <xsl:variable name="IDs1" select="/...
If I need to compare 2 XML files and see quickly the differences between them I sort the files using XSLT and then compare the two xml files manually by using WinMerge for example (a simple unix diff can also do the job). If you want to output the differences you can follow the method given by @keshlam Here is the XSL...
18,530,706
Let's say I have this function: ``` void changeMap(Player* player, int map) { player->setMap(map); } ``` And I want a timer class that enables me to run that function after a certain amount of time, Something like this. ``` Player* chr; int mapid = 300; int milliseconds = 6000; Timer.Schedule(changeMap(chr, ...
2013/08/30
[ "https://Stackoverflow.com/questions/18530706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2561241/" ]
If this is a game loop then one way is to keep of list of events that you want to happen some time in the future where you store a time and a pointer to the function you want to call. (Or a std::function, or whatever). Keep the list sorted by time so the soonest event is a the top of the list. Then in your main game l...
You can achieve the desired effect by the liberal use of Functor delegate objects and templates: CAlarm.h ``` #ifndef CALARM_H #define CALARM_H #include "ADTtime.h" #include "CStopwatch.h" template<class FunctionObject> class Alarm : public StopWatch { public: Alarm(const FunctionObject& fn); Alarm(double...
18,530,706
Let's say I have this function: ``` void changeMap(Player* player, int map) { player->setMap(map); } ``` And I want a timer class that enables me to run that function after a certain amount of time, Something like this. ``` Player* chr; int mapid = 300; int milliseconds = 6000; Timer.Schedule(changeMap(chr, ...
2013/08/30
[ "https://Stackoverflow.com/questions/18530706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2561241/" ]
If this is a game loop then one way is to keep of list of events that you want to happen some time in the future where you store a time and a pointer to the function you want to call. (Or a std::function, or whatever). Keep the list sorted by time so the soonest event is a the top of the list. Then in your main game l...
Since you are running on Windows OS, I don't understand why are you reinventing the wheel? ``` CComPtr<IReferenceClock> pReferenceClock; HRESULT hr = CoCreateInstance( CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, IID_IReferenceClock, (void**)&pReferenceClock ); hr = pReferenceClock->AdviseTime( ... ); ...
18,530,706
Let's say I have this function: ``` void changeMap(Player* player, int map) { player->setMap(map); } ``` And I want a timer class that enables me to run that function after a certain amount of time, Something like this. ``` Player* chr; int mapid = 300; int milliseconds = 6000; Timer.Schedule(changeMap(chr, ...
2013/08/30
[ "https://Stackoverflow.com/questions/18530706", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2561241/" ]
If this is a game loop then one way is to keep of list of events that you want to happen some time in the future where you store a time and a pointer to the function you want to call. (Or a std::function, or whatever). Keep the list sorted by time so the soonest event is a the top of the list. Then in your main game l...
You can implement a simple (perhaps a bit rough around the edges) function that fire off a one-off event, like a timer, after a specified amount of milliseconds, using `std::thread` and `std::chrono` facilities Something like that: ``` void doAfter( const std::function<void(void)>& f, size_t intervalMs ) { st...
46,686,328
I have a dialog containing two combo boxes, one owner draw and one non owner draw. This is how they are defined in the .rc file: ``` COMBOBOX IDC_COMBO2,149,49,77,73, CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED | CBS_SORT | VS_VSCROLL COMBOBOX IDC_COMBO3,237,49,48,30, CBS_DROPD...
2017/10/11
[ "https://Stackoverflow.com/questions/46686328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/898348/" ]
First the given height in the resource is the height of the combo box in the dropped down state. This behavior is by design. The size of the combobox item height is I believe determined by the font height of the font assigned to the control. With an owner-draw combobox the system has no idea so it sends you a WM\_MEAS...
The combobox is the most horrible control to work with in Windows when dealing with size and layout. Because it also supports the "simple" style with separate edit and listbox controls always visible it does not use the standard window border/edge styles and instead draws its borders when required. The height specifie...
27,558,579
I have a requirement as below: ``` SELECT code from Products ``` * Select code to table Products * Check length of code; if < 8 auto insert "0" before it to enough 8 character. Sample: ``` If code is : 1234 => 00001234 12345 => 00012345 ..... => xxxxxxxx ``` I want to use a stored proc...
2014/12/19
[ "https://Stackoverflow.com/questions/27558579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024503/" ]
If the `CODE` field is string, this will work ``` SELECT RIGHT('00000000'+ISNULL(CODE,''),8) from Products ``` If `CODE` is integer then ``` SELECT RIGHT('00000000'+CAST(CODE AS VARCHAR(8)),8) from Products ```
``` SELECT CASE WHEN LEN(code) < 8 THEN REPLICATE('0', 8 - LEN(code)) + code ELSE code END FROM Products ```
27,558,579
I have a requirement as below: ``` SELECT code from Products ``` * Select code to table Products * Check length of code; if < 8 auto insert "0" before it to enough 8 character. Sample: ``` If code is : 1234 => 00001234 12345 => 00012345 ..... => xxxxxxxx ``` I want to use a stored proc...
2014/12/19
[ "https://Stackoverflow.com/questions/27558579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024503/" ]
If the `CODE` field is string, this will work ``` SELECT RIGHT('00000000'+ISNULL(CODE,''),8) from Products ``` If `CODE` is integer then ``` SELECT RIGHT('00000000'+CAST(CODE AS VARCHAR(8)),8) from Products ```
Do something like this. 1. Use function "CONCAT" your numbers with 000000000 . 2. Use function "RIGHT" to show 8 digits from right to left . `select right(CONCAT('000000000', 1234),8) as xxx` Hope its help.
13,020,328
I've got a 400+ node munin-1.4.x installation, that I'd like to upgrade to munin-2.x, to take advantage of the CGI based content generation (html & graphs) on the munin master server. I've gone through the official dox ( <http://munin-monitoring.org/wiki/CgiHowto2> ), and its simply not working. It only covers a Virtua...
2012/10/22
[ "https://Stackoverflow.com/questions/13020328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179922/" ]
The problem is that, if you use the configuration in a "location" based setup (rather than in a VirtualHost"), the flag for the RewriteRule is wrong. As per [mod\_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) docu: ``` L Stop the rewriting process immediately and don't apply any more rules. ...
I had exactly the same problem and I struggled for a while, but I eventually came up with the following config which should do exactly what you want. My system is Ubuntu Server 12.10. For some reasons my static files are located at /var/cache/munin/www, I'm not sure whether this is standard on Ubuntu or it was caused ...
13,020,328
I've got a 400+ node munin-1.4.x installation, that I'd like to upgrade to munin-2.x, to take advantage of the CGI based content generation (html & graphs) on the munin master server. I've gone through the official dox ( <http://munin-monitoring.org/wiki/CgiHowto2> ), and its simply not working. It only covers a Virtua...
2012/10/22
[ "https://Stackoverflow.com/questions/13020328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179922/" ]
The problem is that, if you use the configuration in a "location" based setup (rather than in a VirtualHost"), the flag for the RewriteRule is wrong. As per [mod\_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) docu: ``` L Stop the rewriting process immediately and don't apply any more rules. ...
Ensure munin-cgi is installed and the dependencies: mod\_fcgid. CentOS 7, no special parameters added to the file configuration located at /etc/httpd/conf.d/munin.conf. Regards.
13,020,328
I've got a 400+ node munin-1.4.x installation, that I'd like to upgrade to munin-2.x, to take advantage of the CGI based content generation (html & graphs) on the munin master server. I've gone through the official dox ( <http://munin-monitoring.org/wiki/CgiHowto2> ), and its simply not working. It only covers a Virtua...
2012/10/22
[ "https://Stackoverflow.com/questions/13020328", "https://Stackoverflow.com", "https://Stackoverflow.com/users/179922/" ]
I had exactly the same problem and I struggled for a while, but I eventually came up with the following config which should do exactly what you want. My system is Ubuntu Server 12.10. For some reasons my static files are located at /var/cache/munin/www, I'm not sure whether this is standard on Ubuntu or it was caused ...
Ensure munin-cgi is installed and the dependencies: mod\_fcgid. CentOS 7, no special parameters added to the file configuration located at /etc/httpd/conf.d/munin.conf. Regards.
19,784,453
Is there a way to get the index of class name (I.e. the third element with the class "className" would be 3 without using jQ? I don't know jQ, and I don't have time to learn it right now, and I don't want to include code into my code that I don't understand at least some. Thanks. BTW, I've used jQ instead of spellin...
2013/11/05
[ "https://Stackoverflow.com/questions/19784453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1940394/" ]
you can use [document.getElementsByClassName](https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByClassName) ``` var el = document.getElementsByClassName('className'); for (var i = 0; i < el.length; i++) { // your index is inside here } ``` `el[i]` is the element in the current iteration, `i` i...
Just use [`getElementsByClassName`](https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByClassName), it returns a list of elements with the specified classes. ``` elements = document.getElementsByClassName("test") element = elements[2] //get the 3rd element ``` Hope this helps!
19,784,453
Is there a way to get the index of class name (I.e. the third element with the class "className" would be 3 without using jQ? I don't know jQ, and I don't have time to learn it right now, and I don't want to include code into my code that I don't understand at least some. Thanks. BTW, I've used jQ instead of spellin...
2013/11/05
[ "https://Stackoverflow.com/questions/19784453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1940394/" ]
you can use [document.getElementsByClassName](https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByClassName) ``` var el = document.getElementsByClassName('className'); for (var i = 0; i < el.length; i++) { // your index is inside here } ``` `el[i]` is the element in the current iteration, `i` i...
these work as of es6: ``` Array.from(document.querySelectorAll('.elements')).indexOf(anElement) ``` or ``` [...document.querySelectorAll('.elements')].indexOf(anElement) ```
19,784,453
Is there a way to get the index of class name (I.e. the third element with the class "className" would be 3 without using jQ? I don't know jQ, and I don't have time to learn it right now, and I don't want to include code into my code that I don't understand at least some. Thanks. BTW, I've used jQ instead of spellin...
2013/11/05
[ "https://Stackoverflow.com/questions/19784453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1940394/" ]
You could do something like: ``` // the element you're looking for var target = document.getElementById("an-element"); // the collection you're looking in var nodes = document.querySelectorAll(".yourclass"); var index = [].indexOf.call(nodes, target); ``` See: [Array's indexOf](https://developer.mozilla.org/en-US/...
Just use [`getElementsByClassName`](https://developer.mozilla.org/en-US/docs/Web/API/document.getElementsByClassName), it returns a list of elements with the specified classes. ``` elements = document.getElementsByClassName("test") element = elements[2] //get the 3rd element ``` Hope this helps!
19,784,453
Is there a way to get the index of class name (I.e. the third element with the class "className" would be 3 without using jQ? I don't know jQ, and I don't have time to learn it right now, and I don't want to include code into my code that I don't understand at least some. Thanks. BTW, I've used jQ instead of spellin...
2013/11/05
[ "https://Stackoverflow.com/questions/19784453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1940394/" ]
You could do something like: ``` // the element you're looking for var target = document.getElementById("an-element"); // the collection you're looking in var nodes = document.querySelectorAll(".yourclass"); var index = [].indexOf.call(nodes, target); ``` See: [Array's indexOf](https://developer.mozilla.org/en-US/...
these work as of es6: ``` Array.from(document.querySelectorAll('.elements')).indexOf(anElement) ``` or ``` [...document.querySelectorAll('.elements')].indexOf(anElement) ```
52,419,862
I am currently learning python and tried to implement chess. (I've already done this in multiple different languages) ``` class Board: def __init__(self): self._reset() def _reset(self, func=Board.default_layout): self.values = [[0 for x in range(8)] for i in range(8)] self.currentPla...
2018/09/20
[ "https://Stackoverflow.com/questions/52419862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4944986/" ]
Your `def _reset(self, func=Board.default_layout):` is being evaluated as part of the definition of `Board`, so `Board.default_layout` is not defined yet. You could make `default_layout` an ordinary function instead of a static method. It needs to be defined before you use it. ``` def default_layout(values): ... ...
As an alternative to @khelwood's answer, you can also use a `lambda` function instead if you prefer to keep `default_layout` a static method of the `Board` class. Change: ``` def _reset(self, func=Board.default_layout): ``` to ``` def _reset(self, func=lambda values: Board.default_layout(values)): ```
36,109
The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. ``` #! /bin/sh if [ "${1+set}" != "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi EXEC="$1" shift ARGS="" for p in "$@"; do if [ -e "$p" ] then p=$(w...
2008/08/30
[ "https://Stackoverflow.com/questions/36109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
I you do want to have the assignment to CMD you should use `eval $CMD` instead of just `$CMD` in the last line of your script. This should solve your problem with spaces in the paths, I don't know what to do about the "\t" problem.
You can try preceeding the spaces with \ like so: ``` /home/chris/.wine/drive_c/Program Files/Microsoft\ Research/Z3-1.3.6/bin/z3.exe ``` You can also do the same with your \t problem - replace it with \\t.
36,109
The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. ``` #! /bin/sh if [ "${1+set}" != "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi EXEC="$1" shift ARGS="" for p in "$@"; do if [ -e "$p" ] then p=$(w...
2008/08/30
[ "https://Stackoverflow.com/questions/36109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
* bash’s arrays are unportable but the only sane way to handle argument lists in shell * The number of arguments is in ${#} * Bad stuff will happen with your script if there are filenames starting with a dash in the current directory * If the last line of your script just runs a program, and there are no traps on exit,...
You can try preceeding the spaces with \ like so: ``` /home/chris/.wine/drive_c/Program Files/Microsoft\ Research/Z3-1.3.6/bin/z3.exe ``` You can also do the same with your \t problem - replace it with \\t.
36,109
The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. ``` #! /bin/sh if [ "${1+set}" != "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi EXEC="$1" shift ARGS="" for p in "$@"; do if [ -e "$p" ] then p=$(w...
2008/08/30
[ "https://Stackoverflow.com/questions/36109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
I you do want to have the assignment to CMD you should use `eval $CMD` instead of just `$CMD` in the last line of your script. This should solve your problem with spaces in the paths, I don't know what to do about the "\t" problem.
replace the last line from $CMD to just wine '$EXEC' $ARGS You'll note that the error is ''/home/chris/.wine/drive\_c/Program' and not '/home/chris/.wine/drive\_c/Program' The single quotes are not being interpolated properly, and the string is being split by spaces.
36,109
The following shell script takes a list of arguments, turns Unix paths into WINE/Windows paths and invokes the given executable under WINE. ``` #! /bin/sh if [ "${1+set}" != "set" ] then echo "Usage; winewrap EXEC [ARGS...]" exit 1 fi EXEC="$1" shift ARGS="" for p in "$@"; do if [ -e "$p" ] then p=$(w...
2008/08/30
[ "https://Stackoverflow.com/questions/36109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1412/" ]
* bash’s arrays are unportable but the only sane way to handle argument lists in shell * The number of arguments is in ${#} * Bad stuff will happen with your script if there are filenames starting with a dash in the current directory * If the last line of your script just runs a program, and there are no traps on exit,...
replace the last line from $CMD to just wine '$EXEC' $ARGS You'll note that the error is ''/home/chris/.wine/drive\_c/Program' and not '/home/chris/.wine/drive\_c/Program' The single quotes are not being interpolated properly, and the string is being split by spaces.
79,070
As days tick off of call options, time value decays. My question is does that happen automatically at 9:30AM at market open or does it get continuously deducted as the day ticks on?
2017/04/26
[ "https://money.stackexchange.com/questions/79070", "https://money.stackexchange.com", "https://money.stackexchange.com/users/41914/" ]
The time value decay is theoretically constant. In reality, it is driven by supply and demand, just like everything else in the market. For instance, if a big earnings announcement is coming out after the close for the day, you may see little or no time decay in the price of the options during the day before. Also, ...
If you're talking about just Theta, the amount of decay due to the passage of time (all else being equal), then theoretically, the time value is a continuous function, so it would decay throughout the day (although by the day of expiry the time value is very, very small). Which makes sense, since even with 15 minutes t...
79,070
As days tick off of call options, time value decays. My question is does that happen automatically at 9:30AM at market open or does it get continuously deducted as the day ticks on?
2017/04/26
[ "https://money.stackexchange.com/questions/79070", "https://money.stackexchange.com", "https://money.stackexchange.com/users/41914/" ]
If you're talking about just Theta, the amount of decay due to the passage of time (all else being equal), then theoretically, the time value is a continuous function, so it would decay throughout the day (although by the day of expiry the time value is very, very small). Which makes sense, since even with 15 minutes t...
It has been my experience as an amateur trader, theory aside, that I generally see the time value come off at market open and not much during the trading day.
79,070
As days tick off of call options, time value decays. My question is does that happen automatically at 9:30AM at market open or does it get continuously deducted as the day ticks on?
2017/04/26
[ "https://money.stackexchange.com/questions/79070", "https://money.stackexchange.com", "https://money.stackexchange.com/users/41914/" ]
If you're talking about just Theta, the amount of decay due to the passage of time (all else being equal), then theoretically, the time value is a continuous function, so it would decay throughout the day (although by the day of expiry the time value is very, very small). Which makes sense, since even with 15 minutes t...
The time value of the option (theta) decays constantly (by the millisecond) As it is one of the inputs to the option pricing model, it usually has a lower impact on the overall option price than other changes in the market. As the (US) markets price options in penny ($0.01) or nickel ($0.05) increments, you will only...
79,070
As days tick off of call options, time value decays. My question is does that happen automatically at 9:30AM at market open or does it get continuously deducted as the day ticks on?
2017/04/26
[ "https://money.stackexchange.com/questions/79070", "https://money.stackexchange.com", "https://money.stackexchange.com/users/41914/" ]
If you're talking about just Theta, the amount of decay due to the passage of time (all else being equal), then theoretically, the time value is a continuous function, so it would decay throughout the day (although by the day of expiry the time value is very, very small). Which makes sense, since even with 15 minutes t...
This has been my observation in the markets pertaining to option decay. Bulk of the decay happens in the first 15 minutes of trade at market open. Rest of the decay usually happens in pulses whenever market breaks out of ranges intraday. So if its call option and market breaks a range to the downside, call option will ...
79,070
As days tick off of call options, time value decays. My question is does that happen automatically at 9:30AM at market open or does it get continuously deducted as the day ticks on?
2017/04/26
[ "https://money.stackexchange.com/questions/79070", "https://money.stackexchange.com", "https://money.stackexchange.com/users/41914/" ]
The time value decay is theoretically constant. In reality, it is driven by supply and demand, just like everything else in the market. For instance, if a big earnings announcement is coming out after the close for the day, you may see little or no time decay in the price of the options during the day before. Also, ...
It has been my experience as an amateur trader, theory aside, that I generally see the time value come off at market open and not much during the trading day.