qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
3,313,220
``` $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); ``` This is used in a post form and I need to run the code inside the live() when the document is ready. Is there a way, other than to wait for a key press, to invoke it?
2010/07/22
[ "https://Stackoverflow.com/questions/3313220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377920/" ]
It sounds like you're saying that there's a part of the code that will run on `keyup` that you also want to run once when the page loads. If that's the case, you can place that code inside another function, and call it both on page load and inside the `.live()` handler. ``` function someFunction() { // code to run...
If you're asking how to attach the keyup event *after* the document is ready, this is the sollution: ``` jQuery(document).ready(function($) { $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); }); ``` However, this would have no function, because the ...
3,313,220
``` $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); ``` This is used in a post form and I need to run the code inside the live() when the document is ready. Is there a way, other than to wait for a key press, to invoke it?
2010/07/22
[ "https://Stackoverflow.com/questions/3313220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377920/" ]
``` $(function() { // add the event $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); $('#foo').trigger('keyup'); //trigger the event }); ```
If you're asking how to attach the keyup event *after* the document is ready, this is the sollution: ``` jQuery(document).ready(function($) { $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); }); ``` However, this would have no function, because the ...
3,313,220
``` $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); ``` This is used in a post form and I need to run the code inside the live() when the document is ready. Is there a way, other than to wait for a key press, to invoke it?
2010/07/22
[ "https://Stackoverflow.com/questions/3313220", "https://Stackoverflow.com", "https://Stackoverflow.com/users/377920/" ]
``` $(function() { // add the event $('#foo').live('keyup', function (e) { var input = $(this).val(); // code to process input }); $('#foo').trigger('keyup'); //trigger the event }); ```
It sounds like you're saying that there's a part of the code that will run on `keyup` that you also want to run once when the page loads. If that's the case, you can place that code inside another function, and call it both on page load and inside the `.live()` handler. ``` function someFunction() { // code to run...
63,967,169
I have a JSON file ``` response ={ "classifier_id": "xxxxx-xx-1", "url": "/testers/xxxxx-xx-1", "collection": [ { "text": "How hot will it be today?", "top_class": "temperature", "classes": [ { "class_name": "temperature", "confidence": 0.993 }, {...
2020/09/19
[ "https://Stackoverflow.com/questions/63967169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11716280/" ]
With cocoapods and Xcode 12, you currently need to set your Pods' deployment targets in a so-called "post-install hook". Try adding this to the end of your Podfile: ``` deployment_target = '12.0' post_install do |installer| installer.generated_projects.each do |project| project.targets.each do |target| ...
You are tying to import a version of `RxSwift` that has already set its minimum deployment target to iOS 12.0 while your project itself is still on iOS 10.0. This should not be related to Xcode or the Xcode update. If you can post your Podfile we can verify this.
63,967,169
I have a JSON file ``` response ={ "classifier_id": "xxxxx-xx-1", "url": "/testers/xxxxx-xx-1", "collection": [ { "text": "How hot will it be today?", "top_class": "temperature", "classes": [ { "class_name": "temperature", "confidence": 0.993 }, {...
2020/09/19
[ "https://Stackoverflow.com/questions/63967169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11716280/" ]
Just to people who may end up in the same case as me. The reason of this error was that I was using the `beta` channel. After switching to the `stable` channel, I ran ``` cd ios/ pod deintegrate pod cache clean --all cd .. flutter clean ``` And, I removed the `Podfile` and the `Podfile.lock`. Then, I built the proje...
You are tying to import a version of `RxSwift` that has already set its minimum deployment target to iOS 12.0 while your project itself is still on iOS 10.0. This should not be related to Xcode or the Xcode update. If you can post your Podfile we can verify this.
63,967,169
I have a JSON file ``` response ={ "classifier_id": "xxxxx-xx-1", "url": "/testers/xxxxx-xx-1", "collection": [ { "text": "How hot will it be today?", "top_class": "temperature", "classes": [ { "class_name": "temperature", "confidence": 0.993 }, {...
2020/09/19
[ "https://Stackoverflow.com/questions/63967169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11716280/" ]
With cocoapods and Xcode 12, you currently need to set your Pods' deployment targets in a so-called "post-install hook". Try adding this to the end of your Podfile: ``` deployment_target = '12.0' post_install do |installer| installer.generated_projects.each do |project| project.targets.each do |target| ...
Just to people who may end up in the same case as me. The reason of this error was that I was using the `beta` channel. After switching to the `stable` channel, I ran ``` cd ios/ pod deintegrate pod cache clean --all cd .. flutter clean ``` And, I removed the `Podfile` and the `Podfile.lock`. Then, I built the proje...
63,967,169
I have a JSON file ``` response ={ "classifier_id": "xxxxx-xx-1", "url": "/testers/xxxxx-xx-1", "collection": [ { "text": "How hot will it be today?", "top_class": "temperature", "classes": [ { "class_name": "temperature", "confidence": 0.993 }, {...
2020/09/19
[ "https://Stackoverflow.com/questions/63967169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11716280/" ]
With cocoapods and Xcode 12, you currently need to set your Pods' deployment targets in a so-called "post-install hook". Try adding this to the end of your Podfile: ``` deployment_target = '12.0' post_install do |installer| installer.generated_projects.each do |project| project.targets.each do |target| ...
You need to change minimum deployment target, you can change it from `Xcode` like this (here i changed it to 11, in your case you need to change it to 12): [![enter image description here](https://i.stack.imgur.com/IA09u.jpg)](https://i.stack.imgur.com/IA09u.jpg)
63,967,169
I have a JSON file ``` response ={ "classifier_id": "xxxxx-xx-1", "url": "/testers/xxxxx-xx-1", "collection": [ { "text": "How hot will it be today?", "top_class": "temperature", "classes": [ { "class_name": "temperature", "confidence": 0.993 }, {...
2020/09/19
[ "https://Stackoverflow.com/questions/63967169", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11716280/" ]
Just to people who may end up in the same case as me. The reason of this error was that I was using the `beta` channel. After switching to the `stable` channel, I ran ``` cd ios/ pod deintegrate pod cache clean --all cd .. flutter clean ``` And, I removed the `Podfile` and the `Podfile.lock`. Then, I built the proje...
You need to change minimum deployment target, you can change it from `Xcode` like this (here i changed it to 11, in your case you need to change it to 12): [![enter image description here](https://i.stack.imgur.com/IA09u.jpg)](https://i.stack.imgur.com/IA09u.jpg)
150,046
I've got a small shaded pole motor (C-type) that I'm cannibalizing for use in a project, but the current RPM is too high. I don't want to spend the effort to build a micro-controller to run it. Is there a way to easily change the RPM by making a relative change to the wound coil? For instance, it's currently running a...
2015/01/20
[ "https://electronics.stackexchange.com/questions/150046", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/64779/" ]
A shaded pole motor is a type of induction motor, just using some neat magnetic tricks to generate a second phase. It runs at slightly below synchronous speed, the slip depends on the torque. For a simple 2 pole motor, you'd expect it to run at perhaps 90% of 3000 rpm (50 Hz countries), or 3600 rpm (60 Hz). This is wh...
Those answers are just mumbo-jumbo-babble. Just use a rheostat at 1000 ohms and plenty of amps ratings. Ohmite makes the best. A rheostat varies the current going through the motor. Research it and you'll see that I'm right. Not many people knows that. Laboratory stir plate are made with a shaded pole motor, a switch a...
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The best way I can see is to use `$.validate.element(selector)` in the blur event for each element you want this behaviour for: ``` var v = $('#formid').validate(); ``` Then setup blur events: ``` $('#firstName').blur(function(){ v.element('#firstName'); }); ``` See it in action here: <http://jsfiddle.net/ryl...
You can use the validator 'form' method, see [documentation](http://docs.jquery.com/Plugins/Validation/Validator/form). This triggers form validation: ``` $('#formid').validate().form(); ``` If you want it on blur you might use this: ``` $('#formid :input').blur(function() { $('#formid').validate().form(); });...
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
You can use the validator 'form' method, see [documentation](http://docs.jquery.com/Plugins/Validation/Validator/form). This triggers form validation: ``` $('#formid').validate().form(); ``` If you want it on blur you might use this: ``` $('#formid :input').blur(function() { $('#formid').validate().form(); });...
``` <script> $(document).ready(function(){ $("#formid input, #formid select, #formid textarea").blur(function() { $('#formid').validate(); }); }); </script> ```
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The best way I can see is to use `$.validate.element(selector)` in the blur event for each element you want this behaviour for: ``` var v = $('#formid').validate(); ``` Then setup blur events: ``` $('#firstName').blur(function(){ v.element('#firstName'); }); ``` See it in action here: <http://jsfiddle.net/ryl...
``` <script> $(document).ready(function(){ $("#formid input, #formid select, #formid textarea").blur(function() { $('#formid').validate(); }); }); </script> ```
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The best way I can see is to use `$.validate.element(selector)` in the blur event for each element you want this behaviour for: ``` var v = $('#formid').validate(); ``` Then setup blur events: ``` $('#firstName').blur(function(){ v.element('#firstName'); }); ``` See it in action here: <http://jsfiddle.net/ryl...
I know its already too late but still I want to add to this. Very easy way to set the validation for submit and blur event is: ``` $("#MainForm").validate({ onfocusout: function (element) { if ($(element).valid()) { $(element).removeC...
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The current version of the plugin has a function called 'validateOnBlur' which will do what you're asking. Your code should look like this if you've applied the id of `#formid` to the form. ``` <script> $('#formid').validateOnBlur(); </script> ``` For some solid documentation on this head to his github page -- <...
You should set the [onfocusout option](http://docs.jquery.com/Plugins/Validation/validate#options) to true (scroll down to see it) ``` $("#formid").validate({ rules: { // simple rule, converted to {required:true} required: "required", }, onfocusout: true }); ```
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The current version of the plugin has a function called 'validateOnBlur' which will do what you're asking. Your code should look like this if you've applied the id of `#formid` to the form. ``` <script> $('#formid').validateOnBlur(); </script> ``` For some solid documentation on this head to his github page -- <...
I know its already too late but still I want to add to this. Very easy way to set the validation for submit and blur event is: ``` $("#MainForm").validate({ onfocusout: function (element) { if ($(element).valid()) { $(element).removeC...
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
You can use the validator 'form' method, see [documentation](http://docs.jquery.com/Plugins/Validation/Validator/form). This triggers form validation: ``` $('#formid').validate().form(); ``` If you want it on blur you might use this: ``` $('#formid :input').blur(function() { $('#formid').validate().form(); });...
I know its already too late but still I want to add to this. Very easy way to set the validation for submit and blur event is: ``` $("#MainForm").validate({ onfocusout: function (element) { if ($(element).valid()) { $(element).removeC...
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The best way I can see is to use `$.validate.element(selector)` in the blur event for each element you want this behaviour for: ``` var v = $('#formid').validate(); ``` Then setup blur events: ``` $('#firstName').blur(function(){ v.element('#firstName'); }); ``` See it in action here: <http://jsfiddle.net/ryl...
You should set the [onfocusout option](http://docs.jquery.com/Plugins/Validation/validate#options) to true (scroll down to see it) ``` $("#formid").validate({ rules: { // simple rule, converted to {required:true} required: "required", }, onfocusout: true }); ```
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
You can use the validator 'form' method, see [documentation](http://docs.jquery.com/Plugins/Validation/Validator/form). This triggers form validation: ``` $('#formid').validate().form(); ``` If you want it on blur you might use this: ``` $('#formid :input').blur(function() { $('#formid').validate().form(); });...
You should set the [onfocusout option](http://docs.jquery.com/Plugins/Validation/validate#options) to true (scroll down to see it) ``` $("#formid").validate({ rules: { // simple rule, converted to {required:true} required: "required", }, onfocusout: true }); ```
9,189,910
Ok I have a form with jquery validation that works but I want to take it one step further. It validates using a plug in but only on submit. I am wondering if there is a way to get it to validate on blur so a person doesn't have to wait until they hit submit to know if they have an error. I downloaded this plugin: <ht...
2012/02/08
[ "https://Stackoverflow.com/questions/9189910", "https://Stackoverflow.com", "https://Stackoverflow.com/users/982853/" ]
The best way I can see is to use `$.validate.element(selector)` in the blur event for each element you want this behaviour for: ``` var v = $('#formid').validate(); ``` Then setup blur events: ``` $('#firstName').blur(function(){ v.element('#firstName'); }); ``` See it in action here: <http://jsfiddle.net/ryl...
The current version of the plugin has a function called 'validateOnBlur' which will do what you're asking. Your code should look like this if you've applied the id of `#formid` to the form. ``` <script> $('#formid').validateOnBlur(); </script> ``` For some solid documentation on this head to his github page -- <...
52,739,323
I have a dataframe with a shape `(42538, 145)` in which there are over 50 columns which have a `NaN` values for all the rows. ![Example of the table here](https://i.stack.imgur.com/p2sLg.jpg) I would like to drop these columns without specifying each and every column name in `df.drop`.
2018/10/10
[ "https://Stackoverflow.com/questions/52739323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10357278/" ]
You probably want to start with [`df.notnull`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.notnull.html) to get the locations of all the non-NaNs. You can then use [`df.any`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.any.html) on the result, with `axis` set to ...
Try this: ```py tmp_col = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21] df1.columns = tmp_col df2 = df1[(df1[2] == 'RO En') | (df1[2] == 'RO En Adj')] df2[['bp1','bp2']] = df2[6].str.split('-',expand=True) df2[['mn1','mn2']] = df2[11].str.split(' ',expand=True) df2['FN'] = df2[10] + ' ' + df2[11] df2.loc[...
52,739,323
I have a dataframe with a shape `(42538, 145)` in which there are over 50 columns which have a `NaN` values for all the rows. ![Example of the table here](https://i.stack.imgur.com/p2sLg.jpg) I would like to drop these columns without specifying each and every column name in `df.drop`.
2018/10/10
[ "https://Stackoverflow.com/questions/52739323", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10357278/" ]
You can use [`pd.DataFrame.dropna`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dropna.html) over `axis=1`: ``` df = pd.DataFrame({'A': [1, 2, 3], 'B': [np.nan]*3, 'C': [4, 5, 6], 'D': [np.nan]*3}) df_new = df.dropna(axis=1) print(df_new) A C 0 1 4 1 2 5 2 3 ...
Try this: ```py tmp_col = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21] df1.columns = tmp_col df2 = df1[(df1[2] == 'RO En') | (df1[2] == 'RO En Adj')] df2[['bp1','bp2']] = df2[6].str.split('-',expand=True) df2[['mn1','mn2']] = df2[11].str.split(' ',expand=True) df2['FN'] = df2[10] + ' ' + df2[11] df2.loc[...
5,095,062
The Hibernate Validator documentation has a simple Getting Started guide which outlines [testing validation rules](http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html/validator-gettingstarted.html#d0e168). The relevant chunk is ``` @Test public void manufacturerIsNull() { Car car = new Car(null,...
2011/02/23
[ "https://Stackoverflow.com/questions/5095062", "https://Stackoverflow.com", "https://Stackoverflow.com/users/134894/" ]
You could have a look at the class `org.hibernate.validator.test.util.TestUtil` which is used for Hibernate Validator's own tests and offers functionality for testing expected constraint violations (amongst others there is `assertCorrectConstraintTypes()` for example). Just note, that this class is not part of Hiberna...
Testing the bean validation against a concrete constraint class is a bad idea because will tightly couple the test with the implementation. So, instead of this: ``` assertTrue(ValidationUtils.containsConstraintViolation(violations, NotNull.class)); ``` You could test the outcome of the validation to be that of what ...
37,641,599
I was experimenting with array and pointers in C. And here <http://r4r.co.in/c/c_topics/c_array_basics/array_representation_in_memory.shtml> I read that ``` ar[2]=*(ar+(sizeof(datatype)*2)); ``` However after writing following test program in C:- ``` #include<stdio.h> #include<conio.h> int main() { int arr...
2016/06/05
[ "https://Stackoverflow.com/questions/37641599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4802474/" ]
`E1[E2]` is defined to be equivalent to `*((E1)+(E2))` ([N1570](http://chimera.roma1.infn.it/SP/COMMON/iso-iec-9899-1990.pdf) 6.5.2.1), so `array[4]` will always be `*(array+4)` given that it is in valid range. `+` operator used between a pointer to integer is defined to give (the integer) *elements* (not bytes) after...
You originally misinterpreted the way addition works with pointers. A pointer is an address plus the type of object it points to. So, addition knows that it has to add `sizeof()` bytes. See [Difference Between \*(Pointer + Index) and Pointer[]](https://stackoverflow.com/questions/4622461/difference-between-pointer-ind...
37,641,599
I was experimenting with array and pointers in C. And here <http://r4r.co.in/c/c_topics/c_array_basics/array_representation_in_memory.shtml> I read that ``` ar[2]=*(ar+(sizeof(datatype)*2)); ``` However after writing following test program in C:- ``` #include<stdio.h> #include<conio.h> int main() { int arr...
2016/06/05
[ "https://Stackoverflow.com/questions/37641599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4802474/" ]
`E1[E2]` is defined to be equivalent to `*((E1)+(E2))` ([N1570](http://chimera.roma1.infn.it/SP/COMMON/iso-iec-9899-1990.pdf) 6.5.2.1), so `array[4]` will always be `*(array+4)` given that it is in valid range. `+` operator used between a pointer to integer is defined to give (the integer) *elements* (not bytes) after...
Pointer arithmetic takes the size of the pointed-to type into account. Given a pointer `p` to an object of type `T`, the expression `p+1` will give the address of the next object of type `T`. So, if `p == 0x8000`, `p+1` may yield `0x8001`, `0x8002`, `0x8004`, `0x8008`, or any other value depending on the size of `T`. ...
37,641,599
I was experimenting with array and pointers in C. And here <http://r4r.co.in/c/c_topics/c_array_basics/array_representation_in_memory.shtml> I read that ``` ar[2]=*(ar+(sizeof(datatype)*2)); ``` However after writing following test program in C:- ``` #include<stdio.h> #include<conio.h> int main() { int arr...
2016/06/05
[ "https://Stackoverflow.com/questions/37641599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4802474/" ]
`E1[E2]` is defined to be equivalent to `*((E1)+(E2))` ([N1570](http://chimera.roma1.infn.it/SP/COMMON/iso-iec-9899-1990.pdf) 6.5.2.1), so `array[4]` will always be `*(array+4)` given that it is in valid range. `+` operator used between a pointer to integer is defined to give (the integer) *elements* (not bytes) after...
``` printf("\n*(Array+(sizeof(int)*4)):%d",*(array+((sizeof(int*))*4))); ``` should be ``` printf("\n*(Array+(sizeof(int)*4)):%d",*(array+((sizeof(int))*4))); ``` and the above is only valid when the array of int is treated each byte, which i think is unlikely.
51,626,908
Guys, For some reasons, I have to put a np.array into a single column of DataFrame. It looks as : ``` A B C 1 [1,2] 0 2 [4] 0 3 [1,2,5,6] 0 7 [2,5,6] 0 4 [8] 0 ``` Is there any method setting the column C based on length of column B wit...
2018/08/01
[ "https://Stackoverflow.com/questions/51626908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8437660/" ]
Use [`numpy.where`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html) by condition by [`len`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.str.len.html) and [`isin`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.isin.html): ``` df['C'] = np.where(df['B'...
Use `.apply`: ``` df['C']=df.apply(lambda row: 1 if len(row['B'].tolist()) in [2,4] else -1,axis=1) print(df) ``` Output: ``` A B C 0 1 [1,2] 1 1 2 [4] -1 2 3 [1,2,5,6] 1 3 7 [2,5,6] -1 4 4 [8] -1 ``` (Do `ast.literal_eval` if the dataframe element are strings)
51,689,520
I have such array: ``` homeShapeShift: [ [ {text:"BTC", callback_data: 'btc'}, {text:"ETH", callback_data: 'eth'}, {text:"XRP", callback_data: 'xrp'}, {text:"ETC", callback_data: 'etc'}, ], [ {text:"ZEC", callback_data: 'zec'}, ...
2018/08/04
[ "https://Stackoverflow.com/questions/51689520", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4915919/" ]
If you just want to remove one element just map the inner arrays to new inner filtered arrays: ``` let fe = keyboard.homeShapeShift.map(k => k.filter(e => e.text !== 'ZEC')); ``` Or if you wanna remove the whole array use `every` to get a boolean: ``` let fe = keyboard.homeShapeShift.filter(k => k.every(e => e.t...
You could filter the inner arrays by mapping them and then filter the outer array by the length of the inner arrays. ```js var homeShapeShift = [[{ text: "BTC", callback_data: 'btc' }, { text: "ETH", callback_data: 'eth' }, { text: "XRP", callback_data: 'xrp' }, { text: "ETC", callback_data: 'etc' }], [{ text: "ZEC", ...
26,207,326
Can anyone help to point us to instructions on how to get Django >1.5 working on Google App Engine? I have seen a number of people claim they have Django 1.6 working. We'd like to get 1.6 or 1.7 running. I have searched here for instructions on how to set this up. No luck so far. Update: In our development machine we ...
2014/10/05
[ "https://Stackoverflow.com/questions/26207326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1306929/" ]
You cannot - GAE only supports 1.5, and even that is marked as experimental. If you need django 1.7, perhaps you should use [Google Compute Engine](https://cloud.google.com/compute/docs/), which is Google's brand name for virtual machines that you can spool up. If you are not married to Google App Engine, Heroku suppo...
App Engine's Python environment currently knows how to provide Django up to version 1.5 via the `libraries:` configuration mechanism. This doesn't mean that later versions of Django won't work, only that they aren't yet built in. (I'm not sure why the latest built-in version is 1.5. It may have something to do with AE'...
26,207,326
Can anyone help to point us to instructions on how to get Django >1.5 working on Google App Engine? I have seen a number of people claim they have Django 1.6 working. We'd like to get 1.6 or 1.7 running. I have searched here for instructions on how to set this up. No luck so far. Update: In our development machine we ...
2014/10/05
[ "https://Stackoverflow.com/questions/26207326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1306929/" ]
> > You can use any pure Python third party libraries in your Google App Engine application. In order to use a third party library, simply include the files in your application's directory, and they will be uploaded with your application when you deploy it to our system. You can import the files as you would any other...
You cannot - GAE only supports 1.5, and even that is marked as experimental. If you need django 1.7, perhaps you should use [Google Compute Engine](https://cloud.google.com/compute/docs/), which is Google's brand name for virtual machines that you can spool up. If you are not married to Google App Engine, Heroku suppo...
26,207,326
Can anyone help to point us to instructions on how to get Django >1.5 working on Google App Engine? I have seen a number of people claim they have Django 1.6 working. We'd like to get 1.6 or 1.7 running. I have searched here for instructions on how to set this up. No luck so far. Update: In our development machine we ...
2014/10/05
[ "https://Stackoverflow.com/questions/26207326", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1306929/" ]
> > You can use any pure Python third party libraries in your Google App Engine application. In order to use a third party library, simply include the files in your application's directory, and they will be uploaded with your application when you deploy it to our system. You can import the files as you would any other...
App Engine's Python environment currently knows how to provide Django up to version 1.5 via the `libraries:` configuration mechanism. This doesn't mean that later versions of Django won't work, only that they aren't yet built in. (I'm not sure why the latest built-in version is 1.5. It may have something to do with AE'...
23,160,901
I have a table wherein I need to put a border around a given row or rows with spacing between them. I seem to be able to do one or the other. I know I can use ``` table { border-collapse: separate; border-spacing: 1em 0.5em; } ``` To get my spacing, but then the border won't show up with something like ``` tr.bo...
2014/04/18
[ "https://Stackoverflow.com/questions/23160901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187835/" ]
Duplicate question here: [Style row or column rather than cells when border-collapse: separate](https://stackoverflow.com/questions/2035413/style-row-or-column-rather-than-cells-when-border-collapse-separate) The recommendation is to use colspan to simulate a table row, and add a border to the table inside of the cols...
I guess what you want is to put spaces between the borders of the cell and its data? If so, you can use the property padding in td. ex: ``` td { padding-left: 10px; padding-right: 10px; padding-bottom: 10px; padding-top: 10px; } ```
23,160,901
I have a table wherein I need to put a border around a given row or rows with spacing between them. I seem to be able to do one or the other. I know I can use ``` table { border-collapse: separate; border-spacing: 1em 0.5em; } ``` To get my spacing, but then the border won't show up with something like ``` tr.bo...
2014/04/18
[ "https://Stackoverflow.com/questions/23160901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187835/" ]
Duplicate question here: [Style row or column rather than cells when border-collapse: separate](https://stackoverflow.com/questions/2035413/style-row-or-column-rather-than-cells-when-border-collapse-separate) The recommendation is to use colspan to simulate a table row, and add a border to the table inside of the cols...
you can try to draw an unblured shadow : **[DEMO](http://jsfiddle.net/2nMcg/3/)** ``` .bordered { box-shadow:0 0 0 1px black; } ``` :( this works in FF , but ... --- so , we can use `:first-child` and `:last-child` to draw borders from `td`s, **[DEMO 2](http://jsfiddle.net/2nMcg/8/)** --- ``` .bordered td ...
23,160,901
I have a table wherein I need to put a border around a given row or rows with spacing between them. I seem to be able to do one or the other. I know I can use ``` table { border-collapse: separate; border-spacing: 1em 0.5em; } ``` To get my spacing, but then the border won't show up with something like ``` tr.bo...
2014/04/18
[ "https://Stackoverflow.com/questions/23160901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187835/" ]
Duplicate question here: [Style row or column rather than cells when border-collapse: separate](https://stackoverflow.com/questions/2035413/style-row-or-column-rather-than-cells-when-border-collapse-separate) The recommendation is to use colspan to simulate a table row, and add a border to the table inside of the cols...
You can have an inner table which is bordered: ``` <table> <tr><td colspan="3"> <table class="bordered"> <tr> <td>foo</td> <td>bar</td> <td>baz</td> </tr> </table> </td></tr> <tr> <td>lorem</td> <td>ipsum</td> <td>dolor<...
23,160,901
I have a table wherein I need to put a border around a given row or rows with spacing between them. I seem to be able to do one or the other. I know I can use ``` table { border-collapse: separate; border-spacing: 1em 0.5em; } ``` To get my spacing, but then the border won't show up with something like ``` tr.bo...
2014/04/18
[ "https://Stackoverflow.com/questions/23160901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/187835/" ]
Duplicate question here: [Style row or column rather than cells when border-collapse: separate](https://stackoverflow.com/questions/2035413/style-row-or-column-rather-than-cells-when-border-collapse-separate) The recommendation is to use colspan to simulate a table row, and add a border to the table inside of the cols...
If you want spacing between the table rows and add a border style to each row you can achieve this by setting only top and bottom border-spacing otherwise you cannot have a continuous line for each table row. And you need to set the border style on the td. Since border-collapse: collapse prevents to style the border on...
33,090,412
I was given an assignment in my functional programming course that asks me to rewrite several functions, like `map` and `filter` to be tail recursive. I'm not 100% sure how to go about this yet but I know that you can define functions by calling `foldr` and `foldl`. I know `foldl` is tail recursive, so if I can defin...
2015/10/12
[ "https://Stackoverflow.com/questions/33090412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4556703/" ]
There are two ways to make a recursive function tail recursive: 1. Convert the function to accumulator passing style. This only works in some cases. 2. Convert the function to continuation passing style. This works in all cases. Consider the definition of the `map` function: ```hs map :: (a -> b) -> [a] -> [b] map _...
I'm suspecting the professor/lecturer is expecting solutions where tail recursion is used "directly", i.e. lexically, within the source code of the function, not indirectly, or "dynamically", where tail recursion only happens at runtime within the scope of some subroutine call. Otherwise, you might as well supply e.g....
5,645,544
I'm trying to recreate this image slider: <http://www.egrappler.com/contents/jsCarousel/demo/jsCarousel.htm> Except using more meaningful html. This page just uses a bunch of random divs, with more divs encapsulating the entire thing: ``` <div id="jsCarousel"> <div>Image</div> <div>Image</div> <div>Image</div>...
2011/04/13
[ "https://Stackoverflow.com/questions/5645544", "https://Stackoverflow.com", "https://Stackoverflow.com/users/679161/" ]
Inside jsCarousel.js (where the code starts on line 2), change the `div` to an `li` in these lines: `22, 43, 44` Change line 74 to this: `$('> div > li', slidercontents).css('display', '');` Inside jsCarousel.css, add `margin:0;` and `padding:0;` to `.jscarousel-contents` (line 35) also change `.jscarousal-contents ...
Well, the js is like ``` $(document).ready(function() { $('#jsCarousel').jsCarousel({ onthumbnailclick: function(src) { alert(src); }, autoscroll: true }); }); ``` And the structure of html is like this ``` <div id="jsCarousel"> <div> <img src="images/img_1.jpg"><br> <sp...
60,235,058
I'm trying to implement my first BS option model in Python.Instead of passing one Underlying price at a time however, I would like to pass an array. Here's the code and the error message: ``` xS=np.arange(10,110,10) C=np.maximum(xS-K,0) def bsm_call(S,K,T,r,sigma): d1=[(log(S/K) + 0.5 * pow(sigma,2)*T)/(sigma*p...
2020/02/15
[ "https://Stackoverflow.com/questions/60235058", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8564498/" ]
Just simply output the table after the loop completes. ``` $table = foreach ($gp in $GPINFO) { # Code that gets the values for $aclBefore and $aclAfter is here new-object psobject -Property @{ GPO_Name = $gp.DisplayName Old_Owner = $aclBefore New_Owner = $aclAfter } } $table | For...
You just can't pipe from foreach (). It's an odd part of the language that comes up a lot. Other ways: Foreach-object: ``` $GPINFO | foreach-object { $gp = $_ new-object psobject -Property @{ GPO_Name = $gp.DisplayName Old_Owner = $aclBefore New_Owner = $aclAfter } } | Format-Table...
33,696,903
Let's say I have several columns, one of which has the datetimes below: ``` 2015-07-19 17:00:01 2015-07-19 17:15:01 2015-07-19 17:30:01 2015-07-19 17:45:01 2015-07-19 18:00:01 2015-07-19 18:15:01 2015-07-19 18:30:01 2015-07-19 18:45:01 2015-07-19 19:00:01 2015-07-19 19:15:01 2015-07-19 19:30:01 2015-07-19 19:45:01 201...
2015/11/13
[ "https://Stackoverflow.com/questions/33696903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3325586/" ]
This is working for me: ``` int permissionCheck = ContextCompat.checkSelfPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale...
To simplify your code I recommend you to use next code: 1. Create a OnPermissionRequested interface: ``` public interface OnPermissionRequested { void onGranted(); } ``` 2. In activities/fragments add next methods to check permission. You also can create a main activity and fragment and extend to avoid duplicate...
48,190,268
I want to check if the data at the current 2 references exists, but it seems it returns always true (always the first Toast ) and i think is not checking if URL\_CARS AND URL\_PLANES exists , here is what i have: ``` mDatabase.child("Users").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child("URL_CARS")...
2018/01/10
[ "https://Stackoverflow.com/questions/48190268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9164141/" ]
Firebase will always return you a snapshot when you're trying to read data and it won't ever be null. Because a `Datasnapshot` object consists of two attributes: `key` and `value`, so it's something like `Datasnapshot(key, value)`. When you query your database based on a certain key, the value might not exist (your cas...
To solve this, please use the following code: ``` String uid = FirebaseAuth.getInstance().getCurrentUser().getUid(); DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference(); DatabaseReference uidRef = rootRef.child("Users").child(uid); ValueEventListener eventListener = new ValueEventListener() { ...
10,462,686
I'm using Redis to generate IDs for my in memory stored models. The Redis client requires a callback to the `INCR` command, which means the code looks like ``` client.incr('foo', function(err, id) { ... continue on here }); ``` The problem is, that I already have written the other part of the app, that expects the...
2012/05/05
[ "https://Stackoverflow.com/questions/10462686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72583/" ]
Node.js in its essence is an **async I/O library** (with plugins). So, by definition, there's no synchronous I/O there and you should rewrite your app.
It is a bit of a pain, but what you have to do is wrap the logic that you had after the counter was generated into a function, and call that from the Redis callback. If you had something like this: ``` var id = get_synchronous_id(); processIdSomehow(id); ``` you'll need to do something like this. ``` var runIdLogic...
10,462,686
I'm using Redis to generate IDs for my in memory stored models. The Redis client requires a callback to the `INCR` command, which means the code looks like ``` client.incr('foo', function(err, id) { ... continue on here }); ``` The problem is, that I already have written the other part of the app, that expects the...
2012/05/05
[ "https://Stackoverflow.com/questions/10462686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72583/" ]
Node.js in its essence is an **async I/O library** (with plugins). So, by definition, there's no synchronous I/O there and you should rewrite your app.
@Sergio said this briefly in his answer, but I wanted to write a little more of an expanded answer. node.js is an asynchronous design. It runs in a single thread, which means that in order to remain fast and handle many concurrent operations, all blocking calls must have a callback for their return value to run them as...
10,462,686
I'm using Redis to generate IDs for my in memory stored models. The Redis client requires a callback to the `INCR` command, which means the code looks like ``` client.incr('foo', function(err, id) { ... continue on here }); ``` The problem is, that I already have written the other part of the app, that expects the...
2012/05/05
[ "https://Stackoverflow.com/questions/10462686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72583/" ]
Node.js in its essence is an **async I/O library** (with plugins). So, by definition, there's no synchronous I/O there and you should rewrite your app.
The application state in node.js is normally passed around as an object. What I would do is closer to: ``` var state = {} client.incr('foo', function(err, id) { state.id = id; doSomethingWithId(state.id); }); function doSomethingWithId(id) { // reuse state if necessary } ``` It's just a different way of doin...
10,462,686
I'm using Redis to generate IDs for my in memory stored models. The Redis client requires a callback to the `INCR` command, which means the code looks like ``` client.incr('foo', function(err, id) { ... continue on here }); ``` The problem is, that I already have written the other part of the app, that expects the...
2012/05/05
[ "https://Stackoverflow.com/questions/10462686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72583/" ]
It is a bit of a pain, but what you have to do is wrap the logic that you had after the counter was generated into a function, and call that from the Redis callback. If you had something like this: ``` var id = get_synchronous_id(); processIdSomehow(id); ``` you'll need to do something like this. ``` var runIdLogic...
@Sergio said this briefly in his answer, but I wanted to write a little more of an expanded answer. node.js is an asynchronous design. It runs in a single thread, which means that in order to remain fast and handle many concurrent operations, all blocking calls must have a callback for their return value to run them as...
10,462,686
I'm using Redis to generate IDs for my in memory stored models. The Redis client requires a callback to the `INCR` command, which means the code looks like ``` client.incr('foo', function(err, id) { ... continue on here }); ``` The problem is, that I already have written the other part of the app, that expects the...
2012/05/05
[ "https://Stackoverflow.com/questions/10462686", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72583/" ]
It is a bit of a pain, but what you have to do is wrap the logic that you had after the counter was generated into a function, and call that from the Redis callback. If you had something like this: ``` var id = get_synchronous_id(); processIdSomehow(id); ``` you'll need to do something like this. ``` var runIdLogic...
The application state in node.js is normally passed around as an object. What I would do is closer to: ``` var state = {} client.incr('foo', function(err, id) { state.id = id; doSomethingWithId(state.id); }); function doSomethingWithId(id) { // reuse state if necessary } ``` It's just a different way of doin...
75,351
<https://www.france24.com/en/live-news/20220909-ukraine-reconstruction-to-cost-349-bn-report> > > Rebuilding Ukraine following the devastation caused by the Russian > invasion will cost an estimated $349 billion, according to a report > issued Friday. > > > But the figure, which totals 1.5 times the size of the Ukr...
2022/09/09
[ "https://politics.stackexchange.com/questions/75351", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/38301/" ]
**Legal from what perspective?** International law consists of the assumption that states are [sovereign](https://en.wikipedia.org/wiki/Westphalian_sovereignty), and negotiated or customary rules between them. Just which customary rules are established enough to be [jus cogens](https://en.wikipedia.org/wiki/Peremptory...
**Yes**. The only potential hurdle to it would be sovereign immunity. But **sovereign immunity can be removed with a legislation**. There are already laws which remove sovereign immunity to civil law suits. The criteria for sovereign immunity are established in [Foreign Sovereign Immunities Act](https://en.wikipedia....
75,351
<https://www.france24.com/en/live-news/20220909-ukraine-reconstruction-to-cost-349-bn-report> > > Rebuilding Ukraine following the devastation caused by the Russian > invasion will cost an estimated $349 billion, according to a report > issued Friday. > > > But the figure, which totals 1.5 times the size of the Ukr...
2022/09/09
[ "https://politics.stackexchange.com/questions/75351", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/38301/" ]
Apparently a precedent for doing so (i.e. unlocking frozen Russian assets to use in the rebuilding of Ukraine) exists legally somewhere in the Iraqi 1990 invasion of Kuwait, according to Philip Zelikow at the University of Virginia. But I'm curious as to why it must be "the U.S." that facilitates this process. What, ar...
**Yes**. The only potential hurdle to it would be sovereign immunity. But **sovereign immunity can be removed with a legislation**. There are already laws which remove sovereign immunity to civil law suits. The criteria for sovereign immunity are established in [Foreign Sovereign Immunities Act](https://en.wikipedia....
75,351
<https://www.france24.com/en/live-news/20220909-ukraine-reconstruction-to-cost-349-bn-report> > > Rebuilding Ukraine following the devastation caused by the Russian > invasion will cost an estimated $349 billion, according to a report > issued Friday. > > > But the figure, which totals 1.5 times the size of the Ukr...
2022/09/09
[ "https://politics.stackexchange.com/questions/75351", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/38301/" ]
**Legal from what perspective?** International law consists of the assumption that states are [sovereign](https://en.wikipedia.org/wiki/Westphalian_sovereignty), and negotiated or customary rules between them. Just which customary rules are established enough to be [jus cogens](https://en.wikipedia.org/wiki/Peremptory...
Apparently a precedent for doing so (i.e. unlocking frozen Russian assets to use in the rebuilding of Ukraine) exists legally somewhere in the Iraqi 1990 invasion of Kuwait, according to Philip Zelikow at the University of Virginia. But I'm curious as to why it must be "the U.S." that facilitates this process. What, ar...
75,351
<https://www.france24.com/en/live-news/20220909-ukraine-reconstruction-to-cost-349-bn-report> > > Rebuilding Ukraine following the devastation caused by the Russian > invasion will cost an estimated $349 billion, according to a report > issued Friday. > > > But the figure, which totals 1.5 times the size of the Ukr...
2022/09/09
[ "https://politics.stackexchange.com/questions/75351", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/38301/" ]
**Legal from what perspective?** International law consists of the assumption that states are [sovereign](https://en.wikipedia.org/wiki/Westphalian_sovereignty), and negotiated or customary rules between them. Just which customary rules are established enough to be [jus cogens](https://en.wikipedia.org/wiki/Peremptory...
The context matters. If to ask "can and would USA just nationalize arbitrary foreign accounts for no reasons", the answer is likely no and all talks about "undermined trust" are relevant. But there is more than that in the context. If I launch a rocket from my yard and destroy a house of my neighbor, it cannot be the...
75,351
<https://www.france24.com/en/live-news/20220909-ukraine-reconstruction-to-cost-349-bn-report> > > Rebuilding Ukraine following the devastation caused by the Russian > invasion will cost an estimated $349 billion, according to a report > issued Friday. > > > But the figure, which totals 1.5 times the size of the Ukr...
2022/09/09
[ "https://politics.stackexchange.com/questions/75351", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/38301/" ]
Apparently a precedent for doing so (i.e. unlocking frozen Russian assets to use in the rebuilding of Ukraine) exists legally somewhere in the Iraqi 1990 invasion of Kuwait, according to Philip Zelikow at the University of Virginia. But I'm curious as to why it must be "the U.S." that facilitates this process. What, ar...
The context matters. If to ask "can and would USA just nationalize arbitrary foreign accounts for no reasons", the answer is likely no and all talks about "undermined trust" are relevant. But there is more than that in the context. If I launch a rocket from my yard and destroy a house of my neighbor, it cannot be the...
77,515
In general I have found that as the focal length of 35mm (or APS-C) lenses increases, the physical length of the lens increases as well. However, my large format lens is much thinner than other 35mm lenses of equivalent focal length. Here is a picture: [![Two lenses](https://i.stack.imgur.com/oNMHx.jpg)](https://i.sta...
2016/05/18
[ "https://photo.stackexchange.com/questions/77515", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/36933/" ]
The focal length is the distance from the (theoretical) center of the lens to the image plane. On the large format camera, there's a lot more *camera* between the lens and the film. The lenses are also often relatively simple — there's no need for a focusing mechanism in the lens itself, for example. @osullic gives ...
A few points to consider (mostly adding to mattdm's answer): A manually focusing 135mm Nikkor 2.8 lens in F mount is about 91.5mm long, and looking at a drawing of the lens most of the optical elements are in the front. So a comparison with a zoom lens isn't really fair -- it is a much more complicated lens. Strictly...
77,515
In general I have found that as the focal length of 35mm (or APS-C) lenses increases, the physical length of the lens increases as well. However, my large format lens is much thinner than other 35mm lenses of equivalent focal length. Here is a picture: [![Two lenses](https://i.stack.imgur.com/oNMHx.jpg)](https://i.sta...
2016/05/18
[ "https://photo.stackexchange.com/questions/77515", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/36933/" ]
The focal length is the distance from the (theoretical) center of the lens to the image plane. On the large format camera, there's a lot more *camera* between the lens and the film. The lenses are also often relatively simple — there's no need for a focusing mechanism in the lens itself, for example. @osullic gives ...
Take a look at these two Schneider lenses that both have 90mm focal length: ![](https://i.stack.imgur.com/yztbd.jpg) ![](https://i.stack.imgur.com/RhrEg.jpg) The first has coverage for "35mm" format, the second coverage for large format. I am not sure, but I think the main reason for the difference in size is the fac...
77,515
In general I have found that as the focal length of 35mm (or APS-C) lenses increases, the physical length of the lens increases as well. However, my large format lens is much thinner than other 35mm lenses of equivalent focal length. Here is a picture: [![Two lenses](https://i.stack.imgur.com/oNMHx.jpg)](https://i.sta...
2016/05/18
[ "https://photo.stackexchange.com/questions/77515", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/36933/" ]
The focal length is the distance from the (theoretical) center of the lens to the image plane. On the large format camera, there's a lot more *camera* between the lens and the film. The lenses are also often relatively simple — there's no need for a focusing mechanism in the lens itself, for example. @osullic gives ...
The word lens is from the Latin, shaped like a lentil seed. This is a disk that bulges out of both sides, we call this lens shape, convex – convex. A single transparent convex – convex lens will do the deed. We task the camera lens to gather image forming light rays from a 3 dimensional world (object at different dista...
77,515
In general I have found that as the focal length of 35mm (or APS-C) lenses increases, the physical length of the lens increases as well. However, my large format lens is much thinner than other 35mm lenses of equivalent focal length. Here is a picture: [![Two lenses](https://i.stack.imgur.com/oNMHx.jpg)](https://i.sta...
2016/05/18
[ "https://photo.stackexchange.com/questions/77515", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/36933/" ]
A few points to consider (mostly adding to mattdm's answer): A manually focusing 135mm Nikkor 2.8 lens in F mount is about 91.5mm long, and looking at a drawing of the lens most of the optical elements are in the front. So a comparison with a zoom lens isn't really fair -- it is a much more complicated lens. Strictly...
The word lens is from the Latin, shaped like a lentil seed. This is a disk that bulges out of both sides, we call this lens shape, convex – convex. A single transparent convex – convex lens will do the deed. We task the camera lens to gather image forming light rays from a 3 dimensional world (object at different dista...
77,515
In general I have found that as the focal length of 35mm (or APS-C) lenses increases, the physical length of the lens increases as well. However, my large format lens is much thinner than other 35mm lenses of equivalent focal length. Here is a picture: [![Two lenses](https://i.stack.imgur.com/oNMHx.jpg)](https://i.sta...
2016/05/18
[ "https://photo.stackexchange.com/questions/77515", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/36933/" ]
Take a look at these two Schneider lenses that both have 90mm focal length: ![](https://i.stack.imgur.com/yztbd.jpg) ![](https://i.stack.imgur.com/RhrEg.jpg) The first has coverage for "35mm" format, the second coverage for large format. I am not sure, but I think the main reason for the difference in size is the fac...
The word lens is from the Latin, shaped like a lentil seed. This is a disk that bulges out of both sides, we call this lens shape, convex – convex. A single transparent convex – convex lens will do the deed. We task the camera lens to gather image forming light rays from a 3 dimensional world (object at different dista...
29,925
Given [how easy it is to register to vote](https://politics.stackexchange.com/questions/29879/is-anything-preventing-non-us-citizens-from-registering-to-vote-in-non-voter-id) in the US as a non-US citizen, it seems plausible that a non-zero number of such persons are on the electoral rolls in the US. There [are statist...
2018/03/27
[ "https://politics.stackexchange.com/questions/29925", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/7434/" ]
See [Nation Council of State Legislatures](http://www.ncsl.org/research/elections-and-campaigns/voter-list-accuracy.aspx), almost all states take efforts to purge voter registration rolls of ineligible persons, including those persons who are ineligible because of citizenship. The reason for NOT expending effort tp "co...
[![enter image description here](https://i.stack.imgur.com/Ki7wx.png)](https://i.stack.imgur.com/Ki7wx.png) There is good information on the foreign born population of every county in the United States (and for that matter, every census tract), which is broken down by age as well. There is good information on the num...
9,689,970
My Java code returns a Collection (ArrayList) and the resulting JSON produced by JAXB looks like: ``` {"todo":[{"name":"CAMPBELL","sales":"3","time":"1331662363931"}, {"name":"FRESNO","sales":"2","time":"1331662363931"}]} ``` But, is there a way I can make it look like: ``` [{"name":"CAMPBELL","sales":"3","time":"1...
2012/03/13
[ "https://Stackoverflow.com/questions/9689970", "https://Stackoverflow.com", "https://Stackoverflow.com/users/655577/" ]
All you need is: ``` var todo = resp.todo; ``` where `resp` is the whole JSON response. Note that this is actually good design. A root array is not recommended due to [JSON hijacking](http://haacked.com/archive/2009/06/25/json-hijacking.aspx).
**Note:** I'm the [**EclipseLink JAXB (MOXy)**](http://www.eclipse.org/eclipselink/moxy.php) lead and a member of the [**JAXB 2 (JSR-222)**](http://jcp.org/en/jsr/detail?id=222) expert group. Instead of correcting bad JSON on the client, you could fix the problem on the server. Below is an example of how EclipseLink J...
46,184,818
I have the Review Model, I am trying to validate the model, so that when the user selects a date, it can't be the date in the future. Review.cs ``` public class Review : BaseEntity{ [Key] public int Id {get; set;} [Required(ErrorMessage="You need a restaurant name!")] public string RestaurantName {g...
2017/09/12
[ "https://Stackoverflow.com/questions/46184818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8350646/" ]
You can create a custom validation attribute which does your custom logic and use that to decorate your property name. ``` public class DateLessThanOrEqualToToday : ValidationAttribute { public override string FormatErrorMessage(string name) { return "Date value should not be a future date"; } ...
You need to write a custom validator for this. You can name it as you wish, for example. ``` [DateNotInTheFuture] public DateTime Date { get; set; } ``` Process itself is explained in good detail in this article: <https://msdn.microsoft.com/en-us/library/cc668224.aspx> Summarised: * Create new sealed public class ...
46,184,818
I have the Review Model, I am trying to validate the model, so that when the user selects a date, it can't be the date in the future. Review.cs ``` public class Review : BaseEntity{ [Key] public int Id {get; set;} [Required(ErrorMessage="You need a restaurant name!")] public string RestaurantName {g...
2017/09/12
[ "https://Stackoverflow.com/questions/46184818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8350646/" ]
Try **custom validation** or **standard model validation** with attributes. First option, set attribute on property **standard dataannotations validation**: * Set **DateType** attribute with errormessage properties and dateformatstring. * Set **Range** attribute if you want. * Set **Display** attribute for show label...
You need to write a custom validator for this. You can name it as you wish, for example. ``` [DateNotInTheFuture] public DateTime Date { get; set; } ``` Process itself is explained in good detail in this article: <https://msdn.microsoft.com/en-us/library/cc668224.aspx> Summarised: * Create new sealed public class ...
46,184,818
I have the Review Model, I am trying to validate the model, so that when the user selects a date, it can't be the date in the future. Review.cs ``` public class Review : BaseEntity{ [Key] public int Id {get; set;} [Required(ErrorMessage="You need a restaurant name!")] public string RestaurantName {g...
2017/09/12
[ "https://Stackoverflow.com/questions/46184818", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8350646/" ]
You can create a custom validation attribute which does your custom logic and use that to decorate your property name. ``` public class DateLessThanOrEqualToToday : ValidationAttribute { public override string FormatErrorMessage(string name) { return "Date value should not be a future date"; } ...
Try **custom validation** or **standard model validation** with attributes. First option, set attribute on property **standard dataannotations validation**: * Set **DateType** attribute with errormessage properties and dateformatstring. * Set **Range** attribute if you want. * Set **Display** attribute for show label...
9,062,209
My question is why does python use both reference counting and mark-and-sweep for gc? Why not only mark-and-sweep? My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right? ...
2012/01/30
[ "https://Stackoverflow.com/questions/9062209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383482/" ]
Python (the language) doesn't say which form of garbage collection it uses. The main implementation (often known as CPython) acts as you describe. Other versions such as Jython or IronPython use a purely garbage collected system. Yes, there is a benefit of earlier collection with reference counting, but the main reaso...
**Reference counting deallocates objects sooner than garbage collection.** But as reference counting can't handle reference cycles between unreachable objects, Python uses a garbage collector (really just a cycle collector) to collect those cycles when they exist.
9,062,209
My question is why does python use both reference counting and mark-and-sweep for gc? Why not only mark-and-sweep? My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right? ...
2012/01/30
[ "https://Stackoverflow.com/questions/9062209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383482/" ]
**Reference counting deallocates objects sooner than garbage collection.** But as reference counting can't handle reference cycles between unreachable objects, Python uses a garbage collector (really just a cycle collector) to collect those cycles when they exist.
> > My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right? > > > Yes. As soon as the refcount goes to zero and object can be removed. This won't happen in a cyclic ref...
9,062,209
My question is why does python use both reference counting and mark-and-sweep for gc? Why not only mark-and-sweep? My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right? ...
2012/01/30
[ "https://Stackoverflow.com/questions/9062209", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383482/" ]
Python (the language) doesn't say which form of garbage collection it uses. The main implementation (often known as CPython) acts as you describe. Other versions such as Jython or IronPython use a purely garbage collected system. Yes, there is a benefit of earlier collection with reference counting, but the main reaso...
> > My initial guess is that using reference counting can easily remove non-cyclic referenced objects, this may somewhat speed up mark-and-sweep and gain memory immediately. Don't know if my guess is right? > > > Yes. As soon as the refcount goes to zero and object can be removed. This won't happen in a cyclic ref...
13,874,742
I would like to recursively go through all files ending in .mp3 or .flac (case-insentive) in my `C:\Songs` directory and pass each file path as an argument to a binary file run from windows command prompt which returns a string representation of the audio fingerprint. I then want to insert a record into a 2xn sqlite t...
2012/12/14
[ "https://Stackoverflow.com/questions/13874742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/784637/" ]
Using a batch script ``` @echo off setlocal pushd "C:\Songs" REM Get the file count for /f %%N in ('dir /b /a-d *.mp3 *.flac^|find /c /v ""') do set "cnt=%%N" REM The file count is now in the cnt variable. I'll simply ECHO the value echo File count = %cnt% REM Process each file for %%F in (*.mp3 *.flac) do ( REM ...
You *could* use a Windows batch script for this. @dbenham's answer looks like a good start if that's the approach you want to take (and I upvoted that answer). But if you want real error checking, or you want to enhance this over time I'd recommend a real programming or scripting language. There are a lot of good choi...
46,765,099
I am currently trying to use a Kubernetes cluster for the Gitlab CI. While following the not so good docs (<https://docs.gitlab.com/runner/install/kubernetes.html>), what I did was manually register a runner with the token from Gitlab CI section so I could get another token and use it in the ConfigMap I use for the dep...
2017/10/16
[ "https://Stackoverflow.com/questions/46765099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6618742/" ]
@djuarez As long the deployment selector matches the pods label in the template section, and in this case from what I can see that is the case: ``` selector: matchLabels: name: gitlab-runner template: metadata: labels: name: gitlab-runner ``` it should not be a problem; provided the correct API is ...
Because of: ``` selector: matchLabels: name: gitlab-runner ``` No pod is able to retrieve a job with that label. Removing the selector would be enough, there is no need for it.
46,532,245
I am trying to create a method that will remove the first item from a list. Here's what a have so far... ``` public void removefromlist(int n) { for(n != 0) n = n -1 If(n -1 != 0) List.remove(n) } ```
2017/10/02
[ "https://Stackoverflow.com/questions/46532245", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8710307/" ]
According to this, <https://github.com/dotnet/corefx/pull/12426>, if I'm reading this right, it's missing until .NET Standard 1.7. **Edit:** No, no, no, I got this all wrong. The problem was that I didn't have ".NET Core cross-platform development" selected when I installed Visual Studio 2017. That gave me the class l...
You need to either include the namespace at the top of the program trying to use the DataTable, or you need to fully qualify the name of the class, everytime you reference it. e.g. ``` using System.Data; System.Data.DataTable myTable = new System.Data.DataTable(); ```
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
Assuming others will find this question when having the `overloaded method value thenReturn with alternatives` error, I want to share my solution as well. Instead of `when(field.getValue(isA(classOf[Record]))).thenReturn(value)` I use `doReturn(value).when(field).getValue(isA(classOf[Record]))` which resolves the ...
The workaround is quite easy: ``` OngoingStubbing<T> thenReturn(T value); OngoingStubbing<T> thenReturn(T value1, T valu2, T... values); ``` There is no "varargs must be non empty" feature.
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
Assuming others will find this question when having the `overloaded method value thenReturn with alternatives` error, I want to share my solution as well. Instead of `when(field.getValue(isA(classOf[Record]))).thenReturn(value)` I use `doReturn(value).when(field).getValue(isA(classOf[Record]))` which resolves the ...
I tried Steve's solution and got a huge compiler error including: ``` scala.tools.nsc.symtab.Types$TypeError: type mismatch; found : scala.reflect.Manifest[Nothing] required: scala.reflect.ClassManifest[B] Note: Nothing <: B, but trait ClassManifest is invariant in type T. You may wish to investigate a wildcard ty...
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
These answers are all to the wrong question. The difference is subtle, but this is not the same issue as the one in the [linked ticket](https://issues.scala-lang.org/browse/SI-2991). That one does require unreasonable gymnastics to call the non-varargs method. For this one, the following is enough. ``` thenReturn[Stri...
Assuming others will find this question when having the `overloaded method value thenReturn with alternatives` error, I want to share my solution as well. Instead of `when(field.getValue(isA(classOf[Record]))).thenReturn(value)` I use `doReturn(value).when(field).getValue(isA(classOf[Record]))` which resolves the ...
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
If calling the vararg version is acceptable, ``` thenReturn("something", Nil: _*) ``` Can't think of a way to call the method without varargs right now.
The workaround is quite easy: ``` OngoingStubbing<T> thenReturn(T value); OngoingStubbing<T> thenReturn(T value1, T valu2, T... values); ``` There is no "varargs must be non empty" feature.
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
This is a known Scala-Java interoperability problem, though it's unfortunately not in the FAQ. Here's the [Scala ticket describing the problem](https://issues.scala-lang.org/browse/SI-2991). Essentially, both methods are applicable when you give a single argument, and the Scala compiler currently doesn't have any heuri...
If calling the vararg version is acceptable, ``` thenReturn("something", Nil: _*) ``` Can't think of a way to call the method without varargs right now.
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
These answers are all to the wrong question. The difference is subtle, but this is not the same issue as the one in the [linked ticket](https://issues.scala-lang.org/browse/SI-2991). That one does require unreasonable gymnastics to call the non-varargs method. For this one, the following is enough. ``` thenReturn[Stri...
I tried Steve's solution and got a huge compiler error including: ``` scala.tools.nsc.symtab.Types$TypeError: type mismatch; found : scala.reflect.Manifest[Nothing] required: scala.reflect.ClassManifest[B] Note: Nothing <: B, but trait ClassManifest is invariant in type T. You may wish to investigate a wildcard ty...
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
This is a known Scala-Java interoperability problem, though it's unfortunately not in the FAQ. Here's the [Scala ticket describing the problem](https://issues.scala-lang.org/browse/SI-2991). Essentially, both methods are applicable when you give a single argument, and the Scala compiler currently doesn't have any heuri...
The workaround is quite easy: ``` OngoingStubbing<T> thenReturn(T value); OngoingStubbing<T> thenReturn(T value1, T valu2, T... values); ``` There is no "varargs must be non empty" feature.
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
These answers are all to the wrong question. The difference is subtle, but this is not the same issue as the one in the [linked ticket](https://issues.scala-lang.org/browse/SI-2991). That one does require unreasonable gymnastics to call the non-varargs method. For this one, the following is enough. ``` thenReturn[Stri...
If calling the vararg version is acceptable, ``` thenReturn("something", Nil: _*) ``` Can't think of a way to call the method without varargs right now.
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
If calling the vararg version is acceptable, ``` thenReturn("something", Nil: _*) ``` Can't think of a way to call the method without varargs right now.
I tried Steve's solution and got a huge compiler error including: ``` scala.tools.nsc.symtab.Types$TypeError: type mismatch; found : scala.reflect.Manifest[Nothing] required: scala.reflect.ClassManifest[B] Note: Nothing <: B, but trait ClassManifest is invariant in type T. You may wish to investigate a wildcard ty...
13,358,716
I'm trying to create jsp page which will create a svg graphic file. Based on various examples of jsp pages and svgs i come with this: ``` <?xml version="1.0" encoding="UTF-8"?> <%@ page language="java" contentType="image/svg+xml; charset=UTF-8;" pageEncoding="UTF-8"%> <% response.addHeader( "Content-Disp...
2012/11/13
[ "https://Stackoverflow.com/questions/13358716", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902383/" ]
This is a known Scala-Java interoperability problem, though it's unfortunately not in the FAQ. Here's the [Scala ticket describing the problem](https://issues.scala-lang.org/browse/SI-2991). Essentially, both methods are applicable when you give a single argument, and the Scala compiler currently doesn't have any heuri...
I tried Steve's solution and got a huge compiler error including: ``` scala.tools.nsc.symtab.Types$TypeError: type mismatch; found : scala.reflect.Manifest[Nothing] required: scala.reflect.ClassManifest[B] Note: Nothing <: B, but trait ClassManifest is invariant in type T. You may wish to investigate a wildcard ty...
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
You can use `Counter` class for exactly this purpose: ``` from collections import Counter x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] c = Counter(x) new_values = [item for item in x if c[item] > 1] indexes = [1 if c[item] == 1 else 0 for item in x] print(new_values) print(indexes) ``` Output is: ``...
You can use [`collections.Counter`](https://docs.python.org/3/library/collections.html#collections.Counter) and isolate items appearing only once. then use list comprehensions for your desired results. The solution is O(n) overall, although it involves 3 passes. ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','L...
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
Alternative *one-liner* with **`pandas`** module and its [`pd.Series.duplicated()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.duplicated.html) function: ``` In [80]: x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] In [81]: (~pd.Series(x).duplicated(keep=False)).astype(int).tolist()...
You can use [`collections.Counter`](https://docs.python.org/3/library/collections.html#collections.Counter) and isolate items appearing only once. then use list comprehensions for your desired results. The solution is O(n) overall, although it involves 3 passes. ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','L...
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
Alternative *one-liner* with **`pandas`** module and its [`pd.Series.duplicated()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.duplicated.html) function: ``` In [80]: x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] In [81]: (~pd.Series(x).duplicated(keep=False)).astype(int).tolist()...
You can use `Counter` class for exactly this purpose: ``` from collections import Counter x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] c = Counter(x) new_values = [item for item in x if c[item] > 1] indexes = [1 if c[item] == 1 else 0 for item in x] print(new_values) print(indexes) ``` Output is: ``...
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
You can use `Counter` class for exactly this purpose: ``` from collections import Counter x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] c = Counter(x) new_values = [item for item in x if c[item] > 1] indexes = [1 if c[item] == 1 else 0 for item in x] print(new_values) print(indexes) ``` Output is: ``...
Could you create a new list, and work with that? ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] loc = [] new_x = [] for name in x: if x.count(name) == 1: loc.append(1) else: loc.append(0) new_x.append(name) ```
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
You can use `Counter` class for exactly this purpose: ``` from collections import Counter x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] c = Counter(x) new_values = [item for item in x if c[item] > 1] indexes = [1 if c[item] == 1 else 0 for item in x] print(new_values) print(indexes) ``` Output is: ``...
You can also use list comprehension ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga', 'Lam'] y = [name for name in x if x.count(name) != 1] ``` output ====== ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam']
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
Alternative *one-liner* with **`pandas`** module and its [`pd.Series.duplicated()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.duplicated.html) function: ``` In [80]: x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] In [81]: (~pd.Series(x).duplicated(keep=False)).astype(int).tolist()...
Could you create a new list, and work with that? ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] loc = [] new_x = [] for name in x: if x.count(name) == 1: loc.append(1) else: loc.append(0) new_x.append(name) ```
51,221,526
I have the following list of words: ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] ``` I need to remove the words that appear only once, and return there indices, or positions. ``` y = ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam'] loc = [0, 0, 0, 1, 1, 0, 0] ``` Any simple function to do this?
2018/07/07
[ "https://Stackoverflow.com/questions/51221526", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3110765/" ]
Alternative *one-liner* with **`pandas`** module and its [`pd.Series.duplicated()`](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.duplicated.html) function: ``` In [80]: x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga','Lam'] In [81]: (~pd.Series(x).duplicated(keep=False)).astype(int).tolist()...
You can also use list comprehension ``` x = ['Gaga', 'Gaga', 'Lam', 'Reem', 'Pal', 'Gaga', 'Lam'] y = [name for name in x if x.count(name) != 1] ``` output ====== ['Gaga', 'Gaga', 'Lam', 'Gaga', 'Lam']
214,687
This is the first in what I plan to be a series of questions on how cats with a human level intelligence would be able to work things out. I was inspired by an artist called [Neytirix](https://www.deviantart.com/neytirix) and the [world](https://www.deviantart.com/neytirix/art/Passing-through-834355010) she drew for h...
2021/10/03
[ "https://worldbuilding.stackexchange.com/questions/214687", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/86570/" ]
While cats are certainly individuals. as a general observation from having owned five cats as pets, they don’t like wearing things, especially tight things. Harnesses can restrict a cat's movement, they can get their claws caught in them and the experience of putting them on can cause them distress. I imagine cats mi...
**One thing at a time.** [![cat carries socks](https://i.stack.imgur.com/GGpmP.jpg)](https://i.stack.imgur.com/GGpmP.jpg) <https://www.youtube.com/watch?v=TUA03xCO2eo> This cat carries a sock. So too most cats in your world: a sock. Some of them might sometimes carry a pipe cleaner, or a raw piece of sphagetti, or B...
214,687
This is the first in what I plan to be a series of questions on how cats with a human level intelligence would be able to work things out. I was inspired by an artist called [Neytirix](https://www.deviantart.com/neytirix) and the [world](https://www.deviantart.com/neytirix/art/Passing-through-834355010) she drew for h...
2021/10/03
[ "https://worldbuilding.stackexchange.com/questions/214687", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/86570/" ]
With no changes in their anatomy, cats can mostly use their mouth to handles something: either by holding and lifting it, if not to big, or by pulling it on the ground. In other words, the first way would resemble how they carry their kittens or small preys like mice and birds. The second way would resemble how they m...
While cats are certainly individuals. as a general observation from having owned five cats as pets, they don’t like wearing things, especially tight things. Harnesses can restrict a cat's movement, they can get their claws caught in them and the experience of putting them on can cause them distress. I imagine cats mi...
214,687
This is the first in what I plan to be a series of questions on how cats with a human level intelligence would be able to work things out. I was inspired by an artist called [Neytirix](https://www.deviantart.com/neytirix) and the [world](https://www.deviantart.com/neytirix/art/Passing-through-834355010) she drew for h...
2021/10/03
[ "https://worldbuilding.stackexchange.com/questions/214687", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/86570/" ]
With no changes in their anatomy, cats can mostly use their mouth to handles something: either by holding and lifting it, if not to big, or by pulling it on the ground. In other words, the first way would resemble how they carry their kittens or small preys like mice and birds. The second way would resemble how they m...
**One thing at a time.** [![cat carries socks](https://i.stack.imgur.com/GGpmP.jpg)](https://i.stack.imgur.com/GGpmP.jpg) <https://www.youtube.com/watch?v=TUA03xCO2eo> This cat carries a sock. So too most cats in your world: a sock. Some of them might sometimes carry a pipe cleaner, or a raw piece of sphagetti, or B...
214,687
This is the first in what I plan to be a series of questions on how cats with a human level intelligence would be able to work things out. I was inspired by an artist called [Neytirix](https://www.deviantart.com/neytirix) and the [world](https://www.deviantart.com/neytirix/art/Passing-through-834355010) she drew for h...
2021/10/03
[ "https://worldbuilding.stackexchange.com/questions/214687", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/86570/" ]
With human level intellegince then the answer is they get another animal to do the heavy moving. So you just need your cats to train horses for the heavy goods. Maybe they would also train something like a small dog for day-to-day carrying of small items.
**One thing at a time.** [![cat carries socks](https://i.stack.imgur.com/GGpmP.jpg)](https://i.stack.imgur.com/GGpmP.jpg) <https://www.youtube.com/watch?v=TUA03xCO2eo> This cat carries a sock. So too most cats in your world: a sock. Some of them might sometimes carry a pipe cleaner, or a raw piece of sphagetti, or B...
214,687
This is the first in what I plan to be a series of questions on how cats with a human level intelligence would be able to work things out. I was inspired by an artist called [Neytirix](https://www.deviantart.com/neytirix) and the [world](https://www.deviantart.com/neytirix/art/Passing-through-834355010) she drew for h...
2021/10/03
[ "https://worldbuilding.stackexchange.com/questions/214687", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/86570/" ]
With no changes in their anatomy, cats can mostly use their mouth to handles something: either by holding and lifting it, if not to big, or by pulling it on the ground. In other words, the first way would resemble how they carry their kittens or small preys like mice and birds. The second way would resemble how they m...
With human level intellegince then the answer is they get another animal to do the heavy moving. So you just need your cats to train horses for the heavy goods. Maybe they would also train something like a small dog for day-to-day carrying of small items.
74,434,139
I'm attempting to create a new list with all the possible pairs in a list but only want to have the numbers that are neighbors be possible pairs. For example, I have already created this list from a file: [1, 8, 10, 16, 19, 22, 27, 33, 36, 40, 47, 52, 56, 61, 63, 71, 72, 75, 81, 81, 84, 88, 96, 98, 103, 110, 113, 118...
2022/11/14
[ "https://Stackoverflow.com/questions/74434139", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14783967/" ]
Use `zip()` with a slice of the list offset by one place. ``` result = list(zip(newl, newl[1:])) ```
Just use this simple for loop: ``` newl = [1, 8, 10, 16, 19, 22, 27, 33, 36, 40, 47, 52, 56, 61, 63, 71, 72, 75, 81, 81, 84, 88, 96, 98, 103, 110, 113, 118, 124, 128, 129, 134, 134, 139, 148, 157, 157, 160, 162, 164] lst = [] for i in range(len(newl)): try: lst.append((newl[i], newl[i+1])) except: ...
40,689,038
So, I'm working on a website with Meteor and Materialize-css, and attempting to implement a dropdown menu in the navbar, which activates on hover instead of on click. I have my files this way: HTML: ``` <ul id="dropdown1" class="dropdown-content"> <li><a href="#">Option 1</a></li> <li><a href="#">Option 2<...
2016/11/19
[ "https://Stackoverflow.com/questions/40689038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7180935/" ]
it's because 'hover' needs to be surrounded with quotes. this is just a syntax error in your JSON. ``` $(".dropdown-button").dropdown({ "hover": true }); ``` I tested this with materialize 1.0.0-Beta.
Make sure you have Jquery included. This may be causing the problem. I would comment but don't have enough rep.
40,689,038
So, I'm working on a website with Meteor and Materialize-css, and attempting to implement a dropdown menu in the navbar, which activates on hover instead of on click. I have my files this way: HTML: ``` <ul id="dropdown1" class="dropdown-content"> <li><a href="#">Option 1</a></li> <li><a href="#">Option 2<...
2016/11/19
[ "https://Stackoverflow.com/questions/40689038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7180935/" ]
it's because 'hover' needs to be surrounded with quotes. this is just a syntax error in your JSON. ``` $(".dropdown-button").dropdown({ "hover": true }); ``` I tested this with materialize 1.0.0-Beta.
I figured it out! I was getting so frustrated that I tried downgrading Materialize from `v0.97.7` to `v0.97.0`, because version .8 had given me trouble. And now (like magic) everything works! I hope this helps someone in the future.
41,696,268
Both RevitPythonShell scripts and Revit Python Macros are relying on Iron Python. In both cases, at least in Revit 15, neither require the installation of IronPython. I believe RevitPythonShell installs with the capacity to process the ironPython script (rpsruntime.dll). Revit must install with the same capacity. The...
2017/01/17
[ "https://Stackoverflow.com/questions/41696268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3614570/" ]
I agree with your assumption that these two environments are probably completely separate and independent of each other. Since the Python code that you write within them is pure .NET, it is easy to reference other .NET modules, assemblies, libraries, whatever you want to call them. They would reside in .NET assembly D...
For pure-python modules, it could be as easy as having a CPython installation (e.g. Anaconda) and pip installing to that, then adding the site-packages of that installation to the search path in RPS. For modules that include native code (numpy and many others), this gets more tricky and you should google how to instal...
13,064,111
Friends, I run my code in instruments, it show memory leak in 5 line(out of following code) i.e `cell = [[[NSBundle mainBundle] loadNibNamed:@"ZoomCustomVideoCell" owner:self options:nil] objectAtIndex:0];` I have no idea why it shows a memory leak there and what is solution for same ``` - (UITableViewCell *)tableVi...
2012/10/25
[ "https://Stackoverflow.com/questions/13064111", "https://Stackoverflow.com", "https://Stackoverflow.com/users/560193/" ]
The `loadNibNamed:owner:options:` method takes the argument passed as `owner:` as the “File's Owner” of the nib. This means that outlets in the nib will be connected to whatever you pass as the owner. Since you are passing `self` as the owner, it will be overwriting any previously assigned outlets for `self` with ones ...
This line causes the memory leak: ``` cell = [[[NSBundle mainBundle] loadNibNamed:@"ZoomCustomVideoCell" owner:self options:nil] objectAtIndex:0]; ``` change it to: ``` cell = [[[[NSBundle mainBundle] loadNibNamed:@"ZoomCustomVideoCell" owner:self options:nil] objectAtIndex:0] autorelease]; ```
558,564
I have an external HD that, when plugged in, is accessible at: `/media/myusername/79039342-7793-4990-9eae-95ef3d4a9331`. I figured out it's the drive called `/dev/sdb` (with a single partition in it `sdb1`). Fine! Thing is, it is not writeable. If I try: ``` sudo mount -o remount,uid=1000,gid=1000,rw /dev/sdb1 ``...
2014/12/09
[ "https://askubuntu.com/questions/558564", "https://askubuntu.com", "https://askubuntu.com/users/352526/" ]
First, when it's auto-mounted, run `mount` and look for the `/dev/sdb1` and see how it's mounted now. If there's a `ro` it's read-only, or a `rw` means you're almost done :) And a `lsblk` is a prettier way to see if & where drives are mounted too. `sudo blkid` may show some more useful info as well, possibly about FS ...
First, I would unmount it. ``` umount /dev/sdb1 ``` Then, I'd remount it ``` sudo mount /dev/sdb1 /home/user/driveb1 rw 0 2 ``` I would then check to be sure it was remounted ``` mount ```
16,985,311
I've populated a listview with names using Icon View. The listview isn't full, and when you accidently catch a blank area of the listview it actually registers a click on the first item in the listview, which is triggering an event that hasn't actually happened. Is there a way of catching a "non-click" Thanks John...
2013/06/07
[ "https://Stackoverflow.com/questions/16985311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2385197/" ]
I seem to recall needing to use the HitTest method to validate the ListItem that was just clicked. I captured the X/Y coords in the MouseDown then in the Click I validated that the click actually landed on a ListItem.
The *HitTest* method mentioned by tcarvin is sound. If you don't need the generic Click event though, it would be easier to opt for the *ItemClick* event instead. This should only fire when actually clicking on an item.
36,979,325
For `(int -> int) -> int = <fun>` the corresponding expression can be `fun x -> (x 1) + 1`. Is it possible to have an expression with `int -> (int -> int) = <fun>` type? If not then why?
2016/05/02
[ "https://Stackoverflow.com/questions/36979325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4060355/" ]
You can split your url by `/` and take needed element (first remove `http://` part): ```js var str = 'http://test.com/en/country/city'; str = str.replace('http://', ''); var parts = str.split('/'); console.log(parts); alert(parts[2]+', '+parts[3]); ```
Try something like this. ``` var url = window.location.href; var urlArray = url.split("/"); urlArray[urlArray.length-1] //City urlArray[urlArray.length-2] //Country ```
36,979,325
For `(int -> int) -> int = <fun>` the corresponding expression can be `fun x -> (x 1) + 1`. Is it possible to have an expression with `int -> (int -> int) = <fun>` type? If not then why?
2016/05/02
[ "https://Stackoverflow.com/questions/36979325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4060355/" ]
Try: ``` var fragment = "http://test.com/en/country/city"; var array_fragment = fragment.split('/'); var city = array_fragment[array_fragment.length - 1] var country = array_fragment[array_fragment.length - 2] alert(country) ```
> > Is this posible with lastIndexOf? > > > **Yes, it is possible.** Let's say ``` x="http://test.com/en/country/city" ``` We get the position of the last `/` ``` y=x.lastIndexOf("/");//26 ``` We get the position of the second last `/` ``` z=x.lastIndexOf("/",y-1);//18 ``` To extract the country, we no...
36,979,325
For `(int -> int) -> int = <fun>` the corresponding expression can be `fun x -> (x 1) + 1`. Is it possible to have an expression with `int -> (int -> int) = <fun>` type? If not then why?
2016/05/02
[ "https://Stackoverflow.com/questions/36979325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4060355/" ]
Try: ``` var fragment = "http://test.com/en/country/city"; var array_fragment = fragment.split('/'); var city = array_fragment[array_fragment.length - 1] var country = array_fragment[array_fragment.length - 2] alert(country) ```
Try something like this. ``` var url = window.location.href; var urlArray = url.split("/"); urlArray[urlArray.length-1] //City urlArray[urlArray.length-2] //Country ```
36,979,325
For `(int -> int) -> int = <fun>` the corresponding expression can be `fun x -> (x 1) + 1`. Is it possible to have an expression with `int -> (int -> int) = <fun>` type? If not then why?
2016/05/02
[ "https://Stackoverflow.com/questions/36979325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4060355/" ]
Use split function to get second last value. Try this ``` var url='http://test.com/en/country/city'; var splitArray=url.split('/'); alert(splitArray[splitArray.length-2]); ```
Try something like this. ``` var url = window.location.href; var urlArray = url.split("/"); urlArray[urlArray.length-1] //City urlArray[urlArray.length-2] //Country ```
36,979,325
For `(int -> int) -> int = <fun>` the corresponding expression can be `fun x -> (x 1) + 1`. Is it possible to have an expression with `int -> (int -> int) = <fun>` type? If not then why?
2016/05/02
[ "https://Stackoverflow.com/questions/36979325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4060355/" ]
You could do something like this: ``` var url = "http://test.com/en/country/city" var urlParts = url.split("/") urlParts[urlParts.length - 1] (which would equal to "city") urlParts[urlParts.length - 2] (which would equal to "country") ``` Basically split on each occurence of `"/"` and pick the correct item from the ...
Try something like this. ``` var url = window.location.href; var urlArray = url.split("/"); urlArray[urlArray.length-1] //City urlArray[urlArray.length-2] //Country ```
36,979,325
For `(int -> int) -> int = <fun>` the corresponding expression can be `fun x -> (x 1) + 1`. Is it possible to have an expression with `int -> (int -> int) = <fun>` type? If not then why?
2016/05/02
[ "https://Stackoverflow.com/questions/36979325", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4060355/" ]
Try: ``` var fragment = "http://test.com/en/country/city"; var array_fragment = fragment.split('/'); var city = array_fragment[array_fragment.length - 1] var country = array_fragment[array_fragment.length - 2] alert(country) ```
You could do something like this: ``` var url = "http://test.com/en/country/city" var urlParts = url.split("/") urlParts[urlParts.length - 1] (which would equal to "city") urlParts[urlParts.length - 2] (which would equal to "country") ``` Basically split on each occurence of `"/"` and pick the correct item from the ...