source
stringclasses
1 value
task_type
stringclasses
1 value
in_source_id
stringlengths
1
8
prompt
stringlengths
209
40.4k
gold_standard_solution
stringlengths
0
56.7k
verification_info
stringclasses
1 value
metadata
stringlengths
138
225
problem_id
stringlengths
9
10
stackexchange
llm_judgeable_groundtruth_similarity
123570
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: This question was asked on Judaism.StackExchange a few days ago, but I think it has a better chance of being answered here. Disregarding the grammatical discussion in the comments on that question 1 , Rashi (a commentary on Bible) wrote that if you hollow out an eggshell, fill it with dew, close it, and leave it out in the sun, the eggshell will rise in the air. Question: will an eggshell, filled with dew and heated, actually rise in the air? Apparently, someone tried this out , and found that the eggshell rose a few centimeters. ( Page is in Hebrew, Google Translate does an OK job, but everything you really need to know is copied here. ) Also found this type type of thing discussed (though with a different starting point) here . 1 FTR, I actually think that he was referring to the dew, but let's look at this question as if he was talking about the eggshell. Now provide the response and nothing else.
What is probably being referred to here indirectly is the fact that air with moisture in it is less dense that dry air. The question becomes, is the buoyancy force of an empty egg with the optimal moisture content of air sufficient to overcome it's weight? Searching around I see that water vapor has a density of 0.804g/Land dry air has a density of 1.27 g/L. So from that I will revise my interpretation of the question. Will an empty eggshell full of water vapor rise at STP? Volume of an egg = 52 ml, therefore weigh differential is (1.27-0.804)*0.052 = 0.0242 grams. With an egg shell typically taking up 11% of the weight of an egg (being 50 grams), and 11% is 5.5 grams. TLDR: No
{}
{'log_upvote_score': 5, 'links': ['https://physics.stackexchange.com/questions/123570', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/53027/']}
jdg_87041
stackexchange
llm_judgeable_groundtruth_similarity
220239
Below is a question asked on the forum softwareengineering.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I'm currently doing an application design that involves sale of service. The application will ultimately be used internationally and will need to adjust prices based on user location. Is it a good idea to store / work with all prices in an absolute unit? For example - credits. And I can specify conversion rules like 1 credit = 1 USD. What scenarios would I need to be careful about if I do this (and should I be doing this)? One thing I can think of is problems during auditing if I change my conversion rules periodically. In which case I'll need to start storing conversion rules by date and the conversion process will also require the time of transaction to give the correct amount in any currency for that time. Am I complicating this too much? Now provide the response and nothing else.
You're both over and under-complicating it. You're over-complicating it for the users, who now have to convert things between credits and their local currency in their head, and under-complicating it for yourself. Things are not priced identically around the world, even once you account for exchange rates. Heck, things are not priced identically around what I assume is your home country of the US, tax rates change on a per-state and per-city level and for a payment system this has to be taken into account. Simply put, this will increase the difficulty for the user (and thus decrease the likelihood they'll actually give you that money) and not significantly improve your own situation. Systems of "points" instead of real currency are typically used not to simplify things, but to hide the true cost of items, and only really work well in situations where there can be no competition. See theme parks, proprietary video game systems, casinos, et cetera.
{}
{'log_upvote_score': 4, 'links': ['https://softwareengineering.stackexchange.com/questions/220239', 'https://softwareengineering.stackexchange.com', 'https://softwareengineering.stackexchange.com/users/41780/']}
jdg_87042
stackexchange
llm_judgeable_groundtruth_similarity
61779
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I am trying to understand what “$p$ implies $q$” means. I read that $p$ is a sufficient condition for $q$, and $q$ is a necessary condition for $p$. Further from Wikipedia , A necessary condition of a statement must be satisfied for the statement to be true. Formally, a statement $P$ is a necessary condition of a statement $Q$ if $Q$ implies $P,\quad (Q \Rightarrow P)$. A sufficient condition is one that, if satisfied, assures the statement's truth. Formally, a statement $P$ is a sufficient condition of a statement $Q$ if $P$ implies $Q,\quad (P \Rightarrow Q)$. Now what I am stuck with is that if $P$ is not satisfied will the condition still always be true? Now provide the response and nothing else.
This is a simple matter answered by the truth table of $\Rightarrow$: $$\begin{array}{ c | c || c | } P & Q & P\Rightarrow Q \\ \hline \text T & \text T & \text T \\ \text T & \text F & \text F \\ \text F & \text T & \text T \\ \text F & \text F & \text T \end{array}$$ This shows that when $P$ is false, the implication is true. Note that this is the definition of the table, there is no need to prove it. This is how $\Rightarrow$ is defined to work. As an example, here is one: $$\textbf{If it is raining then there are clouds in the sky}$$ In this case $P=$It is raining, and $Q=$There are clouds in the sky. Note that $P$ is sufficient to conclude $Q$, and $Q$ is necessary for $P$. There is no rain without clouds, and if there are no clouds then there cannot be any rain. However, note that $P$ is not necessary for $Q$. There could be light clouds without any rain, and there could be clouds of snow and blizzard (which is technically not rain).
{}
{'log_upvote_score': 6, 'links': ['https://math.stackexchange.com/questions/61779', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/-1/']}
jdg_87043
stackexchange
llm_judgeable_groundtruth_similarity
473520
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am using temp data as follow in my controllers - very simple, when there is a problem: TempData("StatusMessage") = "You have no items set to Auto-Ship." Then on every page I have a user control as follows: <div class="error-container"><% If TempData.ContainsKey("ErrorMessage") Then%><script> $('div.error-container').show();</script><div class="msg-error"><p><%=TempData("ErrorMessage") %></p></div><% End If%><% If TempData.ContainsKey("StatusMessage") Then%><script> $('div.error-container').show();</script><div class="msg-status"><p><%=TempData("StatusMessage")%></p></div><% End If%><ul></ul></div> Problem is when I do have an error added to tempdata it shows up properly on the first request but ALSO shows up again on the next request as well - which is obviously very confusing and not a desired behavior. I am not using any IoC, I did see the post with the same problems when using that. Now provide the response and nothing else.
The sole purpose of TempData is to persist until the next request. Stuff you do not want to persist until the next request should go into ViewData, instead. Realistically, this means that TempData is only safe to use when redirecting. When not redirecting, the "next request" could be anything.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/473520', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/34548/']}
jdg_87044
stackexchange
llm_judgeable_groundtruth_similarity
9189338
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Maybe this is very basic, but I am all confused. I have a simple html page with many sections (div). I have a string containing html tags in javascript. The code is as follows: <html xmlns="http://www.w3.org/1999/xhtml"><head><script type="text/javascript">var str1="<html><body><div id='item1'><h2>This is a heading1</h2><p>This is a paragraph1.</p></div><div id='item2'><h2>This is a heading2</h2><p>This is another paragraph.</p></div><div id='lastdiv'>last</div></body></html>";</script></head><body><div id="title1"></div><div id="new1"></div><div id="title2"></div><div id="new2"></div></body></html> I want to extract content of the html tags (from the string in javascript) and display that content in my html page in desired sections. i.e. I want "This is a heading1" displayed in <div id="title1"> and "This is a paragraph1." to be displayed in <div id="new1"> and same for the second pair of tags. I need all of this to work only on the client side. I have tried to use HTML DOM getElementByTagName method and its getting too complicated. I know very little of jquery. And I am confused. I dont understand how to go about it. Can you guide me what to use - javascript or jquery and how to use it? Is there a way to identify the from the string and iterate through it? How to extract "This is heading1" (and similar contents enclosed in the html tags) from str1?? I don't know the index of these hence cannot use substr() or substring() function in javascript. Now provide the response and nothing else.
Using .text() as both a 'getter' and a 'setter' we can just repeat the pattern of: target the element on the page we wish to fill give it content fromthe string jsFiddle <script type="text/javascript">var str1="<html><body><div id='item1'><h2>This is a heading1</h2><p>This is a paragraph1.</p></div><div id='item2'><h2>This is a heading2</h2><p>This is another paragraph.</p></div><div id='lastdiv'>last</div></body></html>";$(function(){ var $str1 = $(str1);//this turns your string into real html //target something, fill it with something from the string $('#title1').text( $str1.find('h2').eq(0).text() ); $('#new1').text( $str1.find('p').eq(1).text() ); $('#title2').text( $str1.find('h2').eq(1).text() ); $('#new2').text( $str1.find('p').eq(1).text() );})</script>
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/9189338', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1196522/']}
jdg_87045
stackexchange
llm_judgeable_groundtruth_similarity
4872923
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Tried following code to check what happens when we convert integer pointer to a integer . #include<stdio.h> #include<stdlib.h> int main() { int *p; int a; p = (int *)malloc(sizeof(int)); *p = 10; a = (int)p; printf("%d\n",*p); printf("%d \n",a); return 0; } The output is : 10 135680008 Can anyone explain, the concept related to this conversion? Any links provided related to this topic would also be helpful. Now provide the response and nothing else.
Apparently you confuse the pointer with the content of the pointer. As an analogy to the real world, you could say that, with me pointing at a bird, you want to convert my index finger to a bird. But there is no relation between the type 'bird' and 'finger'. Transferring that analogy to your program: you are converting the object pointing to your int to an int itself. Since a C pointer is implemented as 'the number of a memory cell', and since there are lots of memory cells available, it's obvious that (int)p will result in a very big number. Casting is a nasty thing. It's a coincidence that pointers are quite analogous to integers. If they were implemented as "the n th address of the m th memory bank", you wouldn't be asking this question because there wouldn't have been an obvious relation, and you wouldn't have been able to do this cast.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/4872923', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/388394/']}
jdg_87046
stackexchange
llm_judgeable_groundtruth_similarity
268084
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: What is the most efficient way to create a constant (never changes at runtime) mapping of string s to int s? I've tried using a const Dictionary , but that didn't work out. I could implement a immutable wrapper with appropriate semantics, but that still doesn't seem totally right. For those who have asked, I'm implementing IDataErrorInfo in a generated class and am looking for a way to make the columnName lookup into my array of descriptors. I wasn't aware (typo when testing! d'oh!) that switch accepts strings, so that's what I'm gonna use. Thanks! Now provide the response and nothing else.
Creating a truly compile-time generated constant dictionary in C# is not really a straightforward task. Actually, none of the answers here really achieve that. There is one solution though which meets your requirements, although not necessarily a nice one; remember that according to the C# specification, switch-case tables are compiled to constant hash jump tables. That is, they are constant dictionaries, not a series of if-else statements. So consider a switch-case statement like this: switch (myString){ case "cat": return 0; case "dog": return 1; case "elephant": return 3;} This is exactly what you want. And yes, I know, it's ugly.
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/268084', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4918/']}
jdg_87047
stackexchange
llm_judgeable_groundtruth_similarity
14386775
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am new to the subprocess.call function and I have tried different combinations of the same call but it is not working. I am trying to execute the following command: cmd = 'sort -k1,1 -k4,4n -k5,5n '+outpath+fnametempout+' > '+outpath+fnameoutprint cmd If I try the call I get an error: cmd = cmd.split(" ")print cmdsubprocess.call(cmd) the error I get is: sort: stat failed: >: No such file or directory Now provide the response and nothing else.
Doing it this way, you need shell=True to allow the shell redirection to work. subprocess.call('sort -k1,1 -k4,4n -k5,5n '+outpath+fnametempout,shell=True) A better way is: with open(outpath+fnameout,'w') as fout: #context manager is OK since `call` blocks :) subprocess.call(cmd,stdout=fout) which avoids spawning a shell all-together and is safe from shell injection type attacks. Here, cmd is a list as in your original, e.g. cmd = 'sort -k1,1 -k4,4n -k5,5n '+outpath+fnametempoutcmd = cmd.split() It should also be stated that python has really nice sorting facilities and so I doubt that it is actually necessary to pass the job off to sort via a subprocess. Finally, rather than using str.split to split the arguments, from a string, it's probably better to use shlex.split as that will properly handle quoted strings. >>> import shlex>>> cmd = "foo -b -c 'arg in quotes'">>> print cmd.split()['foo', '-b', '-c', "'arg", 'in', "quotes'"]>>> print shlex.split(cmd)['foo', '-b', '-c', 'arg in quotes']
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/14386775', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1205745/']}
jdg_87048
stackexchange
llm_judgeable_groundtruth_similarity
28835
Below is a question asked on the forum arduino.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I want to replace my door lock with an one made with an Arduino and a servo, but I'm not sure if the platform is stable enough to use it for something like this. If I do everything right (code, connections, constant power), could I trust in this? Now provide the response and nothing else.
I'm not sure if the platform is stable enough to use it for something like this. Absolutely it is. As I describe in my post about an RFID door lock I use a Uno (and some additional parts) to unlock my door. Since writing that I improved the software as described here so you can reprogram the valid list of cards "on the fly" (without uploading new code) as the valid cards are stored in EEPROM. My system has been operating for over 5 years without any problems, except once when there was a brownout in the area and I had to power cycle the system (possibly the RFID reader failed and not the Arduino). My system "fails shut" so it keeps the door locked in the event of a power failure. However I have alternate ways of leaving the building in the event of a power failure combined with a fire. You are talking about a servo rather than an electric strike. That is likely to be the weak point, and not the Arduino as such. You would need to ensure it was powerful enough to do whatever-it-is you are planning to do, and that it had suitable drivers (eg. MOSFET or driver board). My system gets used dozens of times each day. We never have a problem with it.
{}
{'log_upvote_score': 5, 'links': ['https://arduino.stackexchange.com/questions/28835', 'https://arduino.stackexchange.com', 'https://arduino.stackexchange.com/users/16637/']}
jdg_87049
stackexchange
llm_judgeable_groundtruth_similarity
1844812
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: A couple of times when I've tried to prove symmetries of various tensors (for learning), I've ended up with the expression below, and the fact that either a) I made mistake, or b) the expression is symmetric with respect to switching k and l. $$\frac{\partial g_{ij}}{\partial x^k} \frac{\partial g^{ij}}{\partial x^l}$$ Where $g_{..}$ and $g^{..}$ are the covariant and contravariant metric tensor respectively, and $x^.$ is the coordinate. Is the expression symmetric wrt switching $k$ and $l$? If so, is it possible to prove this using only indicial notation? Now provide the response and nothing else.
Since the product rule tells us $0 = \partial( g g^{-1} ) = (\partial g) g^{-1} + g (\partial g^{-1})$, we have a formula for the derivative of the inverse metric: $$ \partial_l g^{ij} = -g^{ia} g^{jb} \partial_l g_{ab}.$$ Substituting this in to your expression we get $$ -g^{ia} g^{jb} \partial_l g_{ab} \partial_k g_{ij}.$$ If we swap the dummy indices $a \leftrightarrow i$, $b \leftrightarrow j$ then this is equal to $$ -g^{ai} g^{jb} \partial_l g_{ij} \partial_k g_{ab};$$ so it's symmetric in $k$ and $l$.
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/1844812', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/89797/']}
jdg_87050
stackexchange
llm_judgeable_groundtruth_similarity
11475
Below is a question asked on the forum cs.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: As I understand, the assignment problem is in P as the Hungarian algorithm can solve it in polynomial time - O(n 3 ). I also understand that the assignment problem is an integer linear programming problem, but the Wikipedia page states that this is NP-Hard. To me, this implies the assignment problem is in NP-Hard. But surely the assignment problem can't be in both P and NP-Hard, otherwise P would equal NP? Does the Wikipedia page simply mean that the general algorithm for solving all ILP problems is NP-Hard? A few other sources state that ILP is NP-Hard so this is really confusing my understanding of complexity classes in general. Now provide the response and nothing else.
If a problem is NP-Hard it means that there exists a class of instances of that problem whose are NP-Hard.It is perfectly possible for other specific classes of instances to be solvable in polynomial time. Consider for example the problem of finding a 3-coloration of a graph . It is a well-known NP-Hard problem. Now imagine that its instances are restricted to graphs that are, for example, trees. Clearly you can easily find a 3-coloration of a tree in polynomial time (indeed you can also find a 2-coloration). Consider decision problems for a second.A method of proving the hardness of a decision problem $P$ is devising a polynomial (Karp) reduction from another problem $Q$ that is known to be NP-Hard.In this reduction you show that there exists a function $f$ that maps each instance $q$ of the problem $Q$ to an instance of the problem $P$ such that:$q$ is a yes instance for $Q \iff f(q)$ is a yes instance for $P$.This implies that solving $f(q)$ must be "at least as difficult" as solving $q$ itself. Notice how it's not required for the image of $f$ to be equal to the set of the instances of $P$ . Therefore it's perfectly possibile for problem $P$ restricted to some subset of instances to not be hard. To return to your original question: The assignment problem can be solved in polynomial time, i.e., a solution to each instance of the assignment problem can be computed in polynomial time. ILP is NP-Hard: in general it might be hard to compute a solution to an ILP problem, i.e. there are instances of ILP that are hard. Some specific instances of ILP can be solved in polynomial time.
{}
{'log_upvote_score': 6, 'links': ['https://cs.stackexchange.com/questions/11475', 'https://cs.stackexchange.com', 'https://cs.stackexchange.com/users/1554/']}
jdg_87051
stackexchange
llm_judgeable_groundtruth_similarity
19625732
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Here is something interesting I found while learning scope in javascript. Code var foo = "This is a global variable.";var bar = function() { alert(foo); foo = "Value has been modified";}bar();alert(foo); This gives the normal response you think you would get, but if I change this one line: from: foo = "Value has been modified"; to: var foo = "Value has been modified"; I get a value of undefined for foo, why is this? Since the function is global scope how come it doesn't accept the var keyword in front of it? Edit Now I understand basically what is happening the var foo in the function bar will gain most importance because of the var keyword and get hoisted up, but it will be hoisted up without the value it has been assigned. Now provide the response and nothing else.
In a var statement, there are two parts to it - the actual declaration: var foo //; ... and the assignment, which is optional: = 1234567890; If there is no assignment done to it, the variable (if not already defined) defaults to undefined . The variable declaration part is moved to the top of the current scope (the start of the function), but not the actual assignment (so it's equivalent to the following): var foo = "This is a global variable.";var bar = function() { var foo; // undefined alert(foo); // yes, it's undefined foo = "Value has been modified"; // modify local, not global}bar();alert(foo); // the global one Functions create their own scope - for example take this: var test = function (){ var bar = 1; console.log(bar); // 1};test();console.log(bar); // ReferenceError: bar is not defined
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/19625732', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']}
jdg_87052
stackexchange
llm_judgeable_groundtruth_similarity
30974555
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: if (Progress.bar.status == 'finished' || Progress.bar.status == 'uploading'){ //code here} How do I shorten this? I'd like to write it without having to repeat Progress.bar.status twice. Something along the lines of: Progress.bar.status == ('finished' or 'uploading'). Now provide the response and nothing else.
I like lookup tables: if ({finished:1, uploading:1}[Progress.bar.status]){ //code here} this uses an object to code two or more options, and even side-steps quoting every choice. its also very fast since the object can be cached and there is no comparison logic or methods to invoke, just fast property access driving the flow... do note that in some cases, you might want to use Object.create(null) and then merge/extend that blank object with your options, if you absolutely must avoid false-positives for "hasOwnProperty", "valueOf", "toString", "toLocaleString", "constructor", and a few double-underscore extensions. it's not often an issue, but it is something to keep in mind. if you can live without feeding your if those keywords, or building a cached collection of choices from Object.create(), it's a fast and simple way to code "one of the above" flows.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/30974555', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/734289/']}
jdg_87053
stackexchange
llm_judgeable_groundtruth_similarity
691560
Below is a question asked on the forum serverfault.com. Provide a good and informational response to it like a helpful human would. Question: I am currently planning a high available Windows Server 2012 R2 environment within a Hyper-V-Cluster with two nodes. I am not sure about how to deploy the virtual domain controller for the work domain, to keep the forest available when a node goes down. I see two options: Create one virtual machine with the domain services and configure the vm as a cluster resource in the failover cluster. Let the cluster worry about the availability of the virtual machine (domain controller). Create one VM on Hyper-V-Node 1. Create a second VM on Hyper-V-Node 2. VMs are not configured as a cluster resource (no redundancy per VM). Install domain services on both VMs. Let the domain controllers worry about offering the domain services, if a node and therefore one VM goes down. My Questions are: Is there a preferred method? What advantages and disadvantages do both methods have? I appreciate high quality answers, please back up your responses with sources. Now provide the response and nothing else.
Creating a single, clustered Domain Controller isn't creating highly available AD services. It's creating a highly available VM, regardless of the services that VM is serving. If you lose the VM (OS failure, data corruption, etc.) then you've lost the services that VM was serving, so those services were not highly available to begin with. Don't confuse a clustered, highly available VM with a clustered, highly available service. A clustered, highly available VM makes the VM highly available and indirectly makes the services on the VM highly available BUT only so long as the VM itself is up and running. if the VM itself is down, so are the services it provides. Clustered VM's protect against HOST failures, not VM or service level failures. The proper course of action would be to create two Domain Controllers. Place them where you wish and cluster them if you want to. If it were me, I'd create two and place them as you've suggested (one DC on each host) and I'd cluster them as well. There's no reason to have one of them be unavailable if one of the hosts goes down. Clustering them allows both to continue serving clients regardless of which host is up or down.
{}
{'log_upvote_score': 4, 'links': ['https://serverfault.com/questions/691560', 'https://serverfault.com', 'https://serverfault.com/users/188837/']}
jdg_87054
stackexchange
llm_judgeable_groundtruth_similarity
11759196
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I've got an answer about how to use SocketAppender (I need it to gather logs from distributed system), but I am new to log4j and I have no idea how to use that sample code. Probably I should have log4j-server.properties like that: log4j.appender.SERVER=org.apache.log4j.net.SocketAppenderlog4j.appender.SA.Port=4712log4j.appender.SA.RemoteHost=loghostlog4j.appender.SA.ReconnectionDelay=10000 But I still don't know how to start the server (how to use this line) org.apache.log4j.net.SimpleSocketServer 4712 log4j-server.properties And what is the most important:Where\How can I see my logs? Now provide the response and nothing else.
You can run the server using java -classpath log4j.jar org.apache.log4j.net.SimpleSocketServer 4712 log4j-server.properties The SimpleSocketServer receives logging events sent to the specified port number by the remote SocketAppender , and logs them as if they were generated locally , according to the configuration you supply in log4j-server.properties . It's up to you to configure the relevant console/file/rolling file appenders and attach them to the relevant loggers just as you would if you were doing the logging directly in the original process rather than piping the log events over a network socket. I.e. if you're currently creating local log files with something like: log4j.rootLogger=DEBUG, filelog4j.appender.file=org.apache.log4j.RollingFileAppenderlog4j.appender.file.File=logfile.loglog4j.appender.file.MaxFileSize=1MBlog4j.appender.file.MaxBackupIndex=1log4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=[%d] [%t] [%m]%n then you would change it so that the sending side log4j.properties simply says log4j.rootLogger=DEBUG, serverlog4j.appender.server=org.apache.log4j.net.SocketAppenderlog4j.appender.server.Port=4712log4j.appender.server.RemoteHost=loghostlog4j.appender.server.ReconnectionDelay=10000 and the server-side log4j-server.properties contains the definitions that were previously on the sending side: log4j.rootLogger=DEBUG, filelog4j.appender.file=org.apache.log4j.RollingFileAppenderlog4j.appender.file.File=logfile.loglog4j.appender.file.MaxFileSize=1MBlog4j.appender.file.MaxBackupIndex=1log4j.appender.file.layout=org.apache.log4j.PatternLayoutlog4j.appender.file.layout.ConversionPattern=[%d] [%t] [%m]%n In particular, note that there's no point specifying a layout on the SocketAppender on the sending side - what goes over the network is the whole logging event object, it's the receiving side that is responsible for doing the layout.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/11759196', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1527394/']}
jdg_87055
stackexchange
llm_judgeable_groundtruth_similarity
4208946
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: If I have a function like : $f(x) = \sin(e^{x/2} + e^{-x/2})$ or something equally complicated, do I actually need to work out if $f(-x) = -f(x)$ , or are all sine functions odd no matter what it is a function of and it is just a matter of proving this using trig identities? thanks! Now provide the response and nothing else.
No, not all $\sin(f(x))$ are odd. In fact, you need $f$ to be odd for that to happen. Well, not exactly; the non-injectiveness of the sine function means there are other ways to make it happen. For instance, we can loosen the oddness requirement on $f$ to "for any $x$ there is an $n$ such that $f(-x)=2\pi n-f(x)$ ". And that's not the most loose construction. But we're getting close. So if you insert, say, an even $f$ into the sine function, the result is necessarily an even function. For instance, $\sin((-x)^2)=\sin(x^2)$ .
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/4208946', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/870063/']}
jdg_87056
stackexchange
llm_judgeable_groundtruth_similarity
18956941
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm trying to save an image in bmp format, but it doesn't create any file.If I use "png" instead, everything works fine.Any ideas? //This works fine:ImageIO.write(bi, "png", new File("D:\\MyImage.png"));//This does not work:ImageIO.write(bi, "bmp", new File("D:\\MyImage.bmp")); ImageIO.getWriterFormatNames() gives me "jpg", "bmp", "jpeg" and some others.. Thanks in advance. Jakob Now provide the response and nothing else.
I just finished debugging a similar problem and I thought I will present my reasoning here, although Jakob has gone ahead with the PNG format. First, always check the return value of ImageIO.write(...) . It will return false if no appropriate writer can be found and that's what should have happened when Jakob tried writing it as a bitmap. This happens when the actual image format of the file does not match what is given in the 'format name' argument. No exception is thrown in this case. Check out the docs at http://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageIO.html#write(java.awt.image.RenderedImage, java.lang.String, java.io.File) Second, check the image type of the BufferedImage object by using the BufferedImage#getType() method. Check out the possible return values at http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html#getType() . For example, If you get the type as TYPE_INT_ARGB from your BufferedImage object (which represents a PNG with a alpha component) you wont have success using ImageIO.write(bi, "BMP", new File("D:\\test.bmp")) and the method would return false , even though you can see BMP/bmp in the list of entries obtained using ImageIO.getWriterFormatNames() . You might have to work on the encoding and transform your image to the desired format. Third, when facing such problems which can be a pain sometimes, it always helps to use an image editor such as GIMP to check out your image properties in detail. @Green arrow, a minor note... you can use either "bmp" or "BMP" as the image format value. The same applies for other formats as well. It does not matter.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/18956941', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2795144/']}
jdg_87057
stackexchange
llm_judgeable_groundtruth_similarity
18812055
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I want to rotate a graphic element infinitely but with some time interval by step. For example, rotate 90 degree (smooth animation) then after 5 secs rotate another 90 degree and repeat the same infinitely. Can this be done using only css? Here is my JS BIN Now provide the response and nothing else.
Pretty simple. The following code limits the transformation to keyframes 40%-60% (one fifth of the entire duration). So, if we give 6 seconds to the entire animation, 1.2s will be used for movement and 4.8s will be used for delay. You can play with it to get more accurate numbers. @-webkit-keyframes rotation { 0%, 40% {-webkit-transform: rotate(0deg);} 60%, 100% {-webkit-transform: rotate(90deg);}}@keyframes rotation { 0%, 40% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); }}.wrapper a:last-child div { -webkit-animation: rotation 6s infinite linear; animation: rotation 6s infinite linear;} Snippet @-webkit-keyframes rotation { 0%, 40% {-webkit-transform: rotate(0deg);} 60%, 100% {-webkit-transform: rotate(90deg);}}@keyframes rotation { 0%, 40% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); }}.wrapper { position: relative;}.wrapper a:first-child div{ position: absolute; width:25px; height:25px; top: 13px; left: 13px; background: red; z-index: 100;}.wrapper a:last-child div { width:50px; height:50px; position: relative; background: orange; -webkit-animation: rotation 6s infinite linear; animation: rotation 6s infinite linear;} <!DOCTYPE html><html><head><meta charset=utf-8 /><title>JS Bin</title></head><body> <div class="wrapper"> <a href="#"><div></div></a> <a href="#"><div></div></a> </div></body></html>
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/18812055', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2031016/']}
jdg_87058
stackexchange
llm_judgeable_groundtruth_similarity
5523290
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I find the documentation on this issue to be unclear: Say you are working with iOS (NOT the Mac case, no need to mention the differences). Say it is strictly 4.0+ (no need to mention differences in old OS). Say we are loading the NIB strictly automatically. Say you have a UIViewController, BigView. Say there are a dozen so-called "top-level" items in the NIB file...could be custom controls, images, or anything else. Say you are definitely going to explicitly create and then get rid of BigView a number of times during the app's run. So: For one of these top-level items in the NIB, there are three possibilities : (1) You do not have any sort of IBOutlet for it, at all. (2) You do have a connected IBOutlet - but not a property. (3) You do have a connected IBOutlet property (to avoid confusion, we'll say a retain property). So what happens to the item when BigView is released? In the case of (3) it seems clear that you must release explicitly. If you do not, it will hang around after the view is gone. No problem. In the case of (1) I assume ( but can anyone actually confirm? ) that the item will be released when BigView is gone. In the case of (2) it's not clear what happens....... Looking at the well-known reference link: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html it is very dubious: "In iOS, the nib-loading code uses the setValue:forKey: method to reconnect each outlet. That method similarly looks for an appropriate accessor method and [SO WHAT HAPPENS IF THERE ISN'T ONE?? TELL US APPLE...] falls back on other means when that fails...[GOOD GRIEF!]" And scroll down to "Nib Object Retention": "Objects in the nib file are created with a retain count of 1 and then autoreleased" Fantastic.. But wait! Read on a few words... however, ... which uses the available setter method or retains the object by default if no setter method is available What are they talking about? Do they mean that if no setter is available (ivar, but no property), that it is AGAIN RETAINED (other than the "retain" they just mention in the previous clause) --- or, are they just repeating themselves, i.e. the "retains the object by default" is the same "retain" they were talking about immediately previously ("created with a retain count of 1 and then autoreleased"). And why would they even mention the autorelease if that's not what happens? Indeed -- if anyone actually specifically knows the answer to this question ...... how do you know?!? Did you ask DTS, or through testing, or? I suggest, the key documentation (just pasted in) is aggressively unclear. Again - if you have an IBOutlet, but not a property , connected to a "top-level" object .. are you responsible for releasing it? Is it retained? in that situation? For that matter .... merely in situation (1) is it absolutely the case that the thingy will be released when BigView goes away? I would certainly assume this is the case, but who knows? The question is what happens if you DO use an IBOutlet iVar, but NOT a property... I've foolishly never thought about this before / assumed too much, does anyone have the decisive answer? Cheers!! For the record I have made a test project. In fact (surprisingly to me) the mere act of connecting an IB element to an IBOutlet in fact apparently adds one retain . (I can only assume from the shoddy docu, in that situation you get specifically: Retain, Autorelease, Retain - leading to one retain on balance.) So, that's the answer. I will post the demo project. I also direct any readers to Jonah's answer below which flawlessly explains the behavior of setValue:forKey: Cheers Now provide the response and nothing else.
I don't see what causes so much confusion, I think the "Nib Object Retention" documentation explains exactly what happens. Let's break it down and walk through what happens: Objects in the nib file are created with a retain count of 1 and then autoreleased. ClassLoadedFromNib *loadedObject = [[[ClassLoadedFromNib alloc] initWithCoder:coder] autorelease]; As it rebuilds the object hierarchy, however, UIKit reestablishes connections between the objects using the setValue:forKey: method, [filesOwner setValue:loadedObject forKey:nameOfIBOutlet]; which uses the available setter method or retains the object by default if no setter method is available. The default behavior of -setValue:forKey: in iOS is roughly //lazy pseudocodeif ([self respondsToSelector:@selector(@"setKeyName:")]) { [self setKeyName:value];}else { object_setIvar(self, _keyName, [value retain]);} See the key-value programming guide for even more detail. Unless your file's owner object overrides -setValue:forKey: (or +accessInstanceVariablesDirectly and -setValue:forUndefinedKey: ) expect object ownership to be managed as above. If you define outlets for nib-file objects, you should always define a setter method (or declared property) for accessing that outlet. Setter methods for outlets should retain their values, and setter methods for outlets containing top-level objects must retain their values to prevent them from being deallocated. Allowing nib loading to set ivar directly to externally retained objects is confusing. Don't do that. Provide setter methods for your outlets so the ownership of the loaded object is clear. If you do not store the top-level objects in outlets, you must retain either the array returned by the loadNibNamed:owner:options: method or the objects inside the array to prevent those objects from being released prematurely. Objects not connected to outlets have been autoreleased. Retain them or the array returned from -loadNibNamed:owner:options: if you are going to try to access them later.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/5523290', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/294884/']}
jdg_87059
stackexchange
llm_judgeable_groundtruth_similarity
59085911
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am using react-router v5.1 with TypeScript and have this route configurations: <Router basename="/" hashType="slash"> <Switch> <Route path="/token/:tokenName"> <TokenPage /> </Route> </Switch></Router> and I try to access the url param (tokenName) in the component, with useParams hook like so: const TokenPage: FC<TokenPageProps> = props => { const { tokenName } = useParams() ...} However, typescript thinks that tokenName param can be undefined: which does not make sense since react router won't match this route if the param is missing in the URL. How can I fix the typing in that situation? Now provide the response and nothing else.
In this situation, your TokenPage code is unaware it is being wrapped by a Route . You are right that if the URL does not contain the proper parameters, your component wouldn't be rendered. But Typescript isn't aware of this. The default typing you got there is proper and you should null check the value before using it. If ever you would want to override the typing, useParams is generic and accepts a type specifying the return value type. interface ParamTypes { tokenName: string}const { tokenName } = useParams<ParamTypes>() EDIT 09/29/20 The latest typing for useParams changed. export function useParams<Params extends { [K in keyof Params]?: string } = {}>(): Params; As you can see, the new default is {} which will not imply any of the keys contained, but the generic constraints does assume that the values are of type string . So the following line would now yield a Property 'tokenName' does not exist on type '{}'. TypeScript error. const { tokenName } = useParams() To fix this, either you type the useParams with known parameters like in the first example, or you type it like this: const { tokenName } = useParams<Record<string, string | undefined>>()
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/59085911', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2886379/']}
jdg_87060
stackexchange
llm_judgeable_groundtruth_similarity
24620108
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm having problems with git ls-files --others --ignored --exclude-standard not listing some ignored files. My project has this directory structure .├── aspnet│   ├── .gitignore│   ├── __init__.py│   ├── lib│   │   ├── <lots of big stuff> The aspnet/.gitignore lists lib/* , and git add aspnet/lib/foo reports that this path is ignored. But git ls-files --others --ignored --exclude-standard does not list the files under lib . These are untracked files, they show up in output if I do git ls-files --others , but not if I provide the ignored flag. Using git version 1.7.9.5 Edit: works as expected with git version 1.8.5.2 (Apple Git-48), this seems to be a git bug Now provide the response and nothing else.
Having find (likely on UNIX/Linux), you can issue the following command in the root folder of your git repository: find . -type f | git check-ignore --stdin find . -type f will list all files in the folder recursively, while git check-ignore will list those files from the list, which are effectively ignored by .gitignore . The check-ignore command is relatively new. If your .git version does not support it already, you can use the following workaround with a POSIX compatible shell (like bash, sh, dash, zsh). It is based on the fact that .gitignore contains glob patterns which are meant to be interpreted by a shell. The workaround iterates over the glob patterns from .gitignore , expands them in the shell and filters out directories from it: while read glob ; do if [ -d "$glob" ] ; then # Be aware of the fact that even out of an ignored # folder a file could have been added using git add -f find "$glob" -type f -exec \ bash -c "FILE={};[ \$(git status -s \$FILE) == "" ] && echo \$FILE" \; else for file in "$glob" ; do # Again, be aware of files which add been added using -f bash -c "FILE={};[ \$(git status -s \$FILE) == "" ] && echo \$FILE" \; done fi# Pipe stderr to /dev/null since .gitignore might contain entries for non # existing files which would trigger an error message when passing them to finddone < .gitignore 2>/dev/null | sort
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/24620108', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/119592/']}
jdg_87061
stackexchange
llm_judgeable_groundtruth_similarity
42803
Below is a question asked on the forum engineering.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: These are suction-mounting hooks. I want to visualize and understand how do they stick on walls. After these hooks stick on wall. Like we compressed them. How? Since gases are compressible up to a good finite limit. What makes it difficult for them to come off if I pull them. It should be easily able come off also. Online , it says that the air gets enclosed inside . But I am not getting exactly what it means by that. How does that air enclosed creates a way in which it becomes difficult for us to pull the hook off. Now provide the response and nothing else.
TL;DR: Its not the air that's enclosed inside that creates the force, but the lack of air - or more precisely pressure. First of all some nomenclature (this is for the closed type, there is also the open type): When you press a suction cup on a surface what happens is that the air inside it is pushed out. During the compression phase of the cup the air comes out of the lip to the atmospheric pressure. So if you have an original volume $V_0$ of the suction cup, and then the volume reduces to $V_2 = \frac{V_0}{2}$ (usually there is even less volume), then the mass of the air trapped inside the suction cup is about half the original (keep this in mind for later on). Figure 2: Air exiting . (source: ijiset.com ) The dome is flexible, so while pushing it is easy to change its shape (thus force the the air out). Additionally the shape of the lip (at a tangent with the object makes it easy for the air to be driven out). However, after the external force is removed then because of the material elasticity, the suction cup is trying to return to the original shape. Figure 3: Different stages. (source: Abetterchemtext ) Following on with the example, because the suction cup tries to recover (partially), as the volume of the suction cup tries to increase the air density reduces, and so does the pressure. So what you end up is a low pressure underneath the suction cup. If the suction cup were allowed to recover its original shape (it doesn't) then the pressure in the example would be half the pressure. Figure 4: Low and high pressure regions. (source: wired ) Then the "suction" force is equal to : $$F = A\cdot dP $$ where : A is the area of the suction cup (its projection) dP is the difference in pressure ( $P_{High}- P_{low}$ ) numerical example Assuming a diameter of 50 mm, and a pressure difference at about half the pressure of the atmospheric pressure, then you can estimate that the pull out force would be approximately: $$F = \frac{\pi d^2}{4} \Delta P $$ $$F \approx 2 \; [N]$$ Notice that if you double the diameter the force quadruples, so you can get significantly higher forces. Why some surfaces are better The reason why smooth non porous surfaces tend to behave better with suction cups is that there is not much leakage (from the outside in). Air coming in the suction chamber would increase the pressure inside the chamber, and therefore reduce the pressure differential $\Delta P$ .
{}
{'log_upvote_score': 6, 'links': ['https://engineering.stackexchange.com/questions/42803', 'https://engineering.stackexchange.com', 'https://engineering.stackexchange.com/users/30877/']}
jdg_87062
stackexchange
llm_judgeable_groundtruth_similarity
32115244
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I need to check backend via API for app settings update, therefore I'm not sure would it be sufficient to perform such check upon launching or I need to do as soon as app comes to the foreground. Of course it depends on how many apps are opened, device capabilities, but what is there a general rule about how long an app can survive in the background until it's killed? A week? Now provide the response and nothing else.
Remove Old 1.4.x go installation and then install go 1.5. I faced the same problem after installing go 1.5. The issue is that I installed go 1.5 at the same place of 1.4.2. Go 1.5 does not use C anymore and if old C installation files are present it throws the error as you are shown. if you want the old installation to be present as well then install 1.5 to some other location and set GOROOT to that location. Hope it helps. Edit 1: For Linux Users: if you downloaded go1.5*.tar.gz then you did this: tar -C /usr/local/ -xvf go1.5.linux-amd64.tar.gz Your old folder C files are not deleted, so the correct process is: First: You should delete you old go folder. sudo rm -rf /usr/local/go/ Second: Then run tar -C /usr/local/ -xvf go1.5.x.linux-amd64.tar.gz
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/32115244', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/597292/']}
jdg_87063
stackexchange
llm_judgeable_groundtruth_similarity
12229817
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am trying to understand the ListView concept and how it works and I'm trying to create my own adapter which extends BaseAdapter . For ArrayAdapter for instance, there is the notifyDataSetChanged() method which should be called after you've updated the array list which holds all your data, in order to refresh the ListView . But I am creating my own subclass of BaseAdapter . That method is not available to me, or is it? How do i implement this method? Basically, what does that method do exactly, maybe I'll understand then. In case of the ArrayAdapter i'm guessing it looks at what position the ListView is currently displaying and it checks if it's the same one as in the ArrayList after it was updated? Or... It says that the method: Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself. But how exactly does it refresh itself? Can someone explain please? Now provide the response and nothing else.
I've figured it out . I couldn't understand how the hell the adapter started and how did it know where to get the data from. When i extended the BaseAdapter class, in the constructor of that class I initialized the list of items that I wanted to see in the ListView . But I couldn't figure out how these values would be used and when. So here's the thing !!! : In the BaseAdapter there are some methods that need to be overridden. Among these, there is getCount() . When the ListView is created and whatnot, it calls getCount() . If this returns a value different than 0 (I returned the size of the ArrayList which I've previously initialized in the constructor), then it calls getView() enough times to fill the screen with items. For instance , I initialized the ArrayList with 20 items. Because only 8 items initially fit on the screen, getView() was called 8 times, each time asking for the position it required for me to return (more precisely it wanted to know how the row would look like in the list on that specific position, what data it needed to contain). If I scroll down the list, getView() gets called over and over again, 'til I hit the end of the list, in my case 20 items / rows. What notifyDataSetChanged() does is ... when called, it looks at what items are displayed on the screen at the moment of its call (more precisely which row indexes ) and calls getView() with those positions. i.e. if you're displaying the first 8 items in the list (so those are the ones visible on the screen) and you add another item between the 2nd and 3rd item in the list and you call notifyDataSetChanged() then getView() is called 8 times, with positions starting from 0 and ending with 7, and because in the getView() method you're getting data from the ArrayList then it will automatically return the new item inserted in the list alongside 7 out of the previous 8 (7 and not 8 because the last item went one position down, so it is not visible anymore), and the ListView will redraw, or whatever, with these items. Also, important to specify is that if you've implemented getView() correctly, you'll end up recycling the items (the objects) already displayed (instead of creating new ones). See this video at around 12:00 minutes to see the correct way to implement getView() I've figured all this out by placing calls to LogCat in every method and following what was going on. Hope this helps someone who's just now starting to understand how ListView s work. P.S. This example also helped me a lot to understand. UPDATE Nowadays ListViews are not really used anymore. Android came out with the RecyclerView which does the recycling of the views for you, but knowing the basics of a ListView helps with understanding the RecyclerView . Here's a link for reference: https://developer.android.com/guide/topics/ui/layout/recyclerview
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/12229817', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2064171/']}
jdg_87064
stackexchange
llm_judgeable_groundtruth_similarity
30401460
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: For Postgres, I keep getting this error multiple times even though I have already set the location of the bin folder to the path variable in Windows 8. Is there something else I'm missing? (I can't post pictures since I don't have enough reputation) Now provide the response and nothing else.
Just an update because I was trying it on Windows 10 you do need to set the path to the following: ;C:\Program Files\PostgreSQL\14\bin ;C:\Program Files\PostgreSQL\9.5\lib PS : 14 is the current version, check whatever version you are on.You can do that either through the CMD by using set PATH [the path] or from my computer => properties => advanced system settings=> EnvironmentVariables => System Variables Then search for path. Important: don't replace the PATHs that are already there just add one beside them as follows ;C:\Program Files\PostgreSQL\9.5\bin ;C:\Program Files\PostgreSQL\9.5\lib Please note : On windows 10, if you follow this: computer => properties => advanced system settings=> Environment Variables => System Variables> select PATH, you actually get the option to add new row. Click Edit, add the /bin and /lib folder locations and save changes. Then close your command prompt if it's open and then start it againtry psql --versionIf it gives you an answer then you are good to go if not try echo %PATH% and see if the path you set was added or not and if it's added is it added correctly or not. Important note: Replace 9.5 with your current version number. As of 2021, that is 13.For 2022 is 14.
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/30401460', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4797192/']}
jdg_87065
stackexchange
llm_judgeable_groundtruth_similarity
471886
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I learned from that plasma can reflect radiations of frequency less than that of its own oscillations. If so, considering the plasma in Sun's atmosphere, it should also reflect solar radiations. That would mean that the radiation emitted from the inner layers of the Sun would be reflected back by the outer layers. So, the only radiation coming out should be the ones generated at the outer layers, for which there is no denser layers of plasma surrounding it. And of course, the ones that have higher frequencies than the plasma in each layer would come out unscathed. If this is true, most of the radiation generated by fusion will be trapped inside, and what we observe is only a fraction. Note that the intensity of observable radiation coming out from stars would now mostly depend on the outermost layer. So, wouldn't it be inappropriate to consider stars as Black bodies while determining their temperature and other properties? Is Sun brighter and hotter than what we see from outside? Now provide the response and nothing else.
Note that the intensity of observable radiation coming out from stars would now mostly depend on the outermost layer. Because the material in the star is opaque, it completely depends on the outermost layer. Of course the properties of that layer (such as its temperature) are driven by the energy coming from the interior. So, wouldn't it be inappropriate to consider stars as Black bodies while determining their temperature and other properties? It is appropriate for an object that has a spectrum that closely matches a blackbody spectrum. However the only property that describes is the temperature of the visible layer. It doesn't imply anything about the interior and processes that produce and distribute energy. You shouldn't read blackbody and think that means that the (invisible) interior is simple or in some way similar to the exterior. The sun's interior is much hotter than the exterior (around 15 million Kelvin in the core, compared to the 6000 Kelvin or so at the photosphere). Because it is not visible, I would hesitate to call it "brighter". But you could consider it that way.
{}
{'log_upvote_score': 5, 'links': ['https://physics.stackexchange.com/questions/471886', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/155230/']}
jdg_87066
stackexchange
llm_judgeable_groundtruth_similarity
14300413
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a database where I store strings of addresses of images which I wanna use in my app. I have ClientAuction Class which reads that string from the DB along with other things public class ClientAuction : INotifyPropertyChanged{ private string photoFileName; public string PhotoFilename { set { if (photoFilename != value) { photoFilename = value; OnPropertyChanged("PhotoFilename"); } } get { return photoFilename; } }} All the other bindings are working but the images just won't show. I've tried relative addresses, addresses on my hard drive, web addresses but nothing shows up. I've also tried using Uri and ImageSource or using a BitmapImage in but no result <Grid Name="AllAuctionsContentPanel" DataContext="{Binding Source={StaticResource presenter}}"> <ScrollViewer> <ListBox Name="AllItems" ItemsSource="{Binding Auctions}" Height="750" SelectionChanged="Items_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <Border BorderBrush="{StaticResource PhoneAccentBrush}" Width="450" BorderThickness="1" CornerRadius="12" Margin="2"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Image Grid.Row="0" Grid.Column="0" Source="{Binding PhotoFileName}" Height="128" Width="128" Margin="10"> </Image> <ContentControl Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center"> <StackPanel > <StackPanel Orientation="Horizontal"> <TextBlock Text="Item Name: "></TextBlock> <TextBlock Text="{Binding ItemName}"></TextBlock> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="Starting Bid: "></TextBlock> <TextBlock Text="{Binding StartingBid}"></TextBlock> </StackPanel> <StackPanel Orientation="Horizontal"> <TextBlock Text="End Time: "></TextBlock> <TextBlock Text="{Binding EndTime}"></TextBlock> </StackPanel> </StackPanel> </ContentControl> </Grid> </Border> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </ScrollViewer> </Grid> Now provide the response and nothing else.
You wrote : var myModule = require('myModule.js');myModule.put({}, function(){ //some callback stuff}); Here myModule is in fact MyModule , a constructor function. So what you are doing is MyModule.put() , a call to a "static" method of MyModule . MyModule.prototype.put defines an "instance" method so you have to instanciate first : var MyModule = require('./myModule.js');var myModule = new MyModule();// or as you used `if (!(this instanceof MyModule)) { … }`var myModule = MyModule();myModule.put({}, function () {}); So basically your code needs just a pair of () to work : MyModule().put({}, function () {});// same as(new MyModule).put({}, function () {}); Récap : var MyModule = function () { // Construct object};MyModule.staticMethod = function () { this; // is bound to `MyModule` function object};MyModule.prototype.instanceMethod = function () { this; // is bound to the `MyModule` instance object it’s called from};// UsageMyModule.staticMethod();var instance = new MyModule();instance.instanceMethod();
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/14300413', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1284344/']}
jdg_87067
stackexchange
llm_judgeable_groundtruth_similarity
26829086
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Is it possible to set a different timeoutlen depending on the typed key? For example, I have this short timeout to go with my <Esc> remapping to jk set timeoutlen=200 I'd like to make timeoutlen longer if I start with a <leader> because I have some mappings that require sequences of keys that are not as easy to type as jk . Now provide the response and nothing else.
There's nothing built-in. With regards to your mapping, you probably mean :inoremap jj <Esc> , and for that to apply quickly, you just need to ensure that there are no other insert mode mappings that start with jj . To avoid that the first j appears only with a delay, you could use :autocmds to toggle the 'timeoutlen' value: :autocmd InsertEnter * set timeoutlen=200:autocmd InsertLeave * set timeoutlen=1000
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/26829086', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2548357/']}
jdg_87068
stackexchange
llm_judgeable_groundtruth_similarity
14383258
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a site created which is dynamic and the information (area / category / subcategory) passes through htaccess for nice URLs.For example, as the user dives into the categories it flows as follows: /parts/hard-drives/parts/hard-drives/hard-drives-sas I wondered if there was a way to extend this from then on in htaccess so I can pass more items and grab the variable with php, ie: /parts/hard-drives/hard-drives-sas/?manufacturer=dell&price=20 My current lines for the htaccess file are as follows: RewriteRule ^parts/([^/\.]+)/([^/\.]+)/?$ parts.php?p=$1&f=$2 [L]RewriteRule ^parts/([^/\.]+)/?$ parts.php?p=$1 [L]RewriteRule ^parts parts.php [L] You will see the first line relates to /products/hard-drives/hard-drives-sas the second relates to /products/hard-drives and then simply a parts page /parts Hopefully that makes sense! Thanks. Now provide the response and nothing else.
Use QSA flag to pass GET variables: RewriteRule ^parts/([^/\.]+)/([^/\.]+)/?$ parts.php?p=$1&f=$2 [L,QSA]RewriteRule ^parts/([^/\.]+)/?$ parts.php?p=$1 [L,QSA]RewriteRule ^parts parts.php [L,QSA] Docs: When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined. Consider the following rule: RewriteRule /pages/(.+) /page.php?page=$1 [QSA] With the [QSA] flag, a request for /pages/123?one=two will be mapped to /page.php?page=123&one=two. Without the [QSA] flag, that same request will be mapped to /page.php?page=123 - that is, the existing query string will be discarded. http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_qsa
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/14383258', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1087600/']}
jdg_87069
stackexchange
llm_judgeable_groundtruth_similarity
30097432
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I need to create an input text box with a bottom border and the side borders should span half the height of the input on left and right. Is there an easy way to design this in CSS ? Image is show below: Now provide the response and nothing else.
Maybe this could be an elegant solution. If you use background then you can specify really nicely where what goes and it improves readability a bit. input[type="text"] { padding: 10px; background: linear-gradient(#000, #000), linear-gradient(#000, #000), linear-gradient(#000, #000); background-size: 1px 20%, 100% 1px, 1px 20%; background-position: bottom left, bottom center, bottom right; background-repeat: no-repeat; border: none; color: #999;} <input type="text" />
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/30097432', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/832893/']}
jdg_87070
stackexchange
llm_judgeable_groundtruth_similarity
2537421
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I have this problem that I've struggled with for a while. If you place $4$ points randomly into a unit square (uniform distribution in both $x$ and $y$), with what probability will this shape be convex if the $4$ points are connected in some order? Equivalently, with what probability will there be a point inside the triangle with the largest area with vertices at the other $3$ points. In particular I am interested in the answer for when this area of support is $\mathbb{R}^2$ and is uniform. I ran a simulation and found that on a unit square the answer is about $71\%$ concave. On a unit circle picking polar co-ordinates r and theta from uniform random distributions results in a a probability of concavity of $68\%$. When the distribution for r is altered so that each point in the circle is equally likely then this falls to $51\%$. Any advice or links for a possible answer or whether this is even possible would be appreciated. EDIT: It turns out this problem is the same as Sylvester's 4 point problem. Alas I am 150 years too late. Thanks to all who helped. Only one person gave an answer, not quite correct but I award the bounty to them anyway for their efforts. Now provide the response and nothing else.
Here is a different approach to the problem. Consider a random triangle illustrated below. Regions are labelled near ($N_i$) and far ($F_i$) from point $i$. $T$ is the triangle. If the 4th point falls in regions $F_1$, $F_2$, or $F_3$ a convex quadrilateral will result. The probability that 4 points produce a convex shape is equivalent to the probability that the 4th point will be in one of those regions. That is, $p=E[F_1+F_2+F_3]$ where $F_i$ is the random variable expressing the area of that region. To simplify the calculations, consider the shaded region labelled $A_1$ and the counterparts $A_2$ and $A_3$.$$F_1+N_2+N_3=A_1$$$$N_1+F_2+F_3+T=1-A_1$$Combining these one finds,$$F_1+F_2+F_3 = 2 - 2T - A_1 - A_2 - A_3$$and therefore,$$p=E[F_1+F_2+F_3]=2 - 2E[T] - 3E[A]$$Fortunately others have worked out $E[T]={11\over144}$ To work out $E[A]$, I considered separately the case where the unit square is bisected across opposite sides (as is the case for $A_1$). You can show that this occurs with probability ${2\over3}$, given two uniform random points. The smallest of the two areas $A_\min$ follows the distribution $$f(a_\min)=4a_\min$$ for $0<a_\min<{1\over2}$. Given the two points $(2,3)$ point $1$ point will fall in the smaller of the two areas with probability $a_\min$, in which case $A_1=1-a_\min$.$$E[A_{opp}]=16\int_0^{1\over2}a_\min^2(1-a_\min)\,da_\min = {5\over12}$$ For the case where the unit square is cut across a corner (as is the case for $A_2$), $A_\min={1\over2}X_0Y_0$ where $X_0$ and $Y_0$ are independent random variables with the identical distribution, $f(x)=2x$ for $0<x<1$. This gives the distribution for $A_\min$, $$f(a_\min)=-16 a_\min \log 2a_\min$$ for $0<a_\min<{1\over2}$.$$E[A_{corner}]=-32\int_0^{1\over2}a_\min^2(1-a_\min)\log 2a_\min\,da_\min = {23\over72}$$And so, overall$$E[A] = P(A_{opp})E[A_{opp}]+P(A_{corner})E[A_{corner}]={2\over3}{5\over12}+{1\over3}{23\over72} = {83\over216}$$Finally,$$p = 2 - 2{11\over144} - 3{83\over216}={25\over36}=\left({5\over6}\right)^2=0.69\bar{4}$$which is close to your simulation result. A very simple form!
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/2537421', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/481442/']}
jdg_87071
stackexchange
llm_judgeable_groundtruth_similarity
55186100
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have some annotation in a class such as public class ProductModel {@Pattern(regexp="^(1|[1-9][0-9]*)$", message ="Quantity it should be number and greater than zero")private String quantity; then in my controller @Controllerpublic class Product Controllerprivate ProductService productService;@PostMapping("/admin/product")public String createProduct(@Valid @ModelAttribute("product") ProductModel productModel, BindingResult result){ // add println for see the errors System.out.println("binding result: " + result); if (!result.hasErrors()) { productService.createProduct(productModel); return "redirect:/admin/products"; } else { return "product"; }} Then I am trying to do a test of createProduct from ProductController. @RunWith(MockitoJUnitRunner.class)public class ProductControllerTest {@Autowiredprivate MockMvc mockMvc;@MockProductService productService;@InjectMocksProductController productController;@Mockprivate BindingResult mockBindingResult;@Beforepublic void setupTest() { MockitoAnnotations.initMocks(this); Mockito.when(mockBindingResult.hasErrors()).thenReturn(false);}@Testpublic void createProduct() throws Exception { productController = new ProductController(productService); productController.createProduct(new ProductModel(), mockBindingResult); Here I do not know how can I add values to the object productmodel and also how can I test the message output of "...number should be greater than zero".What I was trying to do it was create an object and then assert with values for making it fail or work such as assertEquals(hello,objectCreated.getName());Any advice or help will be highly appreciated. Now provide the response and nothing else.
To validate bean annotations you must have the context in execution. You can do this with: @RunWith(SpringRunner.class)@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) Then your tests will validate the annotations. However, if you just want to validate the annotation of model (without another business rules) you can use a validator: private static ValidatorFactory validatorFactory;private static Validator validator;@BeforeClasspublic static void createValidator() { validatorFactory = Validation.buildDefaultValidatorFactory(); validator = validatorFactory.getValidator();}@AfterClasspublic static void close() { validatorFactory.close();}@Testpublic void shouldReturnViolation() { ProductModel productModel = new ProductModel(); productModel.setQuantity("a crazy String"); Set<ConstraintViolation<ProductModel>> violations = validator.validate(productModel); assertFalse(violations.isEmpty());}
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/55186100', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9737443/']}
jdg_87072
stackexchange
llm_judgeable_groundtruth_similarity
14995610
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: This question is related to this one . What I would like to know is how to apply the suggested solution to a bunch of data (4 columns), e.g.: 0.1 0 0.1 2.00.1 0 1.1 -0.4981217129980.1 0 2.1 -0.499730050750.1 0 3.1 -0.4999160820380.1 0 4.1 -0.4999637265860.1 1 0.1 -0.01814058956920.1 1 1.1 -0.4907749886180.1 1 2.1 -0.4986537428460.1 1 3.1 -0.4995807479530.1 1 4.1 -0.4998186960630.1 2 0.1 -0.01070791195720.1 2 1.1 -0.4836418230930.1 2 2.1 -0.4975820612330.1 2 3.1 -0.4992458634380.1 2 4.1 -0.4996737496570.1 3 0.1 -0.00752485890890.1 3 1.1 -0.4767130381660.1 3 2.1 -0.496514976150.1 3 3.1 -0.4989114275890.1 3 4.1 -0.4995288872950.1 4 0.1 -0.005791800030480.1 4 1.1 -0.4699799740920.1 4 2.1 -0.4954524580860.1 4 3.1 -0.4985774395050.1 4 4.1 -0.4993841089041.1 0 0.1 302.01.1 0 1.1 -0.2727272727271.1 0 2.1 -0.4673361408061.1 0 3.1 -0.4898459266221.1 0 4.1 -0.4956109168471.1 1 0.1 -0.0001549159981651.1 1 1.1 -0.1488033298651.1 1 2.1 -0.3758813584541.1 1 3.1 -0.4537495485481.1 1 4.1 -0.4789428418491.1 2 0.1 -9.03765566114e-051.1 2 1.1 -0.09727028066131.1 2 2.1 -0.3142918598421.1 2 3.1 -0.4226062530831.1 2 4.1 -0.4633593530841.1 3 0.1 -6.31234088628e-051.1 3 1.1 -0.07200952192031.1 3 2.1 -0.2700157868971.1 3 3.1 -0.3954623007161.1 3 4.1 -0.448757932481.1 4 0.1 -4.84199181874e-051.1 4 1.1 -0.05711870547041.1 4 2.1 -0.2366609920421.1 4 3.1 -0.3715939832111.1 4 4.1 -0.43504858692.1 0 0.1 1102.02.1 0 1.1 0.3283245679942.1 0 2.1 -0.3809523809522.1 0 3.1 -0.4629921788462.1 0 4.1 -0.484003424212.1 1 0.1 -4.25137933034e-052.1 1 1.1 -0.05131909215082.1 1 2.1 -0.2248661511012.1 1 3.1 -0.3637524701262.1 1 4.1 -0.4307004366582.1 2 0.1 -2.48003822279e-052.1 2 1.1 -0.03100252551242.1 2 2.1 -0.1580220370872.1 2 3.1 -0.299446128182.1 2 4.1 -0.3879654242052.1 3 0.1 -1.73211484062e-052.1 3 1.1 -0.02204662458622.1 3 2.1 -0.121627800642.1 3 3.1 -0.2544240418892.1 3 4.1 -0.352940823112.1 4 0.1 -1.32862131387e-052.1 4 1.1 -0.01708280021972.1 4 2.1 -0.09881384178022.1 4 3.1 -0.2211545872942.1 4 4.1 -0.3237135966713.1 0 0.1 2402.03.1 0 1.1 1.305033809173.1 0 2.1 -0.2405787711913.1 0 3.1 -0.419354838713.1 0 4.1 -0.4651412486763.1 1 0.1 -1.95102493785e-053.1 1 1.1 -0.02481146387733.1 1 2.1 -0.1351530193043.1 1 3.1 -0.2741253364093.1 1 4.1 -0.369656441713.1 2 0.1 -1.13811197906e-053.1 2 1.1 -0.01471163668193.1 2 2.1 -0.08729507006273.1 2 3.1 -0.2029359254123.1 2 4.1 -0.3066122853083.1 3 0.1 -7.94877050259e-063.1 3 1.1 -0.01036247834323.1 3 2.1 -0.06422535682713.1 3 3.1 -0.1609708972353.1 3 4.1 -0.2619064744183.1 4 0.1 -6.09709039262e-063.1 4 1.1 -0.007986269133553.1 4 2.1 -0.05075640812633.1 4 3.1 -0.1333495657823.1 4 4.1 -0.2285637544234.1 0 0.1 4202.04.1 0 1.1 2.657400450794.1 0 2.1 -0.04621531152144.1 0 3.1 -0.3589339062134.1 0 4.1 -0.4390243902444.1 1 0.1 -1.11538537794e-054.1 1 1.1 -0.01446198603174.1 1 2.1 -0.08681903437184.1 1 3.1 -0.2037679827554.1 1 4.1 -0.3085192152654.1 2 0.1 -6.50646078271e-064.1 2 1.1 -0.00851565842894.1 2 2.1 -0.05387847144944.1 2 3.1 -0.1402152400684.1 2 4.1 -0.237463801254.1 3 0.1 -4.54421180079e-064.1 3 1.1 -0.005976690618144.1 3 2.1 -0.0388397895994.1 3 3.1 -0.1066753968164.1 3 4.1 -0.1929222625234.1 4 0.1 -3.48562423225e-064.1 4 1.1 -0.004596931653084.1 4 2.1 -0.03033052313754.1 4 3.1 -0.08603688421334.1 4 4.1 -0.162420599686 The solution to the initial problem is: # Python-matplotlib Commandsfrom mpl_toolkits.mplot3d import Axes3Dfrom matplotlib import cmimport matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = fig.gca(projection='3d')X = np.arange(-5, 5, .25)Y = np.arange(-5, 5, .25)X, Y = np.meshgrid(X, Y)R = np.sqrt(X**2 + Y**2)Z = np.sin(R)Gx, Gy = np.gradient(Z) # gradients with respect to x and yG = (Gx**2+Gy**2)**.5 # gradient magnitudeN = G/G.max() # normalize 0..1surf = ax.plot_surface( X, Y, Z, rstride=1, cstride=1, facecolors=cm.jet(N), linewidth=0, antialiased=False, shade=False)plt.show() As far as I can see, and this applies to all matplotlib-demos, the variables X, Y and Z are nicely prepared. In practical cases this is not always the case. Ideas how to reuse the given solution with arbitrary data? Now provide the response and nothing else.
Great question Tengis, all the math folks love to show off the flashy surface plots with functions given, while leaving out dealing with real world data. The sample code you provided uses gradients since the relationships of a variables are modeled using functions. For this example I will generate random data using a standard normal distribution. Anyways here is how you can quickly plot 4D random (arbitrary) data with first three variables are on the axis and the fourth being color: from mpl_toolkits.mplot3d import Axes3Dimport matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = fig.add_subplot(111, projection='3d')x = np.random.standard_normal(100)y = np.random.standard_normal(100)z = np.random.standard_normal(100)c = np.random.standard_normal(100)img = ax.scatter(x, y, z, c=c, cmap=plt.hot())fig.colorbar(img)plt.show() Note: A heatmap with the hot color scheme (yellow to red) was used for the 4th dimension Result: ] 1
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/14995610', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1213793/']}
jdg_87073
stackexchange
llm_judgeable_groundtruth_similarity
573247
Below is a question asked on the forum physics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: In all the books, that I have studied so far, they say that Carnot cycle is the most efficient cycle. But why isn't any other reversible process as efficient as Carnot cycle? Can somebody please provide mathematical explanation for why that is or isn't the case? Now provide the response and nothing else.
A nuance is that the Carnot cycle is the only reversible cycle between only two reservoirs . There are other idealized cycles that are also reversible (i.e., that generate no entropy) but require more reservoirs. See da Silva, "Some considerations aboutthermodynamic cycles", Eur. J. Phys. 33 (2012) 13–42 for the math framework of evaluating engine reversibility. Note the statement "This property makes the Carnot engine a veryspecial engine: it is the unique reversible heat engine functioning with only two reservoirs. (Any other cycle could be performed in a reversible way, but that would require a virtuallyinfinite number of thermal reservoirs.)" See also Leff, "Thermal efficiency at maximum work output: New results for old heat engines," Am. J. Phys. 55, 602 (1987) and Leff, "Reversible and irreversible heat engine and refrigerator cycles," Am. J. Phys. 86, 344 (2018) for mathematical analyses of non-Carnot reversible cycles, such as the reversible Otto cycle.
{}
{'log_upvote_score': 4, 'links': ['https://physics.stackexchange.com/questions/573247', 'https://physics.stackexchange.com', 'https://physics.stackexchange.com/users/-1/']}
jdg_87074
stackexchange
llm_judgeable_groundtruth_similarity
44840735
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Angular 1 does not accept onchange() event, it's only accepts ng-change() event. Angular 2, on the other hand, accepts both (change) and (ngModelChange) events, which both seems to be doing the same thing. What's the difference? which one is best for performance? ngModelChange : <input type="text" pInputText class="ui-widget ui-text" (ngModelChange)="clearFilter()" placeholder="Find"/> vs change : <input type="text" pInputText class="ui-widget ui-text" (change)="clearFilter()" placeholder="Find"/> Now provide the response and nothing else.
(change) event bound to classical input change event. https://developer.mozilla.org/en-US/docs/Web/Events/change You can use (change) event even if you don't have a model at your input as <input (change)="somethingChanged()"> (ngModelChange) is the @Output of ngModel directive. It fires when the model changes. You cannot use this event without ngModel directive. https://github.com/angular/angular/blob/master/packages/forms/src/directives/ng_model.ts#L124 As you discover more in the source code, (ngModelChange) emits the new value. https://github.com/angular/angular/blob/master/packages/forms/src/directives/ng_model.ts#L169 So it means you have ability of such usage: <input (ngModelChange)="modelChanged($event)"> modelChanged(newObj) { // do something with new value} Basically, it seems like there is no big difference between two, but ngModel events gains the power when you use [ngValue] . <select [(ngModel)]="data" (ngModelChange)="dataChanged($event)" name="data"> <option *ngFor="let currentData of allData" [ngValue]="currentData"> {{data.name}} </option> </select> dataChanged(newObj) { // here comes the object as parameter} assume you try the same thing without " ngModel things" <select (change)="changed($event)"> <option *ngFor="let currentData of allData" [value]="currentData.id"> {{data.name}} </option></select> changed(e){ // event comes as parameter, you'll have to find selectedData manually // by using e.target.data}
{}
{'log_upvote_score': 10, 'links': ['https://Stackoverflow.com/questions/44840735', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2218635/']}
jdg_87075
stackexchange
llm_judgeable_groundtruth_similarity
320124
Below is a question asked on the forum mathoverflow.net. Provide a good and informational response to it like a helpful human would. Question: Based on online info, it seems that most of these numbers have many solutions. Are there any that have only 1 known solution or only a few solutions? Now provide the response and nothing else.
Chebyshev's bias is consistent with the Riemann Hypothesis. I like Terry Tao's explanation in his blog: [..] the bias is small [..] and certainly consistent with known or conjectured positive results such as Dirichlet’s theorem or the generalised Riemann hypothesis. The reason for the Chebyshev bias can be traced back to the von Mangoldt explicit formula which relates the distribution of the von Mangoldt function ${\Lambda}$ modulo ${q}$ with the zeroes of the ${L}$ -functions with period ${q}$ . This formula predicts (assuming some standard conjectures like GRH) that the von Mangoldt function ${\Lambda}$ is quite unbiased modulo ${q}.$ The von Mangoldt function is mostly concentrated in the primes, but it also has a medium-sized contribution coming from squares of primes, which are of course all located in the quadratic residues modulo ${q}.$ (Cubes and higher powers of primes also make a small contribution, but these are quite negligible asymptotically.) To balance everything out, the contribution of the primes must then exhibit a small preference towards quadratic non-residues, and this is the Chebyshev bias. See also Rubinstein and Sarnak MR review here .
{}
{'log_upvote_score': 4, 'links': ['https://mathoverflow.net/questions/320124', 'https://mathoverflow.net', 'https://mathoverflow.net/users/134216/']}
jdg_87076
stackexchange
llm_judgeable_groundtruth_similarity
63482
Below is a question asked on the forum hermeneutics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: The question is: What is the sex/gender of the Holy Spirit per the Biblical pronouns in general and in John 14:26, is it male or neither male nor female? ————— But before answering, please take care and note the following and speak about translation in your answer: Specifically, I have heard that the Holy Spirit is neither male nor female (unlike The Son and The Father). With this thinking, we must use the word “He” rather than “It” - not to denote The Holy Spirit’s sex but His personhood (and not objectness). Ive heard that other languages can list a He to give agency/aliveness without implying a sex. Is that true? Bonus question is to splice out that translation aspect. In John 14:26, is the “he” truly, explicitly a masculine term in Greek, or could it refer to a someone generally (as opposed to a something)? John 14:26 But the Comforter, which is the Holy Ghost, whom the Father will send in my name, he shall teach you all things, and bring all things to your remembrance, whatsoever I have said unto you. Now provide the response and nothing else.
Does John 14:26 explicitly use masculine terms for the Holy Spirit? ΚΑΤΑ ΙΩΑΝΝΗΝ 14:26 1881 Westcott-Hort New Testament 26 ο δε παρακλητος το πνευμα το αγιον ο πεμψει ο πατηρ εν τω ονοματιμου εκεινος υμας διδαξει παντα και υπομνησει υμας παντα α ειπον υμινεγω comforter- defender (pa.ra. klei.tos) παρακλητος το πνευμα το αγιον (ho) holy spirit . It is always in the neuter form The demonstrative pronoun "that one"( εκεινος"ekeinos) **John 14:26 This answer is from the book " Truth in Translation" by Jason David Beduhn associate professor of religious studies at Northern Arizona University, in Flagstaff. ** QUOTE In John14:26 Jesus says :"But the conforter (pa.ra. klei.tos) which the Father will send in my name---that one will teach you everything" Here is a relative pronoun and a demonstrative pronoun are involved in the sentence. The demonstrative pronoun "that one"( εκεινος"ekeinos) refers back to the word (parakleitos- παρακλητος )comforter, a masculine noun meaning a defense attorney or supporter. Since Greek requires gender agreement between a pronoun and the noun it refers back to "that one"is in the masculine form, like comforter, defender. The relative pronoun "which" (ho) refers back to the phrase "holy spirit" which as always appears in the neuter form. So the neuter pronoun "which" (ho) is used rather than the masculine form (hos) In accordance with the details of the verse, the KJV and NW accurately have "which."The NASB, NIV, NRSV, AB, and TEV employ the personal form "whom" which deliberately goes against the neuter gender of the original Greek. Their only reason for doing so is a theological bias in favor of their own belief in a personalized "Holy Spirit." A similarly biased choice is made with respect to the demonstrative pronoun "that one." Demonstrative have the sole function of pointing to something. In themselves they carry no information other than identifying what previously mentioned thing is being talked about again. We see accurate literal handling of this part of Greek speech in the NW's "that one". The KJV, NASB, NAB, AB, TEV, and LB change "that one" to "he" (the NASB and AB capitalize "He"), adding a personalizing (and masculinizing) sense of the "holy spirit." King James Version 26 But the Comforter, which is the Holy Ghost, whom the Father willsend in my name, he shall teach you all things, and bring all thingsto your remembrance, whatsoever I have said unto you. NT 26 But the helper, the holy spirit, which the Father will send in myname, that one will teach you all things and bring back to your mindsall the things I told you. UNQUOTE THE QUESTION THAT ARISES: WHAT IS THE HOLY SPIRIT? The power of the Most High will overshadow you J.Moffat Luke 1:34,35 34" Mary said to the angel, “How can this be, since I am a virgin?” 35"The angel answered her, "The holy Spirit will come upon you, the power of the Most High will overshadow you; hence what is born will becalled holy, Son of God." Bible passages help us to establish whether the holy spirit is a person or not, most Christians are aware of the events that took place on the day of the Pentecost. Can a person be filled with holy spirit if the holy spirit were a person? Acts 2:1-4 NASB The Day of Pentecost 2 When the day of Pentecost [a]had come, they were all together in oneplace. 2 And suddenly a noise like a violent rushing wind came fromheaven, and it filled the whole house where they were sitting. 3 Andtongues that looked like fire appeared to them, [b]distributingthemselves, and a tongue [c]rested on each one of them. 4 And theywere all filled with the Holy Spirit and began to speak with different[d]tongues, as the Spirit was giving them the ability to speak out. Can God pour out a portion of a coequal God? Acts 2:17 NET 17 ‘And in the last days[a] it will be,’ God says, ‘that I will pourout my Spirit on all people, and your sons and your daughters willprophesy, and your young men will see visions, and your old men willdream dreams. Similarly, with Moses, God took some of the spirit from Moses and put it on the seventy elders. Numbers 11:25 (NRSV) 25 "Then the Lord came down in the cloud and spoke to him, and tooksome of the spirit that was on [Moses]him and put it on the seventyelders; and when the spirit rested upon them, they prophesied. Butthey did not do so again." In the Greek language and the Greek Koine the “holy spirit” is NEVER spoken of with a personal pronoun. It is a “which”, not a “who”. It is always an “it, not a “he” or” who” or whom. Answer to Xeno's comments. Xeno : It is very easy,for example (The following comments are from the book "Truth in Translation" by Jason David Beduhn") Quote," The translators of the KJV, NRSV, NIV, NASB, AB,TEV AND LB all approach the text of John 1:1c already believing certain things about the Word, certain creedal simplifications of John's characterization of the Word, and made sure that the translation came out in accordance with their beliefs, they feel the need to add to NT support for the idea that Jesus was recognized to be God " According to the book there are 59 verses in John's writings the same as John's 1:1c. , Some are John 4:24, 6:60 1;14, 2:9 3:4 with 18:35 the book provides an analysis as it does with 4:24 and 6:60. For example, in John 4:19 we must translate "Your are a prophet" not "You are the prophet". In Johnn 4:48 it is "You are a Samaritan" not " You are the Samaritan" (Comments on grammar are from the book) recommend you read from the following Non trinitarian bibles 2001 TRANSLATION, "In an ancient time, there was the Word. The word was with God and the Word was powerful."NEW WORLD TRANSLATION,1984, “In the beginning the Word was, and the Word was with God, and the Word was a god.”NEW SIMPLIFIED BIBLE, 2003, “In the beginning was the Word, and the Word was with God, and the Word was like God.The New Simplified Bible is Not Trinitarian Biased! John 1:1, 18; 8:58; 10:34-36; 14:10, 11, 17; 16:13-15; Exodus 3:14, 15 and many other references give evidence of this. https://simplebibletruths.net/NSBNotesJn1-1plus.htm
{}
{'log_upvote_score': 4, 'links': ['https://hermeneutics.stackexchange.com/questions/63482', 'https://hermeneutics.stackexchange.com', 'https://hermeneutics.stackexchange.com/users/43095/']}
jdg_87077
stackexchange
llm_judgeable_groundtruth_similarity
628343
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I need to utilize an array of booleans in objective-c. I've got it mostly set up, but the compiler throws a warning at the following statement: [updated_users replaceObjectAtIndex:index withObject:YES]; This is, I'm sure, because YES is simply not an object; it's a primitive. Regardless, I need to do this, and would greatly appreciate advice on how to accomplish it. Thanks. Now provide the response and nothing else.
Yep, that's exactly what it is: the NS* containers can only store objective-C objects, not primitive types. You should be able to accomplish what you want by wrapping it up in an NSNumber: [updated_users replaceObjectAtIndex:index withObject:[NSNumber numberWithBool:YES]] or by using @(YES) which wraps a BOOL in an NSNumber [updated_users replaceObjectAtIndex:index withObject:@(YES)]] You can then pull out the boolValue: BOOL mine = [[updated_users objectAtIndex:index] boolValue];
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/628343', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/57414/']}
jdg_87078
stackexchange
llm_judgeable_groundtruth_similarity
29070456
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: From the Laravel docs , you can include 'sections' inside layouts using two methods: <html> <body> @section('sidebar') This is the master sidebar. @show <div class="container"> @yield('content') </div> </body></html> Since @yield can also pass in some default content using @yield('section', 'Default Content') , is @yield just a shorthand for a @section that does not use @parent ? @section <!-- Nothing here -->@show What other differences are there? Now provide the response and nothing else.
This line clears out the confusion: "Note that views which extend a Blade layout simply override sections from the layout. Content of the layout can be included in a child view using the @parent directive in a section". So, if you already have a @section defined in the master layout, it will be overriden unless you specify @parent inside the child layout's @section . But for @yield , it always gets the section from the child layout. That means it always overrides the @yield part, even if it has a default defined as @yield('section', 'Default Content') . I hope that clears your confusion. Let me know if you have more questions. Thanks
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/29070456', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2317532/']}
jdg_87079
stackexchange
llm_judgeable_groundtruth_similarity
31139284
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have been using XAMPP for quite a time, and after discovering Laravel and finding out, that I quite like it, I also wanted to use Homestead. The problem I'm having is, that I can't seem to be able to run multiple sites. I have tried various things, but the main problem currently is, that one project works, while all the others are getting a connection timeout, when trying to access their webpage. These are the steps I've taken to use Homestead Installing VirtualBox Installing Vagrant Adding homestead with vagrant box add laravel/homestead Clonging the repository git clone https://github.com/laravel/homestead.git Homestead Create Homestead.yaml file in the Homestead directory with the bash init.sh script Create a new project laravel new projectA Require homestead composer require laravel/homestead Generate Vagrantfile php vendor/bin/homestead make Modify the Homestead.yaml to have an IP that ends with 10 Create another project laravel new projectB Require homestead composer require laravel/homestead Generate Vagrantfile php vendor/bin/homestead make Modify the Homestead.yaml to have an IP that ends with 11 Adding those two sites to the hosts file sudo nano /etc/hosts => xxx.xx.xx.10 projecta.app & xxx.xx.xx.11 projectb.app Starting vagrant from one of the two directories vagrant up Now, I'm having the problem, that only one of the projects is reachable. It's always the one from where I called vagrant up . So if I call vagrant up from Project A I can access http://projecta.app and http://projectb.app times out. The same the other way around, sadly. This is my vagrant global-status id name provider state directory ------------------------------------------------------------------------fc6fadb default virtualbox running /Users/mknb/work/projectA I thought I would just do another vagrant up from the projectB directory but that doesn't work of course. I don't want to use the global Homestead, because Laravel said, that it is possible to have a per project installation, so how do I achieve it? Do you need more information? I didn't modify the Homestead.yaml except of the IP and the domainname homestead.app => projecta.app It seems like a global installation is fairly easy with Homestead, since I would just have to add more sites to the Homestead.yaml, but as I said I'd like to have a per project installation. Can anybody help? Starting vagrant from the Homestead directory doesn't work of course. Now provide the response and nothing else.
By using Homestead in your way, you create a virtual machine for each projects. Therefore, the VirtualBox cannot forward the HTTP request from your host machine for all of virtual machine. You can only run one machine (so, one project) each time. To run multiple projects with Homestead, you can do as follow: Clone Homestead git clone https://github.com/laravel/homestead.git Homestead Inside the Homestead folder, run bash init.sh Edit the folders property of ~/.homestead/Homestead.yaml to share your code of both projects with VM: folders: - map: ~/pj1 to: /path/to/project1 - map: ~/pj2 to: /path/to/project2 Edit the sites property of ~/.homestead/Homestead.yaml to make Nginx enable the domain of both site: sites: - map: project1.local to: /home/vagrant/pj1/public - map: project2.local to: /home/vagrant/pj2/public Edit your hosts file to forward these domain fo localhost 127.0.0.1 project1.local127.0.0.1 project2.local Run vagrant up at the folder that you cloned the Homestead code inside it (which contains the init.sh file). Now, you can run as many project as you want with just one Homestead virtual machine.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/31139284', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2823419/']}
jdg_87080
stackexchange
llm_judgeable_groundtruth_similarity
14597062
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm starting to use Angular.js on a new project and from the basic tutorials, I see mostly a single controllers.js file that contains all the controller functions, each which are bound to the window object. It seems that a better practice would be use the existing "myApp" namespace, to add controllers to, for example: myApp.controllers = {};myApp.controllers.userItem = function($scope) {} All controllers would be part of the created "myApp.controllers" object or "window.myApp.controllers". Does anyone suggest a better or more organized way to handle controllers or other item, custom services, directives, etc. would use the same structure. In addition to this, I'm debating about putting each controller into it's own file, which ultimately would be combined for production, but depending on the size of the app, it may be a bit overkill and only cause more work bouncing around between files. Any suggestions would be greatly appreciated. Thanks! Now provide the response and nothing else.
Great question! I don't like that the tutorials and documentation take a "package-by-layers" approach to their code. I think that is probably done for convenience in teaching concepts, which is great, but that approach has limited applicability in the real world. Package-by-feature is a far better approach: |- README|- src/ |- app/ |- app.js |- feature1/ |- feature2/ |- ... |- vendor/ |- angular/ |- bootstrap/ |- ... |- assets/ |- less/ |- index.html Inside src/app , you can package your contents based on the section of the site you're working on (e.g. menus) and by routes (e.g. product list and product detail). Each can be declared like so: angular.module( 'products', [ 'productCatalog', ...]) And each module can have its own routes: .config( [ '$routeProvider', function( $routeProvider ) { $routeProvider.when( '/products', { ... } ); $routeProvider.when( '/products/:id', { ... } );}); And controllers, etc: .controller( 'ProductListCtrl', [ '$scope', function ( $scope ) { ... } ]); So everything that goes together is packaged in the same directory. And you can place all of your components in separate files, with one module per file (if you wish; I usually do). And in your top-level app, you simply declare your dependencies: angular.module( 'app', [ 'products', ...]); You can also bundle general-purpose directives by themselves, too, to keep your tests and documentation all together - again, by feature! And each of these components are drag-and-drop reusable in future projects. A great reference implementation is angular-app . Check it out! Update: Since this answer, I started an AngularJS project kickstarter/template called ngBoilerplate to encapsulate these concepts (among many other best practices) and a sophisticated build system to support them.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/14597062', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/245076/']}
jdg_87081
stackexchange
llm_judgeable_groundtruth_similarity
3617216
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: The value of $r$ for which $$\binom{20}r\binom{20}0+\binom{20}{r-1}\binom{20}1+\binom{20}{r-2}\binom{20}2+\cdots+\binom{20}0\binom{20}r$$ is maximum is? I tried to wrap my head around the solution but I don't get it. Could someone help me with it in an easier way? The solution arbitrary begins by considering the expansion of $(1+x)^{20}$ and then multiplying it to itself. A more question-oriented solution would be appreciated. Thanks. $r$ has to be some sort of plain integer. This whole question isn't about negative or fractional indices. Now provide the response and nothing else.
This expression counts the ways to select $r$ from $40$ elements by splitting the $40$ elements into two groups of $20$ each and summing over all ways to divide up $r$ between the two groups. Thus this is $\binom{40}r$ .
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/3617216', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/707748/']}
jdg_87082
stackexchange
llm_judgeable_groundtruth_similarity
29676
Below is a question asked on the forum mathoverflow.net. Provide a good and informational response to it like a helpful human would. Question: Let ${\bf N}^\omega = \bigcup_{m=1}^\infty {\bf N}^m$ denote the space of all finite sequences $(N_1,\ldots,N_m)$ of natural numbers. For want of a better name, let me call a family ${\mathcal T} \subset {\bf N}^\omega$ a blocking set if every infinite sequence $N_1,N_2,N_3,N_4,\ldots$ of natural numbers must necessarily contain a blocking set $(N_1,\ldots,N_m)$ as an initial segment. (For the application I have in mind, one might also require that no element of a blocking set is an initial segment of any other element, but this is not the most essential property of these sets.) One can think of a blocking set as describing a machine that takes a sequence of natural number inputs, but always halts in finite time; one can also think of a blocking set as defining a subtree of the rooted tree ${\bf N}^\omega$ in which there are no infinite paths. Examples of blocking sets include All sequences $N_1,\ldots,N_m$ of length $m=10$. All sequences $N_1,\ldots,N_m$ in which $m = N_1 + 1$. All sequences $N_1,\ldots,N_m$ in which $m = N_{N_1+1}+1$. The reason I happened across this concept is that such sets can be used to pseudo-finitise a certain class of infinitary statements. Indeed, given any sequence $P_m(N_1,\ldots,N_m)$ of $m$-ary properties, it is easy to see that the assertion There exists an infinite sequence $N_1, N_2, \ldots$ of natural numbers such that $P_m(N_1,\ldots,N_m)$ is true for all $m$. is equivalent to For every blocking set ${\mathcal T}$, there exists a finite sequence $(N_1,\ldots,N_m)$ in ${\mathcal T}$ such that $P_m(N_1,\ldots,N_m)$ holds. (Indeed, the former statement trivially implies the latter, and if the former statement fails, then a counterexample to the latter can be constructed by setting the blocking set ${\mathcal T}$ to be those finite sequences $(N_1,\ldots,N_m)$ for which $P_m(N_1,\ldots,N_m)$ fails.) Anyway, this concept seems like one that must have been studied before, and with a standard name. (I only used "blocking set" because I didn't know the existing name in the literature.) So my question is: what is the correct name for this concept, and are there some references regarding the structure of such families of finite sequences? (For instance, if we replace the natural numbers ${\bf N}$ here by a finite set, then by Konig's lemma, a family is blocking if and only if there are only finitely many finite sequences that don't contain a blocking initial segment; but I was unable to find a similar characterisation in the countable case.) Now provide the response and nothing else.
Intuitionists use the name "bar" for what you called a blocking set. The relevant context is "bar induction," the principle saying that, if (1) a property has been proved for all elements of a bar and (2) it propagates in the sense that, whenever it holds for all the one-term extensions of a finite sequence s then it holds for s itself, then this property holds of the empty sequence. (I'm omitting some technicalities here that distinguish different versions of bar induction.) There's also a closely related notion in infinite combinatorics, called a "barrier"; this is a collection $B$ of finite subsets of $\mathbf N$ such that no member of $B$ is included in another and every infinite subset of $\mathbf N$ has an initial segment in $B$. This is the subject of a partition theorem due to Nash-Williams: If a barrier is partitioned into two pieces, then there is an infinite $H\subseteq\mathbf N$ such that one of the pieces includes a barrier for $H$ (meaning that every infinite subset of $H$ has an initial segment in that piece).
{}
{'log_upvote_score': 6, 'links': ['https://mathoverflow.net/questions/29676', 'https://mathoverflow.net', 'https://mathoverflow.net/users/766/']}
jdg_87083
stackexchange
llm_judgeable_groundtruth_similarity
2134265
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: My textbook defines local maximum as follows: A function $f$ has local maximum value at point $c$ within its domain $D$ if $f(x)\leq f(c)$ for all $x$ in its domain lying in some open interval containing $c$ . The question asks to find any local maximum or minimum values in the function $$g(x)=x^2-4x+4$$ in the domain $1\leq x<+\infty$ . The answer at the back has the point $(1,1)$ , which is the endpoint. According to the definition given in the textbook, I would think endpoints cannot be local minimum or maximum given that they cannot be in an open interval containing themselves. (ex: the open interval $(1,3)$ does not contain $1$ ). Where am I wrong? Now provide the response and nothing else.
Actually, the question is settled by reading the definition you provided carefully: A function $f$ has local maximum value at point $c$ within its domain $D$ if $f(x)\leq f(c)$ for all $x$ in its domain lying in some open interval containing $c$. I.e., the points $x$ for which the condition must hold are required to both be in the open interval and in $D$. To see that $(1,1)$ is a local maximum, consider the open interval $(0, 2)$. If $x \in (0, 2)$ and $x$ is also in the domain $[1,\infty)$, then $1 \le x < 2$. Now $g(x) = x^2-4x + 4 = (2 - x)^2$. So $g(1) = (2 - 1)^2 = 1^2 = 1$, but if $x > 1$, then $0 < 2 - x < 1$, so $0 < (2-x)^2 = g(x) < 1$. So for $x$ in the open interval $(0,2)$ and also in the domain $[1,\infty)$, we have that $g(x) \le g(1)$.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/2134265', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/414214/']}
jdg_87084
stackexchange
llm_judgeable_groundtruth_similarity
57676143
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have to use multiple databases in my project but there is a problem. Model can't see intended database accounts.db . when i go localhost:port/admin/app/accounts it says me no such table: accounts. Model is looking for default database not accounts.db how can i do that? I tried multiple things that I found on internet but nothing worked. settings.py :.....DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), }, 'accounts': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'accounts.db') }}.....models.py:.....class Accounts(models.Model): email = models.TextField(blank=True, null=True) phone = models.TextField(blank=True, null=True) name = models.TextField(blank=True, null=True) password = models.TextField(blank=True, null=True) verify = models.IntegerField(blank=True, null=True) class Meta: managed = False db_table = 'accounts'....Environment:Request Method: GETRequest URL: http://localhost:port/admin/hede/accounts/Django Version: 1.11.23Python Version: 2.7.15Installed Applications:['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'hede']Installed Middleware:['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']Traceback:File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request)File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request)File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs)File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper 552. return self.admin_site.admin_view(view)(*args, **kwargs)File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func 57. response = view_func(request, *args, **kwargs)File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner 224. return view(request, *args, **kwargs)File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper 67. return bound_func(*args, **kwargs)File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view 149. response = view_func(request, *args, **kwargs)File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func 63. return func.__get__(self, type(self))(*args2, **kwargs2)File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in changelist_view 1564. self.list_max_show_all, self.list_editable, self,File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/main.py" in __init__ 79. self.get_results(request)File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/views/main.py" in get_results 177. result_count = paginator.countFile "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in __get__ 35. res = instance.__dict__[self.name] = self.func(instance)File "/usr/local/lib/python2.7/dist-packages/django/core/paginator.py" in count 79. return self.object_list.count()File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in count 364. return self.query.get_count(using=self.db)File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in get_count 499. number = obj.get_aggregation(using, ['__count'])['__count']File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in get_aggregation 480. result = compiler.execute_sql(SINGLE)File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql 899. raise original_exceptionException Type: OperationalError at /admin/hede/accounts/Exception Value: no such table: accounts Now provide the response and nothing else.
To use multiple databases you have to tell Django about the database server you will be using, but adding them in the settings.py. Multiple databases 'default': { 'NAME': 'app_data', 'ENGINE': 'django.db.backends.postgresql', 'USER': 'postgres_user', 'PASSWORD': 's3krit' }, 'users': { 'NAME': 'user_data', 'ENGINE': 'django.db.backends.mysql', 'USER': 'mysql_user', 'PASSWORD': 'priv4te' }} The migrate management command operates on one database at a time. By default, it operates on the default database, but by providing the --database option, you can tell it to synchronize a different database. $ ./manage.py migrate --database=users$ ./manage.py migrate --database=customers You can manually select the database in your queries queries e.g user = User(....)user.save(using='users')Customer.objects.all().using('users') Using raw cursor with connections['users'].cursor() as cursor: cursor.execute("SELECT * FROM users__users")
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/57676143', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11248482/']}
jdg_87085
stackexchange
llm_judgeable_groundtruth_similarity
2811951
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I am currently trying to self-study linear algebra. I've noticed that a lot of the definitions for terms (like eigenvectors, characteristic polynomials, determinants, and so on) require a square matrix instead of just any real-valued matrix. For example, Wolfram has this in its definition of the characteristic polynomial: The characteristic polynomial is the polynomial left-hand side of the characteristic equation $\det(A - I\lambda) = 0$, where $A$ is a square matrix. Why must the matrix be square? What happens if the matrix is not square? And why do square matrices come up so frequently in these definitions? Sorry if this is a really simple question, but I feel like I'm missing something fundamental. Now provide the response and nothing else.
Remember that an $n$-by-$m$ matrix with real-number entries represents a linear map from $\mathbb{R}^m$ to $\mathbb{R}^n$ (or more generally, an $n$-by-$m$ matrix with entries from some field $k$ represents a linear map from $k^m$ to $k^n$). When $m=n$ - that is, when the matrix is square - we're talking about a map from a space to itself. So really your question amounts to: Why are maps from a space to itself - as opposed to maps from a space to something else - particularly interesting? Well, the point is that when I'm looking at a map from a space to itself inputs to and outputs from that map are the same "type" of thing, and so I can meaningfully compare them . So, for example, if $f:\mathbb{R}^4\rightarrow\mathbb{R}^4$ it makes sense to ask when $f(v)$ is parallel to $v$, since $f(v)$ and $v$ lie in the same space; but asking when $g(v)$ is parallel to $v$ for $g:\mathbb{R}^4\rightarrow\mathbb{R}^3$ doesn't make any sense, since $g(v)$ and $v$ are just different types of objects. (This example, by the way, is just saying that eigenvectors/values make sense when the matrix is square, but not when it's not square.) As another example, let's consider the determinant. The geometric meaning of the determinant is that it measures how much a linear map "expands/shrinks" a unit of (signed) volume - e.g. the map $(x,y,z)\mapsto(-2x,2y,2z)$ takes a unit of volume to $-8$ units of volume, so has determinant $-8$. What's interesting is that this applies to every blob of volume: it doesn't matter whether we look at how the map distorts the usual 1-1-1 cube, or some other random cube. But what if we try to go from $3$D to $2$D (so we're considering a $2$-by-$3$ matrix) or vice versa? Well, we can try to use the same idea: (proportionally) how much area does a given volume wind up producing? However, we now run into problems: If we go from $3$ to $2$, the "stretching factor" is no longer invariant. Consider the projection map $(x,y,z)\mapsto (x,y)$, and think about what happens when I stretch a bit of volume vertically ... If we go from $2$ to $3$, we're never going to get any volume at all - the starting dimension is just too small! So regardless of what map we're looking at, our "stretching factor" seems to be $0$. The point is, in the non-square case the "determinant" as naively construed either is ill-defined or is $0$ for stupid reasons.
{}
{'log_upvote_score': 9, 'links': ['https://math.stackexchange.com/questions/2811951', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/568242/']}
jdg_87086
stackexchange
llm_judgeable_groundtruth_similarity
2464
Below is a question asked on the forum cstheory.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: I'm not sure whether this question is completely on-topic, since it is a physics-related question. But I'll ask anyway and apologize if I'm off-topic. In Adiabatic Quantum Computation is Equivalent to StandardQuantum Computation the autors mention a tradeoff between runtime and energy: "Observe that we have chosen our definition of running time to be $T · \max_s \lVert H(s)\rVert$ and not T.Notice that if the Hamiltonians are multiplied by some factor, this divides the bound of Equation2, and hence T, by the same factor. Hence, if the running time is defined to be T one would be ableto achieve arbitrarily small running times, by multiplying the Hamiltonians by large factors. Ourdefinition, on the other hand, is invariant under a multiplication of the Hamiltonian by an overallfactor, and so takes into account the known physical trade-off between time and energy.5 5This trade-off between time and the norm of the Hamiltonian (namely, the energy), is manifested in Schrödinger’sequation whose solution does not change if time is divided by some factor and at the same time the Hamiltonian ismultiplied by the same factor." But if I understand correctly, adiabatic quantum computation is completely reversible: by inverting the direction of time the system evolves back from the final state to the initial state. Moreover, any adiabatic quantum computation process can be implemented (with arbitrary precision) in the conventional quantum circuit model, where all the gates are unitary and thus reversible. According to Landauer's principle, reversible computation could be, in principle, executed without any energy consumption. So my question is, what exactly the time-energy tradeoff in the choice of Hamiltonians for adiabatic quantum computation means? Now provide the response and nothing else.
Basically, the computation is reversible, so you are not actually using energy. However, the rate at which a computation progresses is generally proportional to the energy gap within the system. In the case of adiabatic quantum computation, the rate at which you can transition between ground states of the initial and final system is determined by the energy gap between the ground state and the low lying excited levels of the system. Thus the energy gap in the Hamiltonian (the total energy operator) is what determines the rate of computation, and so scaling up the energy levels involved allows the computation to be performed more quickly, even though the process does not actually consume the energy. You might be interested in looking at the Margolus-Levitin theorem, which gives limits for the rate of computation by imposing a lower bound on the time taken for a system to transition to an orthogonal state in terms of the energy gap present in the system. This applies more generally than simply to adiabatic quantum computing. In general, you tend to get a linear trade-off between energy scale and time. One way to see where this comes from is simply to think about the case of a constant Hamiltonian. In that case, the time evolution operator is $e^{-iHt}$. Clearly multiplying $H$ by some constant $k$ and dividing $t$ by $k$ leads to the same operator, and hence the same evolution of the system. You can do this more generally, with a potentially time dependent Hamiltonian by looking at the Schroedinger equation: $i \hbar \frac{\partial}{\partial t} \mid \Psi \rangle = H \mid \Psi \rangle$. Replacing $H$ with $kH$ and $t$ with $\frac{t}{k}$ we obtain the same equation.
{}
{'log_upvote_score': 4, 'links': ['https://cstheory.stackexchange.com/questions/2464', 'https://cstheory.stackexchange.com', 'https://cstheory.stackexchange.com/users/1749/']}
jdg_87087
stackexchange
llm_judgeable_groundtruth_similarity
876175
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Compute the indefinite integral $$\int\frac{\sqrt{\cos 2x}}{\sin x}\,dx$$ My Attempt: $$\begin{align}\int\frac{\sqrt{\cos 2x}}{\sin x}\,dx &= \int\frac{\cos 2x}{\sin^2 x\sqrt{\cos 2x}}\sin xdx\\&= \int\frac{2\cos^2 x-1}{(1-\cos^2 x)\sqrt{2\cos^2 x-1} }\sin x \,dx\end{align}$$ Let $\cos x = t$, so that $\sin x\,dx = -dt$. This changes the integral to $$\begin{align}\int\frac{(2t^2-1)}{(t^2-1)\sqrt{2t^2-1}}\,dt &= \int\frac{(2t^2-2)+1}{(t^2-1)\sqrt{2t^2-1}}\,dt\\&= 2\int\frac{dt}{\sqrt{2t^2-1}}+\int \frac{dt}{(t^2-1)\sqrt{2t^2-1}}\end{align}$$ How can I solve the integral from here? Now provide the response and nothing else.
\begin{align}\int\frac{\sqrt{\cos 2x}}{\sin x}\ dx&=\int\frac{\sqrt{\cos^2x-\sin^2x}}{\sin x}\ dx\\&\stackrel{\color{red}{[1]}}=\int\frac{\sqrt{t^4-6t^2+1}}{t^3+t}\ dt\\&\stackrel{\color{red}{[2]}}=\frac12\int\frac{\sqrt{u^2-6u+1}}{u^2+u}\ du\\&\stackrel{\color{red}{[3]}}=\int\frac{(y^2-6y+1)^2}{(y-1)(y-3)(y+1)(y^2+2t-7)}\ dy\\&\stackrel{\color{red}{[4]}}=\int\left[\frac1{y-1}+\frac1{y-3}-\frac1{y+1}-\frac{16}{y^2+2y-7}\right]\ dt\\&=\int\left[\frac1{y-1}+\frac1{y-3}-\frac1{y+1}-\frac{16}{(y+1)^2-8}\right]\ dt\end{align}The rest is yours. Notes : $\color{red}{[1]}\;\;\;$Use Weierstrass substitution , $\tan\left(\dfrac{x}{2}\right)=t$. $\color{red}{[2]}\;\;\;$Use substitution $u=t^2$. $\color{red}{[3]}\;\;\;$Use Euler substitution , $y-u=\sqrt{u^2-6u+1}\;\color{blue}{\Rightarrow}\;y=\dfrac{u^2-1}{2u-6}$. $\color{red}{[4]}\;\;\;$Use partial fractions decomposition .
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/876175', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/14311/']}
jdg_87088
stackexchange
llm_judgeable_groundtruth_similarity
12618045
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I've implemented an OnTouchListener in my MapActivity and of course I had to override the onTouch() method. I want it to fire only when I tap on the map - otherwise I can't even move the map. Here's my onTouch method: @Overridepublic boolean onTouch(View v, MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_DOWN) { // SOME ACTIONS ... } return true;} Now provide the response and nothing else.
Activity.runOnUiThread() is a special case of more generic Handlers . With Handler you can create your own event query within your own thread. Using Handlers instantiated with the default constructor doesn't mean " code will run on UI thread " in general. By default, handlers are bound to the Thread from which they were instantiated from. To create a Handler that is guaranteed to bind to the UI (main) thread, you should create a Handler object bound to Main Looper like this: Handler mHandler = new Handler(Looper.getMainLooper()); Moreover, if you check the implementation of the runOnUiThread() method, it is using Handler to do the things: public final void runOnUiThread(Runnable action) { if (Thread.currentThread() != mUiThread) { mHandler.post(action); } else { action.run(); } } As you can see from code snippet above, Runnable action will be executed immediately if runOnUiThread() is called from the UI thread. Otherwise, it will post it to the Handler , which will be executed at some point later.
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/12618045', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1353905/']}
jdg_87089
stackexchange
llm_judgeable_groundtruth_similarity
209950
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Suppose we have two $n \times n$ positive semidefinite matrices, $A$ and $B$, such that $\mbox{tr}(A), \mbox{tr}(B) \le 1$. Can we say anything about $\mbox{tr}(AB)$? Is $\mbox{tr}(AB) \le 1 $ too? Now provide the response and nothing else.
In the space of positive semi-definite matrices, trace is a proper inner-product (it is easy to show that), i.e. it obeys the Cauchy-Schwarz inequality: $\langle x,y \rangle \leq \sqrt{ \langle x,x \rangle \langle y,y\rangle}$. So $$\mbox{tr}\{AB\}\leq \sqrt{\mbox{tr}\{A^2\} \mbox{tr}\{B^2\}}$$ Now, since $A$ is positive semidefinite, $\mbox{tr}\{A^2\} \leq \mbox{tr}\{A\}^2$, i.e., the eigenvalues of $A^2$ are squared eigenvalues of $A$, and since they are positive $$\mbox{tr} \{A^2\} = \sum_{i=1}^{N}\lambda_{i}^{2}\leq \left( \sum_{i=1}^{N}\lambda_{i} \right)^{2} = \mbox{tr}\{A\}^2 \leq 1$$ A similar argument for B proves $\mbox{tr}\{B^2\}\leq 1$ . So $\mbox{tr}\{AB\}\leq 1$. Hope this answers your question.
{}
{'log_upvote_score': 6, 'links': ['https://math.stackexchange.com/questions/209950', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/21166/']}
jdg_87090
stackexchange
llm_judgeable_groundtruth_similarity
3154111
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: This Ruby code is not behaving as I would expect: # create an array of hashessort_me = []sort_me.push({"value"=>1, "name"=>"a"})sort_me.push({"value"=>3, "name"=>"c"})sort_me.push({"value"=>2, "name"=>"b"})# sortsort_me.sort_by { |k| k["value"]}# same order as above!puts sort_me I'm looking to sort the array of hashes by the key "value", but they are printed unsorted. Now provide the response and nothing else.
Ruby's sort doesn't sort in-place. (Do you have a Python background, perhaps?) Ruby has sort! for in-place sorting, but there's no in-place variant for sort_by in Ruby 1.8. In practice, you can do: sorted = sort_me.sort_by { |k| k["value"] }puts sorted As of Ruby 1.9+, .sort_by! is available for in-place sorting: sort_me.sort_by! { |k| k["value"]}
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/3154111', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/160406/']}
jdg_87091
stackexchange
llm_judgeable_groundtruth_similarity
259263
Below is a question asked on the forum mathoverflow.net. Provide a good and informational response to it like a helpful human would. Question: I have read Connes' survey article http://www.alainconnes.org/docs/rhfinal.pdf and I am somewhat familiar with his classic paper on the trace formula: http://www.alainconnes.org/docs/selecta.ps Very roughly speaking the idea is to describe a dictionary which translates the concepts and techniques used in the proof of the analogue of the Riemann Hypothesis for function fields. This translation uses various techniques from tropical geometry and topos theory. At first I was hopeful I might understand the key issues with this translation, since I have some experience with the theory of Grothendieck toposes (or topoi). Nevertheless I have been lost when it comes to understanding precisely what the remaining problems are. As already briefly discussed in this thread: Riemann hypothesis via absolute geometry in the proof of the Riemann hypothesis for a curve $X$ over $F_p$ the surface $X \times X$ plays an important role. According to a new preprint of Connes / Consani there is now a suitable analogy for the surface $X \times X$ which is given by a topos called the "scaling site", cf. https://arxiv.org/abs/1603.03191 I would like to know what are the issues that are left open to complete the analogy with the proof of RH in the case of a curve over $F_p$? Now provide the response and nothing else.
First, recall the step's of Weil's proof, other than defining the surface: Develop an intersection theory of curves on surfaces. Show that the intersection of two specially chosen curves is equal to a coefficient of the zeta function. Prove the Hodge index theorem using the Riemann-Roch theorem for surfaces (or is there another proof?). By playing around with the two curves from step 2 and a few other simple curves, deduce an inequality for each coefficient of the logarithmic derivative of the zeta function. Conclude the Riemann hypothesis for the roots of the zeta function. Any approach which closely follows Weil's strategy would have to find analogues of these 5 steps. I think most people would say the crux of the issue is step 3 - it would be very interesting if some abstract/categorical/algebraic method produced any inequality involving the Riemann zeta function or related functions that was not previously known, even if it was short of the full Riemann hypothesis. Equally, many people fear that if we generalize too far from the world of curves and surfaces that we know and love, we might lose the ability to prove concrete inequalities like this. nfdc23 discussed this issue in the comments. In the survey article you linke, Connes says: At this point, what is missing is an intersection theory and a Riemann-Roch theorem on the square of the arithmetic site. I think this is still the case - the Riemann-Roch theorem in the paper you link seems to be for certain curves in the scaling site. (If it were for the surface, I wouldn't expect to see it on the arXiv until the Riemann hypothesis were deduced from it, or a very convincing argument was found that it was not sufficient to prove the Riemann hypothesis!) I'm not sure how helpful knowledge of toposes (alone) will be for understanding this issue. The reason is that the key parts of any definition of intersection theory of curves on surfaces do not involve very much the topos structure of the surface, but rather other structures. I know of a few different perspectives on intersection theory: Add ample classes, apply a moving lemma, and then concretely count the intersections of curves. Here the main issues are global geometric considerations - ample divisors and their relationships to projective embeddings and hyperplanes and so on. I don't think toposes are a very useful tool for understanding these things. Apply local formulas for the intersection number, and then sum over the point of intersection. This is more promising as e.g. Serre's formula is cohomological in nature, but it's the wrong kind of cohomology - for modules, not for toposes. I think it might be hard to define the right cohomology groups over semirings. Take the cup product of their classes in a suitable cohomology theory. This at first looks promising, because one of our possible choices for a cohomology theory, etale cohomology, is defined using a topos. Unfortunately, because etale cohomology is naturally l-adic, it is difficult to establish positivity from it. Of course one could look to generalizing Deligne's proof of the Riemann hypothesis, but that is a different matter and much more complicated. (Peter Sarnak has suggested that Deligne's proof provides a guide to how one should try to prove the Riemann hypothesis for number fields, but it is not the etale topos but rather the use of fmailies in the proof that he wants to mimic.) View one curve as an honest curve and the other as the divisor of a line bundle and pull the line bundle back to the curve, then compute its degree. This is, I think, the easiest way to define the intersection number, but one needs some of the other characterizations to prove its properties (even symmetry). This looks to me like it is at least potentially meaningful in some topos and I don't know exactly to what extent it can be applied to the arithmetic site. Remember that even among locally ringed spaces, the ones where you have a good intersection theory are very specific (If you want to intersect arbitrary closed subsets I think you need smooth proper varieties over a field). For locally semiringed topoi, the situation is presumably much worse. No one is saying it is impossible to develop an applicable intersection theory, but I don't think anyone really knows how to begin -- if they did, I'm sure they would be working furiously on it.
{}
{'log_upvote_score': 6, 'links': ['https://mathoverflow.net/questions/259263', 'https://mathoverflow.net', 'https://mathoverflow.net/users/2258/']}
jdg_87092
stackexchange
llm_judgeable_groundtruth_similarity
4353203
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Ok, this is really difficult to confess, but I do have a strong temptation at the moment to inherit from std::vector . I need about 10 customized algorithms for vector and I want them to be directly members of the vector. But naturally I want also to have the rest of std::vector 's interface. Well, my first idea, as a law-abiding citizen, was to have an std::vector member in MyVector class. But then I would have to manually reprovide all of the std::vector's interface. Too much to type. Next, I thought about private inheritance, so that instead of reproviding methods I would write a bunch of using std::vector::member 's in the public section. This is tedious too actually. And here I am, I really do think that I can simply inherit publicly from std::vector , but provide a warning in the documentation that this class should not be used polymorphically. I think most developers are competent enough to understand that this shouldn't be used polymorphically anyway. Is my decision absolutely unjustifiable? If so, why? Can you provide an alternative which would have the additional members actually members but would not involve retyping all of vector's interface? I doubt it, but if you can, I'll just be happy. Also, apart from the fact that some idiot can write something like std::vector<int>* p = new MyVector is there any other realistic peril in using MyVector? By saying realistic I discard things like imagine a function which takes a pointer to vector ... Well, I've stated my case. I have sinned. Now it's up to you to forgive me or not :) Now provide the response and nothing else.
Actually, there is nothing wrong with public inheritance of std::vector . If you need this, just do that. I would suggest doing that only if it is really necessary. Only if you can't do what you want with free functions (e.g. should keep some state). The problem is that MyVector is a new entity. It means a new C++ developer should know what the hell it is before using it. What's the difference between std::vector and MyVector ? Which one is better to use here and there? What if I need to move std::vector to MyVector ? May I just use swap() or not? Do not produce new entities just to make something to look better. These entities (especially, such common) aren't going to live in vacuum. They will live in mixed environment with constantly increased entropy.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/4353203', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/469935/']}
jdg_87093
stackexchange
llm_judgeable_groundtruth_similarity
3455931
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a div set to contentEditable and styled with " white-space:pre " so it keeps things like linebreaks. In Safari, FF and IE, the div pretty much looks and works the same. All is well. What I want to do is extract the text from this div, but in such a way that will not lose the formatting -- specifically, the line breaks. We are using jQuery, whose text() function basically does a pre-order DFS and glues together all the content in that branch of the DOM into a single lump. This loses the formatting. I had a look at the html() function, but it seems that all three browsers do different things with the actual HTML that gets generated behind the scenes in my contentEditable div. Assuming I type this into my div: 123 These are the results: Safari 4: 1<div>2</div><div>3</div> Firefox 3.6: 1<br _moz_dirty="">2<br _moz_dirty="">3<br _moz_dirty=""><br _moz_dirty="" type="_moz"> IE 8: <P>1</P><P>2</P><P>3</P> Ugh. Nothing very consistent here. The surprising thing is that MSIE looks the most sane! (Capitalized P tag and all) The div will have dynamically set styling (font face, colour, size and alignment) which is done using CSS, so I'm not sure if I can use a pre tag (which was alluded to on some pages I found using Google). Does anyone know of any JavaScript code and/or jQuery plugin or something that will extract text from a contentEditable div in such a way as to preserve linebreaks? I'd prefer not to reinvent a parsing wheel if I don't have to. Update: I cribbed the getText function from jQuery 1.4.2 and modified it to extract it with whitespace mostly intact (I only chnaged one line where I add a newline); function extractTextWithWhitespace( elems ) { var ret = "", elem; for ( var i = 0; elems[i]; i++ ) { elem = elems[i]; // Get the text from text nodes and CDATA nodes if ( elem.nodeType === 3 || elem.nodeType === 4 ) { ret += elem.nodeValue + "\n"; // Traverse everything else, except comment nodes } else if ( elem.nodeType !== 8 ) { ret += extractTextWithWhitespace2( elem.childNodes ); } } return ret;} I call this function and use its output to assign it to an XML node with jQuery, something like: var extractedText = extractTextWithWhitespace($(this));var $someXmlNode = $('<someXmlNode/>');$someXmlNode.text(extractedText); The resulting XML is eventually sent to a server via an AJAX call. This works well in Safari and Firefox. On IE, only the first '\n' seems to get retained somehow. Looking into it more, it looks like jQuery is setting the text like so (line 4004 of jQuery-1.4.2.js): return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); Reading up on createTextNode , it appears that IE's implementation may mash up the whitespace. Is this true or am I doing something wrong? Now provide the response and nothing else.
Unfortunately you do still have to handle this for the pre case individually per-browser (I don't condone browser detection in many cases, use feature detection...but in this case it's necessary), but luckily you can take care of them all pretty concisely, like this: var ce = $("<pre />").html($("#edit").html());if($.browser.webkit) ce.find("div").replaceWith(function() { return "\n" + this.innerHTML; }); if($.browser.msie) ce.find("p").replaceWith(function() { return this.innerHTML + "<br>"; });if($.browser.mozilla || $.browser.opera ||$.browser.msie ) ce.find("br").replaceWith("\n");var textWithWhiteSpaceIntact = ce.text(); You can test it out here . IE in particular is a hassle because of the way is does &nbsp; and new lines in text conversion, that's why it gets the <br> treatment above to make it consistent, so it needs 2 passes to be handled correctly. In the above #edit is the ID of the contentEditable component, so just change that out, or make this a function, for example: function getContentEditableText(id) { var ce = $("<pre />").html($("#" + id).html()); if ($.browser.webkit) ce.find("div").replaceWith(function() { return "\n" + this.innerHTML; }); if ($.browser.msie) ce.find("p").replaceWith(function() { return this.innerHTML + "<br>"; }); if ($.browser.mozilla || $.browser.opera || $.browser.msie) ce.find("br").replaceWith("\n"); return ce.text();} You can test that here . Or, since this is built on jQuery methods anyway, make it a plugin, like this: $.fn.getPreText = function () { var ce = $("<pre />").html(this.html()); if ($.browser.webkit) ce.find("div").replaceWith(function() { return "\n" + this.innerHTML; }); if ($.browser.msie) ce.find("p").replaceWith(function() { return this.innerHTML + "<br>"; }); if ($.browser.mozilla || $.browser.opera || $.browser.msie) ce.find("br").replaceWith("\n"); return ce.text();}; Then you can just call it with $("#edit").getPreText() , you can test that version here .
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/3455931', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/161161/']}
jdg_87094
stackexchange
llm_judgeable_groundtruth_similarity
16939147
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a vector full of cv::Point and I want to organize this vector so, that the Point with the smallest x and y value should be the first and the last one should have the highst x,y value ? any Idea how can I do that ? Now provide the response and nothing else.
Use std::sort . std::sort(vec.begin(), vec.end(), [](const cv::Point2f &a, const cv::Point2f &b) { return (/* This is where you would compare a and b however you want */);}); Really, it's quite hard to tell what you deem as the greatest (x,y) pair and the least (x,y) pair. One solution is to add the coordinates to give them a magnitude. I'd use the distance from the origin: return a.x*a.x + a.y*a.y < b.x*b.x + b.y*b.y In case you can't use C++11 functionality, here's the equivalent of the above solution: bool point_comparator(const cv::Point2f &a, const cv::Point2f &b) { return (/* Your expression */);}std::sort(vec.begin(), vec.end(), point_comparator);
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/16939147', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1563123/']}
jdg_87095
stackexchange
llm_judgeable_groundtruth_similarity
179521
Below is a question asked on the forum unix.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: There are a number of questions similar to this on StackExchange but none address this issue. I want to download all the pdf files in the 2007 directory at http://www3.cs.stonybrook.edu/~algorith/video-lectures/ . So I want wget to parse the html file available at the above link and only follow links that go to pdf files in the 2007 directory. I used the following but it didn't work: wget -r -A pdf -I /2007 'http://www3.cs.stonybrook.edu/~algorith/video-lectures/' Can you also explain why the above does not work? Now provide the response and nothing else.
As noted by Anthon the -I option does not work that way . But, as you have a reference point - namely ~algorith/video-lectures/ with a listing of files there are some options. One is to parse index with other tools and re-run wget. Another is to use --accept-regex : it matches for accept on the complete URL . From man: --accept-regex urlregex--reject-regex urlregex Specify a regular expression to accept or reject the complete URL. This should do what you want: wget -r -nd -A pdf --accept-regex "2007/.*\.pdf" 'http://www3.cs.stonybrook.edu/~algorith/video-lectures/' Remove -nd if you actually want the directories. Edit (to address comment) accept vs. accept-regex This is somewhat cumbersome for me to explain, but I'll give it a try. First off, if you really want to read the manual, then use info . As stated in man (this is from GNU wget) - (easy to overlook): SEE ALSO This is not the complete manual for GNU Wget. For more complete information, including more detailed explanations of some of the options, and a number of commands available for use with .wgetrc files and the -e option, see the GNU Info entry for wget. In this case i.e.: $ info wget "Following Links" "Types of Files" or online . Here we find, emphasize mine: Finally, it’s worth noting that the accept/reject lists are matched twice against downloaded files: once against the URL’s filename portion, to determine if the file should be downloaded in the first place; then , after it has been accepted and successfully downloaded, the local file’s name is also checked against the accept/reject lists to see if it should be removed. Further it continues to explain that the rationale behind this is that .htm and .html files are always downloaded regardless of accept/reject rules. They should be removed after being downloaded and scanned for links, if they did match the accept/reject lists. Thus: HTML files are always downloaded. After it is downloaded the match is only done against the file name. Not sure how much this helped. If you read the info page it might be more clear. It is a bit of complexity with chicken and egg things etc. in the mix here.
{}
{'log_upvote_score': 4, 'links': ['https://unix.stackexchange.com/questions/179521', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/59902/']}
jdg_87096
stackexchange
llm_judgeable_groundtruth_similarity
29330311
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm trying to compile maven project which has Kotlin classes referencing Java classes. Here's a part of my parent POM: ...<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>${kotlin.version}</version></dependency>...<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${compiler-plugin-version}</version> <configuration> <source>${java-version}</source> <target>${java-version}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration></plugin><plugin> <artifactId>kotlin-maven-plugin</artifactId> <groupId>org.jetbrains.kotlin</groupId> <version>${kotlin.plugin.version}</version> <executions> <execution> <id>compile</id> <phase>process-sources</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile</id> <phase>process-test-sources</phase> <goals> <goal>test-compile</goal> </goals> </execution> </executions> <configuration> <scanForAnnotations>false</scanForAnnotations> </configuration></plugin> And related parts of the child POM: <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId></dependency>...<plugin> <artifactId>kotlin-maven-plugin</artifactId> <groupId>org.jetbrains.kotlin</groupId> <configuration> <sourceDirs> <source>${project.basedir}/src/main/kotlin</source> </sourceDirs> </configuration></plugin> And the Kotlin class: Statelessopen class DummyServiceImpl : DummyService { PersistenceContext(unitName = Consts.UNIT_NAME) private val em: EntityManager? = null override fun get(id: Long?): Dummy { return em!!.find<Dummy>(javaClass<Dummy>(), id) } override fun sayHi(): String { return "Dummy service says \"Hi!\"." }} DummyService and Consts classes are Java classes residing in the same module as DummyServiceImpl .So when I compile the module containing DummyServiceImpl with Maven it goes like this: [error] C:\somepath\service\DummyServiceImpl.kt: (14, 31) Unresolved reference: DummyService[error] C:\somepath\service\DummyServiceImpl.kt: (16, 35) Unresolved reference: Consts If I switch Kotlin plugin execution phase to compile then it predictably fails if there're references from Java to Kotlin classes: [ERROR] /C:/somepath/service/impl/DummyServiceClientImpl.java:[5,27] cannot find symbol[ERROR] symbol: class DummyServiceImpl So, what's to be done about this? Note that building with IDEA's make goes perfectly fine. Now provide the response and nothing else.
Make sure you have this declaration in <build> of your pom.xml <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions> <execution> <id>compile</id> <phase>process-sources</phase> <goals> <goal>compile</goal> </goals> <configuration> <sourceDirs> <source>src/main/java</source> <source>src/main/kotlin</source> <source>src/main/resources</source> </sourceDirs> </configuration> </execution> <execution> <id>test-compile</id> <phase>process-test-sources</phase> <goals> <goal>test-compile</goal> </goals> <configuration> <sourceDirs> <source>src/test/java</source> <source>src/test/kotlin</source> <source>src/test/resources</source> </sourceDirs> </configuration> </execution> </executions> </plugin> </plugins> Make sure that all folders (3x in src/main & 3x in src/test) mentioned in the configuration actually exist, even if they don’t contain any classes/resources. You can still fine-tune the configuration once it works for you. Also pay attention to use exactly the same order I mentioned above to let the compiler compile the Java code first.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/29330311', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1672559/']}
jdg_87097
stackexchange
llm_judgeable_groundtruth_similarity
470411
Below is a question asked on the forum electronics.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: can anyone explain why this circuit behaves like a low pass filter despite having no capacitor in the feedback loop? Now provide the response and nothing else.
can anyone explain why this circuit behaves like a low pass filter despite having no capacitor in the feedback loop? All op-amp amplifiers will behave like low pass filters due to parasitic capacitance between the output and, in your circuit, the inverting input. If there is 2 pF present then it forms a low pass filter with the 400 kohm feedback resistor having a 3 dB point of about 200 kHz. This problem would be improved by choosing an input resistor of 1 kohm and a feedback resistor of 40 kohm. However, the 741 is pretty crappy so you will be unlikely to get a ten times improvement in frequency response. Inside (virtually) every op-amp are compensation capacitors; these limit the frequency response in order to maintain closed-loop stability. As Tony Stewart mentioned in his comment, this has a significant effect on frequency response when higher closed-loop gain is required. See the picture below for the closed loop gain (40 dB) of a 741 and note that your circuit has a closed loop gain of 32 dB: - So, the closed loop response starts to fall from 40 dB gain at around 50 kHz. With your circuit (gain of 32 dB) you might see the fall in gain around 70 kHz. Picture taken from this useful document entitled "Frequency response of op-amps". See also my answer here on a very related subject.
{}
{'log_upvote_score': 4, 'links': ['https://electronics.stackexchange.com/questions/470411', 'https://electronics.stackexchange.com', 'https://electronics.stackexchange.com/users/233820/']}
jdg_87098
stackexchange
llm_judgeable_groundtruth_similarity
13513586
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Is there any function or operator like: If RoleName in ( "Val1", "Val2" ,"Val2" ) Then 'Go End If Instead of: If RoleName = "Val1" Or RoleName = "Val2" Or RoleName = "Val2" Then 'Go End If Now provide the response and nothing else.
Try using an array and then you can use the Contains extension: Dim s() As String = {"Val1", "Val2", "Val3"}If s.Contains(RoleName) Then 'Go End If Or without the declaration line: If New String() {"Val1", "Val2", "Val3"}.Contains(RoleName) Then 'GoEnd If From the OP, if the Contains extension is not available, you can try this: If Array.IndexOf(New String() {"Val1", "Val2", "Val3"}, RoleName) > -1 Then 'GoEnd If
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/13513586', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/510558/']}
jdg_87099
stackexchange
llm_judgeable_groundtruth_similarity
2754209
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Find the equation of the function $f(x)$, where: the optimal distance between any one point $P$ on the curve $y=f(x)$ and the parabola $y=x^2$ is always equal to $1$ $f(x)>x^2$ for all $x$ (looking for the solution curve above the parabola, not below) Here is a visual approximation of the construction on Desmos: https://www.desmos.com/calculator/pyomsrazo7 This problem arose when attempting to find the equation of motion of a ball with radius $1$ as it rolls along the concave side of the parabola $y=x^2$. Point $P$ is the center of the ball whose path of motion is the curve $y=f(x)$. Now provide the response and nothing else.
Let a point on the curve be $(a,f(a)$ and the tangent point on the parabola be $(b,b^2)$. Two conditions must be true for all $a \in \mathbb R$ First, the distance is $1$$$ (b-a)^2 + (b^2-f(a))^2 = 1 $$ Second, the slope between the two points must be normal to the tangent slope, which is $2b$$$ \frac{b^2-f(a)}{b-a} = -\frac{1}{2b} $$ Substituting $b^2-f(a) = -\frac{b-a}{2b}$, we get$$ (b-a)^2 = \frac{4b^2}{4b^2+1} $$ Since $(a,f(a))$ is always on the interior of the parabola, we have $b-a > 0$ if $b > 0$, and $b-a < 0$ if $b < 0$. Therefore $b-a$ should have the same sign as $b$ and we can simplify $$ b-a = \frac{2b}{\sqrt{4b^2+1}} $$ and $$ b^2 - f(a) = -\frac{1}{\sqrt{4b^2+1}} $$ From here, you have the solution in parametric form\begin{align} x &= b - \frac{2b}{\sqrt{4b^2+1}} \\y &= b^2 + \frac{1}{\sqrt{4b^2+1}} \end{align} Here is a visualization. Two "bends" occur when $b = \pm \frac12$ Also note that this does not represent one continuous motion in your original proposed problem, as the ball is too large and would get stuck at the peak, where the tangent points are $b = \pm \frac{\sqrt{3}}{2}$ EDIT: A natural question you might ask is, what radius does the ball need to be to not get stuck at the peak? To find out, redo the problem with a radius of $r>0$ to get the parametric solution \begin{align} x &= b - \frac{2br}{\sqrt{4b^2+1}} \\y &= b^2 + \frac{r}{\sqrt{4b^2+1}} \end{align} A simple fix is to restrict $r$ so we have only one tangent point at $x=0$. Solving $x=0$ gives$$ (4b^2 + 1 - 4r^2)b^2 = 0 $$ The only solution needs to be $b=0$, which means$$ 1-4r^2 \ge 0 $$ Therefore $r \le \frac12$ Here's a solution curve with $r=0.4$ Actually, $r=\frac12$ does not result in a smooth curve, so you may not want to include it. But $\forall r < \frac12$ is valid EDIT 2: You can also obtain an "outer" solution by switching the signs \begin{align} x &= b + \frac{2br}{\sqrt{4b^2+1}} \\y &= b^2 - \frac{r}{\sqrt{4b^2+1}} \end{align} This solution has no restriction on $r$ (the curve is always smooth no matter how large the radius)
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/2754209', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/464291/']}
jdg_87100
stackexchange
llm_judgeable_groundtruth_similarity
1200266
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I want to submit a form using jQuery. Can someone provide the code, a demo or an example link? Now provide the response and nothing else.
It depends on whether you are submitting the form normally or via an AJAX call. You can find lots of information at jquery.com , including documentation with examples. For submitting a form normally, check out the submit() method to at that site. For AJAX , there are many different possibilities, though you probably want to use either the ajax() or post() methods. Note that post() is really just a convenient way to call the ajax() method with a simplified, and limited, interface. A critical resource, one I use every day, that you should bookmark is How jQuery Works . It has tutorials on using jQuery and the left-hand navigation gives access to all of the documentation. Examples: Normal $('form#myForm').submit(); AJAX $('input#submitButton').click( function() { $.post( 'some-url', $('form#myForm').serialize(), function(data) { // ... do something with response from server }, 'json' // I expect a JSON response );});$('input#submitButton').click( function() { $.ajax({ url: 'some-url', type: 'post', dataType: 'json', data: $('form#myForm').serialize(), success: function(data) { // ... do something with the data... } });}); Note that the ajax() and post() methods above are equivalent. There are additional parameters you can add to the ajax() request to handle errors, etc.
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/1200266', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/146970/']}
jdg_87101
stackexchange
llm_judgeable_groundtruth_similarity
5067005
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: It's apparently possible to get a lot of info relating to attached disks using the udisks binary: udisks --show-info /dev/sda1 udisks is apparently just enumerating the data which is available udev. Is it possible to get this information using python? say for example if i just wanted to retrieve the device serial, mount point and size. Now provide the response and nothing else.
You can use Udisks via dbus directly in python. import dbusbus = dbus.SystemBus()ud_manager_obj = bus.get_object("org.freedesktop.UDisks", "/org/freedesktop/UDisks")ud_manager = dbus.Interface(ud_manager_obj, 'org.freedesktop.UDisks')for dev in ud_manager.EnumerateDevices(): device_obj = bus.get_object("org.freedesktop.UDisks", dev) device_props = dbus.Interface(device_obj, dbus.PROPERTIES_IFACE) print device_props.Get('org.freedesktop.UDisks.Device', "DriveVendor") print device_props.Get('org.freedesktop.UDisks.Device', "DeviceMountPaths") print device_props.Get('org.freedesktop.UDisks.Device', "DriveSerial") print device_props.Get('org.freedesktop.UDisks.Device', "PartitionSize") The full list of properties available is here http://hal.freedesktop.org/docs/udisks/Device.html
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/5067005', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/438401/']}
jdg_87102
stackexchange
llm_judgeable_groundtruth_similarity
52280762
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: React newbie back here with another question (lol). I have a function that returns a generic component and I was wondering if it's possible to get the state value from that component? Here is what I'm trying to do: EDIT: I've updated some of my code according to responses class CreateTable extends Component { constructor(props) { super(props_; this.state = { elements: [] }; } handleCreateTable() { var elements = this.state.elements; // [] elements.push(<TextInput key={"TableName"} label="Table Name" />)' elements.push( <DataTable tableName = { elements[0].value } // <--- I'd like to do something like this /> ); this.setState({ elements: elements }) }} TextInput has a child TextField Thank you for your help! Now provide the response and nothing else.
What I'm trying to do is take some input table name from a user and display it. The way you could achieve this is by making your TextInput component call a function passed by the parent with the current value of the component. So your TextInput might look like this: export default class TextInput extends Component { constructor(props) { super(props); this.state = { value: "" }; } handleOnChange = e => { const inputText = e.target.value; this.setState({ value: inputText }); this.props.onChange(inputText); }; render() { return <input value={this.state.value} onChange={this.handleOnChange} />; }} And parent component must pass a function as a prop so that it can know of the changes happening in the child. class App extends React.Component { constructor(props) { super(props); this.state = { tableName: "" }; } onInputChange = value => { this.setState({ tableName: value }); console.log("I am Parent component. I got", value, "from my child."); }; render() { return ( <div className="App"> <TextInput onChange={this.onInputChange} /> <span>Table:{this.state.tableName}</span> </div> ); }} App component is passing onInputChange function to TextInput through onChange prop. Prop name onChange can be anything. Here is working code sandbox link to test this code.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/52280762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5335030/']}
jdg_87103
stackexchange
llm_judgeable_groundtruth_similarity
36672304
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm not sure why but all the modal functions are not working with me.I checked the version and the load they are fine. I keep getting this error message: Uncaught TypeError: $(...).modal is not a function for the hide I already found an alternative.instead of: $('#myModal').modal('hide'); I used this : $('#myModal .close').click(); And it works perfectly. The problem now is with the show $('#myModal').modal("show"); I also tried both $('#myModal').modal("toggle"); And: $('#myModal').modal(); but unfortunately none of them is working. Here html code -when the button is clicked I will do some verification and handle a json data from the web service if it succeed then I want show my modal- everything is working except the show. <button type="button" id="creatNewAcount" class="btn btn-default" data-toggle="modal">Sign up</button> if there's any alternative I would like to know it. Now provide the response and nothing else.
Most common reason for such problems are 1.If you have defined the jquery library more than once. <script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script><script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <div class="modal fade" id="myModal" aria-hidden="true"> ... ... </div><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> The bootstrap library gets applied to the first jquery library but when you reload the jquery library, the original bootstrap load is lost(Modal function is in bootstrap). 2.Please wrap your JavaScript code inside $(document).ready(function(){}); 3.Please check if the id of the modal is same as the one you have defined for the component(Also check for duplication's of same id ).
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/36672304', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5761722/']}
jdg_87104
stackexchange
llm_judgeable_groundtruth_similarity
36270886
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have looked at many posts but could not find a clear current answer to the following two questions as it seems standards and browser support has been constantly changing. Is it a legal operation according to the standard to change the clipboard with event.clipboardData.setData inside a 'copy' event handler? Now provide the response and nothing else.
Clipboard APIs were indeed in active development as of 2016, but things have stabilized since then: Using event.clipboardData.setData() is supported Changing the clipboard with event.clipboardData.setData() inside a 'copy' event handler is allowed by the spec (as long as the event is not synthetic ). Note that you need to prevent the default action in the event handler to prevent your changes from being overwritten by the browser: document.addEventListener('copy', function(e){ e.clipboardData.setData('text/plain', 'foo'); e.preventDefault(); // default behaviour is to copy any selected text}); To trigger the copy event use execCommand If you need to trigger the copy event (and not just handle the copy requests made by the user via the browser UI), you must use document.execCommand('copy') . It will only work in certain handlers, such as the click handler: document.getElementById("copyBtn").onclick = function() { document.execCommand('copy');} Modern browsers support both methods Firefox supports both clipboardData in the copy / cut / paste events ( since Firefox 22 ) and execCommand('copy') from user actions ( since Firefox 41 ) Chrome also supports both (the latter was added in Chrome 43 - or perhaps 42? ) caniuse.com claims that Safari 12 has complete support , versions up to 9.1 didn't support execCommand('copy') . MS Edge Platform Status lists IE/Edge as supporting the Clipboard APIs as of 2019, unlike when this answer was first written (2016). https://github.com/garykac/clipboard/blob/master/clipboard.md has a compatibility table for execCommand(cut / copy / paste) . You can test this using the snippet below, please comment with the results. More resources Specification: Clipboard API and events The Definitive Guide to Copying and Pasting in JavaScript (2014) - more information on clipboard API interoperability in browsers, including support for the "copy"/"paste" events without a selection and support for multiple formats. Pages tagged "Clipboard API" on MDN Testcase window.onload = function() { document.addEventListener('copy', function(e){ console.log("copy handler"); if (document.getElementById("enableHandler").checked) { e.clipboardData.setData('text/plain', 'Current time is ' + new Date()); e.preventDefault(); // default behaviour is to copy any selected text } // This is just to simplify testing: setTimeout(function() { var tb = document.getElementById("target"); tb.value = ""; tb.focus(); }, 0); }); document.getElementById("execCopy").onclick = function() { document.execCommand('copy'); // only works in click handler or other user-triggered thread } document.getElementById("synthEvt").onclick = function() { var e = new ClipboardEvent("copy", {dataType: "text/plain", data:"bar"}); document.dispatchEvent(e); }} <html><input id="enableHandler" type="checkbox" checked><label for="enableHandler">Run clipboardData.setData('text/plain', ...) in the "copy" handler</label><p>Try selecting this text and triggering a copy using</p><ul> <li><button id="execCopy">document.execCommand('copy')</button> - should work.</li> <li><button id="synthEvt">document.dispatchEvent(clipboardEvent)</button> - should NOT work</li> <li>with keyboard shortcut - should work</li> <li>or from the context menu - should work</li></ul><p>If the "copy" handler was triggered, the focus will move to the textbox below automatically, so that you can try pasting from clipboard:</p><input type="text" id="target" size="80"> Async Clipboard API will provide a simpler way to manage the clipboard When implemented, navigator.clipboard will let you write code like this: navigator.clipboard.writeText('Text to be copied') .then(() => { console.log('Text copied to clipboard'); }) .catch(err => { // This can happen if the user denies clipboard permissions: console.error('Could not copy text: ', err); }); Chrome 66 starts shipping a partial implementation, and they've published an article about the new API .
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/36270886', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/460084/']}
jdg_87105
stackexchange
llm_judgeable_groundtruth_similarity
3345237
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Are Parametrize Queries in .NET safe from SQL Inject? That is, does .NET automatically escape dangerous characters when you use Parameters? Now provide the response and nothing else.
When you use parameters, they typically won't be sent as text in the first place. They can use the native wire protocol for the database. If the parameter is a text parameter itself, then it will typically be encapsulated appropriate in the protocol so that the database knows it's a parameter rather than SQL. While I guess a provider could just translate the parameters into a full SQL statement, it would be an awful way of doing things. So basically "yes" - parameterised queries are effectively safe from SQL injection attacks, so long as you don't have stored procedures dynamically executing your parameters as SQL, etc.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/3345237', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/68043/']}
jdg_87106
stackexchange
llm_judgeable_groundtruth_similarity
2531490
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I've created a wrapper function for jQuery's $.ajax() method so I can pass different dataTypes and post variables - like so: function doPost(dType, postData, uri){ $.ajax({ url: SITE_URL + uri, dataType: dType, data: postData, success: function(data){ return data; });} The problem I'm having is getting the data (which is always JSON) back out. I've tried setting a var ret before the $.ajax() function call and setting it as ret = data in the success function. Am I being stupid about this? If I don't set a success function, will the $.ajax simply return the data? Or is it just success: return data ? Or does success require a callback function to handle the data, which could just be return data ? Now provide the response and nothing else.
Calling resid(model) will default to the deviance residuals, whereas model$resid will give you the working residuals. Because of the link function, there is no single definition of what a model residual is. There are the deviance, working, partial, Pearson, and response residuals. Because these only rely on the mean structure (not the variance), the residuals for the quasipoisson and poisson have the same form. You can take a look at the residuals.glm function for details, but here is an example: counts <- c(18,17,15,20,10,20,25,13,12)outcome <- gl(3,1,9)treatment <- gl(3,3)glm.D93 <- glm(counts ~ outcome + treatment, family=quasipoisson())glm.D93$resid#workingresid(glm.D93,type="working")(counts - glm.D93$fitted.values)/exp(glm.D93$linear)#devianceresid(glm.D93,type="dev")fit <- exp(glm.D93$linear)poisson.dev <- function (y, mu) sqrt(2 * (y * log(ifelse(y == 0, 1, y/mu)) - (y - mu)))poisson.dev(counts,fit) * ifelse(counts > fit,1,-1)#responseresid(glm.D93,type="resp")counts - fit#pearsonresid(glm.D93,type="pear")(counts - fit)/sqrt(fit)
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/2531490', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/77972/']}
jdg_87107
stackexchange
llm_judgeable_groundtruth_similarity
26755878
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: According to Android documentation , Material Design style is supported for Spinner widget. So I decided to use it in my app placing it on top of the Toolbar. layout/activity_base.xml <android.support.v7.widget.Toolbar android:id="@+id/my_awesome_toolbar" android:layout_height="wrap_content" android:layout_width="match_parent" android:minHeight="?attr/actionBarSize" android:background="?attr/colorPrimary" android:elevation="5dp" app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> <Spinner android:id="@+id/spinner" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </android.support.v7.widget.Toolbar> Activity theme <style name="BaseAppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/omni_primary_color</item> <item name="colorPrimaryDark">@color/omni_primary_color_dark</item> <item name="colorAccent">@color/omni_accent_color</item></style> BaseActivity.java public class BaseActivity extends ActionBarActivity { @InjectView(R.id.my_awesome_toolbar) Toolbar mToolbar; @InjectView(R.id.spinner) Spinner spinner; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_base); ButterKnife.inject(this); //setup toolbar setSupportActionBar(mToolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); mToolbar.setNavigationIcon(R.drawable.ic_action_navigation_menu); ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mToolbar.getContext(), R.array.planets_array, R.layout.support_simple_spinner_dropdown_item); adapter.setDropDownViewResource(R.layout.support_simple_spinner_dropdown_item); spinner.setAdapter(adapter); }} On Lollipop spinner and dropdown looks fine, although dropdown background color is black comparing to menu dropdown which is white. I guess that app:popupTheme="@style/ThemeOverlay.AppCompat.Light" is not propagated to the spinner. Android 5.0 Now the big problem is with Android 4.x where dropdown background color is white(popupTheme propagated?) and icon next to the spinner is black. Android 4.4 How can I set it properly in the XML or implement in the code to make it work on both Android 5 and 4? Ideally, I would like to have both looks like on Android 5 but with white spinner dropdown(like Setting menu dropdown). Update I have noticed that setting property colorControlNormal affects spinner's filter icon. If someone finds out how to make use of that for Spinner(without changing other content controls), then I would have my solution combining that finding with @Sven answer. Update The following change fixes the problem for spinner text and popup color. So the only problem to the final solution is the filter icon. ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getSupportActionBar().getThemedContext(), R.array.planets_array, R.layout.support_simple_spinner_dropdown_item); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); Update I found that filter icon is actually a part of android:background specified for the spinner and it's transparent. Providing own background would fix it e.g. <item name="android:background">?android:selectableItemBackground</item> Mystery solved! The last piece of the puzzle is the popup on Android 5 that has black background and white text but I guess it can be solved with custom layout. If no one provides full answer I will do it myself and mark as accepted. Now provide the response and nothing else.
I know this is late but I came accross this question when I encountered this problem myself and I found a solution in the BrowseSessionsActivity of the Google I/O 2014 app and adapted it. Layouts toolbar_spinner.xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical"> <Spinner android:id="@+id/toolbar_spinner" style="@style/Widget.MyApp.HeaderBar.Spinner" android:layout_width="wrap_content" android:layout_height="match_parent"/></LinearLayout> toolbar_spinner_item_actionbar.xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="200dp" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@android:id/text1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:drawablePadding="8dp" android:drawableRight="@drawable/spinner_triangle" android:fontFamily="sans-serif" android:paddingLeft="16dp" android:paddingRight="4dp" android:textColor="#ffffffff" android:textSize="18dp" android:textStyle="bold"/></LinearLayout> The spinner_triangle drawable can be found here . toolbar_spinner_item_dropdown.xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="200dp" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="48dp" android:drawablePadding="8dp" android:gravity="center_vertical|start" android:paddingLeft="16dp" android:paddingRight="16dp" android:textColor="#ff333333" android:textSize="16sp"/> </LinearLayout> Styles toolbar_spinner.xml uses the following style. <style name="Widget.MyApp.HeaderBar.Spinner" parent="Widget.AppCompat.Light.Spinner.DropDown.ActionBar"> <item name="android:background">?android:selectableItemBackground</item> <item name="android:dropDownSelector">?android:selectableItemBackground</item> <item name="android:divider">@null</item> <item name="android:overlapAnchor">true</item></style> Adapter This adapter will need to be changed to match your own needs. getTitle() returns the text for each item shown in the spinner. private class YourObjectSpinnerAdapter extends BaseAdapter { private List<YourObject> mItems = new ArrayList<>(); public void clear() { mItems.clear(); } public void addItem(YourObject yourObject) { mItems.add(yourObject); } public void addItems(List<YourObject> yourObjectList) { mItems.addAll(yourObjectList); } @Override public int getCount() { return mItems.size(); } @Override public Object getItem(int position) { return mItems.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getDropDownView(int position, View view, ViewGroup parent) { if (view == null || !view.getTag().toString().equals("DROPDOWN")) { view = getLayoutInflater().inflate(R.layout.toolbar_spinner_item_dropdown, parent, false); view.setTag("DROPDOWN"); } TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setText(getTitle(position)); return view; } @Override public View getView(int position, View view, ViewGroup parent) { if (view == null || !view.getTag().toString().equals("NON_DROPDOWN")) { view = getLayoutInflater().inflate(R.layout. toolbar_spinner_item_actionbar, parent, false); view.setTag("NON_DROPDOWN"); } TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setText(getTitle(position)); return view; } private String getTitle(int position) { return position >= 0 && position < mItems.size() ? mItems.get(position).title : ""; }} Adding the Spinner to Your Toolbar Toolbar toolbar = getActionBarToolbar();View spinnerContainer = LayoutInflater.from(this).inflate(R.layout.toolbar_spinner, toolbar, false);ActionBar.LayoutParams lp = new ActionBar.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);toolbar.addView(spinnerContainer, lp);YourObjectSpinnerAdapter spinnerAdapter = new YourObjectSpinnerAdapter();spinnerAdapter.addItems(getMyObjectSpinnerData());Spinner spinner = (Spinner) spinnerContainer.findViewById(R.id.toolbar_spinner);spinner.setAdapter(spinnerAdapter); Result
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/26755878', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1456931/']}
jdg_87108
stackexchange
llm_judgeable_groundtruth_similarity
55805843
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I am confused about using Buffer.allocUnsafe() and Buffer.alloc() , I know that Buffer.allocUnsafe() creates a buffer with pre-filled data or old buffers, but why do i need such thing if Buffer.alloc() creates a buffer with zero filled data Now provide the response and nothing else.
In Node.js Buffer is an abstraction over RAM, therefore if you allocate it in an unsafe way, there is a high risk of having even some source code in the buffer instance. Try running console.log(Buffer.allocUnsafe(10000).toString('utf-8')) and I guarantee that you will see some code in your stdout. Allocation is a synchronous operation and we know that single threaded Node.js doesn't really feel good about synchronous stuff. Unsafe allocation is much faster than safe, because the buffer santarization step takes time. Safe allocation is, well, safe, but there is a performance trade off. I'd suggest sticking to safe allocation first and if you end up with low performance, you can think of ways to implement unsafe allocation, without exposing private stuff. Just keep in mind that allocUnsafe method has the word unsafe for a reason. E.g, if you are going to pass some compliance certification like PCI DSS, I'm pretty sure QSA will notice that and will have a lot of questions.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/55805843', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/11115145/']}
jdg_87109
stackexchange
llm_judgeable_groundtruth_similarity
26501
Below is a question asked on the forum unix.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: What's the difference between patch -p0 and patch -p1 ? Is there any difference at all? Now provide the response and nothing else.
The most common way to create a patch is to run the diff command or some version control's built-in diff -like command. Sometimes, you're just comparing two files, and you run diff like this: diff -u version_by_alice.txt version_by_bob.txt >alice_to_bob.patch Then you get a patch that contains changes for one file and doesn't contain a file name at all. When you apply that patch, you need to specify which file you want to apply it to: patch <alice_to_bob.patch version2_by_alice.txt Often, you're comparing two versions of a whole multi-file project contained in a directory. A typical invocation of diff looks like this: diff -ru old_version new_version >some.patch Then the patch contains file names, given in header lines like diff -ru old_version/dir/file new_version/dir/file . You need to tell patch to strip the prefix ( old_version or new_version ) from the file name. That's what -p1 means: strip one level of directory. Sometimes, the header lines in the patch contain the file name directly with no lead-up. This is common with version control systems; for example cvs diff produces header lines that look like diff -r1.42 foo . Then there is no prefix to strip, so you must specify -p0 . In the special case when there are no subdirectories in the trees that you're comparing, no -p option is necessary: patch will discard all the directory part of the file names. But most of the time, you do need either -p0 or -p1 , depending on how the patch was produced.
{}
{'log_upvote_score': 6, 'links': ['https://unix.stackexchange.com/questions/26501', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/7768/']}
jdg_87110
stackexchange
llm_judgeable_groundtruth_similarity
22273046
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: public static void main(String[] args) {int i=153;int j=63;System.out.println((char)i);System.out.println((char)j);}OUTPUT:-?? I have some ideas why is this strange output.. But can anyone give me some idea so that i can print the extended ASCIIs as well.. Now provide the response and nothing else.
ASCII 153 ( 0x99 ) is different from Unicode U+0099 (Control character). Solution This program should do what you intend it to do: public class ExtendedAscii { public static final char[] EXTENDED = { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 }; public static final char getAscii(int code) { if (code >= 0x80 && code <= 0xFF) { return EXTENDED[code - 0x7F]; } return (char) code; } public static final void printChar(int code) { System.out.printf("%c%n", getAscii(code)); } public static void main(String[] args) { printChar(153); printChar(63); }} Output: Ü ? As you can see from the output above, the intended character gets printed correctly. Extension of Concept Also, I wrote a program that prints out the Unicode values for the extended Ascii. As you can see in the output below, a lot of characters have trouble being displayed as native char . Code: public class ExtendedAscii { public static final char[] EXTENDED = { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0 }; public static void main(String[] args) { for (char c : EXTENDED) { System.out.printf("%s, ", new String(Character.toChars(c))); } }} Output: Ç, ü, é, â, ä, à, å, ç, ê, ë, è, ï, î, ì, Ä, Å, É, æ, Æ, ô, ö, ò, û, ù, ÿ, Ö, Ü, ¢, £, ¥, ?, ƒ, á, í, ó, ú, ñ, Ñ, ª, º, ¿, ?, ¬, ½, ¼, ¡, «, », ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ß, ?, ?, ?, ?, µ, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ±, ?, ?, ?, ?, ÷, ?, °, ?, ·, ?, ?, ², ?,  , Reference Table: ( source ) Dec Hex Unicode   Char   Description--- --- -------   ----   -----------------------------------128 80 U+00C7 Ç latin capital letter c with cedilla129 81 U+00FC ü latin small letter u with diaeresis130 82 U+00E9 é latin small letter e with acute131 83 U+00E2 â latin small letter a with circumflex132 84 U+00E4 ä latin small letter a with diaeresis133 85 U+00E0 à latin small letter a with grave134 86 U+00E5 å latin small letter a with ring above135 87 U+00E7 ç latin small letter c with cedilla136 88 U+00EA ê latin small letter e with circumflex137 89 U+00EB ë latin small letter e with diaeresis138 8A U+00E8 è latin small letter e with grave139 8B U+00EF ï latin small letter i with diaeresis140 8C U+00EE î latin small letter i with circumflex141 8D U+00EC ì latin small letter i with grave142 8E U+00C4 Ä latin capital letter a with diaeresis143 8F U+00C5 Å latin capital letter a with ring above144 90 U+00C9 É latin capital letter e with acute145 91 U+00E6 æ latin small ligature ae146 92 U+00C6 Æ latin capital ligature ae147 93 U+00F4 ô latin small letter o with circumflex148 94 U+00F6 ö latin small letter o with diaeresis149 95 U+00F2 ò latin small letter o with grave150 96 U+00FB û latin small letter u with circumflex151 97 U+00F9 ù latin small letter u with grave152 98 U+00FF ÿ latin small letter y with diaeresis153 99 U+00D6 Ö latin capital letter o with diaeresis154 9A U+00DC Ü latin capital letter u with diaeresis155 9B U+00A2 ¢ cent sign156 9C U+00A3 £ pound sign157 9D U+00A5 ¥ yen sign158 9E U+20A7 ₧ peseta sign159 9F U+0192 ƒ latin small letter f with hook160 A0 U+00E1 á latin small letter a with acute161 A1 U+00ED í latin small letter i with acute162 A2 U+00F3 ó latin small letter o with acute163 A3 U+00FA ú latin small letter u with acute164 A4 U+00F1 ñ latin small letter n with tilde165 A5 U+00D1 Ñ latin capital letter n with tilde166 A6 U+00AA ª feminine ordinal indicator167 A7 U+00BA º masculine ordinal indicator168 A8 U+00BF ¿ inverted question mark169 A9 U+2310 ⌐ reversed not sign170 AA U+00AC ¬ not sign171 AB U+00BD ½ vulgar fraction one half172 AC U+00BC ¼ vulgar fraction one quarter173 AD U+00A1 ¡ inverted exclamation mark174 AE U+00AB « left-pointing double angle quotation mark175 AF U+00BB » right-pointing double angle quotation mark176 B0 U+2591 ░ light shade177 B1 U+2592 ▒ medium shade178 B2 U+2593 ▓ dark shade179 B3 U+2502 │ box drawings light vertical180 B4 U+2524 ┤ box drawings light vertical and left181 B5 U+2561 ╡ box drawings vertical single and left double182 B6 U+2562 ╢ box drawings vertical double and left single183 B7 U+2556 ╖ box drawings down double and left single184 B8 U+2555 ╕ box drawings down single and left double185 B9 U+2563 ╣ box drawings double vertical and left186 BA U+2551 ║ box drawings double vertical187 BB U+2557 ╗ box drawings double down and left188 BC U+255D ╝ box drawings double up and left189 BD U+255C ╜ box drawings up double and left single190 BE U+255B ╛ box drawings up single and left double191 BF U+2510 ┐ box drawings light down and left192 C0 U+2514 └ box drawings light up and right193 C1 U+2534 ┴ box drawings light up and horizontal194 C2 U+252C ┬ box drawings light down and horizontal195 C3 U+251C ├ box drawings light vertical and right196 C4 U+2500 ─ box drawings light horizontal197 C5 U+253C ┼ box drawings light vertical and horizontal198 C6 U+255E ╞ box drawings vertical single and right double199 C7 U+255F ╟ box drawings vertical double and right single200 C8 U+255A ╚ box drawings double up and right201 C9 U+2554 ╔ box drawings double down and right202 CA U+2569 ╩ box drawings double up and horizontal203 CB U+2566 ╦ box drawings double down and horizontal204 CC U+2560 ╠ box drawings double vertical and right205 CD U+2550 ═ box drawings double horizontal206 CE U+256C ╬ box drawings double vertical and horizontal207 CF U+2567 ╧ box drawings up single and horizontal double208 D0 U+2568 ╨ box drawings up double and horizontal single209 D1 U+2564 ╤ box drawings down single and horizontal double210 D2 U+2565 ╥ box drawings down double and horizontal single211 D3 U+2559 ╙ box drawings up double and right single212 D4 U+2558 ╘ box drawings up single and right double213 D5 U+2552 ╒ box drawings down single and right double214 D6 U+2553 ╓ box drawings down double and right single215 D7 U+256B ╫ box drawings vertical double and horizontal single216 D8 U+256A ╪ box drawings vertical single and horizontal double217 D9 U+2518 ┘ box drawings light up and left218 DA U+250C ┌ box drawings light down and right219 DB U+2588 █ full block220 DC U+2584 ▄ lower half block221 DD U+258C ▌ left half block222 DE U+2590 ▐ right half block223 DF U+2580 ▀ upper half block224 E0 U+03B1 α greek small letter alpha225 E1 U+00DF ß latin small letter sharp s226 E2 U+0393 Γ greek capital letter gamma227 E3 U+03C0 π greek small letter pi228 E4 U+03A3 Σ greek capital letter sigma229 E5 U+03C3 σ greek small letter sigma230 E6 U+00B5 µ micro sign231 E7 U+03C4 τ greek small letter tau232 E8 U+03A6 Φ greek capital letter phi233 E9 U+0398 Θ greek capital letter theta234 EA U+03A9 Ω greek capital letter omega235 EB U+03B4 δ greek small letter delta236 EC U+221E ∞ infinity237 ED U+03C6 φ greek small letter phi238 EE U+03B5 ε greek small letter epsilon239 EF U+2229 ∩ intersection240 F0 U+2261 ≡ identical to241 F1 U+00B1 ± plus-minus sign242 F2 U+2265 ≥ greater-than or equal to243 F3 U+2264 ≤ less-than or equal to244 F4 U+2320 ⌠ top half integral245 F5 U+2321 ⌡ bottom half integral246 F6 U+00F7 ÷ division sign247 F7 U+2248 ≈ almost equal to248 F8 U+00B0 ° degree sign249 F9 U+2219 ∙ bullet operator250 FA U+00B7 · middle dot251 FB U+221A √ square root252 FC U+207F ⁿ superscript latin small letter n253 FD U+00B2 ² superscript two254 FE U+25A0 ■ black square255 FF U+00A0 no-break space
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/22273046', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2249804/']}
jdg_87111
stackexchange
llm_judgeable_groundtruth_similarity
28911030
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Can anyone please help me what to do with this? My eclipse wont open. I already downloaded multiple files from the internet and yet it's still the same. No errors are found since it wont start. Now provide the response and nothing else.
Well the code of vgaspar.trivix did not work completly for me, the default values did not get set for the schema. Also i got an NullPointerException . I managed to get it working as intended by editing the Apply method and manipulated the schemaRegistry like this: public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription){ if (operation.parameters == null) return; IDictionary<string, object> parameterValuePairs = GetParameterValuePairs(apiDescription.ActionDescriptor); foreach (var param in operation.parameters) { if (param.schema != null && param.schema.@ref != null) { string schemaName = [email protected]('/').LastOrDefault(); if (schemaRegistry.Definitions.ContainsKey(schemaName)) foreach (var props in schemaRegistry.Definitions[schemaName].properties) { if (parameterValuePairs.ContainsKey(props.Key)) props.Value.@default = parameterValuePairs[props.Key]; } } var parameterValuePair = parameterValuePairs.FirstOrDefault(p => p.Key.IndexOf(param.name, StringComparison.InvariantCultureIgnoreCase) >= 0); param.@default = parameterValuePair.Value; }}
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/28911030', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4641283/']}
jdg_87112
stackexchange
llm_judgeable_groundtruth_similarity
15428604
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have some methods returning Task<T> on which I can await at will. I'd like to have those Tasks executed on a custom TaskScheduler instead of the default one. var task = GetTaskAsync ();await task; I know I can create a new TaskFactory (new CustomScheduler ()) and do a StartNew () from it, but StartNew () takes an action and create the Task , and I already have the Task (returned behind the scenes by a TaskCompletionSource ) How can I specify my own TaskScheduler for await ? Now provide the response and nothing else.
I think what you really want is to do a Task.Run , but with a custom scheduler. StartNew doesn't work intuitively with asynchronous methods; Stephen Toub has a great blog post about the differences between Task.Run and TaskFactory.StartNew . So, to create your own custom Run , you can do something like this: private static readonly TaskFactory myTaskFactory = new TaskFactory( CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskContinuationOptions.None, new MyTaskScheduler());private static Task RunOnMyScheduler(Func<Task> func){ return myTaskFactory.StartNew(func).Unwrap();}private static Task<T> RunOnMyScheduler<T>(Func<Task<T>> func){ return myTaskFactory.StartNew(func).Unwrap();}private static Task RunOnMyScheduler(Action func){ return myTaskFactory.StartNew(func);}private static Task<T> RunOnMyScheduler<T>(Func<T> func){ return myTaskFactory.StartNew(func);} Then you can execute synchronous or asynchronous methods on your custom scheduler.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/15428604', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1063783/']}
jdg_87113
stackexchange
llm_judgeable_groundtruth_similarity
31421413
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm working in a sentiment analysis problem the data looks like this: label instances 5 1190 4 838 3 239 1 204 2 127 So my data is unbalanced since 1190 instances are labeled with 5 . For the classification Im using scikit's SVC . The problem is I do not know how to balance my data in the right way in order to compute accurately the precision, recall, accuracy and f1-score for the multiclass case. So I tried the following approaches: First: wclf = SVC(kernel='linear', C= 1, class_weight={1: 10}) wclf.fit(X, y) weighted_prediction = wclf.predict(X_test)print 'Accuracy:', accuracy_score(y_test, weighted_prediction)print 'F1 score:', f1_score(y_test, weighted_prediction,average='weighted')print 'Recall:', recall_score(y_test, weighted_prediction, average='weighted')print 'Precision:', precision_score(y_test, weighted_prediction, average='weighted')print '\n clasification report:\n', classification_report(y_test, weighted_prediction)print '\n confussion matrix:\n',confusion_matrix(y_test, weighted_prediction) Second: auto_wclf = SVC(kernel='linear', C= 1, class_weight='auto')auto_wclf.fit(X, y)auto_weighted_prediction = auto_wclf.predict(X_test)print 'Accuracy:', accuracy_score(y_test, auto_weighted_prediction)print 'F1 score:', f1_score(y_test, auto_weighted_prediction, average='weighted')print 'Recall:', recall_score(y_test, auto_weighted_prediction, average='weighted')print 'Precision:', precision_score(y_test, auto_weighted_prediction, average='weighted')print '\n clasification report:\n', classification_report(y_test,auto_weighted_prediction)print '\n confussion matrix:\n',confusion_matrix(y_test, auto_weighted_prediction) Third: clf = SVC(kernel='linear', C= 1)clf.fit(X, y)prediction = clf.predict(X_test)from sklearn.metrics import precision_score, \ recall_score, confusion_matrix, classification_report, \ accuracy_score, f1_scoreprint 'Accuracy:', accuracy_score(y_test, prediction)print 'F1 score:', f1_score(y_test, prediction)print 'Recall:', recall_score(y_test, prediction)print 'Precision:', precision_score(y_test, prediction)print '\n clasification report:\n', classification_report(y_test,prediction)print '\n confussion matrix:\n',confusion_matrix(y_test, prediction)F1 score:/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:676: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". sample_weight=sample_weight)/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1172: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". sample_weight=sample_weight)/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1082: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". sample_weight=sample_weight) 0.930416613529 However, Im getting warnings like this: /usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:1172:DeprecationWarning: The default `weighted` averaging is deprecated,and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1" How can I deal correctly with my unbalanced data in order to compute in the right way classifier's metrics? Now provide the response and nothing else.
I think there is a lot of confusion about which weights are used for what. I am not sure I know precisely what bothers you so I am going to cover different topics, bear with me ;). Class weights The weights from the class_weight parameter are used to train the classifier .They are not used in the calculation of any of the metrics you are using : with different class weights, the numbers will be different simply because the classifier is different. Basically in every scikit-learn classifier, the class weights are used to tell your model how important a class is. That means that during the training, the classifier will make extra efforts to classify properly the classes with high weights. How they do that is algorithm-specific. If you want details about how it works for SVC and the doc does not make sense to you, feel free to mention it. The metrics Once you have a classifier, you want to know how well it is performing. Here you can use the metrics you mentioned: accuracy , recall_score , f1_score ... Usually when the class distribution is unbalanced, accuracy is considered a poor choice as it gives high scores to models which just predict the most frequent class. I will not detail all these metrics but note that, with the exception of accuracy , they are naturally applied at the class level: as you can see in this print of a classification report they are defined for each class. They rely on concepts such as true positives or false negative that require defining which class is the positive one. precision recall f1-score support 0 0.65 1.00 0.79 17 1 0.57 0.75 0.65 16 2 0.33 0.06 0.10 17avg / total 0.52 0.60 0.51 50 The warning F1 score:/usr/local/lib/python2.7/site-packages/sklearn/metrics/classification.py:676: DeprecationWarning: The default `weighted` averaging is deprecated, and from version 0.18, use of precision, recall or F-score with multiclass or multilabel data or pos_label=None will result in an exception. Please set an explicit value for `average`, one of (None, 'micro', 'macro', 'weighted', 'samples'). In cross validation use, for instance, scoring="f1_weighted" instead of scoring="f1". You get this warning because you are using the f1-score, recall and precision without defining how they should be computed!The question could be rephrased: from the above classification report, how do you output one global number for the f1-score?You could: Take the average of the f1-score for each class: that's the avg / total result above. It's also called macro averaging. Compute the f1-score using the global count of true positives / false negatives, etc. (you sum the number of true positives / false negatives for each class). Aka micro averaging. Compute a weighted average of the f1-score. Using 'weighted' in scikit-learn will weigh the f1-score by the support of the class: the more elements a class has, the more important the f1-score for this class in the computation. These are 3 of the options in scikit-learn, the warning is there to say you have to pick one . So you have to specify an average argument for the score method. Which one you choose is up to how you want to measure the performance of the classifier: for instance macro-averaging does not take class imbalance into account and the f1-score of class 1 will be just as important as the f1-score of class 5. If you use weighted averaging however you'll get more importance for the class 5. The whole argument specification in these metrics is not super-clear in scikit-learn right now, it will get better in version 0.18 according to the docs. They are removing some non-obvious standard behavior and they are issuing warnings so that developers notice it. Computing scores Last thing I want to mention (feel free to skip it if you're aware of it) is that scores are only meaningful if they are computed on data that the classifier has never seen . This is extremely important as any score you get on data that was used in fitting the classifier is completely irrelevant. Here's a way to do it using StratifiedShuffleSplit , which gives you a random splits of your data (after shuffling) that preserve the label distribution. from sklearn.datasets import make_classificationfrom sklearn.cross_validation import StratifiedShuffleSplitfrom sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score, classification_report, confusion_matrix# We use a utility to generate artificial classification data.X, y = make_classification(n_samples=100, n_informative=10, n_classes=3)sss = StratifiedShuffleSplit(y, n_iter=1, test_size=0.5, random_state=0)for train_idx, test_idx in sss: X_train, X_test, y_train, y_test = X[train_idx], X[test_idx], y[train_idx], y[test_idx] svc.fit(X_train, y_train) y_pred = svc.predict(X_test) print(f1_score(y_test, y_pred, average="macro")) print(precision_score(y_test, y_pred, average="macro")) print(recall_score(y_test, y_pred, average="macro")) Hope this helps.
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/31421413', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4416307/']}
jdg_87114
stackexchange
llm_judgeable_groundtruth_similarity
2595701
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I've been adding unit tests to some legacy C++ code, and I've run into many scenarios where an assert inside a function will get tripped during a unit test run. A common idiom that I've run across is functions that take pointer arguments and immediately assert if the argument is NULL. I could easily get around this by disabling asserts when I'm unit testing. But I'm starting to wonder if unit tests are supposed to alleviate the need for runtime asserts. Is this a correct assessment? Are unit tests supposed to replace runtime asserts by happening sooner in the pipeline (ie: the error is caught in a failing test instead of when the program is running). On the other hand, I don't like adding soft fails to code (e.g. if (param == NULL) return false; ). A runtime assert at least makes it easier to debug a problem in case a unit test missed a bug. Now provide the response and nothing else.
A runtime assert at least makes it easier to debug a problem in case a unit test missed a bug. This is a pretty fundamental point. Unit tests are not meant to replace assertions (which IMHO are a standard part of producing good quality code), they're meant to complement them. Secondly, lets say you have a function Foo which asserts that it's parameters are valid. In your unit test for Foo you can make sure you only supply valid parameters, so you think you're alright. 6 months down the track some other developer is going to call Foo from some new piece of code (which may or may not have unit tests), and at that point you'll be very grateful you put those asserts in there.
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/2595701', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/304608/']}
jdg_87115
stackexchange
llm_judgeable_groundtruth_similarity
2616355
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a named range like the following covering A2:D3 ITEM PRICE QTY SUBTOTAL1 10 3 301 5 2 10 TOTAL: 40 I am to insert a new row using VBA into the range copying the formulas not values. Any tips/links greatly appreciated. Now provide the response and nothing else.
This should do it: Private Sub newRow(Optional line As Integer = -1)Dim target As RangeDim cell As RangeDim rowNr As Integer Set target = Range("A2:D3") If line <> -1 Then rowNr = line Else rowNr = target.Rows.Count End If target.Rows(rowNr + 1).Insert target.Rows(rowNr).Copy target.Rows(rowNr + 1) For Each cell In target.Rows(rowNr + 1).Cells If Left(cell.Formula, 1) <> "=" Then cell.Clear Next cellEnd Sub
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/2616355', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/62282/']}
jdg_87116
stackexchange
llm_judgeable_groundtruth_similarity
15970161
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have created an Xml file with example contents as follows: <?xml version="1.0" encoding="utf-8" ?><Periods> <PeriodGroup name="HER"> <Period> <PeriodName>Prehistoric</PeriodName> <StartDate>-500000</StartDate> <EndDate>43</EndDate> </Period> <Period> <PeriodName>Iron Age</PeriodName> <StartDate>-800</StartDate> <EndDate>43</EndDate> </Period> <Period> <PeriodName>Roman</PeriodName> <StartDate>43</StartDate> <EndDate>410</EndDate> </Period> </PeriodGroup> <PeriodGroup name="CAFG"> <Period> <PeriodName>Prehistoric</PeriodName> <StartDate>-500000</StartDate> <EndDate>43</EndDate> </Period> <Period> <PeriodName>Roman</PeriodName> <StartDate>43</StartDate> <EndDate>410</EndDate> </Period> <Period> <PeriodName>Anglo-Saxon</PeriodName> <StartDate>410</StartDate> <EndDate>800</EndDate> </Period> </PeriodGroup></Periods> I need to be able to read the Period node children within a selected PeriodGroup. I guess the PeriodName could be an attribute of Period if that is more sensible. I have looked at loads of examples but none seem to be quite right and there seems to be dozens of different methods, some using XmlReader, some XmlTextReader and some not using either. As this is my first time reading an Xml file, I thought I'd ask if anyone could give me a pointer. I've got something working just to try things out, but it feels clunky. I'm using VS2010 and c#. Also, I see a lot of people are using LINQ-Xml, so I'd appreciate the pros and cons of using this method. string PG = "HER";XmlDocument doc = new XmlDocument();doc.Load(Server.MapPath("./Xml/XmlFile.xml"));string text = string.Empty;XmlNodeList xnl = doc.SelectNodes("/Periods/PeriodGroup");foreach (XmlNode node in xnl){ text = node.Attributes["name"].InnerText; if (text == PG) { XmlNodeList xnl2 = doc.SelectNodes("/Periods/PeriodGroup/Period"); foreach (XmlNode node2 in xnl2) { text = text + "<br>" + node2["PeriodName"].InnerText; text = text + "<br>" + node2["StartDate"].InnerText; text = text + "<br>" + node2["EndDate"].InnerText; } } Response.Write(text);} Now provide the response and nothing else.
You could use an XPath approach like so: XmlNodeList xnl = doc.SelectNodes(string.Format("/Periods/PeriodGroup[@name='{0}']/Period", PG)); Though prefer LINQ to XML for it's readability. This will return Period node children based on the PeriodGroup name attribute supplied, e.g. HER : XDocument xml = XDocument.Load(HttpContext.Current.Server.MapPath(FileLoc));var nodes = (from n in xml.Descendants("Periods") where n.Element("PeriodGroup").Attribute("name").Value == "HER" select n.Element("PeriodGroup").Descendants().Elements()).ToList(); Results: <PeriodName>Prehistoric</PeriodName><StartDate>-500000</StartDate><EndDate>43</EndDate><PeriodName>Iron Age</PeriodName><StartDate>-800</StartDate><EndDate>43</EndDate><PeriodName>Roman</PeriodName><StartDate>43</StartDate><EndDate>410</EndDate> The query is pretty straightforward from n in xml.Descendants("Periods") Will return a collection of the descendant elements for the element Periods .We then use where to filter this collection of nodes based on attribute value: where n.Element("PeriodGroup").Attribute("name").Value == "HER" Will then filter down the collection to PeriodGroup elements that have a name attribute with a value of HER Finally, we select the PeriodGroup element and get it's descendant nodes select n.Element("PeriodGroup").Descendants().Elements() EDIT (See comments) Since the result of this expression is just a query, we use .ToList() to enumerate the collection and return an object containing the values you need. You could also create anonymous types to store the element values for example: var nodes = (from n in xml.Descendants("Period"). Where(r => r.Parent.Attribute("name").Value == "HER") select new { PeriodName = (string)n.Element("PeriodName").Value, StartDate = (string)n.Element("StartDate").Value, EndDate = (string)n.Element("EndDate").Value }).ToList();//Crude demonstration of how you can reference each specific element in the result//I would recommend using a stringbuilder here..foreach (var n in nodes){ text += "<br>" + n.PeriodName; text += "<br>" + n.StartDate; text += "<br>" + n.EndDate;} This is what the nodes object will look like after the query has run:
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/15970161', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1106938/']}
jdg_87117
stackexchange
llm_judgeable_groundtruth_similarity
65272
Below is a question asked on the forum chemistry.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: According to this Wikipedia article , the half-life of Bismuth-209 is 19 billion billion years, which exceeds the age of the Universe by factor on the order of a billion. How is the half-life of an element measured and experimentally verified if the half-life exceeds the age of the Universe? Now provide the response and nothing else.
Well, half-life describes the time after which half of the substance has decayed. This is all probability and statistics. If you look at a single atom you cannot make any prediction when it will decay. It might be within the next 3 seconds or it might be here even after hundreds of billion years. The probability that it decays during the half-life is 50%, so if we look at a very large number of such atoms we can use statistics to predict how much substance will actually decay in a given time. Now bismuth-209 has $1.9×10^{19}$ years half-life, So if we have a lot of Bismuth-209 after that time we will only have half of it. But that doesn't mean we don't have any decay right now. 209 grams of Bismuth-209 are 1 mole so $6.022×10^{23}$ particles, a lot of those. Now the decay goes down exponentially but if we just calculate the average decay rate during the first half-life if we start off with 1 mole and we keep in mind that the rate will be much faster in the beginning we see that we have an average of around 16000 decays every year, which means around 44 a day. Again, in the beginning it will be more, approaching the time of half-life it will be less. Now how do we know the half-life? It's simple in theory, some french researcher put 31 grams bismuth-209 in a box with very sensitive equipment and measured the alpha particles which are send out during decay. This isn't a trivial task to do, but it's possible. They counted 128 particles over 5 days and then did the math to calculate the half-life. The original paper can be found here .
{}
{'log_upvote_score': 5, 'links': ['https://chemistry.stackexchange.com/questions/65272', 'https://chemistry.stackexchange.com', 'https://chemistry.stackexchange.com/users/-1/']}
jdg_87118
stackexchange
llm_judgeable_groundtruth_similarity
13955738
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a number assigned to a variable, like that: var myVar = 1234; Now I want to get the second digit (2 in this case) from that number without converting it to a string first. Is that possible? Now provide the response and nothing else.
So you want to get the second digit from the decimal writing of a number. The simplest and most logical solution is to convert it to a string : var digit = (''+myVar)[1]; or var digit = myVar.toString()[1]; If you don't want to do it the easy way, or if you want a more efficient solution, you can do that : var l = Math.pow(10, Math.floor(Math.log(myVar)/Math.log(10))-1);var b = Math.floor(myVar/l);var digit = b-Math.floor(b/10)*10; Demonstration For people interested in performances, I made a jsperf . For random numbers using the log as I do is by far the fastest solution.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/13955738', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1856596/']}
jdg_87119
stackexchange
llm_judgeable_groundtruth_similarity
9644099
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm really confused. I tried to encode but the error said can't decode... . >>> "你好".encode("utf8")Traceback (most recent call last):File "<stdin>", line 1, in <module>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128) I know how to avoid the error with "u" prefix on the string. I'm just wondering why the error is "can't decode" when encode was called. What is Python doing under the hood? Now provide the response and nothing else.
"你好".encode('utf-8') encode converts a unicode object to a string object. But here you have invoked it on a string object (because you don't have the u). So python has to convert the string to a unicode object first. So it does the equivalent of "你好".decode().encode('utf-8') But the decode fails because the string isn't valid ascii. That's why you get a complaint about not being able to decode.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/9644099', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/523517/']}
jdg_87120
stackexchange
llm_judgeable_groundtruth_similarity
29762012
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm trying to check if a value is zero in x86_64 assembly code. I know that this usually consist of a cmp variant followed by a jmp variant, but I'm not sure of the exact instructions to use. Now provide the response and nothing else.
If you've just used an instruction that modifies ZF before, simply check that flag and jump using JZ or JE . For example and rax, rbx ; ZF was modifiedjz is_zero ; so to check if rax is zero, a single jump is enough If ZF was not set, you need to do that explicitly. The obvious way is cmp rax, 0je equal_zero However since cmp is longer if you look at the output binary, test or sometimes and , or is preferred 83F800 cmp eax, 009C0 or eax, eax85C0 test eax, eax The resulting code will be test rax, raxjz is_zero You can get the assembly output from a compiler and check or view it in an online tool like gcc godbolt Read more: http://en.wikibooks.org/wiki/X86_Assembly/Control_Flow
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/29762012', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4139707/']}
jdg_87121
stackexchange
llm_judgeable_groundtruth_similarity
548156
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: The opposite category of the category of rings is equivalent to the category of affine schemes, via the Spec functor. Is there a similar result if we consider the Proj construction, that takes a graded ring and returns some scheme? This is a question from a beginner in algebraic geometry, trying to understand how things fit together. Now provide the response and nothing else.
Unfortunately, there is not. As Mariano points out, non-isomorphic rings might happen to have isomorphic Proj. However, the biggest problem is pointed out by Alex: Proj is not even a functor, unless you add some restrictions. The problem is already illustrated at the level of vector spaces. If $V \to W$ is a map of vector spaces, you do not get a map $P(V) \to P(W)$ from it, unless it is an injection. Indeed, where would you send lines in the kernel?
{}
{'log_upvote_score': 5, 'links': ['https://math.stackexchange.com/questions/548156', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/2614/']}
jdg_87122
stackexchange
llm_judgeable_groundtruth_similarity
31517794
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have five tabs that are using Bootstrap for animation. They were working fine until I added the final tab: Management. When I click the Management tab the SuperAdmin tab displays as still active in the nav. But when I click the SuperAdmin tab I do not have the same issue. The management tab is then inactive. So the issue is only happening one way. I did some copy and paste from that tab when I created the Management tab because the design was similar. I assume that's what is causing the issue, but I can't find the exact problem. I did try to remove the active class from the SuperAdmin tab when the Management tab was clicked, but that did not seem to work: <script>$("#management").click(function () { $("#super-admin").removeClass("active");}); Here is the nav: <ul class="nav nav-tabs" id="navTabs"><li @(Request.Url.AbsoluteUri.Contains("Create") ? Html.Raw("class=\"active\"") : Html.Raw("")) > @Html.ActionLink("Add Record", "Create", "Home")</li><li @(Request.Url.AbsoluteUri.Contains("Search") ? Html.Raw("class=\"active\"") : Html.Raw("")) >@Html.ActionLink("Search", "Search", "Home")</li>@if (User.IsInRole("Admin") || User.IsInRole("SuperAdmin") || User.IsInRole("Manager")) { <li @(Request.Url.AbsoluteUri.Contains("Category") ? Html.Raw("class=\"active\"") : Html.Raw("")) >@Html.ActionLink("Admin", "Index", "Category")</li> }@if (User.IsInRole("SuperAdmin") || User.IsInRole("Manager")) { <li @(Request.Url.AbsoluteUri.Contains("SuperAdmin") ? Html.Raw("class=\"active\"") : Html.Raw("")) >@Html.ActionLink("SuperAdmin", "Index", "SuperAdmin")</li> }@if (User.IsInRole("Manager")) { <li @(Request.Url.AbsoluteUri.Contains("Management") ? Html.Raw("class=\"active\"") : Html.Raw(""))>@Html.ActionLink("Management", "Index", "Management")</li> } <li >@Html.ActionLink("Logoff", "Logoff", "Home")</li> </ul> The best I could do to show this in jsFiddle: Super Admin selected: https://jsfiddle.net/s3f3cjon/ Management selected: https://jsfiddle.net/9sd1faub/3/ You can see that the Super Admin tab still has the class active. Any help would be appreciated. Thanks! Now provide the response and nothing else.
If you define a (computed read-only) property sortIndex of CLProximity extension CLProximity { var sortIndex : Int { switch self { case .Immediate: return 0 case .Near: return 1 case .Far: return 2 case .Unknown: return 3 } }} then you can sort an array of beacons with let sortedBeacons = sorted(beacons) { $0.proximity.sortIndex < $1.proximity.sortIndex } If .Unknown is the only CLProximity value that needs"special treatment" and all other possible values are in the desiredrelative order then you can simplify the property definition to extension CLProximity { var sortIndex : Int { return self == .Unknown ? Int.max : rawValue }}
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/31517794', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4661184/']}
jdg_87123
stackexchange
llm_judgeable_groundtruth_similarity
3949206
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a weird problem where I cannot run aapt from an sbt command as well as from the shell. I run this command: sbt update package-debug And everything hums along until I get this error: java.io.IOException: Cannot run program "/home/egervari/Programs/android-sdk-linux_x86/platforms/android-7/tools/aapt": java.io.IOException: error=2, No such file or directory So I try running it manually, just for the heck of it: egervari@ken:~/Programs/android-sdk-linux_x86/platforms/android-7/tools$ ./aaptbash: ./aapt: No such file or directory This is pretty weird because it's right there: egervari@ken:~/Programs/android-sdk-linux_x86/platforms/android-7/tools$ ls -latotal 4660drwxr-xr-x 3 egervari egervari 4096 2010-10-16 09:13 .drwxr-xr-x 8 egervari egervari 4096 2010-10-16 09:13 ..-rwxrwxrwx 1 egervari egervari 3472673 2010-10-16 09:13 aapt-rwxrwxrwx 1 egervari egervari 1050328 2010-10-16 09:13 aidl-rwxrwxrwx 1 egervari egervari 213690 2010-10-16 09:13 dexdump-rwxrwxrwx 1 egervari egervari 2497 2010-10-16 09:13 dxdrwxr-xr-x 2 egervari egervari 4096 2010-10-16 09:13 lib-rw-r--r-- 1 egervari egervari 10800 2010-10-16 09:13 NOTICE.txtegervari@ken:~/Programs/android-sdk-linux_x86/platforms/android-7/tools$ Help? :/ Now provide the response and nothing else.
It looks like you're trying to run a 32-bit binary on a 64-bit OS. Maybe you're missing the required shared libraries. Try running file aapt and ldd ./aapt to see what it says. If this is the case then installing ia32-libs could fix it , as there are no 64-bit binaries available. sudo apt-get install ia32-libs
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/3949206', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/331439/']}
jdg_87124
stackexchange
llm_judgeable_groundtruth_similarity
1212799
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have an ASCII log file with some content I would like to extract. I've never taken time to learn Perl properly, but I figure this is a good tool for this task. The file is structured like this: ... ... some garbage ... ... garbage STARTwhat i want is on differentlines END ... ... more garbage ...next one START more stuff I want, againspread through multiple lines END ...more garbage So, I'm looking for a way to extract the lines between each START and END delimiter strings. How can I do this? So far, I've only found some examples on how to print a line with the START string, or other documentation items that are somewhat related with what I'm looking for. Now provide the response and nothing else.
You want the flip-flop operator (also known as the range operator) .. #!/usr/bin/env perluse strict;use warnings;while (<>) { if (/START/../END/) { next if /START/ || /END/; print; }} Replace the call to print with whatever you actually want to do (e.g., push the line into an array, edit it, format it, whatever). I'm next -ing past the lines that actually have START or END , but you may not want that behavior. See this article for a discussion of this operator and other useful Perl special variables.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/1212799', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/36145/']}
jdg_87125
stackexchange
llm_judgeable_groundtruth_similarity
7559645
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: The other day I tried to do this, but it doesn't work: enum MyEnum {ONE = 1, TWO = 2} much to my surprise, it doesn't compile!!! How to se custom ordinals??? Now provide the response and nothing else.
You can't. Ordinals are fixed by starting at 0 and working up. From the docs for ordinal() : Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero). You can't assign your own values. On the other hand, you can have your own values in the enum: public enum Foo { ONE(1), TWO(2); private final int number; private Foo(int number) { this.number = number; } public int getNumber() { return number; }}
{}
{'log_upvote_score': 7, 'links': ['https://Stackoverflow.com/questions/7559645', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/138606/']}
jdg_87126
stackexchange
llm_judgeable_groundtruth_similarity
43550853
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm writing a Flutter app, and I'd like to use/implement the "frosted glass" effect that's common on iOS. How do I do this? Now provide the response and nothing else.
You can use the BackdropFilter widget to achieve this effect. import 'dart:ui';import 'package:flutter/material.dart';void main() { runApp(new MaterialApp(home: new FrostedDemo()));}class FrostedDemo extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( body: new Stack( children: <Widget>[ new ConstrainedBox( constraints: const BoxConstraints.expand(), child: new FlutterLogo() ), new Center( child: new ClipRect( child: new BackdropFilter( filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: new Container( width: 200.0, height: 200.0, decoration: new BoxDecoration( color: Colors.grey.shade200.withOpacity(0.5) ), child: new Center( child: new Text( 'Frosted', style: Theme.of(context).textTheme.display3 ), ), ), ), ), ), ], ), ); }}
{}
{'log_upvote_score': 9, 'links': ['https://Stackoverflow.com/questions/43550853', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/123471/']}
jdg_87127
stackexchange
llm_judgeable_groundtruth_similarity
9829578
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I need a fast way to count the number of bits in an integer in python.My current solution is bin(n).count("1") but I am wondering if there is any faster way of doing this? PS: (i am representing a big 2D binary array as a single list of numbers and doing bitwise operations, and that brings the time down from hours to minutes. and now I would like to get rid of those extra minutes. Edit: 1. it has to be in python 2.7 or 2.6 and optimizing for small numbers does not matter that much since that would not be a clear bottleneck, but I do have numbers with 10 000 + bits at some places for example this is a 2000 bit case: 12448057941136394342297748548545082997815840357634948550739612798732309975923280685245876950055614362283769710705811182976142803324242407017104841062064840113262840137625582646683068904149296501029754654149991842951570880471230098259905004533869130509989042199261339990315125973721454059973605358766253998615919997174542922163484086066438120268185904663422979603026066685824578356173882166747093246377302371176167843247359636030248569148734824287739046916641832890744168385253915508446422276378715722482359321205673933317512861336054835392844676749610712462818600179225635467147870208L Now provide the response and nothing else.
For arbitrary-length integers, bin(n).count("1") is the fastest I could find in pure Python. I tried adapting Óscar's and Adam's solutions to process the integer in 64-bit and 32-bit chunks, respectively. Both were at least ten times slower than bin(n).count("1") (the 32-bit version took about half again as much time). On the other hand, gmpy popcount() took about 1/20th of the time of bin(n).count("1") . So if you can install gmpy, use that. To answer a question in the comments, for bytes I'd use a lookup table. You can generate it at runtime: counts = bytes(bin(x).count("1") for x in range(256)) # py2: use bytearray Or just define it literally: counts = (b'\x00\x01\x01\x02\x01\x02\x02\x03\x01\x02\x02\x03\x02\x03\x03\x04' b'\x01\x02\x02\x03\x02\x03\x03\x04\x02\x03\x03\x04\x03\x04\x04\x05' b'\x01\x02\x02\x03\x02\x03\x03\x04\x02\x03\x03\x04\x03\x04\x04\x05' b'\x02\x03\x03\x04\x03\x04\x04\x05\x03\x04\x04\x05\x04\x05\x05\x06' b'\x01\x02\x02\x03\x02\x03\x03\x04\x02\x03\x03\x04\x03\x04\x04\x05' b'\x02\x03\x03\x04\x03\x04\x04\x05\x03\x04\x04\x05\x04\x05\x05\x06' b'\x02\x03\x03\x04\x03\x04\x04\x05\x03\x04\x04\x05\x04\x05\x05\x06' b'\x03\x04\x04\x05\x04\x05\x05\x06\x04\x05\x05\x06\x05\x06\x06\x07' b'\x01\x02\x02\x03\x02\x03\x03\x04\x02\x03\x03\x04\x03\x04\x04\x05' b'\x02\x03\x03\x04\x03\x04\x04\x05\x03\x04\x04\x05\x04\x05\x05\x06' b'\x02\x03\x03\x04\x03\x04\x04\x05\x03\x04\x04\x05\x04\x05\x05\x06' b'\x03\x04\x04\x05\x04\x05\x05\x06\x04\x05\x05\x06\x05\x06\x06\x07' b'\x02\x03\x03\x04\x03\x04\x04\x05\x03\x04\x04\x05\x04\x05\x05\x06' b'\x03\x04\x04\x05\x04\x05\x05\x06\x04\x05\x05\x06\x05\x06\x06\x07' b'\x03\x04\x04\x05\x04\x05\x05\x06\x04\x05\x05\x06\x05\x06\x06\x07' b'\x04\x05\x05\x06\x05\x06\x06\x07\x05\x06\x06\x07\x06\x07\x07\x08') Then it's counts[x] to get the number of 1 bits in x where 0 ≤ x ≤ 255.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/9829578', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/696208/']}
jdg_87128
stackexchange
llm_judgeable_groundtruth_similarity
4332
Below is a question asked on the forum mathematica.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Consider the following: data={{{3542313600, 175}, {3542918400, 175}}, {{3544128000, 450},{3544128000, 450}, {3545337600, 450}, {3545942400, 450}, {3546547200, 450}}}; whereas the first element of each {_,_} represent a date in absolute time, i.e. {_,_} corresponds to the pattern {AbsoluteDate_,Value_} . Now I would like to calculate the sum of all Value_ when the corresponding AbsoluteDate_ is equal, e.g. {3545337600, 450}, {3545337600, 450} -> {3545337600, 900} . Now provide the response and nothing else.
The following also works (though its a bit messy to look at) and will probably be faster than pattern matching if you have large input data. Transpose[{#[[All, 1, 1]], Total[#[[All, All, 2]], {2}]}] &[#] & /@ (GatherBy[#, First] & /@ data) EDIT: I should point out that there are at least a couple of different problems being solved in the answers posted here. The results posted by myself and @RM attempt to preserve the structure of the original data and so do not gather like dates if they are present in multiple sublists. Answers posted by @David Carraher and @rcollyer ignore the structure of the original data and gather all like dates. I'm not sure which is the correct approach in this case but it felt worth pointing out the difference.
{}
{'log_upvote_score': 4, 'links': ['https://mathematica.stackexchange.com/questions/4332', 'https://mathematica.stackexchange.com', 'https://mathematica.stackexchange.com/users/508/']}
jdg_87129
stackexchange
llm_judgeable_groundtruth_similarity
975193
Below is a question asked on the forum serverfault.com. Provide a good and informational response to it like a helpful human would. Question: I have this virtual host entry in my apache configuration. Server has only one IP address. If I put the server IP address in the browser, from which location the contents will serve? "/opt/bitnami/apache2/htdocs" or "/opt/bitnami/apps/wordpress/htdocs". Well, in my testing it shows that contents are served from "/opt/bitnami/apps/wordpress/htdocs". I want to know why. <VirtualHost _default_:80> DocumentRoot "/opt/bitnami/apache2/htdocs" DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"<Directory "/opt/bitnami/apache2/htdocs"> Require all granted</Directory><Directory "/opt/bitnami/apps/wordpress/htdocs"> Require all granted</Directory></VirtualHost> Now provide the response and nothing else.
This appears to happen when the system page file is located on the iSCSI device. While locating the page file on iSCSI worked fine under Windows 7, it appears to be broken in Windows 10. Unfortunately, Windows defaults to setting up a page file on the primary disk, so when the primary disk is iSCSI, it is broken out-of-the-box. (Note that the stop code PAGE_FAULT_IN_NONPAGED_AREA does not necessarily relate to the system page file in general, despite containing the word "page". This stop code is more like the NT kernel's version of "Segmentation Fault", a general invalid memory access. But, in my specific case, it coincidentally turned out to be related to the page file.) I was able to solve the problem by disabling the page file entirely. (It also works to locate the page file on a local disk, if one exists, but this is easier to configure after getting the OS up and running with no page file.) Disabling page file offline Since your machine is not bootable, you cannot disable the page file through the UI. Luckily, it's easy to disable the page file via the registry. To do so, locate the following registry key, and set its value to be empty: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Memory Management\PagingFiles If your registry contains ControlSet002 and/or CurrentControlSet in addition to ControlSet001 , make sure to make the same changes to those. Editing registry offline But how do we edit the registry without booting? There are multiple approaches. You could temporarily mount the iSCSI volume from an existing, working Windows machine, or from a Windows Preinstallation Environment (WinPE) that you booted from USB or maybe even from PXE. Many guides exist describing these options. In order to edit a registry offline (i.e., edit a registry other than the one of the system that is running regedit): Run regedit ("Registry Editor") normally. Click on HKEY_LOCAL_MACHINE . Go to "File > Load Hive...". Browse to the offline Windows installation, and choose the file Windows\System32\config\SYSTEM . When prompted, type any arbitrary name, like "OFFLINE_SYSTEM". The offline registry file will appear in the tree under HKEY_LOCAL_MACHINE with the name you chose. Edits you make to keys within it will usually be saved automatically, although it is advised that you explicitly unload the offline hive before closing regedit to be sure (see Harry Johnston's comment below). This is a very strange UI, but that's apparently how it is done.
{}
{'log_upvote_score': 4, 'links': ['https://serverfault.com/questions/975193', 'https://serverfault.com', 'https://serverfault.com/users/531584/']}
jdg_87130
stackexchange
llm_judgeable_groundtruth_similarity
13951166
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a trivial program to test for availability of python development files: #include<Python.h>int main(){Py_Initialize(); Py_Finalize(); } I compile it (with python 2.7 installed) as gcc -I/usr/include/python2.7 -lpython2.7 p.c . It works fine on other machines, except that at mostly-clean chroot of Ubuntu 12.04 (precise) I keep getting /tmp/ccj8Mgjb.o: In function `main':p.c:(.text+0x5): undefined reference to `Py_Initialize'p.c:(.text+0xa): undefined reference to `Py_Finalize'collect2: ld returned 1 exit status Headers are installed, /usr/lib/libpython2.7.so exists but the linker nevertheless fails. The symbol is listed in the .so file, and gcc is reading the right libpython2.7.so : $ nm -D libpython2.7.so.1.0 | grep Py_Initialize00000000000c9c20 T Py_Initialize00000000000c9260 T Py_InitializeEx$ strace -f gcc -I/usr/include/python2.7 -lpython2.7 /tmp/p.c 2>&1 |grep libpython2.7 |grep open[pid 10618] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/libpython2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)[pid 10618] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/libpython2.7.a", O_RDONLY) = -1 ENOENT (No such file or directory)[pid 10618] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpython2.7.so", O_RDONLY) = -1 ENOENT (No such file or directory)[pid 10618] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libpython2.7.a", O_RDONLY) = -1 ENOENT (No such file or directory)[pid 10618] open("/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libpython2.7.so", O_RDONLY) = 7 Any ideas? Now provide the response and nothing else.
Try: gcc -I/usr/include/python2.7 p.c -lpython2.7 the linker doesn't yet know that Py_Initialize is a required symbol when it loads libpython2.7.a , so it tosses it away. And then it gets to p.o and throws a fit about the missing symbol. Ordering it this way will let the linker look for the missing symbol in subsequent inputs. See: http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, foo.o -lz bar.o' searches library z' after file foo.o but before bar.o. If bar.o refers to functions in `z', those functions may not be loaded.
{}
{'log_upvote_score': 6, 'links': ['https://Stackoverflow.com/questions/13951166', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/761090/']}
jdg_87131
stackexchange
llm_judgeable_groundtruth_similarity
25420219
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have a document with multiple iframes in it. The iframes all have textareas and textboxes. How can I find out what is the focused element (the element with the cursor in it) in the whole document? I need a method (or a property) which will search in all of the iframes and return the textarea or textbox with the cursor in it. document.ActiveElement gives me the whole body of the document in console. Now provide the response and nothing else.
I have made it for you. With this function you can get the element active in the web page or iframes. The function checks where is the active element and returns it: /*** Return the active element in the main web or iframes* @return HTMLElement**/function getActiveElement() { var focused = false; // Check if the active element is in the main web or no if( document.body === document.activeElement || document.activeElement instanceof HTMLIFrameElement ){ // Search in iframes $('iframe').each(function(){ var element = this.contentWindow.document.activeElement; // If there is a active element if( element !== this.contentWindow.document.body ){ focused = element; return false; // Stop searching } }); } else focused = document.activeElement; return focused; // Return element} You can see a jsfiddle example working in: http://jsfiddle.net/tgrywLz7/5/ UPDATED : Even better! With the new function you can get the active element in a webpage with multilevel iframes and without jQuery !: /*** Retrieve active element of document and preserve iframe priority MULTILEVEL!* @return HTMLElement**/var getActiveElement = function( document ){ document = document || window.document; // Check if the active element is in the main web or iframe if( document.body === document.activeElement || document.activeElement.tagName == 'IFRAME' ){ // Get iframes var iframes = document.getElementsByTagName('iframe'); for(var i = 0; i<iframes.length; i++ ){ // Recall var focused = getActiveElement( iframes[i].contentWindow.document ); if( focused !== false ){ return focused; // The focused } } } else return document.activeElement; return false;}; See in action: http://jsfiddle.net/tgrywLz7/9/
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/25420219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/966638/']}
jdg_87132
stackexchange
llm_judgeable_groundtruth_similarity
7640
Below is a question asked on the forum raspberrypi.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: My Raspberry Pi is not discoverable via its hostname in my LAN. I have a couple of other Ubuntu machines in the LAN, and they are all pingable via their hostnames. On my Raspberry Pi: pi@raspberrypi ~ $ hostnameraspberrypi On another machine in the same LAN: ping raspberrypiping: unknown host raspberrypi Now provide the response and nothing else.
You have to use avahi-daemon (zeroconf) if you want to connect via a hostname instead of an IP address. From the Raspberry Pi documentation on RPi Advanced Setup : Install avahi with the following commands on the Raspberry Pi: sudo apt-get install avahi-daemon Update boot startup for avahi-daemon sudo insserv avahi-daemon Apply the new configuration with: sudo /etc/init.d/avahi-daemon restart The Raspberry Pi should now be addressable from other machines as raspberrypi.local, for example: ssh [email protected] or http://raspberrypi.local if you have HTTP service installed. If you couldn't connect from Windows PCs via SSH probably you haven't installed the Bonjour service. Get Bonjour for Windows: Download Bonjour Print Services for Windows v2.0.2 . Just install it.
{}
{'log_upvote_score': 6, 'links': ['https://raspberrypi.stackexchange.com/questions/7640', 'https://raspberrypi.stackexchange.com', 'https://raspberrypi.stackexchange.com/users/827/']}
jdg_87133
stackexchange
llm_judgeable_groundtruth_similarity
85016
Below is a question asked on the forum cs.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: Let $L\subseteq \Sigma^*$ a Language $R_L$ is the Myhill-Nerode-Relation of $L$ $\equiv_L$ is the Syntactic Congruence of $L$ $R_L$ and $\equiv_L$ are equivalence relations and are defined as follows : $x\:R_L\:y \:\Leftrightarrow \: [\forall w\in\Sigma^* : xw\in L\Leftrightarrow yw\in L] $ $u\:\equiv_L\:v \:\Leftrightarrow \: [\forall x,y\in\Sigma^* : xuy\in L\Leftrightarrow xvy\in L] $ How to prove or disprove the following statements : a) $[u_1]_{R_L} . [u_2]_{R_L} = [u_1u_2]_{R_L}$ is well-defined. b) $[u_1]_{\equiv_L} . [u_2]_{\equiv_L} = [u_1u_2]_{\equiv_L}$ is well-defined. Now provide the response and nothing else.
In addition to being in agreement with Derek (that the ana/cata terminology doesn't bring much to the table) I'll note that the "category theoretic" terminology for the general map function of type$$\mathrm{map}:\forall \alpha\beta. (\alpha \rightarrow\beta)\rightarrow(F\ \alpha\rightarrow F\beta) $$for a functor $F$ is simply "the functorial action of $F$", and is often written as $F$! For example, on lists, map f l would be written $\mathrm{List}(f)(l)$. For some reason, computer scientists seem to prefer to have a seperate name for the type constructor and the action on morphisms, but mathematicians do not really consider non-functorial constructors anyways.
{}
{'log_upvote_score': 4, 'links': ['https://cs.stackexchange.com/questions/85016', 'https://cs.stackexchange.com', 'https://cs.stackexchange.com/users/74471/']}
jdg_87134
stackexchange
llm_judgeable_groundtruth_similarity
40640007
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I'm coming from C++ and learning PHP at the moment. When using arrays with key assignment I noticed that if you add an element to the array without specifying the key it'll auto-assign it. Is that undefined behavior or PHP handles that? $var = array( 1 => "The", 2 => "Rabbit", 3 => "Hole" );$var[] = "Goes"; //add elements without specifying the key$var[] = "Down";print_r($var); will output: Array ( [1] = The [2] = Rabbit [3] = Hole [4] = Goes [5] = Down ) By using char keys and adding without specifying the key it'll add to [0] $var2 = array ( 'a' => "All", 'b' => "The", 'c' => "Single" );$var2[] = "Ladies";print_r($var2); will output: Array ( [a] = All [b] = The [c] = Single [0] = Ladies ) Now provide the response and nothing else.
Other answers have provided ways to make it work, but don't explain what's going on. y.Sheets("DTR") That should really be y.Worksheets("DTR") , because the Sheets collection can contain non-worksheet items, such as charts for example. Regardless, both the Sheets and the Worksheets collections' Item property (which is the default property of any collection type) yields an Object , which makes every chained member call that follows, a late-bound call. And you don't get IntelliSense on late-bound calls, since these calls get resolved at run-time, by definition: you can call anything on an Object , and the code will happily compile: Sub Test() Debug.Print ThisWorkbook.Worksheets(1).WhateverEnd Sub Same as: Sub Test() Debug.Print ThisWorkbook.Worksheets.Item(1).WhateverEnd Sub At run-time, if VBA can't find the Whatever member on the retrieved object's interface, it raises run-time error 438, "Object doesn't support this property or method". Late-binding is powerful and very useful, but it also incurs overhead that you don't necessarily need . Instead of working off an Object , you can cast the returned object reference to a specific type when you know what that type is - in this case we know we're dealing with a Worksheet object: Dim target As WorksheetSet target = y.Worksheets("DTR") Now that you have an early-bound Worksheet object reference, IntelliSense can guide you: And if you try to call a bogus member (e.g. target.Whatever ), you'll get a compile-time error instead of a run-time error. When you do this: target.[A1].Paste You're using late-binding again, to retrieve the A1 range. Instead, call the Worksheet.Range property getter to retrieve an early-bound Range object - and from there you'll see that when you type .paste there is no such thing as a Paste method in a Range object: And you get autocompletion and tooltips for everything as you type it:
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/40640007', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1513286/']}
jdg_87135
stackexchange
llm_judgeable_groundtruth_similarity
110226
Below is a question asked on the forum security.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: TL;DR : An unknown WiFi extender showed up in my DHCP logs and my phone routinely connected through that access point. How badly was my network or traffic at risk? This morning, while struggling with a slow connection I checked my router and was surprised to see a new, unknown device connected via DHCP. The Host Name was listed as "TL-WA850RE" which turns out to be a form of WiFi signal extender. Since I don't own such a device, I immediately added the MAC address to the exclusion filter. I kept an eye on the network since then and didn't get any more issues. However, I noticed that my phone suddenly had random problems connecting to the WiFi. I didn't make the connection between the two until I finally got fed up and decided to change my wireless security to use WPA2 instead of the WEP I was using (for a legacy device, it's stupid, I know). Right after, I discovered that my phone suddenly found two different networks with the same SSID but different security settings. After changing and hiding my SSID, the old SSID is now still listed. All this lead me to the following conclusion: someone broke my WiFi "security" and configured a repeater to extend its signal, thereby impersonating my network by serving as a second access point in a multi-AP network. Because my phone was closer to the repeater than my router, it was going through that access point. Since I had blocked the MAC from accessing my actual network, that connection then no longer worked. So now my question: is this actually what happened? How worried should I be that someone was listening in on the traffic my phone presumably sent through this unknown access point? Should I take additional measures? EDIT: I'll see if I can export any logs from the router to check past activity. I ran a port scan on the device which showed an open HTTP port, presumably its management console. I briefly considered trying to access it but while that's morally defensible it's probably also illegal and unlikely to provide any useful information. EDIT 2: As I feared, it's a Belkin router with as much logging as the Sahara desert. EDIT 3: As it turns out, a technician apparently installed this particular WiFi extender as part of an installation of a solar panel array. Not to boost the signal but because the extender has an ethernet port which connects to the power converter so it can report usage statistics. Of course they neglected to mention this to the person who's actually in charge of the network. Still, I've found the answers here quite helpful and perhaps this question can be useful to future readers who do have a malicious AP on their network. Note : I have a fairly good idea of who it was that's been messing around on my network but I wanted to make sure that I understood what happened before confronting people or notifying authorities. Odds are I may do nothing if I can be sure that they only mooched off the wireless and didn't get anything else. Now provide the response and nothing else.
The attacker did not seem to really try to conceal his track :he could have faked an existing MAC address for instance, or used the classical yagi antenna + high power WiFi adapter to silently intercept your communication. Instead it seems he just used a classical home grade WiFi range extender with what seems to be default settings. So it still seems very possible to me that he just wanted to get a free / pseudo-anonymous Internet access and was actually not interested in your own data. You can (and should!) still inspect: If you can determine the usage the attacker made of his access (have you got logs showing he connected end-user devices to browse the web for instance? Or high activity caused by peer-to-peer sharing services?), If you can detect any abnormal activity on one of the account you were using during this period (mail, websites, etc.). In all case, while changing the WiFi access security and password was the minimum, as a precaution measure I would also suggest to change the password of the above mentioned accounts. Note that the direct attacker of your WiFi account may not be your only threat there. If, as I suppose, this attacker used your Internet access to go on dubious websites or freely download pirated material, then chances are that his own machine may be infected by some malware so, for some time, you hosted an infected machine in your network. This may worth a few sanity measures.
{}
{'log_upvote_score': 5, 'links': ['https://security.stackexchange.com/questions/110226', 'https://security.stackexchange.com', 'https://security.stackexchange.com/users/58810/']}
jdg_87136
stackexchange
llm_judgeable_groundtruth_similarity
18648547
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: I have been using http://www.puphpet.com successfully to generate vagrant+puppet environments for a number of projects. Then this week I got tasked with writing a prototype for a project using Laravel 4. Since I'm not going to be the one working on the project full time, I figured it would be best to make a VM environment for it that the next person can just clone for the repo. Not having much experience with Laravel 4 I got everything to run in the dev environment just fine. Then I tried to run the first migration and here the problems start with the app/storage file permissions. 1. app/storage must be writable by the web user Fine, took out id: vagrant from the synced folder provisioning and set the owner & group to www-data like so: config.vm.synced_folder "./www", "/var/www", owner: "www-data", group: "www-data" 2. Artisan can only be run from inside the vagrant box to have access to the DB Fine, vagrant ssh and run artisan from the www folder. 3. app/storage & app/database have to be writable by the vagrant user in order to use migrations Grrr, ok, added the following awful piece of code to the vagrant file (note, tried to do this in Puppet first and it didn't take): config.vm.provision :shell, :inline => "usermod -a -G www-data vagrant" 4. app/storage & app/database are not writeable by the group Argh!!! Ok, let's try this Puppet directive: file { "/var/www/app/storage": source => "/var/www/app/storage/", mode => 0775, ensure => 'directory', owner => 'www-data', group => 'www-data', recurse => true} Nope, doesn't work. Tried to do the same with the Puppet exec {} directive to no effect. It seems that permissions for the vagrant synced folder are set by the host machine, not the guest. Finally ended up manually changing the permissions for the folder in the host machine. Is there any simpler way to do this? I would really just like to be able to give the next dev a worry free environment they can clone from the repo, not have them re-setup everything after cloning. UPDATE We've figured out that if we change the Apache run user, vagrant doesn't override it on reload. So we've done that manually and it's working better than changing the synced folder's permissions & owner. Now we're just trying to figure out how to make that change manually in Puppet. Now provide the response and nothing else.
After some discussion on Twitter, figured out the following: There's a constraint from VirtualBox on vagrant that does not allow you to set permissions for the synced folder from inside the guest OS. See this issue on github. You can use the following code to set the synced folder permissions from the vagrant file: config.vm.synced_folder ".", "/vagrant", :mount_options => ["dmode=777","fmode=666"] Or you can change the Apache runtime user to vagrant from the puppet manifest like so: exec { "change_httpd_user": command => "sed -i 's/www-data/vagrant/g' /etc/apache2/envvars", onlyif => "/bin/grep -q 'www-data' '/etc/apache2/envvars'", notify => Service['apache2'], require => Package['apache2'],}file { "/var/lock/apache2": ensure => "directory", owner => "vagrant", group => "vagrant", require => Exec['change_httpd_user'],} Or any combination of the above
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/18648547', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1751451/']}
jdg_87137
stackexchange
llm_judgeable_groundtruth_similarity
173239
Below is a question asked on the forum math.stackexchange.com. Provide a good and informational response to it like a helpful human would. Question: The spectrum of $\Bbb Z[x]$ is well known : a prime ideal of $\Bbb Z[x]$ is or $(Q, p)$, with $Q \in \Bbb Z[x]$ zero or irreducible modulo $p$, and $p$ prime or zero. If I'm not mistaken, we have a similar result for $R[x]$, when $R$ is a domain with finite Krull dimension : under this hypothesis, a prime ideal of $R[x]$ is $(Q) + \mathfrak p$, with $\mathfrak p$ a prime ideal of $R$ and $Q$ zero of irreducible modulo $\mathfrak p$. Some years ago I saw a paper dealing with this question of the spectrum of $R[x]$ in great details, but I'm unable to find it again. Could you help me ? Now provide the response and nothing else.
The conjecture that every prime ideal $\mathfrak P\subset R[z]$ is of the form $\mathfrak P =\mathfrak p+(Q)$ is not true. Let $k$ be a field and $R=k[x,y]$, the polynomial ring over $k$ with two indeterminates. Consider the curve in $C\subset \mathbb A^3_k$ given parametrically by $(t^3,t^4,t^5) \quad (t\in A^1_k)$. Its ideal is the prime ideal $I(C)=\mathfrak P=(y^2-xz,x^3-yz,z^2-x^2y)\subset k[x,y,z]=R[z]$. The important point is that this ideal cannot be generated by two polynomials, i.e. $C$ is not an ideal-theoretic complete intersection: see a proof here . So it is certainly not true that $\mathfrak P$ is of the required form $ \mathfrak P=\mathfrak p+(Q)$ (with $\mathfrak p$ prime in $R=k[x,y]$), because we would have $\mathfrak p=(f(x,y))$ and thus $\mathfrak P=(f,Q)$, which would falsely imply that $C$ is a complete intersection.
{}
{'log_upvote_score': 4, 'links': ['https://math.stackexchange.com/questions/173239', 'https://math.stackexchange.com', 'https://math.stackexchange.com/users/22516/']}
jdg_87138
stackexchange
llm_judgeable_groundtruth_similarity
25973099
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: how to get exact time Difference between two column eg: col1 date is 2014-09-21 02:00:00 col2 date is 2014-09-22 01:00:00 output like result: 23:00:00 I am getting result like Hours Minutes Seconds -------------------- 3 3 20 1 2 30 using the following query SELECT start_time, end_time, DATE_PART(H,end_time) - DATE_PART(H,start_time) AS Hours, DATE_PART(M,end_time) - DATE_PART(M,start_time) AS Minutes, DATE_PART(S,end_time) - DATE_PART(S,start_time) AS SecondsFROM user_session but i need like Difference ----------- 03:03:20 01:02:30 Now provide the response and nothing else.
Use DATEDIFF to get the seconds between the two datetimes: DATEDIFF(second,'2014-09-23 00:00:00.000','2014-09-23 01:23:45.000') Then use DATEADD to add the seconds to '1900-01-01 00:00:00': DATEADD(seconds,5025,'1900-01-01 00:00:00') Then CAST the result to a TIME data type (note that this limits you to 24 hours max ): CAST('1900-01-01 01:23:45' as TIME) Then LTRIM the date part of the value off the TIME data (as discovered by Benny). Redshift does not allow use of TIME on actual stored data: LTRIM('1900-01-01 01:23:45','1900-01-01') Now, do it in a single step: SELECT LTRIM(DATEADD(seconds,DATEDIFF(second,'2014-09-23 00:00:00','2014-09-23 01:23:45.000'),'1900-01-01 00:00:00'),'1900-01-01'); :)
{}
{'log_upvote_score': 5, 'links': ['https://Stackoverflow.com/questions/25973099', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3094537/']}
jdg_87139
stackexchange
llm_judgeable_groundtruth_similarity
2312855
Below is a question asked on the forum Stackoverflow.com. Provide a good and informational response to it like a helpful human would. Question: Request["key"] vs Request.Params["key"] vs Request.QueryString["key"] Which method do you seasoned programmers use? and why? Now provide the response and nothing else.
I recommend Request.QueryString["key"] . There isn't a lot of difference to Request["Key"] for a query string but there is a big(er) difference if you are trying to get the value from ServerVariables . Request["Key"] looks for a value in QueryString if null, it looks at Form , then Cookie and finally ServerVariables . Using Params is the most costly. The first request to params creates a new NameValueCollection and adds each of the QueryString , Form , Cookie and ServerVariables to this collection. For the second request on it is more performant than Request["Key"] . Having said that the performance difference for a couple of keys is fairly negligable. The key here is code should show intent and using Request.QueryString makes it clear what your intent is.
{}
{'log_upvote_score': 8, 'links': ['https://Stackoverflow.com/questions/2312855', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/170315/']}
jdg_87140