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
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't you rather want to keep them separated? ``` $_SESSION['response'] = $_POST; ```
Since the POST is made by a payment gateway, the session will be associated with it (and most likely be lost at first request, since it can be assumed that it won't ever bother reading the session cookie). Your client won't ever see this data in their session. If you want to have this data available, you need to persist it somehow, if the payment gateway gives you exploitable client information. Possible solution are a database, key/value store... Alternatively, it is common that the payment gateway will allow you to specify a link to redirect the client's browser to after the purchase. Getting the parameters from the POST, you could append them to the redirect URL to pass them back to your website as GET parameters.
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't use single quotes: ``` foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } ``` I'd encourage you to read about [Strings in PHP](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single). **Note:** This is potentially unsafe for several reasons - mostly injection by key collision. Consider if I *posted* the logged in user id. This could be mitigated through encapsulation: ``` $_SESSION['posted_data'] = $_POST; ```
Since the POST is made by a payment gateway, the session will be associated with it (and most likely be lost at first request, since it can be assumed that it won't ever bother reading the session cookie). Your client won't ever see this data in their session. If you want to have this data available, you need to persist it somehow, if the payment gateway gives you exploitable client information. Possible solution are a database, key/value store... Alternatively, it is common that the payment gateway will allow you to specify a link to redirect the client's browser to after the purchase. Getting the parameters from the POST, you could append them to the redirect URL to pass them back to your website as GET parameters.
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't use single quotes: ``` foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } ``` I'd encourage you to read about [Strings in PHP](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single). **Note:** This is potentially unsafe for several reasons - mostly injection by key collision. Consider if I *posted* the logged in user id. This could be mitigated through encapsulation: ``` $_SESSION['posted_data'] = $_POST; ```
If you **really** want to do it as you state, you could use something like ``` $_SESSION=array_merge($_SESSION,$_POST); ``` which would work but be a "bad thing" - plenty of scope to overwrite items already in the `$_SESSION` variable: index.php: ``` <form action="2.php" method="post"> <input type="text" name="hidden" value="hidden"> <button type="submit">Click</button> </form> ``` 2.php: ``` <?php session_start(); session_unset(); $_SESSION['hidden']="existing"; $_SESSION=array_merge($_SESSION,$_POST); echo '<pre>'.print_r($_SESSION,true).'</pre>'; ``` Better would be to use ``` $_SESSION['POST']=$_POST; ``` Obviously, perform any data checks you need to before doing this though
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't use single quotes: ``` foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } ``` I'd encourage you to read about [Strings in PHP](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single). **Note:** This is potentially unsafe for several reasons - mostly injection by key collision. Consider if I *posted* the logged in user id. This could be mitigated through encapsulation: ``` $_SESSION['posted_data'] = $_POST; ```
Ignoring the security issues this could cause depending on how you use it, what you could do is use: ``` $_SESSION = array_merge($_POST, $_SESSION); ``` This will only bring in POST vars which have a key not already found in $\_SESSION. Switch them around if you want the POST vars to take precedence of course. Just a quick note on security, if like a lot of people you use the session to store user id, what would happen if i sent a POST request to your script with `userid=1`? All im saying is, be careful what you are doing with this. You'd be better off if possible doing as suggested and using a unique key in $\_SESSION for post vars such as `$_SESSION['post_vars'] = $_POST` (or maybe `['form_data']` if you're using it to persist form data, which is usually why people do this).
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
If you **really** want to do it as you state, you could use something like ``` $_SESSION=array_merge($_SESSION,$_POST); ``` which would work but be a "bad thing" - plenty of scope to overwrite items already in the `$_SESSION` variable: index.php: ``` <form action="2.php" method="post"> <input type="text" name="hidden" value="hidden"> <button type="submit">Click</button> </form> ``` 2.php: ``` <?php session_start(); session_unset(); $_SESSION['hidden']="existing"; $_SESSION=array_merge($_SESSION,$_POST); echo '<pre>'.print_r($_SESSION,true).'</pre>'; ``` Better would be to use ``` $_SESSION['POST']=$_POST; ``` Obviously, perform any data checks you need to before doing this though
You could also use the [array union operator](http://php.net/language.operators.array): ``` $_SESSION = $_POST + $_SESSION; ``` This takes the values of `$_POST` and adds those values of `$_SESSION` whose keys are not already present in `$_POST`.
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
Don't you rather want to keep them separated? ``` $_SESSION['response'] = $_POST; ```
You could also use the [array union operator](http://php.net/language.operators.array): ``` $_SESSION = $_POST + $_SESSION; ``` This takes the values of `$_POST` and adds those values of `$_SESSION` whose keys are not already present in `$_POST`.
18,383,869
Would this be the correct way to loop through the $POST data sent by an API and have a equivalent $SESSION name/value pair be created from it? ``` foreach($_POST as $key=>$value) { $_SESSION['$key']=$value; } ``` **UPDATE:** First, thanks for the solid responses - I think I need to explain the problem I'm trying to overcome and why this functionality is being considered. The $\_POST response is coming from a payment processor gateway - the problem is that since the payment form/processing is not on our domain the results of the payment (approved/declined etc. etc.) is being RELAYED to our server via $POST - When our PHP code tries to process the response data it looks for various PHP structures (Like php include 'file.php') under there domain instead of ours and errors out - I need to move the $POST data into a session and then move the person back to our domain so that the file/directory/resource tree is correct. Does this make sense what im encountering?
2013/08/22
[ "https://Stackoverflow.com/questions/18383869", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2065226/" ]
If you **really** want to do it as you state, you could use something like ``` $_SESSION=array_merge($_SESSION,$_POST); ``` which would work but be a "bad thing" - plenty of scope to overwrite items already in the `$_SESSION` variable: index.php: ``` <form action="2.php" method="post"> <input type="text" name="hidden" value="hidden"> <button type="submit">Click</button> </form> ``` 2.php: ``` <?php session_start(); session_unset(); $_SESSION['hidden']="existing"; $_SESSION=array_merge($_SESSION,$_POST); echo '<pre>'.print_r($_SESSION,true).'</pre>'; ``` Better would be to use ``` $_SESSION['POST']=$_POST; ``` Obviously, perform any data checks you need to before doing this though
Ignoring the security issues this could cause depending on how you use it, what you could do is use: ``` $_SESSION = array_merge($_POST, $_SESSION); ``` This will only bring in POST vars which have a key not already found in $\_SESSION. Switch them around if you want the POST vars to take precedence of course. Just a quick note on security, if like a lot of people you use the session to store user id, what would happen if i sent a POST request to your script with `userid=1`? All im saying is, be careful what you are doing with this. You'd be better off if possible doing as suggested and using a unique key in $\_SESSION for post vars such as `$_SESSION['post_vars'] = $_POST` (or maybe `['form_data']` if you're using it to persist form data, which is usually why people do this).
41,645,853
First off this is a pretty basic problem, but i just cant seem to get it, ok so here is a general overview of my program ``` |class A | |new B();| |new C();| / \ / \ |Class B | |Class C | |new D();| |method E(){}| | |Class D | |Invokes method E| ``` This is my programs hierarchy and I want to invoke the non static method E from class D, without creating a new instance of class C, is there a way to do this or do i have to restructure my class hierarchy. \*\*EDIT:\*\*Here is real code to display my problem(without a class B though): ``` import javax.swing.JFrame; import javax.swing.JSplitPane; public class TheFrame extends JFrame{ public TheFrame(){ setTitle("Suduku Solver"); add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new TextLabel(), new ChangeButton())); setVisible(true); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setSize(300,300); setLocationRelativeTo(null); } public static void main(String[] args) { new TheFrame(); } } import javax.swing.JLabel; public class TextLabel extends JLabel{ public TextLabel(){ setText("This is the Label"); } public void ChangeLabel(){ setText("Changed Label"); } } import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; public class ChangeButton extends JButton { public ChangeButton(){ setText("Click to change Label"); addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent e) { //Invoke TextLabel changeText method here } }); } } ``` i would like to invoke the changeText method by clicking the button
2017/01/14
[ "https://Stackoverflow.com/questions/41645853", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6096085/" ]
Just use `into`: ``` select O.[full name], O.[EID], O.[Loc], GL.* into #NewTable from [dbo].[team] O outer apply [dbo].[fngetlocdetail](O.[eWorkCity]) GL; ``` You should specify the column names for `GL`. As @Prdp aptly points out, this will fail if the column names in `GL` duplicate one of the other names.
Did you try to use the [Select Into](http://www.w3schools.com/sql/sql_select_into.asp) statement? ``` SELECT column_name(s) INTO newtable [IN externaldb] FROM table1; ```
49,069,956
I'm currently working on a react native project . Here I want to use Realm as database incorporated with Redux.I searched over internet and theoretically tried to understand how whole things works together. But I found no simple demo / source code to get a clear picture of whole thing. Official website of Realm provides some good hints to depict the scenario and some useful guidelines but it did not provide the complete solution which I need. Is there any useful resource with full source code (simple ,easy to understand) on how redux ,realm and react-native works together ? It would be a great help for me.
2018/03/02
[ "https://Stackoverflow.com/questions/49069956", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4390775/" ]
Comparing Redux and Realm is odd. But, whether to have them both are choose one between them is sure, a problem. For getting clear with, you can read the following links: * What is functionality difference between redux and realm, and which suits React? - Read this [comment](https://github.com/realm/realm-js/issues/141#issuecomment-200540036) * RN+Redux+Realm - R3 solution in theory - this [article](https://medium.com/@manggit/react-native-redux-realm-js-r3-js-a-new-mobile-development-standard-5290ec02a590) * R3 solution in practical code - this [article](https://medium.com/@manggit/code-example-react-native-redux-realm-js-r3-js-cb35e8998a42). The continuation of previous article In my opinion React + Redux + Realm = R3 makes a good solution.
It's time to avoid using Redux everywhere. It added tremendous complexity and so many steps to interact with DB. Also, the usual suggested approach of opening Realm connection inside actions is problematic since you don't use the real benefits of Realm objects. Here we ended up removing Redux altogether. <https://medium.com/schmiedeone/avoid-using-redux-with-realm-move-to-a-thinner-data-layer-react-native-8e80cc7b07b3>
1,468,619
I'm asking for the advice. I'm working at the Silverlight 3 application and now I should select the mean how to save the information and get it. I could save the necessary info in files (from 1 to 300K size) or I could save them in database. If I would use WebClient for accessing to separate file there's very low loading of the server. If I get data from database the server would load much more I think and the code on the server too. Please correct me if I'm not right. I'm looking forward to hearing from you! Thanks
2009/09/23
[ "https://Stackoverflow.com/questions/1468619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/46503/" ]
there are additional considerations if you use a file that is localized to the users machine. If you wish to save data w/o any user intervention then you are limited to using Isolated Storage, which has constraints on the size of your data. Otherwise, you have to ask the user for information on where to save/load the file. This is due to the security model used by silverlight. i am thinking that a Database and the RIA framework might be the way to go. just my 2垄
If you are saving and loading the entire file at a time, then it might be okay to use a WebClient. This might take a little coding to handle errors that may result in incomplete saves. If you're serializing some objects or xml data and storing that in a file, then you should probably be using a database instead. Edit: It can be a pain to get WebClient or HttpWebRequest working correctly with GET/POST, but WCF can also be a pain to configure if you haven't done it before. WCF is probably better style, and you'll want to use a binary binding and send the file across as a byte[].
9,602,127
I use graphviz (v2.28.0) as a library in a C++ application and I would like to render graphs using the dot layout. Everything works fine until I call the **gvLayout(\_context, \_graph, "dot");** function which outputs the following error : ``` Error: Layout type: "dot" not recognized. Use one of: ``` I use the following library flags when linking : ``` -lgvc -lgraph -lpathplan -lcdt -lgvplugin_dot_layout ``` Calling dot from the Unix command line works as expected. What am I doing wrong ?
2012/03/07
[ "https://Stackoverflow.com/questions/9602127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1137884/" ]
You probably either already fixed this or gave up, but I ended up here so I'm sure someone else will... Plugins need to be loaded explicitly. I'm not sure whether this is related to static linking or needs to be done whenever graphviz is used as a library. This fixed dot for me: ``` extern gvplugin_library_t gvplugin_dot_layout_LTX_library; gvAddLibrary(gvc, &gvplugin_dot_layout_LTX_library); ```
Do you use graphviz with dynamic library loading? In a static environment the following lines may help: ``` #include "gvplugin.h" extern gvplugin_library_t gvplugin_dot_layout_LTX_library; extern gvplugin_library_t gvplugin_neato_layout_LTX_library; extern gvplugin_library_t gvplugin_core_LTX_library; extern gvplugin_library_t gvplugin_quartz_LTX_library; extern gvplugin_library_t gvplugin_visio_LTX_library; lt_symlist_t lt_preloaded_symbols[] = { { "gvplugin_dot_layout_LTX_library", &gvplugin_dot_layout_LTX_library}, { "gvplugin_neato_layout_LTX_library", &gvplugin_neato_layout_LTX_library}, { "gvplugin_core_LTX_library", &gvplugin_core_LTX_library}, { "gvplugin_quartz_LTX_library", &gvplugin_quartz_LTX_library}, { "gvplugin_visio_LTX_library", &gvplugin_visio_LTX_library}, { 0, 0} }; ```
9,602,127
I use graphviz (v2.28.0) as a library in a C++ application and I would like to render graphs using the dot layout. Everything works fine until I call the **gvLayout(\_context, \_graph, "dot");** function which outputs the following error : ``` Error: Layout type: "dot" not recognized. Use one of: ``` I use the following library flags when linking : ``` -lgvc -lgraph -lpathplan -lcdt -lgvplugin_dot_layout ``` Calling dot from the Unix command line works as expected. What am I doing wrong ?
2012/03/07
[ "https://Stackoverflow.com/questions/9602127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1137884/" ]
I got this error when I added the "-O2" optimization flag to gcc when I compiled graphviz on macosx. When I removed that flag, the error went away.
Do you use graphviz with dynamic library loading? In a static environment the following lines may help: ``` #include "gvplugin.h" extern gvplugin_library_t gvplugin_dot_layout_LTX_library; extern gvplugin_library_t gvplugin_neato_layout_LTX_library; extern gvplugin_library_t gvplugin_core_LTX_library; extern gvplugin_library_t gvplugin_quartz_LTX_library; extern gvplugin_library_t gvplugin_visio_LTX_library; lt_symlist_t lt_preloaded_symbols[] = { { "gvplugin_dot_layout_LTX_library", &gvplugin_dot_layout_LTX_library}, { "gvplugin_neato_layout_LTX_library", &gvplugin_neato_layout_LTX_library}, { "gvplugin_core_LTX_library", &gvplugin_core_LTX_library}, { "gvplugin_quartz_LTX_library", &gvplugin_quartz_LTX_library}, { "gvplugin_visio_LTX_library", &gvplugin_visio_LTX_library}, { 0, 0} }; ```
9,602,127
I use graphviz (v2.28.0) as a library in a C++ application and I would like to render graphs using the dot layout. Everything works fine until I call the **gvLayout(\_context, \_graph, "dot");** function which outputs the following error : ``` Error: Layout type: "dot" not recognized. Use one of: ``` I use the following library flags when linking : ``` -lgvc -lgraph -lpathplan -lcdt -lgvplugin_dot_layout ``` Calling dot from the Unix command line works as expected. What am I doing wrong ?
2012/03/07
[ "https://Stackoverflow.com/questions/9602127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1137884/" ]
You probably either already fixed this or gave up, but I ended up here so I'm sure someone else will... Plugins need to be loaded explicitly. I'm not sure whether this is related to static linking or needs to be done whenever graphviz is used as a library. This fixed dot for me: ``` extern gvplugin_library_t gvplugin_dot_layout_LTX_library; gvAddLibrary(gvc, &gvplugin_dot_layout_LTX_library); ```
I got this error when I added the "-O2" optimization flag to gcc when I compiled graphviz on macosx. When I removed that flag, the error went away.
9,602,127
I use graphviz (v2.28.0) as a library in a C++ application and I would like to render graphs using the dot layout. Everything works fine until I call the **gvLayout(\_context, \_graph, "dot");** function which outputs the following error : ``` Error: Layout type: "dot" not recognized. Use one of: ``` I use the following library flags when linking : ``` -lgvc -lgraph -lpathplan -lcdt -lgvplugin_dot_layout ``` Calling dot from the Unix command line works as expected. What am I doing wrong ?
2012/03/07
[ "https://Stackoverflow.com/questions/9602127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1137884/" ]
You probably either already fixed this or gave up, but I ended up here so I'm sure someone else will... Plugins need to be loaded explicitly. I'm not sure whether this is related to static linking or needs to be done whenever graphviz is used as a library. This fixed dot for me: ``` extern gvplugin_library_t gvplugin_dot_layout_LTX_library; gvAddLibrary(gvc, &gvplugin_dot_layout_LTX_library); ```
According to a [reply](http://graphviz.996277.n3.nabble.com/How-to-load-libraries-in-correct-order-no-plugins-found-tp2174p2175.html) by Emden R. Gansner on the ['graphviz-interest' mailing list](http://graphviz.996277.n3.nabble.com/Graphviz-Interest-f3.html), this error message indicates that the software was unable to find the graphviz config file. The graphviz config file (`config6`) is used by the `gvc` library to load the various `libgvplugin_...` libraries on demand. Gansner also mentions that graphviz supports a [`GVBINDIR` environment variable](https://www.graphviz.org/doc/info/command.html) which, if defined, is used to specify the directory containing the graphviz config file. This is also discussed at [How to configure & package Graphviz for Mac App Store?](https://stackoverflow.com/q/43009041/822699). In my case (where I'm trying to include the graphviz libraries in an macOS/Objective-C framework), a framework subdirectory (called "Libraries") contains the `config6` file plus these `libgvplugin_...` libraries (next to the regular graphviz libraries): ``` Libraries: config6 libgvplugin_core.6.dylib libgvplugin_dot_layout.6.dylib libgvplugin_gd.6.dylib libgvplugin_neato_layout.6.dylib libgvplugin_quartz.6.dylib ``` From within one of the framework's classes, one could then set the `GVBINDIR` environment variable like this: ```c NSBundle *containingBundle = [NSBundle bundleForClass:[self class]]; NSURL *librariesDirURL = [[containingBundle bundleURL] URLByAppendingPathComponent:@"Versions/A/Libraries" isDirectory:YES]; if (librariesDirURL) { setenv("GVBINDIR", (char*)[[librariesDirURL path] UTF8String], 1); } ``` Setting the `GVBINDIR` environment variable is the only solution that worked for me. I've also tried the solutions mentioned by others above including loading the default graphviz plugins explicitly. E.g., with `_graphContext` being defined as `static GVC_t *_graphContext`, this code: ```c extern gvplugin_library_t gvplugin_dot_layout_LTX_library; extern gvplugin_library_t gvplugin_neato_layout_LTX_library; extern gvplugin_library_t gvplugin_core_LTX_library; extern gvplugin_library_t gvplugin_quartz_LTX_library; lt_symlist_t lt_preloaded_symbols[] = { { "gvplugin_dot_layout_LTX_library", &gvplugin_dot_layout_LTX_library}, { "gvplugin_neato_layout_LTX_library", &gvplugin_neato_layout_LTX_library}, { "gvplugin_core_LTX_library", &gvplugin_core_LTX_library}, { "gvplugin_quartz_LTX_library", &gvplugin_quartz_LTX_library}, { 0, 0} }; _graphContext = gvContextPlugins(lt_preloaded_symbols, 1); ``` actually worked for me. I.e., this caused the graphviz plugins to load and the above mentioned error message ('Error: Layout type: "dot" not recognized. Use one of:') vanished. However, any subsequent call to `gvLayout()` then caused a graphviz crash (`EXC_BAD_ACCESS`) for me. So for now I'm taking the environment variable approach.
9,602,127
I use graphviz (v2.28.0) as a library in a C++ application and I would like to render graphs using the dot layout. Everything works fine until I call the **gvLayout(\_context, \_graph, "dot");** function which outputs the following error : ``` Error: Layout type: "dot" not recognized. Use one of: ``` I use the following library flags when linking : ``` -lgvc -lgraph -lpathplan -lcdt -lgvplugin_dot_layout ``` Calling dot from the Unix command line works as expected. What am I doing wrong ?
2012/03/07
[ "https://Stackoverflow.com/questions/9602127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1137884/" ]
I got this error when I added the "-O2" optimization flag to gcc when I compiled graphviz on macosx. When I removed that flag, the error went away.
According to a [reply](http://graphviz.996277.n3.nabble.com/How-to-load-libraries-in-correct-order-no-plugins-found-tp2174p2175.html) by Emden R. Gansner on the ['graphviz-interest' mailing list](http://graphviz.996277.n3.nabble.com/Graphviz-Interest-f3.html), this error message indicates that the software was unable to find the graphviz config file. The graphviz config file (`config6`) is used by the `gvc` library to load the various `libgvplugin_...` libraries on demand. Gansner also mentions that graphviz supports a [`GVBINDIR` environment variable](https://www.graphviz.org/doc/info/command.html) which, if defined, is used to specify the directory containing the graphviz config file. This is also discussed at [How to configure & package Graphviz for Mac App Store?](https://stackoverflow.com/q/43009041/822699). In my case (where I'm trying to include the graphviz libraries in an macOS/Objective-C framework), a framework subdirectory (called "Libraries") contains the `config6` file plus these `libgvplugin_...` libraries (next to the regular graphviz libraries): ``` Libraries: config6 libgvplugin_core.6.dylib libgvplugin_dot_layout.6.dylib libgvplugin_gd.6.dylib libgvplugin_neato_layout.6.dylib libgvplugin_quartz.6.dylib ``` From within one of the framework's classes, one could then set the `GVBINDIR` environment variable like this: ```c NSBundle *containingBundle = [NSBundle bundleForClass:[self class]]; NSURL *librariesDirURL = [[containingBundle bundleURL] URLByAppendingPathComponent:@"Versions/A/Libraries" isDirectory:YES]; if (librariesDirURL) { setenv("GVBINDIR", (char*)[[librariesDirURL path] UTF8String], 1); } ``` Setting the `GVBINDIR` environment variable is the only solution that worked for me. I've also tried the solutions mentioned by others above including loading the default graphviz plugins explicitly. E.g., with `_graphContext` being defined as `static GVC_t *_graphContext`, this code: ```c extern gvplugin_library_t gvplugin_dot_layout_LTX_library; extern gvplugin_library_t gvplugin_neato_layout_LTX_library; extern gvplugin_library_t gvplugin_core_LTX_library; extern gvplugin_library_t gvplugin_quartz_LTX_library; lt_symlist_t lt_preloaded_symbols[] = { { "gvplugin_dot_layout_LTX_library", &gvplugin_dot_layout_LTX_library}, { "gvplugin_neato_layout_LTX_library", &gvplugin_neato_layout_LTX_library}, { "gvplugin_core_LTX_library", &gvplugin_core_LTX_library}, { "gvplugin_quartz_LTX_library", &gvplugin_quartz_LTX_library}, { 0, 0} }; _graphContext = gvContextPlugins(lt_preloaded_symbols, 1); ``` actually worked for me. I.e., this caused the graphviz plugins to load and the above mentioned error message ('Error: Layout type: "dot" not recognized. Use one of:') vanished. However, any subsequent call to `gvLayout()` then caused a graphviz crash (`EXC_BAD_ACCESS`) for me. So for now I'm taking the environment variable approach.
196,416
So I trying to use list of wrapper class as iterator in batch. below is the code I have tried so far Iterable class -------------- ``` public class AccountCustomIterator implements Iterable<AccountWrapper>, Iterator<AccountWrapper> { public List<AccountWrapper> lstAccountWrapper; Integer i {get; set;} public AccountCustomIterator(List<AccountWrapper> lstAccountWrapper) { this.lstAccountWrapper = lstAccountWrapper; i = 0; } public Boolean hasNext() { return (i >= lstAccountWrapper.size()) ? false : true; } public AccountWrapper next() { if(i < lstAccountWrapper.size()) { i = i+1; return lstAccountWrapper[i-1]; } return null; } public Iterator<AccountWrapper> iterator() { return this; } public class AccountWrapper { public String strUnique = ''; public List<Account> lstAccount = new List<Account>(); public AccountWrapper(String strUnique, List<Account> lstAccount) { this.strUnique = strUnique; this.lstAccount = lstAccount; } } } ``` And here is the batch class --------------------------- ``` global class AccountChildrecordsUpdateBatch implements Database.batchable<AccountCustomIterator.AccountWrapper> { global Iterator<AccountCustomIterator.AccountWrapper> start(Database.BatchableContext BC) { List<AccountCustomIterator.AccountWrapper> lst = new List<AccountCustomIterator.AccountWrapper>(); return new AccountCustomIterator(lst); } global void execute(Database.BatchableContext BC, List<AccountCustomIterator.AccountWrapper> scope) { } global void finish(Database.BatchableContext BC) { } } ``` unable to save the batch file getting below error > > line 1, col 14. Class AccountChildrecordsUpdateBatch must implement > the method: System.Iterable > Database.Batchable.start(Database.BatchableContext) > > >
2017/10/21
[ "https://salesforce.stackexchange.com/questions/196416", "https://salesforce.stackexchange.com", "https://salesforce.stackexchange.com/users/18731/" ]
Note that there are two separate classes: `Iterable` and `Iterator`. In your question you use the latter where the interface demands the former. Note also that a `List` is an `Iterable`: ``` Object demo = new List<String>(); system.assert(demo instanceof Iterable<String>); ``` So you can just return the list. No need to define your own custom classes nor wrap the list in anything. ``` public with sharing class MyBatch implements Database.Batchable<MyClass> { public Iterable<MyClass> start(Database.BatchableContext context) { return new List<MyClass>(); // obviously the list can be populated // the point here is just to illustrate // you can return a List as an Iterable } public void execute(Database.BatchableContext context, List<MyClass> scope) { } public void finish(Database.BatchableContext context) { } } ```
ok So I found the issue able to resolve it. Below is code for custom data type as batch iterator ``` global class AccountChildrecordsUpdateBatch implements Database.batchable<AccountCustomIterator.AccountWrapper> { global Iterable<AccountCustomIterator.AccountWrapper> start(Database.BatchableContext BC) { List<AccountCustomIterator.AccountWrapper> lstAccWrap = new List<AccountCustomIterator.AccountWrapper>(); List<Account> lstAccount = [SELECT Id, Name FROM Account]; map<String, List<Account>> mapUniqNameToLstAcc = new map<String, List<Account>>(); for(Account objAcc: lstAccount) { if(!mapUniqNameToLstAcc.containsKey(objAcc.Name)) mapUniqNameToLstAcc.put(objAcc.Name)), new List<Account>{}); mapUniqNameToLstAcc.get(objAcc.Name)).add(objAcc); } for(String strUnique:mapUniqNameToLstAcc.keySet()) { lstAccWrap.add(new AccountCustomIterator.AccountWrapper(strUnique, mapUniqNameToLstAcc.get(strUnique))); } return new AccountCustomIterator(lstAccWrap); } global void execute(Database.BatchableContext BC, List<object> scope) { List<AccountCustomIterator.AccountWrapper> lstWrap = (List<AccountCustomIterator.AccountWrapper>)scope; system.debug('======exetcute method-scope--'+ lstWrap); } global void finish(Database.BatchableContext BC) { } } ```
25,124,499
As per the question, let's say you have the following code: ``` Random rand = new Random(); for (int k = 0; k < rand.nextInt(10); k++) { //Do stuff here } ``` Does `k` get compared to `rand.nextInt(10)` only once, when the loop starts running, so that there's an equal chance of the loop running at every interval between 0 and 9? Or does it get compared each iteration of the loop, making it more likely for lower numbers to occur? Furthermore, does this differ between languages? My example is for Java, but is there a standard that exists between most languages?
2014/08/04
[ "https://Stackoverflow.com/questions/25124499", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3907638/" ]
> > Does k get compared to rand.nextInt(10) only once, when the loop starts running? > > > No, `k` is compared to the next random number the `rand` generates each time the loop continuation condition is checked. If you wish to generate a random number once, define a variable, and set it to `nextInt(10)` before the loop. You could also use an alternative that counts backwards: ``` for (int k = rand.nextInt(10); k >= 0 ; k--) { //Do stuff here } ``` The same is true in at least four other languages which use this syntax of the `for` loop - C++, C, C#, and Objective C.
Let's `testIt()` ``` public static int testIt() { System.out.println("testIt()"); return 2; } public static void main(String[] args) { for (int i = 0; i < testIt(); i++) { System.out.println(i); } } ``` Output is ``` testIt() 0 testIt() 1 testIt() ``` The answer is it gets compared at each iteration of the loop, making it more likely for lower numbers to occur. It might vary in other languages. Even if it doesn't today, it might tomorrow. If you want to know, you should test it. **Edit** For example, in Java 8 you could write ``` import static java.util.stream.IntStream.rangeClosed; // ... public static void main(String[] args) { Random rand = new Random(); rangeClosed(1,1+rand.nextInt(10)).forEach(n -> System.out.println(n)); } ```
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
To substract to dates you can get them both as longs `getTime()` and subtract the values that are returned.
There is a framework to work with the date in java... <http://joda-time.sourceforge.net/userguide.html> take a look, i'm sure that it can help you
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
To substract to dates you can get them both as longs `getTime()` and subtract the values that are returned.
It depends what do you want. To get difference in milliseconds say `dtStartDate.getTime() - dtEndDate.getTime()`. To get difference in days, hours etc use Calendar class (methods like after, before, compareTo, roll may help).
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
To substract to dates you can get them both as longs `getTime()` and subtract the values that are returned.
``` long diffInMillis = dtEndDate.getTimeInMillis() - dtStartDate.getTimeInMillis(); ```
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
> > ***how can i subtract these two Dates?*** > > > You can get the difference in milliseconds like this: ``` dtEndDate.getTime() - dtStartDate.getTime() ``` ([`getTime`](http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html#getTime%28%29) returns the number of milliseconds since January 1, 1970, 00:00:00 GMT.) However, for this type of date arithmetics the [Joda time library](http://joda-time.sourceforge.net/), which has proper classes for time durations (`Duration`) is probably a better option.
Create two [Calendar](http://download.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html) objects from those Dates and then use the add() method (which can be used to subtrade dates too).
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
> > ***how can i subtract these two Dates?*** > > > You can get the difference in milliseconds like this: ``` dtEndDate.getTime() - dtStartDate.getTime() ``` ([`getTime`](http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html#getTime%28%29) returns the number of milliseconds since January 1, 1970, 00:00:00 GMT.) However, for this type of date arithmetics the [Joda time library](http://joda-time.sourceforge.net/), which has proper classes for time durations (`Duration`) is probably a better option.
There is a framework to work with the date in java... <http://joda-time.sourceforge.net/userguide.html> take a look, i'm sure that it can help you
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
``` long msDiff = dtEndDate.getTime() - dtStartDate.getTime() ``` `msDiff` now holds the number of milliseconds difference between the two dates. Feel free to use the division and mod operators to convert to other units.
Create two [Calendar](http://download.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html) objects from those Dates and then use the add() method (which can be used to subtrade dates too).
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
To substract to dates you can get them both as longs `getTime()` and subtract the values that are returned.
Create two [Calendar](http://download.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html) objects from those Dates and then use the add() method (which can be used to subtrade dates too).
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
> > ***how can i subtract these two Dates?*** > > > You can get the difference in milliseconds like this: ``` dtEndDate.getTime() - dtStartDate.getTime() ``` ([`getTime`](http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html#getTime%28%29) returns the number of milliseconds since January 1, 1970, 00:00:00 GMT.) However, for this type of date arithmetics the [Joda time library](http://joda-time.sourceforge.net/), which has proper classes for time durations (`Duration`) is probably a better option.
``` long diffInMillis = dtEndDate.getTimeInMillis() - dtStartDate.getTimeInMillis(); ```
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
> > ***how can i subtract these two Dates?*** > > > You can get the difference in milliseconds like this: ``` dtEndDate.getTime() - dtStartDate.getTime() ``` ([`getTime`](http://download.oracle.com/javase/1.4.2/docs/api/java/util/Date.html#getTime%28%29) returns the number of milliseconds since January 1, 1970, 00:00:00 GMT.) However, for this type of date arithmetics the [Joda time library](http://joda-time.sourceforge.net/), which has proper classes for time durations (`Duration`) is probably a better option.
To substract to dates you can get them both as longs `getTime()` and subtract the values that are returned.
6,537,023
> > **Possible Duplicate:** > > [How to calculate time difference in java?](https://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) > > > Actually I want to subtract two dates in Java. I tried a lot but can't succeed. So anyone please help me. ``` Date dtStartDate=pCycMan.getStartDate(); Date dtEndDate=pCycMan.getEndDate(); ``` How can I subtract these two Dates?
2011/06/30
[ "https://Stackoverflow.com/questions/6537023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/806106/" ]
``` long msDiff = dtEndDate.getTime() - dtStartDate.getTime() ``` `msDiff` now holds the number of milliseconds difference between the two dates. Feel free to use the division and mod operators to convert to other units.
There is a framework to work with the date in java... <http://joda-time.sourceforge.net/userguide.html> take a look, i'm sure that it can help you
67,583,870
I am creating a Discord bot in Discord.js and I need your "+help". The `+help` command will display an embed containing all the relevant commands. However, when I make the embed, I get this error. ```js TypeError: Cannot read property 'MessageEmbed' of undefined ``` If you are curious, here is my code in `help.js`: ```js module.exports = { name: "help", description: "Help embed.", execute(message, args, Discord) { const Help = new Discord.MessageEmbed() .setColor("red") .setTitle("Command List") .setAuthor("Bots for Guilds") .setDescription("List of all commands with BFG software") .addFields ( {name: "`+help`", value: "Shows all the commands."}, {name: "`+ping`", value: "Ping-pong command: you write `+ping`, and the bot responds \"pong!\""}, {name: "`+cheenta`", value: "Gives a link to my presentation at Cheenta Bose Olympiad Round 7."}, {name: "`+whoisatharv`", value: "Gives information about me."}, {name: "`+youtube`", value: "Give my YouTube Channel link."} ); message.channel.send(Help); } } ``` And `help.js` is being connected to my source file (`main.js`) with a command handler: ```js else if (command === "help") { client.commands.get("help").execute(message, args); } ``` (The `else if` is because there are more commands.) Can you help me?
2021/05/18
[ "https://Stackoverflow.com/questions/67583870", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15860183/" ]
Try using just MessageEmbed() remove Discord from execute as well so like ```py module.exports = { name: "help", description: "Help embed.", execute(message, args) { const Help = new Discord.MessageEmbed() .setColor("red") .setTitle("Command List") .setAuthor("Bots for Guilds") .setDescription("List of all commands with BFG software") .addFields ( {name: "`+help`", value: "Shows all the commands."}, {name: "`+ping`", value: "Ping-pong command: you write `+ping`, and the bot responds \"pong!\""}, {name: "`+cheenta`", value: "Gives a link to my presentation at Cheenta Bose Olympiad Round 7."}, {name: "`+whoisatharv`", value: "Gives information about me."}, {name: "`+youtube`", value: "Give my YouTube Channel link."} ); message.channel.send(Help); } } ```
According to @Tyler2P's comment, I used `Discord` object in the `execute()` function in `help.js`, but I did not in `client.commands.get().execute()` in `main.js`.
5,081,454
I have built a FB4 application which accesses a .NET web service of a partner company. The app runs just fine in FB4 development environment, but won't work when published to my server. I can not figure out how to get past the following error: > > Security error accessing url Destination: DefaultHTTP > > > It is unlikely that I will get a crossdomain.xml file on their server, so I'm trying to get it to work using a proxy. The proxy.php is located in the same directory as the swf, and it works just fine if I use it directly in the browser. The following is what I currently have setup: proxy.php: ``` <?php $session = curl_init(trim(urldecode($_GET['url']))); // Open the Curl session curl_setopt($session, CURLOPT_HEADER, false); // Don't return HTTP headers curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Do return the contents of the call $xml = curl_exec($session); // Make the call header("Content-Type: text/xml"); // Set the content type appropriately echo $xml; // Spit out the xml curl_close($session); ?> ``` The code in Flash Builder 4 (I'm using a Webservice object in FB4): ``` wsdl = http://example.com/autoben/proxy2.php?url=http://staging.partnerCompany.net/api/v01_00/theservice.asmx?wsdl ``` The flash player is version 10.x I'm obviously not understanding the new security rules built into the latest Flash player. A **screenshot** of the error can be seen here: ![flex error](https://i.stack.imgur.com/dEd0t.jpg)
2011/02/22
[ "https://Stackoverflow.com/questions/5081454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/628711/" ]
Sounds like a cross domain policy issue. Check here <http://livedocs.adobe.com/flex/3/html/help.html?content=security2_04.html> for Adobe's advice.
I can't see any obvious reason to why this should not work in concept. So it's likely some minor detail tripping this up. I would recommend using a web debug proxy to work out exactly what is going across the pipes, I personally prefer [Charles](http://www.charlesproxy.com/) but something like [Fiddler](http://www.fiddler2.com/fiddler2/) should work too.
5,081,454
I have built a FB4 application which accesses a .NET web service of a partner company. The app runs just fine in FB4 development environment, but won't work when published to my server. I can not figure out how to get past the following error: > > Security error accessing url Destination: DefaultHTTP > > > It is unlikely that I will get a crossdomain.xml file on their server, so I'm trying to get it to work using a proxy. The proxy.php is located in the same directory as the swf, and it works just fine if I use it directly in the browser. The following is what I currently have setup: proxy.php: ``` <?php $session = curl_init(trim(urldecode($_GET['url']))); // Open the Curl session curl_setopt($session, CURLOPT_HEADER, false); // Don't return HTTP headers curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Do return the contents of the call $xml = curl_exec($session); // Make the call header("Content-Type: text/xml"); // Set the content type appropriately echo $xml; // Spit out the xml curl_close($session); ?> ``` The code in Flash Builder 4 (I'm using a Webservice object in FB4): ``` wsdl = http://example.com/autoben/proxy2.php?url=http://staging.partnerCompany.net/api/v01_00/theservice.asmx?wsdl ``` The flash player is version 10.x I'm obviously not understanding the new security rules built into the latest Flash player. A **screenshot** of the error can be seen here: ![flex error](https://i.stack.imgur.com/dEd0t.jpg)
2011/02/22
[ "https://Stackoverflow.com/questions/5081454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/628711/" ]
Sounds like a cross domain policy issue. Check here <http://livedocs.adobe.com/flex/3/html/help.html?content=security2_04.html> for Adobe's advice.
Make sure you're using relative paths to get the url and not absolute, if you go to <http://mydomain.com> and it tries to get the proxy url from <http://www.mydomain.com> (www. subdomain) a security error will be thrown.
21,580,391
I'm not sure how to refer to what I need to do. So here is an example of the formatting. ``` Where ABC is the Actual Before Calculation A is the total population of the US XYB is the percentage that own their own homes XYC is the percentage in a rural area ``` Notice how all the sentences are aligned with the word `is`. It's kind of a smart indenting, for lack of a better term. You have the right term, then please enlighten me. I've not found an HTML/CSS page that does this, but I have seen it in print. Or would PHP be needed to do this? Thanks!
2014/02/05
[ "https://Stackoverflow.com/questions/21580391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1573545/" ]
You could use a table, I did a quick JSFiddle: ``` <table> <tr> <td>Where ABC is</td> <td>the Actual Before Calculation</td> </tr> <tr> <td>Where A is</td> <td>the total population of the US</td> </tr> </table> ``` [JSFiddle](http://jsfiddle.net/Z6fr5/1/) With some CSS you can align the text of the first `td` on the right: ``` td:first-of-type { text-align: right; } ```
You'll have various solutions. Here's one building a `table` from your unformatted text using jQuery : ``` var lines = $('#a').text().split('\n'); $t = $('<table>').appendTo($('#a').empty()); lines.forEach(function(l){ var m = l.match(/(.*)( is )(.*)/); if (m) $t.append('<tr><td>'+m[1]+'</td><td>'+m[2]+'</td><td>'+m[3]+'</td></tr>'); }); ``` [Demonstration](http://jsbin.com/IcArufIR/4/) EDIT : I understood the question as the need to start from a not formatted text. If you can do the formatting by hand, disregard this answer.
21,580,391
I'm not sure how to refer to what I need to do. So here is an example of the formatting. ``` Where ABC is the Actual Before Calculation A is the total population of the US XYB is the percentage that own their own homes XYC is the percentage in a rural area ``` Notice how all the sentences are aligned with the word `is`. It's kind of a smart indenting, for lack of a better term. You have the right term, then please enlighten me. I've not found an HTML/CSS page that does this, but I have seen it in print. Or would PHP be needed to do this? Thanks!
2014/02/05
[ "https://Stackoverflow.com/questions/21580391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1573545/" ]
You can use a **[Definition List](http://www.w3schools.com/tags/tag_dl.asp)** for this: **HTML** ``` <dl> <dt>Where ABC is</dt> <dd>the Actual Before Calculation</dd> <dt>A is</dt> <dd>the total population of the US</dd> <dt>XYB is</dt> <dd>the percentage that own their own homes</dd> <dt>XYC is</dt> <dd>the percentage in a rural area</dd> </dl> ``` **CSS** ``` dl { border: 3px double #ccc; padding: 0.5em; } dt { float: left; clear: left; width: 140px; text-align: right; font-weight: bold; color: green; } dd { margin: 0 0 0 145px; padding: 0 0 0.5em 0; min-height: 1em; } ``` **[Demo](http://jsfiddle.net/6KaML/5/)**
You could use a table, I did a quick JSFiddle: ``` <table> <tr> <td>Where ABC is</td> <td>the Actual Before Calculation</td> </tr> <tr> <td>Where A is</td> <td>the total population of the US</td> </tr> </table> ``` [JSFiddle](http://jsfiddle.net/Z6fr5/1/) With some CSS you can align the text of the first `td` on the right: ``` td:first-of-type { text-align: right; } ```
21,580,391
I'm not sure how to refer to what I need to do. So here is an example of the formatting. ``` Where ABC is the Actual Before Calculation A is the total population of the US XYB is the percentage that own their own homes XYC is the percentage in a rural area ``` Notice how all the sentences are aligned with the word `is`. It's kind of a smart indenting, for lack of a better term. You have the right term, then please enlighten me. I've not found an HTML/CSS page that does this, but I have seen it in print. Or would PHP be needed to do this? Thanks!
2014/02/05
[ "https://Stackoverflow.com/questions/21580391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1573545/" ]
This might help you <http://jsfiddle.net/Ytv8p/1/> HTML ``` <div> <span class="a">Where ABC</span> <span>is</span> <span>the Actual Before Calculation.</span> </div> <div> <span class="a">A</span> <span>is</span> <span>the total population of the US</span> </div> <div> <span class="a">XYB</span> <span>is</span> <span>the percentage that own their own homes</span> </div> <div> <span class="a">XYC</span> <span>is</span> <span>the percentage in a rural area</span> </div> ``` CSS ``` span { display:inline-block; padding:0 2px; } .a { width:80px; text-align:right; } ```
You could use a table, I did a quick JSFiddle: ``` <table> <tr> <td>Where ABC is</td> <td>the Actual Before Calculation</td> </tr> <tr> <td>Where A is</td> <td>the total population of the US</td> </tr> </table> ``` [JSFiddle](http://jsfiddle.net/Z6fr5/1/) With some CSS you can align the text of the first `td` on the right: ``` td:first-of-type { text-align: right; } ```
21,580,391
I'm not sure how to refer to what I need to do. So here is an example of the formatting. ``` Where ABC is the Actual Before Calculation A is the total population of the US XYB is the percentage that own their own homes XYC is the percentage in a rural area ``` Notice how all the sentences are aligned with the word `is`. It's kind of a smart indenting, for lack of a better term. You have the right term, then please enlighten me. I've not found an HTML/CSS page that does this, but I have seen it in print. Or would PHP be needed to do this? Thanks!
2014/02/05
[ "https://Stackoverflow.com/questions/21580391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1573545/" ]
You can use a **[Definition List](http://www.w3schools.com/tags/tag_dl.asp)** for this: **HTML** ``` <dl> <dt>Where ABC is</dt> <dd>the Actual Before Calculation</dd> <dt>A is</dt> <dd>the total population of the US</dd> <dt>XYB is</dt> <dd>the percentage that own their own homes</dd> <dt>XYC is</dt> <dd>the percentage in a rural area</dd> </dl> ``` **CSS** ``` dl { border: 3px double #ccc; padding: 0.5em; } dt { float: left; clear: left; width: 140px; text-align: right; font-weight: bold; color: green; } dd { margin: 0 0 0 145px; padding: 0 0 0.5em 0; min-height: 1em; } ``` **[Demo](http://jsfiddle.net/6KaML/5/)**
You'll have various solutions. Here's one building a `table` from your unformatted text using jQuery : ``` var lines = $('#a').text().split('\n'); $t = $('<table>').appendTo($('#a').empty()); lines.forEach(function(l){ var m = l.match(/(.*)( is )(.*)/); if (m) $t.append('<tr><td>'+m[1]+'</td><td>'+m[2]+'</td><td>'+m[3]+'</td></tr>'); }); ``` [Demonstration](http://jsbin.com/IcArufIR/4/) EDIT : I understood the question as the need to start from a not formatted text. If you can do the formatting by hand, disregard this answer.
21,580,391
I'm not sure how to refer to what I need to do. So here is an example of the formatting. ``` Where ABC is the Actual Before Calculation A is the total population of the US XYB is the percentage that own their own homes XYC is the percentage in a rural area ``` Notice how all the sentences are aligned with the word `is`. It's kind of a smart indenting, for lack of a better term. You have the right term, then please enlighten me. I've not found an HTML/CSS page that does this, but I have seen it in print. Or would PHP be needed to do this? Thanks!
2014/02/05
[ "https://Stackoverflow.com/questions/21580391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1573545/" ]
This might help you <http://jsfiddle.net/Ytv8p/1/> HTML ``` <div> <span class="a">Where ABC</span> <span>is</span> <span>the Actual Before Calculation.</span> </div> <div> <span class="a">A</span> <span>is</span> <span>the total population of the US</span> </div> <div> <span class="a">XYB</span> <span>is</span> <span>the percentage that own their own homes</span> </div> <div> <span class="a">XYC</span> <span>is</span> <span>the percentage in a rural area</span> </div> ``` CSS ``` span { display:inline-block; padding:0 2px; } .a { width:80px; text-align:right; } ```
You'll have various solutions. Here's one building a `table` from your unformatted text using jQuery : ``` var lines = $('#a').text().split('\n'); $t = $('<table>').appendTo($('#a').empty()); lines.forEach(function(l){ var m = l.match(/(.*)( is )(.*)/); if (m) $t.append('<tr><td>'+m[1]+'</td><td>'+m[2]+'</td><td>'+m[3]+'</td></tr>'); }); ``` [Demonstration](http://jsbin.com/IcArufIR/4/) EDIT : I understood the question as the need to start from a not formatted text. If you can do the formatting by hand, disregard this answer.
21,580,391
I'm not sure how to refer to what I need to do. So here is an example of the formatting. ``` Where ABC is the Actual Before Calculation A is the total population of the US XYB is the percentage that own their own homes XYC is the percentage in a rural area ``` Notice how all the sentences are aligned with the word `is`. It's kind of a smart indenting, for lack of a better term. You have the right term, then please enlighten me. I've not found an HTML/CSS page that does this, but I have seen it in print. Or would PHP be needed to do this? Thanks!
2014/02/05
[ "https://Stackoverflow.com/questions/21580391", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1573545/" ]
You can use a **[Definition List](http://www.w3schools.com/tags/tag_dl.asp)** for this: **HTML** ``` <dl> <dt>Where ABC is</dt> <dd>the Actual Before Calculation</dd> <dt>A is</dt> <dd>the total population of the US</dd> <dt>XYB is</dt> <dd>the percentage that own their own homes</dd> <dt>XYC is</dt> <dd>the percentage in a rural area</dd> </dl> ``` **CSS** ``` dl { border: 3px double #ccc; padding: 0.5em; } dt { float: left; clear: left; width: 140px; text-align: right; font-weight: bold; color: green; } dd { margin: 0 0 0 145px; padding: 0 0 0.5em 0; min-height: 1em; } ``` **[Demo](http://jsfiddle.net/6KaML/5/)**
This might help you <http://jsfiddle.net/Ytv8p/1/> HTML ``` <div> <span class="a">Where ABC</span> <span>is</span> <span>the Actual Before Calculation.</span> </div> <div> <span class="a">A</span> <span>is</span> <span>the total population of the US</span> </div> <div> <span class="a">XYB</span> <span>is</span> <span>the percentage that own their own homes</span> </div> <div> <span class="a">XYC</span> <span>is</span> <span>the percentage in a rural area</span> </div> ``` CSS ``` span { display:inline-block; padding:0 2px; } .a { width:80px; text-align:right; } ```
29,903,947
Why am i getting 0. I is an auto variable, so it should print some garbage value, right? I am using gcc compiler. ``` #include "stdio.h" void main() { int i; printf("%d\n", i); } ```
2015/04/27
[ "https://Stackoverflow.com/questions/29903947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4367335/" ]
> > Does gcc initializes auto variable to 0? > > > Yes and No! Actually uninitialized auto variables get **indeterminate value** (either an unspecified value or a trap representation**1**). Using such variables in a program invoke undefined behavior-- *behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which ANSI C International Standard imposes no requirements.* (C11:搂3.4.3) Once UB is invoked you may get either expected or unexpected result. Result may vary run to run of that program, compiler to compiler or even version to version of same compiler, even on temperature of your system! --- **1**. An automatic variable can be initialized to a trap representation without causing undefined behavior, but the value of the variable cannot be used until a proper value is stored in it. (**C11: 6.2.6 Representations of types--Footnote 50**)
Variables declared inside a function are uninitialized. One cannot predict what might show up if you print them out. in your example `main` is a function too. Hence it so happens that it is zero. When you declare variable to be static or gloabally, the compiler will have them initialzed to zero.
29,903,947
Why am i getting 0. I is an auto variable, so it should print some garbage value, right? I am using gcc compiler. ``` #include "stdio.h" void main() { int i; printf("%d\n", i); } ```
2015/04/27
[ "https://Stackoverflow.com/questions/29903947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4367335/" ]
> > Does gcc initializes auto variable to 0? > > > Yes and No! Actually uninitialized auto variables get **indeterminate value** (either an unspecified value or a trap representation**1**). Using such variables in a program invoke undefined behavior-- *behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which ANSI C International Standard imposes no requirements.* (C11:搂3.4.3) Once UB is invoked you may get either expected or unexpected result. Result may vary run to run of that program, compiler to compiler or even version to version of same compiler, even on temperature of your system! --- **1**. An automatic variable can be initialized to a trap representation without causing undefined behavior, but the value of the variable cannot be used until a proper value is stored in it. (**C11: 6.2.6 Representations of types--Footnote 50**)
No, I get random values with gcc (Debian 4.9.2-10) 4.9.2. ``` ofd@ofd-pc:~$ gcc '/home/ofd/Destkop/test.c' ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218415715 ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218653283 ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218845795 ```
29,903,947
Why am i getting 0. I is an auto variable, so it should print some garbage value, right? I am using gcc compiler. ``` #include "stdio.h" void main() { int i; printf("%d\n", i); } ```
2015/04/27
[ "https://Stackoverflow.com/questions/29903947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4367335/" ]
> > Does gcc initializes auto variable to 0? > > > Yes and No! Actually uninitialized auto variables get **indeterminate value** (either an unspecified value or a trap representation**1**). Using such variables in a program invoke undefined behavior-- *behavior, upon use of a nonportable or erroneous program construct or of erroneous data, for which ANSI C International Standard imposes no requirements.* (C11:搂3.4.3) Once UB is invoked you may get either expected or unexpected result. Result may vary run to run of that program, compiler to compiler or even version to version of same compiler, even on temperature of your system! --- **1**. An automatic variable can be initialized to a trap representation without causing undefined behavior, but the value of the variable cannot be used until a proper value is stored in it. (**C11: 6.2.6 Representations of types--Footnote 50**)
It has become standard security practice for freshly allocated memory to be cleared (usually to 0) before being handed over by the OS. Don't want to be handing over memory that may have contained a password or private key! So, there's no guarantee what you'll get since the compiler is not guaranteeing to initialize it either, but in modern days it will typically be a value that's consistent across a particular OS at least.
29,903,947
Why am i getting 0. I is an auto variable, so it should print some garbage value, right? I am using gcc compiler. ``` #include "stdio.h" void main() { int i; printf("%d\n", i); } ```
2015/04/27
[ "https://Stackoverflow.com/questions/29903947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4367335/" ]
No, I get random values with gcc (Debian 4.9.2-10) 4.9.2. ``` ofd@ofd-pc:~$ gcc '/home/ofd/Destkop/test.c' ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218415715 ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218653283 ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218845795 ```
Variables declared inside a function are uninitialized. One cannot predict what might show up if you print them out. in your example `main` is a function too. Hence it so happens that it is zero. When you declare variable to be static or gloabally, the compiler will have them initialzed to zero.
29,903,947
Why am i getting 0. I is an auto variable, so it should print some garbage value, right? I am using gcc compiler. ``` #include "stdio.h" void main() { int i; printf("%d\n", i); } ```
2015/04/27
[ "https://Stackoverflow.com/questions/29903947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4367335/" ]
No, I get random values with gcc (Debian 4.9.2-10) 4.9.2. ``` ofd@ofd-pc:~$ gcc '/home/ofd/Destkop/test.c' ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218415715 ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218653283 ofd@ofd-pc:~$ '/home/ofd/Desktop/a.out' -1218845795 ```
It has become standard security practice for freshly allocated memory to be cleared (usually to 0) before being handed over by the OS. Don't want to be handing over memory that may have contained a password or private key! So, there's no guarantee what you'll get since the compiler is not guaranteeing to initialize it either, but in modern days it will typically be a value that's consistent across a particular OS at least.
24,969,577
There are some filters out there but there are no working Java only solutions or some useful libraries. I am using Spring MVC with Tomcat and deploy release to Heroku (so cannot change servlet container configuration). How to enable REST gzip compression in Spring MVC without XML?
2014/07/26
[ "https://Stackoverflow.com/questions/24969577", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1809513/" ]
You could set the rule for using compression on your servlet container, for example apache-tomcat you could use the compression property. From [documentation](https://tomcat.apache.org/tomcat-8.0-doc/config/http.html): > > **compression** > > > The Connector may use HTTP/1.1 GZIP compression in an attempt to save > server bandwidth. The acceptable values for the parameter is "off" > (disable compression), "on" (allow compression, which causes text data > to be compressed), "force" (forces compression in all cases), or a > numerical integer value (which is equivalent to "on", but specifies > the minimum amount of data before the output is compressed). If the > content-length is not known and compression is set to "on" or more > aggressive, the output will also be compressed. If not specified, this > attribute is set to "off". > > > Note: There is a tradeoff between using compression (saving your > bandwidth) and using the sendfile feature (saving your CPU cycles). If > the connector supports the sendfile feature, e.g. the NIO connector, > using sendfile will take precedence over compression. The symptoms > will be that static files greater that 48 Kb will be sent > uncompressed. You can turn off sendfile by setting useSendfile > attribute of the connector, as documented below, or change the > sendfile usage threshold in the configuration of the DefaultServlet in > the default conf/web.xml or in the web.xml of your web application. > > > **compressionMinSize** > > > If compression is set to "on" then this attribute may be used to specify the minimum amount of data before the > output is compressed. If not specified, this attribute is defaults to > "2048". > > >
One option is to change to Spring Boot and use an embedded Tomcat. Then you can use the `ConfigurableEmbeddedServletContainer` as suggested by [Andy Wilkinson](https://stackoverflow.com/users/1384297/andy-wilkinson) and myself in the answers to [this question](https://stackoverflow.com/questions/21410317/using-gzip-compression-with-spring-boot-mvc-javaconfig-with-restful): ``` @Bean public EmbeddedServletContainerCustomizer servletContainerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer servletContainer) { ((TomcatEmbeddedServletContainerFactory) servletContainer).addConnectorCustomizers( new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler(); httpProtocol.setCompression("on"); httpProtocol.setCompressionMinSize(256); String mimeTypes = httpProtocol.getCompressableMimeTypes(); String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE; httpProtocol.setCompressableMimeTypes(mimeTypesWithJson); } } ); } }; } ``` If you choose to switch to Spring Boot, there is a specific chapter about [Heroku deployment](http://docs.spring.io/spring-boot/docs/1.1.x/reference/htmlsingle/#cloud-deployment-heroku) in the Spring Boot reference docs.
33,545,424
I have a google spreadsheet that contains a list of email addresses. It's a contact list of sorts. I would like to have a function that opens a gmail new mail message window with these adresses (or some sub-set of them) so I can then complete the email and send. The [Sending Email tutorial](https://developers.google.com/apps-script/articles/sending_emails?hl=en) on Google Developers shows you how to create and send emails directly, but not how open gmail ready for further editing. Having looked at the reference for MailApp it seems that I can only use it to send completed emails, while GMailApp seems to allow me to access existing gmail messages. Is there a way I can start gmail with a new message window without sending it?
2015/11/05
[ "https://Stackoverflow.com/questions/33545424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4995013/" ]
There is no way for Google Apps Script to interact with the GMail User Interface. An alternative would be to produce a `mailto:` link with a [prefilled message URL](https://stackoverflow.com/questions/2583928/prefilling-gmail-compose-screen-with-html-text), and present that to the user in a dialog or sidebar in your spreadsheet. When the link is clicked, it should open a new message window.
yes this is (sort of) possible. 1. make a webapp with a button to create the email. 2. create a draft email as you wish using the gmail api in advanced services (see [How to use the Google Apps Script code for creating a Draft email (from 985)?](https://stackoverflow.com/q/25391740/2213940)) 3. provide a link in your webapp to open the drafts folder. Alternatively you might be able to use the gmail api to find the draft message id and build a url that directly opens the single draft message (haven't tried that with drafts, might not be possible) "sort of" because the part you cant do is open the drafts window (or single message) automatically, the user must click something that opens the final link. **Advantage**: more flexibility on your email body content, inline images and attachments. **Disadvantage**: one more click and possibly only being able to open the drafts folder (and not the single draft directly)
33,545,424
I have a google spreadsheet that contains a list of email addresses. It's a contact list of sorts. I would like to have a function that opens a gmail new mail message window with these adresses (or some sub-set of them) so I can then complete the email and send. The [Sending Email tutorial](https://developers.google.com/apps-script/articles/sending_emails?hl=en) on Google Developers shows you how to create and send emails directly, but not how open gmail ready for further editing. Having looked at the reference for MailApp it seems that I can only use it to send completed emails, while GMailApp seems to allow me to access existing gmail messages. Is there a way I can start gmail with a new message window without sending it?
2015/11/05
[ "https://Stackoverflow.com/questions/33545424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4995013/" ]
There is no way for Google Apps Script to interact with the GMail User Interface. An alternative would be to produce a `mailto:` link with a [prefilled message URL](https://stackoverflow.com/questions/2583928/prefilling-gmail-compose-screen-with-html-text), and present that to the user in a dialog or sidebar in your spreadsheet. When the link is clicked, it should open a new message window.
Thanks for your suggestions. It seems that there are several work arounds. As my email needs are repetitively simple I ended up using a function that opens a really simple dialog box, with a text boxs for reciepients (which I can prepopulate if necessary) and subject and a text area for the message. The send button handler calls MailApp.sendEmail.
33,545,424
I have a google spreadsheet that contains a list of email addresses. It's a contact list of sorts. I would like to have a function that opens a gmail new mail message window with these adresses (or some sub-set of them) so I can then complete the email and send. The [Sending Email tutorial](https://developers.google.com/apps-script/articles/sending_emails?hl=en) on Google Developers shows you how to create and send emails directly, but not how open gmail ready for further editing. Having looked at the reference for MailApp it seems that I can only use it to send completed emails, while GMailApp seems to allow me to access existing gmail messages. Is there a way I can start gmail with a new message window without sending it?
2015/11/05
[ "https://Stackoverflow.com/questions/33545424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4995013/" ]
yes this is (sort of) possible. 1. make a webapp with a button to create the email. 2. create a draft email as you wish using the gmail api in advanced services (see [How to use the Google Apps Script code for creating a Draft email (from 985)?](https://stackoverflow.com/q/25391740/2213940)) 3. provide a link in your webapp to open the drafts folder. Alternatively you might be able to use the gmail api to find the draft message id and build a url that directly opens the single draft message (haven't tried that with drafts, might not be possible) "sort of" because the part you cant do is open the drafts window (or single message) automatically, the user must click something that opens the final link. **Advantage**: more flexibility on your email body content, inline images and attachments. **Disadvantage**: one more click and possibly only being able to open the drafts folder (and not the single draft directly)
Thanks for your suggestions. It seems that there are several work arounds. As my email needs are repetitively simple I ended up using a function that opens a really simple dialog box, with a text boxs for reciepients (which I can prepopulate if necessary) and subject and a text area for the message. The send button handler calls MailApp.sendEmail.
39,523,726
Say for example I have a table that contains a description of a customer's activities while in a cafe. (Metaphor of the actual table I am working on) ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 1 1 Yes 2 1 3 1 3 Yes 4 1 1 4 1 ``` I wish to combine the rows in this way ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 Yes 2 1 3 1 Yes 4 1 2 ``` I did self join with coalesce, but it did not give my desired results.
2016/09/16
[ "https://Stackoverflow.com/questions/39523726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6596647/" ]
As per your comment, initial table is a temp table, Try to make the result as a cte result, then do aggregation on that, like the below query. ``` ; WITH cte_1 AS ( //your query to return the result set) SELECT customer,sum([borrowed book]) BorrowedBook, sum([ordered drink]) OrderedDrink, max([has company]) HasCompany FROM cte_1 GROUP BY Customer ```
Use **Group By:** ``` DECLARE @tblTest as Table( Customer INT, BorrowedBook INT, OrderedDrink INT, HasCompany BIt ) INSERT INTO @tblTest VALUES (1,1,NULL,NULL) ,(1,NULL,1,NULL) ,(1,NULL,NULL,1) ,(2,NULL,1,NULL) ,(3,NULL,1,NULL) ,(3,NULL,NULL,1) ,(4,1,1,NULL) ,(4,NULL,1,NULL) SELECT Customer, SUM(ISNULL(BorrowedBook,0)) AS BorrowedBook, SUM(ISNULL(OrderedDrink,0)) AS OrderedDrink, CASE MIN(CAST(HasCompany AS INT)) WHEN 1 THEN 'YES' ELSE '' END AS HasCompany FROM @tblTest GROUP BY Customer ```
39,523,726
Say for example I have a table that contains a description of a customer's activities while in a cafe. (Metaphor of the actual table I am working on) ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 1 1 Yes 2 1 3 1 3 Yes 4 1 1 4 1 ``` I wish to combine the rows in this way ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 Yes 2 1 3 1 Yes 4 1 2 ``` I did self join with coalesce, but it did not give my desired results.
2016/09/16
[ "https://Stackoverflow.com/questions/39523726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6596647/" ]
As per your comment, initial table is a temp table, Try to make the result as a cte result, then do aggregation on that, like the below query. ``` ; WITH cte_1 AS ( //your query to return the result set) SELECT customer,sum([borrowed book]) BorrowedBook, sum([ordered drink]) OrderedDrink, max([has company]) HasCompany FROM cte_1 GROUP BY Customer ```
Not sure, why you are getting error with group by. Your coalesce should be correct. Refer below way. ``` Select customer , case when [borrowed] = 0 then NULL else [borrowed] end as [borrowed] , case when [ordered] = 0 then NULL else [ordered] end as [ordered] , case when [company] = 1 then 'Yes' end as company from ( Select customer, coalesce( case when (case when borrowed = '' then null else borrowed end) = 1 then 'borrowed' end, case when (case when ordered = '' then null else ordered end) = 1 then 'ordered' end, case when (case when company = '' then null else company end) = 'Yes' then 'company' end ) val from Table ) main PIVOT ( COUNT (val) FOR val IN ( [borrowed], [ordered], [company] ) ) piv ``` OUTPUT: ``` customer | borrowed | ordered | company --------------------------------------- 1 1 1 Yes 2 NULL 1 NULL 3 NULL 1 Yes ```
39,523,726
Say for example I have a table that contains a description of a customer's activities while in a cafe. (Metaphor of the actual table I am working on) ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 1 1 Yes 2 1 3 1 3 Yes 4 1 1 4 1 ``` I wish to combine the rows in this way ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 Yes 2 1 3 1 Yes 4 1 2 ``` I did self join with coalesce, but it did not give my desired results.
2016/09/16
[ "https://Stackoverflow.com/questions/39523726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6596647/" ]
You can do this by **group by**, ``` select Customer,sum([borrowed book]), sum([ordered drink]), max([has company]) from customeractivity group by Customer ```
Use **Group By:** ``` DECLARE @tblTest as Table( Customer INT, BorrowedBook INT, OrderedDrink INT, HasCompany BIt ) INSERT INTO @tblTest VALUES (1,1,NULL,NULL) ,(1,NULL,1,NULL) ,(1,NULL,NULL,1) ,(2,NULL,1,NULL) ,(3,NULL,1,NULL) ,(3,NULL,NULL,1) ,(4,1,1,NULL) ,(4,NULL,1,NULL) SELECT Customer, SUM(ISNULL(BorrowedBook,0)) AS BorrowedBook, SUM(ISNULL(OrderedDrink,0)) AS OrderedDrink, CASE MIN(CAST(HasCompany AS INT)) WHEN 1 THEN 'YES' ELSE '' END AS HasCompany FROM @tblTest GROUP BY Customer ```
39,523,726
Say for example I have a table that contains a description of a customer's activities while in a cafe. (Metaphor of the actual table I am working on) ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 1 1 Yes 2 1 3 1 3 Yes 4 1 1 4 1 ``` I wish to combine the rows in this way ``` Customer Borrowed Book Ordered Drink Has Company 1 1 1 Yes 2 1 3 1 Yes 4 1 2 ``` I did self join with coalesce, but it did not give my desired results.
2016/09/16
[ "https://Stackoverflow.com/questions/39523726", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6596647/" ]
You can do this by **group by**, ``` select Customer,sum([borrowed book]), sum([ordered drink]), max([has company]) from customeractivity group by Customer ```
Not sure, why you are getting error with group by. Your coalesce should be correct. Refer below way. ``` Select customer , case when [borrowed] = 0 then NULL else [borrowed] end as [borrowed] , case when [ordered] = 0 then NULL else [ordered] end as [ordered] , case when [company] = 1 then 'Yes' end as company from ( Select customer, coalesce( case when (case when borrowed = '' then null else borrowed end) = 1 then 'borrowed' end, case when (case when ordered = '' then null else ordered end) = 1 then 'ordered' end, case when (case when company = '' then null else company end) = 'Yes' then 'company' end ) val from Table ) main PIVOT ( COUNT (val) FOR val IN ( [borrowed], [ordered], [company] ) ) piv ``` OUTPUT: ``` customer | borrowed | ordered | company --------------------------------------- 1 1 1 Yes 2 NULL 1 NULL 3 NULL 1 Yes ```
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
The main problem is that the rule you are using assumes $a$ is a constant. Whilst your problem is most definitely not. $$ u(x) = f(x)^{g(x)} = \mathrm{e}^{g\ln f} $$ which means $$ u'(x) = \left(g'(x) \ln f(x) + \frac{g(x)}{f(x)}f'(x)\right)f(x)^{g(x)} $$
$${ \left( { \sin { x } }^{ \cos { x } } \right) }^{ \prime }={ \left( { e }^{ \cos { x } \ln { \sin { x } } } \right) }^{ \prime }={ e }^{ \cos { x } \ln { \sin { x } } }\left( -\sin { x } \ln { \left( \sin { x } \right) +\frac { \cos ^{ 2 }{ x } }{ \sin { x } } } \right) \\ $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
$${ \left( { \sin { x } }^{ \cos { x } } \right) }^{ \prime }={ \left( { e }^{ \cos { x } \ln { \sin { x } } } \right) }^{ \prime }={ e }^{ \cos { x } \ln { \sin { x } } }\left( -\sin { x } \ln { \left( \sin { x } \right) +\frac { \cos ^{ 2 }{ x } }{ \sin { x } } } \right) \\ $$
Write the function as $$ y=e^{\cos x \ln(\sin x)} $$ so $$ y'=e^{\cos x \ln(\sin x)}\left[-\sin x \ln(\sin x) +\frac{\cos x}{\sin x} \cos x \right] $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
Note your answer is incorrect, since the formula you quoted requires $a$ to be a constant Let $y=\sin x^{\cos x}$ $$\ln y = \cos x\ln(\sin x)$$ $$\frac{1}{y} \frac{dy}{dx} = -\sin x\ln(\sin x)+\cos x\cdot\frac{\cos x}{\sin x}$$ $$\frac{dy}{dx} = \sin x^{\cos x}\bigg(\frac{\cos^2x}{\sin x} -\sin x\ln(\sin x)\bigg) $$
$${ \left( { \sin { x } }^{ \cos { x } } \right) }^{ \prime }={ \left( { e }^{ \cos { x } \ln { \sin { x } } } \right) }^{ \prime }={ e }^{ \cos { x } \ln { \sin { x } } }\left( -\sin { x } \ln { \left( \sin { x } \right) +\frac { \cos ^{ 2 }{ x } }{ \sin { x } } } \right) \\ $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
I suggest you start here: $(\sin x)^{cos x} = e^{\cos x \ln (\sin x)}$ As you differentiate don't lose track of the product rule and the chain rule. $\frac d{dx} e^{\cos x \ln \sin x} = e^{\cos x \ln \sin x} \frac d{dx} (\cos x\ln (\sin x))\\ e^{\cos x \ln \sin x} (-\sin x \ln (\sin x) + \frac {cos x}{\sin x}(\frac d{dx} \sin x)\\ e^{\cos x \ln \sin x} (-\sin x \ln (\sin x) + \frac {cos^2 x}{\sin x})$ And finally we can simplfy $e^{\cos x \ln \sin x}$ back again $(\sin x)^{cos x} (-\sin x \ln (\sin x) + \frac {cos^2 x}{\sin x})$
$${ \left( { \sin { x } }^{ \cos { x } } \right) }^{ \prime }={ \left( { e }^{ \cos { x } \ln { \sin { x } } } \right) }^{ \prime }={ e }^{ \cos { x } \ln { \sin { x } } }\left( -\sin { x } \ln { \left( \sin { x } \right) +\frac { \cos ^{ 2 }{ x } }{ \sin { x } } } \right) \\ $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
The main problem is that the rule you are using assumes $a$ is a constant. Whilst your problem is most definitely not. $$ u(x) = f(x)^{g(x)} = \mathrm{e}^{g\ln f} $$ which means $$ u'(x) = \left(g'(x) \ln f(x) + \frac{g(x)}{f(x)}f'(x)\right)f(x)^{g(x)} $$
Write the function as $$ y=e^{\cos x \ln(\sin x)} $$ so $$ y'=e^{\cos x \ln(\sin x)}\left[-\sin x \ln(\sin x) +\frac{\cos x}{\sin x} \cos x \right] $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
The main problem is that the rule you are using assumes $a$ is a constant. Whilst your problem is most definitely not. $$ u(x) = f(x)^{g(x)} = \mathrm{e}^{g\ln f} $$ which means $$ u'(x) = \left(g'(x) \ln f(x) + \frac{g(x)}{f(x)}f'(x)\right)f(x)^{g(x)} $$
Note your answer is incorrect, since the formula you quoted requires $a$ to be a constant Let $y=\sin x^{\cos x}$ $$\ln y = \cos x\ln(\sin x)$$ $$\frac{1}{y} \frac{dy}{dx} = -\sin x\ln(\sin x)+\cos x\cdot\frac{\cos x}{\sin x}$$ $$\frac{dy}{dx} = \sin x^{\cos x}\bigg(\frac{\cos^2x}{\sin x} -\sin x\ln(\sin x)\bigg) $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
The main problem is that the rule you are using assumes $a$ is a constant. Whilst your problem is most definitely not. $$ u(x) = f(x)^{g(x)} = \mathrm{e}^{g\ln f} $$ which means $$ u'(x) = \left(g'(x) \ln f(x) + \frac{g(x)}{f(x)}f'(x)\right)f(x)^{g(x)} $$
I suggest you start here: $(\sin x)^{cos x} = e^{\cos x \ln (\sin x)}$ As you differentiate don't lose track of the product rule and the chain rule. $\frac d{dx} e^{\cos x \ln \sin x} = e^{\cos x \ln \sin x} \frac d{dx} (\cos x\ln (\sin x))\\ e^{\cos x \ln \sin x} (-\sin x \ln (\sin x) + \frac {cos x}{\sin x}(\frac d{dx} \sin x)\\ e^{\cos x \ln \sin x} (-\sin x \ln (\sin x) + \frac {cos^2 x}{\sin x})$ And finally we can simplfy $e^{\cos x \ln \sin x}$ back again $(\sin x)^{cos x} (-\sin x \ln (\sin x) + \frac {cos^2 x}{\sin x})$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
Note your answer is incorrect, since the formula you quoted requires $a$ to be a constant Let $y=\sin x^{\cos x}$ $$\ln y = \cos x\ln(\sin x)$$ $$\frac{1}{y} \frac{dy}{dx} = -\sin x\ln(\sin x)+\cos x\cdot\frac{\cos x}{\sin x}$$ $$\frac{dy}{dx} = \sin x^{\cos x}\bigg(\frac{\cos^2x}{\sin x} -\sin x\ln(\sin x)\bigg) $$
Write the function as $$ y=e^{\cos x \ln(\sin x)} $$ so $$ y'=e^{\cos x \ln(\sin x)}\left[-\sin x \ln(\sin x) +\frac{\cos x}{\sin x} \cos x \right] $$
2,240,755
In a regular heptagon, all diagonals are drawn. Then points $A$, $B$, and $C$ in the diagram below are collinear: [![heptagon](https://i.stack.imgur.com/cuSzo.png)](https://i.stack.imgur.com/cuSzo.png) (If the vertices of the pentagon are $P\_1, \dots, P\_7$ in clockwise order, then $A = P\_1$, $B$ is the intersection of $P\_2 P\_5$ and $P\_3 P\_7$, and $C$ is the intersection of $P\_2 P\_4$ and $P\_3 P\_5$.) Offhand, I see two approaches to trying to prove this (I verified it by direct computation in Mathematica): 1. Use the area method ([Machine Proofs in Geometry](http://www.mmrc.iss.ac.cn/~xgao/publ.html) style) to express the area $S\_{ABC}$ in terms of areas of triangles formed by vertices of the heptagon, in hopes of showing that it's $0$. 2. Use [Trig Ceva](http://www.cut-the-knot.org/triangle/TrigCeva.shtml) to show that $\angle P\_4 AB = \angle P\_4 AC$: if we draw line $AB$, then $B$ is the intersection of three chords in the circumcircle of the heptagon, forming six arcs - four of which we already know. Same for $C$. However, both of these methods seem extremely computationally intensive. (Though I'd be happy to be proven wrong there, if someone sees a straightforward way to do either computation.) Is there a simple proof why $A$, $B$, and $C$ are collinear, or at least a good reason *why* we should expect this to be true?
2017/04/18
[ "https://math.stackexchange.com/questions/2240755", "https://math.stackexchange.com", "https://math.stackexchange.com/users/383078/" ]
I suggest you start here: $(\sin x)^{cos x} = e^{\cos x \ln (\sin x)}$ As you differentiate don't lose track of the product rule and the chain rule. $\frac d{dx} e^{\cos x \ln \sin x} = e^{\cos x \ln \sin x} \frac d{dx} (\cos x\ln (\sin x))\\ e^{\cos x \ln \sin x} (-\sin x \ln (\sin x) + \frac {cos x}{\sin x}(\frac d{dx} \sin x)\\ e^{\cos x \ln \sin x} (-\sin x \ln (\sin x) + \frac {cos^2 x}{\sin x})$ And finally we can simplfy $e^{\cos x \ln \sin x}$ back again $(\sin x)^{cos x} (-\sin x \ln (\sin x) + \frac {cos^2 x}{\sin x})$
Write the function as $$ y=e^{\cos x \ln(\sin x)} $$ so $$ y'=e^{\cos x \ln(\sin x)}\left[-\sin x \ln(\sin x) +\frac{\cos x}{\sin x} \cos x \right] $$
72,645,168
I am after some help with a bit of complex dataframe management/column creation. I have a data frame that looks something like this: ``` dat <- data.frame(Target = sort(rep(c("1", "2", "3", "4"), times = 5)), targ1frames_x = c(0.42, 0.46, 0.50, 0.60, 0.86, 0.32, 0.56, 0.89, 0.98, 0.86, 0.57, 0.79, 0.52, 0.62, 0.55, 0.12, 0.35, 0.50, 0.48, 0.45), targ1frames_y = c(0.69, 0.63, 0.74, 0.81, 0.12, 0.67, 0.54, 0.30, 0.25, 0.18, 0.63, 0.63, 0.79, 0.81, 0.96, 0.90, 0.75, 0.74, 0.81, 0.76), targ1frames_time = rep(c(0.00006, 0.18, 0.27, 0.35, 0.43), times = 4)) Target targ1frames_x targ1frames_y targ1frames_time 1 1 0.42 0.69 0.00006 2 1 0.46 0.63 0.18000 3 1 0.50 0.74 0.27000 4 1 0.60 0.81 0.35000 5 1 0.86 0.12 0.43000 6 2 0.32 0.67 0.00006 7 2 0.56 0.54 0.18000 8 2 0.89 0.30 0.27000 9 2 0.98 0.25 0.35000 10 2 0.86 0.18 0.43000 11 3 0.57 0.63 0.00006 12 3 0.79 0.63 0.18000 13 3 0.52 0.79 0.27000 14 3 0.62 0.81 0.35000 15 3 0.55 0.96 0.43000 16 4 0.12 0.90 0.00006 17 4 0.35 0.75 0.18000 18 4 0.50 0.74 0.27000 19 4 0.48 0.81 0.35000 20 4 0.45 0.76 0.43000 ``` This is from an experiment in which participants had to click on-screen targets with a computer mouse. The Target column indicates which target was clicked, targ1frames\_x shows the x coordinates of the cursor on each frame; targ1frames\_y shows the y coordinates on each frame; and targ1frames\_time indicates the time of each frame change. What I want to work out is the time of the frame change when the mouse coordinates from **either** x or y columns changed between the first value for each target (i.e. the starting cursor position) and the subsequent rows by >= 0.2. I want to get the single time for each target when this occurs into a new column/data frame. I.e., I want to end up with: ``` Target targ1_initTime 1 1 0.43000 2 2 0.18000 3 3 0.18000 4 4 0.18000 ``` Note that for the simplicity of providing a reproducible example, each target here has the same time values, which is not the case in my actual dataset. I am trying to write code that can be flexible to produce the time at which the x **or** y coordinate changes from the starting value (within the x or y coordinate columns) by +-0.2 for each target. I hope this makes sense, I would be very grateful for any advice - if anything needs further clarification, please let me know in the comments.
2022/06/16
[ "https://Stackoverflow.com/questions/72645168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16958042/" ]
We could do it this way. Here demonstrated for `targ1frames_x` (for `targ1frames_y` the code needs to be adapted): ``` library(dplyr) dat %>% group_by(Target) %>% mutate(diff_x = targ1frames_x - lag(targ1frames_x)) %>% filter(diff_x >= 0.2) %>% slice(1) %>% select(Target, targ1frames_time) Target targ1frames_time <chr> <dbl> 1 1 0.43 2 2 0.18 3 3 0.18 4 4 0.18 ```
``` dat %>% mutate(diff_row_x = targ1frames_x - lag(targ1frames_x , default = first(targ1frames_x )))%>% mutate(diff_row_y = targ1frames_y - lag(targ1frames_y , default = first(targ1frames_y )))%>% filter(!(diff_row_x & diff_row_y <=0.2)) ``` Now I understand your question, this code is more appropriate than my previous solution
72,645,168
I am after some help with a bit of complex dataframe management/column creation. I have a data frame that looks something like this: ``` dat <- data.frame(Target = sort(rep(c("1", "2", "3", "4"), times = 5)), targ1frames_x = c(0.42, 0.46, 0.50, 0.60, 0.86, 0.32, 0.56, 0.89, 0.98, 0.86, 0.57, 0.79, 0.52, 0.62, 0.55, 0.12, 0.35, 0.50, 0.48, 0.45), targ1frames_y = c(0.69, 0.63, 0.74, 0.81, 0.12, 0.67, 0.54, 0.30, 0.25, 0.18, 0.63, 0.63, 0.79, 0.81, 0.96, 0.90, 0.75, 0.74, 0.81, 0.76), targ1frames_time = rep(c(0.00006, 0.18, 0.27, 0.35, 0.43), times = 4)) Target targ1frames_x targ1frames_y targ1frames_time 1 1 0.42 0.69 0.00006 2 1 0.46 0.63 0.18000 3 1 0.50 0.74 0.27000 4 1 0.60 0.81 0.35000 5 1 0.86 0.12 0.43000 6 2 0.32 0.67 0.00006 7 2 0.56 0.54 0.18000 8 2 0.89 0.30 0.27000 9 2 0.98 0.25 0.35000 10 2 0.86 0.18 0.43000 11 3 0.57 0.63 0.00006 12 3 0.79 0.63 0.18000 13 3 0.52 0.79 0.27000 14 3 0.62 0.81 0.35000 15 3 0.55 0.96 0.43000 16 4 0.12 0.90 0.00006 17 4 0.35 0.75 0.18000 18 4 0.50 0.74 0.27000 19 4 0.48 0.81 0.35000 20 4 0.45 0.76 0.43000 ``` This is from an experiment in which participants had to click on-screen targets with a computer mouse. The Target column indicates which target was clicked, targ1frames\_x shows the x coordinates of the cursor on each frame; targ1frames\_y shows the y coordinates on each frame; and targ1frames\_time indicates the time of each frame change. What I want to work out is the time of the frame change when the mouse coordinates from **either** x or y columns changed between the first value for each target (i.e. the starting cursor position) and the subsequent rows by >= 0.2. I want to get the single time for each target when this occurs into a new column/data frame. I.e., I want to end up with: ``` Target targ1_initTime 1 1 0.43000 2 2 0.18000 3 3 0.18000 4 4 0.18000 ``` Note that for the simplicity of providing a reproducible example, each target here has the same time values, which is not the case in my actual dataset. I am trying to write code that can be flexible to produce the time at which the x **or** y coordinate changes from the starting value (within the x or y coordinate columns) by +-0.2 for each target. I hope this makes sense, I would be very grateful for any advice - if anything needs further clarification, please let me know in the comments.
2022/06/16
[ "https://Stackoverflow.com/questions/72645168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16958042/" ]
We could do it this way. Here demonstrated for `targ1frames_x` (for `targ1frames_y` the code needs to be adapted): ``` library(dplyr) dat %>% group_by(Target) %>% mutate(diff_x = targ1frames_x - lag(targ1frames_x)) %>% filter(diff_x >= 0.2) %>% slice(1) %>% select(Target, targ1frames_time) Target targ1frames_time <chr> <dbl> 1 1 0.43 2 2 0.18 3 3 0.18 4 4 0.18 ```
I realised I had not done an amazing job of explaining what I was trying to do, so these solutions did not entirely work, though they gave me the building blocks to get there! Thanks so much for all of your help. Here is what I did in the end: ``` #Change columns to correct class dat2 <-dat %>% mutate(targ1frames_x = as.numeric(targ1frames_x), targ1frames_y = as.numeric(targ1frames_y), targ1frames_time = as.numeric(targ1frames_time)) #Extract the first x and y coordinates for each target sPosDat <- dat2 %>% group_by(Target) %>% select(Target, targ1frames_x, targ1frames_y) %>% mutate(targ1Start_x = targ1frames_x, targ1Start_y = targ1frames_y) %>% #rename columns slice(1) #Remove extra columns to keep things tidy sPosDat <- sPosDat[-c(2, 3)] #Join the sPosDat onto the main data dat3 <- left_join(dat2, sPosDat, by = "Target") #Now work out the difference between the start position coords and coords on each frame dat3 <- dat3 %>% mutate(posDiff_x = abs(targ1frames_x - targ1Start_x)) %>% mutate(posDiff_y = abs(targ1frames_y - targ1Start_y)) #Now we need to select the rows in the time column which correspond to the x OR y #coordinate difference of > 0.2 dat4 <- dat3 %>% group_by(Target) %>% filter(posDiff_x > 0.2 | posDiff_y > 0.2) %>% slice(1) %>% select(Target, targ1frames_time) ``` I'm sure there is a more elegant way to achieve this, but the code seems to work all the same.
12,187,842
In the website on which I'm working, users may send messages to each other. I want users to be able to use text-style tags such as < b > , < i > , and < u > to make text bold, italic and underlined respectively. But, in fact, I don't want to be XSSed with those < script > tags. Or perhaps a < b > with a mouseover attribute. What's the easiest and the most secure way to do so? I'm using django and jQuery if that matters.
2012/08/29
[ "https://Stackoverflow.com/questions/12187842", "https://Stackoverflow.com", "https://Stackoverflow.com/users/684397/" ]
If you want to write to a log file don't use `Write-Host`. Use `Write-Output` or don't use `Write-*` at all because `Write-Output` is the default e.g: ``` Write-Output 'hello' > foo.txt ``` is equivalent to: ``` 'hello' > foo.txt ``` `Write-Output` sends output to the stdout stream (ie 1). Use `Write-Error` to send output to the error stream (ie 2). These two streams can be redirected. `Write-Host` more or less writes directly to the host UI bypassing output streams altogether. In PowerShell V3, you can also redirect the following streams: ``` The Windows PowerShell redirection operators use the following characters to represent each output type: * All output 1 Success output 2 Errors 3 Warning messages 4 Verbose output 5 Debug messages ```
I would use `Start-Transcript`. The only caveat is that it doesn't capture standard output, only output from `Write-Host`. So, you just have to pipe the output from legacy command line applications to `Write-Host`: ``` Start-Transcript -Path C:\logs\mylog.log program.exe | Write-Host ```
57,571,510
I am working on an iOS 11+ app and would like to create a view like in this picture: [![View](https://i.stack.imgur.com/6YrHQ.png)](https://i.stack.imgur.com/6YrHQ.png) The two labels are positioned to work as columns of different height depending on the label content. The content of both labels is variable due to custom text entered by the user. Thus I cannot be sure which of the the two labels is higher at runtime and there is also no limit to the height. **How can I position the `BottomView` to have a margin 20px to the higher of the two columns / labels?** Both labels should only use the min. height necessary to show all their text. Thus giving both labels an equal height is no solution. I tried to use vertical spacing **greater than** 20px to both labels but this leads (of course) to an `Inequality Constraint Ambiguity`. **Is it possible to solve this simple task with Autolayout only or do I have to check / set the sizes and margins manually in code?**
2019/08/20
[ "https://Stackoverflow.com/questions/57571510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/777861/" ]
[![enter image description here](https://i.stack.imgur.com/dJxW6.png)](https://i.stack.imgur.com/dJxW6.png) You can add labels to stackView
One way to do this is to assign equal height constraint to both label. By doing this height of label will always be equal to large label (Label with more content). You can do this by selecting both labels and adding equal height constraint as mentioned in screen short. [![enter image description here](https://i.stack.imgur.com/2TqWa.png)](https://i.stack.imgur.com/2TqWa.png) Result would be some think like below [![enter image description here](https://i.stack.imgur.com/GSbnT.png)](https://i.stack.imgur.com/GSbnT.png)
57,571,510
I am working on an iOS 11+ app and would like to create a view like in this picture: [![View](https://i.stack.imgur.com/6YrHQ.png)](https://i.stack.imgur.com/6YrHQ.png) The two labels are positioned to work as columns of different height depending on the label content. The content of both labels is variable due to custom text entered by the user. Thus I cannot be sure which of the the two labels is higher at runtime and there is also no limit to the height. **How can I position the `BottomView` to have a margin 20px to the higher of the two columns / labels?** Both labels should only use the min. height necessary to show all their text. Thus giving both labels an equal height is no solution. I tried to use vertical spacing **greater than** 20px to both labels but this leads (of course) to an `Inequality Constraint Ambiguity`. **Is it possible to solve this simple task with Autolayout only or do I have to check / set the sizes and margins manually in code?**
2019/08/20
[ "https://Stackoverflow.com/questions/57571510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/777861/" ]
[![enter image description here](https://i.stack.imgur.com/dJxW6.png)](https://i.stack.imgur.com/dJxW6.png) You can add labels to stackView
The answer given as <https://stackoverflow.com/a/57571805/341994> does work, but it is not very educational. "Use a stack view." Yes, but what is a stack view? It is a view that makes constraints for you. It is not magic. What the stack view does, you can do. An ordinary view surrounding the two labels and sizing itself to the longer of them would do fine. The stack view, as a stack view, is not doing anything special here. You can build the same thing just using constraints yourself. (Actually, the surrounding view is not really needed either, but it probably makes things a bit more encapsulated, so let's go with that.) Here's a version of your project running on my machine: [![enter image description here](https://i.stack.imgur.com/0ciZ6.png)](https://i.stack.imgur.com/0ciZ6.png) And with the other label made longer: [![enter image description here](https://i.stack.imgur.com/IBb2p.png)](https://i.stack.imgur.com/IBb2p.png) So how is that done? It's just ordinary constraints. Here's the storyboard: [![enter image description here](https://i.stack.imgur.com/CfzHD.png)](https://i.stack.imgur.com/CfzHD.png) Both labels have a greater-than-or-equal constraint (which happens to have a constant of 20) from their bottom to the bottom of the superview. All their other constraints are obvious and I won't describe them here. Okay, but that is not quite enough. There remains an ambiguity, and Xcode will tell you so. Inequalities need to be resolved somehow. We need something on the far side of the inequality to aim at. The solution is one more constraint: the superview itself has a height constraint of 1 *with a priority of 749*. That is a low enough priority to permit the compression resistance of the labels to operate. So the labels get their full height, and the superview tries to collapse as short as possible to 1, but it is prevented by the two inequalities: its bottom must be more than 20 points below the bottom of both labels. And so we get the desired result: the bottom of the superview ends up *exactly* 20 points below the bottom of the *longest* label.
15,297,557
I have a line of code that is : `File file = new File(getFile())` in a java class `HandleData.java` Method - `getFile()` takes the value of the property `fileName`. And `fileName` is injected through `application_context.xml` with a bean section of the class - HandleData as below: ``` <bean id="dataHandler" class="com.profile.transaction.HandleData"> <property name="fileName" value="DataFile.xml"></property> </bean> ``` I build the project successfully and checked that - `DataFile.xml` is present in `WEB-INF/classes`. And the HandleData.class is present in `WEB-INF/classes/com/profile/transacon` But when I run it it throws me filenotfound exception. If I inject the absolute path (`C:\MyProjectWorkspace\DataProject\target\ProfileService\WEB-INF\classes\DataFile.xml` it finds the file successfully.). Could someone help in figuring out the proper path to be injected so that the file is taken from the classpath ?
2013/03/08
[ "https://Stackoverflow.com/questions/15297557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893135/" ]
While injecting a `File` is generally the preferred approach, you can also leverage Spring's ResourceLoader for dynamic loading of resources. Generally this is as simple as injecting the `ResourceLoader` into your Spring bean: ``` @Autowired private ResourceLoader resourceLoader; ``` Then to load from the classpath: ``` resourceLoader.getResource("classpath:myfile.txt"); ```
You should have: ``` <property name="fileName" value="classpath:DataFile.xml" /> ``` And it should be injected as a `org.springframework.core.io.Resource` similar to [this answer](https://stackoverflow.com/a/7486582/516433)
15,297,557
I have a line of code that is : `File file = new File(getFile())` in a java class `HandleData.java` Method - `getFile()` takes the value of the property `fileName`. And `fileName` is injected through `application_context.xml` with a bean section of the class - HandleData as below: ``` <bean id="dataHandler" class="com.profile.transaction.HandleData"> <property name="fileName" value="DataFile.xml"></property> </bean> ``` I build the project successfully and checked that - `DataFile.xml` is present in `WEB-INF/classes`. And the HandleData.class is present in `WEB-INF/classes/com/profile/transacon` But when I run it it throws me filenotfound exception. If I inject the absolute path (`C:\MyProjectWorkspace\DataProject\target\ProfileService\WEB-INF\classes\DataFile.xml` it finds the file successfully.). Could someone help in figuring out the proper path to be injected so that the file is taken from the classpath ?
2013/03/08
[ "https://Stackoverflow.com/questions/15297557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893135/" ]
While injecting a `File` is generally the preferred approach, you can also leverage Spring's ResourceLoader for dynamic loading of resources. Generally this is as simple as injecting the `ResourceLoader` into your Spring bean: ``` @Autowired private ResourceLoader resourceLoader; ``` Then to load from the classpath: ``` resourceLoader.getResource("classpath:myfile.txt"); ```
Since OP is injecting Only the fileName through spring, still want to create the File Object through code , You should Use ClassLoadeer to read the file Try this ``` InputStream is = HandleData.class.getClassLoader().getResourceAsStream(getFile())); ``` **Edit** Heres the remainder of code , to read the file ``` BufferedInputStream bf = new BufferedInputStream(is); DataInputStream dis = new DataInputStream(bf); while (dis.available() != 0) { System.out.println(dis.readLine()); } ``` **Edit 2** Since you want it as File Object, to get hold of the FileInputStream try this ``` FileInputStream fisTargetFile = new FileInputStream(new File(HandleData.class.getClassLoader().getResource(getFile()).getFile())); ```
14,489,632
Below is some example code I use to make some boxplots: ``` stest <- read.table(text=" site year conc south 2001 5.3 south 2001 4.67 south 2001 4.98 south 2002 5.76 south 2002 5.93 north 2001 4.64 north 2001 6.32 north 2003 11.5 north 2003 6.3 north 2004 9.6 north 2004 56.11 north 2004 63.55 north 2004 61.35 north 2005 67.11 north 2006 39.17 north 2006 43.51 north 2006 76.21 north 2006 158.89 north 2006 122.27 ", header=TRUE) require(ggplot2) ggplot(stest, aes(x=year, y=conc)) + geom_boxplot(horizontal=TRUE) + facet_wrap(~site, ncol=1) + coord_flip() + scale_y_log10() ``` Which results in this: ![boxplot](https://i.stack.imgur.com/BOPa4.png) I tried everything I could think of but cannot make a plot where the **south facet** only contains years where data is displayed (2001 and 2002). Is what I am trying to do possible? Here is a [link](http://dl.dropbox.com/u/20145982/2013-01-23_2130.png) (DEAD) to the screenshot showing what I want to achieve:
2013/01/23
[ "https://Stackoverflow.com/questions/14489632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2005342/" ]
Use the `scales='free.x'` argument to `facet_wrap`. But I suspect you'll need to do more than that to get the plot you're looking for. Specifically `aes(x=factor(year), y=conc)` in your initial `ggplot` call.
A simple way to circumvent your problem (with a fairly good result): generate separately the two boxplots and then join them together using the `grid.arrange` command of the `gridExtra` package. ``` library(gridExtra) p1 <- ggplot(subset(stest,site=="north"), aes(x=factor(year), y=conc)) + geom_boxplot(horizontal=TRUE) + coord_flip() + scale_y_log10(name="") p2 <- ggplot(subset(stest,site=="south"), aes(x=factor(year), y=conc)) + geom_boxplot(horizontal=TRUE) + coord_flip() + scale_y_log10(name="X Title",breaks=seq(4,6,by=.5)) + grid.arrange(p1, p2, ncol=1) ```
28,662,450
I'm trying to create a makefile that will compile two files: -main.cpp -queue.h Inside of the header file I have the a full implementation of a template Queue class. The main file includes the header file. I can test this code in the terminal (on a Mac) by typing this in: ``` g++ -c main.cpp g++ -o queue main.o ``` and I'm able to run the program (./queue) with no problem. Now for this project it needs to compile by just typing "make" in the terminal. For previous projects I used something like this: ``` all: sDeque sDeque: sDeque.o sDeque_main.o g++ -o sDeque sDeque.o sDeque_main.o sDeque.o: sDeque.cpp sDeque.h g++ -c sDeque.cpp sDeque_main.o: sDeque_main.cpp sDeque.h g++ -c sDeque_main.cpp clean: rm sDeque sDeque.o sDeque_main.o ``` But the example above has a main.cpp , sDeque.cpp and sDeque.h. And this works since I can create object files but I don't think I can create an object file from just a header file. For the task at hand I only have the main and the header file (since its a template class). How do I make the makefile for this?
2015/02/22
[ "https://Stackoverflow.com/questions/28662450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4594551/" ]
``` # All the targets all: queue # Dependencies and rule to make queue queue: main.o g++ -o queue main.o # Dependencies and rule to make main.o main.o: main.cpp queue.h g++ -c main.cpp clean: rm queue main.o ```
R Sahu's answer is correct, but note that you can do a lot better (less typing) by taking advantage of GNU make's built-in rules, which already know how to do this stuff. In particular, if you rename your `main.cpp` file to `queue.cpp` (so that it has the same prefix as the program you want to generate, `queue`), your entire makefile can consist of just: ``` CXX = g++ all: queue queue.o: queue.h clean: rm queue queue.o ```
51,097,743
I've seen lots of questions about this but I still can't solve my problem. I have a fragment called `CameraFragment.java` which opens a camera and saves the taken picture. The problem is, to save that I need to have WRITE\_EXTERNAL\_STORAGE permissions... I've added these lines to my Manifest.xml: `<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />` `<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />` But in my **logcat**, when I run this code to save the image: ``` private void saveImage(Bitmap finalBitmap, String image_name) { final String appDirectoryName = "Feel"; String root = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES).toString(); File myDir = new File(root); myDir.mkdirs(); String fname = "Image" + image_name + ".jpg"; File file = new File(myDir, fname); //if (file.exists()) file.delete(); Log.i("LOAD", root + fname); try { FileOutputStream out = new FileOutputStream(file); finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } } ``` I still get this error: `W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Imageimagem1.jpg (Permission denied)` I am not sure but I think that this error comes from no permissions to write the file... How can I give this permissions in runtime?
2018/06/29
[ "https://Stackoverflow.com/questions/51097743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9995448/" ]
[Click here](http://github.com/Karumi/Dexter) for run time permissions! please look into this github.com/Karumi/Dexter
Here is a class, with a method asking for storage permission ``` public class PermissionManager { public static boolean checkPermissionREAD_EXTERNAL_STORAGE(final Context context) { int currentAPIVersion = Build.VERSION.SDK_INT; if (currentAPIVersion >= android.os.Build.VERSION_CODES.M) { if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale( (Activity) context, Manifest.permission.READ_EXTERNAL_STORAGE)) { showDialog("External storage", context, Manifest.permission.READ_EXTERNAL_STORAGE); } else { ActivityCompat .requestPermissions( (Activity) context, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 101); } return false; } else { return true; } } else { return true; } } } ``` Used in your activity: ``` @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { switch (requestCode) { case 101: if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast.makeText(this, "Permission given", Toast.LENGTH_SHORT).show(); //saveImage(finalBitmap, image_name); <- or whatever you want to do after permission was given . For instance, open gallery or something } else { Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show(); } break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); } } ``` In your case, you'll also check for it before saving the file ``` if (PermissionManager.checkPermissionREAD_EXTERNAL_STORAGE(this)){ saveImage(finalBitmap, image_name); } ```
51,097,743
I've seen lots of questions about this but I still can't solve my problem. I have a fragment called `CameraFragment.java` which opens a camera and saves the taken picture. The problem is, to save that I need to have WRITE\_EXTERNAL\_STORAGE permissions... I've added these lines to my Manifest.xml: `<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />` `<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />` But in my **logcat**, when I run this code to save the image: ``` private void saveImage(Bitmap finalBitmap, String image_name) { final String appDirectoryName = "Feel"; String root = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES).toString(); File myDir = new File(root); myDir.mkdirs(); String fname = "Image" + image_name + ".jpg"; File file = new File(myDir, fname); //if (file.exists()) file.delete(); Log.i("LOAD", root + fname); try { FileOutputStream out = new FileOutputStream(file); finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } } ``` I still get this error: `W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Imageimagem1.jpg (Permission denied)` I am not sure but I think that this error comes from no permissions to write the file... How can I give this permissions in runtime?
2018/06/29
[ "https://Stackoverflow.com/questions/51097743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9995448/" ]
[Click here](http://github.com/Karumi/Dexter) for run time permissions! please look into this github.com/Karumi/Dexter
You can use [PermissionDispatcher](https://github.com/codepath/android_guides/wiki/Managing-Runtime-Permissions-with-PermissionsDispatcher) to handle it very gently AFAIK it works in all versions. Hope this will help you
51,097,743
I've seen lots of questions about this but I still can't solve my problem. I have a fragment called `CameraFragment.java` which opens a camera and saves the taken picture. The problem is, to save that I need to have WRITE\_EXTERNAL\_STORAGE permissions... I've added these lines to my Manifest.xml: `<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />` `<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />` But in my **logcat**, when I run this code to save the image: ``` private void saveImage(Bitmap finalBitmap, String image_name) { final String appDirectoryName = "Feel"; String root = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES).toString(); File myDir = new File(root); myDir.mkdirs(); String fname = "Image" + image_name + ".jpg"; File file = new File(myDir, fname); //if (file.exists()) file.delete(); Log.i("LOAD", root + fname); try { FileOutputStream out = new FileOutputStream(file); finalBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } } ``` I still get this error: `W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Pictures/Imageimagem1.jpg (Permission denied)` I am not sure but I think that this error comes from no permissions to write the file... How can I give this permissions in runtime?
2018/06/29
[ "https://Stackoverflow.com/questions/51097743", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9995448/" ]
Here is a class, with a method asking for storage permission ``` public class PermissionManager { public static boolean checkPermissionREAD_EXTERNAL_STORAGE(final Context context) { int currentAPIVersion = Build.VERSION.SDK_INT; if (currentAPIVersion >= android.os.Build.VERSION_CODES.M) { if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { if (ActivityCompat.shouldShowRequestPermissionRationale( (Activity) context, Manifest.permission.READ_EXTERNAL_STORAGE)) { showDialog("External storage", context, Manifest.permission.READ_EXTERNAL_STORAGE); } else { ActivityCompat .requestPermissions( (Activity) context, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, 101); } return false; } else { return true; } } else { return true; } } } ``` Used in your activity: ``` @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { switch (requestCode) { case 101: if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast.makeText(this, "Permission given", Toast.LENGTH_SHORT).show(); //saveImage(finalBitmap, image_name); <- or whatever you want to do after permission was given . For instance, open gallery or something } else { Toast.makeText(this, "Permission Denied", Toast.LENGTH_SHORT).show(); } break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); } } ``` In your case, you'll also check for it before saving the file ``` if (PermissionManager.checkPermissionREAD_EXTERNAL_STORAGE(this)){ saveImage(finalBitmap, image_name); } ```
You can use [PermissionDispatcher](https://github.com/codepath/android_guides/wiki/Managing-Runtime-Permissions-with-PermissionsDispatcher) to handle it very gently AFAIK it works in all versions. Hope this will help you
67,522,333
I am using `springdoc` with `spring-boot` configured mostly with annotations. I would like to expose a particular class schema which is not referenced by any service. Is it possible to do this? In pseudocode, I am effectively trying to do this: `GroupedOpenAPI.parseAndAddClass(Class<?> clazz);` or `GroupedOpenAPI.scan("my.models.package");` === Update === I managed to parse the Schema using `ModelConverters.getInstance().readAll(MyClass.class);` and then tried to add it as an `OpenApiCustomiser`, however it is still not visible in the UI.
2021/05/13
[ "https://Stackoverflow.com/questions/67522333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1243436/" ]
In the SpringDoc, you can add a non-related class to the generated specification using `OpenApiCustomiser` ``` @Bean public OpenApiCustomiser schemaCustomiser() { ResolvedSchema resolvedSchema = ModelConverters.getInstance() .resolveAsResolvedSchema(new AnnotatedType(MyClass.class)); return openApi -> openApi .schema(resolvedSchema.schema.getName(), resolvedSchema.schema); } ``` But need to be careful, because if your additional model is not referenced in any API, by default the SpringDoc automatically removes every broken reference definition. To disable this default behavior, you need to use the following configuration property: ``` springdoc.remove-broken-reference-definitions=false ```
The accepted answer is correct, however this will only add the schema for "MyClass.class". If there are any classes referenced from `MyClass.class` which are not in the schemas, they won't be added. I managed to add all classes like this: ``` private OpenApiCustomiser addAdditionalModels() { Map<String, Schema> schemasToAdd = ModelConverters.getInstance() .resolveAsResolvedSchema(new AnnotatedType(MyClass.class)) .referencedSchemas; return openApi -> { var existingSchemas = openApi.getComponents().getSchemas(); if (!CollectionUtils.isEmpty(existingSchemas)) { schemasToAdd.putAll(existingSchemas); } openApi.getComponents().setSchemas(schemasToAdd); }; } ```
67,522,333
I am using `springdoc` with `spring-boot` configured mostly with annotations. I would like to expose a particular class schema which is not referenced by any service. Is it possible to do this? In pseudocode, I am effectively trying to do this: `GroupedOpenAPI.parseAndAddClass(Class<?> clazz);` or `GroupedOpenAPI.scan("my.models.package");` === Update === I managed to parse the Schema using `ModelConverters.getInstance().readAll(MyClass.class);` and then tried to add it as an `OpenApiCustomiser`, however it is still not visible in the UI.
2021/05/13
[ "https://Stackoverflow.com/questions/67522333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1243436/" ]
In the SpringDoc, you can add a non-related class to the generated specification using `OpenApiCustomiser` ``` @Bean public OpenApiCustomiser schemaCustomiser() { ResolvedSchema resolvedSchema = ModelConverters.getInstance() .resolveAsResolvedSchema(new AnnotatedType(MyClass.class)); return openApi -> openApi .schema(resolvedSchema.schema.getName(), resolvedSchema.schema); } ``` But need to be careful, because if your additional model is not referenced in any API, by default the SpringDoc automatically removes every broken reference definition. To disable this default behavior, you need to use the following configuration property: ``` springdoc.remove-broken-reference-definitions=false ```
I tested both solutions with following dependencies: ``` <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>1.6.6</version> </dependency> <dependency> <groupId>io.swagger.codegen.v3</groupId> <artifactId>swagger-codegen-generators</artifactId> <version>1.0.32</version> </dependency> ``` @nkocev solution throws an UnsupportedOperationException for putAll() when reloading /v3/api-docs. java.lang.UnsupportedOperationException: null at java.util.Collections$UnmodifiableMap.putAll(Collections.java:1465) --- @VadymVL solution worked fine, the response model was added to the schema. I just want to provide this information. If you want to add multiple missing schemas, you can create a @Bean for each schema. ``` @Configuration public class SampleConfiguration { @Bean public OpenApiCustomiser schemaCustomiser() { ResolvedSchema resolvedSchema = ModelConverters.getInstance() .readAllAsResolvedSchema(new AnnotatedType(MyClass.class)); return openApi -> openApi.schema(resolvedSchema.schema.getName(), resolvedSchema.schema); } @Bean public OpenApiCustomiser schemaCustomiser2() { ResolvedSchema resolvedSchema = ModelConverters.getInstance() .readAllAsResolvedSchema(new AnnotatedType(MyClass2.class)); return openApi -> openApi.schema(resolvedSchema.schema.getName(), resolvedSchema.schema); } } ``` Both are then made available in the schemas. I've just started working with these dependencies, but this seems like a working solution. I look forward to more helpful POCs.
67,522,333
I am using `springdoc` with `spring-boot` configured mostly with annotations. I would like to expose a particular class schema which is not referenced by any service. Is it possible to do this? In pseudocode, I am effectively trying to do this: `GroupedOpenAPI.parseAndAddClass(Class<?> clazz);` or `GroupedOpenAPI.scan("my.models.package");` === Update === I managed to parse the Schema using `ModelConverters.getInstance().readAll(MyClass.class);` and then tried to add it as an `OpenApiCustomiser`, however it is still not visible in the UI.
2021/05/13
[ "https://Stackoverflow.com/questions/67522333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1243436/" ]
In the SpringDoc, you can add a non-related class to the generated specification using `OpenApiCustomiser` ``` @Bean public OpenApiCustomiser schemaCustomiser() { ResolvedSchema resolvedSchema = ModelConverters.getInstance() .resolveAsResolvedSchema(new AnnotatedType(MyClass.class)); return openApi -> openApi .schema(resolvedSchema.schema.getName(), resolvedSchema.schema); } ``` But need to be careful, because if your additional model is not referenced in any API, by default the SpringDoc automatically removes every broken reference definition. To disable this default behavior, you need to use the following configuration property: ``` springdoc.remove-broken-reference-definitions=false ```
With `GroupedOpenApi` (schema must be set manually): ``` @Bean GroupedOpenApi api() { return GroupedOpenApi.builder() .group("REST API") .addOpenApiCustomizer(openApi -> { openApi.addSecurityItem(new SecurityRequirement().addList("Authorization")) .components(new Components() .addSchemas("User", ModelConverters.getInstance().readAllAsResolvedSchema(User.class).schema) .addSchemas("UserTo", ModelConverters.getInstance().readAllAsResolvedSchema(UserTo.class).schema) .addSecuritySchemes("Authorization", new SecurityScheme() .in(SecurityScheme.In.HEADER) .type(SecurityScheme.Type.HTTP) .scheme("bearer") .name("JWT")) ) .info(new Info().title("REST API").version("1.0").description(...)); }) .pathsToMatch("/api/**") .build(); } ```
20,594,498
I had task to copy and delete a huge folder using win32 api (C++), I am using the Code Guru recurisive directory deletion code, which works well, but there arises certain question. [RemoveDirectory](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365488%28v=vs.85%29.aspx) > > **Million thanks to Lerooooy Jenkins for pointing it.** > > > The link to CodeGuru for recursive deletes doesn't correctly handle > symbolic links/junctions. Given that a reparse point could point > anywhere (even network drives), you need to be careful when deleting > recursively and only delete the symbolic link/junction and not what it > points at. The correct way to handle this situation is to detect > reparse points (via GetFileAttributes()) and NOT traverse it as a > subdirectory. > > > So my question is how to actually handle Symbolic Links and Junction while deleting or coping a folder tree. For the shake of question here is the source code of CodeGuru Directory Deletion ``` #include <string> #include <iostream> #include <windows.h> #include <conio.h> int DeleteDirectory(const std::string &refcstrRootDirectory, bool bDeleteSubdirectories = true) { bool bSubdirectory = false; // Flag, indicating whether // subdirectories have been found HANDLE hFile; // Handle to directory std::string strFilePath; // Filepath std::string strPattern; // Pattern WIN32_FIND_DATA FileInformation; // File information strPattern = refcstrRootDirectory + "\\*.*"; hFile = ::FindFirstFile(strPattern.c_str(), &FileInformation); if(hFile != INVALID_HANDLE_VALUE) { do { if(FileInformation.cFileName[0] != '.') { strFilePath.erase(); strFilePath = refcstrRootDirectory + "\\" + FileInformation.cFileName; if(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if(bDeleteSubdirectories) { // Delete subdirectory int iRC = DeleteDirectory(strFilePath, bDeleteSubdirectories); if(iRC) return iRC; } else bSubdirectory = true; } else { // Set file attributes if(::SetFileAttributes(strFilePath.c_str(), FILE_ATTRIBUTE_NORMAL) == FALSE) return ::GetLastError(); // Delete file if(::DeleteFile(strFilePath.c_str()) == FALSE) return ::GetLastError(); } } } while(::FindNextFile(hFile, &FileInformation) == TRUE); // Close handle ::FindClose(hFile); DWORD dwError = ::GetLastError(); if(dwError != ERROR_NO_MORE_FILES) return dwError; else { if(!bSubdirectory) { // Set directory attributes if(::SetFileAttributes(refcstrRootDirectory.c_str(), FILE_ATTRIBUTE_NORMAL) == FALSE) return ::GetLastError(); // Delete directory if(::RemoveDirectory(refcstrRootDirectory.c_str()) == FALSE) return ::GetLastError(); } } } return 0; } int main() { int iRC = 0; std::string strDirectoryToDelete = "c:\\mydir"; // Delete 'c:\mydir' without deleting the subdirectories iRC = DeleteDirectory(strDirectoryToDelete, false); if(iRC) { std::cout << "Error " << iRC << std::endl; return -1; } // Delete 'c:\mydir' and its subdirectories iRC = DeleteDirectory(strDirectoryToDelete); if(iRC) { std::cout << "Error " << iRC << std::endl; return -1; } // Wait for keystroke _getch(); return 0; } ```
2013/12/15
[ "https://Stackoverflow.com/questions/20594498", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2056430/" ]
Use [`DeleteFile`](http://msdn.microsoft.com/en-us/library/windows/desktop/aa363915%28v=vs.85%29.aspx) to delete file symbolic links. Use [`RemoveDirectory`](http://msdn.microsoft.com/en-us/library/windows/desktop/aa365488%28v=vs.85%29.aspx) to delete directory symbolic links and junctions. In other words, you treat them just like any other file or directory except that you don't recurse into directories that have the `FILE_ATTRIBUTE_REPARSE_POINT` attribute.
The simplest way to achieve your goal, and the recommended way to do it, is to get the system to do the work. * If you need to support XP then you use [`SHFileOperation`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762164.aspx) with the `FO_DELETE` flag. * Otherwise, for Vista and later, use [`IFileOperation`](http://msdn.microsoft.com/en-us/library/windows/desktop/bb775771.aspx). These APIs handle all the details for you, and use the same code paths as does the shell. You can even show the standard shell progress UI if you desire.
9,178,718
I'm trying to remove default focus froom chrome and it works with outline:none; in the same time I want to add an box-shadow but it not working for select . ``` *:focus { outline:none; } input[type="text"]:focus,input[type="checkbox"]:focus,input[type="password"]:focus, select:focus, textarea:focus,option:focus{ box-shadow:0 0 2px 0 #0066FF; -webkit-box-shadow:0 0 9px 0 #86AECC; z-index:1; } ``` fiddle: <http://jsfiddle.net/DCjYA/309/>
2012/02/07
[ "https://Stackoverflow.com/questions/9178718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192687/" ]
Try this: ``` * { outline-color: lime; } ```
Most effective solution on Links only: ``` a:focus, a:active{ outline:none; } ``` Or you can disable global: ``` *{ outline:none; } ```
9,178,718
I'm trying to remove default focus froom chrome and it works with outline:none; in the same time I want to add an box-shadow but it not working for select . ``` *:focus { outline:none; } input[type="text"]:focus,input[type="checkbox"]:focus,input[type="password"]:focus, select:focus, textarea:focus,option:focus{ box-shadow:0 0 2px 0 #0066FF; -webkit-box-shadow:0 0 9px 0 #86AECC; z-index:1; } ``` fiddle: <http://jsfiddle.net/DCjYA/309/>
2012/02/07
[ "https://Stackoverflow.com/questions/9178718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192687/" ]
Try this: ``` * { outline-color: lime; } ```
This should also do the trick: ``` a:focus, a:active { outline-color: transparent !important; } ```
9,178,718
I'm trying to remove default focus froom chrome and it works with outline:none; in the same time I want to add an box-shadow but it not working for select . ``` *:focus { outline:none; } input[type="text"]:focus,input[type="checkbox"]:focus,input[type="password"]:focus, select:focus, textarea:focus,option:focus{ box-shadow:0 0 2px 0 #0066FF; -webkit-box-shadow:0 0 9px 0 #86AECC; z-index:1; } ``` fiddle: <http://jsfiddle.net/DCjYA/309/>
2012/02/07
[ "https://Stackoverflow.com/questions/9178718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192687/" ]
Try this: ``` * { outline-color: lime; } ```
for me this worked ``` :focus { outline: -webkit-focus-ring-color auto 0; } ```
9,178,718
I'm trying to remove default focus froom chrome and it works with outline:none; in the same time I want to add an box-shadow but it not working for select . ``` *:focus { outline:none; } input[type="text"]:focus,input[type="checkbox"]:focus,input[type="password"]:focus, select:focus, textarea:focus,option:focus{ box-shadow:0 0 2px 0 #0066FF; -webkit-box-shadow:0 0 9px 0 #86AECC; z-index:1; } ``` fiddle: <http://jsfiddle.net/DCjYA/309/>
2012/02/07
[ "https://Stackoverflow.com/questions/9178718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192687/" ]
This should also do the trick: ``` a:focus, a:active { outline-color: transparent !important; } ```
Most effective solution on Links only: ``` a:focus, a:active{ outline:none; } ``` Or you can disable global: ``` *{ outline:none; } ```
9,178,718
I'm trying to remove default focus froom chrome and it works with outline:none; in the same time I want to add an box-shadow but it not working for select . ``` *:focus { outline:none; } input[type="text"]:focus,input[type="checkbox"]:focus,input[type="password"]:focus, select:focus, textarea:focus,option:focus{ box-shadow:0 0 2px 0 #0066FF; -webkit-box-shadow:0 0 9px 0 #86AECC; z-index:1; } ``` fiddle: <http://jsfiddle.net/DCjYA/309/>
2012/02/07
[ "https://Stackoverflow.com/questions/9178718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192687/" ]
for me this worked ``` :focus { outline: -webkit-focus-ring-color auto 0; } ```
Most effective solution on Links only: ``` a:focus, a:active{ outline:none; } ``` Or you can disable global: ``` *{ outline:none; } ```
9,178,718
I'm trying to remove default focus froom chrome and it works with outline:none; in the same time I want to add an box-shadow but it not working for select . ``` *:focus { outline:none; } input[type="text"]:focus,input[type="checkbox"]:focus,input[type="password"]:focus, select:focus, textarea:focus,option:focus{ box-shadow:0 0 2px 0 #0066FF; -webkit-box-shadow:0 0 9px 0 #86AECC; z-index:1; } ``` fiddle: <http://jsfiddle.net/DCjYA/309/>
2012/02/07
[ "https://Stackoverflow.com/questions/9178718", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192687/" ]
for me this worked ``` :focus { outline: -webkit-focus-ring-color auto 0; } ```
This should also do the trick: ``` a:focus, a:active { outline-color: transparent !important; } ```
34,737,272
In Azure there are 2 options available to create virtual machines. A. normal VM B. Classic VM Does anybody know what is the difference between both option? When do we use one over other?
2016/01/12
[ "https://Stackoverflow.com/questions/34737272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136425/" ]
The Azure Virtual Machine (classic) is based on the old Azure Service Management Model (ASM). Which revolved around the concept of a cloud service. Everything was contained inside a cloud service, and that was the gateway to the internet. While it is still used (extensively) Azure is now moving over to the Azure Resource Management Model (ARM). ARM uses the concept of declarative templates to configure an entire solution (rather than individual components) So you can create an entire Sharepoint stack, rather than just a singular machine. ARM also has a much more logical approach to networking. Instead of having a monolithic VM in an obscure cloud service. You have a VM, that you attach a network card to. You can then put the Network card into a VNet and attach a public IP (if you need one) Unless you have a compelling reason to use ASM (classic) You should create your solution using ARM. As this is the MS recommendation going forward (todo find a link to that) It also means that you can create templates for your deployments, so you can have a repeatable solution. On the negative, the old portal manage.windowsazure.com can not manage anything that is deployed using ARM, and there are still parts of ASM that haven't been migrated over to ARM yet. For instance you cannot configure Azure VM backup, since Azure backup is ASM and it can't 'see' ARM VMs It very largely depends on your circumstances though, what it is you are planning for, the method you are going to deploy with. If you are just looking to stand a machine up to do a single task, it makes very little difference. If you are looking to deploy into an environment that will have some concepts of DevOps going forward, then ARM is the way to go.
The one big differences is for resource management. For that new version is called Azure Resource Manager VM (ARM VM). ARM VM is better in terms of; * Classic VM must be tied with *Cloud Service*, and Cloud Service consumes resource limitation and not-so-flexible network configuration. * ARM VM is managed under Azure Resource Manager (ARM) which can be organized with/without other Azure services. ARM is like a folder of Azure services, and it gives you more fine-grained resource management. Classic VM can be migrated to ARM VM version, but you have to afford service downtime. To migrate from classic VM, read the [official article: Considerations for Virtual Machines](https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model/#considerations-for-virtual-machines).
34,737,272
In Azure there are 2 options available to create virtual machines. A. normal VM B. Classic VM Does anybody know what is the difference between both option? When do we use one over other?
2016/01/12
[ "https://Stackoverflow.com/questions/34737272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136425/" ]
Short answer to your question is `Normal VM or Virtual Machines` is the new way of deploying your Virtual Machines whereas `Classic VM or Virtual Machines (Classic)` is the old way of deploying them. Azure is pushing towards the new way of deploying resources so the recommendation would be to use it instead of old way. However please keep in mind that there're some features which are available in the old way that have not been ported on to the new way so you just have to compare the features offered and only if something that you need is not available in new way, you use the old way. Now comes the long answer :) Essentially there's a REST API using which you interact with Azure Infrastructure. When Azure started out, this API was called `Service Management API (SMAPI)` which served its purpose quite well at that time (and to some extent today). However as Azure grew, so does the requirements of users and that's where SMAPI was found limiting. A good example is access control. In SMAPI, there was access control but it was more like `all-or-none` kind of access control. It lacked the granularity asked by users. Instead of patching SMAPI to meet user's requirement, Azure team decided to rewrite the entire API which was much simpler, more robust and feature rich. This API is called `Azure Resource Manager API (ARM)`. ARM has many features that are not there in SMAPI (my personal favorite is `Role-based access control - RBAC`). If you have noticed that there are two Azure portals today - [`https://manage.windowsazure.com`](https://manage.windowsazure.com) (old) and [`https://portal.azure.com`](https://portal.azure.com) (new). Old portal supports SMAPI whereas new portal supports ARM. In order to surface resources created via old portal into new portal (so that you can have a unified experience), Azure team ended up creating a resource provider for old stuff and their names will always end with `(Classic)` so you will see `Virtual Machines (Classic)`, `Storage Accounts (Classic)` etc. So the resources you create in old portal can be seen in the new portal (provided the new portal supports them) but any resources you create in the new portal using ARM are not shown in the old portal.
The Azure Virtual Machine (classic) is based on the old Azure Service Management Model (ASM). Which revolved around the concept of a cloud service. Everything was contained inside a cloud service, and that was the gateway to the internet. While it is still used (extensively) Azure is now moving over to the Azure Resource Management Model (ARM). ARM uses the concept of declarative templates to configure an entire solution (rather than individual components) So you can create an entire Sharepoint stack, rather than just a singular machine. ARM also has a much more logical approach to networking. Instead of having a monolithic VM in an obscure cloud service. You have a VM, that you attach a network card to. You can then put the Network card into a VNet and attach a public IP (if you need one) Unless you have a compelling reason to use ASM (classic) You should create your solution using ARM. As this is the MS recommendation going forward (todo find a link to that) It also means that you can create templates for your deployments, so you can have a repeatable solution. On the negative, the old portal manage.windowsazure.com can not manage anything that is deployed using ARM, and there are still parts of ASM that haven't been migrated over to ARM yet. For instance you cannot configure Azure VM backup, since Azure backup is ASM and it can't 'see' ARM VMs It very largely depends on your circumstances though, what it is you are planning for, the method you are going to deploy with. If you are just looking to stand a machine up to do a single task, it makes very little difference. If you are looking to deploy into an environment that will have some concepts of DevOps going forward, then ARM is the way to go.
34,737,272
In Azure there are 2 options available to create virtual machines. A. normal VM B. Classic VM Does anybody know what is the difference between both option? When do we use one over other?
2016/01/12
[ "https://Stackoverflow.com/questions/34737272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136425/" ]
The Azure Virtual Machine (classic) is based on the old Azure Service Management Model (ASM). Which revolved around the concept of a cloud service. Everything was contained inside a cloud service, and that was the gateway to the internet. While it is still used (extensively) Azure is now moving over to the Azure Resource Management Model (ARM). ARM uses the concept of declarative templates to configure an entire solution (rather than individual components) So you can create an entire Sharepoint stack, rather than just a singular machine. ARM also has a much more logical approach to networking. Instead of having a monolithic VM in an obscure cloud service. You have a VM, that you attach a network card to. You can then put the Network card into a VNet and attach a public IP (if you need one) Unless you have a compelling reason to use ASM (classic) You should create your solution using ARM. As this is the MS recommendation going forward (todo find a link to that) It also means that you can create templates for your deployments, so you can have a repeatable solution. On the negative, the old portal manage.windowsazure.com can not manage anything that is deployed using ARM, and there are still parts of ASM that haven't been migrated over to ARM yet. For instance you cannot configure Azure VM backup, since Azure backup is ASM and it can't 'see' ARM VMs It very largely depends on your circumstances though, what it is you are planning for, the method you are going to deploy with. If you are just looking to stand a machine up to do a single task, it makes very little difference. If you are looking to deploy into an environment that will have some concepts of DevOps going forward, then ARM is the way to go.
Azure provides two deploy models now: Azure Resource Manager(Normal) and Azure Service Management(Classic) and some [important considerations](https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model#considerations-for-virtual-machines) you should care when working Virtual Machines. 1. Virtual machines deployed with the classic deployment model cannot be included in a virtual network deployed with Resource Manager. 2. Virtual machines deployed with the Resource Manager deployment model must be included in a virtual network. 3. Virtual machines deployed with the classic deployment model don't have to be included in a virtual network.
34,737,272
In Azure there are 2 options available to create virtual machines. A. normal VM B. Classic VM Does anybody know what is the difference between both option? When do we use one over other?
2016/01/12
[ "https://Stackoverflow.com/questions/34737272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136425/" ]
Short answer to your question is `Normal VM or Virtual Machines` is the new way of deploying your Virtual Machines whereas `Classic VM or Virtual Machines (Classic)` is the old way of deploying them. Azure is pushing towards the new way of deploying resources so the recommendation would be to use it instead of old way. However please keep in mind that there're some features which are available in the old way that have not been ported on to the new way so you just have to compare the features offered and only if something that you need is not available in new way, you use the old way. Now comes the long answer :) Essentially there's a REST API using which you interact with Azure Infrastructure. When Azure started out, this API was called `Service Management API (SMAPI)` which served its purpose quite well at that time (and to some extent today). However as Azure grew, so does the requirements of users and that's where SMAPI was found limiting. A good example is access control. In SMAPI, there was access control but it was more like `all-or-none` kind of access control. It lacked the granularity asked by users. Instead of patching SMAPI to meet user's requirement, Azure team decided to rewrite the entire API which was much simpler, more robust and feature rich. This API is called `Azure Resource Manager API (ARM)`. ARM has many features that are not there in SMAPI (my personal favorite is `Role-based access control - RBAC`). If you have noticed that there are two Azure portals today - [`https://manage.windowsazure.com`](https://manage.windowsazure.com) (old) and [`https://portal.azure.com`](https://portal.azure.com) (new). Old portal supports SMAPI whereas new portal supports ARM. In order to surface resources created via old portal into new portal (so that you can have a unified experience), Azure team ended up creating a resource provider for old stuff and their names will always end with `(Classic)` so you will see `Virtual Machines (Classic)`, `Storage Accounts (Classic)` etc. So the resources you create in old portal can be seen in the new portal (provided the new portal supports them) but any resources you create in the new portal using ARM are not shown in the old portal.
The one big differences is for resource management. For that new version is called Azure Resource Manager VM (ARM VM). ARM VM is better in terms of; * Classic VM must be tied with *Cloud Service*, and Cloud Service consumes resource limitation and not-so-flexible network configuration. * ARM VM is managed under Azure Resource Manager (ARM) which can be organized with/without other Azure services. ARM is like a folder of Azure services, and it gives you more fine-grained resource management. Classic VM can be migrated to ARM VM version, but you have to afford service downtime. To migrate from classic VM, read the [official article: Considerations for Virtual Machines](https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model/#considerations-for-virtual-machines).
34,737,272
In Azure there are 2 options available to create virtual machines. A. normal VM B. Classic VM Does anybody know what is the difference between both option? When do we use one over other?
2016/01/12
[ "https://Stackoverflow.com/questions/34737272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136425/" ]
The one big differences is for resource management. For that new version is called Azure Resource Manager VM (ARM VM). ARM VM is better in terms of; * Classic VM must be tied with *Cloud Service*, and Cloud Service consumes resource limitation and not-so-flexible network configuration. * ARM VM is managed under Azure Resource Manager (ARM) which can be organized with/without other Azure services. ARM is like a folder of Azure services, and it gives you more fine-grained resource management. Classic VM can be migrated to ARM VM version, but you have to afford service downtime. To migrate from classic VM, read the [official article: Considerations for Virtual Machines](https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model/#considerations-for-virtual-machines).
Azure provides two deploy models now: Azure Resource Manager(Normal) and Azure Service Management(Classic) and some [important considerations](https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model#considerations-for-virtual-machines) you should care when working Virtual Machines. 1. Virtual machines deployed with the classic deployment model cannot be included in a virtual network deployed with Resource Manager. 2. Virtual machines deployed with the Resource Manager deployment model must be included in a virtual network. 3. Virtual machines deployed with the classic deployment model don't have to be included in a virtual network.
34,737,272
In Azure there are 2 options available to create virtual machines. A. normal VM B. Classic VM Does anybody know what is the difference between both option? When do we use one over other?
2016/01/12
[ "https://Stackoverflow.com/questions/34737272", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136425/" ]
Short answer to your question is `Normal VM or Virtual Machines` is the new way of deploying your Virtual Machines whereas `Classic VM or Virtual Machines (Classic)` is the old way of deploying them. Azure is pushing towards the new way of deploying resources so the recommendation would be to use it instead of old way. However please keep in mind that there're some features which are available in the old way that have not been ported on to the new way so you just have to compare the features offered and only if something that you need is not available in new way, you use the old way. Now comes the long answer :) Essentially there's a REST API using which you interact with Azure Infrastructure. When Azure started out, this API was called `Service Management API (SMAPI)` which served its purpose quite well at that time (and to some extent today). However as Azure grew, so does the requirements of users and that's where SMAPI was found limiting. A good example is access control. In SMAPI, there was access control but it was more like `all-or-none` kind of access control. It lacked the granularity asked by users. Instead of patching SMAPI to meet user's requirement, Azure team decided to rewrite the entire API which was much simpler, more robust and feature rich. This API is called `Azure Resource Manager API (ARM)`. ARM has many features that are not there in SMAPI (my personal favorite is `Role-based access control - RBAC`). If you have noticed that there are two Azure portals today - [`https://manage.windowsazure.com`](https://manage.windowsazure.com) (old) and [`https://portal.azure.com`](https://portal.azure.com) (new). Old portal supports SMAPI whereas new portal supports ARM. In order to surface resources created via old portal into new portal (so that you can have a unified experience), Azure team ended up creating a resource provider for old stuff and their names will always end with `(Classic)` so you will see `Virtual Machines (Classic)`, `Storage Accounts (Classic)` etc. So the resources you create in old portal can be seen in the new portal (provided the new portal supports them) but any resources you create in the new portal using ARM are not shown in the old portal.
Azure provides two deploy models now: Azure Resource Manager(Normal) and Azure Service Management(Classic) and some [important considerations](https://azure.microsoft.com/en-us/documentation/articles/resource-manager-deployment-model#considerations-for-virtual-machines) you should care when working Virtual Machines. 1. Virtual machines deployed with the classic deployment model cannot be included in a virtual network deployed with Resource Manager. 2. Virtual machines deployed with the Resource Manager deployment model must be included in a virtual network. 3. Virtual machines deployed with the classic deployment model don't have to be included in a virtual network.
70,374,067
```cpp #include <stdio.h> int main() { int arr[] = {10, 20, 30, 8, 2}; int index = -1, ele; printf("Enter the elment you want to search :"); scanf("%d", ele); for (int i = 0; i < 5; i++) { if (arr[i] == ele) ; index = i; break; } if (index == -1) { printf("Not found\n"); } else { printf("Found at %d", index); } return 0; } ``` the above code isn't printing the result. I am learning C programing from past few days. Can You please help me out with this. I am not getting any type of error.
2021/12/16
[ "https://Stackoverflow.com/questions/70374067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16166780/" ]
Your if statement doesn't have any code within it *(just a semi colon)*. Prefer using braces ```cpp if (arr[i] == ele) { index = i; break; } ``` Also, you'll need to specify the address of the variable you are reading into when using scanf, e.g. ```cpp scanf("%d", &ele); //< take the address of 'ele' using & ```
There are 2 mistakes in the code ``` #include<stdio.h> int main() { int arr[] = {10, 20, 30, 8, 2}; int index = -1, ele; printf("Enter the elment you want to search :"); scanf("%d", &ele);//mistake here for (int i = 0; i < 5; i++) { if (arr[i] == ele) { //Here a semi colon is used index = i; break; } } if (index == -1) { printf("Not found\n"); } else { printf("Found at %d", index); } return 0; } ``` Correcting these will give correct output[![enter image description here](https://i.stack.imgur.com/vtZYn.png)](https://i.stack.imgur.com/vtZYn.png)
70,095,538
I am trying to deploy a hub & spoke topology on Azure. I have VNet: hub, spoke1 & spoke2, respectively with the 3 following address spaces: `10.0.0.0/16`, `10.1.0.0/16` & `10.2.0.0/16`. And each have only one subnet on the `/24` address space. I have peered each spoke to the hub and deployed a Linux machine in my hub subnet. Now, I want to use that Linux machine as a router to forward traffic coming from `10.1.0.0/16` and targetting `10.2.0.0/16` to the spoke2 VNet and vice-versa. I have added a `User Defined Route` on each spoke to use the Linux router IP address (`10.0.0.5`) as the Next hop when targetting the other spoke. I have enable `ip_forwarding` on my Linux machine: `echo 1 > /proc/sys/net/ipv4/ip_forward` and added 2 routes `ip route add 10.1.0.0/24 via 10.0.0.1 dev eth0` and `ip route add 10.2.0.0/24 via 10.0.0.1 dev eth0` since `10.0.0.1` is my gateway on my router and `eth0` my NIC. I have also enabled `IP Forwarding` on the NIC of my router in Azure. But... this does not work. Packets are not forwarded to appropriate network and I don't understand why. If any of you has a hint or even the solution to implement this I would appreciate. Thanks.
2021/11/24
[ "https://Stackoverflow.com/questions/70095538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2003148/" ]
No need for ``` setContentView(binding.getRoot()); ``` DataBinding.setContentView() is enough.
Or u can code it Like I do. Also Im using kotlin ``` private lateinit var binding: ActivityMainBinding override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = ActivityMainBinding.inflate(layoutInflater) val view = binding.root setContentView(view) ```
6,378
Let's suppose a CFI can no longer qualify for a 1st or 2nd class physical, or maybe her/his 2nd class physical was 18 months ago. Can she/he still give required instruction and endorsements as long as they don't charge for their time and are not paid for it in any other way?
2014/06/19
[ "https://aviation.stackexchange.com/questions/6378", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/394/" ]
A CFI with a third class medical can provide any kind of instruction that they are qualified for (and be compensated for it), per [14 CFR 61.23(a)(3)(iv) and (v)](http://rgl.faa.gov/Regulatory_and_Guidance_Library/rgFar.nsf/FARSBySectLookup/61.23). The FAA's position in these scenarios is that you're being compensated for the transference of knowledge, not the operation of the aircraft. For completeness, A CFI can provide instruction WITHOUT a medical if they are not flying PIC or acting as a required crew member. In this scenario training can be provided for certain additional ratings (e.g. commercial) or flight reviews AS LONG AS the student can PIC during that flight AND the CFI is NOT a required crew member (i.e. safety pilot for insturment training). Additionally, the FAA has made a [legal interpretation](http://www.faa.gov/about/office_org/headquarters_offices/agc/pol_adjudication/agc200/Interpretations/data/interps/2014/Schaffner%20-%20%282014%29%20Legal%20Interpretation.pdf) that a CFI can provide instruction to a pilot that is not current to carry passengers, as long as all other requirements for the student to be PIC can be met. The specific regulations that allows this are [14 CFR 61.3(c)(2)(viii)](http://rgl.faa.gov/Regulatory_and_Guidance_Library/rgFar.nsf/FARSBySectLookup/61.3) and [14 CFR 61.23(b)(5)](http://rgl.faa.gov/Regulatory_and_Guidance_Library/rgFar.nsf/FARSBySectLookup/61.23)
A CFI can give, and charge for instruction with a 3rd class medical. If the training does not require the CFI to be PIC, then the instruction can be given (and charged for) with no medical at all.
7,197,947
I have a xml in which I have to search for a tag and replace the value of tag with a new values. For example, ``` <tag-Name>oldName</tag-Name> ``` and replace `oldName` to `newName` like ``` <tag-Name>newName</tag-Name> ``` and save the xml. How can I do that without using thirdparty lib like `BeautifulSoup` Thank you
2011/08/25
[ "https://Stackoverflow.com/questions/7197947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/379235/" ]
The best option from the standard lib is (I think) the [xml.etree](http://docs.python.org/library/xml.etree.elementtree.html) package. Assuming that your example tag occurs only once somewhere in the document: ``` import xml.etree.ElementTree as etree # or for a faster C implementation # import xml.etree.cElementTree as etree tree = etree.parse('input.xml') elem = tree.find('//tag-Name') # finds the first occurrence of element tag-Name elem.text = 'newName' tree.write('output.xml') ``` Or if there are multiple occurrences of tag-Name, and you want to change them all if they have "oldName" as content: ``` import xml.etree.cElementTree as etree tree = etree.parse('input.xml') for elem in tree.findall('//tag-Name'): if elem.text == 'oldName': elem.text = 'newName' # some output options for example tree.write('output.xml', encoding='utf-8', xml_declaration=True) ```
Python has 'builtin' libraries for working with xml. For this simple task I'd look into minidom. You can find the docs here: <http://docs.python.org/library/xml.dom.minidom.html>
7,197,947
I have a xml in which I have to search for a tag and replace the value of tag with a new values. For example, ``` <tag-Name>oldName</tag-Name> ``` and replace `oldName` to `newName` like ``` <tag-Name>newName</tag-Name> ``` and save the xml. How can I do that without using thirdparty lib like `BeautifulSoup` Thank you
2011/08/25
[ "https://Stackoverflow.com/questions/7197947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/379235/" ]
The best option from the standard lib is (I think) the [xml.etree](http://docs.python.org/library/xml.etree.elementtree.html) package. Assuming that your example tag occurs only once somewhere in the document: ``` import xml.etree.ElementTree as etree # or for a faster C implementation # import xml.etree.cElementTree as etree tree = etree.parse('input.xml') elem = tree.find('//tag-Name') # finds the first occurrence of element tag-Name elem.text = 'newName' tree.write('output.xml') ``` Or if there are multiple occurrences of tag-Name, and you want to change them all if they have "oldName" as content: ``` import xml.etree.cElementTree as etree tree = etree.parse('input.xml') for elem in tree.findall('//tag-Name'): if elem.text == 'oldName': elem.text = 'newName' # some output options for example tree.write('output.xml', encoding='utf-8', xml_declaration=True) ```
If you are certain, I mean, completely 100% positive that the string `<tag-Name>` will *never* appear inside that tag and the XML will always be formatted like that, you can always use good old string manipulation tricks like: ``` xmlstring = xmlstring.replace('<tag-Name>oldName</tag-Name>', '<tag-Name>newName</tag-Name>') ``` If the XML isn't always as conveniently formatted as `<tag>value</tag>`, you could write something like: ``` a = """<tag-Name> oldName </tag-Name>""" def replacetagvalue(xmlstring, tag, oldvalue, newvalue): start = 0 while True: try: start = xmlstring.index('<%s>' % tag, start) + 2 + len(tag) except ValueError: break end = xmlstring.index('</%s>' % tag, start) value = xmlstring[start:end].strip() if value == oldvalue: xmlstring = xmlstring[:start] + newvalue + xmlstring[end:] return xmlstring print replacetagvalue(a, 'tag-Name', 'oldName', 'newName') ``` Others have already mentioned `xml.dom.minidom` which is probably a better idea if you're not absolutely certain beyond any doubt that your XML will be so simple. If you can guarantee that, though, remember that XML is just a big chunk of text that you can manipulate as needed. I use similar tricks in some production code where simple checks like `if "somevalue" in htmlpage` are much faster and more understandable than invoking BeautifulSoup, lxml, or other \*ML libraries.
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
Since you want to learn, I guess you don't want to use a lot of utility functions, so I will help with your `high`. Notice that there are two things when you want to construct the list: the starting number and the ending number. For `low`, it's easy because the ending number is a literal 0, while the starting number changes, so you can keep track by using only one variable. For `high`, the starting number needs to be changed in every iteration like in `low`. However, the ending number is not a literal (though it is constant), so we will need its information. Therefore, we will add the ending number as one of the arguments of the function. That is, we expect ``` (high 1 10) ; evaluates to (list 1 2 3 4 5 6 7 8 9 10) ``` The body then would be: ``` (define high (位 (start stop) ...)) ``` The terminating condition is when `start` goes beyond `stop`. This is the base case where the answer is `'()`. ``` (define high (位 (start stop) (cond [(> start stop) '()] ...))) ``` Otherwise, `start` is less than or equal to `stop`. The answer, a list starting from `start` and ends at `stop`, is the same as `start` attaching to the front of a list starting from `(add1 start)` and ends at `stop`. That is: ``` high start stop = [start start+1 start+2 ... stop] = [start] + [start+1 start+2 start+3 ... stop] = [start] + high start+1 stop ``` Thus: ``` (define high (位 (start stop) (cond [(> start stop) '()] [else (cons start (high (add1 start) stop))]))) ```
How about using built-in list procedures? it'll be a lot easier, an besides, it's the recommended way to think about a solution when using Scheme, which encourages a functional-programming style of coding: ``` (define (high-low n) (let ((lst (build-list n identity))) (append lst (cons n (reverse lst))))) ``` For example: ``` (high-low 4) => '(0 1 2 3 4 3 2 1 0) ```
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
How about using built-in list procedures? it'll be a lot easier, an besides, it's the recommended way to think about a solution when using Scheme, which encourages a functional-programming style of coding: ``` (define (high-low n) (let ((lst (build-list n identity))) (append lst (cons n (reverse lst))))) ``` For example: ``` (high-low 4) => '(0 1 2 3 4 3 2 1 0) ```
Here are a couple more options. Using `named let` and `quasi-quote`... ``` (define (high-low n) (let hi-lo ((i 0)) (if (= i n) `(,i) `(,i ,@(hi-lo (+ i 1)) ,i)))) ``` ...another option using `do`: ``` (define (high-low2 n) (do ((i (- n) (+ i 1)) (out '() (cons (- n (abs i)) out))) ((> i n) out))) ```
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
How about using built-in list procedures? it'll be a lot easier, an besides, it's the recommended way to think about a solution when using Scheme, which encourages a functional-programming style of coding: ``` (define (high-low n) (let ((lst (build-list n identity))) (append lst (cons n (reverse lst))))) ``` For example: ``` (high-low 4) => '(0 1 2 3 4 3 2 1 0) ```
Here is a rather over-general solution, built on a function which builds lists in a rather general way. It has the advantage of being tail-recursive: it will build arbitrarily long lists without exploding, but the disadvantages of needing to build them backwards and of being somewhat obscure to understand. Here is the function: ```lisp (define (lister base inc stop cont) ;; start with a (non-empty) list, base; ;; cons more elements of the form (inc (first ...)) to it; ;; until (stop (first ...)) is true; ;; finally call cont with the resulting list (define (lister-loop accum) (if (stop (first accum)) (cont accum) (lister-loop (cons (inc (first accum)) accum)))) (lister-loop base)) ``` (Note this could obviously use named-let for the inner function.) And here is a function using this function, twice, to count up and down. ```lisp (define (cud n) ;; count up and down (lister '(0) (位 (x) (+ x 1)) (位 (x) (= x n)) (位 (accum) (lister accum (位 (x) (- x 1)) zero? (位 (a) a))))) ``` And then: ``` > (cud 10) '(0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0) ``` --- Note that this was written using Racket: I think that is is pretty portable Scheme except that I have called `lambda` `位` and perhaps Scheme does not have `first` and so on.
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
Since you want to learn, I guess you don't want to use a lot of utility functions, so I will help with your `high`. Notice that there are two things when you want to construct the list: the starting number and the ending number. For `low`, it's easy because the ending number is a literal 0, while the starting number changes, so you can keep track by using only one variable. For `high`, the starting number needs to be changed in every iteration like in `low`. However, the ending number is not a literal (though it is constant), so we will need its information. Therefore, we will add the ending number as one of the arguments of the function. That is, we expect ``` (high 1 10) ; evaluates to (list 1 2 3 4 5 6 7 8 9 10) ``` The body then would be: ``` (define high (位 (start stop) ...)) ``` The terminating condition is when `start` goes beyond `stop`. This is the base case where the answer is `'()`. ``` (define high (位 (start stop) (cond [(> start stop) '()] ...))) ``` Otherwise, `start` is less than or equal to `stop`. The answer, a list starting from `start` and ends at `stop`, is the same as `start` attaching to the front of a list starting from `(add1 start)` and ends at `stop`. That is: ``` high start stop = [start start+1 start+2 ... stop] = [start] + [start+1 start+2 start+3 ... stop] = [start] + high start+1 stop ``` Thus: ``` (define high (位 (start stop) (cond [(> start stop) '()] [else (cons start (high (add1 start) stop))]))) ```
`#!racket` (aka `#lang racket`) has a `range` procedure so if you have the power of racket at your hands you can just do: ``` (define (high-low n) (append (range n) ; 0 to n-1 (range n -1 -1))) ; n to 0 ``` If you want to roll your own recursive loop you can think of it as building a list in reverse starting at zero increasing by one until a limit, then decreasing until zero. The step changes and when your current value is equal to the end value and your direction is decreasing you are one element from the finish line. ``` (define (high-low n) (let loop ((cur 0) (limit n) (step add1) (acc '())) (cond ((not (= cur limit)) ; general step in either direction (loop (step cur) limit step (cons cur acc))) ((eq? step add1) ; turn (loop cur 0 sub1 acc)) (else ; finished (cons cur acc))))) ``` I guess there are numerous ways to skin this cat and this is just one tail recursive one.
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
Since you want to learn, I guess you don't want to use a lot of utility functions, so I will help with your `high`. Notice that there are two things when you want to construct the list: the starting number and the ending number. For `low`, it's easy because the ending number is a literal 0, while the starting number changes, so you can keep track by using only one variable. For `high`, the starting number needs to be changed in every iteration like in `low`. However, the ending number is not a literal (though it is constant), so we will need its information. Therefore, we will add the ending number as one of the arguments of the function. That is, we expect ``` (high 1 10) ; evaluates to (list 1 2 3 4 5 6 7 8 9 10) ``` The body then would be: ``` (define high (位 (start stop) ...)) ``` The terminating condition is when `start` goes beyond `stop`. This is the base case where the answer is `'()`. ``` (define high (位 (start stop) (cond [(> start stop) '()] ...))) ``` Otherwise, `start` is less than or equal to `stop`. The answer, a list starting from `start` and ends at `stop`, is the same as `start` attaching to the front of a list starting from `(add1 start)` and ends at `stop`. That is: ``` high start stop = [start start+1 start+2 ... stop] = [start] + [start+1 start+2 start+3 ... stop] = [start] + high start+1 stop ``` Thus: ``` (define high (位 (start stop) (cond [(> start stop) '()] [else (cons start (high (add1 start) stop))]))) ```
Here are a couple more options. Using `named let` and `quasi-quote`... ``` (define (high-low n) (let hi-lo ((i 0)) (if (= i n) `(,i) `(,i ,@(hi-lo (+ i 1)) ,i)))) ``` ...another option using `do`: ``` (define (high-low2 n) (do ((i (- n) (+ i 1)) (out '() (cons (- n (abs i)) out))) ((> i n) out))) ```
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
Since you want to learn, I guess you don't want to use a lot of utility functions, so I will help with your `high`. Notice that there are two things when you want to construct the list: the starting number and the ending number. For `low`, it's easy because the ending number is a literal 0, while the starting number changes, so you can keep track by using only one variable. For `high`, the starting number needs to be changed in every iteration like in `low`. However, the ending number is not a literal (though it is constant), so we will need its information. Therefore, we will add the ending number as one of the arguments of the function. That is, we expect ``` (high 1 10) ; evaluates to (list 1 2 3 4 5 6 7 8 9 10) ``` The body then would be: ``` (define high (位 (start stop) ...)) ``` The terminating condition is when `start` goes beyond `stop`. This is the base case where the answer is `'()`. ``` (define high (位 (start stop) (cond [(> start stop) '()] ...))) ``` Otherwise, `start` is less than or equal to `stop`. The answer, a list starting from `start` and ends at `stop`, is the same as `start` attaching to the front of a list starting from `(add1 start)` and ends at `stop`. That is: ``` high start stop = [start start+1 start+2 ... stop] = [start] + [start+1 start+2 start+3 ... stop] = [start] + high start+1 stop ``` Thus: ``` (define high (位 (start stop) (cond [(> start stop) '()] [else (cons start (high (add1 start) stop))]))) ```
Here is a rather over-general solution, built on a function which builds lists in a rather general way. It has the advantage of being tail-recursive: it will build arbitrarily long lists without exploding, but the disadvantages of needing to build them backwards and of being somewhat obscure to understand. Here is the function: ```lisp (define (lister base inc stop cont) ;; start with a (non-empty) list, base; ;; cons more elements of the form (inc (first ...)) to it; ;; until (stop (first ...)) is true; ;; finally call cont with the resulting list (define (lister-loop accum) (if (stop (first accum)) (cont accum) (lister-loop (cons (inc (first accum)) accum)))) (lister-loop base)) ``` (Note this could obviously use named-let for the inner function.) And here is a function using this function, twice, to count up and down. ```lisp (define (cud n) ;; count up and down (lister '(0) (位 (x) (+ x 1)) (位 (x) (= x n)) (位 (accum) (lister accum (位 (x) (- x 1)) zero? (位 (a) a))))) ``` And then: ``` > (cud 10) '(0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0) ``` --- Note that this was written using Racket: I think that is is pretty portable Scheme except that I have called `lambda` `位` and perhaps Scheme does not have `first` and so on.
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
`#!racket` (aka `#lang racket`) has a `range` procedure so if you have the power of racket at your hands you can just do: ``` (define (high-low n) (append (range n) ; 0 to n-1 (range n -1 -1))) ; n to 0 ``` If you want to roll your own recursive loop you can think of it as building a list in reverse starting at zero increasing by one until a limit, then decreasing until zero. The step changes and when your current value is equal to the end value and your direction is decreasing you are one element from the finish line. ``` (define (high-low n) (let loop ((cur 0) (limit n) (step add1) (acc '())) (cond ((not (= cur limit)) ; general step in either direction (loop (step cur) limit step (cons cur acc))) ((eq? step add1) ; turn (loop cur 0 sub1 acc)) (else ; finished (cons cur acc))))) ``` I guess there are numerous ways to skin this cat and this is just one tail recursive one.
Here are a couple more options. Using `named let` and `quasi-quote`... ``` (define (high-low n) (let hi-lo ((i 0)) (if (= i n) `(,i) `(,i ,@(hi-lo (+ i 1)) ,i)))) ``` ...another option using `do`: ``` (define (high-low2 n) (do ((i (- n) (+ i 1)) (out '() (cons (- n (abs i)) out))) ((> i n) out))) ```
37,220,607
I'm not sure what the best way to phrase this is, so I'm just going to show an example. (high-low 4) -> (0 1 2 3 4 3 2 1 0) (high-low 0) -> (0) ``` (define low (位 (a) (cond [(zero? a) '()] [else (cons (sub1 a) (low (sub1 a)))]))) ``` I think that the best way to do this is to break it up into 2 separate functions and call them in the main function. The code above is the second part of the function but I'm struggling to define the high part of it (0-a) Any help is welcome (This is not homework, I'm just interested in learning how Scheme works).
2016/05/13
[ "https://Stackoverflow.com/questions/37220607", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6264061/" ]
`#!racket` (aka `#lang racket`) has a `range` procedure so if you have the power of racket at your hands you can just do: ``` (define (high-low n) (append (range n) ; 0 to n-1 (range n -1 -1))) ; n to 0 ``` If you want to roll your own recursive loop you can think of it as building a list in reverse starting at zero increasing by one until a limit, then decreasing until zero. The step changes and when your current value is equal to the end value and your direction is decreasing you are one element from the finish line. ``` (define (high-low n) (let loop ((cur 0) (limit n) (step add1) (acc '())) (cond ((not (= cur limit)) ; general step in either direction (loop (step cur) limit step (cons cur acc))) ((eq? step add1) ; turn (loop cur 0 sub1 acc)) (else ; finished (cons cur acc))))) ``` I guess there are numerous ways to skin this cat and this is just one tail recursive one.
Here is a rather over-general solution, built on a function which builds lists in a rather general way. It has the advantage of being tail-recursive: it will build arbitrarily long lists without exploding, but the disadvantages of needing to build them backwards and of being somewhat obscure to understand. Here is the function: ```lisp (define (lister base inc stop cont) ;; start with a (non-empty) list, base; ;; cons more elements of the form (inc (first ...)) to it; ;; until (stop (first ...)) is true; ;; finally call cont with the resulting list (define (lister-loop accum) (if (stop (first accum)) (cont accum) (lister-loop (cons (inc (first accum)) accum)))) (lister-loop base)) ``` (Note this could obviously use named-let for the inner function.) And here is a function using this function, twice, to count up and down. ```lisp (define (cud n) ;; count up and down (lister '(0) (位 (x) (+ x 1)) (位 (x) (= x n)) (位 (accum) (lister accum (位 (x) (- x 1)) zero? (位 (a) a))))) ``` And then: ``` > (cud 10) '(0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0) ``` --- Note that this was written using Racket: I think that is is pretty portable Scheme except that I have called `lambda` `位` and perhaps Scheme does not have `first` and so on.
9,468
Can anyone identify these bricks, which I suspect are LEGO clones. They may be more than 30 years old. I bought them on ebay as Betta Bilda from LEGO/Duplo dealer. Some BB was included, but these are unknown to me, with an extensive BB collection. [![Mystery bricks 1](https://i.stack.imgur.com/1xSNi.jpg)](https://i.stack.imgur.com/1xSNi.jpg) [![Mystery bricks 4](https://i.stack.imgur.com/9pO9E.jpg)](https://i.stack.imgur.com/9pO9E.jpg) The underside of the bricks is hollow and with apparently random numbers - they aren't part numbers because they are different for the same part and sometimes the same for different parts. Window frames have no top studs. [![Mystery bricks 7](https://i.stack.imgur.com/MLvsa.jpg)](https://i.stack.imgur.com/MLvsa.jpg) [![Mystery bricks 8](https://i.stack.imgur.com/QmrFC.jpg)](https://i.stack.imgur.com/QmrFC.jpg) [![Mystery bricks 13](https://i.stack.imgur.com/tceIf.jpg)](https://i.stack.imgur.com/tceIf.jpg) I took a good look through many posts with similar questions, but found nothing that matched. Many Google reverse images searches kept pointing at real LEGO/Duplo, before I noticed this place. Usually I can identify unknowns like this, but these are a real challenge. Edit (Nov 29, 2019) =================== Some comments have asked for clarity on size of these bricks. The majority are close to if not identical to 8 stud LEGO, although there are also 2 and 4 stud bricks too. They clip to Betta Bilda pieces, in a similar way to authentic LEGO. The window frames appear to be confirmed by two comments as 1950-60 LEGO, but additional insight would still be appreciated.
2017/12/05
[ "https://bricks.stackexchange.com/questions/9468", "https://bricks.stackexchange.com", "https://bricks.stackexchange.com/users/9622/" ]
From the LEGO Wikipedia Page "1961 and 1962 saw the introduction of the first Lego wheels, an addition that expanded the potential for building cars, trucks, buses and other vehicles from Lego bricks. Also during this time, the Lego Group introduced toys specifically targeted towards the pre-school market." here is a picture of these first-ever Duplo bricks from the 60's[![enter image description here](https://i.stack.imgur.com/d44N4.jpg)](https://i.stack.imgur.com/d44N4.jpg) look similar?
I don鈥檛 exactly know if it is LEGO, But it may be an old version of LEGO. The numbers also could be the date the were made or a factory code.