qid
int64
1
74.7M
question
stringlengths
15
55.4k
date
stringlengths
10
10
metadata
sequencelengths
3
3
response_j
stringlengths
2
32.4k
response_k
stringlengths
9
40.5k
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’t 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.
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't think they are LEGO due to the holes in the middle of the studs. LEGO pieces also say "LEGO" somewhere on them, so I bet that they are a 3rd party brand.
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/" ]
As suggested by @mindstormsboi I contacted LEGO customer services and sent them a link to this question as well as many additional photos. The information was passed to their expert team and the answer that came back was "they believe that these are not LEGO® parts". They were not able to identify them as a known clone type. I feel obliged to accept that as a definite answer, although it leaves unknown who actually manufactured the bricks I have. I will continue research into that question, but elsewhere. The customer service team member also gave me two interesting links to a fan created website with some of the history of LEGO parts, as well as section covering many of the clones and similar brick building sets. I include the two links below, as they may be of interest to some who find this question and answer. <https://www.inverso.pt/legos/> <https://www.inverso.pt/legos/clones/texts/mobitec.htm> Thank you to all who contributed their knowledge, experience or point of view.
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?
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/" ]
As suggested by @mindstormsboi I contacted LEGO customer services and sent them a link to this question as well as many additional photos. The information was passed to their expert team and the answer that came back was "they believe that these are not LEGO® parts". They were not able to identify them as a known clone type. I feel obliged to accept that as a definite answer, although it leaves unknown who actually manufactured the bricks I have. I will continue research into that question, but elsewhere. The customer service team member also gave me two interesting links to a fan created website with some of the history of LEGO parts, as well as section covering many of the clones and similar brick building sets. I include the two links below, as they may be of interest to some who find this question and answer. <https://www.inverso.pt/legos/> <https://www.inverso.pt/legos/clones/texts/mobitec.htm> Thank you to all who contributed their knowledge, experience or point of view.
I don’t 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.
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/" ]
As suggested by @mindstormsboi I contacted LEGO customer services and sent them a link to this question as well as many additional photos. The information was passed to their expert team and the answer that came back was "they believe that these are not LEGO® parts". They were not able to identify them as a known clone type. I feel obliged to accept that as a definite answer, although it leaves unknown who actually manufactured the bricks I have. I will continue research into that question, but elsewhere. The customer service team member also gave me two interesting links to a fan created website with some of the history of LEGO parts, as well as section covering many of the clones and similar brick building sets. I include the two links below, as they may be of interest to some who find this question and answer. <https://www.inverso.pt/legos/> <https://www.inverso.pt/legos/clones/texts/mobitec.htm> Thank you to all who contributed their knowledge, experience or point of view.
I don't think they are LEGO due to the holes in the middle of the studs. LEGO pieces also say "LEGO" somewhere on them, so I bet that they are a 3rd party brand.
54,813,381
I would like to remove all non-alphanumeric characters except brackets and what's between them in python. For example : ``` My son's birthday [[David | David Smith]] $$ (is) "today" 2019 ][ ``` become ``` My son s birthday [[David | David Smith]] is today 2019 ``` Here's my function for now : ``` def clean(texte): return re.sub(r"[^0-9a-zA-Z]+", " ", texte).lower() ``` It replace all non-alphanumeric like I want but it replace the square brackets and the pipe inside. I don't know how to add new regex in the sub method and adding a new condition.
2019/02/21
[ "https://Stackoverflow.com/questions/54813381", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7402246/" ]
Instead of replacing you might select what you want to keep using an [alternation](https://www.regular-expressions.info/alternation.html) to either match from `[[` till `]]` or `|` match 1+ times a word character `\w+` and then join the parts back to a string. ``` \[\[[^]]+\]\]|\w+ ``` That will match * `\[\[[^]]+\]\]` match from `[[` till `]]` using a negated character class * `|` Or * `\w+` Match 1+ times a word character [Regex demo](https://regex101.com/r/UeJh7n/1) | [Python demo](https://ideone.com/FykbLA) For example: ``` import re regex = r"\[\[[^]]+\]\]|\w+" test_str = "My son's birthday [[David | David Smith]] $$ (is) \"today\" 2019 ][" res = re.findall(regex, test_str) print(' '.join(res)) # My son s birthday [[David | David Smith]] is today 2019 ```
``` import re x = "My son's birthday [[David | David Smith]] $$ (is) \"today\" 2019 ][" def clean(texte): return re.sub(r"[^\[\[[^\]\]+\]\]|\w]+", " ", texte).lower() print(clean(x)) >>> 'my son s birthday [[david | david smith]] is today 2019 ][' ``` Then you could do a split of "]" and keep the first index.
61,451,684
I am working on a slider carousel with bootstrap. My 'active' image loads, but the controls and the slide don't work. As I am following a tutorial, I thought this would be an easy exercise for practice, but I've hit a snag. For anyone concerned about the boostrap.css link I posted the entire html doc ... but its functionality is working well otherwise, so I don't believe that is the issue here. ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" name="" content="Trey's Personal Website."> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Trey Coggins | Personal Website</title> <script type="text/javascript" src="script/index.js"></script> <link rel="stylesheet" type="text/css" href="styles/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="styles/index-style.css"> </head> <body> <header> <nav class="navbar navbar-expand-md navbar-dark bg-dark"> <a class="navbar-brand" href="">Trey Coggins</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse"> <span class="navbar-toggler-icon"></span></button> <div class="collapse navbar-collapse" id="navbarCollapse"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="">About</a> </li> <li class="nav-item"> <a class="nav-link" href="">Contact</a> </li> </ul> </div> </nav> <div id="carouselControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <img class="d-block w-100" src="img/bricks.jpg" alt=""> <div class="carousel-caption"> <h2>Let's build something together!</h2> </div> </div> <div class="carousel-item"> <img class="d-block w-100" src="img/woods.jpg" alt=""> <div class="carousel-caption"> <h2>Take a walk in the woods</h2> </div> </div> <div class="carousel-item"> <img class="d-block w-100" src="img/stone.jpg" alt=""> <div class="carousel-caption"> <h2>Elevate yourself to the next level</h2> </div> </div> </div> <a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </header> <div class="container text-center"> <div class="row"> <div class="col-md-4"> <img class="rounded-circle" src="img/trey-court-headshot.jpg" alt="Trey & Courtney"> <h2>Trey & Courtney</h2> <p>She's the love of my life!</p> <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p> </div> <div class="col-md-4"> <img class="rounded-circle" src="img/tootsie-smile.jpg" alt="Mama Tootsie"> <h2>Bodhi & Tootsie</h2> <p>These two keep us young!</p> <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p> </div> <div class="col-md-4"> <img class="rounded-circle" src="img/royal-hearts.jpg" alt="Royal Flush"> <h2>Poker</h2> <p>Join the action!</p> <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p> </div> </div> </div> </body> </html> ```
2020/04/27
[ "https://Stackoverflow.com/questions/61451684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You have to return the map of logos which is not happening in your current code. Hence you are getting only one Logos component. ``` import React from 'react'; import { home } from '../homeObj'; const Logos = ({ title, img, img2, img3, key }) => { return ( <> <div className={styles.anaShif} key={key}> <h2 className={styles.h2}> {title} </h2> <div className={styles.logos}> <img id={img.id} src={img} alt={img.alt} className={styles.img} srcSet={`${img2} 2x, ${img3} 3x`} /> </div> </div> </> ); }; function Trusted() { const logosIndex = home.findIndex((obj) => obj.id === 'logos'); const logos = home[logosIndex].logos.map(({ id, alt, src }) => { return <Logos key={id} id={id} title={home[logosIndex].title} img={src} />; }); return logos; } export default Trusted; ```
You not only need to map over `home` but also the `logos` array with-in each `home` object. Also in your case, you don't need the third arg which is the entire array. **Simplify your code like this:** ```js home.map((_objects, i) => { if (_objects.id === "logos") { return ( <> { _objects.logos.map(logo => ( <Logos key={logo.id} id={logo.id} title={logo.title} img={logo.src} /> )) } </> ); }else { return null } } ```
61,451,684
I am working on a slider carousel with bootstrap. My 'active' image loads, but the controls and the slide don't work. As I am following a tutorial, I thought this would be an easy exercise for practice, but I've hit a snag. For anyone concerned about the boostrap.css link I posted the entire html doc ... but its functionality is working well otherwise, so I don't believe that is the issue here. ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" name="" content="Trey's Personal Website."> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Trey Coggins | Personal Website</title> <script type="text/javascript" src="script/index.js"></script> <link rel="stylesheet" type="text/css" href="styles/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="styles/index-style.css"> </head> <body> <header> <nav class="navbar navbar-expand-md navbar-dark bg-dark"> <a class="navbar-brand" href="">Trey Coggins</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse"> <span class="navbar-toggler-icon"></span></button> <div class="collapse navbar-collapse" id="navbarCollapse"> <ul class="navbar-nav"> <li class="nav-item"> <a class="nav-link" href="">Home</a> </li> <li class="nav-item"> <a class="nav-link" href="">About</a> </li> <li class="nav-item"> <a class="nav-link" href="">Contact</a> </li> </ul> </div> </nav> <div id="carouselControls" class="carousel slide" data-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <img class="d-block w-100" src="img/bricks.jpg" alt=""> <div class="carousel-caption"> <h2>Let's build something together!</h2> </div> </div> <div class="carousel-item"> <img class="d-block w-100" src="img/woods.jpg" alt=""> <div class="carousel-caption"> <h2>Take a walk in the woods</h2> </div> </div> <div class="carousel-item"> <img class="d-block w-100" src="img/stone.jpg" alt=""> <div class="carousel-caption"> <h2>Elevate yourself to the next level</h2> </div> </div> </div> <a class="carousel-control-prev" href="#carouselControls" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#carouselControls" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </header> <div class="container text-center"> <div class="row"> <div class="col-md-4"> <img class="rounded-circle" src="img/trey-court-headshot.jpg" alt="Trey & Courtney"> <h2>Trey & Courtney</h2> <p>She's the love of my life!</p> <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p> </div> <div class="col-md-4"> <img class="rounded-circle" src="img/tootsie-smile.jpg" alt="Mama Tootsie"> <h2>Bodhi & Tootsie</h2> <p>These two keep us young!</p> <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p> </div> <div class="col-md-4"> <img class="rounded-circle" src="img/royal-hearts.jpg" alt="Royal Flush"> <h2>Poker</h2> <p>Join the action!</p> <p><a class="btn btn-secondary" href="#" role="button">See more &raquo;</a></p> </div> </div> </div> </body> </html> ```
2020/04/27
[ "https://Stackoverflow.com/questions/61451684", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
You have to return the map of logos which is not happening in your current code. Hence you are getting only one Logos component. ``` import React from 'react'; import { home } from '../homeObj'; const Logos = ({ title, img, img2, img3, key }) => { return ( <> <div className={styles.anaShif} key={key}> <h2 className={styles.h2}> {title} </h2> <div className={styles.logos}> <img id={img.id} src={img} alt={img.alt} className={styles.img} srcSet={`${img2} 2x, ${img3} 3x`} /> </div> </div> </> ); }; function Trusted() { const logosIndex = home.findIndex((obj) => obj.id === 'logos'); const logos = home[logosIndex].logos.map(({ id, alt, src }) => { return <Logos key={id} id={id} title={home[logosIndex].title} img={src} />; }); return logos; } export default Trusted; ```
Without much if else, you can also write like this. ```js home.filter((_objects, i) => _objects.id === 'logos') .map(({logos})=>logos.map(logo=> <Logos key={logo.id} {...logo} />)) ```
381,875
WordPress end points default rules, ``` GET ----> PUBLIC POST, PUT, DELETE ----> AUTH ``` How can I force authentication the WordPress REST API `GET` method requests?
2021/01/21
[ "https://wordpress.stackexchange.com/questions/381875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/198965/" ]
You can't really apply authentication based directly on whether the request is GET or otherwise, but can forcefully apply authentication requirements globally in that manner, if you like. I've been quite verbose with the code to illustrate what's happening: ```php add_filter( 'rest_authentication_errors', function ( $error ) { /** * If it's a WP_Error, leave it as is. Authentication failed anyway * * If it's true, then authentication has already succeeded. Leave it as-is. */ if ( strtolower( $_SERVER[ 'REQUEST_METHOD' ] ) === 'get' && !is_wp_error( $error ) && $error !== true ) { if ( !is_user_logged_in() ) { $error = new \WP_Error( 'User not logged-in' ); } } return $error; }, 11 ); ``` Assumptions: * PHP is at least version 5.3 * We're only testing `GET` requests * If an authentication error has been met before this filter is executed, then we leave the error as-is. * If there is no error, and in-fact it's set to `true`, then this means authentication has already succeeded and there's not need to block anything. * We're only testing whether or not the user making the request is logged-in i.e. is authenticated with WordPress.
Good Question and not that easy to do propperly (took me 1 week to figure that out). Then I found 2 good summaries in WordPress docs: [Home / REST API Handbook / Extending the REST API / Routes and Endpoints](https://developer.wordpress.org/rest-api/extending-the-rest-api/routes-and-endpoints/) [Home / REST API Handbook / Extending the REST API / Adding Custom Endpoints](https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/) There I found out how to use **namespaces**, **routes** and **permission\_callback** correctly. Critical part was to add the **Permission Callback** into the `function.php` of your theme. ```php /** * This is our callback function to return (GET) our data. * * @param WP_REST_Request $request This function accepts a rest request to process data. */ function get_your_data($request) { global $wpdb; $yourdata = $wpdb->get_results("SELECT * FROM your_custom_table"); return rest_ensure_response( $yourdata ); }; /** * This is our callback function to insert (POST) new data record. * * @param WP_REST_Request $request This function accepts a rest request to process data. */ function insert_your_data($request) { global $wpdb; $contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : ''; if ($contentType === "application/json") { $content = trim(file_get_contents("php://input")); $decoded = json_decode($content, true); $newrecord = $wpdb->insert( 'your_custom_table', array( 'column_1' => $decoded['column_1'], 'column_2' => $decoded['column_2'])); }; if($newrecord){ return rest_ensure_response($newrecord); }else{ //something gone wrong return rest_ensure_response('failed'); }; header("Content-Type: application/json; charset=UTF-8"); }; /** * This is our callback function to update (PUT) a data record. * * @param WP_REST_Request $request This function accepts a rest request to process data. */ function update_your_data($request) { global $wpdb; $contentType = isset($_SERVER["CONTENT_TYPE"]) ? trim($_SERVER["CONTENT_TYPE"]) : ''; if ($contentType === "application/json") { $content = trim(file_get_contents("php://input")); $decoded = json_decode($content, true); $updatedrecord = $wpdb->update( 'your_custom_table', array( 'column_1' => $decoded['column_1'], 'column_2' => $decoded['column_2']), array('id' => $decoded['id']), array( '%s' )); }; if($updatedrecord){ return rest_ensure_response($updatedrecord); }else{ //something gone wrong return rest_ensure_response('failed'); }; header("Content-Type: application/json; charset=UTF-8"); }; // Permission Callback // 'ypp' is the Prefix I chose (ypp = Your Private Page) function ypp_get_private_data_permissions_check() { // Restrict endpoint to browsers that have the wp-postpass_ cookie. if ( !isset($_COOKIE['wp-postpass_'. COOKIEHASH] )) { return new WP_Error( 'rest_forbidden', esc_html__( 'OMG you can not create or edit private data.', 'my-text-domain' ), array( 'status' => 401 ) ); }; // This is a black-listing approach. You could alternatively do this via white-listing, by returning false here and changing the permissions check. return true; }; // And then add the permission_callback to your POST and PUT routes: add_action('rest_api_init', function() { /** * Register here your custom routes for your CRUD functions */ register_rest_route( 'your_private_page/v1', '/data', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => 'get_your_data', // Always allow. 'permission_callback' => '__return_true' // <-- you can protect GET as well if your like ), array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => 'insert_your_data', // Here we register our permissions callback. The callback is fired before the main callback to check if the current user can access the endpoint. 'permission_callback' => 'ypp_get_private_data_permissions_check', // <-- that was the missing part ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => 'update_your_data', // Here we register our permissions callback. The callback is fired before the main callback to check if the current user can access the endpoint. 'permission_callback' => 'ypp_get_private_data_permissions_check', // <-- that was the missing part ), )); }); ``` If you like, I posted a Question (similar issue to yours, but for custom routes) and then my findings in the answer. **Full story** with complete code at: [How to force Authentication on REST API for Password protected page using custom table and fetch() without Plugin](https://wordpress.stackexchange.com/questions/391515/how-to-force-authentication-on-rest-api-for-password-protected-page-using-custom/391516#391516) Hope this helps a little.
38,401
Towards the end, when Ripley finally ... > > blows it out of the damned airlock! > > > She mutters a little song that seems to go ``` .... you .... are ... (my) ... lucky ..... star .... .... lucky-lucky-lucky .... ``` or something. What is that song?
2013/07/22
[ "https://scifi.stackexchange.com/questions/38401", "https://scifi.stackexchange.com", "https://scifi.stackexchange.com/users/3007/" ]
I think this is it: *You are my lucky star* from Broadway Melody, 1936. Easier to follow the lyrics in this earlier recording: And this version actually has the oft-omitted "Verse":
Debbie Reynolds - You Are My Lucky Star. I very much believe it's from the film "Singing in the Rain", Hollywood, from just after WW2. Ripley repeats it, as one would do, to concentrate on the job at hand rather than have her mind freeze or frazzle from the terror implicit in her situation. Lovely refrain and obviously someone believes it'll stand the test of time.
72,351,446
I can not figure out my mistake. Can someone help me? We are supposed to create the lists outside of the function. then create an empty list inside a function. We should return 9 different names. ``` first_names = ["Gabriel", "Reinhard", "Siebren"] last_names = ["Colomar", "Chase", "Vaswani"] def name_generator(first_names, last_names): full_name= () import random for _ in range(9): full_name=random.choice(first_names)+" "+random.choice(last_names) full_name.append(full_name) group_string = ", ".join(full_name) ```
2022/05/23
[ "https://Stackoverflow.com/questions/72351446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19114904/" ]
The problem is that you're using a variable `full_name` twice: once as a string to store a new name in, and once as the list. This is closer to what you want: ``` import random first_names = ["Gabriel", "Reinhard", "Siebren"] last_names = ["Colomar", "Chase", "Vaswani"] full_names = [] for _ in range(9): new_name=random.choice(first_names)+" "+random.choice(last_names) full_names.append(new_name) group_string = ", ".join(full_names) ``` I'll note that I'd probably use `full_names` as plural version of the variable name too since it's a list of multiple things.
This makes a list of all possible full names and then picks from what hasn't been taken yet one by one. ``` remaining = [(a,b) for a in range(len(first_names)) for b in range(len(last_names))] full_name = [] while len(remaining)>0: (a,b) = random.choice(remaining) full_name.append(first_names[a] + " " + last_names[b]) remaining.remove((a,b)) ```
70,676,777
This useEffect is rendering one time if dependency array is empty but multiple times if i put folderRef in dependency array. I want to render the component only when I add or delete some folder. Please Help ``` import React, { useState, useEffect , useRef } from "react"; import { db } from "../firebase"; import { collection, getDocs } from "firebase/firestore"; import FolderData from "./FolderData"; function ShowFolder(props) { const [folders, setFolders] = useState([]); const folderRef = useRef(collection(db, "folders")); useEffect(() => { const getData = async () => { const data = await getDocs(folderRef.current); const folderData = data.docs.map((doc) => { return { id: doc.id, data: doc.data() }; }); console.log(folderData); setFolders(folderData); }; getData(); }, [folderRef]); return ( <div className="container md:px-4 mx-auto py-10"> <div className="md:grid lg:grid-cols-6 md:grid-cols-3 mlg:grid-cols-3 md:gap-10 space-y-6 md:space-y-0 px-1 md:px-0 mx-auto"> {folders.map((folder) => { return ( <div key={folder.id}> {folder.data.userId === props.userId && ( <div> <FolderData key={folder.id} folder={folder} /> </div> )} </div> ); })} </div> </div> ); } export default ShowFolder; ```
2022/01/12
[ "https://Stackoverflow.com/questions/70676777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17878146/" ]
You redeclare `folderRef` each render cycle, so if you include it in the `useEffect` hook's dependency array it will trigger render looping. If you don't refer to `folderRef` anywhere else in the component then move it *into* the `useEffect` hook callback to remove it as an external dependnecy. ``` const [folders, setFolders] = useState([]); useEffect(() => { const folderRef = collection(db, "folders"); const getData = async () => { const data = await getDocs(folderRef); const folderData = data.docs.map((doc) => { return { id: doc.id, data: doc.data() }; }); console.log(folderData); setFolders(folderData); }; getData(); }, []); ``` Or store it in a React ref so it can be safely referred to as a stable reference. ``` const [folders, setFolders] = useState([]); const folderRef = useRef(collection(db, "folders")); useEffect(() => { const getData = async () => { const data = await getDocs(folderRef.current); const folderData = data.docs.map((doc) => { return { id: doc.id, data: doc.data() }; }); console.log(folderData); setFolders(folderData); }; getData(); }, [folderRef]); ``` ### Update I've gathered that you are updating the `folders` collection elsewhere in your app and want this component to "listen" for these changes. For this you can implement an `onSnapshot` listener. It may look similar to the following: ``` const [folders, setFolders] = useState([]); useEffect(() => { const unsubscribe = onSnapshot( collection(db, "folders"), (snapshot) => { const folderData = []; snapshot.forEach((doc) => { folderData.push({ id: doc.id, data: doc.data(), }); }); setFolders(folderData); }, ); // Return cleanup function to stop listening to changes // on component unmount return unsubscribe; }, []); ```
I think most Probably your useState function is like ``` const[folderRef , setFolders]=useState(Your Initial Value); ``` if this is the case then when ever you perform ``` useEffect(() => { setFolder(Setting Anything Here) .... },[folderRef]) ``` React starts an infinity loop coz every time you use setFolder the FolderRef gets updated and the useEffect is forced to run again and it won't Stop . use something like ``` const[folderRef , setFolders]=useState(Your Initial Value); const[isLoading, setIsLoading]=useState(true); useEffect(() => { setFolder(Setting Anything Here) setIsLoading(false) .... },[]) ... return ( { isLoading ? "Run the code you wanna run " : null } ) ```
62,747,664
Good day, I'm currently experiencing a weird phenomena, this morning as I open the dbgview application an error message popped out(kernel related), couldn't remember much about the details. Although the dbgview was showing at the task bar but as I clicked on it, it will jump out to no where. It was as if I have 2nd monitor and it jump out to other screen. * I checked with 2nd monitor and it was not there.. I tried to install the latest version. System recovery back to few days before which was still in working condition. But it doesn't help. Hope someone here could show me some clue. 07/07/2020 I discovered it might not related to debugview this app. As I opened up task bar and select the debugview application and maximize the window size it is showing up. However as long as I click restore button at the right top corner of the app it flew out to the universe again.... Thank you
2020/07/06
[ "https://Stackoverflow.com/questions/62747664", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4608323/" ]
DbgView remembers its last position, so what likely happened is that you disconnected a monitor while DbgView was running on it, or maybe you accidentally dragged DbgView offscreen, and now it opens in a position that's no longer visible. Try either of the following. * With DbgView running, `Alt-TAB` to it then press `Alt-Space`, `M` (which opens the system menu and selects Move). While the "move" cursor is showing, use the arrow keys to bring the window back onto the active screen. * With DbgView closed, run `regedit`, navigate to `HKCU\Software\Sysinternals\DbgView` and delete (or rename) the `Settings` value, then run DbgView again. Since it no longer finds the old saved position in the registry, it will now open in the default position on the active monitor.
Try this: * start dbgview * hold the left 'Windows key' * while still holding the windo
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
You can simply generate the divisor and quotient randomly and then compute the dividend. Note that the divisor must be nonzero (thanks to @o11c's remind).
I think that @Vira has the right idea. If you want to generate `a` and `b` such that `a = b * q + r` with `r=0`, the good way to do it is : 1. Generate `b` randomly 2. Generate `q` randomly 3. Compute `a = b * q` 4. Ask to compute the division : `a` divided by `b`. The answer is `q`.
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
1) Take any non-zero randomized Divisor (x). // say 5 2) Take any randomized temporary Dividend (D). // say 24 3) Calculate R = D % x; // => 4 4) return Dividend as (D -x ) // return 20 Now, your dividend will always be perfectly divisible by the divisor.
I think that @Vira has the right idea. If you want to generate `a` and `b` such that `a = b * q + r` with `r=0`, the good way to do it is : 1. Generate `b` randomly 2. Generate `q` randomly 3. Compute `a = b * q` 4. Ask to compute the division : `a` divided by `b`. The answer is `q`.
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
I think that @Vira has the right idea. If you want to generate `a` and `b` such that `a = b * q + r` with `r=0`, the good way to do it is : 1. Generate `b` randomly 2. Generate `q` randomly 3. Compute `a = b * q` 4. Ask to compute the division : `a` divided by `b`. The answer is `q`.
you can generate a number to be divided as [random number1]x[random number2] . The problem will then be [random number1]x[random number2] divide by [random number1]
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
x/y = z y\*z = x Generate y and z as integers, then calculate x.
you can generate a number to be divided as [random number1]x[random number2] . The problem will then be [random number1]x[random number2] divide by [random number1]
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
I think that @Vira has the right idea. If you want to generate `a` and `b` such that `a = b * q + r` with `r=0`, the good way to do it is : 1. Generate `b` randomly 2. Generate `q` randomly 3. Compute `a = b * q` 4. Ask to compute the division : `a` divided by `b`. The answer is `q`.
GZ0 has offered a great solution, one that is likely the most elegant. As an alternative, you could use the modulo operator, %. ``` if num1 % num2 == 0: return num1, num2 ``` You can use that to generate a list of a hundred or a thousand pairs to use in your program.
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
x/y = z y\*z = x Generate y and z as integers, then calculate x.
1) Take any non-zero randomized Divisor (x). // say 5 2) Take any randomized temporary Dividend (D). // say 24 3) Calculate R = D % x; // => 4 4) return Dividend as (D -x ) // return 20 Now, your dividend will always be perfectly divisible by the divisor.
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
x/y = z y\*z = x Generate y and z as integers, then calculate x.
I think that @Vira has the right idea. If you want to generate `a` and `b` such that `a = b * q + r` with `r=0`, the good way to do it is : 1. Generate `b` randomly 2. Generate `q` randomly 3. Compute `a = b * q` 4. Ask to compute the division : `a` divided by `b`. The answer is `q`.
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
1) Take any non-zero randomized Divisor (x). // say 5 2) Take any randomized temporary Dividend (D). // say 24 3) Calculate R = D % x; // => 4 4) return Dividend as (D -x ) // return 20 Now, your dividend will always be perfectly divisible by the divisor.
You can simply generate the divisor and quotient randomly and then compute the dividend. Note that the divisor must be nonzero (thanks to @o11c's remind).
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
1) Take any non-zero randomized Divisor (x). // say 5 2) Take any randomized temporary Dividend (D). // say 24 3) Calculate R = D % x; // => 4 4) return Dividend as (D -x ) // return 20 Now, your dividend will always be perfectly divisible by the divisor.
GZ0 has offered a great solution, one that is likely the most elegant. As an alternative, you could use the modulo operator, %. ``` if num1 % num2 == 0: return num1, num2 ``` You can use that to generate a list of a hundred or a thousand pairs to use in your program.
57,155,638
I have a line chart displayed on a webpage with chart.js but my time data is in UTC. I would like to convert it to the Denver timezone for display on the graph. Chart.js has a [luxon adapter](https://github.com/chartjs/chartjs-adapter-luxon) but I have no idea how to use it. I have included the following scripts: ``` <script src="./chart.js/dist/Chart.bundle.js"></script> <script src="https://cdn.jsdelivr.net/npm/luxon@1.15.0"></script> <script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-luxon@0.2.0"></script> ``` My time data formatted as a json string: ``` var data = [{"x":"2019-07-23 01:16:11","y":83.97},{"x":"2019-07-23 01:07:13","y":82.74},{"x":"2019-07-23 00:58:21","y":83.86}, ... ``` And here are my chart "Options": ```js options: { scales: { xAxes: [{ type: 'time', distribution: 'series', }] } } ``` So where and how do I implement a timezone definition? I have also looked through the [Luxon timezone documentation.](https://moment.github.io/luxon/docs/manual/tour.html#time-zones)
2019/07/23
[ "https://Stackoverflow.com/questions/57155638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11821892/" ]
You can simply generate the divisor and quotient randomly and then compute the dividend. Note that the divisor must be nonzero (thanks to @o11c's remind).
GZ0 has offered a great solution, one that is likely the most elegant. As an alternative, you could use the modulo operator, %. ``` if num1 % num2 == 0: return num1, num2 ``` You can use that to generate a list of a hundred or a thousand pairs to use in your program.
35,760,833
I have a question that's somewhat similar to the one asked here. [Creating Formula (Effective-Discontinue) Dates while using vlookup](https://stackoverflow.com/questions/28097250/creating-formula-effective-discontinue-dates-while-using-vlookup) Basically, I have two tables: 1. Historical sales data per item (with sales dates) 2. Items eligible for commission along with effective/discontinued dates What I need is some way to calculate commission per item into my first table based on the eligible commission items in the second table. The part of my question that differs from the link I provided is that any one of my sales items might have multiple effective/discontinued dates, meaning that item 12345 might be effective 1/1/2015-3/31/2015 and also 4/15/2015-current, so a sale of the item on 4/1/2015 would be ineligible for a commission, but sales on 3/1/2015 and 5/1/2015 would be eligible. Does anyone have suggestions on formulas I can use and ways to organize my data in table 2 to best facilitate what I'm trying to do? Thanks. Edit: Here are some tables with sample data. Table 1 (sales data): ``` InvoiceDate ItemCode QuantityShipped 1/1/2015 123456 100 2/1/2015 789456 100 3/1/2015 789456 300 4/1/2015 123456 200 5/1/2015 123456 300 ``` Table 2 (item eligibility data): ``` Item Code Effective Date Discontinued Date Commission Rate 123456 1/1/2015 3/1/2015 0.02 123456 4/15/2015 0.03 789456 3/1/2015 0.02 ```
2016/03/03
[ "https://Stackoverflow.com/questions/35760833", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6010576/" ]
Entered in E3 as an array formula (using Ctrl+Shift+Enter) I'm not great at this part of excel so I'm sure there are better approaches. [![enter image description here](https://i.stack.imgur.com/mvLa8.png)](https://i.stack.imgur.com/mvLa8.png) [![enter image description here](https://i.stack.imgur.com/S0pbz.png)](https://i.stack.imgur.com/S0pbz.png)
Try this index/match: ``` =IFERROR(INDEX($I$2:$I$4,MATCH(1,IF(($G$2:$G$4<=A2)*(IF($H$2:$H$4<>"",$H$2:$H$4,TODAY())>=A2)*($F$2:$F$4=B2),1,0),0)),0) ``` It is an array, so Confirm with Ctrl-Shift-Enter. [![enter image description here](https://i.stack.imgur.com/Y4Q1y.png)](https://i.stack.imgur.com/Y4Q1y.png) For table references: ``` =IFERROR(INDEX(Table1[Commission Rate],MATCH(1,IF((Table1[Effective Date]<=[@InvoiceDate])*(IF(Table1[Discontinued Date]<>"",Table1[Discontinued Date],TODAY())>=[@InvoiceDate])*(Table1[Item Code]=[@ItemCode]),1,0),0)),0) ``` Still an array formula so ***you must use Ctrl-Shift-Enter*** to confirm the formula instead of Enter when exiting edit mode. After pasting the formula in the formula bar and making the needed changes hit Ctrl-Shift-Enter. If done properly Excel will put `{}` around the formula. [![enter image description here](https://i.stack.imgur.com/qsoBM.png)](https://i.stack.imgur.com/qsoBM.png)
13,334,965
Is it possible to have an app running at aws EC2 and have it's database running at heroku's postgres? In case it is, what are the downsides I should consider? Since heroku is hosted at AWS, is there a way to know where is the location of the machine running my database? Hosting my app in the same region of the database would help to keep the performance? I would like to hear some opinions about this, I've been searching the topic without much success.
2012/11/11
[ "https://Stackoverflow.com/questions/13334965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/888149/" ]
You can determine the public-facing location of your Heroku DB at any given time with a `traceroute` ... but there's no guarantee that it'll stay at that location, or that there isn't any internal re-routing going on. You'd probably want to speak directly with Heroku support about ways to make sure your Heroku DB instances are local to your AWS application instances, as that certainly would benefit performance. See if you can find out which availability zone, or at least which major region, they run the DB in, and whether you can "pin" your database instance to a given region/zone. Amazon's RDS looks OK, but doesn't support PostgreSQL. Please keep nagging them to. I'd probably just run the DB on AWS if performance wasn't particularly important. Use a raid10 of provisioned IOPS EBS volumes on an EBS-optimized instance and you'll get kind-of-ok performance (but at a really big price); alternately, you can use non-crash-safe ssd-based instance store servers and rely on replication and backups to keep your data safe.
I dont have any experience on Heroku PostgreSQL. Generally of course you can run your own service on Amazon EC2 and use the managed database services of Heroku. Downsides might be * nobody guarantees, that Herouku exclusively uses AWS and you probably can't determine the physical Heroku service location within the cloud so you will have to deal with network latencies * in addition to your external traffic fees you'll have to pay for the database traffic unless you talk to a server in the same availability zone in the same region My suggestion ( without knowing any detail about the pros of Heroku ) Have a look at Amazon RDS if you don't want to run a database server on our own. <http://aws.amazon.com/de/rds/> I am operating around 70 server instances on AWS, both RDS and EC2 for more than a year now and I can't imagine any simpler way to keep your stuff running
794,391
I'm trying to solve the following congruence: $x^{17} \equiv 243 \pmod{257}$ I have worked out that the $\gcd(243,257)=1$ and that $243=3^5$ So $x^{17} \equiv 3^5 \pmod{257}$ and I don't really understand what to do next.
2014/05/14
[ "https://math.stackexchange.com/questions/794391", "https://math.stackexchange.com", "https://math.stackexchange.com/users/114091/" ]
Since $257$ is a prime number by Fermat's little theorem $a^{256}\equiv 1\mod 257\ \forall a, 257\not|a$ Now, let us find if there is a solution of the form $3^y$. If there is then the equation will become $$3^{17y-5}\equiv 1\mod 257\Rightarrow 256|17y-5$$ $y=181$ is a solution to this. So $x=3^{181}$ is one solution and all the solutions of the form $3^y$ can be obtained by solving the linear Diphontaine equation $$17y-256z=5$$. Now, if there are solutions of the form $3^ya$ where $a$ does not contain $3$ as a prime factor then the equation will read as $$a^{17}3^{17y-5}\equiv 1\mod 257$$ But I'm not sure how to solve this.
We have the following facts: $\gcd(3,257)=1,\,$ $\varphi(257)=256,\,$ and 3 is a primitive root mod 257. From the first two we know, see e.g. [When is $a^n \equiv a^{(n \;\bmod \; \varphi(m))} \pmod m$ valid](https://math.stackexchange.com/questions/565449/when-is-an-equiv-an-bmod-varphim-pmod-m-valid), $$3^n \equiv 3^{(n \;\bmod \; \varphi(257))} \equiv 3^{(n \;\bmod \; 256)} \pmod {257}$$ Make the Ansatz $x=3^y$, then $$x^{17}\equiv 3^5 \pmod {257} \iff 3^{17y-5}\equiv 1 \equiv 3^0 \pmod {257}$$ Now solve $17y-5\equiv 0 \pmod {256}\,$. The multiplicative inverse is $17^{-1} \equiv 241 \pmod {256}\,$ and $y=5\times 241 \equiv 181 \pmod {256}.\,$ Therefore a solution is$$x=3^y=3^{181} \equiv 28 \pmod {257}.$$ Now you can check that $28^{17} \equiv 243 \pmod {257}.$
794,391
I'm trying to solve the following congruence: $x^{17} \equiv 243 \pmod{257}$ I have worked out that the $\gcd(243,257)=1$ and that $243=3^5$ So $x^{17} \equiv 3^5 \pmod{257}$ and I don't really understand what to do next.
2014/05/14
[ "https://math.stackexchange.com/questions/794391", "https://math.stackexchange.com", "https://math.stackexchange.com/users/114091/" ]
We want to solve $x^{17} \equiv 3^5 \pmod{257}$. Raise both sides to the power $15$ to get $$x^{255} \equiv 3^{75} \pmod{257},$$ or equivalently $x^{-1} \equiv 3^{75} \pmod {257}$. Thus $x \equiv 3^{-75} \equiv 28 \pmod{257}$.
We have the following facts: $\gcd(3,257)=1,\,$ $\varphi(257)=256,\,$ and 3 is a primitive root mod 257. From the first two we know, see e.g. [When is $a^n \equiv a^{(n \;\bmod \; \varphi(m))} \pmod m$ valid](https://math.stackexchange.com/questions/565449/when-is-an-equiv-an-bmod-varphim-pmod-m-valid), $$3^n \equiv 3^{(n \;\bmod \; \varphi(257))} \equiv 3^{(n \;\bmod \; 256)} \pmod {257}$$ Make the Ansatz $x=3^y$, then $$x^{17}\equiv 3^5 \pmod {257} \iff 3^{17y-5}\equiv 1 \equiv 3^0 \pmod {257}$$ Now solve $17y-5\equiv 0 \pmod {256}\,$. The multiplicative inverse is $17^{-1} \equiv 241 \pmod {256}\,$ and $y=5\times 241 \equiv 181 \pmod {256}.\,$ Therefore a solution is$$x=3^y=3^{181} \equiv 28 \pmod {257}.$$ Now you can check that $28^{17} \equiv 243 \pmod {257}.$
32,964,802
Is it possible to use PHP `mail()` on localhost in 64-bit Win10? I use xampp to run localhost and tried to use this function, but it returns error `Socket Error #10060<EOL>Connection timed out`. I used this configuration on 32-bit Win and there was no problem, mails were sent without any errors. Any solutions?
2015/10/06
[ "https://Stackoverflow.com/questions/32964802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4628427/" ]
To send mail in gmail account ->In sendmail(inside wamp folder) folder open file “sendmail.ini” in notepad for editing Change the below line in this file *smtp\_server=smtp.gmail.com* //if u r using gmail id
``` a) Open the "php.ini". For XAMPP,it is located in C:\XAMPP\php\php.ini. Find out if you are using WAMP or LAMP server. Note : Make a backup of php.ini file b) Search [mail function] in the php.ini file. You can find like below. [mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = postmaster@localhost Change the localhost to the smtp server name of your ISP. No need to change the smtp_port. Leave it as 25. Change sendmail_from from postmaster@localhost to your domain email address which will be used as from address.. So for me, it will become like this. [mail function] ; For Win32 only. SMTP = smtp.example.com smtp_port = 25 ; For Win32 only. sendmail_from = info@example.com c) Restart the XAMPP or WAMP(apache server) so that changes will start working. d) Now try to send the mail using the mail() function , mail("example@example.com","Success","Great, Localhost Mail works"); ``` Mail will be sent to "example@example.com" from the localhost with Subject line "Success" and body "Great,Localhost Mail works"
34,523,247
Social Security numbers that I want to accept are: ``` xxx-xx-xxxx (ex. 123-45-6789) xxxxxxxxx (ex. 123456789) xxx xx xxxx (ex. 123 45 6789) ``` I am not a regex expert, but I wrote this (it's kind of ugly) ``` ^(\d{3}-\d{2}-\d{4})|(\d{3}\d{2}\d{4})|(\d{3}\s{1}\d{2}\s{1}\d{4})$ ``` However this social security number passes, when it should actually fail since there is only one space ``` 12345 6789 ``` So I need an updated regex that rejects things like ``` 12345 6789 123 456789 ``` To make things more complex it seems that SSNs cannot start with 000 or 666 and can go up to 899, the second and third set of numbers also cannot be all 0. I came up with this ``` ^(?!000|666)[0-8][0-9]{2}[ \-](?!00)[0-9]{2}[ \-](?!0000)[0-9]{4}$ ``` Which validates with spaces or dashes, but it fails if the number is like so ``` 123456789 ``` Ideally these set of SSNs should pass ``` 123456789 123 45 6789 123-45-6789 899-45-6789 001-23-4567 ``` And these should fail ``` 12345 6789 123 456789 123x45x6789 ABCDEEEEE 1234567890123 000-45-6789 123-00-6789 123-45-0000 666-45-6789 ```
2015/12/30
[ "https://Stackoverflow.com/questions/34523247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1046662/" ]
To solve your problem with dashes, spaces, etc. being consistent, you can use a backreference. Make the first separator a group and allow it to be optional - `([ \-]?)`. You can then reference it with `\1` to make sure the second separator is the same as the first one: ``` ^(?!000|666)[0-9]{3}([ -]?)(?!00)[0-9]{2}\1(?!0000)[0-9]{4}$ ``` See it [here](https://regex101.com/r/rA2xA2/1) (thanks @Tushar)
More complete validation rules are available on CodeProject at <http://www.codeproject.com/Articles/651609/Validating-Social-Security-Numbers-through-Regular>. Copying the information here in case the link goes away, but also expanding on the codeproject answer a bit. A Social Security number CANNOT : * Contain all zeroes in any specific group (ie 000-##-####, ###-00-####, or ###-##-0000) * Begin with ’666′. * Begin with any value from ’900-999′ * Be ’078-05-1120′ (due to the Woolworth’s Wallet Fiasco) * Be ’219-09-9999′ (appeared in an advertisement for the Social Security Administration) This RegEx taken from the referenced CodeProject article will validate all Social Security numbers according to all the rules - requires dashes as separators. ``` ^(?!219-09-9999|078-05-1120)(?!666|000|9\d{2})\d{3}-(?!00)\d{2}-(?!0{4})\d{4}$ ``` Same with spaces, instead of dashes ``` ^(?!219 09 9999|078 05 1120)(?!666|000|9\d{2})\d{3} (?!00)\d{2} (?!0{4})\d{4}$ ``` Finally, this will validate numbers without spaces or dashes ``` ^(?!219099999|078051120)(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$ ``` Combining the three cases above, we get the ### Answer ``` ^((?!219-09-9999|078-05-1120)(?!666|000|9\d{2})\d{3}-(?!00)\d{2}-(?!0{4})\d{4})|((?!219 09 9999|078 05 1120)(?!666|000|9\d{2})\d{3} (?!00)\d{2} (?!0{4})\d{4})|((?!219099999|078051120)(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4})$ ```
34,523,247
Social Security numbers that I want to accept are: ``` xxx-xx-xxxx (ex. 123-45-6789) xxxxxxxxx (ex. 123456789) xxx xx xxxx (ex. 123 45 6789) ``` I am not a regex expert, but I wrote this (it's kind of ugly) ``` ^(\d{3}-\d{2}-\d{4})|(\d{3}\d{2}\d{4})|(\d{3}\s{1}\d{2}\s{1}\d{4})$ ``` However this social security number passes, when it should actually fail since there is only one space ``` 12345 6789 ``` So I need an updated regex that rejects things like ``` 12345 6789 123 456789 ``` To make things more complex it seems that SSNs cannot start with 000 or 666 and can go up to 899, the second and third set of numbers also cannot be all 0. I came up with this ``` ^(?!000|666)[0-8][0-9]{2}[ \-](?!00)[0-9]{2}[ \-](?!0000)[0-9]{4}$ ``` Which validates with spaces or dashes, but it fails if the number is like so ``` 123456789 ``` Ideally these set of SSNs should pass ``` 123456789 123 45 6789 123-45-6789 899-45-6789 001-23-4567 ``` And these should fail ``` 12345 6789 123 456789 123x45x6789 ABCDEEEEE 1234567890123 000-45-6789 123-00-6789 123-45-0000 666-45-6789 ```
2015/12/30
[ "https://Stackoverflow.com/questions/34523247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1046662/" ]
To solve your problem with dashes, spaces, etc. being consistent, you can use a backreference. Make the first separator a group and allow it to be optional - `([ \-]?)`. You can then reference it with `\1` to make sure the second separator is the same as the first one: ``` ^(?!000|666)[0-9]{3}([ -]?)(?!00)[0-9]{2}\1(?!0000)[0-9]{4}$ ``` See it [here](https://regex101.com/r/rA2xA2/1) (thanks @Tushar)
I had a requirement to validate SSN's. This regex will validate SSN for below rules 1. Matches dashes, spaces or no spaces 2. Numbers, 9 digits, non-alphanumeric 3. Exclude all zeros 4. Exclude beginning characters `666,000,900,999,123456789,111111111,222222222,333333333,444444444,555555555,666666666,777777777,888888888,999999999` 5. Exclude ending characters `0000` ``` ^(?!123([ -]?)45([ -]?)6789)(?!\b(\d)\3+\b)(?!000|666|900|999)[0-9]{3}([ -]?)(?!00)[0-9]{2}\4(?!0000)[0-9]{4}$ ``` Explanation ``` ^ - Beginning of string (?!123([ -]?)45([ -]?)6789) - Don't match 123456789, 123-45-6789, 123 45 6789 (?!\b(\d)\3+\b) - Don't match 00000000,111111111...999999999. Repeat same with space and dashes. '\3' is for backtracking to (\d) (?!000|666|900|999) - Don't match SSN that begins with 000,666,900 or 999. ([ -]?) - Check for space and dash. '?' is used to make space and dash optional. ? is 0 or 1 occurence of previous character. (?!00) - the 4th and 5th characters cannot be 00. \4 - Backtracking to check for space and dash again after the 5th character. (?!0000) - The last 4 characters cannot be all zeros. $ - End of string Backtracking is used to repeat a captured group (). Each group is represented sequentially 1,2,3..so on ``` See here for more explanation and examples <https://regex101.com/r/rA2xA2/3>
34,523,247
Social Security numbers that I want to accept are: ``` xxx-xx-xxxx (ex. 123-45-6789) xxxxxxxxx (ex. 123456789) xxx xx xxxx (ex. 123 45 6789) ``` I am not a regex expert, but I wrote this (it's kind of ugly) ``` ^(\d{3}-\d{2}-\d{4})|(\d{3}\d{2}\d{4})|(\d{3}\s{1}\d{2}\s{1}\d{4})$ ``` However this social security number passes, when it should actually fail since there is only one space ``` 12345 6789 ``` So I need an updated regex that rejects things like ``` 12345 6789 123 456789 ``` To make things more complex it seems that SSNs cannot start with 000 or 666 and can go up to 899, the second and third set of numbers also cannot be all 0. I came up with this ``` ^(?!000|666)[0-8][0-9]{2}[ \-](?!00)[0-9]{2}[ \-](?!0000)[0-9]{4}$ ``` Which validates with spaces or dashes, but it fails if the number is like so ``` 123456789 ``` Ideally these set of SSNs should pass ``` 123456789 123 45 6789 123-45-6789 899-45-6789 001-23-4567 ``` And these should fail ``` 12345 6789 123 456789 123x45x6789 ABCDEEEEE 1234567890123 000-45-6789 123-00-6789 123-45-0000 666-45-6789 ```
2015/12/30
[ "https://Stackoverflow.com/questions/34523247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1046662/" ]
More complete validation rules are available on CodeProject at <http://www.codeproject.com/Articles/651609/Validating-Social-Security-Numbers-through-Regular>. Copying the information here in case the link goes away, but also expanding on the codeproject answer a bit. A Social Security number CANNOT : * Contain all zeroes in any specific group (ie 000-##-####, ###-00-####, or ###-##-0000) * Begin with ’666′. * Begin with any value from ’900-999′ * Be ’078-05-1120′ (due to the Woolworth’s Wallet Fiasco) * Be ’219-09-9999′ (appeared in an advertisement for the Social Security Administration) This RegEx taken from the referenced CodeProject article will validate all Social Security numbers according to all the rules - requires dashes as separators. ``` ^(?!219-09-9999|078-05-1120)(?!666|000|9\d{2})\d{3}-(?!00)\d{2}-(?!0{4})\d{4}$ ``` Same with spaces, instead of dashes ``` ^(?!219 09 9999|078 05 1120)(?!666|000|9\d{2})\d{3} (?!00)\d{2} (?!0{4})\d{4}$ ``` Finally, this will validate numbers without spaces or dashes ``` ^(?!219099999|078051120)(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4}$ ``` Combining the three cases above, we get the ### Answer ``` ^((?!219-09-9999|078-05-1120)(?!666|000|9\d{2})\d{3}-(?!00)\d{2}-(?!0{4})\d{4})|((?!219 09 9999|078 05 1120)(?!666|000|9\d{2})\d{3} (?!00)\d{2} (?!0{4})\d{4})|((?!219099999|078051120)(?!666|000|9\d{2})\d{3}(?!00)\d{2}(?!0{4})\d{4})$ ```
I had a requirement to validate SSN's. This regex will validate SSN for below rules 1. Matches dashes, spaces or no spaces 2. Numbers, 9 digits, non-alphanumeric 3. Exclude all zeros 4. Exclude beginning characters `666,000,900,999,123456789,111111111,222222222,333333333,444444444,555555555,666666666,777777777,888888888,999999999` 5. Exclude ending characters `0000` ``` ^(?!123([ -]?)45([ -]?)6789)(?!\b(\d)\3+\b)(?!000|666|900|999)[0-9]{3}([ -]?)(?!00)[0-9]{2}\4(?!0000)[0-9]{4}$ ``` Explanation ``` ^ - Beginning of string (?!123([ -]?)45([ -]?)6789) - Don't match 123456789, 123-45-6789, 123 45 6789 (?!\b(\d)\3+\b) - Don't match 00000000,111111111...999999999. Repeat same with space and dashes. '\3' is for backtracking to (\d) (?!000|666|900|999) - Don't match SSN that begins with 000,666,900 or 999. ([ -]?) - Check for space and dash. '?' is used to make space and dash optional. ? is 0 or 1 occurence of previous character. (?!00) - the 4th and 5th characters cannot be 00. \4 - Backtracking to check for space and dash again after the 5th character. (?!0000) - The last 4 characters cannot be all zeros. $ - End of string Backtracking is used to repeat a captured group (). Each group is represented sequentially 1,2,3..so on ``` See here for more explanation and examples <https://regex101.com/r/rA2xA2/3>
17,377,725
I have two queries that I am not sure how to run as one doing some simple math. ``` SELECT count(*) FROM CUSTOMERINFO where member between '2013-01-01' and '2013-12-31' ``` Returns: 7823 ``` select COUNT(DISTINCT ORDERINFO.OrderID) from orderinfo, orderiteminfo where code = '810samp' AND ORDERINFO.OrderID = ORDERITEMINFO.OrderID AND orderinfo.PrepareDate between '2013-01-01' and '2013-12-31' ``` Returns: 4106 I need to have the query return: 4106 / 7823 X 100
2013/06/29
[ "https://Stackoverflow.com/questions/17377725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2533695/" ]
More than likely, those computers do not have some required Qt library that your program is using. See the tutorial here: <http://doc.qt.io/qt-5/windows-deployment.html> Another easy check would be to install Qt on another computer, move your .exe over and see if it runs. If it does, you certainly did not deploy your application correctly. Edited to add this helpful link since this seems to be the exact same issue people are seeing: <https://bugreports.qt.io/browse/QTBUG-28766>
If you have cygwin installed then you can run `ldd <your_app.exe>` and see list of libraries which are required by your application. After doing so copy your exe to another folder and libraries which are required by it. This should be OK for LGPL license but I AM NOT A LAWYER so please consult some smarter people which are familiar with legal issues.