qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
Use `padding left` like `editText.setPadding (int left, int top, int right, int bottom);`
Try this in your java code ``` editText.setPadding( 5, 0,0,0); ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
Use `padding left` like `editText.setPadding (int left, int top, int right, int bottom);`
Try this code..... ``` android:includeFontPadding="true" android:paddingLeft="5dp" ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
Use `padding left` like `editText.setPadding (int left, int top, int right, int bottom);`
You can do this through XML as well in coding. If you want to do in XML, You have to do the padding to required Edit text. ``` <EditText android:id="@+id/bt_description" android:layout_height="match_parent" android:layout_width="match_parent" android:paddingLeft="10dp" /> ``` If not you can do this through code as above said. ``` email.setPadding(int left,int top,int right,int bottom); ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
try this code ``` android:paddingLeft="5dp" ```
Try this in your java code ``` editText.setPadding( 5, 0,0,0); ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
try this code ``` android:paddingLeft="5dp" ```
Try this code..... ``` android:includeFontPadding="true" android:paddingLeft="5dp" ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
try this code ``` android:paddingLeft="5dp" ```
You can do this through XML as well in coding. If you want to do in XML, You have to do the padding to required Edit text. ``` <EditText android:id="@+id/bt_description" android:layout_height="match_parent" android:layout_width="match_parent" android:paddingLeft="10dp" /> ``` If not you can do this through code as above said. ``` email.setPadding(int left,int top,int right,int bottom); ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
Try this code..... ``` android:includeFontPadding="true" android:paddingLeft="5dp" ```
Try this in your java code ``` editText.setPadding( 5, 0,0,0); ```
15,941,999
Can I set some space inside 'EditText' in the beginning and at the end? If possible, then how? Actually, I have done some customization on my 'EditText' view and now it shows like this, as shown in the below image: ![Emulator screen shot](https://i.stack.imgur.com/SoUOZ.png) In my case, as you see, in my "description" field, the word "Description" starts from the very beginning, which doesnt look attractive, I want to keep some space in the beginning and at the end of the EditText's text. And also i want to set this, at the run time as this editText views are set on the runtime after a selection from the spinner. Can i achieve this?
2013/04/11
[ "https://Stackoverflow.com/questions/15941999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1739882/" ]
Try this code..... ``` android:includeFontPadding="true" android:paddingLeft="5dp" ```
You can do this through XML as well in coding. If you want to do in XML, You have to do the padding to required Edit text. ``` <EditText android:id="@+id/bt_description" android:layout_height="match_parent" android:layout_width="match_parent" android:paddingLeft="10dp" /> ``` If not you can do this through code as above said. ``` email.setPadding(int left,int top,int right,int bottom); ```
13,670,253
The past 3 days I've tried to get this simple example to work but whatever I try I just can't seem to understand where I'm going wrong... HTML: ``` <input type="text" id="textEntry" /> <button>Go</button> <ul id="list"> <li>Text from the input field will appear below</li> </ul> ``` jQUERY: ``` $('button').click(function() { $enteredText = $('#textEntry').val(); if($enteredText.length === 0) { alert('PLace an item in the field box'); } else { $newListItem = $('<li/>').html($enteredText).appendTo('#list'); } }); $('li').live('mouseover mouseout', function(event) { if(event.type == mouseover) { $(this).css('background-color', 'yellow'); } else { $(this).css('backgorund-color', 'transparent'); } }); ``` Ultimately what I'm looking to do is have a user input an item into the text field which would then append itself to the existing list (this works - no issues). The user can then hover over a specific entry causing the background to turn yellow on mouseover and transparent on mouseout (the issue). Any help would be swell. Thanks.
2012/12/02
[ "https://Stackoverflow.com/questions/13670253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/933252/" ]
If the schema contains serial or sequence columns, you should reset these to the max value that occurs in the corresponding column. (normally you should not import the serials from a file, but give them the freedom to autoincrement.) For all imported tables you should identify the sequence fields and run the following code on them. (substitute your schema name for "sch", your table name for "mytable" and your id column name for "id") ``` WITH mx AS ( SELECT MAX(id) AS id FROM sch.mytable) SELECT setval('sch.mytable_id_seq', mx.id) AS curseq FROM mx ; ```
You can automate wildplasser's solution so that all sequences are synchronized with the current maximum value of their associated column: ``` do $block$ declare r record; stmt text; max_id integer; begin for r in ( select * from ( select table_schema, table_name, column_name, pg_get_serial_sequence(table_schema||'.'||table_name, column_name) as col_sequence from information_schema.columns where table_schema not in ('pg_catalog', 'information_schema') ) t where col_sequence is not null ) loop stmt := 'select coalesce(max('||r.column_name||'), 0) + 1 from '||r.table_schema||'.'||r.table_name; execute stmt into max_id; raise notice 'Next ID for %.%.% is %', r.table_schema, r.table_name, r.column_name, max_id; perform setval(r.col_sequence, max_id); end loop; end; $block$ ``` Note that this will only work if the columns have been defined as `serial`, `bigserial` or have been made the "owner" of a sequence.
13,670,253
The past 3 days I've tried to get this simple example to work but whatever I try I just can't seem to understand where I'm going wrong... HTML: ``` <input type="text" id="textEntry" /> <button>Go</button> <ul id="list"> <li>Text from the input field will appear below</li> </ul> ``` jQUERY: ``` $('button').click(function() { $enteredText = $('#textEntry').val(); if($enteredText.length === 0) { alert('PLace an item in the field box'); } else { $newListItem = $('<li/>').html($enteredText).appendTo('#list'); } }); $('li').live('mouseover mouseout', function(event) { if(event.type == mouseover) { $(this).css('background-color', 'yellow'); } else { $(this).css('backgorund-color', 'transparent'); } }); ``` Ultimately what I'm looking to do is have a user input an item into the text field which would then append itself to the existing list (this works - no issues). The user can then hover over a specific entry causing the background to turn yellow on mouseover and transparent on mouseout (the issue). Any help would be swell. Thanks.
2012/12/02
[ "https://Stackoverflow.com/questions/13670253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/933252/" ]
If the schema contains serial or sequence columns, you should reset these to the max value that occurs in the corresponding column. (normally you should not import the serials from a file, but give them the freedom to autoincrement.) For all imported tables you should identify the sequence fields and run the following code on them. (substitute your schema name for "sch", your table name for "mytable" and your id column name for "id") ``` WITH mx AS ( SELECT MAX(id) AS id FROM sch.mytable) SELECT setval('sch.mytable_id_seq', mx.id) AS curseq FROM mx ; ```
Another way is remove the primary key (id) from the columns (or don't dump the id). So your data would look like ``` INSERT INTO book (name, price) VALUES ('Alchemist' , 10); ``` instead of ``` INSERT INTO book (id, name, price) VALUES (1 , 'Alchemist' , 10); ``` This way, you won't have to reset the primary key after loading initial data
13,670,253
The past 3 days I've tried to get this simple example to work but whatever I try I just can't seem to understand where I'm going wrong... HTML: ``` <input type="text" id="textEntry" /> <button>Go</button> <ul id="list"> <li>Text from the input field will appear below</li> </ul> ``` jQUERY: ``` $('button').click(function() { $enteredText = $('#textEntry').val(); if($enteredText.length === 0) { alert('PLace an item in the field box'); } else { $newListItem = $('<li/>').html($enteredText).appendTo('#list'); } }); $('li').live('mouseover mouseout', function(event) { if(event.type == mouseover) { $(this).css('background-color', 'yellow'); } else { $(this).css('backgorund-color', 'transparent'); } }); ``` Ultimately what I'm looking to do is have a user input an item into the text field which would then append itself to the existing list (this works - no issues). The user can then hover over a specific entry causing the background to turn yellow on mouseover and transparent on mouseout (the issue). Any help would be swell. Thanks.
2012/12/02
[ "https://Stackoverflow.com/questions/13670253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/933252/" ]
You can automate wildplasser's solution so that all sequences are synchronized with the current maximum value of their associated column: ``` do $block$ declare r record; stmt text; max_id integer; begin for r in ( select * from ( select table_schema, table_name, column_name, pg_get_serial_sequence(table_schema||'.'||table_name, column_name) as col_sequence from information_schema.columns where table_schema not in ('pg_catalog', 'information_schema') ) t where col_sequence is not null ) loop stmt := 'select coalesce(max('||r.column_name||'), 0) + 1 from '||r.table_schema||'.'||r.table_name; execute stmt into max_id; raise notice 'Next ID for %.%.% is %', r.table_schema, r.table_name, r.column_name, max_id; perform setval(r.col_sequence, max_id); end loop; end; $block$ ``` Note that this will only work if the columns have been defined as `serial`, `bigserial` or have been made the "owner" of a sequence.
Another way is remove the primary key (id) from the columns (or don't dump the id). So your data would look like ``` INSERT INTO book (name, price) VALUES ('Alchemist' , 10); ``` instead of ``` INSERT INTO book (id, name, price) VALUES (1 , 'Alchemist' , 10); ``` This way, you won't have to reset the primary key after loading initial data
13,670,253
The past 3 days I've tried to get this simple example to work but whatever I try I just can't seem to understand where I'm going wrong... HTML: ``` <input type="text" id="textEntry" /> <button>Go</button> <ul id="list"> <li>Text from the input field will appear below</li> </ul> ``` jQUERY: ``` $('button').click(function() { $enteredText = $('#textEntry').val(); if($enteredText.length === 0) { alert('PLace an item in the field box'); } else { $newListItem = $('<li/>').html($enteredText).appendTo('#list'); } }); $('li').live('mouseover mouseout', function(event) { if(event.type == mouseover) { $(this).css('background-color', 'yellow'); } else { $(this).css('backgorund-color', 'transparent'); } }); ``` Ultimately what I'm looking to do is have a user input an item into the text field which would then append itself to the existing list (this works - no issues). The user can then hover over a specific entry causing the background to turn yellow on mouseover and transparent on mouseout (the issue). Any help would be swell. Thanks.
2012/12/02
[ "https://Stackoverflow.com/questions/13670253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/933252/" ]
In Rails you can use the command > > `ActiveRecord::Base.connection.reset_pk_sequence!('users')` > > > to bring the primary key index for the User table in sync again.
You can automate wildplasser's solution so that all sequences are synchronized with the current maximum value of their associated column: ``` do $block$ declare r record; stmt text; max_id integer; begin for r in ( select * from ( select table_schema, table_name, column_name, pg_get_serial_sequence(table_schema||'.'||table_name, column_name) as col_sequence from information_schema.columns where table_schema not in ('pg_catalog', 'information_schema') ) t where col_sequence is not null ) loop stmt := 'select coalesce(max('||r.column_name||'), 0) + 1 from '||r.table_schema||'.'||r.table_name; execute stmt into max_id; raise notice 'Next ID for %.%.% is %', r.table_schema, r.table_name, r.column_name, max_id; perform setval(r.col_sequence, max_id); end loop; end; $block$ ``` Note that this will only work if the columns have been defined as `serial`, `bigserial` or have been made the "owner" of a sequence.
13,670,253
The past 3 days I've tried to get this simple example to work but whatever I try I just can't seem to understand where I'm going wrong... HTML: ``` <input type="text" id="textEntry" /> <button>Go</button> <ul id="list"> <li>Text from the input field will appear below</li> </ul> ``` jQUERY: ``` $('button').click(function() { $enteredText = $('#textEntry').val(); if($enteredText.length === 0) { alert('PLace an item in the field box'); } else { $newListItem = $('<li/>').html($enteredText).appendTo('#list'); } }); $('li').live('mouseover mouseout', function(event) { if(event.type == mouseover) { $(this).css('background-color', 'yellow'); } else { $(this).css('backgorund-color', 'transparent'); } }); ``` Ultimately what I'm looking to do is have a user input an item into the text field which would then append itself to the existing list (this works - no issues). The user can then hover over a specific entry causing the background to turn yellow on mouseover and transparent on mouseout (the issue). Any help would be swell. Thanks.
2012/12/02
[ "https://Stackoverflow.com/questions/13670253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/933252/" ]
In Rails you can use the command > > `ActiveRecord::Base.connection.reset_pk_sequence!('users')` > > > to bring the primary key index for the User table in sync again.
Another way is remove the primary key (id) from the columns (or don't dump the id). So your data would look like ``` INSERT INTO book (name, price) VALUES ('Alchemist' , 10); ``` instead of ``` INSERT INTO book (id, name, price) VALUES (1 , 'Alchemist' , 10); ``` This way, you won't have to reset the primary key after loading initial data
488,019
For most ML models we say they suffer from high bias or high variance, then we correct for it. However, in DL do neural networks suffer from the same concept in the sense that they initially have high bias or high variance and then you correct through regularization and/or dropout? I would argue they initially suffer from high variance and they overfit the data. Then you correct through regularization, add dropout, image pre-processing in the case of CNNs, etc. Is this train of thought correct?
2020/09/18
[ "https://stats.stackexchange.com/questions/488019", "https://stats.stackexchange.com", "https://stats.stackexchange.com/users/72773/" ]
In general NNs are prone to overfitting the training set, which is case of a [high variance](https://datascience.stackexchange.com/questions/45578/why-underfitting-is-called-high-bias-and-overfitting-is-called-high-variance). Your train of thought is generally correct in the sense that the proposed solutions (regularization, dropout layers, etc.) are tools that control the bias-variance trade-off.
Neural networks, including DNNs, don't *by themselves* suffer from high variance any more than other machine learning algorithms. It is just that we find it easier to start the training with more complex networks and control for variance by the techniques you mentioned, than to start with simpler (less expressive) networks and gradually increase their complexity. By observing the network behaviour during training you can already get hints regarding simplification. If you'd start with a simpler network, you'd be tapping in the dark how to augment it.
9,327,400
I've create a c# winforms form, It has a bunch of labels positioned and a flowlayoutpanel. on certain occasions i set one of the labels and the flowlayoutpanel to visible =false. As a result i want all labels beneath them to be pushed up - at the moment there is a gap where they were. Also, I'd like the flowlayoutpanel to grow and shrink depending on the number of items it has. at the moment it is just the size i set it to be in the designer. please can you help with these 2 issues. Thanks
2012/02/17
[ "https://Stackoverflow.com/questions/9327400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66975/" ]
If I got you correctly, I would suggest using a TableLayoutPane with two rows. The top row will contain a docked panel with all the controls that may be hidden. The bottom row will contain a docked panel with all the rest. Set the top row's SizeType to AutoSize and the bottom row's to 100%. When you want to hide the controls, set the top panel's Visible property to false. Now, because the top row is AutoSized it will shrink to nothing, causing the bottom row to "jump" up.
The TableLayoutPanel does the pushing. Maybe you can use that if there is no better answer in next time.
9,327,400
I've create a c# winforms form, It has a bunch of labels positioned and a flowlayoutpanel. on certain occasions i set one of the labels and the flowlayoutpanel to visible =false. As a result i want all labels beneath them to be pushed up - at the moment there is a gap where they were. Also, I'd like the flowlayoutpanel to grow and shrink depending on the number of items it has. at the moment it is just the size i set it to be in the designer. please can you help with these 2 issues. Thanks
2012/02/17
[ "https://Stackoverflow.com/questions/9327400", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66975/" ]
If I got you correctly, I would suggest using a TableLayoutPane with two rows. The top row will contain a docked panel with all the controls that may be hidden. The bottom row will contain a docked panel with all the rest. Set the top row's SizeType to AutoSize and the bottom row's to 100%. When you want to hide the controls, set the top panel's Visible property to false. Now, because the top row is AutoSized it will shrink to nothing, causing the bottom row to "jump" up.
First problem: You may use some simple panels to divide your form, give them the `dock.fill` property. when you'll hide a panel programmatically, the other panels will fill the empty space left. Second problem: You have to set the `Autosize` property to `true`.
192,935
I want to say : > > Analysis **conducted at a** insurance company showed that... > > or > > Analysis **into a** insurance company showed that... > > > What is the best way to phrase this?
2014/08/23
[ "https://english.stackexchange.com/questions/192935", "https://english.stackexchange.com", "https://english.stackexchange.com/users/89164/" ]
I would make it slightly less passive: *"An analysis performed by the insurance company ..."* or other material to indicate *who* performed the analysis and *where* it was performed as well as the issue being analyzed. If you or your associates performed the analysis, you might phrase it: *"An analysis performed by the authors into insurance company policies...'*
Use: > > The analysis that the company made says that \_\_\_. > > >
52,259,592
We are hosting our website in Azure. During the deployment(TFS) we will do the below Steps as the part of the deployment pipeline. 1. Stop the WebApp 2. Deploy Web App Service 3. Start the WebApp After the 1st step, if anyone tries to access our website, then by default Azure will return the below page [![enter image description here](https://i.stack.imgur.com/zXQzr.jpg)](https://i.stack.imgur.com/zXQzr.jpg) We really don't want our users to show this page during the outage. We are planning to show our own outage image/page in such case. Is there is any way to achieve this? Since Azure Web Apps in a Paas model, I'm wondering how to do this? Any inputs Appreciated!
2018/09/10
[ "https://Stackoverflow.com/questions/52259592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7073340/" ]
It should work with ``` from test import foo ``` But you have to add a `__init__.py` to your project directory. For Python 3 it would be: ``` from .test import foo ``` If you use the dot in front of the folder name, python searches for the file in the same directory as the file you are working on is placed in. Sorry for my bad english.
Are you using an IDE? If so add the path to the Python Interpreter inside the project Properties to all the primary packages (foo, test, notebooks). Otherwise try to explicitly add the bar package to the sys path like so ``` import sys import os MYDIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.join(MYDIR,'test')) sys.path.append(os.path.join(MYDIR,'test/foo')) sys.path.append(os.path.join(MYDIR,'test/foo/bar')) #I am not sure this is entirely needed ```
52,259,592
We are hosting our website in Azure. During the deployment(TFS) we will do the below Steps as the part of the deployment pipeline. 1. Stop the WebApp 2. Deploy Web App Service 3. Start the WebApp After the 1st step, if anyone tries to access our website, then by default Azure will return the below page [![enter image description here](https://i.stack.imgur.com/zXQzr.jpg)](https://i.stack.imgur.com/zXQzr.jpg) We really don't want our users to show this page during the outage. We are planning to show our own outage image/page in such case. Is there is any way to achieve this? Since Azure Web Apps in a Paas model, I'm wondering how to do this? Any inputs Appreciated!
2018/09/10
[ "https://Stackoverflow.com/questions/52259592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7073340/" ]
Messing with `sys.path` is rarely a good idea. Since your plan seems to be to use both `foo` and `test` from `notebooks` (that will probably just contain Jupyter notebooks), the cleanest solution would be to install `foo` and `test` as packages. Remove the `__init__.py` from your top level directory and `notebooks`, since you will not want to import them. Then add a `setup.py` to your top level directory. Since your tests are specific to `foo`, you should either rename them `foo_test` or move them into `foo` itself. A minimal `setup.py` would look like this ``` from setuptools import setup setup(name='foo', version='0.1', description='descroption of fo', author='you', author_email='your@mail', packages=['foo','test_foo]) ``` Then you can simply `pip install -e .` in your top level directory and it will be installed into your current virtualenv. If you are not using virtualenvs, you should `pip install --user -e .`
It should work with ``` from test import foo ``` But you have to add a `__init__.py` to your project directory. For Python 3 it would be: ``` from .test import foo ``` If you use the dot in front of the folder name, python searches for the file in the same directory as the file you are working on is placed in. Sorry for my bad english.
52,259,592
We are hosting our website in Azure. During the deployment(TFS) we will do the below Steps as the part of the deployment pipeline. 1. Stop the WebApp 2. Deploy Web App Service 3. Start the WebApp After the 1st step, if anyone tries to access our website, then by default Azure will return the below page [![enter image description here](https://i.stack.imgur.com/zXQzr.jpg)](https://i.stack.imgur.com/zXQzr.jpg) We really don't want our users to show this page during the outage. We are planning to show our own outage image/page in such case. Is there is any way to achieve this? Since Azure Web Apps in a Paas model, I'm wondering how to do this? Any inputs Appreciated!
2018/09/10
[ "https://Stackoverflow.com/questions/52259592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7073340/" ]
Messing with `sys.path` is rarely a good idea. Since your plan seems to be to use both `foo` and `test` from `notebooks` (that will probably just contain Jupyter notebooks), the cleanest solution would be to install `foo` and `test` as packages. Remove the `__init__.py` from your top level directory and `notebooks`, since you will not want to import them. Then add a `setup.py` to your top level directory. Since your tests are specific to `foo`, you should either rename them `foo_test` or move them into `foo` itself. A minimal `setup.py` would look like this ``` from setuptools import setup setup(name='foo', version='0.1', description='descroption of fo', author='you', author_email='your@mail', packages=['foo','test_foo]) ``` Then you can simply `pip install -e .` in your top level directory and it will be installed into your current virtualenv. If you are not using virtualenvs, you should `pip install --user -e .`
Are you using an IDE? If so add the path to the Python Interpreter inside the project Properties to all the primary packages (foo, test, notebooks). Otherwise try to explicitly add the bar package to the sys path like so ``` import sys import os MYDIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.join(MYDIR,'test')) sys.path.append(os.path.join(MYDIR,'test/foo')) sys.path.append(os.path.join(MYDIR,'test/foo/bar')) #I am not sure this is entirely needed ```
52,819,018
This code should count the number of prime numbers based on user input. If user input is 10, then I should get 4. However, I only get 0. Why does the second loop not run? ``` #include<stdio.h> #include<math.h> int main() { int N; scanf("%d", &N); int numprime; numprime = 0; int P=1; for (P; P<N; P++) { if (P%2==0) continue; int e = sqrt(P); for (int j=3;j<=e;j+=2) { if (P%j!=0) { numprime = numprime + 1; } else { continue; } } } printf("%d", numprime); } ```
2018/10/15
[ "https://Stackoverflow.com/questions/52819018", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10502481/" ]
`flex-direction: column` ======================== The major problem (besides some bad syntax on background shorthand) is that the `flex-direction` was at default which is `row` (horizontal). The flex items (`.logo` and `.copy`) are stacked vertically thus the `flex-direction` should be `column`. --- Demo ---- **Details commented in demo** ```css html, body { /* Always set the font on html */ font: 700 16px/1.5 Verdana; width: 100%; height: 100%; } .flex { /* shorthand for background goes in this order: position (center) repeat (no-repeat) size (cover) and there's no slash "/" *//* no-repeat is the only one kept */ background: url('https://i.imgur.com/5OLUUfp.png')no-repeat; /* The sidebar is always top to bottom */ min-height: 100%; /* The width was 100vw which is 100% of viewport which I'm assuming is wrong since a sidebar should only cover a portion of the viewport. */ width: 320px; /* By default flex-direction is row (horizontal flow) */ display: flex; /* The flex items (.logo and .copy) are vertical, so the flex- direction should be column. flex-flow is a combination of flex-direction and flex-wrap */ flex-flow: column nowrap; justify-content: center; align-items: center; } .logo { /* This pushes the footer.copy down to the bottom */ margin: auto; } img { display: block; width: 90%; } .copy { font-size: 0.875rem; color: #FFF; /* This property is given to individual tags that will break away from vertical flow of align-items */ align-self: flex-end; margin-right: 10px } ``` ```html <aside class="flex"> <figure class="logo"> <img src="https://i.imgur.com/cx6bov9.png"> </figure> <footer class='copy'>&copy; copyright 2018</footer> </aside> ```
you can use `position`. Add `position:relative;` to `.inner_content` and `position:absolute;` and `bottom:0;` to `.inner_content p` so your css looks like this ``` .flex { align-items: center; display: flex; } aside { background: url('../img/sidebar-image.jpg') no-repeat center/cover; height: 20em; width: 100vw; float: left; } .inner_content { justify-content: center; flex-direction: column; height: inherit; width: inherit; position: relative; } .inner_content p { font-size: 14px; margin-top: 2em; color: #FFF; position: absolute; bottom:0; } ``` but you can do this in multiple ways here is a link to a similar question explaining this in multiple ways: [Center and right align flexbox elements](https://stackoverflow.com/questions/38948102/center-and-right-align-flexbox-elements)
20,852,167
I am new to php. I have tried the following code to redirect the page when sign In button is clicked, but it is not happening. please help me editing the code. probably, there is an error in header() function. Have I used the header() function correctly? ``` <body> <?php $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) { $passwordErr = "*Password is required"; } else { $password = test_input($_POST["password"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); } ?> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
2013/12/31
[ "https://Stackoverflow.com/questions/20852167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3131191/" ]
Add `@ob_start();` top of the page, ``` if (isset($_POST["sign"])) { header('Location:signInform.php'); } ```
your issue is header already send.You can avoid this issue by using `ob_start()`.Try like this: ``` <?php ob_start(); $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required";} else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) {$passwordErr = "*Password is required";} else {$password = test_input($_POST["password"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); exit(); } ?> <body> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
20,852,167
I am new to php. I have tried the following code to redirect the page when sign In button is clicked, but it is not happening. please help me editing the code. probably, there is an error in header() function. Have I used the header() function correctly? ``` <body> <?php $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) { $passwordErr = "*Password is required"; } else { $password = test_input($_POST["password"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); } ?> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
2013/12/31
[ "https://Stackoverflow.com/questions/20852167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3131191/" ]
Add `@ob_start();` top of the page, ``` if (isset($_POST["sign"])) { header('Location:signInform.php'); } ```
Just remove following line. ``` include("signInform.php"); ``` and put header function like below. ``` header('location:signInform.php'); ```
20,852,167
I am new to php. I have tried the following code to redirect the page when sign In button is clicked, but it is not happening. please help me editing the code. probably, there is an error in header() function. Have I used the header() function correctly? ``` <body> <?php $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) { $passwordErr = "*Password is required"; } else { $password = test_input($_POST["password"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); } ?> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
2013/12/31
[ "https://Stackoverflow.com/questions/20852167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3131191/" ]
Add `@ob_start();` top of the page, ``` if (isset($_POST["sign"])) { header('Location:signInform.php'); } ```
``` use--- echo '<script> location.href="signInform.php";</script>'; instead of header('Location:signInform.php'); replace if($_POST["sign"]) { header('Location:signInform.php'); } to if($_POST["sign"]) { echo '<script> location.href="signInform.php";</script>'; } and why did you include include("signInform.php"); this line that's why showing error already sent. ```
20,852,167
I am new to php. I have tried the following code to redirect the page when sign In button is clicked, but it is not happening. please help me editing the code. probably, there is an error in header() function. Have I used the header() function correctly? ``` <body> <?php $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) { $passwordErr = "*Password is required"; } else { $password = test_input($_POST["password"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); } ?> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
2013/12/31
[ "https://Stackoverflow.com/questions/20852167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3131191/" ]
Just remove following line. ``` include("signInform.php"); ``` and put header function like below. ``` header('location:signInform.php'); ```
your issue is header already send.You can avoid this issue by using `ob_start()`.Try like this: ``` <?php ob_start(); $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required";} else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) {$passwordErr = "*Password is required";} else {$password = test_input($_POST["password"]);} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); exit(); } ?> <body> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
20,852,167
I am new to php. I have tried the following code to redirect the page when sign In button is clicked, but it is not happening. please help me editing the code. probably, there is an error in header() function. Have I used the header() function correctly? ``` <body> <?php $emailErr = $passwordErr = ""; $email = $password = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["email"])) { $emailErr = "*Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["password"])) { $passwordErr = "*Password is required"; } else { $password = test_input($_POST["password"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } include("signInform.php"); if($_POST["sign"]) { header('Location:signInform.php'); } ?> <br/><br/><br/><br/><br/> <h1>WELCOME</h1> <h2>Please, Register Yourself!</h2> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <label>E-mail:</label><br /> <input type="text" name="email"/> <span class="error"> <?php echo $emailErr;?></span> <br /> <label>Password:</label><br /> <input type="password" name="password"/> <span class="error"> <?php echo $passwordErr;?></span> <br /><br /> <input type="submit" value="Register"/><br/> <p>If already a user, Sign in! </p> <input type="submit" value="Sign In" name="sign"/><br/> </form> </body> ```
2013/12/31
[ "https://Stackoverflow.com/questions/20852167", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3131191/" ]
Just remove following line. ``` include("signInform.php"); ``` and put header function like below. ``` header('location:signInform.php'); ```
``` use--- echo '<script> location.href="signInform.php";</script>'; instead of header('Location:signInform.php'); replace if($_POST["sign"]) { header('Location:signInform.php'); } to if($_POST["sign"]) { echo '<script> location.href="signInform.php";</script>'; } and why did you include include("signInform.php"); this line that's why showing error already sent. ```
12,025,173
Here is the main problem: ``` dig maktabkhooneh.info +trace ``` works perfectly fine and returns the right answer. ``` dig maktabkhooneh.info ``` (without +trace) returns: ``` ; <<>> DiG 9.8.1-P1 <<>> maktabkhooneh.info ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 58716 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ``` What could be the reason? I was reading [this](https://serverfault.com/questions/65499/dig-trace-resolves-while-without-doesnt). Is it the only possible reason that I changed domain data 12hrs ago? Isn't there any other possible reason for `SERVFAIL`? **extra info:** I have two BIND servers working on 168.144.251.73 (master) and 168.144.92.50 (slave). and on the master I have: ``` $TTL 300 maktabkhooneh.info. IN SOA ns1.maktabkhooneh.info. admin.maktabkhooneh.info. ( 2012060201 ; Serial 86400 ; Refresh 7200 ; Retry 3600000 ; Expire 300 ) ; Minimum maktabkhooneh.info. IN A 168.144.97.83 maktabkhooneh.info. IN NS ns1.maktabkhooneh.info. maktabkhooneh.info. IN NS ns2.maktabkhooneh.info. ns1 IN A 168.144.251.73 ns2 IN A 168.144.92.50 www IN CNAME maktabkhooneh.info. ```
2012/08/19
[ "https://Stackoverflow.com/questions/12025173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1380812/" ]
`dig +trace` follows the whole chain from the beginning - it queries root servers, then .info servers then your namservers. Thus it avoids any caching resolvers, and also avoids propagation issues. `dig +notrace` (the default) queries your default DNS resolver (on Linux, whatever specified in `/etc/resolv.conf`). There's some problem with that resolver - maybe it's misconfigured, maybe it has old data in its caches, maybe it can not reach your authoritative nameservers, etc.
In my case was a problem related to /etc/named.conf file. I could resolve this with the previous answer from Sandman and googling the way to fix a corrupted named.conf in cpanel. I had to access to shell console and type the following commands: for backup the file ``` mv /etc/named.conf /etc/named.conf.bak ``` for rebuild the file ``` /usr/local/cpanel/scripts/rebuilddnsconfig ``` for restart the named service ``` /etc/init.d/named restart ``` ref: <https://www.web24.com.au/tutorials/named-conf-fix-corrupted-named-conf-cpanel>
38,574,785
I need to extract values from the below JSON response I am receiving from a web service response. ``` {"ns4:SearchSA_PartyReturn": { "xmlns:ns1": "urn:cs-base", "xsi:type": "ns4:SearchSA_PartyReturn", "ns4:object": { "xmlns:ns2": "urn:co-base", "recordCount": 3, "xmlns:ns0": "urn:cs-rest", "ns3:item": [ { "ns3:SA_Party": { "ns3:partyName": "Akorn New Jersey Inc", "ns3:partyStatus": "ACTIVE", "ns2:rowidObject": 20011, "ns3:SAC_Address": { "ns3:item": { "ns3:city": "QUE", "ns3:state": "N", "ns2:rowidObject": 20011, "ns3:postalCode": -4, "ns3:addressType": "P", "ns3:country": "US", "ns3:addressLine": "RD" }, "pageSize": 10, "firstRecord": 1, "searchToken": "SVR1.TD3V" }, "ns3:partyType": "Pharma", "ns3:SAC_Person": { "ns3:item": { "ns3:firstName": "DO", "ns2:rowidObject": 11, "ns3:lastName": "MA", "ns3:middleName": "R", "ns3:personType": 2 }, "pageSize": 10, "firstRecord": 1, "searchToken": "SVR1.TD3U" } }, "ns3:changeSummary": { "logging": false, "xmlns:sdo": "commonj.sdo" } }, { "ns3:SA_Party": { "ns3:partyName": "Akorn New Jersey Inc", "ns3:partyStatus": "ACTIVE", "ns2:rowidObject": 20047, "ns3:SAC_Address": { "ns3:item": { "ns3:city": "SC", "ns3:state": "N", "ns2:rowidObject": 20047, "ns3:postalCode": 12, "ns3:addressType": "B", "ns3:country": "US", "ns3:addressLine": "OTT STET" }, "pageSize": 10, "firstRecord": 1, "searchToken": "SVR1.TD3X" }, "ns3:partyType": "Pharma", "ns3:SAC_Person": { "ns3:item": { "ns3:firstName": "GE", "ns2:rowidObject": 47, "ns3:lastName": "HA", "ns3:middleName": "B", "ns3:personType": 2 }, "pageSize": 10, "firstRecord": 1, "searchToken": "SVR1.TD3W" } }, "ns3:changeSummary": { "logging": false, "xmlns:sdo": "commonj.sdo" } }, { "ns3:SA_Party": { "ns3:partyName": "Cig Na Ltd", "ns3:partyStatus": "ACTIVE", "ns2:rowidObject": 20040, "ns3:SAC_Address": { "ns3:item": { "ns3:city": "JA", "ns3:state": "NY", "ns2:rowidObject": 20040, "ns3:postalCode": 1, "ns3:addressType": "P", "ns3:country": "US", "ns3:addressLine": "QUR" }, "pageSize": 10, "firstRecord": 1, "searchToken": "SVR1.TD3Z" }, "ns3:partyType": "Insurance", "ns3:SAC_Person": { "ns3:item": { "ns3:firstName": "A", "ns2:rowidObject": 40, "ns3:lastName": "Q", "ns3:personType": 2 }, "pageSize": 10, "firstRecord": 1, "searchToken": "SVR1.TD3Y" } }, "ns3:changeSummary": { "logging": false, "xmlns:sdo": "commonj.sdo" } } ], "pageSize": 10, "firstRecord": 1 }, "xmlns:ns3": "urn:co-ors", "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance", "xmlns:ns4": "urn:cs-ors" }} ``` Can anyone help me with a javascript/jquery to extract `ns3:SA_Party` with its corresponding children `ns3:SAC_Address` and `ns3:SAC_Person`. (SA\_Party is the parent with two children SAC\_Address and SAC\_Person). I need the underlying attribute, too.
2016/07/25
[ "https://Stackoverflow.com/questions/38574785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6116467/" ]
It looks like you're trying to get `document.getElementById("setting").value` but the actual ID is "Setting" as per ``` <select name="Setting"> <option value="Office">Office</option> <option value="HOPD">HOPD</option> </select> ``` Try changing the getElementById to `document.getElementById("Setting").value` EDIT ==== Ok, I made a JSFiddle for you: <https://jsfiddle.net/dktoxtne/1/> Let me know if that works! I don't remember all I changed, but I do remember you need to change the `name="Setting"` to `id="Setting"` and a few other things.
``` function settingValue(){ //settingValue=document.getElementById("setting").value; var e = document.getElementById("Setting"); var settingValue = e.options[e.selectedIndex].value; document.getElementById("result").value=medicarePaymentCal(settingValue); } ```
58,567,334
I'm trying to turn a Huffman tree and a stream of bits into a list of characters plus a boolean indicating whether or not the output consumed all the input bits. Here's an example: ``` decode xyz_code [True,False,True,True,True,False,False,True] = ("yzyx",False) ``` Here's what I have so far, but it doesn't work. What's going wrong? Help! ``` data BTree a = Leaf a | Fork (BTree a) (BTree a) deriving (Show, Eq) decode :: BTree a -> [Bool] -> ([a], Bool) decode _ [] = ([],True) decode (Leaf v) [bs] = ([v], bs) decode (Fork left right) (b:bs) | b = decode right bs | otherwise = decode left bs ```
2019/10/26
[ "https://Stackoverflow.com/questions/58567334", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12276493/" ]
I think no, Authorization server is out of their roadmap. Starting from november the 13th every class in spring security which worked with Authorization server features become deprecated. [Spring Security OAuth 2.0 Roadmap Update](https://spring.io/blog/2019/11/14/spring-security-oauth-2-0-roadmap-update#no-authorization-server-support) (here the answer on you question)
@mhrsalehi, please checkout my repo. I added an implementation of old OAuth2 Authorization server for webflux. Currently only support `/oauth/token` if you want support for any other endpoints please submit a ticket or PR. Github: [spring-reactive-authorization-server](https://github.com/VuDo98/spring-reactive-authorization-server)
74,370
I have an Ubuntu 6.06 server that needs to be replaced by an Ubuntu 9.04 server clean setup, I already copied the entire samba file server directory to the new 9.04 server using rsync. I need to know how to migrate the existing user accounts (machine accounts) to the new server so as when I physically transfer the connections everything will be ok and I don't have to manually enter `smbpasswd -a <user>` on the new server. ``` passdb backend = tdbsam ``` network workstations accessing the share are either vista or xp.
2009/10/14
[ "https://serverfault.com/questions/74370", "https://serverfault.com", "https://serverfault.com/users/-1/" ]
``` passdb backend = tdbsam ``` means you have your samba accounts in a `passdb.tdb` file in `SAMBA_DIR/private`. As long as you copy it with rsync you are fine. There are two caveats: * Unix users: a samba user has to be a unix user as well, so you have to copy all files @churnd told you; * timing: machine account are updated every time, so you need a super fresh rsync. In a perfect world, you should stop old server, rsync, start new server.
You'll need to copy /etc/passwd, /etc/shadow, /etc/group, /etc/samba/smbusers, and /etc/samba/smbpasswd. [This site](http://www.cyberciti.biz/faq/howto-move-migrate-user-accounts-old-to-new-server/) shows you how to do the first 3, but I've done the last two and it worked fine.
71,435,759
I am trying to add a new recipe to install new packages in my image. I need the next packages libnfc5 libnfc-bin libnfc-examples, I have found these packages in this page: <http://ftp.de.debian.org/debian/pool/main/libn/libnfc/>, so I am using the next commands to install the packages: * devtool add libnfc5 <http://ftp.de.debian.org/debian/pool/main/libn/libnfc/libnfc5_1.7.1-4+b1_armhf.deb> * devtool build libnfc5 * devtool deploy-target libnfc5 root@my-ip I am not sure if is necessary modify the .bb file generate: libnfc5\_1.7.1-4+b1.bb, and one time that I execute deploy-target which is necessary to do in my device, Do I need to install the library?
2022/03/11
[ "https://Stackoverflow.com/questions/71435759", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18352597/" ]
`PIVOT` relational operator is an option: Sample data: ``` SELECT * INTO Company FROM (VALUES (1, 'Frodo B (manager), Gandalf G (director), Batman C (cleaner)'), (2, 'John Doe (secretary), Mark Jacobs (manager), Lilly Hopes (director), Rihanna Williams (cleaner), Maddy James (supervisor), Merry Poppins (HR)'), (3, 'Rick Ross (cleaner)'), (4, 'Orlando Bloom (manager), Keira Knightly (secretary)') ) d (Id, Team) ``` Statement: ``` SELECT * FROM ( SELECT c.Id, LTRIM(s.[value]) AS [Name], p.Position FROM Company c CROSS APPLY STRING_SPLIT(c.Team, ',') s JOIN (VALUES ('cleaner'), ('director'), ('manager'), ('supervisor'), ('secretary'), ('HR'), ('owner') ) p (Position) ON CHARINDEX(p.Position, s.[value]) > 0 ) t PIVOT ( MAX(Name) FOR Position IN ([cleaner], [director], [manager], [supervisor], [secretary], [HR], [owner]) ) p ``` Result: | Id | cleaner | director | manager | supervisor | secretary | HR | owner | | --- | --- | --- | --- | --- | --- | --- | --- | | 1 | Batman C (cleaner) | Gandalf G (director) | Frodo B (manager) | | | | | | 2 | Rihanna Williams (cleaner) | Lilly Hopes (director) | Mark Jacobs (manager) | Maddy James (supervisor) | John Doe (secretary) | Merry Poppins (HR) | | | 3 | Rick Ross (cleaner) | | | | | | | | 4 | | | Orlando Bloom (manager) | | Keira Knightly (secretary) | | | For SQL Server versions before 2016 (but with XML support), you may split the stored text using well-known XML technique: ``` SELECT * FROM ( SELECT c.Id, LTRIM(s.[value].value('.', 'varchar(1000)')) AS [Name], p.Position FROM ( SELECT *, CAST('<x>' + REPLACE(Team, ',', '</x><x>') + '</x>' AS XML) AS XmlTeam FROM Company ) c CROSS APPLY c.XmlTeam.nodes('./x') s ([value]) JOIN (VALUES ('cleaner'), ('director'), ('manager'), ('supervisor'), ('secretary'), ('HR'), ('owner') ) p (Position) ON CHARINDEX(p.Position, s.[value].value('.', 'varchar(1000)')) > 0 ) t PIVOT ( MAX(Name) FOR Position IN ([cleaner], [director], [manager], [supervisor], [secretary], [HR], [owner]) ) p ```
Recursion is another (knowing that it is limited to 7 iterations): ``` with MyTable as ( select * from (values (1, 'Frodo B (manager), Gandalf G (director), Batman C (cleaner)') ,(2, 'John Doe (secretary), Mark Jacobs(manager), Lilly Hopes(director), Rihanna Williams (cleaner), Maddy James (supervisor), Merry Poppins (HR)') ,(3, 'Rick Ross (cleaner)') ,(4,'Orlando Bloom (manager), Keira Knightly (secretary)') ) T (Id, Team) ), RCTE as ( -- Find closing bracket positions select Id, FromPos=1 , BctPos=charindex(')',Team), Team from MyTable union all select R.Id, FromPos=R.BctPos+2, BctPos=charindex(')', M.Team, R.BctPos+1), M.Team from MyTable M inner join RCTE R on R.Id=M.Id where charindex(')',M.Team,R.BctPos+1)>0 ), Parsed as ( select Id, Team, Member=SubString(Team,FromPos,BctPos-FromPos+1) from RCTE) select Id , director=min(case when Member like '%(director)' then left(Member,len(Member)- charindex('(',Member)-1) end) , cleaner=min(case when Member like '%(cleaner)' then left(Member,len(Member)- charindex('(',Member)-1) end) , manager=min(case when Member like '%(manager)' then left(Member,len(Member)- charindex('(',Member)-1) end) , supervisor=min(case when Member like '%(supervisor)' then left(Member,len(Member)- charindex('(',Member)-1) end) , secretary=min(case when Member like '%(secretary)' then left(Member,len(Member)- charindex('(',Member)-1) end) , owner=min(case when Member like '%(owner)' then left(Member,len(Member)- charindex('(',Member)-1) end) from Parsed group by id order by id ``` I assumed that they are all well formed (brackets are correctly opened closed; and blanks are used consistently, etc.
66,986,874
Have some data stored in different directory paths in databricks file system. Need to rename some folders. Is it possible to rename folders in DBFS? If so, what's the command?
2021/04/07
[ "https://Stackoverflow.com/questions/66986874", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8500105/" ]
You can use `mv` with `%fs` magic, or `dbutils.fs` to do this. This command is used for renaming and/or moving files and directories `%fs mv -r /path/to/folder /path/to/new_folder_name` the `-r` is to do recursive move with directories. It's documented in the [dbutils](https://docs.databricks.com/_static/notebooks/dbutils.html). There is also more info [here](https://docs.databricks.com/data/databricks-file-system.html#dbfs-and-local-driver-node-paths).
Use this. Just replace the path with your actual path. ``` old_name = r"dbfs:/FileStore/tables/PM/TC/ROBERTA" new_name = r"dbfs:/FileStore/tables/PM/TC/BERT" dbutils.fs.mv(old_name, new_name, True) ```
73,695,925
I'm going nuts trying to connnect in Selenium4 to Chrome instance on a localhost. I invoked chrome from bash using ``` $ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=6666 --user-data-dir=/Users/h/Desktop/MY/chrome-profile ``` and next i tried to connect from Selenium4 ``` from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service as ChromeService from webdriver_manager.chrome import ChromeDriverManager # opt = Options() # opt.add_experimental_option("debuggerAddress", "localhost:6666") # opt.add_argument("debuggerAddress", "localhost:6666") # opt.add_debuggerAddress("localhost:6666") # opt.add_debugger_address("localhost:6666") # web_driver = webdriver.Chrome(options=opt) # chrome_options = Options() # chrome_options.add_experimental_option("debuggerAddress", "localhost:6666") # driver = webdriver.Chrome(chrome_options=chrome_options) # driver.get('https://www.google.com') path = '/Users/h/Desktop/MY/webdrivers/chrome/105.0.5195.52/chromedriver' # driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=opt) # service = Service(executable_path=ChromeDriverManager().install()) # driver = webdriver.Chrome(service=service, options=chrome_options) # driver.get('https://www.example.com/') service = ChromeService(executable_path=path, port=6666) # i tried with local path and ChromeDriverManager driver = webdriver.Chrome(service=service) driver.get('https://www.example.com/') ``` i think i tried all possible options: * prepending http:// to localhost throws an error, * using chrome\_options=chrome\_options throws a deprecation warning, pointing i should use >options=<, and seems to have no effect on the browser in localhost, * trying to launch webdriver from a local file, and currently suggested ChromeDriverManager. Both work. Until i want to specify options. i also looped through the example i found on ~20 websites, incl. github bug reports - where people claim their code worked until VSCode upgraded. I guess my question is - is there anything wrong with how i try to pass the chrome options, or did i actually encounter a bug ? ====== Edit: that is a full error trace: ``` --------------------------------------------------------------------------- WebDriverException Traceback (most recent call last) Input In [10], in <cell line: 29>() 22 # driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=opt) 23 24 # service = Service(executable_path=ChromeDriverManager().install()) 25 # driver = webdriver.Chrome(service=service, options=chrome_options) 26 # driver.get('https://www.wp.pl/') 28 service = ChromeService(executable_path=path, port=6666) #at this line you can use your ChromeDriverManager ---> 29 driver = webdriver.Chrome(service=service) 30 driver.get('https://www.example.com/') File ~/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py:69, in WebDriver.__init__(self, executable_path, port, options, service_args, desired_capabilities, service_log_path, chrome_options, service, keep_alive) 66 if not service: 67 service = Service(executable_path, port, service_args, service_log_path) ---> 69 super().__init__(DesiredCapabilities.CHROME['browserName'], "goog", 70 port, options, 71 service_args, desired_capabilities, 72 service_log_path, service, keep_alive) File ~/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py:92, in ChromiumDriver.__init__(self, browser_name, vendor_prefix, port, options, service_args, desired_capabilities, service_log_path, service, keep_alive) 89 self.service.start() 91 try: ---> 92 super().__init__( 93 command_executor=ChromiumRemoteConnection( 94 remote_server_addr=self.service.service_url, 95 browser_name=browser_name, vendor_prefix=vendor_prefix, 96 keep_alive=keep_alive, ignore_proxy=_ignore_proxy), 97 options=options) 98 except Exception: 99 self.quit() File ~/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:270, in WebDriver.__init__(self, command_executor, desired_capabilities, browser_profile, proxy, keep_alive, file_detector, options) 268 self._authenticator_id = None 269 self.start_client() --> 270 self.start_session(capabilities, browser_profile) File ~/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:363, in WebDriver.start_session(self, capabilities, browser_profile) 361 w3c_caps = _make_w3c_caps(capabilities) 362 parameters = {"capabilities": w3c_caps} --> 363 response = self.execute(Command.NEW_SESSION, parameters) 364 if 'sessionId' not in response: 365 response = response['value'] File ~/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py:428, in WebDriver.execute(self, driver_command, params) 426 response = self.command_executor.execute(driver_command, params) 427 if response: --> 428 self.error_handler.check_response(response) 429 response['value'] = self._unwrap_value( 430 response.get('value', None)) 431 return response File ~/opt/anaconda3/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py:207, in ErrorHandler.check_response(self, response) 205 value = response['value'] 206 if isinstance(value, str): --> 207 raise exception_class(value) 208 if message == "" and 'message' in value: 209 message = value['message'] WebDriverException: Message: ```
2022/09/12
[ "https://Stackoverflow.com/questions/73695925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18995273/" ]
You can use the format below: ``` PARSE_DATETIME('%m/%d/%Y %l:%M %p', "7/13/2022 9:46 AM") ``` The output: [![parse_datetime_output](https://i.stack.imgur.com/i07A9.png)](https://i.stack.imgur.com/i07A9.png)
Use `PARSE_DATETIME("%m/%d/%Y %l:%M %p", datetime_closed)` to get datetime or `DATE(PARSE_DATETIME("%m/%d/%Y %l:%M %p", datetime_closed))` to get date
72,506,798
Hello there I try to align some text in a container to the left but it won't work even when there is free space. As you can see there is some free space directly next to the image which isn't used for no reason. Right here I show you a picture and also the style. Thanks in advance if anyone can help. ![enter image description here](https://i.stack.imgur.com/DTEG9.png) ```css .text-wrapper-overview { position: inherit; left: 100px; width: 65%; } .user-name { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: large; font-weight: bold; } .last-message { position: inherit; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 5px; font-size: small; } .timestamp-overview { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: small; font-weight: normal; } ``` ```html <div id={this.name} className="chat-overview" onClick={()=>this.renderChat()}> <img className="round-image" src="https://i.pravatar.cc/200"></img> <div className="text-wrapper-overview"> <p className="user-name">{this.name}</p> <p className="last-message">{this.lastMessage.text}</p> <p className="timestamp-overview">{this.lastDate}</p> </div> <div className="notification">10+</div> </div> ```
2022/06/05
[ "https://Stackoverflow.com/questions/72506798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17032453/" ]
You could use interfaces with default implementations which were introduced in C# 8. Then you could derive from these interfaces. Here's an example of how you could you provide default implementations for the `MoveForward()` and `StartBroadcast()` methods: ```cs public interface IVehicle { void MoveForward() { // your code } void PerformUniqueAbility(); } ``` ```cs public interface IRadioSignalBroadcaster { void StartBroadcast() { // your code } void PerformUniqueBroadcastingAbility(); } ```
You can't inherit more than 1 class but you can inherit more than one interface. Is this what you are looking for? ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp3 { internal class Program { static void Main(string[] args) { IVehicle vehicle = new Vehicle(); IRadioBroadcaster broadcaster = new RadioBroadcaster(); vehicle.MoveForward(); vehicle.PerformUniqueAbility(); broadcaster.StartBroadcast(); broadcaster.PerformUniqueAbility(); } } public interface IUniqueAbillity { void PerformUniqueAbility(); } public interface IVehicle: IUniqueAbillity { void MoveForward(); } public interface IRadioBroadcaster : IUniqueAbillity { void StartBroadcast(); } public abstract class RealWorldObject : IVehicle, IRadioBroadcaster { public void MoveForward() { // Move forward } public abstract void PerformUniqueAbility(); public void StartBroadcast() { // Start broadcast } } public class Vehicle : RealWorldObject, IVehicle { public override void PerformUniqueAbility() { // Do something } } public class RadioBroadcaster : RealWorldObject, IRadioBroadcaster { public override void PerformUniqueAbility() { // Do something } } } ```
72,506,798
Hello there I try to align some text in a container to the left but it won't work even when there is free space. As you can see there is some free space directly next to the image which isn't used for no reason. Right here I show you a picture and also the style. Thanks in advance if anyone can help. ![enter image description here](https://i.stack.imgur.com/DTEG9.png) ```css .text-wrapper-overview { position: inherit; left: 100px; width: 65%; } .user-name { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: large; font-weight: bold; } .last-message { position: inherit; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 5px; font-size: small; } .timestamp-overview { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: small; font-weight: normal; } ``` ```html <div id={this.name} className="chat-overview" onClick={()=>this.renderChat()}> <img className="round-image" src="https://i.pravatar.cc/200"></img> <div className="text-wrapper-overview"> <p className="user-name">{this.name}</p> <p className="last-message">{this.lastMessage.text}</p> <p className="timestamp-overview">{this.lastDate}</p> </div> <div className="notification">10+</div> </div> ```
2022/06/05
[ "https://Stackoverflow.com/questions/72506798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17032453/" ]
You can't inherit more than 1 class but you can inherit more than one interface. Is this what you are looking for? ``` using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp3 { internal class Program { static void Main(string[] args) { IVehicle vehicle = new Vehicle(); IRadioBroadcaster broadcaster = new RadioBroadcaster(); vehicle.MoveForward(); vehicle.PerformUniqueAbility(); broadcaster.StartBroadcast(); broadcaster.PerformUniqueAbility(); } } public interface IUniqueAbillity { void PerformUniqueAbility(); } public interface IVehicle: IUniqueAbillity { void MoveForward(); } public interface IRadioBroadcaster : IUniqueAbillity { void StartBroadcast(); } public abstract class RealWorldObject : IVehicle, IRadioBroadcaster { public void MoveForward() { // Move forward } public abstract void PerformUniqueAbility(); public void StartBroadcast() { // Start broadcast } } public class Vehicle : RealWorldObject, IVehicle { public override void PerformUniqueAbility() { // Do something } } public class RadioBroadcaster : RealWorldObject, IRadioBroadcaster { public override void PerformUniqueAbility() { // Do something } } } ```
I think Jonas gave you the best answer that you can use default `interface` implementations. However I keep my post, because it gives information, how to achieve same effect, using technology without this language feature. ```cs public abstract class Example : IExample { private readonly IVehicle vehicle; private readonly IRadioSignalBroadcaster; public Example(IVehicle vehicle, IRadioSignalBroadcaster radioSignalBroadcaster) { this.vehicle = vehicle; this.radioSignalBroadcaster = radioSignalBroadcaster; } public void MoveForward() => vehicle.MoveForward(); public void StartBroadcast() => radioSignalBroadcaster.StartBroadcast(); public void PerformUniqueAbility() => vehicle.PerformUniqueAbility(); public void PerformUniqueBroadcastingAbility() => radioSignalBroadcaster.PerformUniqueBroadcastingAbility(); } ``` ```cs public interface IExample : IVehicle, IRadioSignalBroadcaster { } ``` ```cs public interface IVehicle { void MoveForward(); void PerformUniqueAbility(); } ``` ```cs public interface IRadioSignalBroadcaster { void StartBroadcast(); void PerformUniqueBroadcastingAbility(); } ``` ```cs public abstract class Vehicle : IVehicle { public void MoveForward() { // ... } public abstract void PerformUniqueAbility(); } ``` ```cs public interface ICustomVehicle : IVehicle { } ``` ```cs public class CustomVehicle : Vehicle, ICustomVehicle { public void PerformUniqueAbility() { // ... } } ``` ```cs public abstract class RadioSignalBroadcaster : IRadioSignalBroadcaster { public void StartBroadcast() { // ... } public abstract void PerformUniqueBroadcastingAbility(); } ``` ```cs public interface ICustomRadioSignalBroadcaster : IRadioSignalBroadcaster { } ``` ```cs public class CustomRadioSignalBroadcaster : RadioSignalBroadcaster, ICustomRadioSignalBroadcaster { public void PerformUniqueBroadcastingAbility() { // ... } } ``` You will create another classes like that: ```cs public class CustomExample : Example, ICustomExample { public CustomExample(ICustomVehicle customVehicle, ICustomRadioSignalBroadcaster customRadioSignalBroadcaster) : base(customVehicle, customRadioSignalBroadcaster) { } } ``` ```cs public interface ICustomExample : IExample { } ```
72,506,798
Hello there I try to align some text in a container to the left but it won't work even when there is free space. As you can see there is some free space directly next to the image which isn't used for no reason. Right here I show you a picture and also the style. Thanks in advance if anyone can help. ![enter image description here](https://i.stack.imgur.com/DTEG9.png) ```css .text-wrapper-overview { position: inherit; left: 100px; width: 65%; } .user-name { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: large; font-weight: bold; } .last-message { position: inherit; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 5px; font-size: small; } .timestamp-overview { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: small; font-weight: normal; } ``` ```html <div id={this.name} className="chat-overview" onClick={()=>this.renderChat()}> <img className="round-image" src="https://i.pravatar.cc/200"></img> <div className="text-wrapper-overview"> <p className="user-name">{this.name}</p> <p className="last-message">{this.lastMessage.text}</p> <p className="timestamp-overview">{this.lastDate}</p> </div> <div className="notification">10+</div> </div> ```
2022/06/05
[ "https://Stackoverflow.com/questions/72506798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17032453/" ]
You could use interfaces with default implementations which were introduced in C# 8. Then you could derive from these interfaces. Here's an example of how you could you provide default implementations for the `MoveForward()` and `StartBroadcast()` methods: ```cs public interface IVehicle { void MoveForward() { // your code } void PerformUniqueAbility(); } ``` ```cs public interface IRadioSignalBroadcaster { void StartBroadcast() { // your code } void PerformUniqueBroadcastingAbility(); } ```
I think Jonas gave you the best answer that you can use default `interface` implementations. However I keep my post, because it gives information, how to achieve same effect, using technology without this language feature. ```cs public abstract class Example : IExample { private readonly IVehicle vehicle; private readonly IRadioSignalBroadcaster; public Example(IVehicle vehicle, IRadioSignalBroadcaster radioSignalBroadcaster) { this.vehicle = vehicle; this.radioSignalBroadcaster = radioSignalBroadcaster; } public void MoveForward() => vehicle.MoveForward(); public void StartBroadcast() => radioSignalBroadcaster.StartBroadcast(); public void PerformUniqueAbility() => vehicle.PerformUniqueAbility(); public void PerformUniqueBroadcastingAbility() => radioSignalBroadcaster.PerformUniqueBroadcastingAbility(); } ``` ```cs public interface IExample : IVehicle, IRadioSignalBroadcaster { } ``` ```cs public interface IVehicle { void MoveForward(); void PerformUniqueAbility(); } ``` ```cs public interface IRadioSignalBroadcaster { void StartBroadcast(); void PerformUniqueBroadcastingAbility(); } ``` ```cs public abstract class Vehicle : IVehicle { public void MoveForward() { // ... } public abstract void PerformUniqueAbility(); } ``` ```cs public interface ICustomVehicle : IVehicle { } ``` ```cs public class CustomVehicle : Vehicle, ICustomVehicle { public void PerformUniqueAbility() { // ... } } ``` ```cs public abstract class RadioSignalBroadcaster : IRadioSignalBroadcaster { public void StartBroadcast() { // ... } public abstract void PerformUniqueBroadcastingAbility(); } ``` ```cs public interface ICustomRadioSignalBroadcaster : IRadioSignalBroadcaster { } ``` ```cs public class CustomRadioSignalBroadcaster : RadioSignalBroadcaster, ICustomRadioSignalBroadcaster { public void PerformUniqueBroadcastingAbility() { // ... } } ``` You will create another classes like that: ```cs public class CustomExample : Example, ICustomExample { public CustomExample(ICustomVehicle customVehicle, ICustomRadioSignalBroadcaster customRadioSignalBroadcaster) : base(customVehicle, customRadioSignalBroadcaster) { } } ``` ```cs public interface ICustomExample : IExample { } ```
72,506,798
Hello there I try to align some text in a container to the left but it won't work even when there is free space. As you can see there is some free space directly next to the image which isn't used for no reason. Right here I show you a picture and also the style. Thanks in advance if anyone can help. ![enter image description here](https://i.stack.imgur.com/DTEG9.png) ```css .text-wrapper-overview { position: inherit; left: 100px; width: 65%; } .user-name { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: large; font-weight: bold; } .last-message { position: inherit; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 5px; font-size: small; } .timestamp-overview { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: small; font-weight: normal; } ``` ```html <div id={this.name} className="chat-overview" onClick={()=>this.renderChat()}> <img className="round-image" src="https://i.pravatar.cc/200"></img> <div className="text-wrapper-overview"> <p className="user-name">{this.name}</p> <p className="last-message">{this.lastMessage.text}</p> <p className="timestamp-overview">{this.lastDate}</p> </div> <div className="notification">10+</div> </div> ```
2022/06/05
[ "https://Stackoverflow.com/questions/72506798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17032453/" ]
You could use interfaces with default implementations which were introduced in C# 8. Then you could derive from these interfaces. Here's an example of how you could you provide default implementations for the `MoveForward()` and `StartBroadcast()` methods: ```cs public interface IVehicle { void MoveForward() { // your code } void PerformUniqueAbility(); } ``` ```cs public interface IRadioSignalBroadcaster { void StartBroadcast() { // your code } void PerformUniqueBroadcastingAbility(); } ```
C# classes can only inherit from one base class, but can inherit from any number of interfaces. If your goal is to have multiple base classes being inherited to `MyNewClass`, you could change one of your abstract classes to inherit from the other, for example: ``` public abstract class RadioSignalBroadcast : Vehicle { // Implementation goes here } public class MyNewClass : RadioSignalBroacast { // Implementation goes here } ``` However, as you can see from this approach, it violates Single Responsibility Principle as now `RadioSignalBroadcast` (and now `MyNewClass`) has more than one reason to change (if there's a change to `Vehicle` or `RadioSignalBroadcast` logic). Any change that happens to any of the base classes will propagate to all other classes which inherit from those base classes, which may or may not be what you're after. > > What's the best way to approach these scenarios? > > > That entirely depends on the design of your application. Questions to ask yourself: * Do you require `Vehicle` and `RadioSignalBroadcast` to be abstract classes, or can it easily be an interface? By the looks of your implementation, you have a couple of methods which you want to share to your derived classes so I understand you wanting to keep them as base classes, but it's something to keep in mind. Also check out if the implementation of `MoveForward` and `StartBroadcast` can have a [default interface implementation](https://devblogs.microsoft.com/dotnet/default-implementations-in-interfaces/). * Does `MyNewClass` need to implement both base classes/interfaces? Couldn't two separate classes work out better? Separating out classes like this helps to focus each of the classes to have one single responsibility. * If `MyNewClass` is not truly a `Vehicle` or a `RadioSignalBroadcast` (as per the previous point), can this object be composed by a combination of either of the two, for example: ``` public class MyNewClass : Vehicle { private readonly RadioSignalBroadcast radio; public MyNewClass(RadioSignalBroadcast radio) { this.radio = radio; } public void DoStuff() { // Do Stuff this.radio.PerformUniqueBroadcastingAbility(); } // Implementation goes here } ``` Let me know if you want example or more points to point out.
72,506,798
Hello there I try to align some text in a container to the left but it won't work even when there is free space. As you can see there is some free space directly next to the image which isn't used for no reason. Right here I show you a picture and also the style. Thanks in advance if anyone can help. ![enter image description here](https://i.stack.imgur.com/DTEG9.png) ```css .text-wrapper-overview { position: inherit; left: 100px; width: 65%; } .user-name { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: large; font-weight: bold; } .last-message { position: inherit; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 5px; font-size: small; } .timestamp-overview { position: inherit; margin: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: small; font-weight: normal; } ``` ```html <div id={this.name} className="chat-overview" onClick={()=>this.renderChat()}> <img className="round-image" src="https://i.pravatar.cc/200"></img> <div className="text-wrapper-overview"> <p className="user-name">{this.name}</p> <p className="last-message">{this.lastMessage.text}</p> <p className="timestamp-overview">{this.lastDate}</p> </div> <div className="notification">10+</div> </div> ```
2022/06/05
[ "https://Stackoverflow.com/questions/72506798", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17032453/" ]
C# classes can only inherit from one base class, but can inherit from any number of interfaces. If your goal is to have multiple base classes being inherited to `MyNewClass`, you could change one of your abstract classes to inherit from the other, for example: ``` public abstract class RadioSignalBroadcast : Vehicle { // Implementation goes here } public class MyNewClass : RadioSignalBroacast { // Implementation goes here } ``` However, as you can see from this approach, it violates Single Responsibility Principle as now `RadioSignalBroadcast` (and now `MyNewClass`) has more than one reason to change (if there's a change to `Vehicle` or `RadioSignalBroadcast` logic). Any change that happens to any of the base classes will propagate to all other classes which inherit from those base classes, which may or may not be what you're after. > > What's the best way to approach these scenarios? > > > That entirely depends on the design of your application. Questions to ask yourself: * Do you require `Vehicle` and `RadioSignalBroadcast` to be abstract classes, or can it easily be an interface? By the looks of your implementation, you have a couple of methods which you want to share to your derived classes so I understand you wanting to keep them as base classes, but it's something to keep in mind. Also check out if the implementation of `MoveForward` and `StartBroadcast` can have a [default interface implementation](https://devblogs.microsoft.com/dotnet/default-implementations-in-interfaces/). * Does `MyNewClass` need to implement both base classes/interfaces? Couldn't two separate classes work out better? Separating out classes like this helps to focus each of the classes to have one single responsibility. * If `MyNewClass` is not truly a `Vehicle` or a `RadioSignalBroadcast` (as per the previous point), can this object be composed by a combination of either of the two, for example: ``` public class MyNewClass : Vehicle { private readonly RadioSignalBroadcast radio; public MyNewClass(RadioSignalBroadcast radio) { this.radio = radio; } public void DoStuff() { // Do Stuff this.radio.PerformUniqueBroadcastingAbility(); } // Implementation goes here } ``` Let me know if you want example or more points to point out.
I think Jonas gave you the best answer that you can use default `interface` implementations. However I keep my post, because it gives information, how to achieve same effect, using technology without this language feature. ```cs public abstract class Example : IExample { private readonly IVehicle vehicle; private readonly IRadioSignalBroadcaster; public Example(IVehicle vehicle, IRadioSignalBroadcaster radioSignalBroadcaster) { this.vehicle = vehicle; this.radioSignalBroadcaster = radioSignalBroadcaster; } public void MoveForward() => vehicle.MoveForward(); public void StartBroadcast() => radioSignalBroadcaster.StartBroadcast(); public void PerformUniqueAbility() => vehicle.PerformUniqueAbility(); public void PerformUniqueBroadcastingAbility() => radioSignalBroadcaster.PerformUniqueBroadcastingAbility(); } ``` ```cs public interface IExample : IVehicle, IRadioSignalBroadcaster { } ``` ```cs public interface IVehicle { void MoveForward(); void PerformUniqueAbility(); } ``` ```cs public interface IRadioSignalBroadcaster { void StartBroadcast(); void PerformUniqueBroadcastingAbility(); } ``` ```cs public abstract class Vehicle : IVehicle { public void MoveForward() { // ... } public abstract void PerformUniqueAbility(); } ``` ```cs public interface ICustomVehicle : IVehicle { } ``` ```cs public class CustomVehicle : Vehicle, ICustomVehicle { public void PerformUniqueAbility() { // ... } } ``` ```cs public abstract class RadioSignalBroadcaster : IRadioSignalBroadcaster { public void StartBroadcast() { // ... } public abstract void PerformUniqueBroadcastingAbility(); } ``` ```cs public interface ICustomRadioSignalBroadcaster : IRadioSignalBroadcaster { } ``` ```cs public class CustomRadioSignalBroadcaster : RadioSignalBroadcaster, ICustomRadioSignalBroadcaster { public void PerformUniqueBroadcastingAbility() { // ... } } ``` You will create another classes like that: ```cs public class CustomExample : Example, ICustomExample { public CustomExample(ICustomVehicle customVehicle, ICustomRadioSignalBroadcaster customRadioSignalBroadcaster) : base(customVehicle, customRadioSignalBroadcaster) { } } ``` ```cs public interface ICustomExample : IExample { } ```
3,051,606
I need to find minimum point of hanging rope with two known points $p\_1, p\_2$ (start and end point of the rope) and known rope length. I want to model all rope shapes with different length and start and end point. Do I have to use numerical methods? Does it have any closed form solution? Known $\to L,(x\_1,y\_1), (x\_2,y\_2)$ then $a=$? I use a general catenary equation like below: $$ f(x)= a\cosh\left(\frac {x-b}a\right)+c\\ L= a\sinh\left(\frac{x\_2}{a}\right)-a\sinh\left(\frac{x\_1}{a}\right) $$
2018/12/24
[ "https://math.stackexchange.com/questions/3051606", "https://math.stackexchange.com", "https://math.stackexchange.com/users/629130/" ]
Starting from @Cesareo answer, considering $$L^2-v^2 = 4a^2\sinh^2\left(\frac{h}{2a}\right)$$ let $x=\frac{h}{2a}$ to make the equation $$\frac{L^2-v^2}{h^2}=\frac{\sinh^2(x) }{x^2}\implies k=\sqrt{\frac{L^2-v^2}{h^2}}=\frac{\sinh(x) }{x}$$ Consider that you look for the zero of $$f(x)=\frac{\sinh(x) }{x}-k$$ It varies very quickly. Then, it would be better to look for the zero of $$g(x)=\log \left(\frac{\sinh (x)}{x}\right)-\log(k)$$ which is much better conditioned. **Edit** To get a starting value $x\_0$ for Newton method, using PadΓ© approximant built at $x=0$ $$\frac{\sinh (x)}x\simeq \frac{7 x^2+60}{60-3 x^2} \implies x\_0=\frac{2 \sqrt{15} \sqrt{k-1}}{\sqrt{3 k+7}}$$ which would be good for $1 \leq k \leq 3$. For larger values of $k$ $$\frac{\sinh (x)}x\simeq \frac{e^x}{2 x}\implies x\_0=-W\_{-1}\left(-\frac{1}{2 k}\right)$$ where appears Lambert function. The table below shows some results $$\left( \begin{array}{ccc} k & x\_0 & x \\ 1.25 & 1.18125 & 1.18273 \\ 1.50 & 1.61515 & 1.62213 \\ 1.75 & 1.91663 & 1.93300 \\ 2.00 & 2.14834 & 2.17732 \\ 2.25 & 2.33550 & 2.37963 \\ 2.50 & 2.49136 & 2.55265 \\ 2.75 & 2.62398 & 2.70395 \\ 3.00 & 2.73861 & 2.83845 \\ & & \\ 3.00 & 2.83315 & 2.83845 \\ 3.25 & 2.95545 & 2.95952 \\ 3.50 & 3.06642 & 3.06962 \\ 3.75 & 3.16801 & 3.17058 \\ 4.00 & 3.26169 & 3.26380 \\ 4.25 & 3.34861 & 3.35037 \\ 4.50 & 3.42970 & 3.43117 \\ 4.75 & 3.50567 & 3.50693 \\ 5.00 & 3.57715 & 3.57823 \end{array} \right)$$ **Edit** Looking at [this question](https://math.stackexchange.com/questions/1068912/solving-sinhax-bx/1068927#1068927) (which I did not remember - problem of age, I guess), I noticed that I was able to generate a quite good estimates building at $x=0$ the $[3,4]$ PadΓ© approximant of $\sinh(x)-k x$. From this, I considered building the $[3,2n]$ PadΓ© approximants which write $$\sinh(x)-k x=x \frac{(1-k)+a^{(n)}\_1 x^2 }{1+\sum\_{m=1}^n b\_m x^{2m} }$$ leading to an approximate solution $$x=\sqrt{\frac {k-1}{a^{(n)}\_1 }}$$ For sure, this was done using a CAS. The longest result able to fit on a single line corresponds to $n=6$ and the result is $$x=\frac{\sqrt{6} \sqrt{(k-1)(105 k^5+60705 k^4+1365738 k^3+5507466 k^2+5665509 k+1414477 )}}{\sqrt{3 k^6+6120 k^5+307017 k^4+2586544 k^3+5952621 k^2+4301640 k+860055}}$$ which seems to be very good even for large values of $k$ (checked up to $k=500$).
Calling $$ x\_2-x\_1 = h\\ y\_2-y\_1 = v $$ we have $$ v = a\cosh\left(\frac{x\_2}{a}\right)-a\cosh\left(\frac{x\_1}{a}\right)\\ L = a\sinh\left(\frac{x\_2}{a}\right)-a\sinh\left(\frac{x\_1}{a}\right) $$ so after some trigonometric transformations we arrive at $$ L^2-v^2 = 4a^2\sinh^2\left(\frac{x\_2-x\_1}{2a}\right) $$ so we have finally $$ L^2-v^2 = 4a^2\sinh^2\left(\frac{h}{2a}\right) $$ with this last equation we can determine the $a = a\_0$ value using an iterative procedure. NOTE Calling now $$ y(x) = y\_0 + a\_0\cosh\left(\frac{x-x\_0}{a\_0}\right) $$ such that $$ y(x\_1) = y\_1\\ y(x\_2) = y\_2 $$ The minimum point is obtained by solving for $x$ $$ y'(x) = 0 $$ so if $x\_1 \le x\_0 \le x\_2$ follows $$ \min y(x) = y\_0 + a\_0 $$ otherwise $$ \min y(x) = \min(y\_1, y\_2) $$ Now, regarding the iterative process we have $$ \frac{L^2-v^2}{4a^2} = \sinh^2\left(\frac{h}{2a}\right) $$ or $$ C\_0^2\lambda^2=\sinh^2\lambda,\ \ \lambda = \frac{h}{2a},\ \ C\_0 = \frac{\sqrt{L^2-v^2}}{h} $$ or $$ C\_0 \lambda = \sinh(\lambda) $$ which should be solved numerically.
28,078,756
So I've typed a command (pacman -S perl-) and I hit tab and see that there are a whole bunch of completions (about 40), and I realize that I want to run every single completion (so I don't accidentally install from CPAN what is already a builtin). How do I run all completions of a command? BONUS: How do I run more than one and less than all of the commands (without typing them in individually)? Example situation (the actual situation): ``` XXXXXXXXXXXXXXXXX ❯❯❯ pacman -S perl-<Tab> ⏎ -- packages -- perl perl-IPC-Run3 perl-ack perl-libwww perl-Archive-Zip perl-Locale-Gettext perl-Authen-SASL perl-LWP-MediaTypes perl-Benchmark-Timer perl-LWP-Protocol-https perl-Capture-Tiny perl-MailTools perl-common-sense perl-MIME-tools perl-Compress-Bzip2 perl-Mozilla-CA perl-Convert-BinHex perl-Net-DNS perl-Crypt-SSLeay perl-Net-HTTP perl-DBI perl-Net-IP perl-Digest-HMAC perl-Net-SMTP-SSL perl-Encode-Locale perl-Net-SSLeay perl-Error perl-Path-Class perl-Exporter-Lite perl-Probe-Perl perl-ExtUtils-Depends perl-Regexp-Common perl-ExtUtils-PkgConfig perl-Socket6 perl-File-Copy-Recursive perl-Sys-CPU perl-File-Listing perl-TermReadKey perl-File-Next perl-Test-Pod perl-File-Which perl-Test-Script perl-Getopt-Tabular perl-TimeDate perl-HTML-Parser perl-Try-Tiny perl-HTML-Tagset perl-URI perl-HTTP-Cookies perl-WWW-RobotRules perl-HTTP-Daemon perl-XML-LibXML perl-HTTP-Date perl-XML-NamespaceSupport perl-HTTP-Message perl-XML-Parser perl-HTTP-Negotiate perl-XML-SAX perl-IO-HTML perl-XML-SAX-Base perl-IO-Socket-INET6 perl-XML-Simple perl-IO-Socket-SSL perl-YAML perl-IO-stringy perl-YAML-Syck ```
2015/01/21
[ "https://Stackoverflow.com/questions/28078756", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2851917/" ]
Here is my own solution to deal with, * To apply matching for completion results. * To insert all the completion matches into the command line. * To activate menu selection and select the completion more than one. --- **To apply matching for completion results**, it could be done with the [`_match`](http://zsh.sourceforge.net/Doc/Release/Completion-System.html#index-_005fmatch). Here is an example `~/.zshrc`: ```sh # below is same as the zsh default effect # zstyle ':completion:*::::' completer _complete _ignored zstyle ':completion:*::::' completer _complete _match _ignored # I don't like expand-or-complete to <Tab>, so I moved it to <C-x><Tab> bindkey '^I' complete-word bindkey '^X^I' expand-or-complete ``` Now, it could be ok to use `*`s to get the effects like this: ``` % ls m*e* ;# I have some local files that matches the glob. main.epro mem.c mem.pro modentry.c module.o modules.stamp makepro.awk mem.epro mem.syms module.c module.pro math.epro mem.o mkmakemod.sh module.epro module.syms % git m*e*<Tab> ;# This prompts completions rather than expands the local files ;# like this: % git merge merge -- join two or more development histories together merge-base -- find as good a common ancestor as possible for a merge merge-file -- run a three-way file merge merge-index -- run merge for files needing merging merge-one-file -- standard helper-program to use with git merge-index merge-tree -- show three-way merge without touching index mergetool -- run merge conflict resolution tools to resolve merge conflicts mktree -- build tree-object from git ls-tree formatted text m*e* ``` **To insert all the compliteon matches into the command line**, it cloud be done with the [`all-matches`](http://zsh.sourceforge.net/Doc/Release/Completion-System.html#index-_005fall_005fmatches). If you have the below snippets in your `~/.zshrc`: ```sh zle -C all-matches complete-word _my_generic zstyle ':completion:all-matches::::' completer _all_matches zstyle ':completion:all-matches:*' old-matches only _my_generic () { local ZSH_TRACE_GENERIC_WIDGET= # works with "setopt nounset" _generic "$@" } bindkey '^X^a' all-matches ``` typing `Tab` then `Control-x`,`Control-a` inserts the completion matches to the command line. For example: ``` % vim string.<Tab> string.c string.epro string.syms ;# then hit <C-x><C-a> % vim string.c string.epro string.syms ``` **To activate menu selection and select the completion more than one**, it could be done by customizing `menuselect` keymap. ([From `zhmodules(1)` 22.7.3 Menu selection](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#Menu-selection)) ```sh zstyle ':completion:*' menu select=0 zmodload zsh/complist bindkey -M menuselect "^[a" accept-and-hold bindkey -M menuselect '^[^[' vi-insert ``` This activete menu selection for the completion results. During the menu selection is active, typing `M-a` (or `Esc-a`) inserts the selected entry and advances the "menu cursor" to next entry. For example session: ``` % ls sig* sigcount.h signals.h signals.syms signames.o signames1.awk signals.c signals.o signames.c signames.pro signames2.awk signals.epro signals.pro signames.epro signames.syms % vim sig<Tab> ;# this lists the matches sigcount.h signals.epro signals.syms signames.epro signames1.awk signals.c signals.h signames.c signames.syms signames2.awk ;# hitting <Tab> second time, the "menu cursor" appears and ;# the first entry will be activated ;# Note: "[[]]" denotes the "menu cursor" here % vim sigcount.h [[sigcount.h]] signals.epro signals.syms signames.epro signames1.awk signals.c signals.h signames.c signames.syms signames2.awk ;# then hit <M-a>(Esc a) ;# "sigcount.h" is now in the command line and ;# the "menu cursor" points "signals.c" now. % vim sigcout.h signals.c sigcount.h signals.epro signals.syms signames.epro signames1.awk [[signals.c]] signals.h signames.c signames.syms signames2.awk ;# then <Tab><Tab> % vim sigcount.h signals.h sigcount.h signals.epro signals.syms signames.epro signames1.awk signals.c [[signals.h]] signames.c signames.syms signames2.awk ``` So, you could select multiple entries in the completion results to hit `M-a`(or `Esc-a`) as you like. *Below paragraph is not bad to know.* In this expample configration, hitting `Esc``Esc` (we did `bindkey -M menuselect '^[^[' vi-insert` in the above snippets) while the menu selection is active, it allows us to interactively limit the completion result based on input patterns. ``` ;# activate "menu selection" and hit <Esc><Esc>, ;# the "interacitve:" mode will be shown at this point. % vim sig* interactive: sig[] [[sigcount.h]] signals.epro signals.syms signames.epro signames1.awk signals.c signals.h signames.c signames.syms signames2.awk ;# hitting "*awk" while interactive is activetad, ;# it colud limit the completion to "sig*awk" % vim sig*awk interactive: sig[] [[signames1.awk]]signames2.awk sig*awk ``` *I'm not sure I describe correctly, so here is the portion of the zsh doc for the menu selection's "interactive mode".* > > vi-insert > > > this toggles between normal and interactive mode; in interactive mode the keys bound to self-insert and self-insert-unmeta insert into the command line as in normal editing mode but without leaving menu selection; after each character completion is tried again and the list changes to contain only the new matches; the completion widgets make the longest unambiguous string be inserted in the command line and undo and backward-delete-char go back to the previous set of matches > > > -- [`zhmodules(1)` 22.7.3 Menu selection](http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#Menu-selection) > > > --- It could be fine to see also [`edit-command-line`](http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#index-edit_002dcommand_002dline) for dealing with quite big command line buffers. --- Now on my debian system, I can get the below effect: ``` # apt-get install perl-*<Tab><C-x><C-a><C-w> ;# ⇓ # apt-get install perl-base perl-byacc perl-cross-debian perl-debug perl-depends perl-doc perl-doc-html perl-modules perl-stacktrace perl-tk ```
I've found a solution to my problem, and it gets the job done, but it's not the kind of solution that I want. I selected the completion text on my screen (I'm using mintty) and copied it into my editor. I then reformatted it like so: ``` perl perl-IPC-Run3 \ perl-ack perl-libwww \ perl-Archive-Zip perl-Locale-Gettext \ perl-Authen-SASL perl-LWP-MediaTypes \ perl-Benchmark-Timer perl-LWP-Protocol-https \ perl-Capture-Tiny perl-MailTools \ perl-common-sense perl-MIME-tools \ perl-Compress-Bzip2 perl-Mozilla-CA \ perl-Convert-BinHex perl-Net-DNS \ perl-Crypt-SSLeay perl-Net-HTTP \ perl-DBI perl-Net-IP \ perl-Digest-HMAC perl-Net-SMTP-SSL \ perl-Encode-Locale perl-Net-SSLeay \ perl-Error perl-Path-Class \ perl-Exporter-Lite perl-Probe-Perl \ perl-ExtUtils-Depends perl-Regexp-Common \ perl-ExtUtils-PkgConfig perl-Socket6 \ perl-File-Copy-Recursive perl-Sys-CPU \ perl-File-Listing perl-TermReadKey \ perl-File-Next perl-Test-Pod \ perl-File-Which perl-Test-Script \ perl-Getopt-Tabular perl-TimeDate \ perl-HTML-Parser perl-Try-Tiny \ perl-HTML-Tagset perl-URI \ perl-HTTP-Cookies perl-WWW-RobotRules \ perl-HTTP-Daemon perl-XML-LibXML \ perl-HTTP-Date perl-XML-NamespaceSupport \ perl-HTTP-Message perl-XML-Parser \ perl-HTTP-Negotiate perl-XML-SAX \ perl-IO-HTML perl-XML-SAX-Base \ perl-IO-Socket-INET6 perl-XML-Simple \ perl-IO-Socket-SSL perl-YAML \ perl-IO-stringy perl-YAML-Syck ``` And pasted it back into my terminal after `pacman -S`. I've said that this isn't the kind of solution that I want, and so I should mention the sort of solution I'm looking for. I'm looking for something like `pacman -S perl-*` which looks like it might glob up all of the completions or something (It doesn't).
344,872
It hadn’t properly registered yet with Arthur that the council wanted to knock it down" - what's the meaning of register with someone here?
2016/08/26
[ "https://english.stackexchange.com/questions/344872", "https://english.stackexchange.com", "https://english.stackexchange.com/users/193168/" ]
This would be dependent on whether the speaker was referring to the group/entity of the Club or to the location of Sunnyside Country Club. For instance if you removed the words 'Sunnyside' and 'Country' and just left the word Club, a speaker would be more likely to choose the term "to". I was accepted for membership to the club. One might then wonder as to which 'club' you are referring, so it is necessary for the speaker to use the Proper Name. Once the proper name is used however, it also has the interchangeable reference to the location of Sunnyside Country Club. If the speaker was referring to the location they would more commonly use 'at' in this sentence. I was accepted for membership at Sunnyside Country Club. (as in over at their location, where they meet.)
See my comment to JA's answer. Membership prepositions per the [Ngram viewer](https://books.google.com/ngrams/graph?content=for%20membership%20*%2Cfor%20membership%20at%2Cfor%20membership%20into&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t2%3B%2Cfor%20membership%20%2A%3B%2Cc0%3B%2Cs0%3B%3Bfor%20membership%20in%3B%2Cc0%3B%3Bfor%20membership%20of%3B%2Cc0%3B%3Bfor%20membership%20and%3B%2Cc0%3B%3Bfor%20membership%20on%3B%2Cc0%3B%3Bfor%20membership%20is%3B%2Cc0%3B%3Bfor%20membership%20to%3B%2Cc0%3B%3Bfor%20membership%20was%3B%2Cc0%3B%3Bfor%20membership%20are%3B%2Cc0%3B%3Bfor%20membership%20were%3B%2Cc0%3B%3Bfor%20membership%20must%3B%2Cc0%3B.t1%3B%2Cfor%20membership%20at%3B%2Cc0%3B.t1%3B%2Cfor%20membership%20into%3B%2Cc0).
344,872
It hadn’t properly registered yet with Arthur that the council wanted to knock it down" - what's the meaning of register with someone here?
2016/08/26
[ "https://english.stackexchange.com/questions/344872", "https://english.stackexchange.com", "https://english.stackexchange.com/users/193168/" ]
This would be dependent on whether the speaker was referring to the group/entity of the Club or to the location of Sunnyside Country Club. For instance if you removed the words 'Sunnyside' and 'Country' and just left the word Club, a speaker would be more likely to choose the term "to". I was accepted for membership to the club. One might then wonder as to which 'club' you are referring, so it is necessary for the speaker to use the Proper Name. Once the proper name is used however, it also has the interchangeable reference to the location of Sunnyside Country Club. If the speaker was referring to the location they would more commonly use 'at' in this sentence. I was accepted for membership at Sunnyside Country Club. (as in over at their location, where they meet.)
I would suggest this is more of a US v UK English issue. I live in the UK and until about five years ago I had never heard the phrase 'membership to' - it was always 'membership of'. Suddenly, 'membership to' has become ubiquitous. As a Brit, 'membership to' makes no sense to me, but had I grown up in the USA it would doubtless seem normal.
344,872
It hadn’t properly registered yet with Arthur that the council wanted to knock it down" - what's the meaning of register with someone here?
2016/08/26
[ "https://english.stackexchange.com/questions/344872", "https://english.stackexchange.com", "https://english.stackexchange.com/users/193168/" ]
This would be dependent on whether the speaker was referring to the group/entity of the Club or to the location of Sunnyside Country Club. For instance if you removed the words 'Sunnyside' and 'Country' and just left the word Club, a speaker would be more likely to choose the term "to". I was accepted for membership to the club. One might then wonder as to which 'club' you are referring, so it is necessary for the speaker to use the Proper Name. Once the proper name is used however, it also has the interchangeable reference to the location of Sunnyside Country Club. If the speaker was referring to the location they would more commonly use 'at' in this sentence. I was accepted for membership at Sunnyside Country Club. (as in over at their location, where they meet.)
I would suggest this is more of a US v UK English issue. UK dictionaries use 'of' when defining membership. Moreover, I've lived in the UK for over 50 years and until about five years ago I had never heard the phrase 'membership to' - it was always 'membership of'. Suddenly, 'membership to' has become ubiquitous. As a Brit, 'membership to' makes no sense to me, but had I grown up in the USA it would doubtless seem normal. I'd add that I'm an editor by profession, so I have a reasonable grasp of UK English and am very alert to changes in usage.
66,802
And in particular, when you play with 2 players do you deal out all the cards the from the deck? Or is there some undealt part that players draw from during the game? I mean, if you deal them all then you'll just know what's in your opponent's hand? This is going to sound trivial, but actually it's part of this theory/hypothesis I have for this anime/manga series [The Quintessential Quintuplets](https://en.wikipedia.org/wiki/The_Quintessential_Quintuplets), where I think the game Sevens(/Fan Tan/Domino) is symbolic of something in the series (namely something to do with the number 7). My thought is that the card game Sevens (and thus the number 7) is so important that it even leads to a mistake like this. So if this were a mistake, then it's possible that Sevens is really important. Or something. * Actually there have been previous discussions of the game Sevens in this series. See: [The importance of "Sevens"](https://www.reddit.com/r/5ToubunNoHanayome/comments/axlujo/the_importance_of_sevens/) From S02E12 of [The Quintessential Quintuplets](https://en.wikipedia.org/wiki/The_Quintessential_Quintuplets) [![enter image description here](https://i.stack.imgur.com/ys4dD.jpg)](https://i.stack.imgur.com/ys4dD.jpg) The 2 kids pictured above, a young Nakano and the young Fuutarou, are playing * in the English dub version: 'Sevens'. (This is also in the English subtitles for the Japanese version.) * in the original Japanese version: '[Shichi Narabe (7並べ)](https://en.wikipedia.org/wiki/Domino_(card_game)#Japan)', which is what Wikipedia calls a(/the?) Japanese variation of Sevens. In the upper right part of the Wikipedia page, you can see that it says 3-8 players, so I guess that includes the Japanese Sevens. You can even see how the cards are laid out that they really are playing (some variation of) Sevens. Other notes: 1. I've read only a bit of the manga, but I'm pretty sure no other kids were playing with the 2. 2. Additionally, Sevens has been played earlier in the series ([S01E09](https://i.stack.imgur.com/RReaF.jpg) where it's still Shichi Narabe [7並べ], but it's translated as 'Fan Tan' instead of 'Sevens', again by both the English dub and the subtitles for the original Japanese), but there were at least 3 players then.
2022/05/14
[ "https://anime.stackexchange.com/questions/66802", "https://anime.stackexchange.com", "https://anime.stackexchange.com/users/4484/" ]
**Yes, it is possible to play *Shichi Narabe* with only 2 players.** First of all, there is no exact requirement for the number of players, though most sites recommend at least 3 or 4 players: * [English Wikipedia](https://en.wikipedia.org/wiki/Domino_(card_game)): 3-7 (intro body) / 3-8 (infobox) * [Japanese Wikipedia](https://ja.wikipedia.org/wiki/7%E4%B8%A6%E3%81%B9#%E4%BA%BA%E6%95%B0): **theoretically 1-20+**, preferably 4-10 * [Nico Nico Pedia](https://dic.nicovideo.jp/a/%E4%B8%83%E4%B8%A6%E3%81%B9) (Japanese): usually 3-5 * [Magic Door](https://magicdoor.jp/seven-rows/) (Japanese): preferably 3-4, **2 is not recommended** * [Trump Stadium](https://playingcards.jp/game_rules/sevens_rules.html) (Japanese): 3-8 (summary) / 4-7 (online in-game setting) * [Trump & Board Game Rule Book](https://sojudo.net/gamerule/trump/shichinarabe) (Japanese): 3-7 * [Introduction to Trump Games from Small to Large Amount of Players](http://trampgame.blog.jp/archives/5937554.html) (Japanese): 3-8 * [Sites about Killing Time](https://xn--68jza6c6j4c9e9094b.jp/category21/entry427.html) (Japanese): **2 is possible**, usually 3, preferably 4-6 (Emphasis added) Japanese Wikipedia also mentioned an optional rule for games with **2-3 players** called [combo](https://ja.wikipedia.org/wiki/7%E4%B8%A6%E3%81%B9#%E3%82%B3%E3%83%B3%E3%83%9C), so it acknowledged that there is also a variation for 2 players. Thus, while it is still possible to play with only 2 players, there are a few reasons why it is not really recommended. Magic Door mentioned in short that it is because both players know each other cards (because all the cards are dealt). A more thorough discussion on [Yahoo! Chiebukuro](https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q10113941205) (Japanese) explained further that since both players know each other cards, it is [a perfect information game](https://en.wikipedia.org/wiki/Perfect_information) and the winner can already be decided since the beginning, given both players play perfectly. In the end, it becomes a game to play without mistakes instead of a game of strategy.
This game may be played with two players. It becomes less of a strategic battle and more of a time-killer. If you trust Wikipedia as a source, the [Japanese Wikipedia article](https://ja.wikipedia.org/wiki/7%E4%B8%A6%E3%81%B9#%E4%BA%BA%E6%95%B0) says it could even be played by one player. I can imagine playing this game alone requires the highest level of patience, strategy, tactic, and most of all a strong mentality, compared to playing against three or more players.
19,970,356
We can extract distinct value set from a list by using following code ``` List<Person> distinctPeople = allPeople .GroupBy(p => new {p.PersonId, p.FavoriteColor} ) .Select(g => g.First()) .ToList(); ``` Assume person has PersonId, FavoriteColor, age, address, etc..... My requirement is I would like to get a separate list which should contain distinct filter data only such as PersonId, FavoriteColor not others. What is the command for that, Assume I can create a small class which contain PersonId, FavoriteColor only
2013/11/14
[ "https://Stackoverflow.com/questions/19970356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2288789/" ]
I am writing this for other people who might run into the same problem like me in the future. Apparently as Mr. Leonardo as pointed out, HTML e-mails doesn't read the external or even internal css at all because the head part of the template are opted out and only body part are used. Thus the solution is to use table and html attributes with inline css to style the html email template. Thanks
The one way is to use inline css in the code, ``` <div class="pre"><strong>Title,</strong>&nbsp;</div> <div class="pre">&nbsp;</div> <blockquote> <div class="pre">Message part</div> </blockquote> <div class="pre">&nbsp;</div> <div class="pre"><span style="background-color: #800080;">Thanks</span>,<br /> <br /> </div> </div> ``` It works for me..
19,970,356
We can extract distinct value set from a list by using following code ``` List<Person> distinctPeople = allPeople .GroupBy(p => new {p.PersonId, p.FavoriteColor} ) .Select(g => g.First()) .ToList(); ``` Assume person has PersonId, FavoriteColor, age, address, etc..... My requirement is I would like to get a separate list which should contain distinct filter data only such as PersonId, FavoriteColor not others. What is the command for that, Assume I can create a small class which contain PersonId, FavoriteColor only
2013/11/14
[ "https://Stackoverflow.com/questions/19970356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2288789/" ]
As other devs mentioned email clients do not load external css, so you have to inline it. Inlining css manually is poor decision. There are libraries to inline css. One of them is [django-inlinecss](https://github.com/roverdotcom/django-inlinecss "django-inlinecss"). You can keep you code exactly as it is. All you need to do is to install django-inlinecss and to change "deposit\_email.html". I do not know how it looks, because you have not publish it, so I give you example of simple header like email template I used before with success. ```html {% load inlinecss %} {% inlinecss "css/email.css" %} <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Title</title> </head> <body> <table class="body"> <tr> <td class="center" align="center" valign="top"> <center> <table class="row header"> <tr> <td class="center" align="center"> <center> <table class="container"> <tr> <td class="wrapper last"> <table class="twelve columns"> <tr> <td> <img src="your_header_link"> </td> <td class="expander"></td> </tr> </table> </td> </tr> </table> </center> </td> </tr> </table> <table class="container"> <tr> <td> <table class="row"> <tr> <td class="wrapper last"> <table class="twelve columns"> <tr> <td> {% block content %} Email {% endblock %} <td class="expander"></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </center> </td> </tr> </table> </body> </html> {% endinlinecss %} ``` Not much going on here. First line loads inlinecss tag. ``` {% load inlinecss %} ``` Second line starts html, which will be css inlined. It also load email.css which can be any static file in your django project. ``` {% inlinecss "css/email.css" %} ``` After that table based template which has header and body with django block 'content'. Final line is ``` {% endinlinecss %} ``` Which ends inlinecss. As you can see I inline my entire template. I recommend to have one or more parent email templates, which contain template structure and than to use template inheritance for particular emails. In that way you need to specify template and inline your css once. Last but not least. In order for table template to play nicely you need email.css styles. CSS is a bit big, but simple in nature. Add your own styles on top of that. ```css #outlook a { padding: 0; } body { width: 100% !important; min-width: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0; } .ExternalClass { width: 100%; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } #backgroundTable { margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: auto; max-width: 100%; float: left; clear: both; display: block; } center { width: 100%; min-width: 580px; } a img { border: none; } p { margin: 0 0 0 10px; } table { border-spacing: 0; border-collapse: collapse; } td { word-break: normal; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; } table, tr, td { padding: 0; vertical-align: top; text-align: left; } hr { color: #d9d9d9; background-color: #d9d9d9; height: 1px; border: none; } /* Responsive Grid */ table.body { height: 100%; width: 100%; } table.container { width: 580px; margin: 0 auto; text-align: inherit; } table.row { padding: 0px; width: 100%; position: relative; } table.container table.row { display: block; } td.wrapper { padding: 10px 20px 0px 0px; position: relative; } table.columns, table.column { margin: 0 auto; } table.columns td, table.column td { padding: 0px 0px 10px; } table.columns td.sub-columns, table.column td.sub-columns, table.columns td.sub-column, table.column td.sub-column { padding-right: 10px; } td.sub-column, td.sub-columns { min-width: 0px; } table.row td.last, table.container td.last { padding-right: 0px; } table.one { width: 30px; } table.two { width: 80px; } table.three { width: 130px; } table.four { width: 180px; } table.five { width: 230px; } table.six { width: 280px; } table.seven { width: 330px; } table.eight { width: 380px; } table.nine { width: 430px; } table.ten { width: 480px; } table.eleven { width: 530px; } table.twelve { width: 580px; } table.one center { min-width: 30px; } table.two center { min-width: 80px; } table.three center { min-width: 130px; } table.four center { min-width: 180px; } table.five center { min-width: 230px; } table.six center { min-width: 280px; } table.seven center { min-width: 330px; } table.eight center { min-width: 380px; } table.nine center { min-width: 430px; } table.ten center { min-width: 480px; } table.eleven center { min-width: 530px; } table.twelve center { min-width: 580px; } table.one .panel center { min-width: 10px; } table.two .panel center { min-width: 60px; } table.three .panel center { min-width: 110px; } table.four .panel center { min-width: 160px; } table.five .panel center { min-width: 210px; } table.six .panel center { min-width: 260px; } table.seven .panel center { min-width: 310px; } table.eight .panel center { min-width: 360px; } table.nine .panel center { min-width: 410px; } table.ten .panel center { min-width: 460px; } table.eleven .panel center { min-width: 510px; } table.twelve .panel center { min-width: 560px; } .body .columns td.one, .body .column td.one { width: 8.333333%; } .body .columns td.two, .body .column td.two { width: 16.666666%; } .body .columns td.three, .body .column td.three { width: 25%; } .body .columns td.four, .body .column td.four { width: 33.333333%; } .body .columns td.five, .body .column td.five { width: 41.666666%; } .body .columns td.six, .body .column td.six { width: 50%; } .body .columns td.seven, .body .column td.seven { width: 58.333333%; } .body .columns td.eight, .body .column td.eight { width: 66.666666%; } .body .columns td.nine, .body .column td.nine { width: 75%; } .body .columns td.ten, .body .column td.ten { width: 83.333333%; } .body .columns td.eleven, .body .column td.eleven { width: 91.666666%; } .body .columns td.twelve, .body .column td.twelve { width: 100%; } td.offset-by-one { padding-left: 50px; } td.offset-by-two { padding-left: 100px; } td.offset-by-three { padding-left: 150px; } td.offset-by-four { padding-left: 200px; } td.offset-by-five { padding-left: 250px; } td.offset-by-six { padding-left: 300px; } td.offset-by-seven { padding-left: 350px; } td.offset-by-eight { padding-left: 400px; } td.offset-by-nine { padding-left: 450px; } td.offset-by-ten { padding-left: 500px; } td.offset-by-eleven { padding-left: 550px; } td.expander { visibility: hidden; width: 0px; padding: 0 !important; } table.columns .text-pad, table.column .text-pad { padding-left: 10px; padding-right: 10px; } table.columns .left-text-pad, table.columns .text-pad-left, table.column .left-text-pad, table.column .text-pad-left { padding-left: 10px; } table.columns .right-text-pad, table.columns .text-pad-right, table.column .right-text-pad, table.column .text-pad-right { padding-right: 10px; } /* Block Grid */ .block-grid { width: 100%; max-width: 580px; } .block-grid td { display: inline-block; padding: 10px; } .two-up td { width: 270px; } .three-up td { width: 173px; } .four-up td { width: 125px; } .five-up td { width: 96px; } .six-up td { width: 76px; } .seven-up td { width: 62px; } .eight-up td { width: 52px; } /* Alignment & Visibility Classes */ table.center, td.center { text-align: center; } h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { text-align: center; } span.center { display: block; width: 100%; text-align: center; } img.center { margin: 0 auto; float: none; } .show-for-small, .hide-for-desktop { display: none; } /* Typography */ body, table.body, h1, h2, h3, h4, h5, h6, p, td { color: #222222; font-family: "Helvetica", "Arial", sans-serif; font-weight: normal; padding: 0; margin: 0; text-align: left; line-height: 1.3; } h1, h2, h3, h4, h5, h6 { word-break: normal; } h1 { font-size: 40px; } h2 { font-size: 36px; } h3 { font-size: 32px; } h4 { font-size: 28px; } h5 { font-size: 24px; } h6 { font-size: 20px; } body, table.body, p, td { font-size: 14px; line-height: 19px; } p.lead, p.lede, p.leed { font-size: 18px; line-height: 21px; } p { margin-bottom: 10px; } small { font-size: 10px; } a { color: #2ba6cb; text-decoration: none; } a:hover { color: #2795b6 !important; } a:active { color: #2795b6 !important; } a:visited { color: #2ba6cb !important; } h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: #2ba6cb; } h1 a:active, h2 a:active, h3 a:active, h4 a:active, h5 a:active, h6 a:active { color: #2ba6cb !important; } h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited { color: #2ba6cb !important; } /* Panels */ .panel { background: #f2f2f2; border: 1px solid #d9d9d9; padding: 10px !important; } .sub-grid table { width: 100%; } .sub-grid td.sub-columns { padding-bottom: 0; } /* Buttons */ table.button, table.tiny-button, table.small-button, table.medium-button, table.large-button { width: 100%; overflow: hidden; } table.button td, table.tiny-button td, table.small-button td, table.medium-button td, table.large-button td { display: block; width: auto !important; text-align: center; background: #2ba6cb; border: 1px solid #2284a1; color: #ffffff; padding: 8px 0; } table.tiny-button td { padding: 5px 0 4px; } table.small-button td { padding: 8px 0 7px; } table.medium-button td { padding: 12px 0 10px; } table.large-button td { padding: 21px 0 18px; } table.button td a, table.tiny-button td a, table.small-button td a, table.medium-button td a, table.large-button td a { font-weight: bold; text-decoration: none; font-family: Helvetica, Arial, sans-serif; color: #ffffff; font-size: 16px; } table.tiny-button td a { font-size: 12px; font-weight: normal; } table.small-button td a { font-size: 16px; } table.medium-button td a { font-size: 20px; } table.large-button td a { font-size: 24px; } table.button:hover td, table.button:visited td, table.button:active td { background: #2795b6 !important; } table.button:hover td a, table.button:visited td a, table.button:active td a { color: #fff !important; } table.button:hover td, table.tiny-button:hover td, table.small-button:hover td, table.medium-button:hover td, table.large-button:hover td { background: #2795b6 !important; } table.button:hover td a, table.button:active td a, table.button td a:visited, table.tiny-button:hover td a, table.tiny-button:active td a, table.tiny-button td a:visited, table.small-button:hover td a, table.small-button:active td a, table.small-button td a:visited, table.medium-button:hover td a, table.medium-button:active td a, table.medium-button td a:visited, table.large-button:hover td a, table.large-button:active td a, table.large-button td a:visited { color: #ffffff !important; } table.secondary td { background: #e9e9e9; border-color: #d0d0d0; color: #555; } table.secondary td a { color: #555; } table.secondary:hover td { background: #d0d0d0 !important; color: #555; } table.secondary:hover td a, table.secondary td a:visited, table.secondary:active td a { color: #555 !important; } table.success td { background: #5da423; border-color: #457a1a; } table.success:hover td { background: #457a1a !important; } table.alert td { background: #c60f13; border-color: #970b0e; } table.alert:hover td { background: #970b0e !important; } table.radius td { -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } table.round td { -webkit-border-radius: 500px; -moz-border-radius: 500px; border-radius: 500px; } /* Outlook First */ body.outlook p { display: inline !important; } /* Media Queries */ @media only screen and (max-width: 600px) { table[class="body"] img { width: auto !important; height: auto !important; } table[class="body"] center { min-width: 0 !important; } table[class="body"] .container { width: 95% !important; } table[class="body"] .row { width: 100% !important; display: block !important; } table[class="body"] .wrapper { display: block !important; padding-right: 0 !important; } table[class="body"] .columns, table[class="body"] .column { table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important; } table[class="body"] .wrapper.first .columns, table[class="body"] .wrapper.first .column { display: table !important; } table[class="body"] table.columns td, table[class="body"] table.column td { width: 100% !important; } table[class="body"] .columns td.one, table[class="body"] .column td.one { width: 8.333333% !important; } table[class="body"] .columns td.two, table[class="body"] .column td.two { width: 16.666666% !important; } table[class="body"] .columns td.three, table[class="body"] .column td.three { width: 25% !important; } table[class="body"] .columns td.four, table[class="body"] .column td.four { width: 33.333333% !important; } table[class="body"] .columns td.five, table[class="body"] .column td.five { width: 41.666666% !important; } table[class="body"] .columns td.six, table[class="body"] .column td.six { width: 50% !important; } table[class="body"] .columns td.seven, table[class="body"] .column td.seven { width: 58.333333% !important; } table[class="body"] .columns td.eight, table[class="body"] .column td.eight { width: 66.666666% !important; } table[class="body"] .columns td.nine, table[class="body"] .column td.nine { width: 75% !important; } table[class="body"] .columns td.ten, table[class="body"] .column td.ten { width: 83.333333% !important; } table[class="body"] .columns td.eleven, table[class="body"] .column td.eleven { width: 91.666666% !important; } table[class="body"] .columns td.twelve, table[class="body"] .column td.twelve { width: 100% !important; } table[class="body"] td.offset-by-one, table[class="body"] td.offset-by-two, table[class="body"] td.offset-by-three, table[class="body"] td.offset-by-four, table[class="body"] td.offset-by-five, table[class="body"] td.offset-by-six, table[class="body"] td.offset-by-seven, table[class="body"] td.offset-by-eight, table[class="body"] td.offset-by-nine, table[class="body"] td.offset-by-ten, table[class="body"] td.offset-by-eleven { padding-left: 0 !important; } table[class="body"] table.columns td.expander { width: 1px !important; } table[class="body"] .right-text-pad, table[class="body"] .text-pad-right { padding-left: 10px !important; } table[class="body"] .left-text-pad, table[class="body"] .text-pad-left { padding-right: 10px !important; } table[class="body"] .hide-for-small, table[class="body"] .show-for-desktop { display: none !important; } table[class="body"] .show-for-small, table[class="body"] .hide-for-desktop { display: inherit !important; } } ``` PS Resulting email html is to messy to publish, but basically it will put all your css properties as inline properties on html tags.
I am writing this for other people who might run into the same problem like me in the future. Apparently as Mr. Leonardo as pointed out, HTML e-mails doesn't read the external or even internal css at all because the head part of the template are opted out and only body part are used. Thus the solution is to use table and html attributes with inline css to style the html email template. Thanks
19,970,356
We can extract distinct value set from a list by using following code ``` List<Person> distinctPeople = allPeople .GroupBy(p => new {p.PersonId, p.FavoriteColor} ) .Select(g => g.First()) .ToList(); ``` Assume person has PersonId, FavoriteColor, age, address, etc..... My requirement is I would like to get a separate list which should contain distinct filter data only such as PersonId, FavoriteColor not others. What is the command for that, Assume I can create a small class which contain PersonId, FavoriteColor only
2013/11/14
[ "https://Stackoverflow.com/questions/19970356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2288789/" ]
As other devs mentioned email clients do not load external css, so you have to inline it. Inlining css manually is poor decision. There are libraries to inline css. One of them is [django-inlinecss](https://github.com/roverdotcom/django-inlinecss "django-inlinecss"). You can keep you code exactly as it is. All you need to do is to install django-inlinecss and to change "deposit\_email.html". I do not know how it looks, because you have not publish it, so I give you example of simple header like email template I used before with success. ```html {% load inlinecss %} {% inlinecss "css/email.css" %} <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Title</title> </head> <body> <table class="body"> <tr> <td class="center" align="center" valign="top"> <center> <table class="row header"> <tr> <td class="center" align="center"> <center> <table class="container"> <tr> <td class="wrapper last"> <table class="twelve columns"> <tr> <td> <img src="your_header_link"> </td> <td class="expander"></td> </tr> </table> </td> </tr> </table> </center> </td> </tr> </table> <table class="container"> <tr> <td> <table class="row"> <tr> <td class="wrapper last"> <table class="twelve columns"> <tr> <td> {% block content %} Email {% endblock %} <td class="expander"></td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </center> </td> </tr> </table> </body> </html> {% endinlinecss %} ``` Not much going on here. First line loads inlinecss tag. ``` {% load inlinecss %} ``` Second line starts html, which will be css inlined. It also load email.css which can be any static file in your django project. ``` {% inlinecss "css/email.css" %} ``` After that table based template which has header and body with django block 'content'. Final line is ``` {% endinlinecss %} ``` Which ends inlinecss. As you can see I inline my entire template. I recommend to have one or more parent email templates, which contain template structure and than to use template inheritance for particular emails. In that way you need to specify template and inline your css once. Last but not least. In order for table template to play nicely you need email.css styles. CSS is a bit big, but simple in nature. Add your own styles on top of that. ```css #outlook a { padding: 0; } body { width: 100% !important; min-width: 100%; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; margin: 0; padding: 0; } .ExternalClass { width: 100%; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } #backgroundTable { margin: 0; padding: 0; width: 100% !important; line-height: 100% !important; } img { outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; width: auto; max-width: 100%; float: left; clear: both; display: block; } center { width: 100%; min-width: 580px; } a img { border: none; } p { margin: 0 0 0 10px; } table { border-spacing: 0; border-collapse: collapse; } td { word-break: normal; -webkit-hyphens: auto; -moz-hyphens: auto; hyphens: auto; border-collapse: collapse !important; } table, tr, td { padding: 0; vertical-align: top; text-align: left; } hr { color: #d9d9d9; background-color: #d9d9d9; height: 1px; border: none; } /* Responsive Grid */ table.body { height: 100%; width: 100%; } table.container { width: 580px; margin: 0 auto; text-align: inherit; } table.row { padding: 0px; width: 100%; position: relative; } table.container table.row { display: block; } td.wrapper { padding: 10px 20px 0px 0px; position: relative; } table.columns, table.column { margin: 0 auto; } table.columns td, table.column td { padding: 0px 0px 10px; } table.columns td.sub-columns, table.column td.sub-columns, table.columns td.sub-column, table.column td.sub-column { padding-right: 10px; } td.sub-column, td.sub-columns { min-width: 0px; } table.row td.last, table.container td.last { padding-right: 0px; } table.one { width: 30px; } table.two { width: 80px; } table.three { width: 130px; } table.four { width: 180px; } table.five { width: 230px; } table.six { width: 280px; } table.seven { width: 330px; } table.eight { width: 380px; } table.nine { width: 430px; } table.ten { width: 480px; } table.eleven { width: 530px; } table.twelve { width: 580px; } table.one center { min-width: 30px; } table.two center { min-width: 80px; } table.three center { min-width: 130px; } table.four center { min-width: 180px; } table.five center { min-width: 230px; } table.six center { min-width: 280px; } table.seven center { min-width: 330px; } table.eight center { min-width: 380px; } table.nine center { min-width: 430px; } table.ten center { min-width: 480px; } table.eleven center { min-width: 530px; } table.twelve center { min-width: 580px; } table.one .panel center { min-width: 10px; } table.two .panel center { min-width: 60px; } table.three .panel center { min-width: 110px; } table.four .panel center { min-width: 160px; } table.five .panel center { min-width: 210px; } table.six .panel center { min-width: 260px; } table.seven .panel center { min-width: 310px; } table.eight .panel center { min-width: 360px; } table.nine .panel center { min-width: 410px; } table.ten .panel center { min-width: 460px; } table.eleven .panel center { min-width: 510px; } table.twelve .panel center { min-width: 560px; } .body .columns td.one, .body .column td.one { width: 8.333333%; } .body .columns td.two, .body .column td.two { width: 16.666666%; } .body .columns td.three, .body .column td.three { width: 25%; } .body .columns td.four, .body .column td.four { width: 33.333333%; } .body .columns td.five, .body .column td.five { width: 41.666666%; } .body .columns td.six, .body .column td.six { width: 50%; } .body .columns td.seven, .body .column td.seven { width: 58.333333%; } .body .columns td.eight, .body .column td.eight { width: 66.666666%; } .body .columns td.nine, .body .column td.nine { width: 75%; } .body .columns td.ten, .body .column td.ten { width: 83.333333%; } .body .columns td.eleven, .body .column td.eleven { width: 91.666666%; } .body .columns td.twelve, .body .column td.twelve { width: 100%; } td.offset-by-one { padding-left: 50px; } td.offset-by-two { padding-left: 100px; } td.offset-by-three { padding-left: 150px; } td.offset-by-four { padding-left: 200px; } td.offset-by-five { padding-left: 250px; } td.offset-by-six { padding-left: 300px; } td.offset-by-seven { padding-left: 350px; } td.offset-by-eight { padding-left: 400px; } td.offset-by-nine { padding-left: 450px; } td.offset-by-ten { padding-left: 500px; } td.offset-by-eleven { padding-left: 550px; } td.expander { visibility: hidden; width: 0px; padding: 0 !important; } table.columns .text-pad, table.column .text-pad { padding-left: 10px; padding-right: 10px; } table.columns .left-text-pad, table.columns .text-pad-left, table.column .left-text-pad, table.column .text-pad-left { padding-left: 10px; } table.columns .right-text-pad, table.columns .text-pad-right, table.column .right-text-pad, table.column .text-pad-right { padding-right: 10px; } /* Block Grid */ .block-grid { width: 100%; max-width: 580px; } .block-grid td { display: inline-block; padding: 10px; } .two-up td { width: 270px; } .three-up td { width: 173px; } .four-up td { width: 125px; } .five-up td { width: 96px; } .six-up td { width: 76px; } .seven-up td { width: 62px; } .eight-up td { width: 52px; } /* Alignment & Visibility Classes */ table.center, td.center { text-align: center; } h1.center, h2.center, h3.center, h4.center, h5.center, h6.center { text-align: center; } span.center { display: block; width: 100%; text-align: center; } img.center { margin: 0 auto; float: none; } .show-for-small, .hide-for-desktop { display: none; } /* Typography */ body, table.body, h1, h2, h3, h4, h5, h6, p, td { color: #222222; font-family: "Helvetica", "Arial", sans-serif; font-weight: normal; padding: 0; margin: 0; text-align: left; line-height: 1.3; } h1, h2, h3, h4, h5, h6 { word-break: normal; } h1 { font-size: 40px; } h2 { font-size: 36px; } h3 { font-size: 32px; } h4 { font-size: 28px; } h5 { font-size: 24px; } h6 { font-size: 20px; } body, table.body, p, td { font-size: 14px; line-height: 19px; } p.lead, p.lede, p.leed { font-size: 18px; line-height: 21px; } p { margin-bottom: 10px; } small { font-size: 10px; } a { color: #2ba6cb; text-decoration: none; } a:hover { color: #2795b6 !important; } a:active { color: #2795b6 !important; } a:visited { color: #2ba6cb !important; } h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { color: #2ba6cb; } h1 a:active, h2 a:active, h3 a:active, h4 a:active, h5 a:active, h6 a:active { color: #2ba6cb !important; } h1 a:visited, h2 a:visited, h3 a:visited, h4 a:visited, h5 a:visited, h6 a:visited { color: #2ba6cb !important; } /* Panels */ .panel { background: #f2f2f2; border: 1px solid #d9d9d9; padding: 10px !important; } .sub-grid table { width: 100%; } .sub-grid td.sub-columns { padding-bottom: 0; } /* Buttons */ table.button, table.tiny-button, table.small-button, table.medium-button, table.large-button { width: 100%; overflow: hidden; } table.button td, table.tiny-button td, table.small-button td, table.medium-button td, table.large-button td { display: block; width: auto !important; text-align: center; background: #2ba6cb; border: 1px solid #2284a1; color: #ffffff; padding: 8px 0; } table.tiny-button td { padding: 5px 0 4px; } table.small-button td { padding: 8px 0 7px; } table.medium-button td { padding: 12px 0 10px; } table.large-button td { padding: 21px 0 18px; } table.button td a, table.tiny-button td a, table.small-button td a, table.medium-button td a, table.large-button td a { font-weight: bold; text-decoration: none; font-family: Helvetica, Arial, sans-serif; color: #ffffff; font-size: 16px; } table.tiny-button td a { font-size: 12px; font-weight: normal; } table.small-button td a { font-size: 16px; } table.medium-button td a { font-size: 20px; } table.large-button td a { font-size: 24px; } table.button:hover td, table.button:visited td, table.button:active td { background: #2795b6 !important; } table.button:hover td a, table.button:visited td a, table.button:active td a { color: #fff !important; } table.button:hover td, table.tiny-button:hover td, table.small-button:hover td, table.medium-button:hover td, table.large-button:hover td { background: #2795b6 !important; } table.button:hover td a, table.button:active td a, table.button td a:visited, table.tiny-button:hover td a, table.tiny-button:active td a, table.tiny-button td a:visited, table.small-button:hover td a, table.small-button:active td a, table.small-button td a:visited, table.medium-button:hover td a, table.medium-button:active td a, table.medium-button td a:visited, table.large-button:hover td a, table.large-button:active td a, table.large-button td a:visited { color: #ffffff !important; } table.secondary td { background: #e9e9e9; border-color: #d0d0d0; color: #555; } table.secondary td a { color: #555; } table.secondary:hover td { background: #d0d0d0 !important; color: #555; } table.secondary:hover td a, table.secondary td a:visited, table.secondary:active td a { color: #555 !important; } table.success td { background: #5da423; border-color: #457a1a; } table.success:hover td { background: #457a1a !important; } table.alert td { background: #c60f13; border-color: #970b0e; } table.alert:hover td { background: #970b0e !important; } table.radius td { -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; } table.round td { -webkit-border-radius: 500px; -moz-border-radius: 500px; border-radius: 500px; } /* Outlook First */ body.outlook p { display: inline !important; } /* Media Queries */ @media only screen and (max-width: 600px) { table[class="body"] img { width: auto !important; height: auto !important; } table[class="body"] center { min-width: 0 !important; } table[class="body"] .container { width: 95% !important; } table[class="body"] .row { width: 100% !important; display: block !important; } table[class="body"] .wrapper { display: block !important; padding-right: 0 !important; } table[class="body"] .columns, table[class="body"] .column { table-layout: fixed !important; float: none !important; width: 100% !important; padding-right: 0px !important; padding-left: 0px !important; display: block !important; } table[class="body"] .wrapper.first .columns, table[class="body"] .wrapper.first .column { display: table !important; } table[class="body"] table.columns td, table[class="body"] table.column td { width: 100% !important; } table[class="body"] .columns td.one, table[class="body"] .column td.one { width: 8.333333% !important; } table[class="body"] .columns td.two, table[class="body"] .column td.two { width: 16.666666% !important; } table[class="body"] .columns td.three, table[class="body"] .column td.three { width: 25% !important; } table[class="body"] .columns td.four, table[class="body"] .column td.four { width: 33.333333% !important; } table[class="body"] .columns td.five, table[class="body"] .column td.five { width: 41.666666% !important; } table[class="body"] .columns td.six, table[class="body"] .column td.six { width: 50% !important; } table[class="body"] .columns td.seven, table[class="body"] .column td.seven { width: 58.333333% !important; } table[class="body"] .columns td.eight, table[class="body"] .column td.eight { width: 66.666666% !important; } table[class="body"] .columns td.nine, table[class="body"] .column td.nine { width: 75% !important; } table[class="body"] .columns td.ten, table[class="body"] .column td.ten { width: 83.333333% !important; } table[class="body"] .columns td.eleven, table[class="body"] .column td.eleven { width: 91.666666% !important; } table[class="body"] .columns td.twelve, table[class="body"] .column td.twelve { width: 100% !important; } table[class="body"] td.offset-by-one, table[class="body"] td.offset-by-two, table[class="body"] td.offset-by-three, table[class="body"] td.offset-by-four, table[class="body"] td.offset-by-five, table[class="body"] td.offset-by-six, table[class="body"] td.offset-by-seven, table[class="body"] td.offset-by-eight, table[class="body"] td.offset-by-nine, table[class="body"] td.offset-by-ten, table[class="body"] td.offset-by-eleven { padding-left: 0 !important; } table[class="body"] table.columns td.expander { width: 1px !important; } table[class="body"] .right-text-pad, table[class="body"] .text-pad-right { padding-left: 10px !important; } table[class="body"] .left-text-pad, table[class="body"] .text-pad-left { padding-right: 10px !important; } table[class="body"] .hide-for-small, table[class="body"] .show-for-desktop { display: none !important; } table[class="body"] .show-for-small, table[class="body"] .hide-for-desktop { display: inherit !important; } } ``` PS Resulting email html is to messy to publish, but basically it will put all your css properties as inline properties on html tags.
The one way is to use inline css in the code, ``` <div class="pre"><strong>Title,</strong>&nbsp;</div> <div class="pre">&nbsp;</div> <blockquote> <div class="pre">Message part</div> </blockquote> <div class="pre">&nbsp;</div> <div class="pre"><span style="background-color: #800080;">Thanks</span>,<br /> <br /> </div> </div> ``` It works for me..
18,746,129
I am trying to make a `left outer join` query that also has a `custom comparator`. I have the following lists: ``` List<ColumnInformation> list1; List<ColumnInformation> list2; ``` These hold information about an SQL column (datatype, name, table, etc). I have overrided `Equals` for the class, and made a `operator ==` and `operator !=`. I understand how to [make a left outer join](https://stackoverflow.com/a/5491381/1043380): ``` var leftOuterJoin = from l1 in list1 join l2 in list2 on l1.objectID equals l2.objectID into temp from l2 in temp.DefaultIfEmpty(new { l1.ID, Name = default(string) }) select new { l1.ID, ColumnName1 = l1.Name, ColumnName2 = l2.Name, }; ``` And I understand how to make and use a custom `IEqualityComparer`: ``` public class ColumnComparer : IEqualityComparer<ColumnInformation> { public bool Equals(ColumnInformation x, ColumnInformation y) { return x == y; //this uses my defined == operator } public int GetHashCode(ColumnInformation obj) { return 1; //forcing the join to use Equals, just trust me on this } } ColumnComparer cc = new ColumnComparer(); var joinedList = list1.Join(list2, x => x, y => y, (x, y) => new {x, y}, cc); ``` My question is: **How can I do both a left outer join and use my comparator at the same time**? As far as I know, the query syntax does not have a keyword for a comparator, and the extension method does not have anything for the `into` keyword. I do not care if the result is in query syntax or extension methods.
2013/09/11
[ "https://Stackoverflow.com/questions/18746129", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1043380/" ]
The way you do that is with a `GroupJoin` and `SelectMany` (to flatten the results): ``` ColumnComparer cc = new ColumnComparer(); var joinedList = list1 .GroupJoin(list2, x => x, y => y, (x, g) => new {x, g}, cc) .SelectMany( z => z.g.DefaultIfEmpty(), (z, b) => new { x = z.x, y = b } ); ```
You can take advantage of Sub-Query in combination with Where: ``` var leftOuterJoin = from l1 in list1 select new { jointList = (from l2 in list2 where l2.objectID == l1.ObjectID // <-- and you can do any other comparing logic in where clause select l2).DefaultIfEmpty(), l1id = l1.ID, ColumnName1 = l1.Name, ColumnName2 = l2.Name }; ```
59,397
As established [in a previous question](https://chemistry.stackexchange.com/q/31276), coordination compounds typically have a *field split* between the $\mathrm{t\_{2g}}$ and the $\mathrm{e\_g}$ d-orbitals.[1] This energy difference can be explained by the crystal field theory which assumes negative point-charges approaching a complex and destabilising orbitals pointing towards said point charges. Commonly, the energy difference between the lower and higher orbitals is referred to by the relative value of $\Delta$ or the equally relative value of $10~\mathrm{Dq}$. The latter is of interest to me. It is clearly used as a (relative) unit, because *ligand field stabilisation enthalpies* (LFSE’s) are typically given in values of $\mathrm{Dq}$ β€” e.g. $\ce{[Cr(H2O)6]^3+}$ (hexaaquachromium(III)) has an LFSE of $-12~\mathrm{Dq}$. But what does $\mathrm{Dq}$ mean and what does it derive from? --- **Note:** [1]: This is explicitly considering the octahedral case. Tetrahedral compounds split the d-orbitals into $\mathrm{t\_2}$ and $\mathrm{e}$. This distinction is, however, not relevant to the question.
2016/09/20
[ "https://chemistry.stackexchange.com/questions/59397", "https://chemistry.stackexchange.com", "https://chemistry.stackexchange.com/users/7475/" ]
I currently happen to have the book by Figgis that Max mentioned. Chapter 2 is devoted to a mathematical formulation of crystal field theory, which I did not bother reading in detail because I do not understand any of it. *(The corollary is: If you have a better answer, please post it!)* It seems that both $D$ and $q$ are collections of constants defined in such a way so as to make the octahedral splitting equal to $10Dq$. In particular it is defined that $$D = \frac{35ze}{4a^5}$$ and $$q = \frac{2e\langle r^4\rangle}{105}$$ where $ze$ is the charge on the ligands (in crystal field theory, the ligands are treated as point charges), $a$ is the distance of the ligands from the central ion, and $\langle r^4 \rangle$ is the mean fourth power radius of the d electrons in the central ion. These quantities can be derived from first principles (that is precisely what crystal field theory is about) and lead to the expression of the crystal field electrostatic potential in Cartesian coordinates: $$\mathbf{V}\_{\mathrm{oct}} = D\left(x^4 + y^4 + z^4 - \frac{3r^4}{5}\right)$$ I followed some references given in the book which ultimately ended up in one of the papers in porphyrin's comment: [*Phys. Rev.* **1932,** *31,* 194](http://journals.aps.org/pr/pdf/10.1103/PhysRev.41.194). There's more discussion there. In particular, as far as I can tell, it seems that $D$ is called that simply because it is a quartic term in the potential (the first three terms having coefficients of $A,B,C$), and $q$ is called that because it is related to a series of constants $p\_J$ which depend on the total spin quantum number $J$ (consistent with $p$ and $q$ being commonly used letters for mathematical constants). --- Just to clear up any potential confusion with porphyrin's comment which at first glance seems to be missing one $r^4$ term in the electrostatic potential, the above article writes: > > It is sufficient to write the potential $V = D(x^4+y^4+z^4)$ since this can be made to satisfy Laplace's equation by adding a function of $r^2$ (viz. $-3Dr^4$). [The addition of this term] corresponds to superposing a spherically symmetrical field, and merely shifts all levels equally. > > > There's still a factor of $1/5$ missing compared to the expression above, but I'm not particularly inclined to figure out how it arises, and I don't think it is of much importance anyway since the only difference is effectively to shift the zero of energy.
I will expand my previous comment into an answer. In the $O\_h$ case the metal ion is surrounded by $6$ ligand ions, each with charge $q=-Ze$ located at $\langle\pm a,0,0\rangle$, $\langle0, \pm a,0\rangle$, and $\langle0,0,\pm a\rangle$. The electrostatic potential of a point charge $q$ is $$V=\frac{kq}R$$ where $$k=\frac1{4\pi\epsilon\_0}$$ is the Coulomb's Law constant and $\epsilon\_0$ is the permittivity of free space and $R=\left\|\vec{r\_f}-\vec{r\_s}\right\|$ is the distance from the source point $\vec{r\_s}$ to the field point $\vec{r\_f}$. Working for the moment with the potential $V\_1$ due to the charge at $\langle a,0,0\rangle$, $$R=\left\|\langle x,y,z\rangle-\langle a,0,0\rangle\right\|=\left\|\langle x-a,y,z\rangle\right\|=\sqrt{(x-a)^2+y^2+z^2}=\sqrt{a^2-2ax+x^2+y^2+z^2}=a\sqrt{1-\frac{2x}a+\frac{r^2}{a^2}}$$ Where $r^2=x^2+y^2+z^2$ is the squared distance from the origin. Then $$V\_1=-\frac{Ze}{4\pi\epsilon\_0a}\left(1-\frac{2x}a+\frac{r^2}{a^2}\right)^{-1/2}$$ Now we need to expand $(1+x)^{-1/2}$ to fourth order in $x$. The Taylor series yields $$(1+x)^{-1/2}=1-\frac12x+\frac38x^2-\frac5{16}x^3+\frac{35}{128}x^4+O\left(x^5\right)$$ We could have obtained this result via algebra alone by assuming that $(1+x)^{-1/2}=1+ax+bx^2+cx^3+dx^4+O\left(x^5\right)$, then squaring and multiplying by $(1+x)$ so that $$\left(1+ax+bx^2+cx^3+dx^4\right)^2(1+x)=1+O\left(x^5\right)$$ and then finding the unknowns $a$, $b$, $c$, and $d$ from the conditions that the coefficients of $x$, $x^2$, $x^3$, and $x^4$ should be zero. Then we have $$\begin{align}V\_1= & -\frac{Ze}{4\pi\epsilon\_0a}\left\{1-\frac12\left[-\frac{2x}a+\frac{r^2}{a^2}\right]+\frac38\left[\frac{4x^2}{a^2}-\frac{4xr^2}{a^3}+\frac{r^4}{a^4}\right]\right. \\ & \left.-\frac5{16}\left[-\frac{8x^3}{a^3}+\frac{12x^2r^2}{a^4}\right]+\frac{35}{128}\frac{16x^4}{a^4}\right\}+O\left(\left(\frac ra\right)^5\right)\end{align}$$ This is complicated, but now we simplify by combining the potentials due to all $6$ ligands. We want to find group operations from $O\_h$ that map the first ligand to the others, and fortunately the powers of $S\_6$, the rotoreflection by angle $\frac{\pi}3$ about the axis through the origin and $\langle1,1,1\rangle$ will do the trick. Its powers cycle the original ligand point through all the others. We just need to find the mappings of the powers of $x$ by the powers of $S\_6$ and sum over all powers of $S\_6$: $$\begin{array}{c|cccccc|c} f(x,y,z)&Ef&S\_6f&S\_6^2f&S\_6^3f&S\_6^4f&S\_6^5f&\sum\limits\_{i=0}^5S\_6^if \\ \hline r^2&r^2&r^2&r^2&r^2&r^2&r^2&6r^2 \\ x&x&-z&y&-x&z&-y&0 \\ x^2&x^2&z^2&y^2&x^2&z^2&y^2&2r^2 \\ x^3&x^3&-z^3&y^3&-x^3&z^3&-y^3&0 \\ x^4&x^4&z^4&y^4&x^4&z^4&y^4&2\left(x^4+y^4+z^4\right) \end{array}$$ So now $$\begin{align}V\_{O\_h}= & \sum\limits\_{i=0}^5S\_6^iV\_1 \\ & =-\frac{Ze}{4\pi\epsilon\_0a}\left\{6-\frac12\left[0+\frac{6r^2}{a^2}\right]+\frac38\left[\frac{8r^2}{a^2}-0+\frac{6r^4}{a^4}\right]\right. \\ & \left.-\frac5{16}\left[0+\frac{24r^4}{a^4}\right]+\frac{35}{4}\frac{x^4+y^4+z^4}{a^4}\right\}+O\left(\left(\frac ra\right)^5\right) \\ & =-\frac{Ze}{4\pi\epsilon\_0a}\left[6-\frac{21r^4}{4a^4}+\frac{35\left(x^4+y^4+z^4\right)}{4a^4}\right]+O\left(\left(\frac ra\right)^5\right) \\ & =-\frac{6Ze}{4\pi\epsilon\_0a}-\frac{35Ze}{16\pi\epsilon\_0a^5}\left(x^4+y^4+z^4-\frac35r^4\right)+O\left(\left(\frac ra\right)^5\right)\end{align}$$ All this mathjax is exhausting. I can't finish in one sitting, but at least I have gotten to $$D=\frac{35Ze}{16\pi\epsilon\_0a^5}$$ **EDIT**: Now that the potential for $O\_h$ geometry has been developed, the same will be done for the $T\_d$ case where the metal ion is surrounded by $4$ ligand ions, each with charge $q=-Ze$, this time located at $\left\langle\frac a{\sqrt3},\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle$, $\left\langle\frac a{\sqrt3},-\frac a{\sqrt3},-\frac a{\sqrt3}\right\rangle$, $\left\langle-\frac a{\sqrt3},\frac a{\sqrt3},-\frac a{\sqrt3}\right\rangle$, and $\left\langle-\frac a{\sqrt3},-\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle$. The distance from the source point at $\vec{r\_s}=\left\langle\frac a{\sqrt3},\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle$ to the field point at $\vec{r\_f}=\langle x,y,z\rangle$ is $$\begin{align}R= & \left\|\vec{r\_f}-\vec{r\_s}\right\|=\left\|\left\langle x-\frac a{\sqrt3},y-\frac a{\sqrt3},z-\frac a{\sqrt3}\right\rangle\right\| \\ & =\sqrt{\left(x-\frac a{\sqrt3}\right)^2+\left(y-\frac a{\sqrt3}\right)^2+\left(z-\frac a{\sqrt3}\right)^2} \\ & =\sqrt{a^2-\frac{2a}{\sqrt3}(x+y+z)+x^2+y^2+z^2} \\ & =a\sqrt{1-\frac{2(x+y+z)}{\sqrt3a}+\frac{r^2}{a^2}}\end{align}$$ Then the potential due to this charge is $$\begin{align}V\_2 & =\frac{kq}R=-\frac{Ze}{4\pi\epsilon\_0a}\left(1-\frac{2(x+y+z)}{\sqrt3a}+\frac{r^2}{a^2}\right)^{-1/2} \\ & =-\frac{Ze}{4\pi\epsilon\_0a}\left\{1-\frac12\left[-\frac{2(x+y+z)}{\sqrt3a}+\frac{r^2}{a^2}\right]+\frac38\left[\frac4{3a^2}(x+y+z)^2-\frac{4(x+y+z)r^2}{\sqrt3a^3}+\frac{r^4}{a^4}\right]\right. \\ & \left.-\frac5{16}\left[-\frac8{3\sqrt3a^3}(x+y+z)^3+\frac{4(x+y+z)^2r^2}{a^4}\right]+\frac{35}{128}\left[\frac{16}{9a^4}(x+y+z)^4\right]\right\}+O\left(\left(\frac ra\right)^5\right)\end{align}$$ This time the group operations that map the model point to all the others will be the members of the $D\_2$ point group: the identity $E$, and the rotations by $180Β°$ about the x-axis $C\_{2x}$, the y-axis $C\_{2y}$, and the z-axis $C\_{2z}$. Again a table for combining the contributions from all point charges: $$\begin{array}{c|cccc|c} f(x,y,z)&R\_1f=Ef&R\_2f=C\_{2x}f&R\_3f=C\_{2y}f&R\_4f=C\_{2z}f&\sum\limits\_{i=1}^4R\_if \\ \hline r^2&r^2&r^2&r^2&r^2&4r^2 \\ x&x&x&-x&-x&0 \\ xy&xy&-xy&-xy&xy&0 \\ xyz&xyz&xyz&xyz&xyz&4xyz \end{array}$$ And the reader can readily verify that also $$\sum\limits\_{i=1}^4R\_iy=\sum\limits\_{i=1}^4R\_iz=\sum\limits\_{i=1}^4R\_ixz=\sum\limits\_{i=1}^4R\_iyz=0$$ So the rule is that terms in the expression for $V\_2$ with odd powers of any of the coordinates cancels except for $xyz$, which, along with all terms with only even powers of coordinates, adds. Expanding powers of $(x+y+z)$ and summing over the four sources, $$\begin{align}V\_{T\_d} & =\sum\limits\_{i=1}^4R\_iV\_2=-\frac{Ze}{4\pi\epsilon\_0a}\left\{4-\frac12\left[0+\frac{4r^2}{a^2}\right]+\frac38\left[\frac4{3a^2}(4r^2)-0+\frac{4r^4}{a^4}\right]\right. \\ & \left.-\frac5{16}\left[-\frac8{3\sqrt3a^3}(6)(4xyz)+\frac{4(4r^2)r^2}{a^4}\right]\right. \\ & \left.+\frac{35}{128}\frac{16}{9a^4}\left[4\left(x^4+y^4+z^4\right)+6(4)\left(x^2y^2+x^2z^2+y^2z^2\right)\right]\right\}+O\left(\left(\frac ra\right)^5\right) \\ & = -\frac{Ze}{4\pi\epsilon\_0a}\left\{4+\frac{3r^4}{2a^4}+\frac{20}{\sqrt3a^3}xyz-\frac{5r^4}{a^4}\right. \\ & \left.+\frac{35}{72a^4}\left[4\left(x^4+y^4+z^4\right)+12\left(r^4-x^4-y^4-z^4\right)\right]\right\}+O\left(\left(\frac ra\right)^5\right) \\ & = -\frac{Ze}{4\pi\epsilon\_0a}\left[4+\frac{20}{\sqrt3a^3}xyz-\frac{35}{9a^4}\left(x^4+y^4+z^5-\frac35r^4\right)\right]+O\left(\left(\frac ra\right)^5\right) \\ & = -\frac{4Ze}{4\pi\epsilon\_0a}-\frac{5Ze}{\sqrt3\pi\epsilon\_0a^4}xyz+\frac{35Ze}{36\pi\epsilon\_0a^5}\left(x^4+y^4+z^4-\frac35r^4\right)+O\left(\left(\frac ra\right)^5\right)\end{align}$$ On comparison with $V\_{O\_h}$, the first term is the potential due to the net charge of all the ligands uniformly spread over the surface of a sphere of radius $a$. The second term has no counterpart in $V\_{O\_h}$ and causes no splitting but does create mixing between the $d\_{xy}$ and $p\_z$ orbitals and would lower the energy of the former and raise the energy of the latter. I don't know how significant that effect is, though. The splitting term is $\frac49D\left(x^4+y^4+z^4-\frac35r^4\right)$ and is in fact $-\frac49$ the value of the splitting term for $O\_h$ geometry. Still not done, but it's getting late. **EDIT**:To get the $q$ part of $Dq$ we are going to have to do some integrals. I am going to use the notation $$\oint f(x,y,z)d^2\Omega$$ to represent the integral of $f(x,y,z)$ over the surface of the unit sphere. One integral we know right off the bat is $$\oint 1d^2\Omega=4\pi$$ using the mensuration formula from geometry for the area of a sphere. Actually, if we didn't know this formula, it would be no problem since if the answer were an unknown, say $\xi$, all the $\xi$'s would cancel out in the final results. If the integrand is a monomial with an odd power of $z$, then $$\begin{align}\oint x^ay^bz^{2c+1}d^2\Omega & =\oint \sigma\_{hz}\left(x^ay^bz^{2c+1}\right)d^2\Omega=(-1)^{2c+1}\oint x^ay^bz^{2c+1}d^2\Omega \\ & =\frac{1+(-1)^{2c+1}}2\oint x^ay^bz^{2c+1}d^2\Omega=0\end{align}$$ Where $\sigma\_{hz}$ is a reflection though the $xy$-plane. Clearly any proper rotation of the integrand about an axis through the origin doesn't affect the value of the integral because it just corresponds to viewing the same function from a different angle. Also inversion of the integrand through the origin doesn't change the integral and any improper rotation including reflection can be written as inversion times a proper rotation. Thus it can be seen that if $$\oint x^ay^bz^cd^2\Omega \ne 0$$ Then $a$, $b$, and $c$ must all be even. Also we can rotate coordinates so that we only need compute $$\oint x^{2a}y^{2b}z^{2c}d^2\Omega$$ for $a \ge b \ge c$. We can calculate $$\oint r^2d^2\Omega=\oint(x^2+y^2+z^2)d^2\Omega=3\oint x^2d^2\Omega=4\pi$$ where we have rotated individual terms and then used $r^2=1$ on the surface of the unit sphere. Now, $$\oint x^2d^2\Omega=\frac{4\pi}3=\oint x^2r^2d^2\Omega=\oint \left(x^4+x^2y^2+x^2z^2\right)d^2\Omega=\oint x^4d^2\Omega+2\oint x^2y^2d^2\Omega$$ Rotating by $\frac{\pi}4$ about the $z$-axis, $$\begin{align}\oint x^4d^2\Omega & =\oint \left(\frac{x+y}{\sqrt2}\right)^4d^2\Omega=\frac14\oint\left(x^4+4x^3y+6x^2y^2+4xy^3+y^4\right)d^2\Omega \\ & =\frac12\oint x^4d^2\Omega+\frac32\oint x^2y^2d^2\Omega\end{align}$$ This gives us two eqautions in two unknowns and we can solve using Excel or Matlab or whatever to get $$\oint x^4d^2\Omega=\frac{4\pi}5\text{ and }\oint x^2y^2d^2\Omega=\frac{4\pi}{15}$$ Again we have $$\oint x^2d^2\Omega=\frac{4\pi}3=\oint x^2r^4d^2\Omega=\oint x^6d^2\Omega+6\oint x^4y^2d^2\Omega+2\oint x^2y^2z^2d^2\Omega$$ $$\oint x^4d^2\Omega=\frac{4\pi}5=\oint x^4r^2d^2\Omega=\oint x^6d^2\Omega+2\oint x^4y^2d^2\Omega$$ $$\oint x^6d^2\Omega=\oint \left(\frac{x+y}{\sqrt2}\right)^6d^2\Omega=\frac14\oint x^6d^2\Omega+\frac{15}4\oint x^4y^2d^2\Omega$$ Solving the last $3$ equations in $3$ unknowns we get $$\oint x^6d^2\Omega=\frac{4\pi}7\text{, }\oint x^4y^2d^2\Omega=\frac{4\pi}{35}\text{, and }\oint x^2y^2z^2d^2\Omega=\frac{4\pi}{105}$$ Almost there :) $$\begin{align}\oint x^2d^2\Omega & =\frac{4\pi}3=\oint x^2r^6d^2\Omega \\ & =\oint x^8d^2\Omega+8\oint x^6y^2d^2\Omega+6\oint x^4y^4d^2\Omega+12\oint x^4y^2z^2d^2\Omega\end{align}$$ $$\begin{align}\oint x^4d^2\Omega & =\frac{4\pi}5=\oint x^4r^4d^2\Omega \\ & =\oint x^8d^2\Omega+4\oint x^6y^2d^2\Omega+2\oint x^4y^4d^2\Omega+2\oint x^4y^2z^2d^2\Omega\end{align}$$ $$\oint x^6d^2\Omega=\frac{4\pi}7=\oint x^6r^2d^2\Omega=\oint x^8d^2\Omega+2\oint x^6y^2d^2\Omega$$ $$\oint x^8d^2\Omega=\oint \left(\frac{x+y}{\sqrt2}\right)^8d^2\Omega=\frac18\oint x^8d^2\Omega+\frac72\oint x^6y^2d^2\Omega+\frac{35}8\oint x^4y^4d^2\Omega$$ Solving these $4$ equations in $4$ unknowns, $$\oint x^8d^2\Omega=\frac{4\pi}{9}\text{, }\oint x^6y^2d^2\Omega=\frac{4\pi}{63}\text{, }\oint x^4y^4d^2\Omega=\frac{4\pi}{105}\text{, and }\oint x^4y^2z^2d^2\Omega=\frac{4\pi}{315}$$ With these integrals in hand we want to normalize the polynomials $xy$ and $x^2-y^2$. $$\oint (xy)^2d^2\Omega=\oint x^2y^2d^2\Omega=\frac{4\pi}{15}$$ So a normalized spherical harmonic that transforms as the $xy$ partner of the $T\_{2g}$ representation of $O\_h$ and as the $z$ partner the $T\_2$ representation of $T\_d$ is $$Y\_{xy}^2(x,y,z)=\left(\frac{15}{4\pi}\right)^{1/2}\frac{xy}{r^2}$$ And we have $$\psi\_{xy}(x,y,z)=Y\_{xy}^2(x,y,z)f\_{xy}(r)$$ To find the electrostatic potential energy of an electron with such a wave function in the $O\_h$ potential we integrate over its charge density to get $$\begin{align}U\_{O\_h,xy} & =\int V\_{O\_h}(x,y,z)\rho\_{xy}(x,y,z)d^3volume \\ & =\int\left[-\frac{6Ze}{4\pi\epsilon\_0a}-D\left(x^4+y^4+z^4-\frac35r^4\right)\right]\times \\ & (-e)\left[\left(\frac{15}{4\pi}\right)^{1/2}\frac{xy}{r^2}f\_{xy}(r)\right]^\*\left[\left(\frac{15}{4\pi}\right)^{1/2}\frac{xy}{r^2}f\_{xy}(r)\right]d^3volume \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}\oint\left|\left(\frac{15}{4\pi}\right)^{1/2}\frac{xy}{r^2}\right|^2d^2\Omega\int\_0^{\infty}\left|f\_{xy}(r)\right|^2r^2dr \\ & +De\left(\frac{15}{4\pi}\right)\oint \left(\frac{xy}{r^2}\right)^2\frac{x^4+y^4+z^4-\frac35r^4}{r^4}\int\_0^{\infty}r^4\left|f\_{xy}(r)\right|^2r^2dr \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}(1)(1)+\frac{15De}{4\pi}\left(\frac{4\pi}{63}+\frac{4\pi}{63}+\frac{4\pi}{315}-\frac35\frac{4\pi}{15}\right)\left\langle r^4\right\rangle \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}-\frac{8De}{105}\left\langle r^4\right\rangle\end{align}$$ Where we have used the separate normalizations of the angular part of the wave function $Y\_{xy}^2(x,y,z)$ and the radial part $f\_{xy}(r)$ and the average value of $r^4$ for the radial distribution, $\left\langle r^4\right\rangle$. Now we calculate $$\oint \left(x^2-y^2\right)^2d^2\Omega=2\oint x^4d^2\Omega-2\oint x^2y^2d^2\Omega=2\left(\frac{4\pi}{5}\right)-2\left(\frac{4\pi}{15}\right)=\frac{16\pi}{15}$$ So a normalized spherical harmonic that transforms as the $x^2-y^2$ partner of the $E\_g$ representation of $O\_h$ and the $E$ representation of $T\_d$ is $$Y\_{x^2-y^2}^2(x,y,z)=\left(\frac{15}{16\pi}\right)^{1/2}\left(x^2-y^2\right)$$ We could also have obtained this normalization by rotating $Y\_{xy}^2(x,y,z)$ by $-90Β°$ about the $z$-axis. Now we can get the electrostatic potential energy of an electron with wave function $$\psi\_{x^2-y^2}(x,y,z)=Y\_{x^2-y^2}^2(x,y,z)f\_{x^2-y^2}(r)$$ in the $O\_h$ potential as $$\begin{align}U\_{O\_h,x^2-y^2} & =\int V\_{O\_h}(x,y,z)\rho\_{x^2-y^2}(x,y,z)d^3volume \\ & =\int\left[-\frac{6Ze}{4\pi\epsilon\_0a}-D\left(x^4+y^4+z^4-\frac35r^4\right)\right]\times \\ & (-e)\left[\left(\frac{15}{16\pi}\right)^{1/2}\frac{x^2-y^2}{r^2}f\_{x^2-y^2}(r)\right]^\*\left[\left(\frac{15}{16\pi}\right)^{1/2}\frac{x^2-y^2}{r^2}f\_{x^2-y^2}(r)\right]d^3volume \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}\oint\left|\left(\frac{15}{16\pi}\right)^{1/2}\frac{x^2-y^2}{r^2}\right|^2d^2\Omega\int\_0^{\infty}\left|f\_{x^2-y^2}(r)\right|^2r^2dr \\ & +De\left(\frac{15}{16\pi}\right)\oint \left(\frac{x^2-y^2}{r^2}\right)^2\frac{x^4+y^4+z^4-\frac35r^4}{r^4}\int\_0^{\infty}r^4\left|f\_{x^2-y^2}(r)\right|^2r^2dr \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}(1)(1)+\frac{15De}{16\pi}\left((2)\frac{4\pi}{9}+(4)\frac{4\pi}{105}-(4)\frac{4\pi}{63}-(2)\frac{4\pi}{315}-\frac65\frac{4\pi}{5}+\frac65\frac{4\pi}{15}\right)\left\langle r^4\right\rangle \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{4De}{35}\left\langle r^4\right\rangle\end{align}$$ Where we have assumed the average value of $r^4$ is the same as for $\psi\_{xy}(x,y,z)$ because they both started out as $d$ orbitals and we haven't taken into account higher-order effects. Since there are $3$ $T\_{2g}$ orbitals and $2$ $E\_g$ orbitals, the average potential energy over all orbitals is $$U\_{O\_h,ave}=\frac15\left[3\left(\frac{6Ze^2}{4\pi\epsilon\_0a}-\frac{8De}{105}\left\langle r^4\right\rangle\right)+2\left(\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{4De}{35}\left\langle r^4\right\rangle\right)\right]=\frac{6Ze^2}{4\pi\epsilon\_0a}$$ The splitting in potential energies of the orbitals is $$\begin{align}U\_{O\_h,x^2-y^2}-U\_{O\_h,xy} & =\left(\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{4De}{35}\left\langle r^4\right\rangle\right)-\left(\frac{6Ze^2}{4\pi\epsilon\_0a}-\frac{8De}{105}\left\langle r^4\right\rangle\right) \\ & =\frac{4De}{21}\left\langle r^4\right\rangle\equiv10Dq\end{align}$$ Then we get $$q=\frac{2e}{105}\left\langle r^4\right\rangle$$ and so $$U\_{O\_h,x^2-y^2}=\left(\frac{6Ze^2}{4\pi\epsilon\_0a}\right)+6Dq$$and$$U\_{O\_h,xy}=\left(\frac{6Ze^2}{4\pi\epsilon\_0a}\right)-4Dq$$ This derivation was a little bloody because I chose to do everything with only algebra. There is a much more elegant exposition possible that requires higher level math. Is it worth adding to the end of this answer or posting as another answer?
59,397
As established [in a previous question](https://chemistry.stackexchange.com/q/31276), coordination compounds typically have a *field split* between the $\mathrm{t\_{2g}}$ and the $\mathrm{e\_g}$ d-orbitals.[1] This energy difference can be explained by the crystal field theory which assumes negative point-charges approaching a complex and destabilising orbitals pointing towards said point charges. Commonly, the energy difference between the lower and higher orbitals is referred to by the relative value of $\Delta$ or the equally relative value of $10~\mathrm{Dq}$. The latter is of interest to me. It is clearly used as a (relative) unit, because *ligand field stabilisation enthalpies* (LFSE’s) are typically given in values of $\mathrm{Dq}$ β€” e.g. $\ce{[Cr(H2O)6]^3+}$ (hexaaquachromium(III)) has an LFSE of $-12~\mathrm{Dq}$. But what does $\mathrm{Dq}$ mean and what does it derive from? --- **Note:** [1]: This is explicitly considering the octahedral case. Tetrahedral compounds split the d-orbitals into $\mathrm{t\_2}$ and $\mathrm{e}$. This distinction is, however, not relevant to the question.
2016/09/20
[ "https://chemistry.stackexchange.com/questions/59397", "https://chemistry.stackexchange.com", "https://chemistry.stackexchange.com/users/7475/" ]
I currently happen to have the book by Figgis that Max mentioned. Chapter 2 is devoted to a mathematical formulation of crystal field theory, which I did not bother reading in detail because I do not understand any of it. *(The corollary is: If you have a better answer, please post it!)* It seems that both $D$ and $q$ are collections of constants defined in such a way so as to make the octahedral splitting equal to $10Dq$. In particular it is defined that $$D = \frac{35ze}{4a^5}$$ and $$q = \frac{2e\langle r^4\rangle}{105}$$ where $ze$ is the charge on the ligands (in crystal field theory, the ligands are treated as point charges), $a$ is the distance of the ligands from the central ion, and $\langle r^4 \rangle$ is the mean fourth power radius of the d electrons in the central ion. These quantities can be derived from first principles (that is precisely what crystal field theory is about) and lead to the expression of the crystal field electrostatic potential in Cartesian coordinates: $$\mathbf{V}\_{\mathrm{oct}} = D\left(x^4 + y^4 + z^4 - \frac{3r^4}{5}\right)$$ I followed some references given in the book which ultimately ended up in one of the papers in porphyrin's comment: [*Phys. Rev.* **1932,** *31,* 194](http://journals.aps.org/pr/pdf/10.1103/PhysRev.41.194). There's more discussion there. In particular, as far as I can tell, it seems that $D$ is called that simply because it is a quartic term in the potential (the first three terms having coefficients of $A,B,C$), and $q$ is called that because it is related to a series of constants $p\_J$ which depend on the total spin quantum number $J$ (consistent with $p$ and $q$ being commonly used letters for mathematical constants). --- Just to clear up any potential confusion with porphyrin's comment which at first glance seems to be missing one $r^4$ term in the electrostatic potential, the above article writes: > > It is sufficient to write the potential $V = D(x^4+y^4+z^4)$ since this can be made to satisfy Laplace's equation by adding a function of $r^2$ (viz. $-3Dr^4$). [The addition of this term] corresponds to superposing a spherically symmetrical field, and merely shifts all levels equally. > > > There's still a factor of $1/5$ missing compared to the expression above, but I'm not particularly inclined to figure out how it arises, and I don't think it is of much importance anyway since the only difference is effectively to shift the zero of energy.
A more high-level answer this time. In this approach we first find out the form of the term in the potential that will split the $d$ orbitals. Recall that the character of a proper rotation by angle $\alpha$ for the set of spherical harmonics with $L^2Y\_l^m(\theta,\phi)=\hbar^2l(l+1)Y\_l^m(\theta,\phi)$ is $$\chi\_l(R(\alpha))=\sum\_{m=-l}^le^{im\alpha}=\frac{\sin(m+\frac12)\alpha}{\sin\frac12\alpha}$$ for $\alpha \neq n\pi$. $\chi\_l(R(0))=2l+1$ because all the diagonal elements are $1$ and $\chi\_l(R(\pi))=(-1)^l$ because the diagonal elements alternate between $\pm1$ and there is an odd number of them so their sum is one of their boundary values. Starting from the character table for $O$, we can decompose the characters of the multipole moments via character orthogonality. $$\begin{array}{c|ccccc|c} O&E&3C\_{2h}&8C\_3&6C\_4&6C\_{2d}&\Gamma \\ \hline A\_1&1&1&1&1&1& \\ A\_2&1&1&1&-1&-1& \\ E&2&2&-1&0&0& \\ T\_1&3&-1&0&1&-1 \\ T\_2&3&-1&0&-1&1 \\ \hline S&1&1&1&1&1&A\_{1g} \\ P&3&-1&0&1&-1&T\_{1u} \\ D&5&1&-1&-1&1&E\_g+T\_{2g} \\ F&7&-1&1&-1&-1&A\_{2u}+T\_{1u}+T\_{2u} \\ G&9&1&0&1&1&A\_{1g}+E\_g+T\_{1g}+T\_{2g} \\ H&11&-1&-1&1&-1&E\_u+2T\_{1u}+T\_{2u} \\ I&13&1&1&-1&1&A\_{1g}+A\_{2g}+E\_g+T\_{1g}+2T\_{2g}\end{array}$$ We have expanded this all the way out to hexacontatetrapole moments just in case it were desired to investigate the splitting of $f$ orbitals, but the only multipole that matters for $d$ orbitals is the $A\_{1g}$ hexadecapole moment. This is because the product of a spherical harmonic $Y\_l^m(\theta,\phi)$ with $Y\_l^{m^{\prime}}(\theta,\phi)$ contains only spherical harmonics $Y\_{l^{\prime\prime}}^{m^{\prime\prime}}(\theta,\phi)$ with even $l^{\prime\prime}$, $0\le l^{\prime\prime}\le2l$. We have used the fact that the parity of electric multipole moments is even for even $l$ and odd for odd $l$ to determine the characters over the full $O\_h$ group. The reverse is the case for magnetic multipole moments. We use the projection operator $$P\_{jk}^{\lambda}f(x,y,z)=\frac{\chi^{\lambda}(E)}{|G|}\sum\_{R\in G}D\_{kj}^{\lambda}\left(R^{-1}\right)Rf(x,y,z)$$ Where $\chi^{\lambda}(E)$ is the number of partners of irreducible representation $\lambda$, $|G|$ is the order of the group $G$, the sum is taken over all elements $R$ of the group, and $D\_{kj}^{\lambda}\left(R^{-1}\right)$ is the matrix element of the matrix representing $R^{-1}$. If $f(x,y,z)$ has any character of the $k^{th}$ partner of the $\lambda^{th}$ irreducible representation of $G$, this will be nonzero and transform as the $j^{th}$ partner of the $\lambda^{th}$ irreducible representation. As an example, with $G=T\_d$, $\lambda=T\_2$, and $f(x,y,z)=x+xz+z\left(2z^2-3x^2-3y^2\right)$ the different $P\_{jk}^{T\_2}f(x,y,z)$ can spit out $9$ different functions. But for our purposes today we only need to project into $A\_{1g}$ because any multipole moments must have the full symmetry of the charge configuration that creates them. Then all $D\_{11}^{A\_{1g}}\left(R^{-1}\right)=1$ so $$P\_{11}^{A\_{1g}}f(x,y,z)=\frac1{|G|}\sum\_{R\in G}Rf(x,y,z)$$ We can simplify the sum by finding the stabilizer $H$ of $F(x,y,z)$ in $G$: $Sf(x,y,z)=f(x,y,z)$ for all $S\in H$. Then given a set $C$ of representatives of $H$ in $G$, we have $$P\_{11}^{A\_{1g}}f(x,y,z)=\frac1{|G|}\sum\_{T\in C}\sum\_{S\in H}TSf(x,y,z)=\frac{|H|}{|G|}\sum\_{T\in C}Tf(x,y,z)$$ Starting with a fourth order polynomial $f(x,y,z)=z^4$, its stabilizer in $G=O\_h$ is $H=D\_{4h}$, the dihedral group of order $16$ with $z$ axis as principal axis of symmetry. The cosets can be written as the powers of $C\_{3[111]}$, a rotation of $120Β°$ about the axis through the origin and $\langle1,1,1\rangle$. $$P\_{11}^{A\_{1g}}f(x,y,z)=\frac{16}{48}\left(Ez^4+C\_{3[111]}z^4+C\_{3[111]}^2z^4\right)=\frac13\left(z^4+x^4+y^4\right)$$ We use the Gram-Schmidt process to turn this into a normalized spherical harmonic. Looking back up at the character table we see that also monopole moments transform as $A\_{1g}$, so we start out with $g(x,y,z)=1$ and find its magnitude: $$\oint\left|1\right|^2d^2\Omega=\frac{2\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac32\right)}=\frac{2\pi^{3/2}}{\frac12\pi^{1/2}}=4\pi$$ Where we have used the formula $$\oint x^{2a}y^{2b}z^{2c}d^2\Omega=\frac{2\Gamma\left(a+\frac12\right)\Gamma\left(b+\frac12\right)\Gamma\left(c+\frac12\right)}{\Gamma\left(a+b+c+\frac32\right)}$$ to evaluate the integrals over the unit sphere of a monomial with even powers of $x$, $y$, and $z$. If any exponent is odd, the integral will be zero. Also $\Gamma\left(\frac12\right)=\sqrt{\pi}$ and for $x>0$, $\Gamma(x+1)=x\Gamma(x)$. Hopefully a reviewer can find a thread like 'What Every Chemistry Student Needs to Know About the Gamma and Beta Functions' and post a link in comments. So with the normalized spherical harmonic $$Y\_{A\_{1g}1}^0(\theta,\phi)=\left(\frac1{4\pi}\right)^{1/2}1$$ We can compute the unnormalized spherical harmonic $$\begin{align}cY\_{A\_{1g}1}^4(\theta,\phi) & =\frac1{r^4}P\_{11}^{A\_{1g}}f(x,y,z)-Y\_{A\_{1g}1}^0(\theta,\phi)\oint \left[Y\_{A\_{1g}1}^0(\theta^{\prime},\phi^{\prime})\right]^\*P\_{11}^{A\_{1g}}f(x^{\prime},y^{\prime},z^{\prime})d^2\Omega^{\prime} \\ & =\frac1{3r^4}\left(x^4+y^4+z^4\right)-\frac1{12\pi}\oint\left((x^{\prime})^4+(y^{\prime})^4+(z^{\prime})^4\right)d^2\Omega^{\prime} \\ & =\frac1{3r^4}\left(x^4+y^4+z^4\right)-\frac1{12\pi}(3)\frac{2\Gamma\left(\frac52\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)} \\ & =\frac1{3r^4}\left(x^4+y^4+z^4\right)-\frac1{4\pi}\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)} \\ & =\frac1{3r^4}\left(x^4+y^4+z^4\right)-\frac15=\frac1{3r^4}\left(x^4+y^4+z^4-\frac35r^4\right)\end{align}$$ This has magnitude $$\begin{align}|c|^2 & =\oint \left[cY\_{A\_{1g}1}^4(\theta,\phi)\right]^\*cY\_{A\_{1g}1}^4(\theta,\phi)d^2\Omega=\frac19\oint\left(x^4+y^4+z^4-\frac35r^4\right)^2d^2\Omega \\ & =\frac19\left[(3)\frac{2\Gamma\left(\frac92\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac{11}2\right)}+(6)\frac{\Gamma\left(\frac52\right)\Gamma\left(\frac52\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac{11}2\right)}\right. \\ & \left.-\frac35(6)\frac{\Gamma\left(\frac52\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)}+\frac9{25}\frac{\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac32\right)}\right] \\ & =\frac19\left[(3)\frac{4\pi}{9}+(6)\frac{4\pi}{105}-\frac35(6)\frac{4\pi}5+\frac9{25}(4\pi)\right]=\frac{64\pi}{4725}\end{align}$$ So $$Y\_{A\_{1g}1}^4(\theta,\phi)=\left(\frac{525}{64\pi}\right)^{1/2}\frac1{r^4}\left(x^4+y^4+z^4-\frac35r^4\right)$$ Given this spherical harmonic, we can find the electrostatic potential readily. To find the potential at a field point $\vec{r\_f}=\left\langle x\_f,y\_f,z\_f\right\rangle$ we add up the contribution of the charge $dq=\rho(\vec{r\_s})d^3volume$ at source point $\vec{r\_s}=\left\langle x\_s.y\_s,z\_s\right\rangle$ and sum over all source points: $$V\_{O\_h}\left(\vec{r\_f}\right)=\int\frac{\rho\left(\vec{r\_s}\right)}{4\pi\epsilon\_0\left\|\vec{r\_f}-\vec{r\_s}\right\|}d^3volume$$ Here $$\begin{align}\left\|\vec{r\_f}-\vec{r\_s}\right\| & =\sqrt{\left(\vec{r\_f}-\vec{r\_s}\right)\cdot\left(\vec{r\_f}-\vec{r\_s}\right)}=\sqrt{r\_s^2-2\vec{r\_s}\cdot\vec{r\_f}+r\_f^2} \\ & =r\_s\sqrt{1-2\frac{\vec{r\_s}\cdot\vec{r\_f}}{r\_s^2}+\frac{r\_f^2}{r\_s^2}}=r\_s\sqrt{1-2\frac{r\_f}{r\_s}\cos\gamma+\frac{r\_f^2}{r\_s^2}}\end{align}$$ Where $\cos\gamma=\frac{\vec{r\_s}\cdot\vec{r\_f}}{r\_sr\_f}$ is cosine of the angle between the source point and the field point as seen at the origin. We can use the generating function for the Legendre polynomials and the spherical harmonic addition theorem to expand $$\begin{align}\frac1{r\_s\sqrt{1-2\frac{r\_f}{r\_s}\cos\gamma+\frac{r\_f^2}{r\_s^2}}} & =\frac1{r\_s}\sum\_{l=0}^{\infty}\left(\frac{r\_f}{r\_s}\right)^lP\_l(\cos\gamma) \\ & =\frac1{r\_s}\sum\_{l=0}^{\infty}\left(\frac{r\_f}{r\_s}\right)^l\frac{4\pi}{2l+1}\sum\_{m=-l}^l\left[Y\_l^m\left(\theta\_s,\phi\_s\right)\right]^\*Y\_l^m\left(\theta\_f,\phi\_f\right)\end{align}$$ Valid for $r\_f\lt r\_s$. If $r\_f>r\_s$, just replace $\frac{r\_f^l}{r\_s^{l+1}}$ with $\frac{r\_s^l}{r\_f^{l+1}}$. This is OK for spherical symmetry, but in chemistry we want a different basis set adapted to the point group of the complex. We choose an orthonormal basis set $\left\{Z\_l^m(\theta,\phi),m=-l,l\right\}$ so we can write the old basis set as $$Y\_l^m(\theta,\phi)=\sum\_{m=-l}^lA\_{m^{\prime}m}^lZ\_l^{m^{\prime}}(\theta,\phi)$$ Since both bases are orthormal sets, $$\begin{align}\delta\_{mm^{\prime}} & =\oint\left[Y\_l^{m^\prime}(\theta,\phi)\right]^\*Y\_l^m(\theta,\phi)d^2\Omega \\ & =\oint\sum\_{m\_1=-l}^l\left[A\_{m\_1m^{\prime}}^lZ\_l^{m\_1}(\theta,\phi)\right]^\*\sum\_{m\_2=-l}^lA\_{m\_2m}^lZ\_l^{m\_2}(\theta,\phi)d^2\Omega \\ & =\sum\_{m\_1=-l}^l\left(A\_{m\_1m^{\prime}}^l\right)^\*\sum\_{m\_2=-l}^lA\_{m\_2m}^l\delta\_{m\_1m\_2}=\sum\_{m\_1=-l}^l\left(A\_{m\_1m^{\prime}}^l\right)^\*A\_{m\_1m}^l\end{align}$$ Which says that as matrices, $(A^l)^{\dagger}A^l=I$. Inverses commute because their product being nonsingular requires that both $(A^l)^{\dagger}$ and $A^l$ must be nonsingular and so their product must have an inverse, $\left(A^l(A^l)^{\dagger}\right)^{-1}$. Then $$\begin{align}A^l(A^l)^{\dagger} & =I\left(A^l(A^l)^{\dagger}\right)=\left[\left(A^l(A^l)^{\dagger}\right)^{-1}\left(A^l(A^l)^{\dagger}\right)\right]\left(A^l(A^l)^{\dagger}\right) \\ & =\left(A^l(A^l)^{\dagger}\right)^{-1}\left[\left(A^l(A^l)^{\dagger}\right)\left(A^l(A^l)^{\dagger}\right)\right]=\left(A^l(A^l)^{\dagger}\right)^{-1}\left\{A^l\left[(A^l)^{\dagger}\left(A^l(A^l)^{\dagger}\right)\right]\right\} \\ & =\left(A^l(A^l)^{\dagger}\right)^{-1}\left\{A^l\left[\left((A^l)^{\dagger}A^l\right)(A^l)^{\dagger}\right]\right\}=\left(A^l(A^l)^{\dagger}\right)^{-1}\left[A^l\left(I(A^l)^{\dagger}\right)\right] \\ & =\left(A^l(A^l)^{\dagger}\right)^{-1}\left(A^l(A^l)^{\dagger}\right)=I\end{align}$$ As matrix elements, this is $$\sum\_{m\_1=-l}^lA\_{m^{\prime}m\_1}^l\left(A\_{mm\_1}^l\right)^\*=\delta\_{mm^{\prime}}$$ Then $$\begin{align}\sum\_{m=-l}^l\left[Y\_l^m\left(\theta\_s,\phi\_s\right)\right]^\*Y\_l^m\left(\theta\_f,\phi\_f\right) & =\sum\_{m=-l}^l\sum\_{m\_1=-l}^l\left[A\_{m\_1m}^lZ\_l^{m\_1}\left(\theta\_s,\phi\_s\right)\right]^\*\sum\_{m\_2=-l}^lA\_{m\_2m}^lZ\_l^{m\_2}\left(\theta\_f,\phi\_f\right) \\ & =\sum\_{m\_1=-l}^l\left[Z\_l^{m\_1}\left(\theta\_s,\phi\_s\right)\right]^\*\sum\_{m\_2=-l}^lZ\_l^{m\_2}\left(\theta\_f,\phi\_f\right)\delta\_{m\_2m\_1} \\ & =\sum\_{m\_1=-l}^l\left[Z\_l^{m\_1}\left(\theta\_s,\phi\_s\right)\right]^\*Z\_l^{m\_1}\left(\theta\_f,\phi\_f\right)\end{align}$$ This is good news because it means that we can use the $Y\_l^m$ basis to prove the spherical harmonic addition theorem, but then substitute a more convenient basis when it comes time to apply it. Now we have $$\begin{align}V\_{O\_h}\left(\vec{r\_f}\right) & =\int\_0^{r\_f}\int\_0^{\pi}\int\_0^{2\pi}\frac{\rho\left(\vec{r\_s}\right)}{4\pi\epsilon\_0}\sum\_{l=0}^{\infty}\frac{r\_s^l}{r\_f^{l+1}}\frac{4\pi}{2l+1}\sum\_{m=-l}^l\left[Y\_l^m\left(\theta\_s,\phi\_s\right)\right]^\*Y\_l^m\left(\theta\_f,\phi\_f\right)d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s \\ & +\int\_{r\_f}^{\infty}\int\_0^{\pi}\int\_0^{2\pi}\frac{\rho\left(\vec{r\_s}\right)}{4\pi\epsilon\_0}\sum\_{l=0}^{\infty}\frac{r\_f^l}{r\_s^{l+1}}\frac{4\pi}{2l+1}\sum\_{m=-l}^l\left[Y\_l^m\left(\theta\_s,\phi\_s\right)\right]^\*Y\_l^m\left(\theta\_f,\phi\_f\right)d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s\end{align}$$ We confine our interest to the region near the origin so $r\_s>r\_f$ and the first integral above will be zero. Also we are just trying to derive a formula for the splitting of the $d$ orbitals, so we cut our sums off at $l=4$. Only the $l=0$ and $l=4$ irreducible representations of the full rotation group have a partner that transforms as $A\_{1g}$ in $O\_h$ and we have those partners to hand at this point. Given the locations of the $6$ charges $-Ze$ at distance $a$ along the coordinate axes we can write $\rho\left(\vec{r\_s}\right)=-Ze\sum\limits\_{j=0}^5\delta^{(3)}\left(\vec{r\_s}-S\_6^j\langle0,0,a\rangle\right)$ where $S\_6$ is a $60Β°$ rotoreflection about the $[111]$ axis, so $$\begin{align}V\_{O\_h}\left(\vec{r\_f}\right) & =\int\_{r\_f}^{\infty}\int\_0^{\pi}\int\_0^{2\pi}\frac{-Ze}{\epsilon\_0}\frac1{r\_s}\sum\limits\_{j=0}^5\delta^{(3)}\left(\vec{r\_s}-S\_6^j\langle0,0,a\rangle\right)\left(\frac1{4\pi}\right)d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s \\ & +\int\_{r\_f}^{\infty}\int\_0^{\pi}\int\_0^{2\pi}\frac{-Ze}{\epsilon\_0}\frac{r\_f^4}{9r\_s^5}\sum\limits\_{j=0}^5\delta^{(3)}\left(\vec{r\_s}-S\_6^j\langle0,0,a\rangle\right)\left(\frac{525}{64\pi}\right)\times \\ & \frac1{r\_s^4}\left(x\_s^4+y\_s^4+z\_s^4-\frac35r\_s^4\right)\frac1{r\_f^4}\left(x\_f^4+y\_f^4+z\_f^4-\frac35r\_f^4\right)d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s \\ & =\frac{-Ze}{\epsilon\_0a}(6)\left(\frac1{4\pi}\right)-\frac{Zer\_f^4}{9\epsilon\_0a^5}(6)\left(\frac{525}{64\pi}\right)\frac25\frac1{r\_f^4}\left(x\_f^4+y\_f^4+z\_f^4-\frac35r\_f^4\right) \\ & =-\frac{6Ze}{4\pi\epsilon\_0a}-\frac{35Ze}{16\pi\epsilon\_0a^5}\left(x\_f^4+y\_f^4+z\_f^4-\frac35r\_f^4\right)\end{align}$$ In the above we used the $3$ dimensional Dirac delta functions to do all the integrals. An $A\_{1u}$ representation in $O\_h$ is $A+1$ for the $T\_d$ case, so we might want to consider such a multipole moment there. Looking for the stabilizer of $xyz$ in $T\_d$, we see that it's the whole group, so it already transforms as $A\_1$ in $T\_d$. It's also already orthogonal to $1$ so $xyz=cY\_{A\_11}^3$. Finding the magnitude, $$\begin{align}|c|^2 & =\oint\left|cY\_{A\_11}^3\right|^2d^2\Omega=\oint x^2y^2z^2d^2\Omega=\frac{2\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)}{\Gamma\left(\frac92\right)} \\ & =\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)}=\frac{4\pi}{105}\end{align}$$ So our normalized spherical harmonic is $$Y\_{A\_11}^3(\theta,\phi)=\left(\frac{105}{4\pi}\right)^{1/2}\frac{xyz}{r^3}$$ The charge distribution for $T\_d$ geometry is $$\rho\left(\vec{r\_s}\right)=-Ze\sum\_{j=0}^3\delta^{(3)}\left(\vec{r\_s}-S\_4^j\left\langle\frac a{\sqrt3},\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle\right)$$ Where $S\_4$ is a $90Β°$ rotoreflection about the $z$ axis. Making the same simplifications as for the $O\_h$ case, we have $$\begin{align}V\_{T\_d}\left(\vec{r\_f}\right) & =\int\_{r\_f}^{\infty}\int\_0^{\pi}\int\_0^{2\pi}\frac{-Ze}{\epsilon\_0}\frac1{r\_s}\sum\_{j=0}^3\delta^{(3)}\left(\vec{r\_s}-S\_4^j\left\langle\frac a{\sqrt3},\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle\right)\left(\frac1{4\pi}\right)d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s \\ & =\int\_{r\_f}^{\infty}\int\_0^{\pi}\int\_0^{2\pi}\frac{-Ze}{\epsilon\_0}\frac{r\_f^3}{7r\_s^4}\sum\_{j=0}^3\delta^{(3)}\left(\vec{r\_s}-S\_4^j\left\langle\frac a{\sqrt3},\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle\right)\left(\frac{105}{4\pi}\right)\times \\ & \frac{x\_sy\_sz\_s}{r\_s^3}\frac{x\_fy\_fz\_f}{r\_f^3}d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s \\ & +\int\_{r\_f}^{\infty}\int\_0^{\pi}\int\_0^{2\pi}\frac{-Ze}{\epsilon\_0}\frac{r\_f^4}{9r\_s^5}\sum\_{j=0}^3\delta^{(3)}\left(\vec{r\_s}-S\_4^j\left\langle\frac a{\sqrt3},\frac a{\sqrt3},\frac a{\sqrt3}\right\rangle\right)\left(\frac{525}{64\pi}\right)\times \\ & \frac1{r\_s^4}\left(x\_s^4+y\_s^4+z\_s^4-\frac35r\_s^4\right)\frac1{r\_f^4}\left(x\_f^4+y\_f^4+z\_f^4-\frac35r\_f^4\right)d\phi\_s\sin\theta\_sd\theta\_sr\_s^2dr\_s \\ & =\frac{-Ze}{\epsilon\_0a}(4)\left(\frac1{4\pi}\right)-\frac{Zer\_f^3}{7\epsilon\_0a^4}(4)\left(\frac{105}{4\pi}\right)\left(\frac1{3\sqrt3}\right)\frac{x\_fy\_fz\_f}{r\_f^3} \\ & -\frac{Zer\_f^4}{9\epsilon\_0a^5}(4)\left(\frac{525}{64\pi}\right)\left(\frac{-4}{15}\right)\frac1{r\_f^4}\left(x\_f^4+y\_f^4+z\_f^4-\frac35r\_f^4\right) \\ & =-\frac{4Ze}{4\pi\epsilon\_0a}-\frac{5Z}{\sqrt3\pi\epsilon\_0a^4e}x\_fy\_fz\_f+\frac{35Ze}{36\pi\epsilon\_0a^5}\left(x\_f^4+y\_f^4+z\_f^4-\frac35r\_f^4\right)\end{align}$$ So now we are ready to get our $d$ orbitals and compute the splitting. Starting with the $d\_{xy}$ orbital: $$\oint x^2y^2d^2\Omega = \frac{2\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)}=\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)}=\frac{4\pi}{15}$$ So the normalized $d\_{xy}$ orbital is $$\psi\_{xy}\left(\vec{r}\right)=\left(\frac{15}{4\pi}\right)^{1/2}\frac{xy}{r^2}f(r)$$ Where f(r) is assumed normalized to unity. We can compute $$\begin{align}U\_{O\_hxy} &=-e\int\left[\psi\_{xy}\left(\vec{r}\right)\right]^\*V\_{O\_h}\left(\vec{R}\right)\psi\_{xy}\left(\vec{r}\right)d^3volume \\ & =-e\oint\int\_0^{\infty}\left[-\frac{6Ze}{4\pi\epsilon\_0a}-\frac{35Ze}{16\pi\epsilon\_0a^5}\frac1{r^4}\times\right. \\ & \left.\left(x^4+y^4+z^4-\frac35r^4\right)r^4\right]\left(\frac{15}{4\pi}\right)\frac{x^2y^2}{r^4}|f(r)|^2r^2drd^2\Omega \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{35Ze^2}{16\pi\epsilon\_0a^5}\left\langle r^4\right\rangle\left(\frac{15}{4\pi}\right)\left[(2)\frac{2\Gamma\left(\frac72\right)\Gamma\left(\frac32\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac{11}2\right)}\right. \\ & \left.+\frac{2\Gamma\left(\frac52\right)\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)}{\Gamma\left(\frac{11}2\right)}-\frac35\frac{2\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)}\right] \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{525Ze^2}{64\pi^2\epsilon\_0a^5}\left\langle r^4\right\rangle\left[(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)\left(\frac92\right)}\right. \\ & \left.+\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)\left(\frac92\right)}-\frac35\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)}\right] \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}-\frac{Ze^2}{6\pi\epsilon\_0a^5}\left\langle r^4\right\rangle\end{align}$$ On to the $d\_{x^2-y^2}$ orbital: $$\begin{align}\oint \left(x^2-y^2\right)^2d^2\Omega &= (2)\frac{2\Gamma\left(\frac52\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)}-(2)\frac{2\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)} \\ & =(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)}-(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)}=\frac{16\pi}{15}\end{align}$$ So the normalized $d\_{x^2-y^2}$ orbital is $$\psi\_{x^2-y^2}\left(\vec{r}\right)=\left(\frac{15}{16\pi}\right)^{1/2}\frac{x^2-y^2}{r^2}f(r)$$ We have $$\begin{align}U\_{O\_hx^2-y^2} &=-e\int\left[\psi\_{x^2-y^2}\left(\vec{r}\right)\right]^\*V\_{O\_h}\left(\vec{R}\right)\psi\_{x^2-y^2}\left(\vec{r}\right)d^3volume \\ & =-e\oint\int\_0^{\infty}\left[-\frac{6Ze}{4\pi\epsilon\_0a}-\frac{35Ze}{16\pi\epsilon\_0a^5}\frac1{r^4}\times\right. \\ & \left.\left(x^4+y^4+z^4-\frac35r^4\right)r^4\right]\left(\frac{15}{16\pi}\right)\frac{\left(x^2-y^2\right)^2}{r^4}|f(r)|^2r^2drd^2\Omega \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{35Ze^2}{16\pi\epsilon\_0a^5}\left\langle r^4\right\rangle\left(\frac{15}{16\pi}\right)\left[(2)\frac{2\Gamma\left(\frac92\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac{11}2\right)}-(4)\frac{2\Gamma\left(\frac72\right)\Gamma\left(\frac32\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac{11}2\right)}\right. \\ & \left.+(4)\frac{2\Gamma\left(\frac52\right)\Gamma\left(\frac52\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac{11}2\right)}-(2)\frac{2\Gamma\left(\frac52\right)\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)}{\Gamma\left(\frac{11}2\right)}\right. \\ & \left.-\frac35(2)\frac{2\Gamma\left(\frac52\right)\Gamma\left(\frac12\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)}+\frac35(2)\frac{2\Gamma\left(\frac32\right)\Gamma\left(\frac32\right)\Gamma\left(\frac12\right)}{\Gamma\left(\frac72\right)}\right] \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{525Ze^2}{256\pi^2\epsilon\_0a^5}\left\langle r^4\right\rangle\left[(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)\left(\frac92\right)}\right. \\ & \left.-(4)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)\left(\frac92\right)}+(4)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)\left(\frac12\right)\left(\frac32\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)\left(\frac92\right)}\right. \\ & \left.-(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)\left(\frac72\right)\left(\frac92\right)}-\frac35(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac32\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)}\right. \\ & \left.+\frac35(2)\frac{2\pi^{3/2}\left(\frac12\right)\left(\frac12\right)}{\pi^{1/2}\left(\frac12\right)\left(\frac32\right)\left(\frac52\right)}\right] \\ & =\frac{6Ze^2}{4\pi\epsilon\_0a}+\frac{Ze^2}{4\pi\epsilon\_0a^5}\left\langle r^4\right\rangle\end{align}$$ With $$Dq=\left(\frac{35Ze}{16\pi\epsilon\_0a^5}\right)\left(\frac{2e}{105}\right)\left\langle r^4\right\rangle=\frac{Ze^2}{24\pi\epsilon\_0a^5}\left\langle r^4\right\rangle$$ We see that $$U\_{O\_hxy}=\frac{6Ze^2}{4\pi\epsilon\_0a}-4Dq$$ and $$U\_{O\_hx^2-y^2}=\frac{6Ze^2}{4\pi\epsilon\_0a}+6Dq$$ For the $T\_d$ case, the $Y\_{A\_11}^3$ multipole moment won't contribute to $U\_{T\_dxy}$ or $U\_{T\_dx^2-y^2}$ because it has odd parity and we have done the other hard integrals already, so $$U\_{T\_dxy}=\frac{4Ze^2}{4\pi\epsilon\_0a}-4\left(-\frac49\right)Dq=\frac{4Ze^2}{4\pi\epsilon\_0a}+\frac{16}9Dq$$ and $$U\_{T\_dx^2-y^2}=\frac{4Ze^2}{4\pi\epsilon\_0a}+6\left(-\frac49\right)Dq=\frac{4Ze^2}{4\pi\epsilon\_0a}-\frac83Dq$$
26,632,644
I am newbie to java db coding... This is my java code ``` Connection conn = null; Statement stmt = null; Class.forName("com.mysql.jdbc.Driver"); System.out.println("Connecting to database..."); conn = DriverManager.getConnection("jdbc:mysql://localhost/EMP",USER,PASS); System.out.println("Creating statement..."); stmt = conn.createStatement(); String sql; ``` This is the exception I am getting : ``` ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tiles].[default]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet default threw exception: java.net.ConnectException: Connection refused: connect ``` I am mySQL server also running and contains simple table named EMP. I am not interpreting the get connection URL comppletely. Can anyone explain it briefly? Thanks.
2014/10/29
[ "https://Stackoverflow.com/questions/26632644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079065/" ]
You are using the wrong driver for the database. Every database (MySQL, PostgreSQL, SQL Server, Oracle etc.) has a different driver which is what connects between JDBC and the particular database's communication protocol. You need the Microsoft SQL Server driver. You can download and install it from here if you don't already have it: [Microsoft down page for JDBC 4.0 driver](http://www.microsoft.com/en-us/download/details.aspx?id=11774). And here are the [instructions](http://technet.microsoft.com/en-us/library/ms378526%28v=sql.110%29.aspx) on how to add the jar to your classpath, and what URL to use. Note that in JDBC 4.0 and above, the `forName` is not necessary anymore.
from what i can see and understand is that you're missing the port. you'd have done it in this way: conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/EMP",USER,PASS); The url can be describe in this way jdbc: which is your connector mysql:which is your current installed database //hostname: which the machine hosting the server portNumber: the port which allows the connection for the server /databaseName: which is your created database. hope it was helpful
26,632,644
I am newbie to java db coding... This is my java code ``` Connection conn = null; Statement stmt = null; Class.forName("com.mysql.jdbc.Driver"); System.out.println("Connecting to database..."); conn = DriverManager.getConnection("jdbc:mysql://localhost/EMP",USER,PASS); System.out.println("Creating statement..."); stmt = conn.createStatement(); String sql; ``` This is the exception I am getting : ``` ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tiles].[default]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet default threw exception: java.net.ConnectException: Connection refused: connect ``` I am mySQL server also running and contains simple table named EMP. I am not interpreting the get connection URL comppletely. Can anyone explain it briefly? Thanks.
2014/10/29
[ "https://Stackoverflow.com/questions/26632644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079065/" ]
You are using the wrong driver for the database. Every database (MySQL, PostgreSQL, SQL Server, Oracle etc.) has a different driver which is what connects between JDBC and the particular database's communication protocol. You need the Microsoft SQL Server driver. You can download and install it from here if you don't already have it: [Microsoft down page for JDBC 4.0 driver](http://www.microsoft.com/en-us/download/details.aspx?id=11774). And here are the [instructions](http://technet.microsoft.com/en-us/library/ms378526%28v=sql.110%29.aspx) on how to add the jar to your classpath, and what URL to use. Note that in JDBC 4.0 and above, the `forName` is not necessary anymore.
Download the Microsoft JDBC driver and use `Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);` If the problem still persists enable TCP/IP network protocol, which is disabled by default, and set the TCP/IP port to 1433 which is the default port number.
26,632,644
I am newbie to java db coding... This is my java code ``` Connection conn = null; Statement stmt = null; Class.forName("com.mysql.jdbc.Driver"); System.out.println("Connecting to database..."); conn = DriverManager.getConnection("jdbc:mysql://localhost/EMP",USER,PASS); System.out.println("Creating statement..."); stmt = conn.createStatement(); String sql; ``` This is the exception I am getting : ``` ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tiles].[default]] (http-localhost-127.0.0.1-8080-1) Servlet.service() for servlet default threw exception: java.net.ConnectException: Connection refused: connect ``` I am mySQL server also running and contains simple table named EMP. I am not interpreting the get connection URL comppletely. Can anyone explain it briefly? Thanks.
2014/10/29
[ "https://Stackoverflow.com/questions/26632644", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1079065/" ]
from what i can see and understand is that you're missing the port. you'd have done it in this way: conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/EMP",USER,PASS); The url can be describe in this way jdbc: which is your connector mysql:which is your current installed database //hostname: which the machine hosting the server portNumber: the port which allows the connection for the server /databaseName: which is your created database. hope it was helpful
Download the Microsoft JDBC driver and use `Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);` If the problem still persists enable TCP/IP network protocol, which is disabled by default, and set the TCP/IP port to 1433 which is the default port number.
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Suppose we have some scalars $a\_0,a\_1,a\_2$ in $\Bbb R$ such that $$a\_0t+a\_1e^t+a\_2\sin t =0 \tag{1}$$ for all real number $t$. Making $t=0$ this gives us $a\_1=0$. Returning to $(1)$, we have $$a\_0t+a\_2\sin t =0 \tag{2}$$ Now, make $t=\pi$ and then $a\_0\pi=0$, which means $a\_0=0$.
*Hint.* Write one as a linear combination of the others. That is, look for real numbers $a,b,c$ not simultaneously vanishing, so that we may write $$at+be^t+c\sin t=0.$$
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Suppose we have some scalars $a\_0,a\_1,a\_2$ in $\Bbb R$ such that $$a\_0t+a\_1e^t+a\_2\sin t =0 \tag{1}$$ for all real number $t$. Making $t=0$ this gives us $a\_1=0$. Returning to $(1)$, we have $$a\_0t+a\_2\sin t =0 \tag{2}$$ Now, make $t=\pi$ and then $a\_0\pi=0$, which means $a\_0=0$.
HINT.- A good way to try this problem is to consider that the elements of $V$ are $f\_1,f\_2,f\_3$ where $f\_1(t)=t,f\_2(t)=e^t,f\_3(t)=\sin(t)$ so you have to show that if the linear combination $$a\_1f\_1+a\_2f\_2+a\_3f\_3=0$$ where les $f\_i$ are three vectors and les $a\_i$ are scalars in your vectorial space, then $a\_1=a\_2=a\_3=0$ (Obviously for each $t$ you have $$(a\_1f\_1+a\_2f\_2+a\_3f\_3)(t)=a\_1f\_1(t)+a\_2f\_2(t)+a\_3f\_3(t)=0)$$
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Here is a another way to skin the cat: Suppose $\alpha\_1 t + \alpha\_2 e^t + \alpha\_3 \sin t = 0$ for all $t$. If we differentiate twice and set $t = 0$, we get $\alpha\_2 e^{\pi \over 2} = 0$ and so $\alpha\_2 = 0$. If we differentiate twice and set $t = -{\pi \over 2}$, we get $\alpha\_3 = 0$. Finally, set $t=1$ to get $\alpha\_1 = 0$. Hence $S$ is linearly independent.
Suppose we have some scalars $a\_0,a\_1,a\_2$ in $\Bbb R$ such that $$a\_0t+a\_1e^t+a\_2\sin t =0 \tag{1}$$ for all real number $t$. Making $t=0$ this gives us $a\_1=0$. Returning to $(1)$, we have $$a\_0t+a\_2\sin t =0 \tag{2}$$ Now, make $t=\pi$ and then $a\_0\pi=0$, which means $a\_0=0$.
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Suppose we have some scalars $a\_0,a\_1,a\_2$ in $\Bbb R$ such that $$a\_0t+a\_1e^t+a\_2\sin t =0 \tag{1}$$ for all real number $t$. Making $t=0$ this gives us $a\_1=0$. Returning to $(1)$, we have $$a\_0t+a\_2\sin t =0 \tag{2}$$ Now, make $t=\pi$ and then $a\_0\pi=0$, which means $a\_0=0$.
Also you may find if $$\begin{vmatrix} f\_1(t) & f\_2(t) & f\_3(t) \\ f\_1'(t) & f\_2'(t) & f\_3'(t)\\ f\_1''(t) & f\_2''(t) & f\_3''(t)\end{vmatrix}= 0,$$ then the three functions are linearly dependent (LD) otherwise they are linearly independent (LI).
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Here is a another way to skin the cat: Suppose $\alpha\_1 t + \alpha\_2 e^t + \alpha\_3 \sin t = 0$ for all $t$. If we differentiate twice and set $t = 0$, we get $\alpha\_2 e^{\pi \over 2} = 0$ and so $\alpha\_2 = 0$. If we differentiate twice and set $t = -{\pi \over 2}$, we get $\alpha\_3 = 0$. Finally, set $t=1$ to get $\alpha\_1 = 0$. Hence $S$ is linearly independent.
*Hint.* Write one as a linear combination of the others. That is, look for real numbers $a,b,c$ not simultaneously vanishing, so that we may write $$at+be^t+c\sin t=0.$$
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Here is a another way to skin the cat: Suppose $\alpha\_1 t + \alpha\_2 e^t + \alpha\_3 \sin t = 0$ for all $t$. If we differentiate twice and set $t = 0$, we get $\alpha\_2 e^{\pi \over 2} = 0$ and so $\alpha\_2 = 0$. If we differentiate twice and set $t = -{\pi \over 2}$, we get $\alpha\_3 = 0$. Finally, set $t=1$ to get $\alpha\_1 = 0$. Hence $S$ is linearly independent.
HINT.- A good way to try this problem is to consider that the elements of $V$ are $f\_1,f\_2,f\_3$ where $f\_1(t)=t,f\_2(t)=e^t,f\_3(t)=\sin(t)$ so you have to show that if the linear combination $$a\_1f\_1+a\_2f\_2+a\_3f\_3=0$$ where les $f\_i$ are three vectors and les $a\_i$ are scalars in your vectorial space, then $a\_1=a\_2=a\_3=0$ (Obviously for each $t$ you have $$(a\_1f\_1+a\_2f\_2+a\_3f\_3)(t)=a\_1f\_1(t)+a\_2f\_2(t)+a\_3f\_3(t)=0)$$
3,367,553
Is $S$ linearly dependent on $\textsf V = \mathcal{F}(\Bbb R,\Bbb R)$ and $S = \{t, e^t ,\sin(t)\}$. How to prove that a set of functions are linearly dependent?
2019/09/24
[ "https://math.stackexchange.com/questions/3367553", "https://math.stackexchange.com", "https://math.stackexchange.com/users/708009/" ]
Here is a another way to skin the cat: Suppose $\alpha\_1 t + \alpha\_2 e^t + \alpha\_3 \sin t = 0$ for all $t$. If we differentiate twice and set $t = 0$, we get $\alpha\_2 e^{\pi \over 2} = 0$ and so $\alpha\_2 = 0$. If we differentiate twice and set $t = -{\pi \over 2}$, we get $\alpha\_3 = 0$. Finally, set $t=1$ to get $\alpha\_1 = 0$. Hence $S$ is linearly independent.
Also you may find if $$\begin{vmatrix} f\_1(t) & f\_2(t) & f\_3(t) \\ f\_1'(t) & f\_2'(t) & f\_3'(t)\\ f\_1''(t) & f\_2''(t) & f\_3''(t)\end{vmatrix}= 0,$$ then the three functions are linearly dependent (LD) otherwise they are linearly independent (LI).
16,917,821
I'm trying to implement simple ScopedExit class. Here's the code: ``` #include <iostream> #include <functional> template<class R, class... Args> class ScopedExit { public: ScopedExit(std::function<R(Args...)> exitFunction) { exitFunc_ = exitFunction; } ~ScopedExit() { exitFunc_(); } private: std::function<R(Args...)> exitFunc_; }; template<> class ScopedExit<void> { public: ScopedExit(std::function<void ()> exitFunction) { exitFunc_ = exitFunction; } ~ScopedExit() { exitFunc_(); } private: std::function<void ()> exitFunc_; }; void foo() { std::cout << "foo() called\n"; } class Bar { public: void BarExitFunc(int x, int y) { std::cout << "BarExitFunc called with x =" << x << "y = " << y << "\n"; } }; int main() { Bar b; std::cout << "Register scoped exit func\n"; { ScopedExit<void, int, int> exitGuardInner(std::bind(&Bar::BarExitFunc, &b, 18, 11)); } ScopedExit exitGuardOutter(foo); std::cout << "About to exit from the scope\n"; return 0; } ``` So, there are a couple of questions: 1. How to pass exit's function arguments to it? For example, I bind BarExitFunc with two integer arguments: 18 and 11. So how can I pass it to the exitFunc\_ in the destructor? I think I need something like invoke function with std::forward<>. 2. gcc 4.7.2 (from ideone.com) complains about exitGuardOutter. It says: > > prog.cpp:60:16: error: missing template arguments before β€˜exitGuardOutter’ > > > prog.cpp:60:16: error: expected β€˜;’ before β€˜exitGuardOutter’ > > > Thanks in advance.
2013/06/04
[ "https://Stackoverflow.com/questions/16917821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/644350/" ]
> > How to pass exit's function arguments to it? For example, I bind BarExitFunc with two integer arguments: 18 and 11. So how can I pass it to the exitFunc\_ in the destructor? > > > I can see no reason whatsoever to pass arguments to `exitFunc_` at call time in the destructor. Whatever you do, you'll have to provide those arguments upfront in the `ScopedExit` constructor anyway. The most straightforward way is simply to use a `function<R()>` and `bind` any required arguments at the definition site like you're already doing: ``` ScopedExit<R> guard(std::bind(someFunction, someArg, otherArg)); ``` This allows you to get rid of the variadic template arguments altogether and simplifies your template *a lot*. --- Now, if what is bothering you is that you have to type `std::bind` and you would rather use such a syntax: ``` ScopedExit<R> guard(someFunction, someArg, otherArg); ``` Really, I don't see the point since it makes the template more complicated, but why not... Just bind/forward the arguments in the constructor itself and still store a `function<R()>`: ``` template<typename... Args> ScopedExit(std::function<R(Args...)> exitFunction, Args&&... args) { exitFunc_ = std::bind(exitFunction, std::forward<Args>(args)...); } ``` Now you systematically `bind` the function even if there are no arguments to bind, so you may want to specialize your class to avoid this useless `bind` when there are no arguments. This is left as an exercise. --- > > gcc 4.7.2 (from ideone.com) complains about exitGuardOutter > > > This is because `foo` isn't a `std::function` and the compiler can't deduce the correct template arguments. As already mentioned by @ForEveR you could just define your guard variable as `ScopedExit<void> guard(foo);`. Or, **wrapping it all up** and keeping in mind what I first said (`bind` is best left out of your template and used at the definition site of your guard) you could just get rid of `std::function` in the constructor and generalize for any functor (which, BTW, is how the Standard library does whenever it needs a functor/callback). For storage you can just use `std::function<void()>` since it accepts non-void return types too: ``` class ScopedExit { public: template<typename Functor> ScopedExit(Functor exitFunction) { exitFunc_ = exitFunction; } ~ScopedExit() { exitFunc_(); } private: std::function<void()> exitFunc_; }; int foo() { return 0; } struct Bar { void bye(int, int) {} }; struct Baz { void operator ()() {} }; int main() { const std::string what = "lambda!"; ScopedExit guard1([&]() { std::cout << "yay a " << what << std::endl; }); ScopedExit guard2(foo); // note how std::function<void()> accepts non-void return types Bar b; ScopedExit guard3(std::bind(&Bar::bye, &b, 1, 2)); ScopedExit guard4(Baz()); } ``` Note how your original variadic template class has now become a flexible non-template class with just a templated constructor whose template argument is deduced automatically, and which accepts almost[see note below] any kind of functor you can think about. --- **Note:** I said *almost* any functor because this doesn't work with default arguments: ``` void foobar(int = 0) {} ScopedExit guard5(foobar); // error: too few arguments to function ``` Even if you stored a `Functor` directly instead of a `std::function<void()>` you wouldn't be able to make use of the default arguments anyway (the signature of `foobar` is still `void(int)` even with a default argument) so one always has to handle this corner-case at the definition site with something like: ``` void foobar(int = 0) {} ScopedExit guard5([]() { foobar(); }); ```
1) You can save arguments in `tuple` for example. However, in your case, you can simply call `exitFunc_()` and function definition should be `std::function<R()> exitFunction` since you already bind arguments to function. Something like this probably ``` #include <iostream> #include <functional> #include <tuple> template<size_t...> struct indices {}; template<size_t N, size_t... Is> struct gen_indices : gen_indices<N - 1, N - 1, Is...> { }; template<size_t... Is> struct gen_indices<0, Is...> : indices<Is...> { }; template<class R, class... Args> class ScopedExit { public: ScopedExit(std::function<R(Args...)> exitFunction, Args&&... args) : arguments_(std::forward_as_tuple(args...)) { exitFunc_ = exitFunction; } ~ScopedExit() { call(gen_indices<sizeof...(Args)>()); } private: template<size_t... Idx> void call(indices<Idx...>) { exitFunc_(std::forward<Args>(std::get<Idx>(arguments_))...); } std::tuple<Args...> arguments_; std::function<R(Args...)> exitFunc_; }; template<> class ScopedExit<void> { public: ScopedExit(std::function<void ()> exitFunction) { exitFunc_ = exitFunction; } ~ScopedExit() { exitFunc_(); } private: std::function<void ()> exitFunc_; }; void foo() { std::cout << "foo() called\n"; } class Bar { public: void BarExitFunc(int x, int y) { std::cout << "BarExitFunc called with x =" << x << "y = " << y << "\n"; } }; int main() { Bar b; std::cout << "Register scoped exit func\n"; { ScopedExit<void, int, int> exitGuardInner ( std::bind(&Bar::BarExitFunc, &b, std::placeholders::_1, std::placeholders::_2), 10, 18 ); } ScopedExit<void> exitGuardOutter(foo); std::cout << "About to exit from the scope\n"; return 0; } ``` 2) Should be created like `ScopedExit<void>`.
656,271
I am using Bluez bluetooth Manager, after I send the files from my Android device to the Laptop which contains Linux Mate with the standard File System. I cannot seem to find the files which a received in this manner. The Bluez documentation does not specify where do these files go.
2015/08/04
[ "https://askubuntu.com/questions/656271", "https://askubuntu.com", "https://askubuntu.com/users/431035/" ]
Grub allows you to password protect its config and console, as well as individual operating system entries. Please note that this *will not* stop dedicated individuals, especially the ones that know what they are doing. But I assume you know that. Lets get started. generate a password hash.. -------------------------- You could store your grub password in plain text but that is entirely insecure and anyone that had access to your account could quickly figure it out. To prevent this we hash the password using the `grub-mkpasswd-pbkdf2` command, like so: ``` user@host~ % grub-mkpasswd-pbkdf2 Enter password: Reenter password: PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.63553D205CF6E... ``` While you type your password no characters will show in the terminal, this is to prevent people looking over your shoulders, etc. Now, copy the entirety of your hash with `Ctrl`+`Shift`+`C`. protecting the config, console.. -------------------------------- Run: ``` sudo nano /etc/grub.d/40_custom ``` This will create a new configuration file called `40_custom` in grub's configuration directory. Now add the lines: ``` set superusers="username" password_pbkdf2 username hash ``` Where `username` is a username of your choice and `hash` is the hash we generated in the last command. Press `Ctrl`+`O` and then `Ctrl`+`X` to save and quit. Run: ``` sudo update-grub ``` To finalize the changes. Now, when anyone attempts to edit the grub configuration or access a grub console it will prompt them for a username and password. password protecting operating system entries.. ---------------------------------------------- Currently the only method to achieve this I can find is to edit the `/boot/grub/grub.cfg` manually. This is only temporary however as any new kernel update will rewrite this file and your passwords will be gone (note that this doesn't effect the console/editing password we set above). All other methods I have found so far are extremely out of date and I can no longer get them to work. I've asked the grub mailing list if there is a newer method and will edit this answer as soon as I find out.
The GRUB manual has a section about [security](http://www.gnu.org/software/grub/manual/grub.html#Security). This tells you how to password protect your GRUB boot menu to restrict access to specific operations or boot variants. It contains a small example.
2,793,312
When we use the cylindrical coordinate system $(r, \theta, z)$ where $r$ is the distance from the point in the $xy$-plane, $\theta$ is the angle with the $x$ axis and $z$ is the heigth. As can been seen in the picture [![enter image description here](https://i.stack.imgur.com/lKIQb.png)](https://i.stack.imgur.com/lKIQb.png) I hav a vector field described by $(0,U\_{\theta}(r),U\_z)$ but how can the angle differ when $r$ is always zero? When $r$ is zero, then there is no difference between different angles. Or am i wrong? Some help would be great.
2018/05/23
[ "https://math.stackexchange.com/questions/2793312", "https://math.stackexchange.com", "https://math.stackexchange.com/users/221950/" ]
**Hint:** You discover the rules by working backwards. First consider polynomials, say of the third degree, like $ax^3+bx^2+cx+d$. The first derivative is a second degree polynomial, so that the LHS of a first order equation would yield $$\alpha y+\beta y'=\alpha ax^3+(\alpha b+3\beta a)x^2+(\alpha c+2\beta b)x+(\alpha d+\beta c),$$ another cubic polynomial. Similarly, $$\alpha y+\beta y'+\gamma y''=\alpha ax^3+(\alpha b+3\beta a)x^2+(\alpha c+2\beta b+6\gamma c)x+(\alpha d+\beta c+2\gamma b)$$ also third degree. Now it is clear that for a linear equation of any degree, if the RHS is a polynomial of degree $d$, there will be another polynomial of degree $d$ which is a solution. --- For an exponential function, $e^{ax}$, $$\alpha y+\beta y'+\gamma y''=(\alpha +\beta a+\gamma a^2)e^{ax}$$ so that an exponential RHS is obtained from an exponential solution. --- You can play the same game with RHS of the form $e^{ax}\sin bx$ and $e^{ax}\cos bx$. If you are familiar with complex numbers, you can even take a shortcut by considering $e^{(a+ib)x}$, which combines the two functions in one.
$$y'''(x)-2y''(x)+y'(x)=x+2$$ It's easy to determine the exponent of the function try to substitute $y=z+ax^n$ $$y'''+.............+y'=x+2$$ $$(z'''+....)+..............+(z'+nax^{n-1})=x+2$$ for y' we get the highest monomial degree in x so it must be equal to the degre of x on right side $$x^{n-1}=x \implies n=2$$ So you have to try a polynomial of degree two $$ax^2+bx+c$$ You observe that you have only derivatives on the left side so $c=0$ And $ax^2+bx$ is the right choice...
477,931
How can I create a table like this in Latex? [![enter image description here](https://i.stack.imgur.com/4MYki.png)](https://i.stack.imgur.com/4MYki.png) I have tried but it didn't work. I need also that it is enumerated so that it appears in the List of Tables. It doesn't matter if it is not coloured, as long as the first two rows are bold. ``` \begin{center} \begin{tabular}{ |c|c|c|c|c| } \hline \multicolumn{5}{|c|}{Number of cells per type} \\ \hline a& b& c& d& e\\ \hline 44 & 39 & 7 & 32 &22 \\ \hline \end{tabular} \end{center} ```
2019/03/05
[ "https://tex.stackexchange.com/questions/477931", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/182855/" ]
I suggest you to use `booktabs` for professional tables. ``` \documentclass[11pt,openright]{book} \usepackage{array} \newcolumntype{C}{>{\centering\arraybackslash}X} \renewcommand{\arraystretch}{1.2} \usepackage{booktabs} \usepackage{tabularx} \usepackage{caption} \begin{document} \listoftables \chapter{My chapter} \begin{table}[htb]\centering \caption{Your table\label{tab:yourtab}} \begin{tabularx}{.5\linewidth}{ |C|C|C|C|C| } \hline \multicolumn{5}{|c|}{\bfseries Number of cells per type} \\ \hline \bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\ \hline 44 & 39 & 7 & 32 &22 \\ \hline \end{tabularx} \end{table} \begin{table}[htb]\centering \caption{My suggestion\label{tab:mytab}} \begin{tabularx}{.5\linewidth}{*5C} \toprule \multicolumn{5}{c}{\bfseries Number of cells per type} \\ \midrule \bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\ \midrule 44 & 39 & 7 & 32 &22 \\ \bottomrule \end{tabularx} \end{table} \end{document} ``` [![enter image description here](https://i.stack.imgur.com/7IC07.png)](https://i.stack.imgur.com/7IC07.png) [![enter image description here](https://i.stack.imgur.com/eg5I0.png)](https://i.stack.imgur.com/eg5I0.png)
A mix-and-match with colors and using something as a starting point ``` \documentclass[10pt,a4paper]{article} \usepackage[table,xcdraw]{xcolor} \begin{document} \listoftables\newpage \begin{table}[] \begin{tabular}{!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}l!{\color{cyan}\vrule}} \arrayrulecolor{cyan}\hline \rowcolor[HTML]{38FFF8} \multicolumn{5}{!{\color{cyan}\vrule}l!{\color{cyan}\vrule}}{\cellcolor[HTML]{38FFF8}Number of cells per type} \\ \arrayrulecolor{cyan}\hline \rowcolor[HTML]{38FFF8} a & b & c & d & e \\ \arrayrulecolor{cyan}\hline 1 & 2 & 3 & 4 & 5 \\ \hline \end{tabular} \caption{a} \end{table} \end{document} ``` to get: [![enter image description here](https://i.stack.imgur.com/jIr7C.png)](https://i.stack.imgur.com/jIr7C.png) [![enter image description here](https://i.stack.imgur.com/Io68R.png)](https://i.stack.imgur.com/Io68R.png) PS: Feel free to play with colors (I right now, do not have the necessary things to find out the colors) and I was lazy enough not to input your numbers (sorry `;-)`)
477,931
How can I create a table like this in Latex? [![enter image description here](https://i.stack.imgur.com/4MYki.png)](https://i.stack.imgur.com/4MYki.png) I have tried but it didn't work. I need also that it is enumerated so that it appears in the List of Tables. It doesn't matter if it is not coloured, as long as the first two rows are bold. ``` \begin{center} \begin{tabular}{ |c|c|c|c|c| } \hline \multicolumn{5}{|c|}{Number of cells per type} \\ \hline a& b& c& d& e\\ \hline 44 & 39 & 7 & 32 &22 \\ \hline \end{tabular} \end{center} ```
2019/03/05
[ "https://tex.stackexchange.com/questions/477931", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/182855/" ]
I suggest you to use `booktabs` for professional tables. ``` \documentclass[11pt,openright]{book} \usepackage{array} \newcolumntype{C}{>{\centering\arraybackslash}X} \renewcommand{\arraystretch}{1.2} \usepackage{booktabs} \usepackage{tabularx} \usepackage{caption} \begin{document} \listoftables \chapter{My chapter} \begin{table}[htb]\centering \caption{Your table\label{tab:yourtab}} \begin{tabularx}{.5\linewidth}{ |C|C|C|C|C| } \hline \multicolumn{5}{|c|}{\bfseries Number of cells per type} \\ \hline \bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\ \hline 44 & 39 & 7 & 32 &22 \\ \hline \end{tabularx} \end{table} \begin{table}[htb]\centering \caption{My suggestion\label{tab:mytab}} \begin{tabularx}{.5\linewidth}{*5C} \toprule \multicolumn{5}{c}{\bfseries Number of cells per type} \\ \midrule \bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\ \midrule 44 & 39 & 7 & 32 &22 \\ \bottomrule \end{tabularx} \end{table} \end{document} ``` [![enter image description here](https://i.stack.imgur.com/7IC07.png)](https://i.stack.imgur.com/7IC07.png) [![enter image description here](https://i.stack.imgur.com/eg5I0.png)](https://i.stack.imgur.com/eg5I0.png)
Don't mix-and-mismatch visual cues and metaphores: if you employ colored rows, don't employ horizontal rules. And, for sure, you can omit all vertical rules -- they're not needed. [![enter image description here](https://i.stack.imgur.com/uJel3.png)](https://i.stack.imgur.com/uJel3.png) ``` \documentclass{article} \usepackage[table,svgnames]{xcolor} \usepackage{array} % for '\extrarowheight' macro \begin{document} \begin{center} \sffamily \setlength\extrarowheight{2pt} % optional \setlength\tabcolsep{9pt} % default: 6pt \begin{tabular}{ ccccc } %\hline \rowcolor{LightBlue} \multicolumn{5}{c}{Number of cells per type} \\ %\hline \rowcolor{LightBlue} a & b & c & d & e\\ %\hline 44 & 39 & 7 & 32 & 22 \\ \hline \end{tabular} \end{center} \end{document} ```
477,931
How can I create a table like this in Latex? [![enter image description here](https://i.stack.imgur.com/4MYki.png)](https://i.stack.imgur.com/4MYki.png) I have tried but it didn't work. I need also that it is enumerated so that it appears in the List of Tables. It doesn't matter if it is not coloured, as long as the first two rows are bold. ``` \begin{center} \begin{tabular}{ |c|c|c|c|c| } \hline \multicolumn{5}{|c|}{Number of cells per type} \\ \hline a& b& c& d& e\\ \hline 44 & 39 & 7 & 32 &22 \\ \hline \end{tabular} \end{center} ```
2019/03/05
[ "https://tex.stackexchange.com/questions/477931", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/182855/" ]
I suggest you to use `booktabs` for professional tables. ``` \documentclass[11pt,openright]{book} \usepackage{array} \newcolumntype{C}{>{\centering\arraybackslash}X} \renewcommand{\arraystretch}{1.2} \usepackage{booktabs} \usepackage{tabularx} \usepackage{caption} \begin{document} \listoftables \chapter{My chapter} \begin{table}[htb]\centering \caption{Your table\label{tab:yourtab}} \begin{tabularx}{.5\linewidth}{ |C|C|C|C|C| } \hline \multicolumn{5}{|c|}{\bfseries Number of cells per type} \\ \hline \bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\ \hline 44 & 39 & 7 & 32 &22 \\ \hline \end{tabularx} \end{table} \begin{table}[htb]\centering \caption{My suggestion\label{tab:mytab}} \begin{tabularx}{.5\linewidth}{*5C} \toprule \multicolumn{5}{c}{\bfseries Number of cells per type} \\ \midrule \bfseries a& \bfseries b& \bfseries c& \bfseries d& \bfseries e\\ \midrule 44 & 39 & 7 & 32 &22 \\ \bottomrule \end{tabularx} \end{table} \end{document} ``` [![enter image description here](https://i.stack.imgur.com/7IC07.png)](https://i.stack.imgur.com/7IC07.png) [![enter image description here](https://i.stack.imgur.com/eg5I0.png)](https://i.stack.imgur.com/eg5I0.png)
There is also a really handy online tool called [Tables Generator](https://www.tablesgenerator.com/). It lets you input your data (you can even upload it from file), and adapt it WYSIWYG-style. It will then generate the correct LaTeX code for you to copy/paste into you document. Edit: As suggested by Sanctus, here is the code that Tables Generator output me (after 2 minutes of data entry). It does give really nice results for relatively simple tables with standard settings (colors, borders, font style, etc), but if you need something fancy, it probably won't provide enough. But I always use it as a starting point, to get the general structure working. Everything else I can then adapt myself. ``` \documentclass{article} \usepackage[table,xcdraw]{xcolor} \usepackage{graphicx} \usepackage{booktabs} \begin{document} % Please add the following required packages to your document preamble: % \usepackage[table,xcdraw]{xcolor} % If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer} \begin{table}[] \begin{tabular}{|c|c|c|c|c|} \hline \rowcolor[HTML]{DAE8FC} \multicolumn{5}{|c|}{\cellcolor[HTML]{DAE8FC}\textbf{\tiny{Number of cells per type}}} \\ \hline \rowcolor[HTML]{DAE8FC} \textbf{a} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{e} \\ \hline 44 & 39 & 7 & 32 & 22 \\ \hline \end{tabular} \end{table} \end{document} ``` [![Output Table](https://i.stack.imgur.com/fHS6h.png)](https://i.stack.imgur.com/fHS6h.png)
923,813
Show that it is not true in general that (i) for any sets A,B, one has P(A union B) is a subset of P(A) union P(B) Show that it is true in general that (ii) for any sets A , B , one has P(A) union P(B) is a subset of P(A union B). For part (i) and part (ii), can you help me verify my proof? i didnt use elements for my answers as the question is to show in general so i did it this way. (i) For any sets A , B , Consider the case A is not a subset of B. Then , A union B will have more elements than A and more elements than B. Hence the power set of A union B will contain a set that has more elements than A or B. Hence, P(A union B) is not a subset of P(A) union P(B). (ii) I got 4 cases to consider. Consider both the case A is not a subset of B and A is not equal to B. Then, both cases will have the same argument that A union B will have more elements than A and more elements than B. Hence, the power set of (A union B) will contain a set that has more elements than A or B. Hence, P(A) union P(B) is a subset of P(A union B). Consider the case A is a subset of B. If A is a subset of B, thus A union B = B. Therefore, all the elements in A union B will be inside B. Thus the power set of (A union B) will be the same as the power set of B. Also since A is a subset of B, elements in A will be in B as well. Therefore, Power set of A is a subset of Power set of B. Since Power set of A is a subset of Power set of B, power set of (A union B) equals to power set of B, thus, P(A U B) = P(B) = P(A) U P(B), hence P(A) U P(B) is a subset of P(A U B). Consider the case B is a subset of A. If B is a subset of A, thus A U B = A. Therefore all the elements in A U B will be in A. Thus the power set of ( A U B ) will be the same as P ( A ). Also , since B is a subset of A, elements in B will be in A as well. Therefore, P( B ) is a subset of P ( A ). Since P(B) is a subset of P(A), P(A) U P(B) = P(A). Thus, P(A U B) = P(A) = P(A) U P(B), hence P(A) U P(B) is a subset of P(A U B). *Do i need to consider the case of null sets?*
2014/09/08
[ "https://math.stackexchange.com/questions/923813", "https://math.stackexchange.com", "https://math.stackexchange.com/users/174559/" ]
Easier way to prove part two: set inclusion. The proof is mostly definition chasing. Let $S \in \mathbf{P}[A]\cup \mathbf{P}[B]$. Then either $S \subseteq A$ or $S \subseteq B$. In either case, $S \in \mathbf{P}[A \cup B]$ by noting that $$S \subseteq A \implies S \subseteq A \cup B \implies S \in \mathbf{P}[A \cup B]$$ And symmetrically for $S \subseteq B$.
We have $A\cup B\in\wp\left(A\cup B\right)$. However $A\cup B\in\wp\left(A\right)\cup\wp\left(B\right)$ is true if and only if $A\cup B\subseteq A$ or $A\cup B\subseteq B$. If $A-B$ and $B-A$ are both non-empty then this is not the case. This proves that (i) is not true in general. --- $X\in\wp\left(A\right)\cup\wp\left(B\right)$ is true if and only if $X$ is a subset of $A$ or a subset of $B$. In both cases $X$ is a subset of $A\cup B$ as well, i.e. $X\in\wp\left(A\cup B\right)$. This proves that (ii) is true in general.
26,017,705
I have an azure website and database. I'm running an ASP.NET MVC 4 / EF 5 app localy and trying to put some data to the azure database before to deploy the app. But I have a TargetInvocationException : {"The ASP.NET Simple Membership database could not be initialized. For more information, please see <http://go.microsoft.com/fwlink/?LinkId=256588>"} Keyword not supported : server This is the connection string that I get from my azure dashboard : ``` <add name="myconstring" connectionString=Server=tcp:myserver.database.windows.net,1433;Database=mydatabase;User ID=cdptest@myserver;Password=******;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.EntityClient" /> ``` I tried this I got "Keyword not supported : data source" ``` <add name="myconstring" connectionString="Data Source=myserver.database.windows.net;Initilal Catalog=mydatabase;User ID=cdptest@myserver;Password=*****;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.EntityClient"/> ```
2014/09/24
[ "https://Stackoverflow.com/questions/26017705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2660758/" ]
The following works for me: ``` <add name="coupdpoAPEkowswAEntities" connectionString="Server=tcp:myserver.database.windows.net,1433;Database=mydatabase;User ID=cdptest@myserver;Password=*****;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" providerName="System.Data.EntityClient"/> ``` Use Server instead of Data Source, and specify the protocol and the port, and use Database instead of Initial Catalog
OK the providername was wrong. System.Data.SqlClient was excepted as this is a code first app model. I probably got System.Data.EntityClient from another app with Model First or Database First...
37,097,643
The server hosting the api is returning http for absolute urls even though the page was loaded using https, does this have something to do with django rest framework? because there doesn't seem any obvious way to remedy this. It's the url field in the Meta class that is relevant ``` class NewsSerializer(serializers.HyperlinkedModelSerializer): user = UserSerializer(read_only=True) source = serializers.CharField(source='get_source_url', read_only=True) comments_count = serializers.IntegerField(read_only=True) date_added = serializers.CharField(source='humanize_date_added', read_only=True) is_owner = serializers.SerializerMethodField() user_voted = serializers.SerializerMethodField() favorited = serializers.SerializerMethodField() image = serializers.SerializerMethodField() def create(self, validated_data): user = self.context['request'].user story = News(user=user, **validated_data) story.save() return story def get_is_owner(self, obj): user = self.context['request'].user if user.is_active and user == obj.user: return True return False def get_user_voted(self, obj): user = self.context['request'].user if user.is_active: return obj.user_voted(user) return None def get_favorited(self, obj): user = self.context['request'].user if user.is_active: return obj.is_favorite(user) class Meta: model = News fields = ('id', 'link', 'title', 'text', 'source', 'user', 'date_added', 'image', 'comments_count', 'url', 'upvotes', 'downvotes', 'user_voted', 'type', 'is_owner', 'favorited') read_only_fields = ('date_added') ``` i am not sure if it has to do with nginx but i have this in the config ``` proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; ```
2016/05/08
[ "https://Stackoverflow.com/questions/37097643", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1567198/" ]
You need to make sure nginx forwards the client's request scheme because it'll make a regular http request to Django. You'll need to add the following line to your vhost definition: ``` proxy_set_header X-Forwarded-Proto $scheme; ```
Are you using Rest Framework reverse() function to build URLs? <http://www.django-rest-framework.org/api-guide/reverse/> It uses incoming request to determine the protocol used.
28,768,715
For a project I am working on, one of the things we're implementing is something that we have code for in some of my teams older ASP.NET and MVC projects - an `Application_Error` exception catcher that dispatches an email to the development team with the exception experience and most relevant details. Here's how it looks: **Global.asax:** ``` protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); string path = "N/A"; if (sender is HttpApplication) path = ((HttpApplication) sender).Request.Url.PathAndQuery; string args = string.Format("<b>Path:</b> {0}", path); // Custom code that generates an HTML-formatted exception dump string message = Email.GenerateExceptionMessage(ex, args); // Custom code that sends an email to the dev team. Email.SendUnexpectedErrorMessage("Some App", message); } ``` One "minor" problem, though - when I intentionally have a part of the code throw an exception in order to test this mechanism... ``` public static void GetMuffinsByTopping(string topping) { throw new Exception("Test Exception!", new Exception("Test Inner Exception!!!")); // Actual repository code is unreachable while this test code is there } ``` The front-end JavaScript is immediately intercepting an HTTP 500 request, but the global.asax.cs code noted above is not being reached (I set a breakpoint on the first executing line of the method.) **Question:** In what way can I get the "old" `Application_Error` handler to dispatch error emails, so that our team's developers can more easily debug our application?
2015/02/27
[ "https://Stackoverflow.com/questions/28768715", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1404206/" ]
Abstract out your error handling logic from `Application_Error` into its own function. Create a [Web API exception filter](http://www.asp.net/web-api/overview/error-handling/exception-handling). ``` //register your filter with Web API pipeline //this belongs in the Application_Start event in Global Application Handler class (global.asax) //or some other location that runs on startup GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute()); //Create filter public class LogExceptionFilterAttribute : ExceptionFilterAttribute { public override void OnException(HttpActionExecutedContext context) { ErrorLogService.LogError(context.Exception); } } //in global.asax or global.asax.cs protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); ErrorLogService.LogError(ex); } //common service to be used for logging errors public static class ErrorLogService { public static void LogError(Exception ex) { //Email developers, call fire department, log to database etc. } } ``` Errors from Web API do not trigger the Application\_Error event. But we can create an exception filter and register it to handle the errors. Also see [Global Error Handling in ASP.NET Web API 2](https://www.asp.net/web-api/overview/error-handling/web-api-global-error-handling).
In my case, i prefer not use Web.config. Then i created code above in Global.asax file: ``` protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); //Not Found (When user digit unexisting url) if(ex is HttpException && ((HttpException)ex).GetHttpCode() == 404) { HttpContextWrapper contextWrapper = new HttpContextWrapper(this.Context); RouteData routeData = new RouteData(); routeData.Values.Add("controller", "Error"); routeData.Values.Add("action", "NotFound"); IController controller = new ErrorController(); RequestContext requestContext = new RequestContext(contextWrapper, routeData); controller.Execute(requestContext); Response.End(); } else //Unhandled Errors from aplication { ErrorLogService.LogError(ex); HttpContextWrapper contextWrapper = new HttpContextWrapper(this.Context); RouteData routeData = new RouteData(); routeData.Values.Add("controller", "Error"); routeData.Values.Add("action", "Index"); IController controller = new ErrorController(); RequestContext requestContext = new RequestContext(contextWrapper, routeData); controller.Execute(requestContext); Response.End(); } } ``` And thtat is my ErrorController.cs ``` public class ErrorController : Controller { // GET: Error public ViewResult Index() { Response.StatusCode = 500; Exception ex = Server.GetLastError(); return View("~/Views/Shared/SAAS/Error.cshtml", ex); } public ViewResult NotFound() { Response.StatusCode = 404; return View("~/Views/Shared/SAAS/NotFound.cshtml"); } } ``` And that is my ErrorLogService.cs copyed from @mason class ``` //common service to be used for logging errors public static class ErrorLogService { public static void LogError(Exception ex) { //Do what you want here, save log in database, send email to police station } } ```
6,091,451
So I have this code that pops up a file chooser and reads the file: ``` JFileChooser chooser = new JFileChooser(); File file = null; int returnValue = chooser.showOpenDialog( null ) ; if( returnValue == JFileChooser.APPROVE_OPTION ) { file = chooser.getSelectedFile() ; } if(file != null) { String filePath = file.getPath(); } // String filePath (that's what i'm trying to input) = "Users/Bill/Desktop/hello.txt"; try { ReadFile files = new ReadFile(***); String[] lines = files.OpenFile(); ``` the three asterisks (*\**) represent the class path of the file to be read. What should I put there if I want to read the file? Before this, I hard-coded the class-path and passed it in and it worked, but now, the class-path can be whatever the user chooses. Thanks for your help!
2011/05/22
[ "https://Stackoverflow.com/questions/6091451", "https://Stackoverflow.com", "https://Stackoverflow.com/users/765039/" ]
I don't know what your `ReadFile` thing is, but it looks like it takes a string representing the file path. In which case, you probably want to give it `file.getPath()`.
Try using this instead of your code in try block: ``` FileReader fr = new FileReader(filePath); FileWriter outputStream = new FileWriter("filename.txt");; int c; while ((c = fr.read()) != -1) { outputStream.write(c); } ```
17,525,935
i have created an application called "xyz.msi" and installed. Now i created another application called "abc.msi" and trying to install. But my question is if "xyz.msi" is installed already then it shouldn't allow to install "abc.msi". Thanks in advance
2013/07/08
[ "https://Stackoverflow.com/questions/17525935", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2560586/" ]
Take a look at the [Upgrade table](http://msdn.microsoft.com/en-us/library/windows/desktop/aa372379%28v=vs.85%29.aspx). You can use this to define the search criteria along with the msidbUpgradeAttributesOnlyDetect attribute to cause your action property to be assigned the ProductCode property that is found. Then you can use your action property in the [LaunchCondition table](http://msdn.microsoft.com/en-us/library/windows/desktop/aa369752%28v=vs.85%29.aspx) to prevent installation.
You are asking how MSI detect an installed application. Its since each MSI will have a unique Product Code (Refer to this: <http://msdn.microsoft.com/en-us/library/windows/desktop/aa370854(v=vs.85).aspx>) whenever you try to install a product it looks up at the product code if it matches it lets you do the re installation or upgrade. if it doesn't it will not. Depends how you creating the MSI. There are lots of ways of creating this but not really sure if you application lets you view the properties or not.
45,935,003
I have a string pipe of values, which I want to modify. the string pipe has a range from 0-5 values, so I made the following: ```js new Vue({ el: '#app', data: { valuesString: "" }, computed: { values: { get() { var values = this.valuesString ? this.valuesString.split("-") : []; if(values.length < 5) values.push(null); return values; }, set(values) { this.valuesString = values.filter(value => value).join("-") } } } }); ``` ```html <script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js"></script> <div id="app"> <div v-for="(value, i) in values" :key="i"> <select v-model="values[i]" style="width: 200px"> <option></option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </div> <br> <span>valuesString: {{ valuesString }}</span> <br> <span>values: {{ values }}</span> </div> ``` The problem now is, that the setter of my computed `values` property getn't called. my usecase is a filter like a categories filter. I get the `valuesString` as parameter from my router. The user should be able to select 1-5 categories to filter. every time the filter changes the router paramter should change and a new empty select should appear until there are 5 categories set.
2017/08/29
[ "https://Stackoverflow.com/questions/45935003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1826106/" ]
I'm not entirely sure I understand what you are looking for, but I think this will do the trick: * Parse the piped string and place it in an array + See the computed property unpiped * loop through the array and place the value in the selectbox + the loop should occur on the . The result is bound to valuesString * The selected value should be pushed to a results array and the selectbox should be cleared. + see the pushValues method. [Jfiddle example](https://jsfiddle.net/retrogradeMT/mxgtqdep/) ``` <div id="app"> <div> <select v-model="valuesString" @change="pushValues" style="width: 200px"> <option v-for="p in unpiped">{{p}}</option> </select> </div> <br> <span>valuesString: {{ valuesString }}</span> <br> <span>unpiped: {{ unpiped }}</span> <br> <span>results: {{ results }}</span> </div> ``` JS: ``` new Vue({ el: '#app', data: { valuesString: "", piped: "1|2|3|4|5", results: [] }, computed: { unpiped(){ var v = this.piped.split("|"); return v; }, }, methods: { pushValues: function(){ this.results.push(this.valuesString) this.valuesString = "" } } }); ```
maby my question wasn't clear. [Bert's comment is right](https://stackoverflow.com/questions/45935003/vue-computed-setter-get-not-triggered-for-array-in-v-model/45951999#comment78845473_45935003) I solved my problem with a workaround, but I'm not so satisfied. maby anyone can help me to optimize it. For this I tried to use computed setters. ```js new Vue({ el: '#app', data: { values: [], valuesString: "", allValues: [...Array(5).keys()] }, watch: { values (val) { if(val.toString() != this.filteredValues.toString() && val.toString() != this.filteredValues.concat([null]).toString()) this.$set(this, 'values', this.filteredValues); else if (this.valuesString != this.filteredValues.join('-')) this.$set(this, 'valuesString', this.filteredValues.join('-')); }, valuesString (valuesString) { this.$set(this, 'values', valuesString.split('-')); } }, computed: { filteredValues () { return this.values.filter(v => v); }, modelArray () { let size = this.filteredValues.length; if(size < 5) size++; return new Array(size); } } }); ``` ```html <script src="//cdnjs.cloudflare.com/ajax/libs/vue/2.3.4/vue.min.js"></script> <div id="app"> <div v-for="(value, i) in modelArray" :key="i"> <select v-model="values[i]" style="width: 200px"> <option></option> <option v-for="(v, j) in allValues" :key="j" v-if="v == values[i] || filteredValues.indexOf(v.toString()) === -1">{{ v }}</option> </select> </div> <br> <span>valuesString: <input v-model="valuesString" /></span> <br> <span>values: {{ values }}</span> <br> <span>filteredValues: {{ filteredValues }}</span> </div> ```
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
Old Answer (still applies unless you are using Visual Studio Update 1 RTM (2015) or later) ------------------------------------------------------------------------------------------ In short. No, there doesn't seem to be a good plugin for it. If you use Perl rarely, I would recommend sticking with Visual Studio for Microsoft languages and [Padre](http://padre.perlide.org/) for Perl. However, if you use Perl as much or more than Microsoft languages, you might want to check out [Emacs](http://www.gnu.org/software/emacs/), which has support for [C#](https://stackoverflow.com/questions/8607/any-good-way-to-use-emacs-for-c-development), [VB.NET](http://www.emacswiki.org/emacs/vbnet-mode.el), and Perl. Emacs is designed to be a "one-stop-shop" for all you do all day long, including browsing the web. You can come into work, start using Emacs and never have to leave it until it is time to go home. *disclaimer: The answer above is geared toward the Original Poster. I'm a big fan of [vim](http://www.vim.org/about.php). Personally, if I were thrust into a situation where I had to work with C# and Perl on the same project, I would get [ViEMU for Visual Studio](http://www.viemu.com/) and then use two editors: Visual Studio for C# and vim for Perl.* --- If this is something you are willing to spend some time on, check out [defining your own syntax highlighting](https://stackoverflow.com/questions/115388/how-can-i-customize-the-syntax-highlighting-in-visual-studio-2005) for Visual Studio.
A workaround for Visual Studio desktop version is to use C++ syntax highlighting. * Go to Options -> Text Editor -> File Extension * Enter extension "pl" (no dot) * Assign it to "Microsoft Visual C++" * Click "Add" If necessary, repeat the same steps for "cgi" extension.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
[Visual Studio Update 1 RTM](http://blogs.msdn.com/b/visualstudio/archive/2015/11/30/visual-studio-update-1-rtm.aspx) now (2015) has Perl support, along with Go, Java, R, Ruby, and Swift.
A work-in-progress Visual Studio [extension](https://marketplace.visualstudio.com/items?itemName=scriplit.perl6-lsp) for Perl6 (not the Perl5 asked by the OP) is incrementally more full-featured. It is released under the [MIT License](https://marketplace.visualstudio.com/items/scriplit.perl6-lsp/license) and its [repository](https://github.com/scriplit/vscode-languageserver-perl6) is on GitHub. As a prerequisite, Perl6 (e.g., [Rakudo](https://rakudo.perl6.org/downloads/rakudo)) needs to already be installed.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
[Visual Studio Update 1 RTM](http://blogs.msdn.com/b/visualstudio/archive/2015/11/30/visual-studio-update-1-rtm.aspx) now (2015) has Perl support, along with Go, Java, R, Ruby, and Swift.
A workaround for Visual Studio desktop version is to use C++ syntax highlighting. * Go to Options -> Text Editor -> File Extension * Enter extension "pl" (no dot) * Assign it to "Microsoft Visual C++" * Click "Add" If necessary, repeat the same steps for "cgi" extension.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
[Komodo Edit](http://www.activestate.com/komodo-edit) is quite nice, and free. code folding and other good stuff.
A workaround for Visual Studio desktop version is to use C++ syntax highlighting. * Go to Options -> Text Editor -> File Extension * Enter extension "pl" (no dot) * Assign it to "Microsoft Visual C++" * Click "Add" If necessary, repeat the same steps for "cgi" extension.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
Old Answer (still applies unless you are using Visual Studio Update 1 RTM (2015) or later) ------------------------------------------------------------------------------------------ In short. No, there doesn't seem to be a good plugin for it. If you use Perl rarely, I would recommend sticking with Visual Studio for Microsoft languages and [Padre](http://padre.perlide.org/) for Perl. However, if you use Perl as much or more than Microsoft languages, you might want to check out [Emacs](http://www.gnu.org/software/emacs/), which has support for [C#](https://stackoverflow.com/questions/8607/any-good-way-to-use-emacs-for-c-development), [VB.NET](http://www.emacswiki.org/emacs/vbnet-mode.el), and Perl. Emacs is designed to be a "one-stop-shop" for all you do all day long, including browsing the web. You can come into work, start using Emacs and never have to leave it until it is time to go home. *disclaimer: The answer above is geared toward the Original Poster. I'm a big fan of [vim](http://www.vim.org/about.php). Personally, if I were thrust into a situation where I had to work with C# and Perl on the same project, I would get [ViEMU for Visual Studio](http://www.viemu.com/) and then use two editors: Visual Studio for C# and vim for Perl.* --- If this is something you are willing to spend some time on, check out [defining your own syntax highlighting](https://stackoverflow.com/questions/115388/how-can-i-customize-the-syntax-highlighting-in-visual-studio-2005) for Visual Studio.
A work-in-progress Visual Studio [extension](https://marketplace.visualstudio.com/items?itemName=scriplit.perl6-lsp) for Perl6 (not the Perl5 asked by the OP) is incrementally more full-featured. It is released under the [MIT License](https://marketplace.visualstudio.com/items/scriplit.perl6-lsp/license) and its [repository](https://github.com/scriplit/vscode-languageserver-perl6) is on GitHub. As a prerequisite, Perl6 (e.g., [Rakudo](https://rakudo.perl6.org/downloads/rakudo)) needs to already be installed.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
Old Answer (still applies unless you are using Visual Studio Update 1 RTM (2015) or later) ------------------------------------------------------------------------------------------ In short. No, there doesn't seem to be a good plugin for it. If you use Perl rarely, I would recommend sticking with Visual Studio for Microsoft languages and [Padre](http://padre.perlide.org/) for Perl. However, if you use Perl as much or more than Microsoft languages, you might want to check out [Emacs](http://www.gnu.org/software/emacs/), which has support for [C#](https://stackoverflow.com/questions/8607/any-good-way-to-use-emacs-for-c-development), [VB.NET](http://www.emacswiki.org/emacs/vbnet-mode.el), and Perl. Emacs is designed to be a "one-stop-shop" for all you do all day long, including browsing the web. You can come into work, start using Emacs and never have to leave it until it is time to go home. *disclaimer: The answer above is geared toward the Original Poster. I'm a big fan of [vim](http://www.vim.org/about.php). Personally, if I were thrust into a situation where I had to work with C# and Perl on the same project, I would get [ViEMU for Visual Studio](http://www.viemu.com/) and then use two editors: Visual Studio for C# and vim for Perl.* --- If this is something you are willing to spend some time on, check out [defining your own syntax highlighting](https://stackoverflow.com/questions/115388/how-can-i-customize-the-syntax-highlighting-in-visual-studio-2005) for Visual Studio.
[Komodo Edit](http://www.activestate.com/komodo-edit) is quite nice, and free. code folding and other good stuff.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
Old Answer (still applies unless you are using Visual Studio Update 1 RTM (2015) or later) ------------------------------------------------------------------------------------------ In short. No, there doesn't seem to be a good plugin for it. If you use Perl rarely, I would recommend sticking with Visual Studio for Microsoft languages and [Padre](http://padre.perlide.org/) for Perl. However, if you use Perl as much or more than Microsoft languages, you might want to check out [Emacs](http://www.gnu.org/software/emacs/), which has support for [C#](https://stackoverflow.com/questions/8607/any-good-way-to-use-emacs-for-c-development), [VB.NET](http://www.emacswiki.org/emacs/vbnet-mode.el), and Perl. Emacs is designed to be a "one-stop-shop" for all you do all day long, including browsing the web. You can come into work, start using Emacs and never have to leave it until it is time to go home. *disclaimer: The answer above is geared toward the Original Poster. I'm a big fan of [vim](http://www.vim.org/about.php). Personally, if I were thrust into a situation where I had to work with C# and Perl on the same project, I would get [ViEMU for Visual Studio](http://www.viemu.com/) and then use two editors: Visual Studio for C# and vim for Perl.* --- If this is something you are willing to spend some time on, check out [defining your own syntax highlighting](https://stackoverflow.com/questions/115388/how-can-i-customize-the-syntax-highlighting-in-visual-studio-2005) for Visual Studio.
For Perl syntax highlight `ext install perl6` Install this extension [To Run Perl and Other languages](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner)
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
A work-in-progress Visual Studio [extension](https://marketplace.visualstudio.com/items?itemName=scriplit.perl6-lsp) for Perl6 (not the Perl5 asked by the OP) is incrementally more full-featured. It is released under the [MIT License](https://marketplace.visualstudio.com/items/scriplit.perl6-lsp/license) and its [repository](https://github.com/scriplit/vscode-languageserver-perl6) is on GitHub. As a prerequisite, Perl6 (e.g., [Rakudo](https://rakudo.perl6.org/downloads/rakudo)) needs to already be installed.
A workaround for Visual Studio desktop version is to use C++ syntax highlighting. * Go to Options -> Text Editor -> File Extension * Enter extension "pl" (no dot) * Assign it to "Microsoft Visual C++" * Click "Add" If necessary, repeat the same steps for "cgi" extension.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
[Visual Studio Update 1 RTM](http://blogs.msdn.com/b/visualstudio/archive/2015/11/30/visual-studio-update-1-rtm.aspx) now (2015) has Perl support, along with Go, Java, R, Ruby, and Swift.
[Komodo Edit](http://www.activestate.com/komodo-edit) is quite nice, and free. code folding and other good stuff.
3,755,892
Does anyone know if there is an extension or plugin for Visual Studio ( any version ) that will recognize Perl syntax highlighting? I want to edit the Perl files in my vs projects, but it gets hard to read sometimes. Thanks.
2010/09/20
[ "https://Stackoverflow.com/questions/3755892", "https://Stackoverflow.com", "https://Stackoverflow.com/users/387203/" ]
[Visual Studio Update 1 RTM](http://blogs.msdn.com/b/visualstudio/archive/2015/11/30/visual-studio-update-1-rtm.aspx) now (2015) has Perl support, along with Go, Java, R, Ruby, and Swift.
For Perl syntax highlight `ext install perl6` Install this extension [To Run Perl and Other languages](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner)
8,626,880
On Android when I am mapping an address on a Mapview I have to wait for that action to return and then my user is given control back so I was wondering how can I send that function of to another thread? ``` mapLocationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mapCurrentAddress(); //Send this function to new thread } }); ``` How can this be done? And how will the new thread respond when it's done?
2011/12/24
[ "https://Stackoverflow.com/questions/8626880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/690851/" ]
Android provides the AsyncTask class to do that. Read <http://developer.android.com/reference/android/os/AsyncTask.html>
You can use an AsyncTask to do this work in the background. Check this [example](http://developer.android.com/reference/android/os/AsyncTask.html)
8,626,880
On Android when I am mapping an address on a Mapview I have to wait for that action to return and then my user is given control back so I was wondering how can I send that function of to another thread? ``` mapLocationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mapCurrentAddress(); //Send this function to new thread } }); ``` How can this be done? And how will the new thread respond when it's done?
2011/12/24
[ "https://Stackoverflow.com/questions/8626880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/690851/" ]
Android provides the AsyncTask class to do that. Read <http://developer.android.com/reference/android/os/AsyncTask.html>
``` Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View v) { p_dialog = ProgressDialog.show((activity_name).this, "", "Loading Image..."); new Thread(new Runnable() { public void run() { function(); } }).start(); } ```
8,626,880
On Android when I am mapping an address on a Mapview I have to wait for that action to return and then my user is given control back so I was wondering how can I send that function of to another thread? ``` mapLocationButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mapCurrentAddress(); //Send this function to new thread } }); ``` How can this be done? And how will the new thread respond when it's done?
2011/12/24
[ "https://Stackoverflow.com/questions/8626880", "https://Stackoverflow.com", "https://Stackoverflow.com/users/690851/" ]
You can use an AsyncTask to do this work in the background. Check this [example](http://developer.android.com/reference/android/os/AsyncTask.html)
``` Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View v) { p_dialog = ProgressDialog.show((activity_name).this, "", "Loading Image..."); new Thread(new Runnable() { public void run() { function(); } }).start(); } ```
83,697
In X-Men Origins, Scott Summers lost his eyes, which were then put into Deadpool. After this event, in X-Men 1 through X-Men 3 Scott was still able to fire lasers, implying that the mutant ability was not related to the eyes? Yet Deadpool was able to fire the lasers with Scott's eyes. In addition Deadpool was able to control if he shot the beam, whereas Cyclops had to keep his eyes closed or adjust his visor. Why is Deadpool able to shoot lasers with eyes and Cyclops without? Why is Deadpool able to control the lasers without the technology Cyclops has?
2015/03/12
[ "https://scifi.stackexchange.com/questions/83697", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/42794/" ]
> > Why is Deadpool able to shoot lasers with eyes and Cyclops without? Why is Deadpool able to control the lasers without the technology Cyclops has? > > > Because Cyclops origin story involves trauma (either mental psychological trauma, or actual head injury) that prevents him from controlling his powers. His brother Havok, who has similar enough powers as Scott that they can attack each other and it won't hurt, does not have this problem. This is why Scott needs Ruby-Quartz glasses or the visor to absorb the blasts which are always on. > > The early accounts in the X-Men comics use flashbacks to tell the origin story of Scott parachuting from his parents' plane. The flashbacks are often told from various narrative perspectives and place different emphasis on the events of this period. Scott's poor control over his power have been attributed to events in his childhood. In Uncanny X-Men #156, Scott's parachute caught fire and Scott struck his head upon landing. This caused brain damage to Scott which is responsible for his poor control over his optic blasts. Several origin stories do not feature the head injury account with X-Men Origins: Cyclops #1 being the most recent. The head injury account has also been retconned in Astonishing X-Men Vol. 2 as being due to a self-imposed mental block he made as a child to deal with the traumatic events of his life. With the help of Emma Frost, Scott is able to briefly bypass his own mental block and control his powers, though he reveals that his control is waning and temporary. [wikipedia] > > > As for Origins, you misunderstand what it is that happens in the movie, which is also pulled from the comics. Comic Deadpool is not a mutant, but his origins involve receiving a **COPY** of Wolverine's mutant healing factor. In the movie, this still happens. Notice that Wolverine was not deprived a healing factor, or his claws, yet Deadpool has both. He received copies of Wolverine's and Cyclops' powers (along with Wraith's teleportation and Bradley's technopathy). This somehow involved surgery of the optic nerves. Scott at no point had his eyes removed. The bandages suggest a biopsy or surgery of the eyes that need to heal. The reason Deadpool can use the optic blasts without the glasses is because he lacks the trauma that Scott received.
the reason is because Hollyweird butt-pulled a bunch of powers for him because they didn't do any research before making the character in the film. This is why Deadpool could shoot beams from his eyes, and had other powers he never had in the Marvel universe. They weren't doing any research and, at the time, had no plans to make a genuine Deadpool movie, so they deliberately fudged his powers, and they made him mute because the "Merc with a Mouth" wouldn't exactly be PG-13 friendly if he had any spoken lines. They learned from this mistake, ultimately, and now we have a Deadpool who is not only true to form, but foul-mouthed and truly an Anti-hero.
5,900,627
I am trying to pass an object from one page to another page using `<asp:hyperlink>` without any success. I was trying to invoke a C# method and put that object into a session but then I realized you can't invoke a method using `<asp:hyperlink>`. Then I thought about using `<asp:linkbutton>` but then I need to open the new webpage in a new window. How can I go about doing this properly? Are there any other good alternatives?
2011/05/05
[ "https://Stackoverflow.com/questions/5900627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/386195/" ]
> > Then I thought about using `<asp:linkbutton>` but then I need to > open the new webpage in a new window. > > > You do not need to open a new window... add this to your server side `LinkButton` handler: ``` <asp:LinkButton id="btnYourLinkButton" runat="server" OnClick="btnYourLinkButton_Click">Test</asp:LinkButton> protected void btnLogout_Click(object sender, System.EventArgs e) { var someObject = GetYourDataWithSomeFunction(); Session["YourData"] = someObject; // saves to session Response.Redirect("yourNewUrl.aspx"); } ``` This will store the value in the `Session` and redirect to a new page in the same window. EDIT: If you **need** to open in a new window then do the same thing as outlined above but instead of doing a `Response.Redirect` add the `window.open` javascript call to your page that is served up to open the new window: ``` ScriptManager.RegisterStartupScript(this, this.GetType(), "AUTOOPEN", "window.open('yourNewUrl.aspx', '_blank');", true); ``` Optionally you could just add an ajax call to your click method to setup the `Session` server side and then trigger the redirect based on your ajax call complete.
Add the object to the `Session` then redirect to the new page. In the new page, check the `Session` variable for the object.
5,900,627
I am trying to pass an object from one page to another page using `<asp:hyperlink>` without any success. I was trying to invoke a C# method and put that object into a session but then I realized you can't invoke a method using `<asp:hyperlink>`. Then I thought about using `<asp:linkbutton>` but then I need to open the new webpage in a new window. How can I go about doing this properly? Are there any other good alternatives?
2011/05/05
[ "https://Stackoverflow.com/questions/5900627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/386195/" ]
Add the object to the `Session` then redirect to the new page. In the new page, check the `Session` variable for the object.
Any web application tends to be stateless in nature. Your objects only live during the processing of the page request. When developing and appliction with a technology such as ASP.Net the general pattern for object retrieval is to send an identifier as part of the form post data or the querystring and then use this identifier to reload the object that you were working with prior to the previous page post/request. It is possible to add objects to the session and retrieve them as suggested in other answers here, but there are issues with this approach e.g. sessions timing out, scalability etc. If you were to give some more details as to the nature of what you are trying to do it would be easier to give you a more complete answer or suggestions on how to solve your particular problem.
5,900,627
I am trying to pass an object from one page to another page using `<asp:hyperlink>` without any success. I was trying to invoke a C# method and put that object into a session but then I realized you can't invoke a method using `<asp:hyperlink>`. Then I thought about using `<asp:linkbutton>` but then I need to open the new webpage in a new window. How can I go about doing this properly? Are there any other good alternatives?
2011/05/05
[ "https://Stackoverflow.com/questions/5900627", "https://Stackoverflow.com", "https://Stackoverflow.com/users/386195/" ]
> > Then I thought about using `<asp:linkbutton>` but then I need to > open the new webpage in a new window. > > > You do not need to open a new window... add this to your server side `LinkButton` handler: ``` <asp:LinkButton id="btnYourLinkButton" runat="server" OnClick="btnYourLinkButton_Click">Test</asp:LinkButton> protected void btnLogout_Click(object sender, System.EventArgs e) { var someObject = GetYourDataWithSomeFunction(); Session["YourData"] = someObject; // saves to session Response.Redirect("yourNewUrl.aspx"); } ``` This will store the value in the `Session` and redirect to a new page in the same window. EDIT: If you **need** to open in a new window then do the same thing as outlined above but instead of doing a `Response.Redirect` add the `window.open` javascript call to your page that is served up to open the new window: ``` ScriptManager.RegisterStartupScript(this, this.GetType(), "AUTOOPEN", "window.open('yourNewUrl.aspx', '_blank');", true); ``` Optionally you could just add an ajax call to your click method to setup the `Session` server side and then trigger the redirect based on your ajax call complete.
Any web application tends to be stateless in nature. Your objects only live during the processing of the page request. When developing and appliction with a technology such as ASP.Net the general pattern for object retrieval is to send an identifier as part of the form post data or the querystring and then use this identifier to reload the object that you were working with prior to the previous page post/request. It is possible to add objects to the session and retrieve them as suggested in other answers here, but there are issues with this approach e.g. sessions timing out, scalability etc. If you were to give some more details as to the nature of what you are trying to do it would be easier to give you a more complete answer or suggestions on how to solve your particular problem.
24,342,687
I am trying to clear a session. Below is a little sample code I wrote to check with `SessionStatus`. ``` @Controller @SessionAttributes(value={"sessAttr1","sessAttr2","sessAttr3"}) public class SessionController { @RequestMapping(value="index") public ModelAndView populateSession(){ ModelAndView modelView = new ModelAndView("home"); modelView.addObject("sessAttr1","This value is added in a session 1"); modelView.addObject("sessAttr2","This value is added in a session 2"); modelView.addObject("sessAttr3","This value is added in a session 3"); return modelView; } @RequestMapping(value="home1") public String populateHomeSession(SessionStatus status){ status.setComplete(); return "home1"; } } ``` When `home1` screen is displayed, I can still see the session objects not getting cleared. If I try this: `${sessAttr1 }` then I can read the session values in `home1` screen. Please clarify why is it not working. **EDIT** I an using `<a href="home1">Next</a>` to navigate from one screen to another. Does it have something to do with this isse I am facing?
2014/06/21
[ "https://Stackoverflow.com/questions/24342687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1317840/" ]
`setComplete` is used to mark a session attribute as not needed *after* the request has been processed by the controller: It does not immediately modify the session, and it overall sounds like it's a poor fit for your use case. It's intended to be used in a situation like a POST where the data is intended to be used during the present request, but should not be used in the future. <http://forum.spring.io/forum/spring-projects/web/108339-problem-with-sessionattribute-and-sessionstatus>
you can use [invalidate()](http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpSession.html#invalidate%28%29) ``` @RequestMapping(value="home1") public String populateHomeSession(HttpservletRequest request){ HttpSession session=request.getSession(); session.invalidate(); return "home1"; } ```
24,342,687
I am trying to clear a session. Below is a little sample code I wrote to check with `SessionStatus`. ``` @Controller @SessionAttributes(value={"sessAttr1","sessAttr2","sessAttr3"}) public class SessionController { @RequestMapping(value="index") public ModelAndView populateSession(){ ModelAndView modelView = new ModelAndView("home"); modelView.addObject("sessAttr1","This value is added in a session 1"); modelView.addObject("sessAttr2","This value is added in a session 2"); modelView.addObject("sessAttr3","This value is added in a session 3"); return modelView; } @RequestMapping(value="home1") public String populateHomeSession(SessionStatus status){ status.setComplete(); return "home1"; } } ``` When `home1` screen is displayed, I can still see the session objects not getting cleared. If I try this: `${sessAttr1 }` then I can read the session values in `home1` screen. Please clarify why is it not working. **EDIT** I an using `<a href="home1">Next</a>` to navigate from one screen to another. Does it have something to do with this isse I am facing?
2014/06/21
[ "https://Stackoverflow.com/questions/24342687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1317840/" ]
you can use [invalidate()](http://docs.oracle.com/javaee/5/api/javax/servlet/http/HttpSession.html#invalidate%28%29) ``` @RequestMapping(value="home1") public String populateHomeSession(HttpservletRequest request){ HttpSession session=request.getSession(); session.invalidate(); return "home1"; } ```
status.setComplete(); remove sessionatribute after render.
24,342,687
I am trying to clear a session. Below is a little sample code I wrote to check with `SessionStatus`. ``` @Controller @SessionAttributes(value={"sessAttr1","sessAttr2","sessAttr3"}) public class SessionController { @RequestMapping(value="index") public ModelAndView populateSession(){ ModelAndView modelView = new ModelAndView("home"); modelView.addObject("sessAttr1","This value is added in a session 1"); modelView.addObject("sessAttr2","This value is added in a session 2"); modelView.addObject("sessAttr3","This value is added in a session 3"); return modelView; } @RequestMapping(value="home1") public String populateHomeSession(SessionStatus status){ status.setComplete(); return "home1"; } } ``` When `home1` screen is displayed, I can still see the session objects not getting cleared. If I try this: `${sessAttr1 }` then I can read the session values in `home1` screen. Please clarify why is it not working. **EDIT** I an using `<a href="home1">Next</a>` to navigate from one screen to another. Does it have something to do with this isse I am facing?
2014/06/21
[ "https://Stackoverflow.com/questions/24342687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1317840/" ]
`setComplete` is used to mark a session attribute as not needed *after* the request has been processed by the controller: It does not immediately modify the session, and it overall sounds like it's a poor fit for your use case. It's intended to be used in a situation like a POST where the data is intended to be used during the present request, but should not be used in the future. <http://forum.spring.io/forum/spring-projects/web/108339-problem-with-sessionattribute-and-sessionstatus>
status.setComplete(); remove sessionatribute after render.
54,616,879
I have a file directory `music/artist/{random_name}/{random_music}.ogg` There's a lot of folder in `{random_name}` and different kind of music title `{random_music}`. So, I wanted to rename the `{random_music}.ogg` to `music.ogg`. Each `{random_name}` folder only have one .ogg files. I've tried with the Bash scripts for hours but didn't managed to find out. ``` for f in ../music/artist/*/*.ogg do echo mv "$f" "${f/.*.ogg/music.ogg}" done ``` It only rename the file on my current dir, which will ask for replace/overwrite. My goals is, I wanted to rename all the `{random_music}.ogg` files to `music.ogg` with their respective directories for example, `music/artist/arai/blue.ogg` to `music/artist/arai/music.ogg` `music/artist/sako/sky.ogg` to `music/artist/sako/music.ogg`
2019/02/10
[ "https://Stackoverflow.com/questions/54616879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8061434/" ]
Your pattern replacement is incorrect. Because all your paths start with `..`, `.*.ogg` actually matches *the entire path*, so *every* file gets turned into `music.ogg` in your current directory. You want `${f/\/*.ogg/music.ogg}` instead, or better yet, `${f%/*}/music.ogg`. That's the rough equivalent of `"$(dirname "$f")"/music.ogg`.
I use usually this: ``` for f in ../music/artist/*/*.ogg do dest="${f/.*.ogg/music.ogg}" if [[ $f != "$dest" ]] # nothing to do if name doesn't change then if [[ -a $dest ]] then printf 'WARNING: File already exists: %s\n' "$dest" else mv "$f" "$dest" fi fi done ```
54,616,879
I have a file directory `music/artist/{random_name}/{random_music}.ogg` There's a lot of folder in `{random_name}` and different kind of music title `{random_music}`. So, I wanted to rename the `{random_music}.ogg` to `music.ogg`. Each `{random_name}` folder only have one .ogg files. I've tried with the Bash scripts for hours but didn't managed to find out. ``` for f in ../music/artist/*/*.ogg do echo mv "$f" "${f/.*.ogg/music.ogg}" done ``` It only rename the file on my current dir, which will ask for replace/overwrite. My goals is, I wanted to rename all the `{random_music}.ogg` files to `music.ogg` with their respective directories for example, `music/artist/arai/blue.ogg` to `music/artist/arai/music.ogg` `music/artist/sako/sky.ogg` to `music/artist/sako/music.ogg`
2019/02/10
[ "https://Stackoverflow.com/questions/54616879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8061434/" ]
Your pattern replacement is incorrect. Because all your paths start with `..`, `.*.ogg` actually matches *the entire path*, so *every* file gets turned into `music.ogg` in your current directory. You want `${f/\/*.ogg/music.ogg}` instead, or better yet, `${f%/*}/music.ogg`. That's the rough equivalent of `"$(dirname "$f")"/music.ogg`.
You can change your code like this ``` for f in ../music/artist/*/*.ogg do echo mv $f "$(dirname "$f")"/music.ogg done ``` Here `dirname` will extract the directory name from your variable and you can append it with your `music.ogg` to get the desired result. For the example path that you provided if `$f` equals `music/artist/arai/blue.ogg`, then the result will be `mv music/artist/arai/blue.ogg music/artist/arai/music.ogg`
54,616,879
I have a file directory `music/artist/{random_name}/{random_music}.ogg` There's a lot of folder in `{random_name}` and different kind of music title `{random_music}`. So, I wanted to rename the `{random_music}.ogg` to `music.ogg`. Each `{random_name}` folder only have one .ogg files. I've tried with the Bash scripts for hours but didn't managed to find out. ``` for f in ../music/artist/*/*.ogg do echo mv "$f" "${f/.*.ogg/music.ogg}" done ``` It only rename the file on my current dir, which will ask for replace/overwrite. My goals is, I wanted to rename all the `{random_music}.ogg` files to `music.ogg` with their respective directories for example, `music/artist/arai/blue.ogg` to `music/artist/arai/music.ogg` `music/artist/sako/sky.ogg` to `music/artist/sako/music.ogg`
2019/02/10
[ "https://Stackoverflow.com/questions/54616879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8061434/" ]
Your pattern replacement is incorrect. Because all your paths start with `..`, `.*.ogg` actually matches *the entire path*, so *every* file gets turned into `music.ogg` in your current directory. You want `${f/\/*.ogg/music.ogg}` instead, or better yet, `${f%/*}/music.ogg`. That's the rough equivalent of `"$(dirname "$f")"/music.ogg`.
I hope this would help you: Previously: ``` [root@user]# tree music music └── artist β”œβ”€β”€ df β”‚Β Β  └── mp.ogg β”œβ”€β”€ gh β”‚Β Β  └── pl.ogg β”œβ”€β”€ jk β”‚Β Β  └── gl.ogg β”œβ”€β”€ po β”‚Β Β  └── ui.ogg β”œβ”€β”€ ty β”‚Β Β  └── lk.ogg └── ui └── dh.ogg 7 directories, 6 files ``` Source code: ``` #!/bin/bash for i in `ls -ld music/artist/* | awk '{print $9}'` do mv $i/*ogg $i/music.ogg done ``` After execution: ``` music └── artist β”œβ”€β”€ df β”‚Β Β  └── music.ogg β”œβ”€β”€ gh β”‚Β Β  └── music.ogg β”œβ”€β”€ jk β”‚Β Β  └── music.ogg β”œβ”€β”€ po β”‚Β Β  └── music.ogg β”œβ”€β”€ ty β”‚Β Β  └── music.ogg └── ui └── music.ogg 7 directories, 6 files ``` As you can see all of the files got renamed correctly.
54,616,879
I have a file directory `music/artist/{random_name}/{random_music}.ogg` There's a lot of folder in `{random_name}` and different kind of music title `{random_music}`. So, I wanted to rename the `{random_music}.ogg` to `music.ogg`. Each `{random_name}` folder only have one .ogg files. I've tried with the Bash scripts for hours but didn't managed to find out. ``` for f in ../music/artist/*/*.ogg do echo mv "$f" "${f/.*.ogg/music.ogg}" done ``` It only rename the file on my current dir, which will ask for replace/overwrite. My goals is, I wanted to rename all the `{random_music}.ogg` files to `music.ogg` with their respective directories for example, `music/artist/arai/blue.ogg` to `music/artist/arai/music.ogg` `music/artist/sako/sky.ogg` to `music/artist/sako/music.ogg`
2019/02/10
[ "https://Stackoverflow.com/questions/54616879", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8061434/" ]
Your pattern replacement is incorrect. Because all your paths start with `..`, `.*.ogg` actually matches *the entire path*, so *every* file gets turned into `music.ogg` in your current directory. You want `${f/\/*.ogg/music.ogg}` instead, or better yet, `${f%/*}/music.ogg`. That's the rough equivalent of `"$(dirname "$f")"/music.ogg`.
``` find ../music/artist/ -type f -name "*.ogg" -exec bash -c 'mydir=`dirname {}`;mv {} $mydir/music.ogg' \; ``` This is a one-liner that should work. It implements the exec option of the find command which then gets the directory name and renames the original file to music.ogg.
6,346
I hope to observe planets like Jupiter and Saturn, and moons. I am a novice when it comes to telescopes and I know images in magazines are not taken with at least 12-inch telescope in a middle of nowhere. Is it possible to view Saturn in little yellowish and Mars in little reddish using following telescopes? I am going to buy one of them. **Which one is worth more for the money with the price difference?** I am living in Sri Lanka (a country close to the equator) in a suburban city. **Option 1** EQ-Reflecting telescope * Aperture: 135mm * Focal length: 800mm Focal ratio: f/6 * Max power: 265x when the air is steady * Price: 300USD approx * Link: <http://www.ksonoptics.com:8081/Product/PrdDtls/121/> **Option 2** EQ-Reflecting telescope * Aperture: 114mm * Focal length: 900mm Focal ratio: f/8 * Max Power: 228x when the air is steady. * Price: 220USD approx * Link: <http://www.ksonoptics.com:8081/Product/PrdDtls/119/>
2014/09/13
[ "https://astronomy.stackexchange.com/questions/6346", "https://astronomy.stackexchange.com", "https://astronomy.stackexchange.com/users/2410/" ]
Go with Option 1 (135mm) as it has bigger light collecting area, i.e. diameter of primary mirror. It will enable you to see faint objects and it will also help you to see the dim objects under a greater zoom eyepiece, e.g. 4mm or 10mm. Also, don't fool yourself with the bigger numbers advertized by telescope vendors like 238X zoom or 300X zoom. First, these are zooming power using Barlow lenses also the more you zoom in on any object, the less light you gather on the mirror and hence objects will look much fainter in appearance. I will suggest the 10mm eyepiece with a 135mm telescope (Option 1) will be sufficient for you to observe planets like Jupiter, its Galilean satellites, Saturn's rings and also many Messier objects like Andromeda Galaxy M31, the Honey Bee Cluster, and open star clusters in the Auriga constellation. Also bear in mind that you live in a country area closer to sea like here in India and the weather will be hot and humid. So ask the vendor about special coating which protects the mirror from rusting (spots on mirror due to moisture) during the humid monsoon season as at least for 4 months it will be humid.
> > Is it possible to view Saturn in little yellowish and Mars in little > reddish using following telescopes? > > > It is definitely possible to observe the rings of Saturn with telescopes this size. Even the Cassini division should sometimes appear visible, if the instruments are well collimated and seeing is not too bad. In terms of color, Saturn is just a boring buttery-yellow even in bigger scopes, so I wouldn't worry about that. But Saturn is getting lower in the sky these days. If you hurry up and get the scope quickly, you may catch it for a few weeks at sunset, low in the western sky. After this, you'll have to wait until next year. Mars is a different animal. Most of the time, all you'll see is a bright brick-red round dot, even in a bigger scope than these ones. But every couple years Mars is at opposition, when it's closest to Earth. We just had one a few months ago. Then you can see some of the big features, such as Syrtis Major, or the polar ice caps, or Hellas Basin full of frost or fog, like a big, bright white area. However, that's only doable briefly around oppositions. The scope must be in perfect collimation, and seeing must cooperate. <http://en.wikipedia.org/wiki/Astronomical_seeing> If everything is at maximum parameters, I'm sure you could see Syrtis Major in a scope this size. During the last opposition, I've seen all of the above features, plus more (Utopia Planitia, Sinus Sabaeus, etc), in as low as 150 mm of aperture, in a scope with great optics, perfectly collimated, during nights with excellent seeing. Anyway, for Mars you'll have to wait until the next opposition, in May 2016. Later this year, in December, Jupiter will start rising in the East, and you could use your scope to watch it - an aperture like this is enough to see the 4 big moons and at least 2 equatorial belts. It will be high in the sky at a comfortable time in the evening early next year. Until then, you can always observe the Moon, two weeks out of every four. Also, the planets and the Moon are not the only things accessible with this aperture. Most of the Messier objects are visible in a 100 ... 150 mm scope, even in suburban areas. M13 is spectacular at any aperture above 100 mm. The Great Orion Nebula is awesome even with binoculars. The Pleiades are great too. Most of these deep space objects require low magnification for the best view, but every case is a bit different. Plenty of double stars out there, too: Mizar, Albireo, even Polaris. All visible in small apertures. > > I am going to buy one of them. Which one is worth more for the money > with the price difference? > > > The instruments are about the same. In theory, the bigger one has a bit more resolving power and a bit larger collecting area, so theoretically it should be slightly better. In practice, with mass-produced instruments like these, it usually depends on the build quality, which can vary. The smaller instrument is an f/8. The longer focal ratio means less aberrations; it also makes it easier for cheap eyepieces to function well, whereas at f/6 ... f/5 a cheap eyepiece may start to exhibit aberrations of its own (independent of telescope aberrations). Also, an f/8 is easier to collimate than an f/6. Overall, I would look at it as a matter of price. If you can easily afford the bigger one, get it. Otherwise, the smaller instrument might be a bit easier to maintain, is less demanding in terms of optics, and it should perform pretty close to the other one - all else being equal. But since you're focused on planetary observations, remember this: It is far more important to learn to correctly collimate your telescope, and develop it into a routine whereby you do a quick collimation check every time before you observe - it only takes a couple minutes. For planetary observations, the smaller telescope, in perfect collimation, will perform far better than the larger one, uncollimated. Heck, the little scope, perfectly collimated, will perform better on planets than a MUCH larger telescope, uncollimated - that's how important collimation is. Improper collimation, or lack thereof, is one of the major factors for lackluster performance for a majority of amateur telescopes (along with poor quality optics - but there's nothing you can do about that, whereas collimation can be improved). Search this forum, or just google, the term collimation, and read the numerous documents you'll find. Or start here: <http://www.cloudynights.com/documents/primer.pdf> Or here: [How can I collimate a dobsonian telescope with a laser collimator?](https://astronomy.stackexchange.com/questions/150/how-can-i-collimate-a-dobsonian-telescope-with-a-laser-collimator) The owner's manual should also provide some recommendations regarding collimation (I hope).
123,285
I have a 20 amp circuit going directly from the panel to the kitchen with 20 amp receptacles and subsequent 12 gauge wire. There are only 4 outlets on that circuit (one being a GFI). I am installing under-cabinet lights and lights above the sink, well within the total amperage and volts allowed for the 20 amp circuit. I will use the 12 gauge wire to power the 15amp single pole switches and go to the lights with 14 gauge wire. Can I connect the 14 gauge neutral to the 12 gauge already in the box or should I just run 12 gauge to the lights for the neutral and connect??.... thank you in advance for your input
2017/09/13
[ "https://diy.stackexchange.com/questions/123285", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/75416/" ]
Switches are not circuit breakers (overcurrent protection). They cannot protect wire and do not make it ok to use smaller wire past them. If any 14AWG wire is used, you must downgrade the breaker to 15A, and downgrade the countertop receptacles to 15A. The other wire can remain 12AWG. This will mean it is not one of the two mandatory 20A circuits for countertop receptacles and you may need to add a circuit. There is another reason not to put kitchen lights on receptacle circuits. An appliance trip will plunge the cook into darkness.
If you have any #14 wire in the circuit, you have to put a 15 A breaker on it. So, to keep your 20 A breaker, you should use #12 wire everywhere, and run #12 to the switch and lights.
7,238,330
I have following code ``` $.ajax({ type: 'POST', url: 'index.jsp', data: 'id=111', dataType: 'jsonp', success: function(data) { alert(data.result); }, error: function( err1, err2, err3 ) { alert('Error:' + err3 ) } }); ``` I am returning response as callback parameter generated with argument of json . like this ``` jQuery16105097715278461496_1314674056493({"result" : "success"}) ``` This works absolutely fine in FF . In IE 9 it goes to error function and shows ``` "Error: jQuery16105097715278461496_1314674056493 was not called" . ``` when I see F12 . I see a warning which says . ``` SEC7112: Script from http://otherdomain.com index.jsp?callback=jQuery16105097715278461496_1314674056493 &eid=111&_=1314674056493 was blocked due to mime type mismatch ``` ![enter image description here](https://i.stack.imgur.com/Az4rZ.png) ![enter image description here](https://i.stack.imgur.com/AUw6T.png) ![enter image description here](https://i.stack.imgur.com/3FiX1.png)
2011/08/30
[ "https://Stackoverflow.com/questions/7238330", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608576/" ]
try adding a contentType ``` $.ajax({ type: 'POST', url: 'index.jsp', data: {id:'111'}, contentType: "application/json; charset=utf-8", dataType: 'jsonp', success: function(data) { alert(data.result); }, error: function( err1, err2, err3 ) { alert('Error:' + err3.status ); alert(err1.responseText); } }); ``` here is a good article <http://msdn.microsoft.com/en-us/library/gg622941%28v=vs.85%29.aspx>
**This library is heavenly helpful I found it after wasting a lot hours.** Use this library <https://github.com/MoonScript/jQuery-ajaxTransport-XDomainRequest> then you won't need to use jsonp. And your Cross Site request will begin to work normally.