qid
int64
10
74.7M
question
stringlengths
15
26.2k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
27
28.1k
response_k
stringlengths
23
26.8k
13,140,481
Pandoc, when it parses a document, includes a metadata block. The Title part of the metadata block is of type [Inline], a markup data type specific to Pandoc. I am trying to find a way to convert that to Html so that I can embed that text directly into the Header element of an outgoing Html document. What function, or combination of functions, is necessary to do this conversion? ``` [Inline] -> Html [Str "My", Space, Str "Title"] -> ("My Title" :: Html) ``` * Inline is a data type for inline markup provided in Pandoc * Html is the generic Html data type provided by Blaze Html For the interim, I'm going to hack a function that handles Str and Space, but I know that I'm eventually going to need the way to do it that handles all of the Inline constructors.
2012/10/30
[ "https://Stackoverflow.com/questions/13140481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/575152/" ]
There are only a few helper functions that I've found that come along Pandoc ([Data.Text.Pandoc.Shared](http://hackage.haskell.org/packages/archive/pandoc/1.9.1.2/doc/html/Text-Pandoc-Shared.html#g:4) and by your example the `stringify` function would be all you need (this functions do note that it removes any formatting, which I guess is not important for text that goes into the header element). ``` inlineToHtml i = (Data.Text.Pandoc.Shared.stringify i) :: Html ```
What you want is this: ``` inlinesToHtml :: [Inline] -> Html inlinesToHtml = writeHtml defaultWriterOptions . Plain ```
10,234,227
We have a (Numeric 3 float) vector class that I would love to align to 16-bytes in order to allow SIMD oerations. Using declspec to 16-byte align it causes a slew of C2719 errors (parameter': formal parameter with \_\_declspec(align('#')) won't be aligned). If I can't pass around a vector aligned, what's the point? Even using a const reference to the vector is causing the compiler error which really annoys me. Is there a way to do what I want here - get 16-byte class alignment while allowing struct passing without having to do some silly trickery to \_\_m128 types?
2012/04/19
[ "https://Stackoverflow.com/questions/10234227", "https://Stackoverflow.com", "https://Stackoverflow.com/users/527574/" ]
> > If I can't pass around a vector aligned, what's the point? > > > `__declspec(align(#))` does seem rather useless. C++11 has support for what you want; `alignas` appears to work in all the ways that `__declspec(align(#))` is broken. For example, using `alignas` to declare your type will cause parameters of that type to be aligned. Unfortunately Microsoft's compiler doesn't support standard alignment specifiers yet, and the only compiler I know of that does is Clang, which has limited support for Windows. Anyway, I just wanted to point out that C++ has this feature and it will probably be available to you eventually. Unless you can move to another platform then for now you're probably best off with not passing parameters by value, as others have mentioned
There is a \_\_declspec(passinreg) that's supported on Xbox360, but not in Visual Studio for Windows at the moment. You can vote for the request to support the feature here: <http://connect.microsoft.com/VisualStudio/feedback/details/381542/supporting-declspec-passinreg-in-windows> For vector arguments in our engine we use a `VectorParameter` typedef'ed to either `const Vector` or `const Vector&` depending on whether the platform supports passing by register.
22,993,949
I create a table into a php file with 2 rows and a button on each last `<td>`: ``` <table id="filterTableMsg" border="1" class="TF"> <tbody><tr><th>Message Title</th><th>Message</th><th>Schedule Date</th><th>share</th> </tr> <tr class="row_hover"> <td>hello</td> <td>hello message</td> <td>2014-04-09 00:11:51</td> <td><button id="FBshare">share it!</button></td> </tr> <tr class="row_hover"> <td>hello again</td> <td>hello new message</td> <td>2014-04-08 10:15:21</td> <td><button id="FBshare">share it!</button></td> </tr> </tbody> </table> ``` When I press a button (`id="FBshare"`) I need to get the row index and then get the value of cell[0], cell[1] and cell[2], with jQuery. I try to solve this with this code but it returns 'undefined' : ``` $(function() { /*when i click on the FBshare button*/ $(document).on('click', '#FBshare', function(e){ e.preventDefault(); var mytable = $('#filterTableMsg tr:eq(1) td');//for example to get the 2nd row alert(mytable.eq(2).html());//here i try to get the html of the 2nd cell but i get 'undifined }); ``` I can get the index of the row of the button by writing this: ``` alert($(this).closest('tr').index()); // but I can't make them work all together. ``` Has anyone faced the same or similar problem? Please give a hand
2014/04/10
[ "https://Stackoverflow.com/questions/22993949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3520356/" ]
Add at the top of your code ``` session_start(); ``` Replace ``` if ($count==1) { header( "refresh:0;url=backoffice.php" ); ``` } with ``` if ($count==1) { header( "refresh:0;url=backoffice.php" ); $_SESSION['logged']="true"; } ``` Then, in backoffice.php, put at the top ``` <?php session_start(); if($_SESSION['logged']!="true"){echo 'Error! You\'re not logged in!';} else{//your code } ?> ```
``` <html> <script> function val() { var x=document.getElementById("a1").value; if((x==" ")||(x=="")) { document.getElementById("nameerror").innerHTML="name field can't be empty"; return false; } } </script> <style> .error {color:red;} </style> <body> <form onsubmit="return val()"> <p style="color:red">*required field</p> <br /> Name: <input type="text" id="a1"><span class="error">*</span> <span id="nameerror" class="error"></span><br> <br> E-mail: <input type="text"><br> <br> Website: <input type="text"><br> <br> Comment: <textarea name="comment" rows="5" cols="30"></textarea><br> <br> Gender:<input type="radio" name="gender">Female <input type="radio" name="gender">Male<br> <br> <input type="submit" value="Submit" onclick="val()"> </form> </body> </html> ```
938,049
I tried to display the url using all sorts of methods of HttpRequest, I tried VirtualPathUtility object as well, but I never was able to display the hidden portion "default.aspx" of the default... what is the method or property that retrieves this segment of the url? reason being, I am so close to creating a 404 on application level that catches all 404s, even html pages, by using File.Exist() on the mapped path of the url, unfortunately, that does not work on the default page. I have seen few articles trying to do the opposite, remove default.aspx when it occurs, this is not the case here. Edit: here is what I am trying: ``` string fullOrigionalpath = context.Request.CurrentExecutionFilePath.ToString(); bool newUrl = System.IO.File.Exists(context.Server.MapPath(fullOrigionalpath)); if (!newUrl) throw new HttpException(404,"page not found"); ``` now you see, if the page is **localhost/lexus/default.aspx**, it works fine with no errors, but if I type in the address **<http://localhost/lexus/>**, the error is thrown, because if you try to output the fullOriginalPath, it does not have "default.aspx" part of it, so Exists returns false! do you have a better way of checking for validity of physical files?
2009/06/02
[ "https://Stackoverflow.com/questions/938049", "https://Stackoverflow.com", "https://Stackoverflow.com/users/63202/" ]
I don't think this is at all possible, so I relied on IIS7.0 rewrite feature to force the default.aspx to appear at all times..
I'm not sure what you mean by "hidden portion" but have you tried ... ``` Request.Url.ToString() ```
41,422,790
I m newbee in laravel. I am sending such type of response through Postman. and in Laravel controller I m getting this response in $request. ``` [{ "id": 40, "cname": "Ramesh", "constraint_value": "", "r_id": "6", "rtype_id": null, "deleted_at": null, "created_at": null, "updated_at": null, "input": "111", "input2": "111" }, { "id": 45, "cname": "Suresh", "constraint_value": "", "r_id": "6", "rtype_id": null, "deleted_at": null, "created_at": null, "updated_at": null, "input": "222", "input2": "222" }, { "id": 49, "cname": "Raj", "constraint_value": "", "r_id": "6", "rtype_id": null, "deleted_at": null, "created_at": null, "updated_at": null, "input": "333", "input2": "333" }] ``` I am facing difficulty in 1. How to count the total no of objects in array which I am receiving in $request. I had used count($request) or sizeOf($request) but its returning only 1 although there are 3 arrays. Help me in this. 2. How to save the data in database through such arrays.I want to save the values of input and input2.
2017/01/02
[ "https://Stackoverflow.com/questions/41422790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6845316/" ]
Probably late, but may help someone in the future. First of all. You need to iterate over the array of objects like so ``` foreach($request->all() as $key => $value){ $model = new Model(); $model->attribute1 = $value['attribute1']; $model->attribute2 = $value['attribute1']; $model->attributeN = $value['attributeN']; // where N is infinite # of attr $model->save(); } ``` So what is happening is that each time the loop iterates, it create a new object of your `Model` type inside the loop and assigns the objects attributes from the array key values and persists in `DB` and repeats until all the objects in the array are finished. The ``` $model = new Model(); ``` is necessary so that each time loop iterates It creates a new object and persists. The loop may save only one object if u do not create it each time the `N` iteration occurs. This may happen if u are creating the model object in the constructor where it is instantiated once when the constructor is run. Hope this helps.
I got the solution. I was making mistake in sending the data from angularjs.I was directly sending the POST request without creating its object like `var data = { 'data':my_request}` .That is why request was reeving with instance in laravel. But, as I start sending data by creating its object its working. This was the solution for my first problem. Help me how to store that received data in database.
52,215,264
in python you could do something like this ``` def divide(numerator, denominator): if numerator == denominator: raise(ZeroDivisionError) ``` what would the equivalent by in c# be?
2018/09/07
[ "https://Stackoverflow.com/questions/52215264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9742648/" ]
> > What is the syntax to raise an error in c#? > > > What you are *generally asking about* is [Creating and Throwing Exceptions (C# Programming Guide)](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/creating-and-throwing-exceptions). Excerpt: > > Exceptions are used to indicate that an error has occurred while running the program. Exception objects that describe an error are created and then thrown with the throw keyword. The runtime then searches for the most compatible exception handler. > > > ``` class ProgramLog { System.IO.FileStream logFile = null; void OpenLog(System.IO.FileInfo fileName, System.IO.FileMode mode) {} void WriteLog() { if (!this.logFile.CanWrite) { throw new System.InvalidOperationException("Logfile cannot be read-only"); } // Else write data to the log and return. } } ``` The actual *answer to your question* is to use the keyword [throw](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/throw). Generally it's used like: ``` throw new Exception(); throw new ArgumentNullException(); throw new DivideByZeroException(); ``` and in the case when you want to [*rethrow* the exception after you catch it](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/throw#re-throwing-an-exception): ``` throw; ``` Now there are few things to consider when throwing exceptions; [does the exception exist already](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/exceptions/compiler-generated-exceptions) and what exception should I consider throwing. I would suggest reading [Eric Lippert's Blog - Vexing exceptions](https://blogs.msdn.microsoft.com/ericlippert/2008/09/10/vexing-exceptions/) regarding what you should consider catching and throwing.
``` public int Divide(int numerator, int denominator) { try { return numerator / denominator; } catch (DivideByZeroException divideByZeroException) { Logger.Error("Divide by zero exception", divideByZeroException); } catch (Exception exception) { Logger.Error(exception); } return 0; } ```
4,467,011
I think, now is the time I should move on to do different area of mathematics. I have done real analysis and topology from Baby Rudin and James Munkres, respectively. I’m thinking to do linear algebra. I’m looking for “standard text” in linear algebra. By standard text, I mean standard text in real analysis is Baby Rudin, Tom Apostol, etc, and in topology Munkres, Dugundji etc. I have seen linear algebra done right by Axler and linear algebra by Hoffman book. IMO those book is basic to my taste. Dugundji is an amazing topology book. Is there an equivalent book in linear algebra? By equivalent I mean, in terms of rigorousness and exercise/problem in textbook. **Edit:** I read almost all linear algebra book recommended by SE users. One thing is common in those books are examples and computational problems. There are lots & lots of examples(in the order of 10 in each section). Some examples involve concepts of number theory, matrix, etc. which I have never studied. **I guess, I’m looking for a book which don’t contain crazy amount of examples.**
2022/06/06
[ "https://math.stackexchange.com/questions/4467011", "https://math.stackexchange.com", "https://math.stackexchange.com/users/861687/" ]
Note that $a\_\pm =\sqrt{\frac{1\pm i\sqrt3}{2}}=\frac{\sqrt3\pm i}2$ and \begin{align} I=&\ \frac 12 \int\_0^\infty \frac{\arctan x\ln(1+x^2)}{x(x^4+x^2+1)} dx\\ =& \ \frac{1}{2\sqrt 3 i} \int\_0^\infty \frac{\arctan x\ln(1+x^2)}{x(x^2+a\_-^2)}-\frac{\arctan x\ln(1+x^2)}{(x^2+a\_+^2)}\ dx\\ = & \ \frac\pi{4\sqrt3 i}\bigg(\frac{\ln^2(a\_- +1)}{a\_-^2}- \frac{\ln^2(a\_+ +1)}{a\_+^2} \bigg)\\ =& \ \frac\pi{4\sqrt3 i}\bigg(\frac{\ln(a\_- +1)}{a\_-}- \frac{\ln(a\_++1)}{a\_+} \bigg)\bigg(\frac{\ln(a\_- +1)}{a\_-}+\frac{\ln(a\_+ +1)}{a\_+} \bigg)\\ =& \ \frac\pi{4\sqrt3 i}\cdot\frac{\sqrt3 \pi -6\ln(2+\sqrt3)}{12i} \cdot \frac{6\sqrt3\ln(2+\sqrt3)+\pi}{12}\\ = &\ \frac\pi{16}\ln^2(2+\sqrt3)-\frac{\pi^2}{48\sqrt3}\ln(2+\sqrt3)-\frac{\pi^3}{576} \end{align}
Note that $$\Im\left(-\frac{2}{\sqrt{3}\left(x^2+\frac{1}{2}+\frac{i\sqrt{3}}{2}\right)} \right) = \frac{1}{x^4+x^2+1}$$ Hence $$ I=\frac 12 \int\_0^\infty \frac{\arctan (x) \ln(1+x^2)}{x(x^4+x^2+1)} \mathrm dx = \Im \left( -\frac{1}{\sqrt{3}} \int\_0^\infty \frac{\arctan (x) \ln(1+x^2)}{x\left(x^2+\frac{1}{2}+\frac{i\sqrt{3}}{2}\right)} \mathrm dx \right) $$ which is just the imaginary part of $$ -\frac{1}{\sqrt{3}}\int\_0^\infty \frac{\arctan(x)\ln(1+x^2)}{x(a^2+x^2)} \ \mathrm dx={\color{Red} { -\frac{\pi \log^2(a+1)}{2\sqrt{3}a^2}}}$$ with $ \displaystyle a = \sqrt{\frac{1}{2}+\frac{i\sqrt{3}}{2}}$ Hence \begin{align\*} I =& \Im\left(-\frac{\pi \left(\frac{1}{2}-\frac{i\sqrt{3}}{2} \right)\log^2\left(1 + \sqrt{\frac{1}{2}+\frac{i\sqrt{3}}{2}}\right)}{2\sqrt{3}}\right) \\ =& \Im\left(-\frac{\pi \left(\frac{1}{2}-\frac{i\sqrt{3}}{2} \right)\left[\ln\left|1 + \sqrt{\frac{1}{2}+\frac{i\sqrt{3}}{2}}\right| + i\arg\left(1 + \sqrt{\frac{1}{2}+\frac{i\sqrt{3}}{2}}\right) \right]^2}{2\sqrt{3}}\right)\\ =& \Im\left(-\frac{\pi \left(\frac{1}{2}-\frac{i\sqrt{3}}{2} \right)\left[\frac{1}{2}\ln(2+\sqrt{3}) + i\frac{\pi}{12}\right]^2}{2\sqrt{3}}\right)\\ =& \Im\left(-\frac{\pi \left(\frac{1}{2}-\frac{i\sqrt{3}}{2} \right)\left[\frac{\log^2(2+\sqrt{3})}{4} + \frac{ \pi i\ln(2+\sqrt{3})}{12} - \frac{\pi^2}{144} \right]}{2\sqrt{3}}\right)\\ =& -\frac{\pi^2\ln(2+\sqrt{3})}{48\sqrt{3}}+ \frac{\pi\ln^2(2+\sqrt{3})}{16} -\frac{\pi^3}{576} \end{align\*}
15,984,623
I have a String and an int, lets say: `String str = "12345";` and `int num = 12345;`. What is the fastest way of seeing if they are the same, `str.equals("" + num)` or `num == Integer.parseInt(str)` (Or is there a faster way?)? This is the source code for [Integer.parseInt](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/Integer.java#Integer.parseInt%28java.lang.String%2Cint%29) and [String.equals](http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/lang/String.java#String.equals%28java.lang.Object%29)
2013/04/13
[ "https://Stackoverflow.com/questions/15984623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1896169/" ]
`num == Integer.parseInt(str)` is going to faster than `str.equals("" + num)` `str.equals("" + num)` will first convert num to string which is O(n) where n being the number of digits in the number. Then it will do a string concatenation again O(n) and then finally do the string comparison. String comparison in this case will be another O(n) - n being the number of digits in the number. So in all ~3\*O(n) `num == Integer.parseInt(str)` will convert the string to integer which is O(n) again where n being the number of digits in the number. And then integer comparison is O(1). So just ~1\*O(n) To summarize both are O(n) - but `str.equals("" + num)` has a higher constant and so is slower.
I think `num == Integer.parseInt(str)` is a better way of doing comparison. Because `str.equals("" + num)` this is not the ideal way how you should compare integer values and also it will create unnecessary String constant objects in the String pool (which hampers performance).
33,304,889
I used alphahull package to delineate dots on a map. I plot the contours with a geom\_segment. My question is : how to fill the delineation given by the segment with a color ? Here is a reproducible example : ``` set.seed(2) dat <- data.frame(x = rnorm(20, 10, 5), y = rnorm(20, 20, 5), z = c(rep(1, 6), rep(2, 4))) library(ggplot2) library(alphahull) alpha <- 100 alphashape1 <- ashape(dat[which(dat$z==1), c("x", "y")], alpha = alpha) alphashape2 <- ashape(dat[which(dat$z==2), c("x", "y")], alpha = alpha) map <- ggplot(dat, aes(x = x, y = y)) + geom_point(data = dat, aes(x = x, y = y, colour = as.factor(dat$z))) + geom_segment(data = data.frame(alphashape1$edges), aes(x = x1, y = y1, xend = x2, yend = y2, colour = levels(as.factor(dat$z))[1])) + geom_segment(data = data.frame(alphashape2$edges), aes(x = x1, y = y1, xend = x2, yend = y2, colour = levels(as.factor(dat$z))[2])) map ``` [![enter image description here](https://i.stack.imgur.com/LwdpW.jpg)](https://i.stack.imgur.com/LwdpW.jpg)
2015/10/23
[ "https://Stackoverflow.com/questions/33304889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5445495/" ]
This is because the `ashape` function only returns segments, not in any order. The only way I found to reconstruct the order was by using the node information to form a graph and then find the shortest path along that graph. A detailed example is here: <https://rpubs.com/geospacedman/alphasimple> - the code needs wrapping into a single function, which should be fairly easy to do. Once you have that order sorted, `geom_polygon` will draw it with filled shading in `ggplot2`.
Based on Spacedman's answer, I ordered separately the two sets of points and came up with this solution. It could be optimized with a function that does it for each group automatically. ``` set.seed(2) dat <- data.frame(x = rnorm(20, 10, 5), y = rnorm(20, 20, 5), z = c(rep(1, 6), rep(2, 4))) library(ggplot2) library(alphahull) alpha <- 100 alphashape1 <- ashape(dat[which(dat$z==1), c("x", "y")], alpha = alpha) alphashape2 <- ashape(dat[which(dat$z==2), c("x", "y")], alpha = alpha) map <- ggplot(dat, aes(x = x, y = y)) + geom_point(data = dat, aes(x = x, y = y, colour = as.factor(dat$z))) + geom_segment(data = data.frame(alphashape1$edges), aes(x = x1, y = y1, xend = x2, yend = y2, colour = levels(as.factor(dat$z))[1])) + geom_segment(data = data.frame(alphashape2$edges), aes(x = x1, y = y1, xend = x2, yend = y2, colour = levels(as.factor(dat$z))[2])) map alpha <- 15 # transparency argument # First contour alphashape1 <- ashape(dat[which(dat$z == 1), c("x", "y")], alpha = alpha) alphashape1_ind <- alphashape1$edges[, c("ind1", "ind2")] class(alphashape1_ind) = "character" alphashape1_graph <- graph.edgelist(alphashape1_ind, directed = FALSE) cut_graph1 <- alphashape1_graph - E(alphashape1_graph)[1] # Cut the first edge ends1 <- names(which(degree(cut_graph1) == 1)) # Get two nodes with degree = 1 path1 <- get.shortest.paths(cut_graph1, ends1[1], ends1[2])$vpath[[1]] path_nodes1 <- as.numeric(V(alphashape1_graph)[path1]$name) # Second contour alphashape2 <- ashape(dat[which(dat$z == 2), c("x", "y")], alpha = alpha) alphashape2_ind <- alphashape2$edges[, c("ind1", "ind2")] class(alphashape2_ind) = "character" alphashape2_graph <- graph.edgelist(alphashape2_ind, directed = FALSE) cut_graph2 <- alphashape2_graph - E(alphashape2_graph)[1] # Cut the first edge ends2 <- names(which(degree(cut_graph2) == 1)) # Get two nodes with degree = 1 path2 <- get.shortest.paths(cut_graph2, ends2[1], ends2[2])$vpath[[1]] path_nodes2 <- as.numeric(V(alphashape2_graph)[path2]$name) # Updating of previous plot (see question) map + geom_polygon(data = dat[which(dat$z == 1), c("x", "y")][path_nodes1, ], aes(x = x, y = y), fill = "red", colour = "red", size = 0.5, alpha = 0.3) + geom_polygon(data = dat[which(dat$z == 2), c("x", "y")][path_nodes2, ], aes(x = x, y = y), colour = "blue", fill = "blue", size = 0.5, alpha = 0.3) ``` [![enter image description here](https://i.stack.imgur.com/QH59M.jpg)](https://i.stack.imgur.com/QH59M.jpg)
4,077
In 2 Kings 19 king Hezekiah faces a great threat to Jerusalem from the Assyrian king. He delivers a message to Isiah with the following words: > > This day is a day of distress and rebuke and disgrace, as when > children come to the moment of birth and there is no strength to > deliver them... > > > (2 Kings 19:3) I have a really hard time understanding the picture of a child birth in this context. What is it that I'm missing? Who are the children that not yet are born? Is it the peoples "salvation" from the Assyrian king? And it seems to be near, the children had come to the moment of birth. But it's something missing. What's that?
2013/02/01
[ "https://hermeneutics.stackexchange.com/questions/4077", "https://hermeneutics.stackexchange.com", "https://hermeneutics.stackexchange.com/users/552/" ]
Interesting answers... Looking at the Hebrew (and some other translations), I would hazard that another accurate translation would be something like: > > Thus says Hizqiyyahu: This day is a day of distress, and of reproach, and of disgrace. For the children have come to the moment of breaking, but there is not enough strength for birthing. > > > So it's not a hypothetical simile, "this situation is like when this thing happens in the abstract", but more immediate: "this situation can be described as this thing happening". Writing it out, it sounds like a very subtle and perhaps not significant difference, but in my head I understand it differently this way. The children are the Israelites, who are powerless to defend themselves against the besieging Assyrians, i.e. trapped in the womb (Jerusalem) without the strength to break free. G!d's miraculous rescue is a sort of Divine C-section, then, if it is not blasphemous to make such a comparison (in Judaism we would say *lehavdil*).
When we are helpless, God is helpful. They felt hopeless against their enemies. But God had already planned to fight for them.
282,452
How to upgrade Magento 2.3.1 to Magento 2.3.2 ?
2019/07/18
[ "https://magento.stackexchange.com/questions/282452", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/52888/" ]
As far as I know, there are two main ways: * If using command line composer, you can follow this guide: <https://devdocs.magento.com/guides/v2.3/comp-mgr/cli/cli-upgrade.html> * <https://devdocs.magento.com/guides/v2.3/comp-mgr/upgrader/upgrade-start.html> (I haven't tried yet with Admin) With the command line and Open source version, on your local machine, you can follow: 1) `composer require magento/product-community-edition=2.3.2 --no-update` 2) Apply updates: `composer update`. 3) Clean the Magento cache `php bin/magento cache:clean` or `rm -rf var/cache/* var/page_cache/* generated/code/*` 4) Update the database schema and data `php bin/magento setup:upgrade`
Please use below commands to upgrade from **2.3.1 to 2.3.2** > > (it is wise to keep backup of source code and database before upgrade) > > > ``` php bin/magento maintenance:enable composer require magento/product-community-edition 2.3.2 --no-update composer update rm -rf var/cache/ rm -rf generated/ chmod +x bin/magento php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php bin/magento indexer:reindex php bin/magento maintenance:disable ```
137,933
We are writing a complex rich desktop application and need to offer flexibility in reporting formats so we thought we would just expose our object model to a scripting langauge. Time was when that meant VBA (which is still an option), but the managed code derivative VSTA (I think) seems to have withered on the vine. What is now the best choice for an embedded scripting language on Windows .NET?
2008/09/26
[ "https://Stackoverflow.com/questions/137933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9731/" ]
[IronPython](https://ironpython.net/). Here's a guide on [how to embed it](https://www.codeproject.com/Articles/53611/Embedding-IronPython-in-a-C-Application).
Try [Ela](http://elalang.net/). This is a functional language similar to Haskell and can be [embedded](http://elalang.net/docs/Article.aspx?p=embedding.htm) into any .Net application. Even it has simple but usable IDE.
41,587,811
I generate table using itextsharp and I would like to retreive the rectangle coordinate of a specific cell in the table. I can't find a way to acheive this. Let say I have a table with 3 columns and 3 rows. I would like to retreive the rectangle coordinate of the middle cell on second row. The table is added using columnText with AddElement. From what I can see, I can get the Y or X for the table element once added to the document, but I can't find an easy way to get the rectangle coordinate of a specific cell. Any hint?
2017/01/11
[ "https://Stackoverflow.com/questions/41587811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2155911/" ]
Since this question is still getting alot of attention and none of the soulotions yet provide the full answer that I was trying to achieve, I'll give an example how I solved it some years ago. > > First to make the animation go left to right, like many other questions have showed: > > > ```css #pot { bottom: 15%; position: absolute; -webkit-animation: linear infinite; -webkit-animation-name: run; -webkit-animation-duration: 5s; } @-webkit-keyframes run { 0% { left: 0; } 50% { left: 100%; } 100% { left: 0; } } ``` ```html <div id="pot"> <img src="https://i.stack.imgur.com/qgNyF.png?s=328&g=1" width=100px height=100px> </div> ``` The problem with only this solution is that the potato goes too far to the right so it gets pushed out from the viewport before turning around. As the user Taig suggested we can use `transform: translate` solution, but we can also just set `50% { left: calc(100% - potatoWidth); }` > > Second to make the animation go left to right, without getting pushed > out from viewport: > > > ```css #pot { bottom: 15%; position: absolute; -webkit-animation: linear infinite; -webkit-animation-name: run; -webkit-animation-duration: 5s; } @-webkit-keyframes run { 0% { left: 0; } 50% { left: calc(100% - 100px); } 100% { left: 0; } } ``` ```html <div id="pot"> <img src="https://i.stack.imgur.com/qgNyF.png?s=328&g=1" width=100px height=100px> </div> ``` And lastly to make potato turn around which I also asked for in the question. To do that we need to change the transform around it's y-axis. Note that if we make it turn around only at 50% it will slowly turn around at the same time it's moving. So we need to specify how long the potato should be at `-webkit-transform: rotateY(0deg);`. In this example the potato doesn't turn until it's 48% into the animation, then it's able to turn in the span of 48% to 50%. > > Third to make the potato turn around in each corner so it doesn't move backwards: > > > ```css #pot { bottom: 15%; position: absolute; -webkit-animation: linear infinite; -webkit-animation-name: run; -webkit-animation-duration: 5s; } @-webkit-keyframes run { 0% { left: 0; } 48% { -webkit-transform: rotateY(0deg); } 50% { left: calc(100% - 100px); -webkit-transform: rotateY(180deg); } 98% { -webkit-transform: rotateY(180deg); } 100% { left: 0; -webkit-transform: rotateY(0deg); } } ``` ```html <div id="pot"> <img src="https://i.stack.imgur.com/qgNyF.png?s=328&g=1" width=100px height=100px> </div> ```
The accepted answer has the flaw that the element is completely pushed out of the viewport during the animation. This might be desired for some use cases, but I wanted to share a cleaner solution that leverages the CSS `transform: translate` property. ```css #pot { bottom: 15%; display: block; position: absolute; animation: linear infinite alternate; animation-name: run; animation-duration: 2s; } @-webkit-keyframes run { 0% { left: 0; transform: translateX(0); } 100% { left: 100%; transform: translateX(-100%); } } ``` ```html <img id="pot" src="https://i.stack.imgur.com/qgNyF.png?s=328&g=1" width="100px" height="100px" /> ``` I wrote in a bit more detail about this technique here: <https://medium.com/@taig/dynamically-position-and-center-an-html-element-with-css-based-on-percentage-5fea0799a589>.
2,396,238
When I using the following code to read file: ``` lines=file("data.txt").read().split("\n") ``` I have the following error ``` MemoryError ``` the file size is ``` ls -l -rw-r--r-- 1 charlie charlie 1258467201 Sep 26 12:57 data.txt ```
2010/03/07
[ "https://Stackoverflow.com/questions/2396238", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130272/" ]
Obviously the file is too large to be read into memory all at once. Why not just use: ``` with open("data.txt") as myfile: for line in myfile: do_something(line.rstrip("\n")) ``` or, if you're not on Python 2.6 and higher: ``` myfile = open("data.txt") for line in myfile: do_something(line.rstrip("\n")) ``` In both cases, you'll get an iterator that can be treated much like a list of strings. EDIT: Since your way of reading the entire file into one large string and then splitting it on newlines will remove the newlines in the process, I have added a `.rstrip("\n")` to my examples in order to better simulate the result.
use this code to read file line by line: ``` for line in open('data.txt'): # work with line ```
34,986,655
How do programmers code proper loading screens? This is how I envision the code behind a loading screen, but I was wondering if there is a better way than just a bunch of conditional statements: ``` loading = 0 def load(percent): while percent <= 100: if percent == 0: foo.loadthing() # Just an example function percent += 10 else if percent == 10: foo.loadthing() percent += 10 ... else if percent == 100: foo.loadthing() load(loading); ```
2016/01/25
[ "https://Stackoverflow.com/questions/34986655", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5721459/" ]
I think you got it backward. I wouldn't code a loading screen based from a loading screen. Not sure about your language i hope you'll understand my c# prototype ``` //Gui thread var screen = LoadingScreen.Show(); await doWork(); //<- c# way to make doWork happen on 2nd thread and continue after the thread has been finished. screen.Hide(); //somewhere else async void doWork() { for(int i = 0; i < filesToLoad; ++i) { LoadFile(i); LoadingScreen.SetPercentage = 100.0 * i / filesToLoad; } } ``` what you see happening here is 2 threads. 1 thread (gui) that shows the loadingscreen for as long as the 2nd thread is doing work. This 2nd thread will send updates to the loading screen saying 'hey i did some more work, please update' **Update** Ah now i see you're using python. My idea should still stand though. You should loop over the work you need to be doing and then calculate the updates from there.
This should work ``` import time import replit from random import randint percent = 0 for i in range(100): replit.clear() percent +=1 print(""" LOADING SCREEN Status: loading %"""+ str(percent) ) time.sleep(randint(1,2)) print("Loading complete!\n") print("Now...") time.sleep(2) print("What you have been waiting for...") time.sleep(2) print("Nothing") ```
12,314,734
I'm wondering what is the right way to store the following data inside an MySQL DB. Let's say an object for example a video. and I want to store the the rating which was give to it by other user, so on option is create a column and store the ID of the users and their rating in a complex way, like that: ``` | ID | video_name | rating (usrID,rating) | | 5 | cool video | (158,4),(5875,1),(585,5) | ``` I guess that it is not the most efficient way to do so. Is there a way to store a table inside of a row? what is the most efficient way to do it so I can use SQL query on the rating without processing the data via a PHP code?
2012/09/07
[ "https://Stackoverflow.com/questions/12314734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1192761/" ]
Create a second table, `ratings`: ``` +----------+---------+--------+ | video_id | user_id | rating | +----------+---------+--------+ | 5 | 158 | 4 | | 5 | 5875 | 1 | | 5 | 585 | 5 | +----------+---------+--------+ ``` You can then *group* and/or [join](http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html) this table in queries, as desired; for example: ``` SELECT videos.*, AVG(ratings.rating) FROM videos JOIN ratings ON videos.id = ratings.video_id GROUP BY videos.id ```
The normal way is an entity relationship diagram. Then you have ratings \* --- 1 video That is, you have a table "video" ``` ID | Name 5 | cool video ``` And a table "ratings" ``` ID | value | USERID | video_ID 1 | 4 | 158 | 5 2 | 1 | 5875 | 5 3 | 5 | 585 | 5 ```
2,246,099
Suppose there is a polynomial: $$P(z) = a\_0 + a\_1z +a\_2z^2 +\dots +a\_nz^n,\quad (a\_n \ne 0)$$ Let $$w = \frac{a\_0}{z^n} + \frac{a\_1}{z^{n-1}} + \frac{a\_2}{z^{n-2}} + \dots + \frac{a\_{n-1}}{z},$$ Why is it that for a sufficiently large positive number $R$, the modulus of each of the quotients in the expression $w$ is less than the number $\frac{\lvert a\_n \rvert}{2n}$ when $\lvert z \rvert > R$
2017/04/22
[ "https://math.stackexchange.com/questions/2246099", "https://math.stackexchange.com", "https://math.stackexchange.com/users/339070/" ]
Since, $a\_n\not=0$ we have $|a\_n|\not=0$. Now, we have to find a positive real number $R\_0$ such that for any complex number $z$ with $|z|> R\_0$ we have $$\left |\frac{a\_0}{z^n}\right|=\frac{|a\_0|}{|z^n|}=\frac{|a\_0|}{|z|^n}<\frac{|a\_n|}{2n},$$$$\left |\frac{a\_1}{z^{n-1}}\right|=\frac{|a\_1|}{|z^{n-1}|}=\frac{|a\_1|}{|z|^{n-1}}<\frac{|a\_n|}{2n},$$$$\vdots$$$$\left |\frac{a\_{n-2}}{z^2}\right|=\frac{|a\_{n-2}|}{|z^2|}=\frac{|a\_{n-2}|}{|z|^2}<\frac{|a\_n|}{2n},$$$$\left |\frac{a\_{n-1}}{z}\right|=\frac{|a\_{n-1}|}{|z|}<\frac{|a\_n|}{2n}.$$ In other words, we have to find a positive real number $R\_0$ such that for any complex number $z$ with $|z|> R\_0$ we have $$\frac{2n|a\_0|}{|a\_n|}<|z|^n,\frac{2n|a\_1|}{|a\_n|}<|z|^{n-1},...,\frac{2n|a\_{n-2}|}{|a\_n|}<|z|^2,\frac{2n|a\_{n-1}|}{|a\_n|}<|z|.$$ But, the above inequalities hold **if and only if** $$\left(\frac{2n|a\_0|}{|a\_n|}\right)^{\frac{1}{n}}<|z|,\left(\frac{2n|a\_1|}{|a\_n|}\right)^{\frac{1}{n-1}}<|z|,...,\left(\frac{2n|a\_{n-2}|}{|a\_n|}\right)^{\frac{1}{2}}<|z|,\frac{2n|a\_{n-1}|}{|a\_n|}<|z|.$$ So, we may take $$R\_0:=1+\max\left\{\left(\frac{2n|a\_0|}{|a\_n|}\right)^{\frac{1}{n}},\left(\frac{2n|a\_1|}{|a\_n|}\right)^{\frac{1}{n-1}},...,\left(\frac{2n|a\_{n-2}|}{|a\_n|}\right)^{\frac{1}{2}},\frac{2n|a\_{n-1}|}{|a\_n|}\right\}.$$ So, for any complex number $z$ with $$|z|>R\_0>\max\left\{\left(\frac{2n|a\_0|}{|a\_n|}\right)^{\frac{1}{n}},\left(\frac{2n|a\_1|}{|a\_n|}\right)^{\frac{1}{n-1}},...,\left(\frac{2n|a\_{n-2}|}{|a\_n|}\right)^{\frac{1}{2}},\frac{2n|a\_{n-1}|}{|a\_n|}\right\}$$$$\implies|z|>\left(\frac{2n|a\_k|}{|a\_n|}\right)^{\frac{1}{n-k}}\text{ for each }k=0,1,...,(n-2),(n-1)$$$$\implies |z|^{n-k}>\frac{2n|a\_k|}{|a\_n|}\text{ for each }k=0,1,...,(n-2),(n-1)$$$$\implies\frac{|a\_n|}{2n}>\frac{|a\_k|}{|z|^{n-k}}=\frac{|a\_k|}{|z^{n-k}|}=\left|\frac{a\_k}{z^{n-k}}\right|\text{ for each }k=0,1,...,(n-2),(n-1).$$
Take the inequality ||> as true. Both are scalars and real, then according to the theorem the reals are ordered: 1/||<1/. Since the potential is preserving the order for all positive integer n: 1/z^n<^/^n. Consider the numbers from 1 to n then this inequality is true for all these numbers. Now =()/z^n. We know not much about the sequence a\_i i=1,...n-1, but if goes larger and larger the well ordered of the reals warrants that each summand will get smaller than 1. But that is a fairly upper bound. The largest term for z->0 is the last term in because it is only -1 in the exponent. It does not matter how small or big −1 is, for large enough values of z it starts to dominate the sum. A simple example is this: [![Plot](https://i.stack.imgur.com/GiFaS.png)](https://i.stack.imgur.com/GiFaS.png) This is the case all coefficients equal and n=3. The simple sum of the coefficients is an upper limit for the over the reals. Since the b=Max[{a(m)/z^m:0<=m<=n-1}] has a such that b/z^n-k<a(n-1)/z k the index of the maximum of the coefficients. It is possible to replace the summands with this maximum: (n-1)b/z^n-k<n-1)a(n-1)/z [![example](https://i.stack.imgur.com/Yy2Zs.png)](https://i.stack.imgur.com/Yy2Zs.png) The green line is the |()|/2 in the choosen example. At this point of the discussion, it is necessary that all a(m)>0 if 0 then this summand is irrelevant to the discussion. The larger the a(m) are the larger but the point is warranted by the well order of the reals. If n the number of coefficients is fixed, but z raises to infinity z always dominates and the sum gets smaller, the first derivative in negative on the positive reals. < ||/2 independent of the magnitude of a(n). There can too be another arbitrary positive number or even smaller ones be selected and this occurs for larger and larger z. The point is that can be greater than n max[{a(m),0<=m<=n-1}]/z and this is steadily decreasing for z getting bigger. a(n)/(2n) is another limit that is beaten be increasing z. Therefore exists for sure. |()|/2 is a constant for the problem during z and can be chosen arbitrarily large. lim w for z->oo is 0!
788,348
I installed XAMPP 1.6.8 and for some reason it didn't work. Later realized port 80 is not free or not listening. How can I release it or make it free? Thanks a lot!
2009/04/25
[ "https://Stackoverflow.com/questions/788348", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
use **netstat -bano** in an elevated command prompt to see what apps are listening on which ports. But Usually following applications uses port 80 in windows. 1. IIS 2. World Wide Web Publishing service 3. IIS Admin Service 4. SQL Server Reporting services 5. Web Deployment Agent Service Stop above applications if running and check!!!
Identify the real process programmatically ------------------------------------------ ### (when the process ID is shown as 4) The answers here, as usual, expect a level of interactivity. The problem is when something is listening through HTTP.sys; then, the PID is always 4 and, as most people find, you need some tool to find the real owner. Here's how to identify the offending process programmatically. No TcpView, etc (as good as those tools are). Does rely on netsh; but then, the problem is usually related to HTTP.sys. ``` $Uri = "http://127.0.0.1:8989" # for example # Shows processes that have registered URLs with HTTP.sys $QueueText = netsh http show servicestate view=requestq verbose=yes | Out-String # Break into text chunks; discard the header $Queues = $QueueText -split '(?<=\n)(?=Request queue name)' | Select-Object -Skip 1 # Find the chunk for the request queue listening on your URI $Queue = @($Queues) -match [regex]::Escape($Uri -replace '/$') if ($Queue.Count -eq 1) { # Will be null if could not pick out exactly one PID $ProcessId = [string]$Queue -replace '(?s).*Process IDs:\s+' -replace '(?s)\s.*' -as [int] if ($ProcessId) { Write-Verbose "Identified process $ProcessId as the HTTP listener. Killing..." Stop-Process -Id $ProcessId -Confirm } } ``` Originally posted here: <https://stackoverflow.com/a/65852847/6274530>
65,262,340
**C:\Android\sdk\bin>sdkmanager** Error: Could not determine SDK root. Error: Either specify it explicitly with --sdk\_root= or move this package into its expected location: \cmdline-tools\latest\ it shows like this, even after specifying the root in env variables. ANDROID\_SDK\_ROOT C:\Android\sdk I am using windows 10 64 bit machine, I want to run flutter without android studio so followed instruction on this page <https://medium.com/@quicky316/install-flutter-sdk-on-windows-without-android-studio-102fdf567ce4>
2020/12/12
[ "https://Stackoverflow.com/questions/65262340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11004696/" ]
You can create a folder `latest` inside your `cmdline-tools` and move all it's contents inside this folder. So, your full path will be `C:\Android\cmdline-tools\latest\bin`. Using this config there is no need to define a `ANDROID_SDK_ROOT` environment variable or a `--sdk_root=` option. It'll assume that your SDK folder is `C:\Android`, and it'll put all your files (system-images, licenses, ...) inside it.
Try the below command it will work perfectly: ``` sdkmanager --sdk_root=path-to-where-cmdline-tools-is "platform-tools" "platforms;android-29" ```
193,315
Is there a noun form of the verb "to decline"? That is, is there a word that follows this pattern: ``` to accept -> acceptance to decline -> ? ``` I am aware of the word declination which is the closest I've found, but that seems to reflect the meaning of "decline" as related to "incline" and "recline" rather than the synonym of refuse. If not, are there synonyms of "decline" that follow this pattern?
2014/08/26
[ "https://english.stackexchange.com/questions/193315", "https://english.stackexchange.com", "https://english.stackexchange.com/users/66815/" ]
I think you may use; [Denial](http://www.thefreedictionary.com/Denial): > > * a refusal to agree or comply with a statement; > > > [Refusal](http://www.thefreedictionary.com/refusal): > > * the act or an instance of refusing > > > Source: www.thefreedictionary.com
> > I'm disinclined to acquiesce to your request. Means "no". > > > *Captain Barbossa, Pirates of the Caribbean: The Curse of the Black Pearl* Perhaps "disinclination" suits your description? 1. the absence of inclination; reluctance; unwillingness.
8,152,814
Is it possible to do a javascript action after play button is pushed? I know I will need to use onStateChange function form Youtube's API. But I really don't know where to start? Any help? Thank you. -- I have also found something here: <http://apiblog.youtube.com/2011/01/introducing-javascript-player-api-for.html>
2011/11/16
[ "https://Stackoverflow.com/questions/8152814", "https://Stackoverflow.com", "https://Stackoverflow.com/users/872981/" ]
Here's a solution that you should be able to extend easily: <http://jsbin.com/evagof>
``` <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load("swfobject", "2.1"); </script> <script type="text/javascript"> // Update a particular HTML element with a new value function updateHTML(elmId, value) { document.getElementById(elmId).innerHTML = value; } // This function is called when the player changes state function onPlayerStateChange(newState) { updateHTML("playerState", newState); if(newState === 1){ //if the player is now playing //add your code here } } // This function is automatically called by the player once it loads function onYouTubePlayerReady(playerId) { ytplayer = document.getElementById("ytPlayer"); // This causes the updatePlayerInfo function to be called every 250ms to // get fresh data from the player setInterval(updatePlayerInfo, 250); updatePlayerInfo(); ytplayer.addEventListener("onPlayerStateChange"); } // The "main method" of this sample. Called when someone clicks "Run". function loadPlayer() { // The video to load var videoID = "ylLzyHk54Z0" // Lets Flash from another domain call JavaScript var params = { allowScriptAccess: "always" }; // The element id of the Flash embed var atts = { id: "ytPlayer" }; // All of the magic handled by SWFObject (http://code.google.com/p/swfobject/) swfobject.embedSWF("http://www.youtube.com/v/" + videoID + "?version=3&enablejsapi=1&playerapiid=player1", "videoDiv", "480", "295", "9", null, null, params, atts); } function _run() { loadPlayer(); } google.setOnLoadCallback(_run); </script> <div id="videoDiv">Loading...</div> <p>Player state: <span id="playerState">--</span></p> ``` <http://code.google.com/apis/ajax/playground/?exp=youtube#polling_the_player>
5,648,771
When checking if a integer is the same or above a current number.. so I type ``` if (5 => 6) { //Bla } ``` but it shows this as a error. Why? Isn't it exactly the same as ``` if (5 >= 6) { //Bla } ```
2011/04/13
[ "https://Stackoverflow.com/questions/5648771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1656790/" ]
The confusion here is that you're assuming >= is two operators smooshed together. In fact, it's only one operator with two characters, much the same as tons of other operators (+=, \*=, -=, etc).
Because it is called greater or equal to. Not equal or greater than. Simple uh?
167,060
I have the posts which have many custom defined meta fields. On posts I am calling them on requirement using `get_post_meta`. Means for 10 meta fields I am using it 10 times. Am I doing it right? Means, is there any performance issue with the above method and if yes then how to reduce the number of calls. I am aware of the answer available here: [Custom Fields and performance](https://wordpress.stackexchange.com/questions/19344/custom-fields-and-performance) which explains that the use of 'single query'. But it is not clear and sound so asking again if somebody knows and want to share in detail.
2014/10/31
[ "https://wordpress.stackexchange.com/questions/167060", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31989/" ]
To answer this, I have gone and done some tests on this, and the results was actually mind blowing. Here is my test =============== *To this yourself, set yourself up with a test page. Just simply copy page.php, rename it and delete the loop. Now just create a new page in the back end. Before you start, first test your timer with empty info to get the amount of queries without any data* I have created 5 meta fields altogether for a test post, * `enclosure`, * `First name`, * `Last name`, * `packages` and * `post_views_count` My test post had an ID of `530`. Inside a post you can just simply use `$post->ID` or `get_the_ID()` to set the post ID So my first test was as follows: ``` <?php timer_start(); $a = get_post_meta(530, 'enclosure', true); $b = get_post_meta(530, 'First name', true); $c = get_post_meta(530, 'Last name', true); $d = get_post_meta(530, 'packages', true); $e = get_post_meta(530, 'post_views_count', true); ?> <p><?php echo get_num_queries(); ?> queries in <?php timer_stop(1, 5); ?> seconds. </p> ``` which gave me the following results > > 1 queries in 0.00195 seconds. > > > My second test was as follows: ``` <?php timer_start(); $a = get_post_meta(530); ?> <p><?php echo get_num_queries(); ?> queries in <?php timer_stop(1, 5); ?> seconds. </p> ``` which, surprisingly gave the same result > > 1 queries in 0.00195 seconds. > > > If you look at the [source code](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/post.php#L1932) for [`get_post_meta()`](http://codex.wordpress.org/Function_Reference/get_post_meta), you'll see that `get_post_meta()` is simply just a wrapper for `get_metadata()`. So this is were you need to look. The [source code](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/meta.php#L440) for [`get_metadata()`](http://codex.wordpress.org/Function_Reference/get_metadata), you'll see that the metadata get cached. So on your question about which to use and about performance, the answer will be, it is up to you. You have seen the proof in the results In my personal opinion, if you need to retrieve 10 meta data fields, (or in my case 5), use the second approach in my answer. ``` $a = get_post_meta(530); ``` It is not only quicker to write, but you should also not repeat code. Another point to note here, the second approach holds all meta fields in an array which can be very easily accessed and retrieved Just as matter of example, here is my output from `$a` if I do a `var_dump( $a );` ``` array(9) { ["_edit_lock"]=> array(1) { [0]=> string(12) "1414838328:1" } ["_edit_last"]=> array(1) { [0]=> string(1) "1" } ["_custom_sidebar_per_page"]=> array(1) { [0]=> string(7) "default" } ["post_views_count"]=> array(1) { [0]=> string(1) "0" } ["packages"]=> array(1) { [0]=> string(1) "0" } ["repeatable_names"]=> array(1) { [0]=> string(79) "a:1:{i:0;a:3:{s:4:"role";s:4:"fool";s:4:"name";s:6:"Pieter";s:3:"url";s:0:"";}}" } ["enclosure"]=> array(1) { [0]=> string(105) "http://localhost/wordpress/wp-content/uploads/2014/09/Nissan-Navara-Tough-City.avi 13218974 video/avi " } ["First name"]=> array(1) { [0]=> string(3) "Tom" } ["Last name"]=> array(1) { [0]=> string(5) "Storm" } } ``` You can now access any of the returned meta data in your post as follows: ``` echo $a['First name'][0] . " " . $a['Last name'][0] . "<br>"; ``` Which will display > > Tom Storm > > >
You can use `get_post_meta` to fetch all meta field values at once. ``` $meta = get_post_meta( get_the_ID() ); ``` This will fetch all meta values of the given post. Use that array instead of fetching individually.
43,575,366
I'm trying to calculate how long one person stays in a homeless shelter using R. The homeless shelter has two different types of check-ins, one for overnight and another for a long-term. I would like to shape the data to get an EntryDate and ExitDate for every stay which does not have at least a one day break. Here are what the data currently look like: ``` PersonalID EntryDate ExitDate 1 2016-12-01 2016-12-02 1 2016-12-03 2016-12-04 1 2016-12-16 2016-12-17 1 2016-12-17 2016-12-18 1 2016-12-18 2016-12-19 2 2016-10-01 2016-10-20 2 2016-10-21 2016-10-22 3 2016-09-01 2016-09-02 3 2016-09-20 2016-09-21 ``` Ultimately, I'm trying to get the above date to represent continuous ranges to calculate total length of stay by participant. For example, the above data would become: ``` PersonalID EntryDate ExitDate 1 2016-12-01 2016-12-04 1 2016-12-16 2016-12-19 2 2016-10-01 2016-10-22 3 2016-09-01 2016-09-02 3 2016-09-20 2016-09-21 ```
2017/04/23
[ "https://Stackoverflow.com/questions/43575366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2108441/" ]
Usually the `100vh` height will account for the adjusted height, with is why you'll sometimes see mobile pages go funky when the browser's address bar slides down. For browsers that don't account for the sliding bar within the `vh` unit: The height for the address bars will not be constant across the browsers, so I'd advise against appending `-50px`. Try setting the height of the page (using javascript) with the `window.innerheight` property. ``` function resetHeight(){ // reset the body height to that of the inner browser document.body.style.height = window.innerHeight + "px"; } // reset the height whenever the window's resized window.addEventListener("resize", resetHeight); // called to initially set the height. resetHeight(); ```
Use `height: 100%` which gives you the height after reducing the menu bar's height. You can test the difference between `100vh` and `100%` by using `document.getElementsByTagName('html')[0].scrollHeight` on mobile browser. For me (Chrome on Andriod), `100vh` returns a higher value than `100%`, which always giving me a vertical scrollbar, even if I haven't added anything in the html body.
349,927
Is there a way to play music through Headphone connector (HI-FI system) and Bluetooth (Wireless speaker in different place) **simultaneously** ? It seems that I can only choose one or the other, but it seems so simple there might be a way to do so. Thanks
2019/01/28
[ "https://apple.stackexchange.com/questions/349927", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/319076/" ]
Its no posible (whitout jailbreack). The cheapest form to do that is: buy two "airport express" (off second hand because Apple dont sales any more), and use airplay. In that way, connect the plug off audio to airport, &, in your iphone can see the two devices (or the cuantity thath you showld buy) to send music at all them.
Unfortunately this is not possible with the native OS. This is possible though of you have 2 speakers and both compatible with AirPlay 2. Whilst not giving the exact same effect it is similar in some ways to what you want. Any device with this logo on the packaging should work with AirPlay 2. [![logo](https://i.stack.imgur.com/NnC79.png)](https://i.stack.imgur.com/NnC79.png) Also, your iPhone must be running iOS 11.4 or later. To view the full requirements go [here.](https://support.apple.com/en-gb/HT208728#airplay2) Then view [this article](https://support.apple.com/HT208744) on how to stream to multiple speakers.
7,684,473
I'd like to do this simply without saving the starting value of the select in an object. if i have (when i load the dom): ``` <select> <option value='1' selected>one</option> <option value='2' >Two</option> ``` and than i later change the selection so that another option is selected, is there some kind of property that stores the value of the option that was originally selected?
2011/10/07
[ "https://Stackoverflow.com/questions/7684473", "https://Stackoverflow.com", "https://Stackoverflow.com/users/397861/" ]
You should use the defaultSelected property of the options object to test if it was selected by default. <http://www.javascriptkit.com/jsref/select.shtml>
use this ``` $('select').find('option[selected]').val(); ``` **[DEMO](http://jsfiddle.net/zu5af/)**
13,036,490
I am trying to run a simple hello world example in python that runs against mongodb. I've set up mongo, bottle and pymong and have the following script inside `C:\Python27\Scripts`: ``` import bottle import pymongo @bottle.route('/') def index() from pymongo import Connection connection = Connection('localhost', 27017) db = connection.test names = db.names item = names.find_one() return '<b>Hello %s!</b>' % item['name'] bottle.run(host='localhost', port=8082) -!-- hello.py All L8 (Python) ``` I want to run this locally and I go to `http://localhost:8082` but I get not found not found. How can I run that code to test it locally on my computer so I can test the code via the browser. I am running Windows 7 and have WAMP installed.
2012/10/23
[ "https://Stackoverflow.com/questions/13036490", "https://Stackoverflow.com", "https://Stackoverflow.com/users/865939/" ]
Change this: ``` public function __construct($Host, $User, $Pass, $Name){ $dbHost = $Host; $dbUser = $User; $dbPass = $Pass; $dbName = $Name; $this->dbConnect(); } ``` to this: ``` public function __construct($Host, $User, $Pass, $Name){ $this->dbHost = $Host; $this->dbUser = $User; $this->dbPass = $Pass; $this->dbName = $Name; $this->dbConnect(); } ```
How about using **this->** ``` public function __construct($Host, $User, $Pass, $Name){ $this->dbHost = $Host; $this->dbUser = $User; $this->dbPass = $Pass; $this->dbName = $Name; $this->dbConnect(); } ```
49,374,192
I have large datasets from 2 sources, one is a huge csv file and the other coming from a database query. I am writing a validation script to compare the data from both sources and log/print the differences. One thing I think is worth mentioning is that the data from the two sources is not in the exact same format or the order. For example: Source 1 (CSV files): ``` email1@gmail.com,key1,1 email2@gmail.com,key1,3 email1@gmail.com,key2,1 email1@gmail.com,key3,5 email2@gmail.com,key3,2 email2@gmail.com,key3,2 email3@gmail.com,key2,3 email3@gmail.com,key3,1 ``` Source 2 (Database): ``` email key1 key2 key3 email1@gmail.com 1 1 5 email2@gmail.com 3 2 <null> email4@gmail.com 1 1 5 ``` The output of the script I want is something like: ``` source1 - source2 (or csv - db): 2 rows total with differences email2@gmail.com 3 2 2 email3@gmail.com <null> 3 1 source2 - source1 (or db-csv): 2 rows total with differences email2@gmail.com 3 2 <null> email4@gmail.com 1 1 5 ``` The output format could be a little different to show more differences, more clearly (from thousands/millions of records). I started writing the script to save the data from both sources into two dictionaries, and loop through the dictionaries or create sets from the dictionaries, but it seems like a very inefficient process. I considered using pandas, but pandas doesn't seem to have a way to do this type of comparison of dataframes. Please tell me if theres a better/more efficient way. Thanks in advance!
2018/03/19
[ "https://Stackoverflow.com/questions/49374192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7483951/" ]
You were in the right path. What do you want is to quickly match the 2 tables. Pandas is probably overkill. You probably want to iterate through you first table and create a dictionary. What you **don't** want to do, is interact the two lists for each elements. Even little lists will demand a large searches. The [ReadCsv](https://docs.python.org/2/library/csv.html) module is a good one to read your data from disk. For each row, you will put it in a dictionary where the key is the email and the value is the complete row. In a common desktop computer you can iterate 10 millions rows in a second. Now you will iterate throw the second row and for each row you'll use the email to get the data from the dictionary. See that this way, since the dict is a data structure that you can get the key value in O(1), you'll interact through N + M rows. In a couple of seconds you should be able to compare both tables. It is really simple. Here is a sample code: ``` import csv firstTable = {} with open('firstTable.csv', 'r') as csvfile: reader = csv.reader(csvfile, delimiter=',') for row in reader: firstTable[row[0]] = row #email is in row[0] for row2 in get_db_table2(): email = row2[0] row1 = firstTable[email] #this is a hash. The access is very quick my_complex_comparison_func(row1, row2) ``` If you don't have enough RAM memory to fit all the keys of the first dictionary in memory, you can use the [Shelve module](https://docs.python.org/3/library/shelve.html) for the firstTable variable. That'll create a index in disk with very quick access. Since one of your tables is already in a database, maybe what I'd do first is to use your database to load the data in disk to a temporary table. Create an index, and make a inner join on the tables (or outer join if need to know which rows don't have data in the other table). Databases are optimized for this kind of operation. You can then make a select from python to get the joined rows and use python for your complex comparison logic.
You can using `pivot` convert the df , the using `drop_duplicates` after `concat` ``` df2=df2.applymap(lambda x : pd.to_numeric(x,errors='ignore') pd.concat([df.pivot(*df.columns).reset_index(),df2)],keys=['db','csv']).\ drop_duplicates(keep=False).\ reset_index(level=0).\ rename(columns={'level_0':'source'}) Out[261]: key source email key1 key2 key3 1 db email2@gmail.com 3 2 2 1 csv email2@gmail.com 3 2 <null> ``` Notice , here I am using the `to_numeric` to convert to numeric for your df2
69,506,468
In data table component footer , there is select option that i need to change its numbers How can I do it ? [![enter image description here](https://i.stack.imgur.com/I5HCA.png)](https://i.stack.imgur.com/I5HCA.png)
2021/10/09
[ "https://Stackoverflow.com/questions/69506468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14952975/" ]
``` def fingersUp(self): fingers = [] if len(self.lmList): if self.lmList[self.tipIds[0]][1] > self.lmList[self.tipIds[0]-1][1]: fingers.append(1) else: fingers.append(0) for id in range(1,5): if self.lmList[self.tipIds[id]][2]< self.lmList[self.tipIds[id]-2][2]: fingers.append(1) else: fingers.append(0) else: fingers = [0,0,0,0,0] return fingers ```
[enter image description here](https://i.stack.imgur.com/3iwD4.png) 1.Indentation 2. Missing "\_ "
40,732
When I go to the "Likes" section of the YouTube video manager under my account I can only see 2 pages of the likes list and the last video in the list is for sure far not the first video I've ever liked. I am actively using YouTube for years, clicking "like" to be able to revisit the video, but now I can only see a small part of all I've liked. I believe that I have once opened the full list but I can't remember how did I do that. Do you happen to know the way? If there is no way to do this through the YouTube UI, solutions involving API usage are also welcome. I just don't want to lose the list.
2013/02/21
[ "https://webapps.stackexchange.com/questions/40732", "https://webapps.stackexchange.com", "https://webapps.stackexchange.com/users/6386/" ]
The problem is that YouTube is limiting every playlist to 200 entries. A solution I came across is to create a new playlist, put the 200 displayed entries from your liked list inside, and delete them from the liked list. The liked list is then not empty, but contains 200 previously liked videos. Proceed until you have all liked videos in playlists.
Here is how I view all my liked videos on YouTube: Go to your "Liked Videos" section and click **play** on one of the videos. Next to the video playing is a playlist of your liked videos (in black color). To the top of this playlist is the title **Liked Videos** Just click that and that's it. At the bottom of the new page there is "Load more" button and it loads 100 videos every time it's clicked so you can view all your liked videos! Take care! :)
36,329,001
Today,I am looking into send Email, but when I add ``` <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.2.5.RELEASE</version> </dependency> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> </dependency> <dependency> <groupId>javax.mail</groupId> <artifactId>javax.mail-api</artifactId> <version>1.5.5</version> </dependency> ``` to pom.xml and deploy on the server, I get an " Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath." validation exception. I'm just added the dependency above and the one for email to a template MVC project. Error stacktrace: ``` DEBUG: org.springframework.ui.context.support.UiApplicationContextUtils - Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.DelegatingThemeSource@20212230] DEBUG: org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean - Failed to set up a Bean Validation provider javax.validation.ValidationException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath. at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:271) at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:223) at org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean.afterPropertiesSet(OptionalValidatorFactoryBean.java:40) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:667) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:633) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:681) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:552) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:493) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1241) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1154) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1041) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4944) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) ```
2016/03/31
[ "https://Stackoverflow.com/questions/36329001", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6138670/" ]
In my case, I moved to Hibernate 7.x but had an old explicit dependency on: ``` <dependency> <artifactId>validation-api</artifactId> <groupId>javax.validation</groupId> <version>2.0.1.Final</version> </dependency> ``` Once I removed this dependency, and allowed Hibernate to transitively pull in the dependency to the Jakarta Bean Validation API (jakarta.validation:jakarta.validation-api:3.0.0). Everything worked fine.
I made it work downgrading the dependency of hibernate-validator from version `7.0.2.Final` to `6.0.13.Final`. This is how my dependencies look like: ``` <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>2.0.1.Final</version> </dependency> <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> <version>6.0.13.Final</version> </dependency> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.el</artifactId> <version>3.0.0</version> </dependency> ```
4,928,135
A character `char` maybe of size one byte but when it comes to four bytes value e.g `int` , how does the cpu differ it from an integer instead of four characters per byte?
2011/02/07
[ "https://Stackoverflow.com/questions/4928135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/607339/" ]
The CPU executes code which you made. This code tells the CPU how to **treat** the few bytes at a certain memory, like "take the four bytes at address 0x87367, treat them as an integer and add one to the value". See, it's you who decide how to treat the memory.
Are you asking a question about CPU design? Each CPU machine instruction is encoded so that the CPU knows how many bits to operate on. The C++ compiler knows to emit 8-bit instructions for `char` and 32-bit instructions for `int`.
44,613,748
I'm trying to set a round image at the top of a page (like a profile page). The image is rectangular and about 300x200. I've tried these ways: 1) Using the Ion-Avatar Tag 2) Using Ion-Image tag, setting the border radius in the scss None of these methods worked. The image just kept showing squared (and eventually shrinked) inside a grey circle: [![enter image description here](https://i.stack.imgur.com/pAKEX.jpg)](https://i.stack.imgur.com/pAKEX.jpg) Any suggestions?
2017/06/18
[ "https://Stackoverflow.com/questions/44613748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4116960/" ]
you can try with css ```css .image { height: 5vw; width: 5vw; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 5px gray; display: inline-block; margin-left: auto; margin-right: auto; } .circle-pic{ width:50px; height:50px; -webkit-border-radius: 50%; border-radius: 50%; } ``` ```html <div class="image"> </div> <p>or if you want only image try this</p> <img class="circle-pic" src="http://autokadabra.ru/system/uploads/users/18/18340/small.png?1318432918" /> ```
In ionic 3, you can do this... ``` <ion-avatar> <img src=""> </ion-avatar> ``` That simple In some cases, you may need to set the img height and width to the same value manually. But this is the standard ionic 3 method. <https://ionicframework.com/docs/components/#avatar-list>
1,893,221
**Theorem :** Given any sequence either there will exist a subsequence which is increasing or there will exist a subsequence which is decreasing (and possibly both) **Partial Proof:** Given a sequence $x\_1 , x\_2, x\_3, ...$ let the set $C$ of positive integers be given by $C = \{N \in Naturals :$ if $m > N$ then $x\_m < x\_N \} $. If $C$ is not bounded above then there exists $k\_1 < k\_2 < k\_3 < ...$ in $C$. The fact that $k\_1 \in C$ ensures that if $m > k\_1$ then $x\_m < x\_{k\_1}$. In particular $x\_{k\_2} < x\_{k\_1}$. Then the fact that $k\_2 \in C$ ensures that if $m > {k\_2}$ then $x\_m < x\_{k\_2}$. In particular $x\_{k\_3} < x\_{k\_2}$. Continuing this way we can see that $x\_{k\_1} > x\_{k\_2} > x\_{k\_3} > .....$ and we have found a decreasing subsequence. **Questions:** 1. I do not understand what the set $C$ means? Which positive integers is the author pointing at? 2. I am also not able to follow the argument which shows the existence of a decreasing subsequence?
2016/08/15
[ "https://math.stackexchange.com/questions/1893221", "https://math.stackexchange.com", "https://math.stackexchange.com/users/95532/" ]
Set $C$ consists of the indices of all the elements that are greater than all the later elements. You should read the definition carefully to understand this. If the sequence is $1,10,2,8,3,7,6,5,4,4,4,4,4,4,4,\ldots$ then $C=\{2,4,6,7,8\}$ because the $10, 8, 7 ,6,5$ are greater than anything that follows and everything else is at least tied. If we change it to $1,10,2,8,3,7,6,5,4,3,2,1,0,-1,-2,-3,\ldots$ the new $C$ is $\{2,4,6,7,8,9,10,11,12,13,\ldots \}$. By the construction, if we take the elements corresponding to the numbers in $C$, we will have a decreasing sequence. In the second example, where $C$ is unbounded, the decreasing sequence is $10,8,7,6,5,4,3,2,1,0,-1,-2,-3,\ldots$ Presumably the argument defines another set where the final inequality is $x\_m \gt x\_N$. If that set is unbounded, it will give us an infinite increasing sequence. Now we have to make an argument in case both sets are bounded.
call the sequence $S=\{x\_n\}$ if any value $a$ is repeated an infinite number of times then we can derive a weakly increasing sequence consisting of the $x\_n$ satisfying $x\_n=a$ if the sequence is unbounded then a monotonic subsequence can be selected using the set $C$ defined in the question. so we need only consider bounded sequences in which each value occurs only once. by a Heine-Borel argument the set of values taken by the sequence must have at least one limit point, say $b$. if any $x\_n=b$ then remove it from consideration. now consider the sequence $S'=\{\frac1{x\_n-b}\}$. This is unbounded so we may select a monotonic subsequence $S''=\{\frac1{x\_{n\_j}-b}\}$. now $\{x\_{n\_j}\}$ is a monotonic subsequence of S.
5,957,039
I read this code on [HTMLCodeTutorial.com](http://www.htmlcodetutorial.com/forms/_INPUT_onClick.html): ``` <FORM> <TABLE BORDER CELLPADDING=3> <TR> <TD><NOBR>radius: <INPUT NAME="Circle_radius" SIZE=4></NOBR></TD> <TD><INPUT TYPE=BUTTON OnClick="Circle_calc(this.form);" VALUE="calculate"></TD> <TD ALIGN=RIGHT BGCOLOR="#AACCFF"> <NOBR>circumference: <INPUT NAME="Circle_circumference" SIZE=9></NOBR><BR> <NOBR>area: <INPUT NAME="Circle_area" SIZE=9></NOBR></TD> </TR> </TABLE> </FORM> ``` I can’t understand `OnClick="Circle_calc(this.form);"` `Circle_calc(this.form)` isn't defined anywhere. How does this function work? Is it a built-in function in HTML?
2011/05/10
[ "https://Stackoverflow.com/questions/5957039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/578462/" ]
It's not built-in. If you look at the source code, it's defined as: ``` <SCRIPT TYPE="text/javascript"> <!-- function Circle_calc(GeoForm) { var CircleRadius = GeoForm.Circle_radius.value; if (CircleRadius >= 0) { GeoForm.Circle_circumference.value = 2 * Math.PI * CircleRadius ; GeoForm.Circle_area.value = Math.PI * Math.pow(CircleRadius, 2) ; } else { GeoForm.Circle_circumference.value = ""; GeoForm.Circle_area.value = ""; } } //--> </SCRIPT> ```
They have been quite naughty methinks, If you do a view page source on that page, and look at the way THEY'VE done the form, then you'll see this: ``` <SCRIPT TYPE="text/javascript"> <!-- function Circle_calc(GeoForm) { var CircleRadius = GeoForm.Circle_radius.value; if (CircleRadius >= 0) { GeoForm.Circle_circumference.value = 2 * Math.PI * CircleRadius ; GeoForm.Circle_area.value = Math.PI * Math.pow(CircleRadius, 2) ; } else { GeoForm.Circle_circumference.value = ""; GeoForm.Circle_area.value = ""; } } //--> </SCRIPT> <P> <FORM> <TABLE BORDER CELLPADDING=3> <TR> <TD><NOBR>radius: <INPUT NAME="Circle_radius" SIZE=4></NOBR></TD> <TD><INPUT TYPE=BUTTON OnClick="Circle_calc(this.form);" VALUE="calculate"></TD> <TD ALIGN=RIGHT BGCOLOR="#AACCFF"> <NOBR>circumference: <INPUT NAME="Circle_circumference" SIZE=9></NOBR><BR> <NOBR>area: <INPUT NAME="Circle_area" SIZE=9></NOBR></TD> </TR> </TABLE> </FORM> <P> ``` As you can see, you now have the HTML code in context, and you can actually see the script that the HTML executes. And as the script is inside the HTML file, you wouldn't need to have an import (if that's the right phrase) at the top of your HTML file telling it which script file to use. Also I would strongly recommend using the W3c Schools tutorials, they're miles better and they can be found here: <http://www.w3schools.com/w3c/w3c_html.asp>
16,271,972
I have a div that should be shown only when the user clicks the show button ``` $("div.toshow").show(); ``` I have written in the body ``` <body> <div class="toshow"> </div> </body> ``` so by default when the page is displayed all this content is seen the user. Is there a way that I can hide it bydefault?
2013/04/29
[ "https://Stackoverflow.com/questions/16271972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530845/" ]
Yes you can use `style` like this: ``` <div class="toshow" style="display:none"></div> ```
You can use CSS `display`: ``` .toshow { display: none; } ```
51,799,359
i'm a beginner in C , so i'm a little confused if `char* ft_name(args)` is equivalent to `char *ft_name(args)` in function prototype . can anybody help me please
2018/08/11
[ "https://Stackoverflow.com/questions/51799359", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10017223/" ]
C compiler ignores the white space between the tokens and both declrations from the compiler point of view look like ``` char*ft_name(args); ``` so they are exactly the same. the only place where compiler does not ignore the white space are string literals like `"Hello world"` The program: ``` int main(int argc, char * * argv) { size_t s = strlen(argv [ 0] ); printf("%zu %s\n", s, argv [ 0 ]); } ``` is seen by the compiler as ``` int main(int argc,char**argv){size_t s=strlen(argv[0]);printf("%zu %s\n",s,argv[0]);} ``` White space is not ignored during the preprocessor stage when macros are expanded.
**Yes**. ``` char* ft_name(args) ``` and ``` char *ft_name(args) ``` are equivalent.
17,566,249
Can anyone help me to set a `KeyPress` action on a currently opened `jInternalFrame`? I have a `jDesktopPane` inside a `jframe`, and I have multiple `jInternalFrame` inside the `DesktopPane`. I am using Netbeans to create this application. On the `jDesktopPane` I have 3 buttons to open 3 `jInternalFrame`, and I created a `Keypress` on those buttons and it works fine using this code: ``` private void formKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here: if(evt.getKeyCode()==KeyEvent.VK_F3){ frmLogistics.setVisible(true); frmLogistics.toFront(); } } ``` A `jInternalFrame` is open and inside there's a `jtoolbar` with sets of buttons, one of it is a close button to close that opened `jInternalFrame`. I set up the code for its `ActionPerform` so when a user clicks that button the frame or window will be closed. The problem now is how about a keyboard press? I want to trigger that close button inside the toolbar in a internalframe in order to close it I tried this code: ``` private void btnCloseLogisticsKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here: if(evt.getKeyCode()==KeyEvent.VK_F4){ int type = JOptionPane.YES_NO_OPTION; int choice = JOptionPane.showConfirmDialog(this,"Do You Want to Log Out?","Exit Logistics System", type); if(choice == JOptionPane.YES_OPTION){ frmLogistics.setVisible(false); frmLogIn.show(); btnCashier.setEnabled(false); btnTrucking.setEnabled(false); btnAccounting.setEnabled(false); } } } ``` But nothing happens. I tried to put that code inside `jtoolbar`, `jInternalFrame` and still nothing happens. Maybe anyone of you could help me?
2013/07/10
[ "https://Stackoverflow.com/questions/17566249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2469754/" ]
For Swing, typically use key bindings over the AWT based, lower level, `KeyListener`. See [How to Use Key Bindings](http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html) for details on how to use them.
In the event keypress click right in the Jframe de netbeans mas naki.. ``` private void formKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here: if(evt.getKeyCode()==KeyEvent.VK_F4){ dispose(); } ```
6,397,250
I have an IF / ELSE statement, although I would like to know how to tell the "else" part to do nothing if it is true. e.g.: ``` if(x == x) //run calc.exe else //DoNothing ``` Or I am write in saying that if I just remove the else statement, it will continue anyway if the if condition is not matched?
2011/06/18
[ "https://Stackoverflow.com/questions/6397250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/804522/" ]
Yes. An non existant `else` statement is the same as an empty one. This is common to all C-like languages.
If you don't put an else part and the if condition is not met the program will continue executing its flow: ``` if (SomeCondition) { // Do something if the condition is not met } // continue executing ```
43,068,424
I am trying to replace my old ID with new one but this function is not working. How can I resolve this error? ```js $("#addfield").click(function(){ alert($(this).data('id')+1); $(this).data('id', + $('#addfield').data('id')+1); console.log($(this).data('id')); }) ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a class="btn btn-success addfield" id="addfield" class="addfield" data-id="1">Add field</a> ```
2017/03/28
[ "https://Stackoverflow.com/questions/43068424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6921231/" ]
The problem is that you increase value after setting `newValue`. In this line: `var newvalue = currentvalue++`; it is happening two things: **1)** var newvalue=currentvalue; **2)** currentvalue=currentvalue+1 ```js $(".addfield").click(function() { $(this).attr('data-id', +$(this).attr('data-id')+1); }) ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a class="btn btn-success addfield" data-id="1" class="addfield">Add field</a> ```
Please check below code, this working with numeric Id. ```js $(".addfield").click(function(){ var currentvalue = $(this).attr('id');alert("Old Id="+currentvalue); var newvalue = currentvalue++; $('.addfield').attr('id', newvalue); alert("New Id="+currentvalue++); }); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="addfield" id="1">Click Here</div> ```
39,785
I have this configuration in **/etc/network/interfaces**: ``` auto lo iface lo inet loopback allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan0 #iface wlan0 inet dhcp iface wlan0 inet static address 192.168.0.110 netmask 255.255.255.0 network 192.168.0.1 gateway 192.168.0.1 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf #iface default inet dhcp iface eth0 inet static address 192.168.0.115 netmask 255.255.255.0 network 192.168.0.1 gateway 192.168.0.1 ``` The wireless static IP worked, but the eth0 didn't. So I tried to do the config in **/etc/dhcpcd.conf**: ``` interface eth0 static ip_address=192.168.0.115/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 ``` And it worked. I am confused and here are several questions: 1. When to use which file? 2. Why the wifi worked with **/etc/network/interfaces** but the eth0 didn't? 3. Does **dhcpcd** has somehow priority over **/etc/network/interface**? 4. How to check which service has priority or someting? And which service uses **/etc/network/interface**?
2015/12/20
[ "https://raspberrypi.stackexchange.com/questions/39785", "https://raspberrypi.stackexchange.com", "https://raspberrypi.stackexchange.com/users/38523/" ]
The priority has to do with your init or systemd configuration. With regards to dhcp: if you have s statically or manually configured interface, and dhcp starts requesting an address afterwards, it will override what you already have. On Debian, dhcp is started for interfaces for which you specify dhcp, and not just magically by itself. If you have unexpected behavior you may have a different system running in the background like NetworkManager. Per point: 1. don't use dhcpcd.conf at all, leave it be. 2. You don't have a eth0 allow hotplug line. 3. If dhcpcd is started after networking and you have it set to take over an interface, it will. 4. Check the order in which you start those services.
First, get the `/etc/network/interfaces` file back to its original version... ``` # interfaces(5) file used by ifup(8) and ifdown(8) # Please note that this file is written to be used with dhcpcd # For static IP, consult `/etc/dhcpcd.conf` and `man dhcpcd.conf` # Include files from `/etc/network/interfaces.d`: source-directory /etc/network/interfaces.d auto lo iface lo inet loopback iface eth0 inet manual allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf ``` Then, keep your changes to the `/etc/dhcpcd.conf` file simple and just for wireless... (at the bottom of the file...) ``` nohook lookup-hostname interface wlan0 static ip_address=192.168.0.53/24 static routers=192.168.0.1 static domain_name_servers=8.8.8.8 ``` `/etc/wpa_supplicant/wpa_supplicant.conf`: ``` ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=US network={ ssid="The SSID of your Router" psk="daPassword" scan_ssid=1 key_mgmt=WPA-PSK } ```
11,431,905
I have a class MyDataCollection that contains MyMetaData and MyData. In my application i have two usercontrolls that display input fields to the user. One for the MyMetaData and the other for MyData. Both usercontrols are included in the MainPage. My Question is: How should i get the data from the usercontrols then the user klicks on the save-button (located on the mainpage)? **Update** I have changed my code accordingly to blindmeis post but now the MetaDataView is not shown: ``` <UserControl.Resources> <DataTemplate x:Key="MetaDataTemplate"> <view:MetaDataView/> </DataTemplate> </UserControl.Resources> <Grid> <ContentPresenter Content="{Binding MetaDataTemplate}"/> </Grid> ```
2012/07/11
[ "https://Stackoverflow.com/questions/11431905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/639367/" ]
why not doing mvvm the easy way?(viewmodel first). you say you have a mainpage - this means you also have a mainpageviewmodel. your mainpageviewmodel handles at least the save command. now you want to show MyMetaData and MyData on your mainpage. so the easy way would be to create one MyMetaData instance and one MyData instance in your mainviewmodel. ``` public class MainPageViewmodel { public ICommand SaveCommand { get; set; } public MyDataViewmodel MyData { get; set; } public MyMetaDataViewmodel MyMetaData { get; set; } public MainPageViewmodel() { this.MyData = new MyDataViewmodel(); this.MyMetaData = new MyMetaDataViewmodel(); } } public class MyDataViewmodel {} public class MyMetaDataViewmodel {} ``` your mainpage just need 2 datatemplates and 2 contentpresenter. //resources ``` <DataTemplate DataType="{x:Type Local:MyDataViewmodel}"> <view:MyDataUserControl/> </DataTemplate> <DataTemplate DataType="{x:Type Local:MyMetaDataViewmodel}"> <view:MyMetaDataUserControl/> </DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <ContentPresenter Content="{Binding MyData}" Grid.Column="0"/> <ContentPresenter Content="{Binding MyMetaData}" Grid.Column="1"/> <Button Content="Save" Command="{Binding SaveCommand}" Grid.Column="2"/> </Grid> ``` because your mainpageviewmodel has both "child" viewmodel, you have all information you want on your savecommand. if you have another scenario pls update your question, maybe post some code. EDIT: i have no silverlight so that just a suggestion: maybe rachel can give you a better answer. ``` <Grid> <ContentPresenter Content="{Binding MyMetaData}" ContentTemplate="{StaticResource MetaDataTemplate}"/> </Grid> ``` if silverlight cant handle datatemplates with datatype you could just put the usercontrol there directly. ``` <Grid> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <view:MyDataUserControl DataContext="{Binding MyData}" Grid.Column="0"/> <view:MyMetaDataUserControl DataContext="{Binding MyMetaData}" Grid.Column="1"/> <Button Content="Save" Command="{Binding SaveCommand}" Grid.Column="2"/> </Grid> ```
You should use Two-way bindings to automatically update the value in your controller. Take a look at [this article](http://msdn.microsoft.com/en-us/library/cc278072%28v=vs.95%29.aspx). Here's an example: ``` <TextBox Text="{Binding MyMetaData, Mode=TwoWay }" /> <TextBox Text="{Binding MyData, Mode=TwoWay }" /> ```
50,719,380
I'm designing a parallel algorithm where, in theory, I want to update an `std::list<...>` per thread. So say I have `m*n` threads, each of these will index a specific `std::list`, after the parallel algorithm has been executed all the list will be merged together. There other approach I was thinking was to use a single `std::list` and lock the access when this is updated (if that's possible in openCL not entirely sure). My question in general is... is it possible to pass stl data structure to a kernel? Thank you
2018/06/06
[ "https://Stackoverflow.com/questions/50719380", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4792660/" ]
So I resolved this error by uncommenting and setting `# calico_ipip_enabled: true` to false. After that though I got another error because of my loopback ip: ``` fatal: [127.0.0.1] => A loopback IP is used in your DNS server configuration. For more details, see https://ibm.biz/dns-fails. ``` But there is an fix/workaround by setting `loopback_dns: true` as mentioned in the link. I can't close this question here but this is how I resolved it.
IBM Cloud private suppoted OS is ubuntu 16.04 .Please check the below url <https://www.ibm.com/support/knowledgecenter/SSBS6K_2.1.0.3/supported_system_config/supported_os.html> Please check the system requirement.. I am also trying to install the setup.. I didnt face this issue.
1,952,404
Does exist in linux bash something similar to the following code in PHP: ``` list($var1, $var2, $var3) = function_that_returns_a_three_element_array() ; ``` i.e. you assign in one sentence a corresponding value to 3 different variables. Let's say I have the bash function `myBashFuntion` that writes to stdout the string "qwert asdfg zxcvb". Is it possible to do something like: ``` (var1 var2 var3) = ( `myBashFuntion param1 param2` ) ``` The part at the left of the equal sign is not valid syntax of course. I'm just trying to explain what I'm asking for. What does work, though, is the following: ``` array = ( `myBashFuntion param1 param2` ) echo ${array[0]} ${array[1]} ${array[2]} ``` But an indexed array is not as descriptive as plain variable names. However, I could just do: ``` var1 = ${array[0]} ; var2 = ${array[1]} ; var3 = ${array[2]} ``` But those are 3 more statements that I'd prefer to avoid. I'm just looking for a shortcut syntax. Is it possible?
2009/12/23
[ "https://Stackoverflow.com/questions/1952404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/25700/" ]
First thing that comes into my mind: ``` read -r a b c <<<$(echo 1 2 3) ; echo "$a|$b|$c" ``` output is, unsurprisingly ``` 1|2|3 ```
let var1=var2=var3=0 or var1=var2=var3="Default value"
18,667
1. I just want to ask how recommended is the book on quantum mechanics by J.J. Sakurai. Is it any good as an introductory text? 2. And are there better suggestions (substitutes)?
2011/12/23
[ "https://physics.stackexchange.com/questions/18667", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/6824/" ]
IMHO it is an excellent book, particularly the first chapters. It goes immediately to the point and forces you to get used right away to bra's and ket's and so on. Many years have passed since I used the book (and now there is even a new edition which I have not looked at) but back when I was an undergraduate student it was my favorite book of choice. On the other hand I don't think of Sakurai's as an introductory text. The first and second chapter could work a bit like that but only for the brightest students. For starters (studying Physics) I would rather suggest a book like Griffith's or from a very different perspective, the recent book by Schumacher "Quantum Processes, Systems and Information".
I remember finding it totally dense and confusing and unreadable as a young undergrad. When I reread it a few years later, I found it totally clear, and I could not (and still cannot) figure out why I had found it confusing before. It's strange! Regardless, I suggest reading Griffiths, then reading it again and again, it's wonderful. :-)
22,771,994
I have the following model attributes: ``` [{ "id": 1, "details": { "name": "Sun Tzu", "height": "180", }, "lists": [ [{ "coworkers": "company cool", "friends": "School", }], [{ "coworkers": "company nice", "friends": "Childhood", }] ] }] ``` Yes, I know it is confusing but I am trying to understand nested models. I want to display in a view (a table row), all the `friends` of `id:1` model. For example: `School, Childhood`. How do I do that? Thanks in advance!
2014/03/31
[ "https://Stackoverflow.com/questions/22771994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1664286/" ]
``` var friends = _.chain(data) .findWhere({ id: 1 }) .result('lists') .flatten(false) .pluck('friends') .value(); ```
You can chain functions to get the output you are looking for ``` console.log(_.chain(data) .find(function(currentObject) { return currentObject.id === 1; }) .pick("lists") .flatten(false) .pluck("friends") .value()); ``` **Output** ``` [ 'School', 'Childhood' ] ```
16,957,270
I want to push the data from server to web client. Now i have used the j2ee technology, i am using javascript and give a ajax call to server some intervel times then the data is showed to webclient. This process works fine. But i feel its overhead to server.I want to get the data from server when the new data comes to database then push the data to web client .Is any other any technologies or tomcat plugin available?
2013/06/06
[ "https://Stackoverflow.com/questions/16957270", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1793377/" ]
Solution with usage of [Enumerable#inject](http://ruby-doc.org/core-2.0/Enumerable.html#method-i-inject): ``` def sum(array) array.inject(0){|sum, el| sum + el} end ``` Or, as suggested, shorter and more elegant form: ``` def sum(array) array.inject(0, :+) end ```
This will do: ``` def sum(array) array.reduce(0, :+) end ```
1,531,903
What do you call your functions when names that contain a saxon genitive like "Verify Task's Priority" and "Change Argument's Priority" or "Increase Action's Delay"? Do you drop the apostrophe? `verifyTasksPriority(), changeArgumentsPriority(), increaseActionsDelay()` Do you drop both the apostrophe and the "s"? `verifyTaskPriority(), changeArgumentPriority(), increaseActionDelay()` Do you replace the saxon genitive with "of"? `verifyPriorityOfTask(), changePriorityOfArgument(), increaseDelayOfAction()`? I don't like the first option because it sounds like the function works on multiple things rather than just one thing. I don't like the second option because it doesn't sound natural. I don't like the third option because the word, *of*, in a function name just doesn't sound right. What option do you use?
2009/10/07
[ "https://Stackoverflow.com/questions/1531903", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
I use the second. It sounds good to me. Think of "Task Priority" as a compound word like "vacuum cleaner".
If you need to make your function names several words long to distinguish them from each other, you are probably failing in the [single responsibility principle](https://en.wikipedia.org/wiki/Single_responsibility_principle) so none of your suggested options will help. I write OO code, mainly in OO languages, so to verify the priority of a task you'd have `task.verifyPriority()`, though usually just have `task.verify()` as the public method. Verifying the priority may involve other logic - say the priority can only be 7 if the task's owner is Bob. Setting the owner of one of Bob's priority 7 tasks to Anna would make it inconsistent, but would you have `verifyOwner()` to be called when you change the owner as well as `verifyPriority()` for when you change the priority, even if they had the same logic? I've found that making APIs less specific to the detail of the implementation leads to more malleable code. In non-OO languages I usually use `<library>_<Noun>_<Verb>` so `tman_task_verify ( task_t* self )` to verify the task object in the task manager library to verify itself.
2,583,756
I want to show that $4^{3x+1} + 2^{3x+1} + 1$ is divisible by 7, I am trying to show this with modular arithmetic. If I break up each part of the equation, I can see that $4^{3x+1} = 4$ x $2^{6x}$ which implies that $4^{3x+1}mod(7) = 4$ I can't quite find a nice factorization of $2^{3x+1}$ Any help specifically on how to treat $2^{3x+1}$ would be appreciated.
2017/12/29
[ "https://math.stackexchange.com/questions/2583756", "https://math.stackexchange.com", "https://math.stackexchange.com/users/431530/" ]
**Hint:** $$2^{3x+1} = 8^x\times 2$$ $$8 \equiv 1\pmod{7} \implies 8^x \equiv 1 \pmod{7}\implies 8^x \times 2\equiv 2\pmod{7}.$$
$X:=2^{3x+1}=2\cdot (7+1)^x \equiv 2\pmod{7}$. Hence $$ X^2+X+1 \equiv 2^2+2+1 \equiv 0\pmod{7}. $$
17,795,346
I am having an issue implementing this calculator on my website which i created. I think i have used the wrong javascript to create the simple calculation which is the following math calculation: **((list price - rrp) / list price) \* 100** **PLEASE NOTE, i am aware of the values not being numbers, please replace them with any numbers. it still doesnt work.** This is to get the percentage value of the discount against the list and the RRP. Please review the code before HTML: ``` <script type="text/javascript"> discountFinal(#OriginalPrice, #ListPrice); </script> <div id="discountCode"> <span id="spanish"></span> <span id="spanishtwo">%</span> </div> ``` Javascript: ``` var discountFinal = function (firstly, secondly) { var totalfirst = secondly - firstly; var totalsecond = totalfirst / secondly; var totalthird = totalsecond * 100; if (document.getElementById("discountCode").innerHTML === null) { document.getElementById("spanishtwo").innerHTML.replace("%", "") } else { document.getElementById("spanish").innerHTML = Math.floor(totalthird / 5) * 5 } }; ``` I dont think i am calling the function within the html properly. Can someone assist with this please. <http://jsfiddle.net/xwzhY/>
2013/07/22
[ "https://Stackoverflow.com/questions/17795346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2244383/" ]
It works fine if you call your function after it exists: <http://jsfiddle.net/xwzhY/2/> Just make sure that the function is declared earlier in the code than you use it. Or declare it using a function statement rather than a function expression assigned to a variable: ``` function discountFinal(firstly, secondly){ ... ```
Trying put "" around your perl variable, you need to pass the value
63,203,144
I'm setting up laradock (Setup for Multiple Projects) following the official documentation from the Laradock in my local machine. After installation I installed the laravel through workspace container bash. I did configured the config file for the app in `nginx/sites/` directory and in `/etc/hosts` file. While visiting the development url I'm getting the following error message: **The stream or file "/var/www/laravel-api/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied**
2020/08/01
[ "https://Stackoverflow.com/questions/63203144", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13904860/" ]
This worked for me: ``` chown -R www-data:www-data "project foldername" ```
You need to run the following command. It works for me: **step 1:** > > sudo chmod -R +rwX . > > > **step 2:** > > sudo chown -R $(whoami) . > > >
74,526,866
[enter image description here](https://i.stack.imgur.com/0rj83.png) [enter image description here](https://i.stack.imgur.com/sFKiK.png) I think is same array type, but, Javascript doesn't import data to second type 'proj\_name'. I use axios to fetching data This is my axios request tsx file ``` import axios,{ AxiosRequestConfig } from 'axios'; import { Projects , Tree } from './PmHomeMenuDataTypes'; const axios_config: AxiosRequestConfig = { method: "get", baseURL: "http://localhost:8000/", url: "service/projects/all", responseType: "json", } export const getAllProjects = () => { const menulist: Tree = []; axios(axios_config) .then((response) => { response.data.map((item: Projects) => { menulist.push(item); }) }); console.log(menulist); return menulist; } ``` I use to fetch data this tsx file ``` import PmHomeTreeComponent from './PmHomeTreeComponent'; import { getAllProjects } from './PmHomeMenuDataGet'; const PmHomeTreeMenu = () => { return <PmHomeTreeComponent menuData={getAllProjects()} /> } export default PmHomeTreeMenu; ``` I don't know what is a problem
2022/11/22
[ "https://Stackoverflow.com/questions/74526866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20032012/" ]
Using your wide dataframe, you can set `stat = "identity"` inside `geom_boxplot()` and manually set the boxplot parameters: ``` library(ggplot2) ggplot(df_wide) + geom_boxplot( aes( y = spp, xmin = lrr1, xlower = lrr1, xupper = lrr2, xmax = lrr2, xmiddle = (lrr1 + lrr2)/2 ), stat = "identity" ) ``` [![](https://i.stack.imgur.com/uhq3s.jpg)](https://i.stack.imgur.com/uhq3s.jpg) But if you don’t care about the middle bar, it may be easier to use your original (long) dataframe with `geom = "bar"` inside `stat_summary()`: ``` ggplot(df, aes(lrr, spp)) + stat_summary( fun.min = min, fun = median, fun.max = max, geom = "bar", color = "black", fill = "white" ) ``` [![](https://i.stack.imgur.com/laSku.jpg)](https://i.stack.imgur.com/laSku.jpg)
Something like this, using `geom_crossbar` ? ``` library(dplyr) library(ggplot2) library(scales) df1 %>% group_by(spp) %>% mutate(upper = max(lrr), lower = min(lrr)) %>% ungroup() %>% ggplot(aes(spp, lrr)) + geom_crossbar(aes(ymin = lower, ymax = upper), fatten = 1, width = 0.5) + scale_y_continuous(breaks = pretty_breaks()) ``` Result: [![enter image description here](https://i.stack.imgur.com/PNfKK.png)](https://i.stack.imgur.com/PNfKK.png) Data: ``` df1 <- structure(list(ID = c(25L, 25L, 24L, 24L, 21L, 21L), spp = c("species 1", "species 1", "species 2", "species 2", "species 3", "species 3" ), lrr = c(-1.029, 0.182, -3.694, 0.3463, 0.5181, 4.4516), Est = c(-0.423814246776361, -0.423814246776361, -1.67397643357167, -1.67397643357167, 2.484906649788, 2.484906649788), SE = c(0.309105763160605, 0.309105763160605, 1.03077640640442, 1.03077640640442, 1.4142135623731, 1.4142135623731 )), class = "data.frame", row.names = c("1", "2", "5", "6", "7", "8")) ```
63,870,821
I have a simple `component` named `rectangle` with a simple `css`. Now I need to show a element example a `div` or another `component` inside that component. How would I achieve this? --- I tried doing: ```html <app-rectangle> <div> ... </div> </app-rectangle> ``` and nothing showed up as the output.
2020/09/13
[ "https://Stackoverflow.com/questions/63870821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9129854/" ]
What you are trying to achieve is called Content Projection. In the template of the `<app-rectangle>` component add the following: `<ng-content></ng-content>` Your div should automatically appear within those tags. See more here: <https://angular.io/guide/lifecycle-hooks#responding-to-projected-content-changes>
You can achieve this using `<ng-content></ng-content>` I believe you are looking for something similar that was asked [here](https://stackoverflow.com/questions/39292195/angular2-html-inside-a-component).
205,515
### Introduction A double-castle number™ is a positive integer number that has a pattern of $$\underbrace{a\cdots a}\_{m\text{ }a\text{s}}b\underbrace{a\cdots a}\_{m\text{ }a\text{s}}b\underbrace{a\cdots a}\_{m\text{ }a\text{s}}\underbrace{a\cdots a}\_{n\text{ }a\text{s}}b\underbrace{a\cdots a}\_{n\text{ }a\text{s}}b\underbrace{a\cdots a}\_{n\text{ }a\text{s}}$$ Where \$m>0\$, \$n>0\$ and \$a-b=1\$ are all non-negative integers, when represented in an integer base \$B\$ where \$B\ge2\$. It is so named because a bar chart representing the base-\$B\$ digits of such a number resembles two castles of the same height place- side by side. For example, \$7029\$\* is a double-castle number because when represented in base 2 it becomes \$1101101110101\_2\$, which can be split into \$11011011\$ and \$10101\$. [![enter image description here](https://i.stack.imgur.com/WwmC1.png)](https://i.stack.imgur.com/WwmC1.png) This is the case when \$m=2\$, \$n=1\$, \$a=1\$, \$b=0\$ and \$B=2\$. \$305421994212\$ is also a double-castle number because when represented in base 8 it becomes \$4343444344344\_8\$, which can be split into \$43434\$ and \$44344344\$. [![enter image description here](https://i.stack.imgur.com/MIhKU.png)](https://i.stack.imgur.com/MIhKU.png) This is the case when \$m=1\$, \$n=2\$, \$a=4\$, \$b=3\$ and \$B=8\$. For \$a>=10\$, \$a\$ should be treated as a single base-\$B\$ "digit" with the value of \$a\$ in base-10. \$206247763570426655730674346\$ is a double-castle number in base-16, whose representation in base-16 is \$\text{AA9AA9AAAAAA9AAAA9AAAA}\_{16}\$. Here, \$a=10\$ but is treated as a single digit \$(10)\_{16}=\text{A}\_{16}\$. [![enter image description here](https://i.stack.imgur.com/6xXmK.png)](https://i.stack.imgur.com/6xXmK.png) This is the case when \$m=2\$, \$n=4\$, \$a=10\$, \$b=9\$ and \$B=16\$. ### Challenge Write a program or function that, given integers \$m>0\$, \$n>0\$, \$1\le a<B\$ and \$B\ge2\$, calculate the corresponding double-castle number™ and output it in base-10. ### Test Cases The input below are in base-10, but in the case say when \$a=11\$ and \$B=12\$ the input should be understood as \$B\_{12}\$. ``` m, n, a, B => Output 1, 1, 1, 2 => 693 2, 1, 1, 2 => 7029 1, 2, 3, 4 => 62651375 1, 2, 4, 8 => 305421994212 1, 4, 7, 10 => 7676777776777767777 2, 4, 8, 16 => 164983095594247313234036872 2, 4, 10, 16 => 206247763570426655730674346 ``` ### Winning Condition This is a code-golf challenge, the shortest submission in each language wins. No standard loopholes allowed. \*7029 comes from my ID minus it written reversed.
2020/06/02
[ "https://codegolf.stackexchange.com/questions/205515", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/71546/" ]
[K (ngn/k)](https://bitbucket.org/ngn/k), 26 bytes ================================================== ``` {z/,/(2+3*x)#'(x#'y),'y-1} ``` Explanation ``` {z/,/(2+3*x)#'(x#'y),'y-1} / using x=2 1; y=1; z=2 as an example (x#'y) / (m;n) copies of a; ex: (1 1;1) ,'y-1 / append b=a-1 to each ex: (1 1 0;1 0) (2+3*x) / length of each sublist ex: (8;5) #' / copy to each length ex: (1 1 0 1 1 0 1 1; 1 0 1 0 1) ,/ / join ex: (1 1 0 1 1 0 1 1 1 0 1 0 1) z/ / convert from base B ex: 7029 ``` [Try it online!](https://tio.run/##y9bNS8/7/z/NqrpKX0dfw0jbWKtCU1ldo0JZvVJTR71S17D2f1q0oYKhtaG1UawCV1q0ERLbUMHI2tjaBM42sbaAsk2sza0NDWIV/gMA "K (ngn/k) – Try It Online")
JavaScript, 75 bytes ==================== There may be rounding errors due to JavaScript's integer limit. ```javascript (m,n,a,B)=>B**(3*(m+n)+4)/~-B*a-B**(n-~n)-B**(m+3*n+2)-B**(2*m-3*~n)-B**n-1 ``` [Try it online!](https://tio.run/##XY3NDsIgEITP@hQcgYKFXX7KQQ99k8ao0RRqrOnRV6/UEk1cyATmm8zeuqkbj4/r/SmnZj7vZxpFEp1o2f7Qck6R01glVhlWv2TLO7mYSb4S@7xihTxVsH6AR4m8oCT1fBzSOPSnXT9c6HZzplqQ9QITpK6JC7jY8Gd7BaHEM0JBTImDsxq9/TEjSLMyVNaADiELFJ6hz7WqlLp8lnFfKbuXkpxza047ExpUwdrcZTxqBDQKXeNhy@Y3 "JavaScript – Try It Online")
24,220,030
I have a hover element in which when user hover over it will get text from a hidden element and when it hovers out it will reassign in its previous value. My html is sort of like this. ``` <div id="product-name">Hover Here</div> <br> <div id="result-content">Lorem ipsum dolor sit amet.</div> <div class="hidden"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla pellentesque mi leo, ut cursus tellus tempor nec. Sed facilisis augue neque, a ornare urna ornare in. Etiam consequat, dui sit amet pretium bibendum, ante ipsum ullamcorper libero, vel tempus erat urna sed purus. Quisque id ultricies elit, non posuere nunc. Etiam pulvinar magna tortor, at aliquet turpis interdum et. Duis imperdiet enim ante, sit amet pretium enim aliquet venenatis. Donec ac nibh nibh. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi aliquam est adipiscing volutpat pulvinar. Curabitur leo augue, iaculis id lacus sed, dictum vestibulum nulla. Etiam sit amet tempus felis, ac aliquet erat. Nunc ullamcorper consequat mattis. In molestie, tortor ac venenatis dapibus, eros neque vulputate nulla, in tristique ante diam non turpis. Maecenas mattis in risus eu ornare. Cras a rutrum nulla. Proin sagittis justo vehicula augue porttitor vulputate. </div> ``` and javascript is this: ``` var object = document.getElementById("product-name"); object.onmouseover=function(){ document.getElementById("result-content").innerHTML = document.getElementsByClassName("hidden")[0].innerHTML; }; object.onmouseout=function(){ document.getElementById("result-content")[0].innerHTML = document.getElementById("result-content").innerHTML; }; ``` [jsfiddle.net](http://jsfiddle.net/6mLRd/) But my mouseout event failed me here. Can anyone help me out here how can i resolve this. I can't use jQuery in this dom only javascript, but I wouldn't mind if anybody show me a better approach to resolve javascript mouseout/mouseover paradigm.
2014/06/14
[ "https://Stackoverflow.com/questions/24220030", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3736019/" ]
I think, in this case must save somewhere previous state, like: ``` var object = document.getElementById("product-name"), previous_state = document.getElementById("result-content").innerHTML; ``` Might not be the best approach, but without major changes in code should look like this: [jsfiddle](http://jsfiddle.net/6mLRd/1/)
try this one for mouse out ``` object.onmouseout=function(){ document.getElementById("result-content").innerHTML ='Lorem ipsum dolor sit amet.'; }; ```
148,884
I have ubuntu 12.04 installed on windows 7. When I use the `Fn` alongside the key to reduce brightness, or even using the system settings, I am not being able to reduce the screen brightness. What is the problem?
2012/06/10
[ "https://askubuntu.com/questions/148884", "https://askubuntu.com", "https://askubuntu.com/users/-1/" ]
Here's how i fixed mine : LCD Brightness Control Once you have installed the proprietary Nvidia drivers as suggested above, you may notice that your brightness control keys do not work properly. This is fixable by editing one's xorg.conf file. Open a terminal window and type the following: ``` sudo nano /etc/X11/xorg.conf ``` This will open your X server configuration (after prompting for your password). You should see a section titled "Device" that looks as follows: ``` Section "Device" Identifier "Default Device" Driver "nvidia" Option "NoLogo" "True" EndSection ``` Append a line so it appears like this: ``` Section "Device" Identifier "Default Device" Driver "nvidia" Option "NoLogo" "True" Option "RegistryDwords" "EnableBrightnessControl=1" EndSection ``` You will need to restart your graphical server (or reboot) for this change to take effect.
There is an app for it...**Brightness And Lock** ![enter image description here](https://i.stack.imgur.com/Ji1PA.png) ![enter image description here](https://i.stack.imgur.com/X2zp7.png)
14,320,149
Who can help me convert GPS latitude-longtitude to x-y coordinates for the Amersfoort RD New (epsg:28992) projected system. My startpoint (data from the GPS device) is something like this: "$GPGGA,071132.784, 5157.3883,N,00434.4648,E,1,03,4.5,-5.1,M,47.1,M,,0000\*73" Or 51°57'23,1600"N;004°34'27,5760"E In another GIS software with no GPS i get the following x and y values at the same location using the above projected system. X: 99128,7851960541 Y: 441194,717554809 I allready tried different approach but stil no success. The Goal is to visualize the current GPS position at realtime in the GIS software. Thx
2013/01/14
[ "https://Stackoverflow.com/questions/14320149", "https://Stackoverflow.com", "https://Stackoverflow.com/users/812011/" ]
The best answer would be to use a third party library to do the conversion for you. Such as [ArcGIS's GeometryService.Project web method](http://resources.arcgis.com/en/help/rest/apiref/project.html) or [PROJ.4's API](http://trac.osgeo.org/proj/wiki/ProjAPI). If you want to do the math yourself, you'll have to look at the [spatial reference](http://spatialreference.org/ref/epsg/28992/) and do the math yourself.
If you use the `PROJ.4` Api you can get the Proj4 Transformation definition string from this link: <http://spatialreference.org/ref/epsg/28992/proj4/> If you want to implement that transfomration for yourself: Its an `Oblique Stereographic projection`, exact paramters to use: [epsg/28992](http://spatialreference.org/ref/epsg/28992/html/) The formulas are described in <http://www.epsg.org/guides/docs/g7-2.pdf> on page 62ff, There is also an example for the Amersfoort RD.
3,904,894
I have a structure like: ``` src -|com -|company -|Core --> JAVA class -|rules --> text files ``` Inside Core is a Java Class that uses: ``` BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName))); ``` But I cannot figure out what relative path to use. Now I use: ``` "..\\..\\..\\..\\rules\\rule1.txt" ``` I also tried: ``` "../../../../rules/rule1.txt" ``` Where did I go wrong?
2010/10/11
[ "https://Stackoverflow.com/questions/3904894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/465734/" ]
It doesn't work that way. Relative paths are relative to the *working directory* of the current application, **not** the directory of the class. If you want to find out what your current working directory is, use `System.getProperty("user.dir")`. A better way is to add the rules directory to the classpath and then use [`Class#getResourceAsStream()`](http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getResourceAsStream%28java.lang.String%29). --- An alternative would be to set the path to the rules directory somehow else: You could provide a command line option if that is feasible or set some system property (e.g. `java -Drules.path=/path/to/rules ...` and later read via `System.getProperty("rules.path")`).
The current directory when executing has nothing to do with what package the current class is in. It doesn't change. If your file is distributed with the application, use Class.getResourceAsStream().
43,599,318
I have the following target: I need to compare two date columns in the same table and create a 3rd column based on the result of the comparison. I do not know how to compare dates in a np.where statement. This is my current code: ``` now = datetime.datetime.now() #set the date to compare delta = datetime.timedelta(days=7) #set delta time_delta = now+delta #now+7 days ``` And here is the np.where statement: ``` DB['s_date'] = np.where((DB['Start Date']<=time_delta | DB['Start Date'] = (None,"")),DB['Start Date'],RW['date']) ``` There is an OR condition to take into account the possibility that Start Date column might be empty
2017/04/24
[ "https://Stackoverflow.com/questions/43599318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3818716/" ]
I use `sass --watch stylesheet.scss:stylesheet.css`. When saving your `.scss` file, it'll automatically update the `.css` file. You might also consider `sass --watch stylesheet.scss:stylesheet.css --style expanded --sourcemap=none` to keep the `.css` file readable. I'd recommend the [Sass Workflow class on Udemy](https://www.udemy.com/sass-workflow/?start=0).
Try out Grunt or Gulp with Sass: A great tutorial: <https://www.taniarascia.com/getting-started-with-grunt-and-sass/>
64,964,363
I create an app in react. I am trying to use fetch with a post to a different port of localhost. I received the req on the server, but my body is empty. Why my body is empty? I don't understand. Code in React function: ``` export default function Sending() { async function handleSubmit(e) { e.preventDefault() try{ let result = await fetch('http://localhost:5000',{ method: 'post', mode: 'no-cors', headers: { 'Accept': 'application/json', 'Content-type': 'application/json', }, body: JSON.stringify({ email: 'example@gmail.com' }) }) console.log(result) } catch (error){ console.log(error) } } return ( <> Have a Form here </> ) } ``` the console log of browser: > > > ``` > Response {type: "opaque", url: "", redirected: false, status: 0, ok: false, …} > body: null > bodyUsed: false > headers: > Headers {} > ok: false > redirected: false > status: 0 > statusText: "" > type: "opaque" > url: "" > __proto__: Response > > ``` > > my simple server hold on node.js: ``` const express = require('express') const bodyParser = require('body-parser') const app = express() const port = process.env.PORT || 5000 app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.post('/', (req, res) => { console.log(req.body) res.send("Hello") }) app.get('/hello', (req, res) => { res.send("Hello, Benny") }) app.listen(port, () => { console.log(`Example app listening at http://localhost:${port}`) }) ```
2020/11/23
[ "https://Stackoverflow.com/questions/64964363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8134930/" ]
Consider installing cors and add it to your code such as shown bellow ```js const cors = require('cors') app.use(cors()) ``` Then with the help of morgan `const morgan = require('morgan');` Consider reading a previous similar case as shown here [Express JS is receiving an empty req.body from ReactJS](https://stackoverflow.com/questions/52847159/express-js-is-receiving-an-empty-req-body-from-reactjs)
From the first glacne; you are sending over a string with the stringify. Node body-parser trys to parse the json. Try removing the stringify and just sending the object over.
15,826,120
i have a table and i have also declared its style as grouped table style in view did load but i also have a button on click of which i want to change the style of the same table. initially i was setting this in view did load method: ``` tableObj= [[UITableView alloc]initWithFrame:CGRectMake(5,50,310,300)style:UITableViewStyleGrouped]; ``` but on button click event i am setting tableview fram and style see below code ``` tableObj.frame=CGRectMake(5,50,310,300); tableObj style=UITableViewStylePlain; ``` but it gives an error.....assignment to readonly property ??
2013/04/05
[ "https://Stackoverflow.com/questions/15826120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2239093/" ]
According to the docs, UITableView's `style` property is declared thus: ``` @property(nonatomic, readonly) UITableViewStyle style ``` That `readonly` keyword means that you can get the value of the property, but you can't set it. You can only set the style when you create the table using `-initWithFrame:style:`. This agrees with the error message you received: > > assignment to readonly property > > > Put simply, you can't do that.
``` tblView.style; ``` It is a read-only property you cannot set any value to while you can only read it which is set.. You can check whether the property is changable or, not by writing your code as below ``` [tblView setStyle:]; ``` But you will find that you can't do that, so you can't set. Better you get 2 tableviews, or, reinitialize your existing tableview with different style.
38,234,911
I new in Xamarin form. On Android, I used ViewPager to load images and the user swipe around the pages. Since Android has adapter, all the views are not initialized at once. Now I want to move to Xamarin form and seeing there is Carousel Page. Does it behave the same as ViewPager only load pages as needed?
2016/07/06
[ "https://Stackoverflow.com/questions/38234911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/186820/" ]
`Xamarin.Forms` `CarouselPage` does not support UI virtualization (recycling). Initialization performance and memory usage can be a problem depending upon the number of pages/children. The **new** preferred `VisualElement` to use is the `CarouselView` that is basically superseding `CarouselPage` and it has been optimized for each platform. Blog: [Xamarin.Forms CarouselView](https://blog.xamarin.com/flip-through-items-with-xamarin-forms-carouselview/) Nuget: [Xamarin.Forms.CarouselView](https://www.nuget.org/packages/Xamarin.Forms.CarouselView) (Currently in pre-release) **FYI:** I just looked the source for for the Android renderer (`CarouselViewRenderer.cs`) and it does indeed implement `RecyclerView`...
If you prevent the call to InitializeComponent in the constructor of the page you might have an effect on the load time. ``` public interface CarouselChildPage { void childAppearing(); void childDissapearing(); } public partial class MainPage : CarouselPage { CarouselPageChild previousPage; protected override void OnCurrentPageChanged() { base.OnCurrentPageChanged(); if (previousPage != null) previousPage.childDissapearing(); int index = Children.IndexOf(CurrentPage); CarouselPageChild childPage = Children[index] as CarouselPageChild; childPage.childAppearing(); previousPage = childPage; } } public partial class FriendsListPage : ContentPage, CarouselPageChild { bool isLoaded = false; public FriendsListPage() { // Remove Initialise Component Here } public void childAppearing() { Logger.log("My Appearing"); if (!isLoaded){ InitializeComponent(); isLoaded = true; } } public void childDissapearing() { Logger.log("My Disappearing"); } } ```
6,162,600
I have some random string, for example: `Hello, my name is john.`. I want that string split into an array like this: `Hello, ,, , my, name, is, john, .,`. I tried `str.split(/[^\w\s]|_/g)`, but it does not seem to work. Any ideas?
2011/05/28
[ "https://Stackoverflow.com/questions/6162600", "https://Stackoverflow.com", "https://Stackoverflow.com/users/407756/" ]
Try: ``` str.split(/([_\W])/) ``` This will split by any non-alphanumeric character (`\W`) and any underscore. It uses capturing parentheses to include the item that was split by in the final result.
This solution caused a challenge with spaces for me (still needed them), then I gave `str.split(/\b/)` a shot and all is well. Spaces are output in the array, which won't be hard to ignore, and the ones left after punctuation can be trimmed out.
37,126,522
I need to figure out how to write a for loop in Python that returns NOT print the sum of odd integers given an input. I can't use the sum function or make a list. So far all I have is this: ``` def sumofoddints (n): n >= 1 total = 0 for num in range (1, n): if num % 2 == 1: total += n return total ``` This doesn't give me the correct sums so I'm not sure how to fix it.
2016/05/09
[ "https://Stackoverflow.com/questions/37126522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6312575/" ]
There is a much simpler way using math. **EDIT:** sorry my bad. Here is the corrected formula ``` def sumOdd(n): return ((n+1)/2)**2 ``` n=1 => 1 = 1 n=3 => 1+3 = 2\*\*2=4 n=5 => 1+3+5 = 3\*\*2=9 n=7 => 1+3+5+7 = 4\*\*2=16
It is simply n\*\*2. Read here: <https://www.quora.com/What-is-the-formula-for-the-sum-of-n-odd-numbers> ``` def sumofoddints (n): return n**2 ```
4,943,849
I have a web site which uses cookies using ASP.NET, however everytime I publish a new site and upload all or some of the new .dlls it invalidates all the existing cookies. The cookies are used to track simple logins, but I want to maintain the cookies that were created before a publish so they are still usable afterwards - this seems to affect webkit based browsers and in my testing I can replicate this issue after each partial or full publish. Below is the Code I use to Set A Cookie: ``` If HttpContext.Current.Response.Cookies(COOKIE_NAME) Is Nothing Then Dim _cookie As New HttpCookie(COOKIE_NAME, CookieValue) _cookie.Path = COOKIE_PATH _cookie.Expires = COOKIE_EXPIRES HttpContext.Current.Response.Cookies.Add(_cookie) Else With HttpContext.Current.Response.Cookies(COOKIE_NAME) .Path = COOKIE_PATH .Value = Value .Expires = COOKIE_EXPIRES End With End If ``` And here is the code I use to Read a Cookie: ``` If HttpContext.Current.Request.Cookies(COOKIE_NAME) IsNot Nothing Then Return HttpContext.Current.Request.Cookies(COOKIE_NAME).Value End If ``` Where COOKIE\_NAME is set to "MyCookie" and COOKIE\_PATH is set to "/" and the COOKIE\_EXPIRES is set to "#1/1/2035#" I can read / write cookies fine, but once I do a Publish all previously created cookies become unreadable by Webkit browsers, although they can be Written to again, but I'm not sure this will be the case all the time - I want a publish to have no effect on the cookies at all - is this possible?
2011/02/09
[ "https://Stackoverflow.com/questions/4943849", "https://Stackoverflow.com", "https://Stackoverflow.com/users/61529/" ]
**Update:** Based on the revised question - 1. Why don't you set AppendDataBoundItems on the dropdownlist? The property would allow the dropdownlist to append items to the existing ones. ``` <asp:DropDownList ID='DropDownList1' runat='server' AutoPostBack='true' EnableViewState='true' AppendDataBoundItems='true'> <asp:ListItem Selected='True' Text='--Select--' Value='1'></asp:ListItem></asp:DropDownList> ``` 2. The Page\_Load method doesn't do what you want to. The else part of it will be executed even if one of them is true ..ex: if "Postback is true" or "callback is true" it would go into the else part. But as suggested in the (1) step, set the AppendDataBoundItems and remove code to add "--select--". --- Most likely issue be with ViewState, Set EnableViewState="true" ``` <%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Test.aspx.cs" EnableViewState="true"%> ``` And if you are using Maste Pages you'll have to enable on it too. ``` <%@ Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="Site" EnableViewState="true" ClassName="Site" %> ``` And in the dropdown web control AutoPostback="true" ``` <asp:DropDownList ID='DropDownList1' runat='server' AutoPostBack='true' OnSelectedIndexChanged='HandleOnDropDownListSelectedIndexChanged'> </asp:DropDownList> ```
I don't know if anyone else had the same Issue as I did but it just so happened that my values were the same for each item in the drop down list and it would never fire the event until I changed the values.
10,579,046
I have searched the web but couldn't find any detailed idea about Native OS development I need to know about Native OS development in detail eg. what is a Native OS what kind of feature it gives.. etc etc..
2012/05/14
[ "https://Stackoverflow.com/questions/10579046", "https://Stackoverflow.com", "https://Stackoverflow.com/users/940347/" ]
"Native OS" is not a product. It is a phrase that describes the operating system that the device comes with, and applications written specifically for that OS (as opposed to Java apps, which are cross-platform). So for example, "Native OS" of iPhone is iOS; and "Native OS iPhone application" will be written in Objective C. On the other hand, e.g. a JavaScript application running on iPhone is not native, because a Javascript application is running through a browser and not directly on the OS. Another example: On a Windows machine, the native OS is (obviously) MS Windows. C++ applications using Windows API are native; Flash or TCL/TK would be non-native.
If you prefer native OS you should specify what exactly it is, like Windows, Linux... etc. :)
3,786,653
Since Objective-C exists and is supported even in MinGW, by passing `-x objective-c`, is there a hack to achieve this with Android SDK? I've did a rudimentary test on a colleague's machine where it appears that language `objective-c`is not supported. I am not interested in getting UIKit or AppKit, or even Foundation, to work; I've written most of an OpenGLES game in Objective-C, and successfully ported it to Mac OS X and Windows; I am fairly certain I could easily port it to GNU/Linux once I get time to figure out enough of GNUStep (and even without it, I could create the classes to get the game running). I'm just interested in the base language and basic runtime (including properties, if possible); even `NSObject` can be easily written to the extent I need it. --- In the meantime, I've managed to compile some Objective-C code, and have written a guide for this: * [Developing Objective-C apps for Android using Mac OS X](http://blog.vucica.net/2011/06/developing-objective-c-apps-for-android-using-mac-os-x.html) There are more details in my answer below.
2010/09/24
[ "https://Stackoverflow.com/questions/3786653", "https://Stackoverflow.com", "https://Stackoverflow.com/users/39974/" ]
The [Apportable platform](http://www.apportable.com/) includes a Clang compiler integration with the Android NDK. It also includes a bunch of other useful features if you want to go beyond basic Objective-C language and runtime support.
There is this Google Code project: <http://code.google.com/p/android-gcc-objc2-0/> however I have not tested it yet. Also, I have inquired on the Cocotron mailing list whether or not this compiler is usable with Cocotron's Foundation and CoreFoundation; one person responded that it is not, and that he has worked on the problem: <http://groups.google.com/group/cocotron-dev/browse_thread/thread/448355f2a6c9c28e#> --- In the meantime, I've managed to compile some Objective-C code, and have written a guide for this: \* [Developing Objective-C apps for Android using Mac OS X](http://blog.vucica.net/2011/06/developing-objective-c-apps-for-android-using-mac-os-x.html) --- Clang is included in NDK nowadays if that's all you need.
5,287,636
Hi stack overflow people i am writing an iphone app thats connects to a web service, through REST with JSON. I would like to generate my model classes in objective c from a json schema provided by my web service, a bit like i d do with wsdl2objc with asoap, xml and wsdl combination. It looks like there s not much out there on this subject i tried something called jsonschema2objc.rb from <http://code.google.com/p/bkjsonschema/> but it s giving me errors even on the simplest json schema, the one found here: <http://en.wikipedia.org/wiki/JSON#Schema> i get this error: Using temporary file /var/folders/rN/rNw33pkyHVeNG+-IesdU+k+++TI/-Tmp-/jsonschema2objc.8WRkBSQo !!! Object definition at index Product has unknown type so here are my 2 questions: * do you guys know any good tool to acheive jsonchema => objective c classes ? * do you know what this error means in my ./jsonschema2objc.rb Thx!
2011/03/13
[ "https://Stackoverflow.com/questions/5287636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/657242/" ]
It's not free, but perhaps [Objectify](http://tigerbears.com/objectify/) would do what you want? It seems very slick.
Pre-writing model code is not the most flexible solution. You can have clever models, which try to convert your incoming JSON to your defined properties. Have a look at the JSONModel Obj-C framework. It has tons of demos and tests included and it's very easy to write models with it: <https://github.com/icanzilb/JSONModel>
6,557,355
I need to split up some strings, but the number of characters and position will change, This is quite easy in PHP but seems more complicated in C#. These are greyhound results in the UK. I have these strings in an array, **I need to extract almost everything from each string**, So I need a quick and simple solution to this. I need to be able to extract the Date, Time, Course(Crayfd), Distance(540m), also the Winner only(no "Winner(s): ", need to remove this), and also the marketID from the URL. **So what built in c# functions would be best suited for all this?**, a small example of some c# functions and how I use them would be great. Also a small explanation would also be great. ``` [0, 0] = "BAGS cards / Crayfd 2nd Jul - 12:58 S6 540m settled" [0, 1] = "Winner(s): Springtown Mary" [0, 2] = "http://rss.betfair.com/Index.aspx?format=html&sportID=4339&marketID=103165302" [1, 0] = "BAGS cards / Crayfd 2nd Jul - 12:58 TO BE PLACED settled" [1, 1] = "Winner(s): Black Hawk Boy, Springtown Mary" [1, 2] = "http://rss.betfair.com/Index.aspx?format=html&sportID=4339&marketID=103165303" [2, 0] = "Forecast Betting / Crayfd (FC) 2nd July - 12:58 Forecast settled" [2, 1] = "Winner(s): 1 - 3" [2, 2] = "http://rss.betfair.com/Index.aspx?format=html&sportID=4339&marketID=103164570" [3, 0] = "BAGS cards / Romfd 2nd Jul - 12:49 A2 400m settled" [3, 1] = "Winner(s): Come On Rosie" [3, 2] = "http://rss.betfair.com/Index.aspx?format=html&sportID=4339&marketID=103165272" ```
2011/07/02
[ "https://Stackoverflow.com/questions/6557355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/711308/" ]
I'd suggest using [String.Split](http://msdn.microsoft.com/en-us/library/system.string.split%28v=VS.100%29.aspx), [String.[Last]IndexOf](http://msdn.microsoft.com/en-us/library/k8b1470s.aspx), [String.Substring](http://msdn.microsoft.com/en-us/library/hxthx5h6.aspx), and LINQ extensions (simple ones, e.g. `.Last()`, just to simplify things). e.g. if the URL is in `string url` and it's safe to assume the marketId is always at the end like that: ``` int marketId = int.Parse(url.Split('=').Last()); ``` Or to get things from the first line, if it's called `courseEtc`: ``` string[] courseEtcParts = courseEtc.Split('/', '-'); string[] lastParts = courseEtcParts.Split(); string time = lastParts[0]; ``` And to look for something like a distance, you could use regex. Something like `[0-9]+m`.
It's not entirely clear what your requirements are, but if you are splitting up strings, my first thought would be to use Regex: <http://msdn.microsoft.com/en-us/library/30wbz966(v=vs.71).aspx> Would that work for you? Hope this helps, John
9,464,705
I have general architecture level question on below scenarios. I have lots of sub systems like components in my product. is it good to keep each subsystem as a separate process ? or is it good to keep all subsystems in separate threads in a single process ? All my subsystems will be interacting each other for giving/getting data from each other.
2012/02/27
[ "https://Stackoverflow.com/questions/9464705", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1041290/" ]
It seems what you are doing it not correct. It is actualy not rendering the TextBox as you have not given items source. Or what you can do is something like ``` <ItemsControl.Items> <TestTextBoxFet:TestTextBox Text="xaml text"/> </ItemsControl.Items> ```
I agree with gaurawerma. The precedence of value set in constructor is higher than that set in Data Template. Hence you see the result as different in both the cases. <http://social.msdn.microsoft.com/Forums/en/wpf/thread/a4e7ed36-9a8a-48ce-a5d5-00a49376669b>
17,057,147
``` import csv with open ('data.txt', 'r') as f: col_one = [row[0] for row in csv.reader(f, delimiter= '\t')] plots = col_one[1:] ``` The data in column one are floats, but above code makes list of strings. How can I make the list of floats correcting above codes?
2013/06/12
[ "https://Stackoverflow.com/questions/17057147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2473267/" ]
To get the relative feature importances, read the [relevant section of the documentation](http://scikit-learn.org/stable/modules/ensemble.html#feature-importance-evaluation) along with the code of the linked examples in that same section. The trees themselves are stored in the `estimators_` attribute of the random forest instance (only after the call to the `fit` method). Now to extract a "key tree" one would first require you to define what it is and what you are expecting to do with it. You could rank the individual trees by computing there score on held out test set but I don't know what expect to get out of that. Do you want to prune the forest to make it faster to predict by reducing the number of trees without decreasing the aggregate forest accuracy?
Here is how I visualize the tree: First make the model after you have done all of the preprocessing, splitting, etc: ``` # max number of trees = 100 from sklearn.ensemble import RandomForestClassifier classifier = RandomForestClassifier(n_estimators = 100, criterion = 'entropy', random_state = 0) classifier.fit(X_train, y_train) ``` Make predictions: ``` # Predicting the Test set results y_pred = classifier.predict(X_test) ``` Then make the plot of importances. The variable `dataset` is the name of the original dataframe. ``` # get importances from RF importances = classifier.feature_importances_ # then sort them descending indices = np.argsort(importances) # get the features from the original data set features = dataset.columns[0:26] # plot them with a horizontal bar chart plt.figure(1) plt.title('Feature Importances') plt.barh(range(len(indices)), importances[indices], color='b', align='center') plt.yticks(range(len(indices)), features[indices]) plt.xlabel('Relative Importance') ``` This yields a plot as below: [![enter image description here](https://i.stack.imgur.com/7DvJh.png)](https://i.stack.imgur.com/7DvJh.png)
11,102,518
I have a file which looks like this: ```none 80,1p21 81,19q13 82,6p12.3 83,Xp11.22 84,3pter-q21 86,3q26.33 87,14q24.1-q24.2|14q24|14q22-q24 88,1q42-q43 89,11q13.1 90,2q23-q24 91,12q13 92,2q22.3 93,3p22 94,12q11-q14 95,3p21.1 97,14q24.3 98,2p16.2 ``` And I want to sort them based on the second column. And the first column should change accordingly too. When you use the 'sort' command in Perl, it doesn't do it because it says it's not numeric. Is there a way to sort things alpha numerically in Perl?
2012/06/19
[ "https://Stackoverflow.com/questions/11102518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1203044/" ]
If you read [the documentation for sort](http://perldoc.perl.org/functions/sort.html), you'll see that you don't need to do a numeric sort in Perl. You can do string comparisons too. ``` @sorted = sort { $a cmp $b } @unsorted; ``` But that still leaves you with a problem as, for example, 19q will sort before 6p. So you can write your own sort function which can make whatever transformations you want before doing the comparison. ``` @sorted = sort my_complex_sort @unsorted; sub my_complex_sort { # code that compares $a and $b and returns -1, 0 or 1 as appropriate # It's probably best in most cases to do the actual comparison using cmp or <=> # Extract the digits following the first comma my ($number_a) = $a =~ /,(\d+)/; my ($number_b) = $b =~ /,(\d+)/; # Extract the letter following those digits my ($letter_a) = $a =~ /,\d+(a-z)/; my ($letter_b) = $b =~ /,\d+(a-z)/; # Compare and return return $number_a <=> $number_b or $letter_a cmp $letter_b; } ```
``` #!/usr/bin/env perl use strict; use warnings; my @datas = map { /^(\d+),(\d*)(.*)$/; [$1, $2, $3]; } <DATA>; my @res = sort {$a->[1] <=> $b->[1] or $a->[2] cmp $b->[2]} @datas; foreach my $data (@res) { my ($x, $y, $z) = @{$data}; print "$x,$y$z\n"; } __DATA__ 80,1p21 81,19q13 82,6p12.3 83,Xp11.22 84,3pter-q21 86,3q26.33 87,14q24.1-q24.2|14q24|14q22-q24 88,1q42-q43 89,11q13.1 90,2q23-q24 91,12q13 92,2q22.3 93,3p22 94,12q11-q14 95,3p21.1 97,14q24.3 98,2p16.2 ```
6,966
I recently did a job for a large organization. The job was not a long-term one, so the terms were that I would complete the work and then submit my invoice after completion of work. I was fine with this. The contract I was asked to sign by the client included a clause that states: > > An invoice must be submitted within 30 days from the end date of the purchase order authorization, or upon completion of the service, whichever occurs first. Failure to submit an invoice within 30 days will be considered a material breach of this contract. This will result in non-payment of services rendered. > > > Additionally the contract stated that invoices must be delivered electronically to the E-mail address of the contact person I worked with. The contract specifically said paper-based invoices cannot be accepted. At the time I signed the contract I did not see either of these as being a problem. However, right after completing the job I had a family emergency and was away for a couple of weeks. With everything going on the invoice just slipped my mind. When I was "back on track" I looked at my records and noticed I hadn't invoiced, so I sent the invoice via Email. This was on day number 29 after I'd completed the work. I requested confirmation of receipt of the invoice in the Email. I did not get a response on day 30 that my invoice had been received. So, to be safe, I sent it again, again requesting confirmation. Later the same day, I received a reply to the Email I sent on day 30, saying that I violated the contract by sending my invoice late. They claimed it was received on day 31, apparently a classic off-by-one error on their part, and therefore I would not be paid. I informed my contact that I had actually submitted the invoice on day 29 but it apparently had not been received. I was given quite a nasty reply, along the lines of "well next time send it in sooner and that won't happen." I cannot prove whether or not the invoice was ignored, maybe got spam-foldered, or whether it was actually not delivered. Do I have any basis whatsoever to challenge this? The amount in question is quite significant. This is an organization I hoped to work with in the future, so I don't want to get on their "bad side", but the amount in question is too significant to ignore. I find it odd that a contract can actually stipulate such a short invoicing period, and I can't honestly say I've heard of a clause like that in a contract before nor have I ever seen it myself in my work. Do I even have any recourse in terms of charge-off or bad debt given the contract?
2017/07/07
[ "https://freelancing.stackexchange.com/questions/6966", "https://freelancing.stackexchange.com", "https://freelancing.stackexchange.com/users/17648/" ]
To answer your question, yes, it is possible to challenge the time limit. You will need a lawyer for that, and will likely win, in my amateur opinion. You sent on day 29, so you are entitled to full payment. That they play games by ignoring it is something that reflects badly on them, and any judge should see right through that. Also, outcomes of cases like this often favor the little guy, you, and I say "like this" because you did, in fact, comply with the contract, and shady companies have often pushed the little guy around, counting on the fact that most do not have funds to fight. Been there, done that, won. What you probably want is 1) for them to pay you, 2) for them to respect you going forward (which they do not), and 3) them to like you and continue having work for you. You cannot have all this. Their move is deliberate, obviously, so if you win one way, they will make sure you lose another way. My choice would be to calmly hire a lawyer, win, expect no future work from them, nor losses, and move on. EDIT: In my case, the contract work so closely resembled employment, state law protected me as though I were an employee. In South Carolina, the state awards "treble damages", which means triple, so my $10K turned into $30K in the suit. I settled out of court for $20K, which was really break-even for me, after legal costs.
If legally possible, the contract needs to be re-negotiated, as you are performing actual repairs and not typical maintenance. While it is the client's right to attempt to become independant of you, you on the other hand should be able to expect to be the sole provider of maintenance - which should not include mopping up after the client made a mess. It seems you need to review the expectations of both parties. If they want to cut you out, be proactive about it and negotiate a 'release contract' where you are paid for documentation and perhaps on-site training and remote support. Perhaps being paid by the hour is the way to go? In fixed price relationships, clients tend to want every single detail covered, whereas they consider nice-to-have versus need-to-have when paying by the hour.
39,857,510
I tried to delete a value from my session using : ``` Session::forget('value') ``` but it didn't delete! However, when i tried using `save` method like so : ``` Session::forget('value') Session::save() ``` it worked! (I.e. the value was deleted from the session.) Please - what am I doing wrong? I don't see the `save` method in the Laravel documentation when using `Session::flush()` and `Session::forget()`.
2016/10/04
[ "https://Stackoverflow.com/questions/39857510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5746074/" ]
The save() method will actaully perform the write to the file. It seems that your application doesn't call Session::save() before it outputs content to the user on all requests. If this method isn't called, the Session file will not get updated with the new values, and they will still be there on the next visit. It's important to always call Session::save() if you wish to be sure stuff got removed or added and the change persists.
i use `Session::save()` method its work fine to save session data. But when i flush session using `Session::flush()` it does not clear all the data that is stored in Laravel session. `Session::forget('value')` works fine to clear session specific value.
10,208
It might just be subjective, but to me the nights seem to be longer than the days. Barely have I gone outside to collect some sand to make glass, or see if I can find that promising looking cave again when night falls. Even with the watch to show me when it's nearly dawn there doesn't seem to be enough time. Are there seasons in Minecraft and can I expect to have longer days at some point?
2010/11/03
[ "https://gaming.stackexchange.com/questions/10208", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/13/" ]
I have just tested it on my world using a timer and it shows that the **safe time lasts about 10 mins 30 seconds** between day and sunset, whereas **mobs spawn and are active for 9 mins 30 seconds** between night and sunrise. However, it takes 20 seconds for the mobs to burn after the day starts. This is set on Difficulty: Normal.
No.The usual Minecraft day and night consists of 33 minutes. The day time takes up 20 minutes of that time. Therefore, nighttime only consists of 13 minutes. Which means that the Minecraft day is longer than the Minecraft night.
22,929,819
I a newbie to java so please don't rate down if this sounds absolute dumb to you ok how do I enter this using a single scanner object > > 5 > > > hello how do you do > > > welcome to my world > > > 6 7 > > > for those of you who suggest ``` scannerobj.nextInt->nextLine->nextLine->nextInt->nextInt,,, ``` check it out, it does not work!!! thanks
2014/04/08
[ "https://Stackoverflow.com/questions/22929819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3247500/" ]
``` public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.printf("Please specify how many lines you want to enter: "); String[] input = new String[in.nextInt()]; in.nextLine(); //consuming the <enter> from input above for (int i = 0; i < input.length; i++) { input[i] = in.nextLine(); } System.out.printf("\nYour input:\n"); for (String s : input) { System.out.println(s); } } ``` Sample execution: ``` Please specify how many lines you want to enter: 3 Line1 Line2 Line3 Your input: Line1 Line2 Line3 ```
You can try only with lambda too: ``` public static void main(String[] args) { Scanner scanner = new Scanner(System.in); scanner.forEachRemaining(input -> System.out.println(input)); } ```
25,162,598
I am working on AngularJS application.In the application one of the DIV is displaying grid data. What I want is, when the grid is loading data, system should show the loading image on top of the div & when the data is loaded, it should remove that image. If I follow the classic way, when data load event is triggered, we can manually show the image on top of the div and when data is fully loaded, we can manually hide the loading image. Can we automate this process and leave it to AngularJS or any other library to decide when to show and when to hide the loading image. Something like, as long as inner HTML of DIV is getting modified, it should display the loading image.
2014/08/06
[ "https://Stackoverflow.com/questions/25162598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1350476/" ]
Yes you can automate this process and leave it to AngularJS using data bindings. ``` <i class=loading-icon ng-if=!ctrl.data.length></i> app.controller("ctrl", function ($http) { var ctrl = this; ctrl.data = []; $http.get(url).success(function (data) { ctrl.data = data; }); }); ```
In the HTML add `data-ng-if="isLoading"` to the loading div, then in the js where you load the data set `scope.isLoading` as true at the before making the request and on load complete set it to false.
30,441
This is a follow-on question from: [How alien can a language be - grammar?](https://worldbuilding.stackexchange.com/questions/30371/how-alien-can-a-language-be-grammar) Leaving the grammar behind we can look at how the actual words or concepts are transmitted. Almost all human languages are based around stringing together sequences of phonemes (sounds). There are exceptions (various sign languages for example) but those are used only when sound is not available due to circumstances such as deafness or a need for silence. So my question is what is the most believable ways, other than stringing together phonemes, that could evolve in a naturally occurring intelligent species? In other words how could they communicate with each other? Note that this would be the primary communication method so either should have an advantage over using phonemes or a reason why phonemes aren't used.
2015/11/25
[ "https://worldbuilding.stackexchange.com/questions/30441", "https://worldbuilding.stackexchange.com", "https://worldbuilding.stackexchange.com/users/49/" ]
One potential that actually occurs in ant species: *Open, bloody warfare.* Well, not quite, but the interactions of a hive's contributing parts can fundamentally affect the way that a hive behaves. In common ants the emergence of a long-running threat changes the worker/soldier dynamic in the nest. In the instance of an emergently intelligent hive species, communicating with another hive is simply a matter of bodyslamming your constituent parts together to see what happens. Want to shout louder? Send more minions. Want to change your inflection? Use different minions. It doesn't matter if some die, they're replaceable. You can be in the middle of delivering a love poem, and to other species (say the monkeys in the flying tin cans) it will look like you're engaged in the most brutal form of warfare possible. This concept is actually explored quite well by Orson Scott Card in the Ender series of books. It seems that the buggers are hell-bent on destroying humanity when actually they're just trying to say 'hello'... So if you're a hive mind: Communicate via the medium of minion.
There is no end to what form an alien language could take - any kind of signal, sound, light or any electromagnetic wave, touch, smell, gravity waves, thoughts, gestures.. The only condition would be that the parts of the signal are somehow related to each other. Also, the composition of the signal can seem like totally random to an external observer.
114,017
How to remove **Price filter** from layered navigation? I set Layered Navigation in Manage Attribute section size as 0 but still the Size filter is showing in left side under Shop by section. Can anyone assist me resolving this issue?
2016/05/05
[ "https://magento.stackexchange.com/questions/114017", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/39424/" ]
Find this file in out layout folder of your theme. ``` /app/design/frontend/diakart/default/layout/catalog.xml ``` there find the layout file written for layered navigation. check code like this line, For size also you will get same line. ``` <block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml" /> ``` add this line before `</block>` ends. ``` <action method="unsetChild"><child>category_filter</child></action> ```
First confirm what you want to remove **Price** filter or **Size** filter. Any attribute you want to remove from layered navigation then just go to Catalog -> Attributes -> Manage Attributes -> Edit that attribute [![enter image description here](https://i.stack.imgur.com/esoMh.png)](https://i.stack.imgur.com/esoMh.png) and set 'Use In Layered Navigation' to **No**
57,002,494
In my LINQ query below I want to select the 'product' rows and add the 'sale' rows data into it but the opposite is happening, it's selecting the 'sale' rows and adding the 'product' rows ``` var query = (from product in SampleProductTable from sale in SampleSalesTable where (sale.ProductId == product.Id) select new { Id = product.Id, TotalSales = product.TotalSales + ((product.Id == sale.ProductId) ? sale.Amount : 0) }) ``` **Sample Product Table** ``` +-------+------------+---------+-----------------+-------+------------+ | Id | CategoryId | BrandId | Name | Price | TotalSales | +-------+------------+---------+-----------------+-------+------------+ | mlk3 | MLK | BRND1 | Creamy Milk | 5 | 10 | | snck2 | SNCK | BRND2 | Chocolate Snack | 2 | 24 | +-------+------------+---------+-----------------+-------+------------+ ``` **Sample Sales Table** ``` +-----+-----------+--------+ | Id | ProductId | Amount | +-----+-----------+--------+ | 120 | mlk3 | 55 | | 121 | mlk3 | 15 | | 122 | snck2 | 12 | | 123 | mlk3 | 5 | | 124 | mlk3 | 10 | | 125 | snck2 | 2 | | 126 | mlk3 | 115 | | 127 | snck2 | 6 | | 128 | snck2 | 34 | +-----+-----------+--------+ ``` **Desired Output** ``` +-------+------------+ | Id | TotalSales | +-------+------------+ | mlk3 | 210 | | snck2 | 78 | +-------+------------+ ```
2019/07/12
[ "https://Stackoverflow.com/questions/57002494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6701210/" ]
In general LINQ terms the query shape you are looking for is called [grouped join](https://learn.microsoft.com/en-us/dotnet/csharp/linq/perform-grouped-joins): > > The group join is useful for producing hierarchical data structures. It pairs each element from the first collection with a set of correlated elements from the second collection. > > > In your case, it will produce a collection of correlated `Sales` for each `Product`. Then all you need is to apply aggregate (`Sum`) inside the final projection (`select`): ``` var query = from product in SampleProductTable join sale in SampleSalesTable on product.Id equals sale.ProductId into productSales select new { Id = product.Id, TotalSales = product.TotalSales + productSales.Sum(sale => sale.Amount) }; ``` But since in some of the comments you mentioned converting to SQL, most likely you are using some ORM like LinqToSQL, EF or EF Core. In such case the things are even simpler. These ORMs support a so called *navigation properties* which represent the relationships, and when used inside queries are translated to SQL with all the necessary joins, so you don't need to be bothered with such details and can concentrate on the logic needed to produce the desired result. If that's the case, the `Product` class would normally have something like ``` public ICollection<Sale> Sales { get; set; } ``` and the query in question would be simple `Select` like this: ``` var query = db.Products .Select(product => new { Id = product.Id, TotalSales = product.TotalSales + product.Sales.Sum(sale => sale.Amount) }); ```
In query syntax, Slava's solution should return with the result you're looking for i.e. ``` var querySyntax = (from product in SampleProductTable join sale in SampleSalesTable on product.Id equals sale.ProductId into sales from subSales in sales.DefaultIfEmpty() group subSales by new { product.Id, product.TotalSales } into grp select new { grp.Key.Id, TotalSales = grp.Sum(s => s.Amount) + grp.Key.TotalSales }).ToList(); ``` If you have a burning desire to use method syntax for whatever reason, this equivalent LINQ query will also work: ``` var methodSyntax = (SampleProductTable .GroupJoin(SampleSalesTable, product => product.Id, sale => sale.ProductId, (product, sales) => new {product, sales}) .SelectMany(s => s.sales.DefaultIfEmpty(), (s, subSales) => new {s, subSales}) .GroupBy(ss => new {ss.s.product.Id, ss.s.product.TotalSales}, ss => ss.subSales) .Select(grp => new {grp.Key.Id, TotalSales = grp.Sum(s => s.Amount) + grp.Key.TotalSales})).ToList(); ```
131,848
Rather than replace a dead ballast in a fluorescent fixture, I've decided to simply bypass and move to LEDs. However, I think I may have grabbed the wrong kind of replacement tubes the other day in Home Depot. They are in the Philips "InstantFit" range, and are specifically intended to be used without having to remove the ballast. But my question is the following. Is it merely that you don't *have* to remove the ballast (i.e. but you can if you want)? Ot is it the case that you *must not* remove the ballast?† I ask because all the instructions I've been able to find are a tiny bit ambiguous (to me). In the "Warnings and Safety" section on page two of [the data sheet](http://www.assets.lighting.philips.com/is/content/PhilipsLighting/fp929001226504-pss-global) it says††: > > Philips LED T8 InstantFit lamps will only operate properly on compatible instant-start ballasts. > > > However, there are two ways to read that. One, which I now think is the intent, is: > > Philips LED T8 InstantFit lamps will operate properly only if used with a ballast, and it must be of a compatible, instant-start type. > > > But the other is: > > Philips LED T8 InstantFit lamps will operate properly with or without a ballast. However, if a ballast is used, then it must be of a compatible, instant-start type. > > > Anyone know definitively which it is? Various numbers (from the box): * Model: 9290012265 * Ordering Code: 20T12 EM LEF/48-4000 IF G 10/1 thanks. † If so, that's fine. But then I need to replace them and get the kind intended for ballast bypass, of which there are several. †† That link is to the "global" version. Curiously, the almost-but-not-quite-identical [US version](http://www.assets.lighting.philips.com/is/content/PhilipsLighting/fp929001226504-pss-en_us) does not make the same explicit point.
2018/01/27
[ "https://diy.stackexchange.com/questions/131848", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/70997/" ]
Interesting thing about being human is the brain is wired to see what it expects to see. It's hard to turn that off, even if you're a [ship spotter](https://en.wikipedia.org/wiki/MV_Yulius_Fuchik#In_popular_culture) or [pilot](https://www.youtube.com/watch?v=b26NcJCLZl4). There **is** such a thing as LED bars which work both ways, either with a ballast or direct-wire. But they're a lot bolder about claiming so! The ruling word is "only" and your first interpretation is correct. The data sheets you link are highly ambiguous. But that's not so weird when you look at the Electrical Code, NEC 110.3b: > > NEC 110.3(b) Equipment must be installed and used in accordance with any instructions included in the listing or labeling requirements. > > > The operative words are **instructions** and **labeling**. A data sheet is neither. So you need to review the labeling on the item, or the instructions in the box. Be warned: if you find that **data sheet** inside the box, *that is bad*. It means this thing is probably counterfeit: the counterfeiters found the same PDF you did because it was the first/easiest document to find. I am always suspicious of the bargain priced items at the big-box. Even legit brands often "make" items specifically for one big-box store. If you have a part number that only associates with one big-box, run screaming.
LED stands for light emitting diode, so not an AC device. The light is emitted when forward biased, so a rectifier is needed to avoid high current in the case of reverse bias and then current limiting to provide the correct operating current. Does not need a ballast but might work with one.
44,869,885
* When I try logging in to wp-admin (or even wp-admin/index.php) I simply get redirected to my site's homepage. (after authenticating successfully - i.e. It DOES accept my login credentials (so its not an account, password or blacklisting issue), but simply wont go to the admin dashboard page after login) (I suspect it may be an infinite loop that is occurring?? - how do I find out?) * But I CAN login if I go directly to the wp-login.php page, which is weird. (but this is not acceptable as I need users to be able to login through a custom login page again) * This came about seemingly randomly (I hadnt changed anything in a week - just woke up one day and couldnt log in) * Preceding factors: + I havent moved the site at all + I havent changed the domain, urls or anything + no cache-ing plugins present The week before I had: Updated WP to 4.8 Updated PHP from 5.4 to 5.6 (to allow installation of an SEO plugin add-on - 'SEO framework extension manager') But it had been working fine for days. * So to given some reporting this after PHP upgrade, I tried setting my PHP back to 5.4, but no luck. * then up to 5.5, and then back up to 5.6 again - still no fix. I do also have a membership plugin that renames the login page to /login (But that has worked fine for years too) I have tried all the usual fixes for wp-admin login issues: - I have tried multiple browsers, and cleared their cache and cookies - no fix. - I have disabled every plugin one by one (via ftp folder rename) - no fix. - even re-updated WordPress to 4.8 again (in case any of the core files needed replacing) * checked file and folder permission are all correct (644) via FTP - all fine - no fix. * I have tried adding lines to the wp-config.php file - with no luck Such as define('WP\_HOME','<https://warrenmaginn.com>'); define('WP\_SITEURL',... etc. define('FORCE\_SSL\_ADMIN', true); define('FORCE\_SSL\_LOGIN', true); even this solution offered at kinocreative: @define('ADMIN\_COOKIE\_PATH', '/'); * when I remove the htaccess file altogether, still no fix (but I do actually get a 404 error page whenever I try access any other page than the root domain, when I dont have the htaccess in place) (which may mean something in the htaccess i needed to correctly link in my site - but my htaccess hasnt changed, and if I edit it down just to the canonical rewrites (I use SSL sitewide, and do not ever use www in any references to my domain (have checked across database etc.) * I have tried inserting the text "die(**FILE**':'.**LINE**);" on every line of the wp-admin/index.php file (to trouble shoot it - and it stopped (without redirecting) even after placing the line all the way at the bottom of the file - so I imagine this means the issue is not in this file) * Any other files I should try this in? * Or debug modes I can use track this down? Any suggestions would be VERY appreciated (this is doing my head in) Thanks in advance for offering your wisdom...
2017/07/02
[ "https://Stackoverflow.com/questions/44869885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8243818/" ]
Warren, First of all, delete the codes you inserted in your wp-config.php. Instead, put it before your the require\_once(ABSPATH . ‘wp-settings.php’): ``` define( 'WP_HOME','http://warrenmaginn.com' ); define( 'WP_SITEURL','http://warrenmaginn.com' ); define( 'TEMPLATEPATH','/home/MYUSER/public_html/wp-content/themes/MYTHEME' ); define( 'STYLESHEETPATH','/home/MYUSER/public_html/wp-content/themes/MYTHEME' ); ``` If your website uses SSL, don't add any rules to wp-config or htaccess because it may result in 500 internal server error. To force the use of SSL, install "Really Simple SSL" and clear your htaccess, leaving only the necessary: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ``` Now, go to your php settings and set error\_reporting as "E\_ALL" and verify what the logs says (if you want to fix it by the hard way). But you can go to your file manager and change the plugin folder name to "plugin.old". It will say if there are any plugins causing the problem. If it is, you could disable each plugin to discover which one is giving you this headache. If plugins is not the real cause, I'd try to upload a fresh version of your Wordpress (you can find it here ~~ <https://wordpress.org/download/>). Remember to rename wp-admin and wp-includes to wp-admin.old and wp-includes.old, respectively before unzip the fresh ones. Don't forget to delete all the root folder WP files except wp-config.php. I'm looking forward to receive your answer.
For those facing this, you might add a new icognito page and visit again, sometimes its due to caching. if its still not working, might be your htaccess file issue.
7,397,050
I want to hide the keyboard after typing the content into the UITextView but i can not do this by default like UITextField. Is there any way to hide the keyboard, Rightnow i put the button which can help me out.If any default way to hide it then please tell me.
2011/09/13
[ "https://Stackoverflow.com/questions/7397050", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1407280/" ]
`CalculateBinary(InputNum)` does NOT modify the value of `InputNum`, so its value would be always the same (300000000) and the while loop never end.
Looks like you are expecting the last number in the file to be less than 0 to terminate your program. Instead it's better to detect the end of the file. Try uncommenting your file code and using the while condition instead: ``` while (fin.good()) ```
16,043,819
I have a java class full of void methods, and I want to make some unit test to get maximal code coverage. For example I have this method : ``` protected static void checkifValidElements(int arg1, int arg2) { method1(arg1); method2(arg1); method3(arg1, arg2); method4(arg1, arg2); method5(arg1); method6(arg2); method7(); } ``` Its poorly named for a reason because I translated the code for better understanding. Each methods verify if the arguments are valid in some way and are well written. Example : ``` private static void method1(arg1) { if (arg1.indexOf("$") == -1) { //Add an error message ErrorFile.errorMessages.add("There is a dollar sign in the specified parameter"); } } ``` My unit test are covering the small methods fine because I ask them to check if the ErrorFile contains the error message, but I dont see how I can test my method checkIfValidElements, it returns nothing or change nothing. When I run code coverage with Maven, it tells me that the unit test doesent cover this part of my class. The only way I see is to change this method to return an int or bollean value, like this : ``` protected static int checkifValidElements(int arg1, int arg2) { method1(arg1); method2(arg1); method3(arg1, arg2); method4(arg1, arg2); method5(arg1); method6(arg2); method7(); return 0; } ``` With this method I am able to do an assert equals, but it seems to me that it is futile to do this. The problem is that I have a couple of class that are designed like this and its lowering my unit test coverage %.
2013/04/16
[ "https://Stackoverflow.com/questions/16043819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1352575/" ]
You can still unit test a void method by asserting that it had the appropriate side effect. In your `method1` example, your unit test might look something like: ``` public void checkIfValidElementsWithDollarSign() { checkIfValidElement("$",19); assert ErrorFile.errorMessages.contains("There is a dollar sign in the specified parameter"); } ```
I think you should avoid writing side-effecting method. Return true or false from your method and you can check these methods in unit tests.
12,743
Due to the nature of DnD core its tropes and builds, weapon types rarely count. Enchantments, especially at higher levels, are what count. Your weapon damage die and type rarely count, and the game does not really favor wielding different types of weapons. Personally, I dislike that. Holding a greatsword, a greatclub, a kukri or a spiked chain should make a difference. While these weapons have some innate bonuses to match their uniqueness, they are pretty limited and rarely worth the effort required to be able to use them (mostly talking about spiked chain and other exotic weapons). Also the game's build strategy does not help with this problem, as most martial classes rely on mastering a weapon and dismissing the use of all others. Tome of Battle fixed that to some extent, but the problem still remains. Wielding a greatclub instead of a greatspear should have some difference, since one is more likely to impale and the other to stun/knockback foes you hit. A greatsword is likely to damage and wound foes that will bleed, and a greataxe may chop a limb or cast bleeding wounds. There are advantages and disadvantages weapons hold that are not portrayed by the damage type. When I play with a martial character, i want to feel an impact from my weapon choice, or the need of different weapons for different challenges (this is partially done by DR/type\_of\_damage). A spear for example, in the right hands, could impale people, a greatclub could stun or push people back by its might and momentum, a greataxe may chop limbs (too much of a mech change i know) and a katana could deal bleeding injuries. I want a mechanic that will make me feel that my weapon of choive matters, that it actually gives me an advantage or a disadvantage, not that it deals 1d10 damage. Are there any rules - homebrew or official in nature - that would tactically favor the use of different weapon types, and give a more realistic approach to weapons?
2012/02/29
[ "https://rpg.stackexchange.com/questions/12743", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/2895/" ]
I do not think you can do this without house rules, but I will say that reality supports you. In historical combat, well off warriors often carried multiple weapons for different uses. During the Heian period in Japan, Samurai often brought both a yari (like a spear) and a katana to battle, and would use the yari when fighting cavalry or fighting on an open field, and then switch to the katana in close quarters. Similarly the Spartans normally brought both spear and sword. And, if both combatants are without armor, the one using a rapier will have an advantage in speed over the man with the great sword. But if both are armored, a rapier is difficult to use and the great sword comes to the fore. So, I agree that weapon type should matter. But actually making that happen tends to make the rules complicated fast, and I have not seen any official D&D rules that would really help with this.
or.... you could just accept that DnD isn't the kind of game where weapon types matter much. After all, you have players with ever-increasing hit points that bear no resemblance to real-world damage. Armour that has little to do with the type of combat you're facing. The original (or 2nd ed) DnD justified this by saying it was all about heroic combat, the kind where the Greek hero marches into battle and kills all the NPCs with just a few scratches to show for it. So, as you're in the kind of world where a hero can kill a thousand kobolds with barely a bruise, why would it matter which weapon he chooses to use? A hero with a club is just as effective a hero as one with a shining sword. In fact, you get to the point where the hero with a chair leg is just as good a combatant - he's a f\*\*\*ing *hero* after all. (if you want an example, think of the Bourne films where the hero beats up the other guy with a rolled up magazine. If I tried it, I'd get a paper cut, but he's a hero where it doesn't matter what he uses) So, don't worry about it too much. If you want realism, go for Runequest. If you want heroic fantasy, stick with DnD and understand a hero will be effective with any weaponry.
12,067,625
I am using eclipse 3.7 indigo , the issue that I am facing is when I start my eclipse my machine gets too slow even the eclipse get hang some times in between , the settings of my eclipse.ini file is below.. ``` -startup plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502 -product org.eclipse.epp.package.jee.product --launcher.defaultAction openFile --launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx512m ``` please advise how to overcome from this..!!
2012/08/22
[ "https://Stackoverflow.com/questions/12067625", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1614879/" ]
Perhaps this will help? I mean, I don't know the specs of the machine you're on, but this is nice on less powerful machines. [What are the best JVM settings for Eclipse?](https://stackoverflow.com/questions/142357/what-are-the-best-jvm-settings-for-eclipse)
Check with the eclipse.ini file and add the following java parameters and values. ``` -vmargs -Dosgi.requiredJavaVersion=1.6 -Xmn128m -Xms1024m -Xmx1024m -Xss2m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+UseParallelGC ``` This worked for me. Might help.
4,181,442
I know this is a dumb question but... Is $x ≠ 1,3,5$ the same as $x$ does not belong to {$1,3,5$}, for example ? --- Sorry for the formatting. Btw, anyone has a link with mathjax's commands I guess? --- Thanks in advance.
2021/06/24
[ "https://math.stackexchange.com/questions/4181442", "https://math.stackexchange.com", "https://math.stackexchange.com/users/942203/" ]
$x \neq 1, 3, 5$ isn't super standard notation, but if someone wrote it out at random I'd assume they meant $x \neq 1$ and $x \neq 3$ and $x \neq 5,$ or $x \not\in \{1, 3, 5\}$ for short.
$x\notin (1,3,5)$ means that $x$ is not a member of a set. The set is defined as elements, which could be letters, intervals or anything else. $x\ne 1$, etc. means that equality is defined which is no necessarily true, unless equality is defined by identity. Simple example $1+2=3$, but for set membership $\{1+2\}$ is not the same as $\{3\}$.
168,710
I just stumbled into something that is both bizarre and confusing, and I'm not entirely sure what to make of it. I'm an IT technician. I sat down on employee Alex\*'s desk, after hours, responding to a request for support from Alex's manager (Charlie\*) about that computer's performance. All people mentioned were not in the office at this time, by the way. Alex's computer was left on, with the user logged in and unlocked. The web browser was left open on employee Blake\*'s personal webmail page, more specifically in an email with Blake's latest salary receipt. I'm unsure what to do with this information. On one hand, it's not my responsibility to make sure personal email accounts are secure, and I'm also not absolutely sure that there is something nefarious going on or if there was consent. On the other hand, this ends up intersecting with the business since the salary receipts are involved, and in spite of that, I also feel like I have a moral obligation to do something about this given that it seems extremely likely that there is something nefarious going on. Their relationship is distant, as far as I can tell, but I don't know either too well. They don't interact a lot because their functions don't intersect too much. They work in different offices, different departments, but in the same floor. Neither is in a position of power or influence, and there's no hierarchy link between them. It's at least possible that there might be more to this beyond the office, but it's unlikely. Plus, even if Blake wanted to show their salary receipt to Alex, for whatever reason, it doesn't make sense to provide access to their personal email account. Some more context: The users' expectation is for us to log in with an admin account, otherwise we schedule support with the user. I don't know if the user knew about the timing of the intervention, since the request came from their manager. Plus, this user always leaves the computer on. Also, the user session locks after some time, so leaving it unlocked may not be surprising if the user relies on the timeout. Since I started working on it right after they left, it just happened to not lock in time. The sensitive information left on the screen suggests to me that the user wasn't thinking about my intervention after hours. --- \*Names fictionalized
2021/01/18
[ "https://workplace.stackexchange.com/questions/168710", "https://workplace.stackexchange.com", "https://workplace.stackexchange.com/users/37033/" ]
Log it -> Tell A & B assuming both knew -> Let them correct you if not ---------------------------------------------------------------------- You should first log what you've seen. A left themselves logged in, security risk, with B's emails open, security risk, and payslip open, personal information risk. Assume that what you saw was through some innocent means, B was checking their emails on A's computer or some such. With your security hat on talk to A and B together - telling them they shouldn't share computers like this and A shouldn't leave the computer on. If A had gained access without consent of B then B can point that out and escalate. This way you're tackling what is your job, IT security, and providing the information to B to take action if necessary.
Other answers deal with the direct question of what to do with the information now that you have it. One option to avoid similar dilemmas in the future (assuming Windows-based PC) would be NEVER look at the screen before hitting ctrl-alt-delete - focusing on the keyboard and not the screen as you approach. Then all private information will disappear from the screen and you can safely look at it to see whether you've got a login prompt or need to select "switch user" to log in with admin credentials as a separate session (although you'd almost certainly have figured that out before that point even from peripheral vision). If the user needs to be logged off for your tests, and you haven't already got standing permission to forcibly end the login session in such cases (potentially losing documents the user was still editing etc.), you could simply select the "lock" option (as the user should have done themselves when leaving the workstation unattended), and report back that user did not log out, so you cannot proceed, and/or seek permission from the manager to forcibly log that user out, potentially losing unsaved work. If the manager asks back "what were they in the middle of" you would then be able to honestly reply "I've no idea, the workstation is [now] locked". It may then still be necessary to report the security incident, but an honest report along the lines of like "user was still logged in on arrival, I immediately locked the workstation without looking at it in order to protect any private information that may have been displayed" would seem a better position to be able to take than, in effect, "On arrival, workstation was unlocked, and I couldn't resist looking at the private information displayed on the screen - and indeed looking at it closely enough to determine that A's computer was logged in to B's private email with B's payslip showing", which is what your original question amounts to. As others have pointed out, you can't now "unsee" what you saw, and there's a whole separate ethical issue about whether you had permission to check out what A had on their screen on arrival, and whether to admit to the privacy violation you committed if you did not have in fact have (implied) permission to do this, and again I'm not attempting to answer that part. However, if respect for privacy is important in your environment, you may want to use that approach in the future - and importantly be seen to be doing it routinely when servicing unattended PCs that can be observed by others in the room or in nearby rooms. A "I didn't see what was on the screen because I do this as soon as I arrive" will stand up a lot better if you've been seen doing that on multiple occasions... you'll need to determine the right balance between what needs to be kept private at all costs and what should be noticed and reported at all costs for your particular environment.
88,659
The CloudFlare free tier service offers unlimited bandwith while other CDNs charge starting at about $.10/gb. > > CloudFlare does not have bandwidth limits. As long as the domains > being added comply with our Terms of Service, CloudFlare does not > impose any limits. > > > There's very little said on their website in the way of restrictions. The offer appears to be legit. Is there a catch?
2016/01/09
[ "https://webmasters.stackexchange.com/questions/88659", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/7249/" ]
Five reasons we offer a free version of the service and always will: 1. Data: we see a much broader range of attacks than we would if we only had our paid users. This allows us to offer better protection to our paid users. 2. Customer Referrals: some of our most powerful advocates are free customers who then "take CloudFlare to work." Many of our largest customers came because a critical employee of theirs fell in love with the free version of our service. 3. Employee Referrals: we need to hire some of the smartest engineers in the world. Most enterprise SaaS companies have to hire recruiters and spend significant resources on hiring. We don't but get a constant stream of great candidates, most of whom are also CloudFlare users. In 2015, our employment acceptance rate was 1.6%, on par with some of the largest consumer Internet companies. 4. QA: one of the hardest problems in software development is quality testing at production scale. When we develop a new feature we often offer it to our free customers first. Inevitably many volunteer to test the new code and help us work out the bugs. That allows an iteration and development cycle that is faster than most enterprise SaaS companies and a MUCH faster than any hardware or boxed software company. 5. Bandwidth Chicken & Egg: in order to get the unit economics around bandwidth to offer competitive pricing at acceptable margins you need to have scale, but in order to get scale from paying users you need competitive pricing. Free customers early on helped us solve this chicken & egg problem. Today we continue to see that benefit in regions where our diversity of customers helps convince regional telecoms to peer with us locally, continuing to drive down our unit costs of bandwidth. Today CloudFlare has 70%+ gross margins and is profitable (EBITDA)/break even (Net Income) even with the vast majority of our users paying us nothing. Matthew Prince Co-founder & CEO, CloudFlare
There's another aspect that should be mentioned here: > > [**Freemium**](https://en.wikipedia.org/wiki/Freemium) is a pricing strategy by which a product or service (typically a digital offering or application such as software, media, games or web services) is provided free of charge, but money (premium) is charged for proprietary features, functionality, or virtual goods. > > > It's a common approach to get users familiar with the service and hope they will upgrade later on. Nothing wrong about freemium as long as the limitations are transparent. With the free plan, it's also likely that you will run into other limits (other than bandwidth) that will cause you to upgrade your account. Especially if you run an ecommerce website, you'll need a lot of other features and functionalities (HTTPS, real-time analytics, ...) that you're willing to pay for.
24,912,067
This is what I see when I try to install my app on my device (I'm using Android Studio 0.8.2): ``` Waiting for device. Target device: samsung-gt_s7500-cf994b04 Uploading file local path: C:\Users\Administrator\AndroidStudioProjects\Testaqua\app\build\outputs\apk\app-debug.apk remote path: /data/local/tmp/com.example.administrator.testaqua Installing com.example.administrator.testaqua DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.administrator.testaqua" pkg: /data/local/tmp/com.example.administrator.testaqua Failure [INSTALL_FAILED_INVALID_URI] ``` What in the seven hells does this error mean? [Edited] I installed my app on another rooted device, and it worked; it seems the problem is my device, android studio is running fine.
2014/07/23
[ "https://Stackoverflow.com/questions/24912067", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1459065/" ]
I get similar error message, I fixed it by passing the absolute path instead of filename, e.g. inside `adb shell`, this command will shows: ``` shell@example:/sdcard $ pm install -r -d app-release.apk pkg: app-release.apk Failure [INSTALL_FAILED_INVALID_URI] ``` Change it to absolute path fixed that error message, e.g.: `pm install -r -d /sdcard/app-release.apk` **[Second reason]** Another reason is the file not exist. It happen when I interrupt `adb push <apk> /sdcard/` by `Ctrl+C` recently. Re-push apk **twice** required. **[Third reason]** This error occurred if the apk reside `/mnt/runtime/default/<thumb_drive_mounted_directory>`, I have to move the apk to `/sdcard/` first to install.
symptoms: ` ``` $ adb install xyz.apk [100%] /data/local/tmp/xyz.apk pkg: cat ver: /data/local/tmp/xyz.apk Failure [INSTALL_FAILED_INVALID_URI] ``` solution: check if u have allow installation from unknown sources enabled :) [![enter image description here](https://i.stack.imgur.com/1Hoi1.jpg)](https://i.stack.imgur.com/1Hoi1.jpg)
8,739,252
I have tried to serialize data using `XmlSerializer`. I have found very a useful post: [XML Serializable Generic Dictionary](http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx). But in fact I need to put the result of serialization not in file but in a string variable, how can I do this?
2012/01/05
[ "https://Stackoverflow.com/questions/8739252", "https://Stackoverflow.com", "https://Stackoverflow.com/users/879992/" ]
Instead of using some `StreamWriter` which points to file you can use `StringWriter` class. ``` using (StringWriter writer = new StringWriter()) { XmlSerializer serializer = new XmlSerializer(typeof (YourType)); serializer.Serialize(writer, yourObject); } ```
XmlWriter.Create() function has one overload which takes StringBuilder, try using it.
9,676,006
Say I am running IRB and I type this into the console: ``` def full_name(first, last) puts "Your full name is: #{first, ' ', last}" end ``` Say, that I wanted to edit that to include the parameter `middle`, how would I just bring back up that same method and edit the parameter list and edit the `puts` statement without having to retype the entire method? P.S. I know that this example is simple and I could easily just retype the method, but I have much larger methods I am experimenting with and I am using this simple one for brevity. Thanks.
2012/03/12
[ "https://Stackoverflow.com/questions/9676006", "https://Stackoverflow.com", "https://Stackoverflow.com/users/91970/" ]
I don't think you have a lot of options here. What I usually do is to place the code I'm playing with in a file and use `load '/path/to/file.rb'` to reload it whenever I change something. You can also try the [`interactive_editor`](https://github.com/jberkel/interactive_editor) gem which allows you to use a full-blown text editor for text editing inside an IRB session.
Check out the [pry](https://github.com/pry/pry) gem - a great replacement for IRB. This features might be helpful: * `hist` - replaying history of commands * `amend-line` - changing a line in a mulit-line entry They are well documented on the [pry wiki](https://github.com/pry/pry/wiki/User-Input)
41,872,508
I am new in windbg and memory analize in windows. I try analize memory dump (crash dump) it's x64 system. After loading all symbols (my and microsoft) I type `!analyze -v` This is a part of output: ``` ...... FAULTING_SOURCE_CODE: <some code here> SYMBOL_STACK_INDEX: 6 SYMBOL_NAME: rtplogic!CSRTPStack::Finalize+19d FOLLOWUP_NAME: MachineOwner MODULE_NAME: RTPLogic IMAGE_NAME: RTPLogic.dll DEBUG_FLR_IMAGE_TIMESTAMP: 58542837 STACK_COMMAND: ~544s; .ecxr ; kb FAILURE_BUCKET_ID: WRONG_SYMBOLS_c0000374_RTPLogic.dll!CSRTPStack::Finalize BUCKET_ID: X64_APPLICATION_FAULT_WRONG_SYMBOLS_rtplogic!CSRTPStack::Finalize+19d ...... ``` This `WRONG_SYMBOLS` worried me. Can I be sure code in `FAULTING_SOURCE_CODE` it is the code that related to crash?
2017/01/26
[ "https://Stackoverflow.com/questions/41872508", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1864033/" ]
I forgot to specify timezone ``` Instant instant = Instant.from( DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm") .withZone(ZoneId.of("UTC")) .parse("2015-05-08T22:57")); ``` works fine. **UPDATE:** Also I had another problem I used `hh` instead of `HH`.
A more flexible way: ``` var instant = ISO_LOCAL_DATE_TIME.parse("2015-05-08T22:57", LocalDateTime::from) .toInstant(UTC); ```
7,914,243
I save jpeg image using the following C# [EmguCV](http://www.emgu.com/) code: ``` Emgu.CV.Image<Gray, byte> image ... image.Save("imageName.jpg"); ``` But image is stored in extremally low quality (1 color square per 8x8 pixels). When I save bmp all are ok: ``` Emgu.CV.Image<Gray, byte> image ... image.Save("imageName.bmp"); ``` How to increase jpeg quality when using `Emgu.Cv.Image.Save` or should I call other function? Why is default quality so low? Tried to ask on [EmguCV forum](http://www.emgu.com/forum/), but it is unreachable.
2011/10/27
[ "https://Stackoverflow.com/questions/7914243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13441/" ]
Building on Chris's answer if anyone is interested here is a simple extention; ``` using System; using System.Linq; using System.Drawing.Imaging; using Emgu.CV.Structure; public static class EmguImageSave { /// <summary> /// Save a jpeg image with a specified quality /// </summary> /// <param name="path">Name of the file to which to save the image</param> /// <param name="quality">Byte that specifies JPEG Quality of the image encoder</param> public static void Save( this Emgu.CV.Image<Bgr, Byte> img, string filename, double quality ) { var encoderParams = new EncoderParameters( 1 ); encoderParams.Param[0] = new EncoderParameter( System.Drawing.Imaging.Encoder.Quality, (long)quality ); var jpegCodec = (from codec in ImageCodecInfo.GetImageEncoders() where codec.MimeType == "image/jpeg" select codec).Single(); img.Bitmap.Save( filename, jpegCodec, encoderParams ); } } ``` Usage; ``` var fname = 0; while( true ) { try { var img = capture.QueryFrame(); img.Save( String.Format( @"c:\rec\{0}.jpg", ++fname), 100 ); } catch( Exception ) { break; } } ```
Here's how I did with Emgu CV: ``` CvInvoke.Imwrite(path, cvImage, new KeyValuePair<ImwriteFlags, int> (ImwriteFlags.JpegQuality, quality)); ```
66,286,938
Not sure What I am doing wrong here. I am trying to get my bot to only send this message if the user starts typing in the defined channel. I don't get errors the bot just doesn't send a message. Help Please! ``` bot.on("typingStart", (channel, user) => { const bot_channel = "812180709401247658" if (channel.id = bot_channel.id) { message.send('wrong channel'); } }); ``` I have also tried: ``` bot.on("typingStart", (message , channel) => { const bot_channel = "812180709401247658" if (channel.id === bot_channel.id) { message.send('wrong channel'); } }); ```
2021/02/20
[ "https://Stackoverflow.com/questions/66286938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15232183/" ]
A single equals sign `=` is assignment. To perform comparison in JavaScript, use either the double equals sign or the triple equals sign. For most cases of comparison, you *should* use `===`. Your code should look like this then: ```js bot.on("typingStart", (channel, user) => { const bot_channel = "812180709401247658" if (channel.id === bot_channel.id) { message.send('wrong channel'); } }); ```
Use this ``` bot.on("typingStart", (message, channel) => { const channel = "812180709401247658" if (message.channel.id != channel) { return message.channel.send('You can only use this command in <#' + channel + '>'); } }); ``` if it still does not work use this ``` bot.on("message", (message) => { const channel = "812180709401247658" if (message.channel.id != channel) { return message.channel.send('You can only use this command in <#' + channel + '>'); } }); ``` **"!=" means isn't, so if channel isn't the one you selected it will return the message, simple**
8,822,885
I've a stored procedure that does something like this: ``` SELECT Id INTO #temp FROM table WHERE ... DELETE FROM #temp INNER JOIN table2 ON a=b WHERE ... ``` But it's running slowly. When I try to view the Execution Plan I can't since the SQL Server Management Studio says "Msg 208, Level 16, State 0, Line 31 Invalid object name '#temp'." Is there any way to view the execution plan (or the execution details (not the plan)) for such script?
2012/01/11
[ "https://Stackoverflow.com/questions/8822885", "https://Stackoverflow.com", "https://Stackoverflow.com/users/72350/" ]
It should let you see the estimated execution plan for the first statement fine. For the second statement you will need to create and populate the `#temp` table first (population is important so that it shows you the plan that will be used for the correct number of rows). (Or you can of course just turn on the "Include Actual Execution Plan" option in SSMS and run the whole thing if you aren't specifically trying to see the estimated plan)
I simply selected the "select into" clause first and executed it by pressing F5. This created the tmp table. Then I selected rest of the queries and clicked "Display Plan" (or press Ctrl+L).
696,671
> > Prove that if $d$ is a common divisor of $a$ & $b$, then $d=\gcd(a,b)$ if and only if $\gcd(\frac{a}{d},\frac{b}{d})=1$ > > > I know I already posted this question, but I want to know if my proof is valid: So for my preliminary definition work I have: $\frac{a}{d}=k, a=\frac{dk b}{d}=l,b=ld $ so then I wrote a linear combination of the $\gcd(a,b)$, $$ax+by=d$$ and substituted: $$dk(x)+dl(y)=d d(kx+ly)=d kx+ly=1 a/d(x)+b/d(y)=1$$ Is this proof correct? If not, where did I go wrong? Thanks!
2014/03/02
[ "https://math.stackexchange.com/questions/696671", "https://math.stackexchange.com", "https://math.stackexchange.com/users/124877/" ]
An example for Hasse-Minkowski might be worth studying it, i.e., the binary quadratic form $5x^2 + 7y^2 − 13z^2$ has a non-trivial rational root since it has a $p$-adic one for every prime, and obviously also a real root. Another example is the $3$-square theorem of Gauss: A positive integer $n$ is the sum of three squares if and only if $-n$ is not a square in $\mathbb{Q}\_2$, the field of $2$-adic integers.
While this may not be novel with respect to the $p$-adic numbers, one can show that $x^2-2=0$ has no solution in $\mathbb{Q}\_5$, and therefore it follows that $\sqrt{2}$ is not rational. There are of course many other examples of this nature, perhaps one can find some more interesting ones.
17,774,547
The code below would be fine for updating a row field: ``` t = TheForm.objects.get(id=1) t.value = 1 t.save() ``` But what if I need to update 5-6 fields at once? Is there any direct way? Like update `(value=1,value2=2)` **EDIT** I already know that I can do: ``` t.value1 = 1 t.value2 = 1 t.value3 = 1 ``` But I am looking for a single line command like the Insert one for instance. (`TheForm(value1=1,value2=2,value3=3)`)
2013/07/21
[ "https://Stackoverflow.com/questions/17774547", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sure! ``` t.value1 = 1 t.value2 = 2 t.save() ``` Alternatively, ``` TheForm.objects.filter(id=1).update(value=1, value2=2) ``` (And you could use `**kwargs` here)
You can change as many fields as you want before you save. ``` t = TheForm.objects.get(id=1) t.value1 = 1 t.value2 = 2 t.save() ``` You can also use the `update` method: ``` t = TheForm.objects.filter(id=1).update(value1=1,value2=2) ``` Note that using `update` is subtlety different. There wont be an error if the object with `id=1` does not exist. Pre- and post-save signals won't be sent when using `update`.
86,820
A few months ago I bought a Nikon D5500, now I want to buy a 50 mm lens, but I just discovered the meaning of DX on my camera. So on the lens reviews I read that if I buy a 50mm to my D5500 it would act like a 75 mm lens and the recommendations is to buy a 35mm. My question is: If I buy the 50mm what would be the difference, do I have to be farther from the subject or what? If I want to have the 50mm effect do I have to buy the 35mm to simulate 52mm? Thanks for the help.
2017/02/03
[ "https://photo.stackexchange.com/questions/86820", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/60509/" ]
Since your kit lens covers 18-55mm, you can get a very good idea of the difference by taking a set of photos at 35mm and another set at 50mm. The main things you'll be gaining by adding a prime to your kit will be sharpness (although probably not much - the kit lens isn't bad) and the wider aperture. On the assumption that you're trying to decide between a 35mm f/1.8 and a 50mm f/1.8, the wider aperture will be more notable on the 50mm, because the kit lens gets a narrower relative aperture at 50mm than at 35mm. (You can find the values it achieves by using A mode and opening as wide as possible). However, the framing is much more obvious than the differences in depth of field. TL;DR try the two focal lengths with your kit lens and decide which is a higher priority for you.
A thing that you may consider on choosing between these two lenses is that the nikon 35 mm is a dx lens. So I consider investing in 50mm is better, in case that you want to upgrade your camera later. Another opinion from me: If you want to buy secondhand, it is easier to get 50mm than 35mm, and later if you want to sell, I think, that it will be also easier to sell 50mm, since many people shoot with 50mm
73,960
Developing iOS or OSX based applications typically requires knowledge of Objective C, since XCode is highly tailored to this language. Android, on the other hand, has chosen Java as it's preferred language for app development. Now, I know other programming languages can be used to develop applications on either platform, but lets be honest, it's a lot easier (and encouraged) to develop apps using these "native languages." As a new app developer, it seems like it would be much easier if there was a common language and development environment for developing applications on all the major platforms. This thought is probably too idealistic for a programming discussion, and I wouldn't be surprised if the SE vultures flew in to close this topic. But, here's my question. Do you think that language endorsement creates unreasonable barriers to entry for new programmers, or do you think it's beneficial in some way (if so, why) for these platforms to use completely different development environments and languages for app development?
2011/05/05
[ "https://softwareengineering.stackexchange.com/questions/73960", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/24399/" ]
Man, nobody among the big players cares about programmers and their strange notions or fairness and efficiency. Every one of them has been building a walled garden and has done a lot of tricks to make programmers stick to their and only their platform. But as a purely theoretical discussion, yes, it would have benefited if we could target all of the platforms from the same development environment. * It would have minimized development and maintenance efforts if there was a unified development environment * It would have indirectly forced the platforms to support more or less the same functionality accessible in the unified manner which would have simplified life for developers * It would have created a unified user experience if the Windows Phone application looked and behaved identically to the iOS application But then it would have also washed out the boundaries between platforms and took it down to who is able to ship the most densely packed hardware at the lowest cost possible. And they do not want that for sure.
I concur with the general thought of "Don't learn a language, learn to program. Language is just a tool." I'd also contend that having a wider, more diversified ecosystem makes for better programming environments, tools toys and end products in general. It forces all parties to create, adapt and innovate on multiple levels. There is also the problem of getting these industry heavyweights in the same room and getting them to agree on anything without submarining the process.