INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How many subsets of size $n$ in $S=\{x_1,\dots ,x_{2n}\}$ under restrictions > Let $S=\\{x_1,\dots ,x_{2n}\\}$. How many subsets of size $n$ are in $S$ such that $\forall1\le i\le n: x_i$ and $x_{n+i}$ are not in the same set. I ran into this problem when thinking how many distinct clauses are required to calculate all boolean functions $f_i:\\{0,1\\}^n\to\\{0,1\\}$ in CNF form. Obviously, without the said restriction, the answer is ${2n \choose n}$. However, I can't think of a way to count the subsets with the said restriction without double counting. I'd appreciate any help or direction.
Your condition $\forall1\le i\le n: x_i$ and $x_{n+i}$ are not in the same set means exactly one of $x_i$ or $x_{n+i}$ is in the set. Your answer is simply $2^n$, since for every $i$, you choose between $x_i$ and $x_{n+i}$.
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "combinatorics, conjunctive normal form" }
How can I make an if using parsec (Haskell) to verify the input generated by an optional choice? I have this algebraic datatype: data Arithmetic = Sum Int Int | Mult Int Int deriving (Show) And I want to do this: parseArith :: Parser Arithmetic parseArith = do a <- many1 digit spaces string "+" <|> string "*" spaces b <- many1 digit ... Where on the "...", I would verify whether it has a "+" or a "*", can someone help me?
As a slight alternative to Franky's answer, make your choice return the constructor you need later on. parseArith :: Parser Arithmetic parseArith = do a <- many1 digit spaces op <- (string "+" >> return Sum) <|> (string "*" >> return Mult) spaces b <- many1 digit spaces return $ op (read a) (read b)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "haskell, parsec" }
PythonWebkit default directory listing I want to change the default directory listing of the pythonwebkit(the one imported from gi.repository) for an application I am working on. Is there any function/script in webkit that does the job?
**EDIT** The code for styling the default directory listing is in the file net/base/dir_header.html and ends up in `chrome.pak` and `chrome_100_percent.pak`. The python module data_pack.py can work with these files. If you want to filter certain file types from the list, you can probably do that in `addRow()` ~~You will have to useos.chdir() to change the current directory for the whole process. AFAIK, WebKit doesn't keep an internal environment for things like the current folder.~~
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "python, webkit, directory listing" }
Proving that $\lim\limits_{t \rightarrow \infty}B_t/t=0$ a.s. without using the law of iterated logarighm. I want to prove that $\lim\limits_{t \rightarrow \infty}B_t/t=0$ a.s directly, without using the law of iterated logarithm. I have read a hint that one can use the law of large numbers. If I look at the sequence $B_n/n, n\in \mathbb{N}$ I can write it as $$\sum\limits_{i=1}^n\frac{B_i-B_{i-1}}{n},$$ this converges to zero by the strong law of large numbers. So if I write $$\frac{B_t}{t}=\frac{B_{\lfloor t\rfloor}}{\lfloor t \rfloor}\cdot\frac{\lfloor t \rfloor}{t}+\frac{B_t-B_{\lfloor t \rfloor }}{t},$$ I have that the first term converges a.s. to zero. So I only need to show that $$\frac{B_t-B_{\lfloor t \rfloor }}{t}$$ converges a.s. to zero. Do you see how to prove this directly?
We want to show that $\frac{\sup_{s \in [0,1)} \lvert B_{n+s}-B_n\rvert}n$ tends to zero almost surely as $n$ goes to $\infty$. We have that $$ \mathbb P\Big(\sup_{s \in [0,1)} \lvert B_{n+s}-B_n\rvert \geq n^{2/3}\Big) = \mathbb P\Big(\sup_{s \in [0,1)} \lvert B_s\rvert \geq n^{2/3}\Big) \leq 2\mathbb P\Big(\sup_{s \in [0,1)} B_s\geq n^{2/3}\Big) = 2\mathbb P\Big(\lvert B_1 \rvert \geq n^{2/3}\Big) \leq \frac{2 \mathbb E\big[B_1^2\big]}{n^{4/3}}.$$ Borel-Cantelli implies that almost surely there is $\bar n = \bar n(\omega)$ such that for any $n\geq \bar n$ it holds that $\sup_{s \in [0,1)} \lvert B_{n+s}-B_n\rvert \leq n^{2/3}$, and thus $$\frac{\sup_{s \in [0,1)} \lvert B_{n+s}-B_n\rvert}n \leq n^{-1/3}.$$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "probability theory, stochastic processes, brownian motion" }
Cancel mouse highlight on mac Whenever I use vim, sometimes I make a single-touch touchpad on vim screen and it makes a highlight like the picture below. The problem is this I cannot cancel this highlight. right click doesn't work, left click just override highlight to that clicked point again. Only way to get rid of this is to quit vim. Anyone else have this problem? I am currently considering disabling mouse click on vim but i am looking for a better solution. Many thanks in advance ![enter image description here]( ![enter image description here](
You can use `fn` to bypass Mouse Reporting for programs like vim. (i.e. do `fn`+`left-mouse button` to clear the selection.) Source: < (If you are not using a Mac and you are having a similar issue, you can use `ctrl-z` to suspend vim. Once you are done doing whatever, execute the `fg` command to bring vim back up.)
stackexchange-vi
{ "answer_score": 3, "question_score": 1, "tags": "terminal, macos, mouse" }
ParserError: Expected ',' but got 'memory' event studentAdded(string memory _studentFirstName, string memory _studentLastName, uint256 _studentId); from solidity: ParserError: Expected ',' but got 'memory' --> contracts/4.Scorecard.sol:35:31: | 35 | event studentAdded(string memory _studentFirstName, string memory _studentLastName, uint256 _studentId);
you should remove memory from the arguments, this should work: event studentAdded(string _studentFirstName, string _studentLastName, uint256 _studentId);
stackexchange-ethereum
{ "answer_score": 1, "question_score": 0, "tags": "solidity, smart contract wallets" }
Proving that the inverse of 2 is not an integer I have been trying to prove that the inverse of $2$ does not exist in integers, but I did not succeed. I tried to assume negatively that is an integer, but I have refrained from moving on... I am not sure if I can divide because we live in the integers, etc... I would be glad to have your help, thanks.
Let $k \in \mathbb{Z}$ s.t. $2k=1$ then, since $k$ is an integer, we have (integers are the free group over the element $1$) $k=\pm(1+1+...+1)$, where the 1 appears k times and $k\neq 0$. But $1=2k=k+k= \pm(1+1+1+1...+1)=1$. Now since there are at least two $1'$s involved in the second to last equation we get $1+1+...+1=0$ which is a contradiction to the assumption
stackexchange-math
{ "answer_score": 0, "question_score": -1, "tags": "inverse, integers" }
How to resolve "No suitable download server found" when updating? I am a new user to Ubuntu 12.04. I have already connected to the Internet (without any firewall or proxy) and can browse the web. But whenever I am trying to update Ubuntu or trying to select the mirror for my location (Singapore) it just gives this error: > NO SUITABLE DOWNLOAD SERVER FOUND. PLEASE CHECK YOUR INTERNET CONNECTION. What can I do to fix this?
To update by terminal ,open Terminal by ctrl+alt+T Type sudo apt-get update It will ask password, give password. Packages will be automatically updated. To Update by Synaptic open synamptic , Click on reload.... It will show you list of packages that are available in new version. So are newbie to ubuntu, install synaptic by Open Terminal, type `sudo apt-get install synaptic`
stackexchange-askubuntu
{ "answer_score": 0, "question_score": 2, "tags": "updates, mirrors" }
Where I can ask questions regarding Samsung mobile phone software? I tried using SuperUser but, as you know, they close such questions. Where can I seek help on such a matter? I need some utility software, like Ultramp3, for Samsung mobile phones.
You could try the Darkforest Group forums
stackexchange-meta
{ "answer_score": 1, "question_score": -3, "tags": "support, site recommendation" }
WinForm C#: Datagridview combobox it is duplicating records from second line The datagridview combobox is duplicating the values ​​from the second line. How can I solve this. Thanks image Code: void ListagemNoCombobox() { //Populando o combobox do criterio string[] criterios = { "Sem Critério", "3ª Série do Ensino Médio ", "2ª Série do Ensino Médio ", "1ª Série do Ensino Médio " }; foreach (string crit in criterios) { cmbCriterio.Items.Add(crit); } }
void ListagemNoCombobox() { cmbCriterio.Items.Clear(); //Populando o combobox do criterio string[] criterios = { "Sem Critério", "3ª Série do Ensino Médio ", "2ª Série do Ensino Médio ", "1ª Série do Ensino Médio " }; foreach (string crit in criterios) { cmbCriterio.Items.Add(crit); } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "c#, winforms, datagridview, combobox, devexpress" }
How to get smoother background size animations? I have the following code:- JSFIDDLE HERE **HTML** <div id="wrapper"> <span id="pb-stars"></span> </div> **CSS** #wrapper { height: 1000px; width: 100%; background: #000000; } #pb-stars { background: url( background-position: center; background-size: 40%; width: 100%; height: 1075px; position: absolute; display: block; top: 0; z-index: 0; } **jQuery** jQuery('#pb-stars').animate({ 'background-size': '110%' }, 28000); The problem I have is that the animation is a bit 'jerky', is there any way to get this animation running any smoother?
Set the easing to 'linear' like so: JSFIDDLE jQuery('#pb-stars').animate({ 'background-size': '110%' }, 28000, 'linear');
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "jquery, css, animation" }
What is a thread safe way to throw an error while using Rcpp I am using `RcppThread` for parallelism in an `Rcpp` function. What is the preferred way to throw an error in the middle of a parallel loop? R's API is single threaded, so I assume `Rcpp::stop()` is not thread safe. `RcppThread` provides means for thread safe `cout` and `CheckUserInterrupt` but not, so far as I can tell, a thread safe `stop`. An example of what I'm trying to do: #include <RcppThread.h> // [[Rcpp::plugins(cpp11)]] // [[Rcpp::depends(RcppThread)]] void myfun() { // parallel loop RcppThread::parallelFor(0, 100, [](int j){ // do something that causes an error Rcpp::stop("Is this error unsafe?"); }); }
Probably not -- The simple and often repeated rule stated eg in the RcppParallel documentation is that _no contact whatsoever_ should be made from multithreaded code back into to R, or with R-created/owned memory. From the top of my head, I would just * break from the parallel loop * assign the error condition or text to a string * once back in single-threaded code call `Rcpp::stop(thattext)`
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "multithreading, rcpp" }
Computation with a transformation of a random variable. The random variable $X$ is uniformly distributed on the interval $[-4,4]$. Compute $P(X^2 ≤ 9)$. I tried to define $Y = X^2$ and compute the density of this transformed variable. The PDF of the uniform distribution is $f_x(x) = \frac{1}{8}$. What I got as a transformed density is $f_y(y) = \frac{1}{16\sqrt(y)}$. However, if I calculate the integral of that transformed density from $0$ to $9$, I get a wrong result. My guess is that it has something to do with the fact that the uniform can take negative values.
Hint: $$ P(X^2<9)=P(-3<X<3)=\int_{-3}^{3}f(x)\,dx $$ where $f$ is the density function for $X$. Now what you need is to find the correct density function for $X$ and then integrate it. * * * Notes. It is fairly easy the see by intuitions of "uniform distribution" that $$ P(-3<X<3)=\frac{\textrm{length of the interval }[-3,3]}{\textrm{length of the interval}[-4,4]}=\frac34 $$
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "probability, probability distributions, uniform distribution, density function" }
Searching a template for thesis APA I've been looking online for several hours and I have not found a template in APA thesis in Latex. I wonder if you have any template you can share me, or any idea of where to look. Here I have a Template in Microsoft Word that can be used as a guide for comparison. Thanks in advance.
I started using this template available from Overleaf.
stackexchange-tex
{ "answer_score": 2, "question_score": 2, "tags": "templates, apa style" }
Entropy of Order Statistic Consider $n$ independent and identically distributed random variables $ \\{X_i\\}_{i=1,...n} $ with support on some interval $[a,b]$ and its $n$'th order statistic $\max_{i \in \\{1,...n\\}} X_i$ . The entropy of the maximum is $$ - \int_a^b F^n(x) \ln F^n(x) dx ,$$ where $F(x)= \Pr (X \le x) $. It seems natural that the entropy should be decreasing in $n$ (just think about $n$ very large). Is this a known result? I did in fact prove that the entropy is monotone, but the proof turned out to be lengthy and messy. I would expect that there is a simple argument. Does anyone know?
No, the entropy is not monotone. For example, consider $F_X(x) = x^{1/N}$ on $[0,1]$. Then $\max(X_1,\ldots,X_N)$ is uniform on $[0,1]$. The entropy of $\max(X_1,\ldots,X_n)$ increases as a function of $n$ for $1 \le n \le N$, reaching $0$ at $n=N$, then decreases after that.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "probability distributions, entropy" }
d3js , enterprise counterpart - for .NET? Are there any Microsoft products similar to d3.js ? A visualization tool for data, which can be used in a .NET framework ? Is it possible to customize ms business intelligence software ?
.net has a built in charting library chart controls on msdn But from what I understand it's not really like d3 in the sense that it's a selection of built in controls not necessarily like d3 for building bespoke visualisations. Scott Hannlseman has a blog post discussing ILNumerics which looks more like a toolkit for building visualisations. Regarding general charting libraries there are lots and lots, but seeing as you're looking for d3.js counterparts I'm guessing you're looking for bespoke visualisations.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": ".net, data binding, d3.js, data visualization" }
Determinant of complex matrix from real and complex parts Is is possible to find the absolute value of the determinant of a complex matrix M, given two real matrices A & B of the same dimension of M; where for N = 2, M would be: $\begin{matrix} a_{00} + i*b_{00} & a_{01} + i*b_{01} \\\ a_{10} + i*b_{10} & a_{11} + i*b_{11} \end{matrix}$? I.e. using just the real numbers and determinants of A & B is there any known relation that can get me the absolute value of the complex determinant from M? Thanks!
$A$ and $B$ can be any matrix, really. Your question is somehow equivalent to; _is there a shorter formula for $\det (A+B)$ where $A, B \in \mathcal{M_n}(\mathbb{R})$_ ? Since the determinant application is _only_ a group homomorphism from the general linear group of degree $n$ to $(\mathbb{R}^*, \times)$, meaning $\det(AB) = (\det A)( \det B)$ and $\det(A^{-1}) = (\det A)^{-1}$, **there is no general formula for the determinant of the sum of two matrices**.
stackexchange-math
{ "answer_score": 4, "question_score": 0, "tags": "linear algebra, complex analysis, determinant" }
Microprocessor vs. web page communication? I'm currently working on a project where I want to control a microprocessor (Arduino) from a web page. The microprocessor will not be connected physically to the computer. * What is the best protocol for communication? (My current choice is TCP). * What is the best way to serialize the objects to be sent? (My current choice is JSON). The server side is written in NodeJs. Since I'm new to this kind of development I would very much appreciate any input on the topic!
Without details about which arduino you plan on using and what shields you might employ to achieve the interface it is hard to make a definite statement. I would argue that with the proper shield to provide the ethernet interface TCP would be an acceptable choice. I am inclined to say you are going to be hard pressed to build a JSON interpreter that fits into the memory foot print of an Arudino. Most of these devices have 32K of program memory, and 1 or 2K of data memory. For embedded devices like this a concise binary protocol on the wire is far more common and easier to fit into the device's limitations.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "json, tcp, arduino, microprocessors" }
How to calculate multiplication of two numbers recursively I was reading about recursion in Java. I found this example in my course page for calculating the multiplication of two numbers recursively : public class bst { public static void main(String[] args) { bst b = new bst(); b.mult(2, 4); System.out.println(b.mult(2, 4)); } public static int mult(int a, int b) { if (b == 0) { return 0; } else { return a + mult(a, b - 1); } } } I used debug to see how it works but I still do not understand how it works to calculate `2*4 = 8`.
This is how it loops through calls. Mind the step numbers and indentations: 1. starts with 2,4 2. goes into else, returns 2 + <starts again> 3. starts with 2,3 4. goes into else, returns 2 + <starts again> 5. starts with 2,2 6. goes into else, returns 2 + <starts again> 7. starts with 2,1 8. goes into else, returns 2 + <starts again> 9. starts with 2,0 10. goes into if, returns 0 to step 8 11. goes to step 8, returns 2 + 0 (=2) to step 6 12. goes to step 6, returns 2 + 2 (=4) to step 4 13. goes to step 4, returns 2 + 4 (=6) to step 2 14. goes to step 2, returns 2 + 6 (=8) to the main call
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "java, recursion" }
what is the between in writing a loop by branching statement and a normal loop what is the between in writing a loop by branching jump statement and a normal loop i.e for example main() { int i=0; while(i<9) { //do something i++; } and main() { int i=0; label: //do something i++; if(i<9) goto label; } is the performance of both of them are equal?
These two loops are not equivalent: the second one is similar to a `do`/`while` loop, not a `while` loop: main() { int i=0; do { //do something i++; } while(i<9); } The two should be the same as far as the performance goes; however, the readability of the solution with the `goto` suffers considerably, so I would refrain from using it in any of your projects.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 2, "tags": "c++, loops" }
My android app should suspend activity when not on screen An android app that I'm writing seems to consume a lot of battery even when it's not the foreground application. My assumption is that I need to unregister the listeners for gps, orientation, etc., when the application is not in the foreground. The thing is, I have a variety of different activities that I switch between and I don't want the listeners to be unregistered as long as I'm switching between them. However, if the user holds down home and switches to another app (or if a phonecall happens or whatever) I want my app to stop doing anything at all. All the on* methods of an activity are specific to that activity. How do I listen for switching away from my application entirely?
> My assumption is that I need to unregister the listeners for gps, orientation, etc., when the application is not in the foreground. Correct. > The thing is, I have a variety of different activities that I switch between and I don't want the listeners to be unregistered as long as I'm switching between them. Sure you do. Each activity must stand alone, not making any assumptions about any other activity that is (or is not) around. You are welcome to move this stuff to a service, bound to by each of your activities, if you prefer. > How do I listen for switching away from my application entirely? There is no such concept in Android.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "android, android activity, halt" }
How should I ventilate an air-tight concrete room? My house has an unused cistern that abuts the foundation. I've cut a doorway into it from my basement and would like to use it as living space. I would like to install a door to obscure and soundproof the room, but that would cut off the only source of air to this air-tight space. I can install a vent by drilling through the basement wall at another location, but I am wondering **how can I safely ventilate the 600 ft³ room so that several people can sit in it for hours at a time**. I would prefer a smaller hole, which will I imagine will require an fan as opposed to just a hole. Does this mean I would also need a second hole to return air, or could enough air escape around the door?
A 4 inch diameter hole with a good fan might be sufficient to move air from the basement into this room under the use you describe. The space under the door might be sufficient to allow the air back into the basement. Is the roof of this cistern room exposed on the surface, and, if so, is it shaded from the sun?
stackexchange-diy
{ "answer_score": 2, "question_score": 0, "tags": "air quality" }
HttpWebRequest with p12 cert + password I need to be authentificated with p12 cert (with password) + cookie. Here is my code : X509Certificate2 certificate = new X509Certificate2(); byte[] rawCertificateData = File.ReadAllBytes(@"C:\mycert.p12"); certificate.Import(rawCertificateData, "c3rtifPassw0rd", X509KeyStorageFlags.PersistKeySet); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(" request.ClientCertificates.Add(certificate); request.CookieContainer = new CookieContainer(); request.CookieContainer.Add(new Cookie("apicookie", "myCookieString") { Domain = "apidomain.com" }); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (var reader = new System.IO.StreamReader(response.GetResponseStream(), ASCIIEncoding.ASCII)) { result = reader.ReadToEnd(); } return result; The server returns a 400 error.
(I don't have enough reputation to answer through a comment) Based on my experience using webrequest, some servers reject non-standard requests; I mean, first, you need to be sure that you set all headers properly for the http request (user-agent, referer, language, etc.). Then, ensure that you use .NET framework 4.5 or higher, since older versions have problems managing some certificates.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, .net, httpwebrequest" }
Google places api autoComplete not showing dropdown I have a simple grails application which has a form. For a requirement, i'm adding cities, state to an input field. I'm using Google places api to autocomplete the input field. The code in my gsp is as follows. <label for="city"> <input id="city" name="city"> </label> <script src=" <script> $( "#city" ).autocomplete({ source: function( request, response ) { var input = document.getElementById('city'); var autoComplete= new google.maps.places.Autocomplete(input); }, minLength: 3 } ); </script> When I execute this, nothing happens. No drop down comes up. Am i missing something? i'm quite new to this API Thanks in Advance
Well you don't need to write `autocomplete` by yourself google map will take care of it. So remove your `autocomplete` code and add just below code <script> var input = document.getElementById('city'); var searchBox = new google.maps.places.SearchBox(input); </script>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, google maps, google maps api 3, google places api" }
New to MVVM: how to workout the View I've just got 3 classes: Topic, Example and Exercise. Topic is the main class where both Example and Exercise is linked to. In my window (non-MVVM) I am populating a listbox with my topics, and upon selecting an item in the listbox where the topics are bound to, I am getting the ID of that topic and again populating 2 listboxes (for examples and exercises) related to that topic. As I am new to MVVM and still trying to understand it, I am at lost on how to convert this to MVVM. Should I have 3 views (3 usercontrols?) for each 3 classes (models)? In my current setting they are all in 1 window.
This is entirely up to you. How do you normally split state and behavior across classes? There is no 'extra' rule for that in MVVM. Think of reuse and single responsibility. This is applicable for View, ViewModel and Model classes. It is possible to compose a View, ViewModel and Model out of multiple classes. One thing I learned is that although it is possible to reuse a ViewModel for multiple Views (in fact some introductions to MVVM state that as benefit) I found that in general Views tend to change after a couple of releases and you'll quickly need to create a separate ViewModel for each View. Again, this is not a requirement of MVVM; it is good old object orientation.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "wpf, mvvm" }
Voicing as lenition Why is voicing considered lenition under phonological criteria? To me voiced consonants seem stronger in articulation, therefore voicing should be considered fortification.
It's not based so much in what _feels_ stronger, but on the overall patterns of sound changes. There is a tendency for voiceless consonants to become voiced, and voiced consonants to become continuants or approximants. Sometimes these changes are found in succession; for example, as late Latin developed into Spanish, the voiceless plosives p, t and k were first voiced (b, d, g) and later fricativized (β̞, ð̞, ɣ̞) (See here). These changes can all be seen as increases in sonorization. Voiceless plosives have the least amount of voicing, and are thus the least "vowel-like" of consonants. As we go from voiced plosives to fricatives, then approximants and finally vowels, each type is more vowel-like. We interpret vowels as weak, so any sound change to moving closer to vowels is interpreted this way, and called lenition.
stackexchange-linguistics
{ "answer_score": 7, "question_score": 2, "tags": "phonology, sound change" }
Describe a $3$-dimensional solid whose symmetry group is isomorphic to $D_5$ Describe a $3$-dimensional solid whose symmetry group is isomorphic to $D_5$. Would a pentagonal frustum satisfy this? I can't think of any other rotations or reflections that could exist for this shape, or any other shape that would satisfy this.
Yes, a (regular) pentagonal frustum would satisfy this. Since the two pentagonal faces of the frustum do not have the same size, any element of the symmetric group must preserve these faces. Hence the symmetric group is, "at most", the symmetric group of a pentagon, which is $D_5$. Since all five rotations and five reflections preserve the frustum, we are done. Another choice of solid with symmetric group $D_5$ would be a regular pentagonal pyramid.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "abstract algebra" }
90s novel, man reincarnates several times at a specific date and time after a heart attack, studies his condition with a woman who also experiences it In the late '90's I read a book where the main character would constantly reincarnate and have a life 'do over' until an inevitable heart attack that would always occur at the same date and time. Each life would start a little later (he would re-inhabit his body at a slightly later stage). He meets a woman who is having the same experiences as him, and they have a relationship that spans lifetimes. Each new iteration of their lives they look for each other, sometimes having to wait until the other person reincarnates before continuing on their research into their condition again.
This is _Replay_ by Ken Grimwood). Exactly as you recall, the novel starts with the protagonist "dying" of a massive heart attack -- and waking up as his much younger self. He finds the woman by virtue of seeing a huge blockbuster movie in 1974 that didn't exist in his previous lives, _Starsea_ , produced by George Lucas and directed by Stephen Spielberg, both complete unknowns at that early date. On another iteration, they attempt to go public, and are taken into government custody, an attempt by the government to control the future (at least up until their death date in 1988).
stackexchange-scifi
{ "answer_score": 16, "question_score": 9, "tags": "story identification, novel, reincarnation" }
How qmake set .dll and .lib file output path respectively I'm a beginner of using qmake to create a project. So how can I set the output of .lib and .dll file respectively when a library project? I think is necessery that I can link the .lib file in other project from a path,and use the .dll file when executing in another path. I have used cmake, it's possible. So I think qmake too. But I can't find the method in document, anyone knows?
Try setting DESTDIR in your qmake file.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "qt, qmake" }
Meaning of !pip when executing Python? I've seen an example of installing via pip that uses syntax I've never seen before: `!pip`: !pip install -q tf-nightly I've Googled around but the ! makes it difficult to narrow down on, what's the ! for compared with the `pip install`?
It is used in `jupyter notebooks` inside code cells. It tells jupyter environment to execute BASH command instead of Python (or other kernel you have chosen). So, this command is simply equivalent to CLI's: $ pip install You can use other UNIX commands from within jupyter notebook like `!ls` or `!pwd`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "python, pip" }
What is the merit of introducing static methods in interface over introducing final methods(if there was one) in java 8? I read from some source as 'Java interface static method helps us in providing security by not allowing implementation classes to override them'.(We can hide them though!) Even final methods can not be overridden. My doubt is 'why did not Java introduce final methods instead of static methods?' . What is that static methods offering over final methods? Thanks
Static methods are invoked using the interface name and can be hidden in derived classes. Final methods are a class specific construct (so far) and cannot be hidden or overridden. They are invoked using an instance name. If you define a method in an interface as final and not static, how would you invoke it? By definition, you cannot create an instance of the interface? See Brian Goetz's comment [here][2] And see this for reason to add static and default methods.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java" }
How do I get AWS Client VPN to resolve DNS using VPC-peered Private Hosted Zone I have a VPC in my AWS account peered to a VPC of a partners account. The partner account has Route 53 resolvers to resolve DNS within domain.com to IPs in their peered VPC. I've associated my VPC with their private hosted zone. Within my VPC (for example SSH into an EC2 instance), the DNS resolution for foo.bar.domain.com works great - I'm resolving & connecting to the resources in their VPC as expected. However, when I'm running and AWS client VPN on my personal machine, I'm unable to resolve the foo.bar.domain.com to the same private IP address through the VPN. So, for example, running a development server on my machine connected to the partner VPC URLs is failing. I've tried hosting a DNS server in the VPC with a zone forwarding rule pointing to the Route 53 IPs. I've tried setting the VPN DNS server IP to the Route 53 IPs. But none of that has worked. Help would be appreciated?
The answer was simpler than I thought: I just had to set the DNS server in the AWS Client VPN Endpoint settings to be the private IP address of my VPC's DNS (which is always the VPC's CIDR +2). From the AWS docs: > If you're unsure about which IP address to specify for the DNS servers, specify the VPC DNS resolver at the .2 IP address in your VPC. Client VPN Endpoints > Modify Client VPN Endpoint > Other optional parameters -> Enable DNS Servers -> IP Address
stackexchange-stackoverflow
{ "answer_score": 24, "question_score": 13, "tags": "amazon web services, dns, amazon route53, amazon vpc" }
Web authentication to external resources I am in the process of creating a web portal for my users, they can currently log in and thats it. I need to connect to a REST API with oauth2 to pull through some data for them to see but I don't want my authentication credentials to be exposed. Is the only way to achieve this to use a server side application? If so/not what strategies should I be looking at to achieve this? Thanks.
The 3rd party service requires an OAuth2 secret, and you need to send it over the wire somehow. If you don't want this secret exposed, you can't do it from the browser, this only leaves server-side options.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "rest, authentication, oauth, oauth 2.0, portal" }
How to sort by count with postgresql? I have two tables: Companies: (id, name, city) Workers: (id, name) I would like to get all companies and sort them by numbers of employes. The result should give: count | company id | company name | city ------------------------------------------ 90 6 foo corp NY 45 9 bar corp LA 0 3 foobar corp HO I tried: select c.*, count(w.id) as c from companies c left join workers w on c.id = w.company_id group by c.id order by c desc; But that's not working as it tells me to group by g.name too :/ Any ideas?
You've aliased the table and column as the same thing, so don't do that. It's not invalid, just tough to follow. Anyway, include all columns that you're selecting that aren't aggregates in your `group by`: select count(w.id) as mycount, w.company_id, c.company_name, c.city from companies c left join workers w on c.id=w.company_id group by w.company_id, c.company_name, c.city order by mycount desc;
stackexchange-stackoverflow
{ "answer_score": 39, "question_score": 31, "tags": "sql, postgresql, join, count" }
How do I link a headervaluerouter to input channel? I have created a headervaluerouter bean @Bean public HeaderValueRouter router (){ HeaderValueRouter router = new HeaderValueRouter("received"); router.setChannelMapping("response","replyCh"); router.setChannelMapping("request","requestCh"); //router.setManagedName(); return router; } But router has no way to set the input channel ?
The router is `MessageHandler` implementation. And it's responsibility is just to handle message. The input channel is a part of consumer endpoint logic. For that purpose you can mark this router bean with the `@ServiceActivator` or just `@Router`. You can find more info in the Reference Manual: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "spring, spring integration, integration" }
AND operator in regular expression? Given a string, how do I express that a pattern must match multiple regex using the AND operator? For example, I want a password to be a minimum of 5 characters AND maximum of 12 characters. * Regex for mimimum 5 characters: `.{5,}` * Regex for maximum 12 characters: `.{12}` I know I can combine the above two to something like this: `.{5,12}`, but this is not what I am trying to achieve. I want to "and" the two regexes.
Well 99% of the time, you would either want to combine them in the parent language, eg. if (Regex.Match(input,pattern1) && Regex.Match(input,pattern2)) { //do work } or improve the regex to combine them, eg. .{5,12} If you really want to combine within a single regex, you can use look ahead assertions, something like this, but the actual matched value will not be what you might expect. ^(?=.{5,})(?=.{0,12})
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "regex" }
How to save image file, using "xfce4-screenshooter -r -c" command? I using `xfce4-screenshooter -r -c` command for make a screenshot. `xfce4-screenshooter --help` says: > **-c, --clipboard** Copy the screenshot to the clipboard > > **-r, --region** Select a region to be captured by clicking a point of the screen without releasing the mouse button, dragging your mouse to the other corner of the region, and releasing the mouse button. Ok. How to save screenshot to the file.png from clipboard? What's tool can helps me?
I've solved the problem so: I using `xclip` for work with my clipboard apt install xclip I typed: xclip -selection clipboard -t image/png -o > /home/user/image.png ...and image file from clipboard (xfce4-screenshooter -r -c) has been created on my user folder. Hope it helps somebody!
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "terminal, image processing, xfce4" }
How can one show that these groups are isomorphic I am working on this problem saying: $$ \text{Inn}(D_8)\cong\text{Inn}(Q_8) $$ I really don't know where can I attack this problem. Thank you $D_8$ is dihedral group and $Q_8$ is quaternon group, both of order 8.
The inner automorphisms of any group are simply $G/Z(G)$ since the conjugation map coming from any element in the center is trivial. The centers of $D_8$ and $Q_8$ are both isomorphic to $Z/2$. In the case of $D_8$, the center is generated by the rotation by 180 degrees. In $Q_8$, the center is simply $\\{1,-1\\}$. It is now not difficult to show that in either case, $Inn(D_8) \cong Z/2 \oplus Z/2 \cong Inn(Q_8)$.
stackexchange-math
{ "answer_score": 4, "question_score": 2, "tags": "group theory" }
Use a model to create an object in a component I'm in Ember 3.4 I can create an EmberObject with let course = EmberObject.extend({ duration: null, level: null }); course.create({ duration: '7', level: 'medium' }); But I already have a model for courses, defined in `'app/models/course.js'`. I wonder if I can "import" the model in the component and use it to create the object.
yeah, you can call extend / create on any ember object. Though, if you're wanting ember-data to be aware of the model, you may want to inject the store via a service. like this: import Component from '@ember/component'; import { service } from '@ember-decorators/service'; export default class extends Component { @service store; async someFunction() { const course = this.store.createRecord('course', { duration: '7', level: 'medium' }); // maybe other logic await course.save(); } } To import anything from models' import ModelName from 'appname/app/models/model-file';
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ember.js" }
In a textbox, protect the first words, but allow adding/editing to text past those words So I have a textbox in C# (Using .NET forms) where I am going to accept a users string for some input. This string already has text (arguments) at the beginning that will exist at the beginning of the string no matter what. It must be there. I want them to be aware of this, but not be able to delete the words from the textbox (so they wont think theyve deleted it already when its going to be there anyways) So these first arguments must not be able to be deleted or edited. Any text after these arguments can be added or modified freely as normal. Is this possible in C#?
Assuming WinForms, you can use a RichTextBox control instead. Set the `Multiline=False` property and here is an example to lock the first characters: richTextBox1.Text = "LOCKED"; richTextBox1.SelectAll(); richTextBox1.SelectionProtected = true; or this, which will only lock the first six characters "LOCKED", but allow the user to change the rest of the sentence: richTextBox1.Text = "LOCKED information"; richTextBox1.Select(0, 6); richTextBox1.SelectionProtected = true;
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "c#, .net, winforms, textbox, protected" }
PHP preg_split() if it is NOT a number, + sign, bracket, new line or tab I have the following operation which splits a string whenever it encounters an alphabet: $splitOriginal = preg_split("/[a-zA-Z]/", implode('', array_slice($array, $key)), 2); I want to extend it in such a way that it splits the string whenever the variable encountered is NOT a number, bracket, plus sign, hyphen, newline or tab. I have written a regex which can match the above: preg_match('/^(?=.*[0-9])[- +()0-9\r\n\t]+$/', $value) But I need to negate it, to match whenever the value being compared is NOT it. Would really appreciate any prompt help I can get. Thank you.
The `[a-zA-Z]` pattern matches any ASCII letter. Any char " _NOT a number, bracket, plus sign, hyphen, newline or tab_ " can also be a letter, so you should focus on the latter requirement, your former pattern is no longer relevant. You should keep using `preg_split`: $splitOriginal = preg_split('/[^\d()+\n\t-]/', implode('', array_slice($array, $key)), 2); The `[^\d()+\n\t-]` pattern matches exactly what you formulated. Pay attention at the hyphen, when it is at the end (or start) of the character class, it can go unescaped.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "php, regex, regex negation, regex look ahead" }
Running(Deploying) app extensions without containing app I have written an today extension for the notification center and I would like to deploy and run the app extension without the containing app. Is that possible?
You can not deploy Extension without containing Application, so you have to deploy your container application to deploy Today Extension. You can read in detail for Today Extension from this Apple link : Today Widget
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "objective c, macos, ios app extension" }
How do I keep the angle of a body in pybox2d between -pi and pi? In the pybox2d manual it states the following: > pybox2d uses radians for angles. The body rotation is stored in radians and may grow unbounded. Consider normalizing the angle of your bodies if the magnitude of the angle becomes too large (use b2Body.SetAngle). However, when I try to implement something to 'normalize' the angle I get the following error: AttributeError: 'b2Body' object has no attribute 'SetAngle' Code snippet: def update_outputs(self): # This is necessary to prevent the angle # from getting too large or small self.body.SetAngle(self.body.angle % 2*pi)
Looks like the library has been pythonized since those docs were written. angle is a property of Body: @angle.setter def angle(self, angle): self._xf.angle=angle self._transform_updated() You should be able to simply set it with something like: def update_outputs(self): # This is necessary to prevent the angle # from getting too large or small self.body.angle %= 2*pi
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, box2d, physics" }
Show igraph plots in Google Colab I am trying to plot `igraph` plots in Google Colab and cannot get it to work. I am using the following code to plot a graph: fg = Graph.Full(n=40, directed=False, loops=False) plot(fg).show() At first I got this error `"NotImplementedError: showing plots is not implemented on this platform: Linux"` but I was able to get around it by configuring the image viewer using the following: from igraph import Configuration cfg = Configuration.instance() cfg['apps.image_viewer'] = "eog" This removed the error but still, no image is being displayed. Removing the `show()` statement to have it displayed inline does not work either. Is there a way to plot igraph graphs in Google Colab or is it simply not compatible? Thank you for your help.
The `.show()` method is deprecated, and will be removed in a future version. Do not use it. See the docstring for more information. Simply use `plot(g)`. * * * You can install igraph on Google Colab using !pip install igraph To use plotting, you have two options. With the Cairo backend: Install `pycairo`, !apt install libcairo2-dev !pip install pycairo import igraph as ig g = ig.Graph.Erdos_Renyi(n=100, m=200) ig.plot(g) With the experimental matplotlib backend (not yet feature-complete): import matplotlib.pyplot as plt fig, ax = plt.subplots() ig.plot(g, target=ax) Or shorter: ig.plot(g, target=plt.axes()) ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, google colaboratory, igraph" }
Mongoose / Mongodb migration to MySQL I have a NodeJS project running with mongodb database (using mongoose). For a technological constraint reason I need to migrate the app from using mongodb to mysql - is there a way to migrate to mysql without having to rewrite the whole mongoose model files? PS. although I'm using mongodb all the query is mainly still not on the nested document (I'm querying only by ID or by some first-level attribute) so actually putting nested document into a field in mysql table should still be fine
I would suggest letting your application run with Mongo for now. Meanwhile write a wrapper for MySQL that would translate your Mongo queries to mysql. Switch to that wrapper once done. Then write another wrapper for Mongo, just in case you need to switch back. Try and keep all your Database specific function calls in the wrapper. So, that you won't need to do this again and again. Just write a new wrapper for whatever Database you will use and just switch. And you'll probably need to run some sort of job to migrate your data from Mongo to MySQL.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "mysql, node.js, mongodb, mongoose, database migration" }
Can we install both version Mule AnyPoint Studio July 2014 and June 2015 Release in same PC without any conflicts? I have a small query generally. I'm working on the studio July 2015 release with 3.5.1 runTime for my client Project. However I'm willing to install AnyPoint June 2015 with runtime 3.7 release for my POC purpose. Does it conflict each by any chance (or override while installing). I don't want to override or update July 2015( It should not be disturbed in any ways) with new since my project running on it. If I want to install the June 2015 what all the step need to take care? or don't require any? . Please advice.
There should be no problem installing several versions of Anypoint Studio as there is no problem in installing several versions of Eclipse on the same machine. Just install the different versions in different directories. You should also be able to use the same workspace across versions, with potential weird effects if incompatible features are used in projects opened with the two versions (which is not what you'll do, so you should be fine).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "mule, mule studio, mule component, mule el" }
How to prevent recreating activity which has AsyncTask and Service in it? Let's assume I have 2 activities: Activity 1, Activity 2. I am starting Activity 2 from Activity 1. Activity 2 - is activity with image and progress bar to display the progress of executing some background task in it which is started in service. When I try to press hardware Back button from Activity 2 it brings me back to Activity 1, so I can start Activity 2 again even if there is service still running. So the question is such: How can I prevent such behaviour. I need to start Activity 2 only 1 time and not exit from it while the work is not finished?? And another case is that I can stop my application from Task manager, but service will be working and after that I can run application again - with new service, while old will be still running? What mechanisms are there to prevent such behaviour? Thanks. !enter image description here
You can bind to a local service from your `Activity` class when it is starting up. Once bound, your `Activity` can call any public methods declared by that service. This would allow your `Activity` to bind to the service, then check to see if the service is currently doing any work. You might make a method like `isRunning()` or similar. If the service is not currently doing any work, you might want to start a new job. If it is already executing some task, you could then display the current progress of that task. You should read the Local Service Sample article on the Android developer site to get an idea how to do this.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android, android intent, android service" }
groovy map populate with default element Is there more Groovish way of adding an element to map of lists and initialize default list if not exists? Or in other words what would be a Groovish way to code the below: def mylist = [1,2,3,4] def mymap = [:] for (num in mylist){ if (num % 2 == 0){ pairity = "even" } else { pairity = "odd" } if (mymap.containsKey(pairity)){ println("Adding to Even") mymap[pairity].add(num) } else { println("adding to Odd") mymap[pairity] = [num] } } print(mymap.toString()) // adding to Odd // adding to Odd // Adding to Even // Adding to Even // [odd:[1, 3], even:[2, 4]]
You can use withDefault) on a map to have automatically generate a value for a missing key on access. [1,2,3,4].inject([:].withDefault{[]}){ m, i -> m[ i%2==0 ? 'odd' : 'even' ] << i; m } // => [even:[1, 3], odd:[2, 4]]
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "groovy" }
python removing blank lines and unwanted spaces I am a newbie to python.I have a text file consisting of lots of blank lines.I need to remove these blank lines such that the existing lines will not be added/combines among each other. text file I am new to python Python is a good programming language Expected output: I am new to python Python is a good programming language And my lines starts from second/nth line.I wanted to begin it from first line.Please help !Answers will be appreciated!
with open("in.txt" ) as f: # use with to close your files automatically lines = [line for line in f.read().split("\n") if line] # split on newline and remove "" using if x for line in lines: print line I am new to python Python is a good programming language
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "python" }
Are there any libraries that bring CS4 Actionscript to Flash CS3? Are there any custom libraries available that allow me to code/publish in CS3 using some of the features of CS4? EDIT: I say "some", because I understand that it is obviously nearly impossible to reimplememnt CS4 in CS3.
There is no difference between CS3 and CS4 in terms of code. You just need to target the current Flash Player 10 platform in your publish settings. They are both using the same Actionscript 3 libraries. You can't load a CS4 project in CS3, but you can save your project to be CS3 compatible inside of flash CS4. Oh, my bad. It's true CS3 can not compile for the Flash 10 platform. Therefore, no. There is no library, because the changes all require the new benefits of the Flash Player 10. You can however use flex to compile your code. This will however require you to convert your code to flex.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "actionscript 3, actionscript, flash cs4, flash cs3" }
Chern class computation of push forward. I am looking at the section of chern class computation from Robert Friedman- Algebraic surfaces and holomorphic vector bundles. If $X$ is smooth quasi-projective variety, $Z$ is a reduced, irreducible subvariety of codimension $r$ in $X$. $j:Z\hookrightarrow X$ denote inclusion map. Then $$c_i(j_* O_Z)=0 \textrm{ for } i<r \textrm{ and } c_r(j_* O_Z)=(-1)^{r-1}(r-1)![Z]$$ where $[Z]$ is the cycle associated to $Z$. Similary, if $V$ is a vector bundle on rank $n$ on $Z$, then $$c_i(j_* V)=0 \textrm{ for } i<r \textrm{ and } c_r(j_* V)=(-1)^{r-1}(r-1)!n[Z].$$ This is statement given in the book. What about higher chern classes? Can we say if $c_{i}(j_*O_X)=c_{i}(j_*V)=0$ for $i>r$. Is this true?
The classes will in general be nonzero. You can check this in the simple case where $Z$ is a global complete intersection (say of codimension two), since then you can write down an explicit resolution for $O_Z$. A general formula (in the codimension two case) can be found in Fulton, "Intersection Theory", Example 15.3.5 — see here. Fulton, William. **Intersection theory.** Second edition. Ergebnisse der Mathematik und ihrer Grenzgebiete. 3. Folge. A Series of Modern Surveys in Mathematics [Results in Mathematics and Related Areas. 3rd Series. A Series of Modern Surveys in Mathematics], 2. _Springer-Verlag, Berlin,_ 1998\. xiv+470 pp.
stackexchange-math
{ "answer_score": 1, "question_score": 6, "tags": "algebraic geometry, vector bundles, characteristic classes, intersection theory" }
No image after waking up monitor Quite often then my monitor goes back to power mode after being in power saving mode (which is initiated after defined period of inactivity), there is just black screen, however it seems like everithing is working besides that malfunction. Note: only monitor goes into sleep mode, CPU is working all the time. Sometimes by tapping different keyboard keys I'm able to make it show something, but usually I just have to press power button, so it gracefully performs power off. I've used this mode for a long time with Windows 7 Pro x64, but started expiriencing this after upgrade to Windows 8 Pro x64. My best guess that can probably be caused by buggy AMD video driver, but I'm not sure is there anything I can do about this if not only waiting for a new driver? I'm using Catalyst Version 13.1 with Radeon HD 7770 graphics card, Dell U2412M monitor connected with DVI cable.
You could try installing a beta driver or an older driver. Here is a beta driver for your card from the official website: < Click "Latest Beta Driver" to download version 13.2. P.S: I assume you meant Radeon **HD** 7770 and not Radeon 7770? Just wanted to point that out to avoid confusion.
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "windows 8, energy saving" }
Issue with ContourPlot of a specific function I plotted a perturbed quadratic function as follows: b = 10; ContourPlot[ 10 x^2 (1 + 75/100 Cos[70 x]/12) + Cos[(100 x)^2]/24 + 2 y^2 (1 + 75/100 Cos[70 y]/12) + Cos[(100 y)^2]/24 + 4 x y, {x, -b, b}, {y, -b, b}, Contours -> 50] Picking $b$, the value range of the plot, different from 10 gives a choppy plot, as expected. However if I pick $b=10$ I get a smooth function - the level curves look exactly like those of a quadratic function, which is not right. How can that be? Is this a bug?
This may be an issue with aliasing and the number of points used for determining the plot. Here is one part of your plot examined in detail with lots of `PlotPoints` and two different ranges. b = 10; ContourPlot[ 10 x^2 (1 + 75/100 Cos[70 x]/12) + Cos[(100 x)^2]/24 + 2 y^2 (1 + 75/100 Cos[70 y]/12) + Cos[(100 y)^2]/24 + 4 x y, {x, 0.9, b}, {y, 0.9, b}, Contours -> 10, PlotPoints -> 200] !Mathematica graphics b = 9; ContourPlot[ 10 x^2 (1 + 75/100 Cos[70 x]/12) + Cos[(100 x)^2]/24 + 2 y^2 (1 + 75/100 Cos[70 y]/12) + Cos[(100 y)^2]/24 + 4 x y, {x, 0.9, b}, {y, 0.9, b}, Contours -> 10, PlotPoints -> 200] !Mathematica graphics They look similar. Such a complicated contour is going to be difficult to resolve without lots of plot points.
stackexchange-mathematica
{ "answer_score": 2, "question_score": 1, "tags": "plotting" }
How to tell GCC to map include directory? I need to compiler source code that contains includes like this: #include <tr1/unordered_map> However my compiler (based on GCC 4.6) does not have the `tr1` directory. I need to somehow tell the compiler to map `<tr1/unordered_map>` to `<unordered_map` without modifying source code of file system?
A bit hacky: Go to the include directory containing `unordered_map` and: ln -s . tr1
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "gcc" }
videojs - how to pause a video while hiding interface? Question: Is it possible to pause a video that autoplays using video.js player, while not displaying the controls of the video? * * * I'm using video.js for a website, and got the video auto-running upon visiting the site. <video id="my-video" class="video-js" controls preload="auto" data-setup='{ "controls": false, "loop": "true", "autoplay": true, "preload": "true" }'> <source src="vid/gh.mp4" type='video/mp4'> I have decided to hide the controls, so you can only see the video. Is it possible to click the video to stop it from playing? I realize by setting the controls to false, I hide the play button and thus remove the option to pause the video. I'm still at a pretty basic level, so I have no idea whether or not this is even possible - but I'm very curious to hear if there is a way to do it! Thanks so much
You can try this: <video width="320" height="240" onclick="this.pause()" autoplay> <source src="{{asset('video/media_.mp4')}}" type="video/mp4"> Your browser does not support the video tag. </video> This will pause your video by clicking on the video. But if you want to play your video again then you need to use the following line in the place of `onclick`: onclick="this.paused ? this.play() : this.pause();"
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "html, css, video.js" }
How do I achieve different routing path for same destination in cisco router I want to route same destination packet coming from the different source s1 and S2, to different path something like this ip route 192.168.221.0 255.255.255.0 192.168.222.1 ip route 192.168.221.0 255.255.255.0 192.168.120.1 How do I achieve it?
You can do this with policy based routing ip access-list standard s1 permit 192.168.221.1 ip access-list standard s2 permit 192.168.221.2 route-map PBR permit 10 match ip address s1 set ip next-hop 192.168.120.1 route-map PBR permit 20 match ip address s2 set ip next-hop 192.168.120.50 interface FastEthernet0/0 ip policy route-map PBR In this example anything arriving on f0/0 is evaluated by the route-map, anything with a source address of 192.168.222.1 is forwarded to 192.168.120.1, anything with source address 192.168.222.2 is forwarded to 192.168.120.50
stackexchange-networkengineering
{ "answer_score": 1, "question_score": 1, "tags": "cisco, router, asymmetric routing" }
Example for GrowlNotification and Callback on Mac I am new to Growl notifications. My chat application shows some growl messages whenever a message is received. When the user clicks on the growl message, I should be able to popup the application window with the message on the window. Is there an example or tutorial for Growl?
You mean like the Implementing Growl support in your Cocoa Application page from the official Growl docs? Or, since you mention AppleScript, perhaps you were looking for Sample AppleScript Notification, also from their docs.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "callback, applescript, growl, growlnotify" }
Dynamically adding directive to element in Angular I have a directive called "resizable" that adds functionality to an element to make it resizable. I want to conditionally apply this directive to an element from a controller. When I add this directive at run-time using `attr`, the attribute for the "resizable" directive is added, but the directive doesn't execute. Here's an illustration: < What I'm expecting is that when `$('span').attr('resizable', '');` is called, the class `funky` should be added to the `span`. Why doesn't it?
You need to use the `$compile` directive to notify angular of the changes. Basically the logic goes like this: "I've changed something within my element that you should be concerned about. Please compile the DOM against my scope": function Controller($scope, $compile) { // Apply resizable directive to span var span = $('span'); span.attr('resizable', ''); $compile(span)($scope); } Documentation here **NOTE:** You SHOULD NOT use jQuery natively within a controller (... or anywhere really). It may select `span` tags outside of your element of interest. You SHOULD try writing a directive to wrap the logic that applies your resizable directive.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, jquery, angularjs" }
Bypass of Access Restrictions in Apache Cordova iOS Recently Apache Cordova announced that iOS contains 2 methods to bypass the URL access restrictions provided by the whitelist. An attacker can use any of the 2 methods to load malicious resources in an app that uses a whitelist to only load trusted resources. As i am new to Cordova, can anyone please provide information how much the above issue will impact the existing application and how.I am using Cordova ios version 3.5.0.
Like it says in the link, this problem allows to inject malicious code into your app, as this involve plugins invocations. This can be used to retrieve all the information that you can extract from your app. This only can be performed through external links, you if you dont have links to external websites, or paths that you are not controlling, you are protected. Also, I don't know about the extension of this backdoor, and maybe few people know it, but if you want to be sure, just update to the latest version of cordova-ios.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ios, cordova, whitelist" }
Hide a div only if it contains some specific words Let's say that there are a lot of divs with same class which are displaying content dynamically as links. How could I remove/hide only those divs which contains the words e.g Sport, Television, Airline? e.g <div class="ns2-category"> <a href="#">Sports</a> </div> <div class="ns2-category"> <a href="#">Sports</a> </div> <div class="ns2-category"> <a href="#">Magazine</a> </div> <div class="ns2-category"> <a href="#">Airlines</a> </div> <div class="ns2-category"> <a href="#">Television</a> </div> <div class="ns2-category"> <a href="#">Other</a> </div>
you can use javascript code below : $("div.ns2-category:has(a:contains('Sports'))").hide(); $("div.ns2-category:has(a:contains('Sports'),a:contains('Television'))").hide(); // either one OR two Edit : add class name with div, for multiple
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "javascript, jquery" }
eth0 interface is missing I have a new Gentoo server installed on virtual, with virtual lan interface. When booting from live CD, network (eth0) is available. When booting into the newly-created system, the network is missing at startup. The interface is shown in dmesg. In `ifconfig`, `eth0` is missing. What's wrong? ![enter image description here]( ![enter image description here](
The problem was in the poorly translated kernel. Bad config file caused that the changes associated with enabling virtualization options did not take effect. After repairing and rebuilding the new kernel, eth0 is available and the net working perfect.
stackexchange-unix
{ "answer_score": 2, "question_score": 1, "tags": "networking, gentoo" }
Getting the positions of a object when you click on it My current jFiddle: < It displays the position of bean 1 (box 1) when you move it around the page, but how I display the position of the second box? I want it to be able to display the position of whatever I click on. So if I clicked on box 1 and moved it, it will display X and Y of the first box If I licked on box 2 and moved it, it should display the X,Y of second box. This is the part of the code where it shows the X and Y positions: $( "*", document ).on('click',function( event ) { var offset = $( "strong" ).offset(); topp = offset.top; left = offset.left; event.stopPropagation(); $( "#result" ).text( this.tagName + " ( " + left + ", " + topp + " )" + offset.id ); } Also, why is the id undefined?
**draggable has a built in stop event** So it may make sense to use that. **something like this:** $('.normal, .failure').draggable({//drag stop: function() {//on stop var t = parseInt($(this).position().top),//get top l = parseInt($(this).position().left);//get left $( "#result" ).text( this.tagName+' ('+l+', '+t+') '+this.id);//print } }); **made a fiddle:** < And the `ID` is undefined, because `$( "strong" ).offset().id` isn't correct, it would need to be `$( "strong" ).prop('id')` or something equivalent. Though `strong` doesn't have an `ID`, so it still wouldn't work... you need the `ID` of `.normal` & `.failure` for it to do what you want.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery, html" }
SAS - Change the format of a column in a proc imported CSV I cannot quite figure out how to change the format of a column in my data file. I have the data set proc imported, and it guessed the format of a specific column as numeric, I would like to to be character-based. This is where I'm currently at, and it does not change the format of my NUMBER column: proc import datafile = 'datapath' out = dataname dbms = CSV replace ; format NUMBER $8. ; guessingrows = 20000 ; run;
You could import the data and then format after using - I believe the following would work. proc sql; create table want as select *, put(Number, 4.) as CharacterVersion from data; quit;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "csv, sas" }
Android Java to C# URL What is the C# equivalent of the following Java snippet below: Drawable image; URL imageUrl; imageUrl = new URL(getMyImageUrl(imageNumber)); Bitmap bitmap = BitmapFactory.decodeStream(imageUrl.openStream()); image = new BitmapDrawable(bitmap); Thanks in advance.
A more literal conversion to C# would be: var imageUrl = new Java.Net.URL(GetMyImageUrl(imageNumber)); var bitmap = Android.Graphics.BitmapFactory.DecodeStream (imageUrl.OpenStream ()); var image = new Android.Graphics.Drawables.BitmapDrawable (bitmap); This is one of the strengths of Mono for Android: the classes and methods mirror the underlying Java platform (with some exceptions) while providing much of the .NET framework, so migrating code from Java to C# should be reasonably straightforward.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "c#, java, android, xamarin.android" }
Can OpenFileDialog receive filename *.*? I want to use `OpenFileDialog` as selecting file with expression( _._ or *.zip) On **File Name EditBox.** Do I have to override `OpenFileDialog` ? if then, please give me a tip about it. At now, If I put file name as _._ and click 'open' , the OpenFileDialog doesn't return anything. Sorry about my poor English. !enter image description here
You can't do what you want with `OpenFileDialog`. It wraps up the common Windows component which has special treatment for file names that contain wildcards. Those are interpreted as filters for the file list view.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, winforms, openfiledialog" }
How does metric decide if set is open or closed? I have a problem in which I am to decide if $A \subset (X,d)$ is open or closed. There are two subproblems, in which the set $A$ is the same but the metrics are different. My question is how does the metric "influence" if the set is open or closed? My notion of a metric is that is some kind of "distance" function inherent to the set but I'm having a hard time seeing how this affects open and closedness. I guess my question is very general. Thanks in advance.
You can define openness (as your book almost certainly does) in terms of the metric: > A set $A \subseteq X$ is _open_ if, for every $a \in A$, there is some real $r > 0$ such that the ball of radius $r$ (as measured by $d$), centered at $a$, is contained in $A$. The general idea is that a set is open if no point in it is "right on the edge," i.e., around every point is at least little neighborhood of points still in the set, as measured by the metric. (A closed set is one whose complement (i.e., the set of everything outside it) is open.)
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "general topology, functional analysis, metric spaces" }
zsh in multi-term I run zsh in multi-term. `M-p` and `M-n` allow me to jump through the input history. Is there a way to make `M-p` and `M-n` behave like `up-line-or-beginning-search` and `down-line-or-beginning-search` (jumping only through entries which start with the already input characters)?
Try: (with-eval-after-load "term" (defun term-send-M-p () "Type M-p in `term-mode'." (interactive) (term-send-raw-string "\ep")) (defun term-send-M-n () "Type M-n in `term-mode'." (interactive) (term-send-raw-string "\en")) (define-key term-raw-map (kbd "M-p") #'term-send-M-p) (define-key term-raw-map (kbd "M-n") #'term-send-M-n)) I think `multi-term` binds `M-p` and `M-n` to `term-send-up` and `term-send-down` by default, which tries to do the same as pressing the arrows in a terminal. IIRC, `multi-term` has an elaborate binding override mechanism, which you may have to use instead of plain `define-key`.
stackexchange-emacs
{ "answer_score": 0, "question_score": 0, "tags": "history, multi term, zsh" }
How to remove IMAP account from Thunderbird's "Grouped Inbox" I have four IMAP accounts "merged" into one using Thunderbird 2's "Grouped inbox" view. I want to take one of the four accounts out of the grouped view. It is a maintenance mailbox that contains a lot of status mails. Those mails tend to clog my "real" inbox. I am able to edit the Inbox folder using "Properties". In the list that comes up, it is possible to de-select the maintenance mailbox and everything works fine. However, if I restart Thunderbird, it will forget what I de-selected and use all four mailboxes again. Is there any way to make Thunderbird remember the change?
What version do you use? I use 3.1.2 and for me the deselected Inbox-folders (via _Select_ ) keep being deselected after a restart. So I'd suggest you to update your version.
stackexchange-superuser
{ "answer_score": 2, "question_score": 2, "tags": "email, thunderbird" }
What was Dumbledore's fallback plan in case Harry fails? Is there any canon support whether Dumbledore had a fallback plan in case that Harry fails? As a start - Harry is hardly the best choice for the one to hunt down and kill Voldemort. There are more experienced people at hand who can do it and have much better chances to succeed. Yes - Harry had a unique advantage of the double protection coming from his mother's blood that was later transferred to Voldemort. Yes - Harry is "the chosen one" according to the prophecy although prophecies depend a lot on what people do and are not guaranteed to come true just because they exist. There are a lot of places where Harry could've been just killed together with Hermione and Ron and the whole knowledge about the hocruxes would've been lost.
Dumbledore didn't have a backup plan. > ‘The last words Albus Dumbledore spoke to the pair of us?’ > > ‘“Harry is the best hope we have. Trust him,”’ said Lupin calmly. > > _Deathly Hallows_ \- page 65 - Bloomsbury - chapter five, _Fallen Warrior_ Dumbledore had complete faith in Harry. There is no mention of a backup plan in canon, nor has J.K. Rowling ever addressed the possibility in any of her interviews.
stackexchange-scifi
{ "answer_score": 10, "question_score": 5, "tags": "harry potter" }
How to create a modal login popup? I need to add login modal popup in my project like Digg's login popup. What are different modal box popups to achieve this?
< \- their dialog is quite flexible :) as for tips, you can add your login form to the page in it's own div that is hidden via css. Then your login link/button/whatever can open it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript, jquery, jqmodal, modalpopup" }
Is it possible to use Not In With This Query I want to view a list of boxes that are in our master list, but have not been marked off-site in our offsite list. Select boxID, boxlocation From masterList WHERE boxlocation NOT IN ( Select boxID FROM offsiteList ) However, either my 2 lists have become very corrupted or my query is returning inaccurate results. Wanted to check this was a good query before I went line by line check of the list...
I suspect you're filtering on the wrong field; presumably `boxID` is the field which matches records in each table; so the one you should compare on. Select boxID, boxlocation From masterList WHERE boxID NOT IN ( Select boxID FROM offsiteList ) Also, if the `offsiteList.boxID` column has nulls, the NOT IN predicate will not work as expected. You will need to filter out the nulls in the subquery: Select boxID, boxlocation From masterList WHERE boxID NOT IN ( Select boxID FROM offsiteList WHERE boxID IS NOT NULL )
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "sql server, tsql" }
How to fix error Call to undefined function link_to_route() laravel 5? First I am sorry my endlish so bad ,Hi all I am a new of laravel I just studying laravel. and I have problame error with link_to_route() function I try to fix and search google but I still can not.and I got error: Whoops, looks like something went wrong. 1/1 FatalErrorException in cb4e66236ac7f3bb7bc9c7abce945dc30f4b8bf1.php line 33: Call to undefined function link_to_route() and here is my route.php Route::group(['prefix'=>'auth'], function(){ Route::get('register',[ 'as' => 'get_register', 'uses' => 'Auth\AuthController@getRegister' ]); Route::post('register',[ 'as' => 'post_register', 'uses' => 'Auth\AuthController@postRegister' ]); }); And here is my code nav.blade.php <li><?php echo link_to_route('get_register', 'Register'); ?></li>
You need to install a package named `"laravelcollective/html": "~5.0"` In your composer.json file, Write this line > "laravelcollective/html": "~5.0" Then open `config/app.php` file. In provider array,Write this line:- > 'Collective\Html\HtmlServiceProvider', Next, add these lines to the 'aliases' array: > 'Form' => 'Collective\Html\FormFacade', > > 'Html' => 'Collective\Html\HtmlFacade', This link will help you.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "php, laravel 4, laravel 5" }
Can I run aws-xray on the same ECS container? I don't want to have to deploy a whole other ECS service just to enable X-Ray. I'm hoping I can run X-Ray on the same docker container as my app, I would have thought that was the preferred way of running it. I know there might be some data loss if my container dies. But I don't much care about that, I'm trying to stop this proliferation of extra services which serve only extra analytical/logging functions, I already have a logstash container I'm not happy about, my feeling is that apps themselves should be able to do this sort of stuff.
So I think the proper way to do this is using supervisord, see link for an example of that, but I ended up just making a very simple script: # start.sh /usr/bin/xray & $CATALINA_HOME/bin/catalina.sh run And then having a Dockerfile: FROM tomcat:9-jdk11-openjdk RUN apt-get install -y unzip RUN curl -o daemon.zip RUN unzip daemon.zip && cp xray /usr/bin/xray # COPY APPLICATION # TODO COPY start.sh /usr/bin/start.sh RUN chmod +x /usr/bin/start.sh CMD ["/bin/bash", "/usr/bin/start.sh"] I think I will look at using `supervisord` next time.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "amazon ecs, aws xray" }
how to replace &#10; with empty string I am trying to display outout of html instead of html tags so I used this regular expression. String(text).replace(/<[^>]+>/gm, ''); To replace the html tags and it removed all the html tags but I still have `& # 10;` in the text. I guess it is for the new line character . How do I escape it? > & # 10;& # 10;& # 10;& # 10;& # 10;& # 10;& # 10;& # 10;& # 10; Where: Access code: 0164 125 followed by the # sign.& # 10; Review& # 10;- New Template PRE DR template v03.xlsx& # 10;- Information Regarding the change& # 10;- Documentacion description Functionality, incidents and project code. \- Delivery software \- Test
Just use the following code: var text = "A string to have & # 10; removed" text.replace(/& # 10;/g, ""); //Returns "A string to have removed" Note that the multi-line modifier (m) is not necessary.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, regex" }
mod_rewrite: Exact URL not matching but matches non exact I am having issues while using mod_rewrite in an .htaccess file to redirect to another domain. Here's what I have: RewriteCond %{HTTP_HOST} ^www.somedomain.com/events_detail/an-event [NC] RewriteRule ^(.*)$ [L,R=301,NC] RewriteCond %{HTTP_HOST} ^www.somedomain.com [NC] RewriteRule ^(.*)$ [L,R=301,NC] For some reason `www.somedomain.com/events_detail/an-event` I get redirected to ` instead of ` When testing out my .htaccess on a tester, it indicates that it does not match the first condition but matches the second. I have tried removing the L option, removing the forward ^ without success. Thank you
RewriteCond %{HTTP_HOST} ^www.somedomain.com$ [NC] RewriteCond %{THE_REQUEST} /an-Event [NC] RewriteRule ^(.*)$ [L,R=301,NC] RewriteCond %{HTTP_HOST} ^www.somedomain.com$ [NC] RewriteRule ^(.*)$ [L,R=301,NC]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "apache, .htaccess, mod rewrite, url rewriting" }
Consume SOAP web service in Ruby 1.9 and Rails 3? I'm trying to consume a SOAP web service, (from SharePoint 2010 if it makes a difference). I'm using Ruby 1.9 and Rails 3. What is the best way to do this? I've read some stuff mentioning Savon < but that is was too new and buggy. Is it still the best solution? Thanks.
I used Savon successfully to interact with the Bullhorn Staffing SOAP based service about six months ago. I didn't have any problems with the Savon Gem, all my headaches came from inconsistencies with the service. My interactions with their service was limited to getting data (simple) and pushing data, which could include a resume file (more complex). I didn't have to look much further than the Savon doc to figure everything out, which I thought was simple to understand and easy to apply to my particular set of problems. TLDR; 1 vote for Savon despite what you may have heard.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 4, "tags": "ruby on rails, ruby, soap" }
DevExpress XtraReporty Print Without any UI Interaction I am having some trouble trying to get a report to print from a service that does not allow UI interaction. Currently I can do the following Dim myReport As New MyXtraReport(myData) myReport.CreateDocument() 'Then I attempt to do the following DirectCast(myReport.PrintingSystem, PrintingSystem).Print However nothing happens when I do this. I don't get any exceptions just no document is printed. Calling `myReport.Print()` will print the correct document but with UI interaction. What am I missing or is this just not intended to be viable. I have also tried using the `myReport.PritingSystem.ExecCommand(PrintDirectly)` but it also doesn't print anything.
You only need to call the Report's Print method: new XtraReport1().Print(); I've tried this and it works. If it does not work, I suggest that you post a sample in the support center and we will try to help you.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "devexpress, xtrareport" }
How to get class Constructor parameteres using Apache BCEL? I 'm able to get methods using BCEL but is it possible to get constructors of a class using the same library?
Yes; the constructors are considered methods by BCEL. They are named `<init>` instead of the class's name.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "java, bcel" }
Bash - How to export VSCode extensions to a .sh file in the following format? Format: code --install-extension adpyke.codesnap --force & code --install-extension alefragnani.Bookmarks --force & code --install-extension arturock.gitstash --force & code --install-extension csholmq.excel-to-markdown-table --force Currently, I'm doing `code --list-extensions | xargs -L 1 echo code --install-extension > install-extensions.sh` to get the extensions printed to `install-extensions.sh` and manually add `--force &` at end of lines in that file, that's the furthest I can get. I'm not very familiar with the bash syntax, could anyone please shed some light?
After some diggings, I finally got it working, the working script: code --list-extensions | xargs -L 1 echo code --install-extension | sed 's/$/ --force/' | sed '$!s/$/ \&/' > install-extensions.sh Reference: How can I add a comma at the end of every line except the last line?
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "bash, visual studio code, automation" }
form_remote_for passes null values (rails 2.3) I have the following actions in the controller: def new @entity = Entity.new end def create @entity = Entity.new(params[:entity]) @entity.save end I have the following form: #this is the new.html.erb <% for_remote_for(@entity) do |f| %> <%= f.text_field :title %> <%= f.text_field :description %> <% end %> For some reason the values for :title, and description is being passed as null. Everything else (e.g created_at, updated_at) gets populated. Any suggestion why these values are being passed as null?
Maybe you can try to do this in your 'create' method: def create Rails.logger.info "These are all params: " + params[:entity][:title] + params[:description] @entity = Entity.new(params[:entity]) @entity.save end * perhaps you can catch the problem in log Also check Rails api for proper syntax - if you have generic form `remote_form_for(@post)` then it is ok, otherwise you need `(:post)`.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails" }
two columns in two rows I have this table: ID Value ----------------- 3 A1 4 A2 8 A20 10 A10 I have to create only two rows with the name of the columns at the beginning, I think using the pivot, but I don't know how to do it: ID 3 4 8 10 ----------------------------------- Value A1 A2 A20 A10
SELECT 'Value' AS ID, [3], [4], [8], [10] FROM test PIVOT ( MAX(value) FOR id IN ([3], [4], [8], [10]) ) AS PivotTable; fiddle
stackexchange-dba
{ "answer_score": 0, "question_score": -3, "tags": "sql server, pivot" }
Probability that a randomly chosen person watches neither basketball games nor hockey games regularly? The question is: > Forty percent of the people in a town watch both basketball games and hockey games regularly. 55 percent watch basketball games and 63 percent watch hockey games regularly. If one person is chosen randomly, what is the probability that this person watches neither basketball games nor hockey games regularly? I've tried to construct a probability tree (which did not bear any results). I also tried to do 1 - (probability that they watch hockey, basketball, or both) however it's the final part of that equation which I seem to have trouble with. How do I calculate the probability that a randomly chosen person watches hockey, basketball, or both?
If forty percent of the people watch both sports, then 15 percent watch only basketball (55-40) and 23 percent watch only hockey (63-40). Therefore we have 100-40-15-23=22 percent of people watching neither one of the sports. So if we choose a random person the probability that he/she watches neither one of the sports is 22 percent.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "probability" }
Can I use private methods? I'm using awesomium WebControl. I wanted to use method: `LoadURL(String)`. But it's a private method. Is there a possible way to use private methods at all? My code: XAML: <my:WindowsFormsHost Name="windowsFormsHost" Visibility="Hidden"/> Code behind [C#] Awesomium.Windows.Forms.WebControl Browser2 = new Awesomium.Windows.Forms.WebControl(); private void start_Click(object sender, RoutedEventArgs e) { windowsFormsHost.Child = Browser2; windowsFormsHost.Visibility = Visibility.Visible; } And i wanted to use: Browser2.LoadURL(String); The method is here: <
You can't call private methods. Private members are accessible only within the body of the class or the struct in which they are declared
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": -4, "tags": "c#, wpf, awesomium" }
how to display linux partitions using python? I am trying to display partitions of linux using python and i want to do it using APIs. I have just tried the following code to get the output. import os f = os.popen ("df -h") for i in f.readlines(): print "myresult : ", i
df command used for - report file system disk space usage I think you required fdisk for Partition table manipulator for Linux. you can use either os.popen or subprocess. just need root user login before running python script.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, linux" }
Downgrade Xcode 5 to Xcode 4.6.1 I have been trying to research a way that I would be able to revert back to Xcode 4.6.1, I can't seem to find a solution. I've seen that in the past people have downgraded their Xcode. Is there a way that I can downgrade Xcode 5 back to Xcode 4.6.1? I have older versions of apps which clients do not wish to upgrade. However I still need to make amendments to theses applications. I need them to remain the same. Is there any way that I can downgrade Xcode?
Move Xcode 5 to the Trash. Download and install Xcode 4.6. You can download older versions of Xcode from the following URL: < You can also have both Xcode 4 and 5 installed. You will have to rename your existing Xcode 5 app from Xcode to another name like Xcode5 before you install Xcode 4.6 in the Applications folder.
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 4, "tags": "xcode, xcode4, xcode5" }
Can somebody illustrate what is "Pixel Tracking" in php? Well, I encountered this new term in programming. What is it? How does it works and how to use it? Can somebody illustrate in php? I have a website, full flash. That site is for signup, enter username and email. The button is in flash. An user visit my site, www.domain.com/index.php?var=string Can I use pixel tracking method to pass this URL variable($var) to another php page (email subscibe processing php page) together with username and email from Flash/AS3??
The more common term is Web bug: an invisible (i.e. 1x1 transparent pixel) image embedded in a web page or email, with its URL containing parameter data. When the page/email is displayed, it will load the image, thereby causing a request containing the parameter data on the server, which can then do things with that data. **Edit:** I don't think the technique would work for what you want to do, since it sounds like the username and email address are entered into the flash app only after the page is fully loaded and displayed, i.e. _after_ the request generated by a hypothetical web bug has already been sent. Can't you make the request to your signup page from the Flash code? Then all you need to do is somehow pass the URL parameter to the Flash app. I think that should be possible.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, methods" }
How can I run through three separate arrays in the same for loop? I have three arrays I am trying to run through and I want to use the values from all three arrays in one function. This might sound confusing but here is what I have: var Name = [Joe, Sarah, Chad] var Age = [18, 20, 22] var Gender = [Male, Female, Male] for name in Name { for age in Age { for gender in Gender { makeUser(name, userAge: age, userGender: gender) } } } This runs but what I get is: (makeUser prints out the 3 values) Joe, 18, Male Joe, 20, Male Joe, 22, Male Joe, 18, Female Joe, 20, Female Joe, 22, Female .... And so on. All I want is Joe, 18, Male Sarah, 20, Female Chad, 22, Male Is this possible? Any help is appreciated. Thanks!
If you are always sure the arrays will be equal in length, then you are better to just loop through one of the arrays and use it's index to reference the others: for (index, name) in enumerate(Name) { makeUser(name, userAge: Age[index], userGender: Gender[index]) } However, I would recommend getting this data into a dictionary, but I assume this is just sample data to illustrate a point. :)
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 9, "tags": "arrays, swift" }
Upgrading sugarcrm from 5.2 to latest I need to upgrade from sugarcrm 5.2 to the most recent. It keeps breaking on the process and I never got passed the 5.5, maybe 6 once. Is it possible for me to just **install** the latest version of sugarcrm, and apply the Upgrade SQLs on the DB **only** and then use the fresh install with the upgraded DB? Thanks [EDIT] I tried silent upgrades and every other way to upgrade the code, I have checked php settings etc, What I want to know is if I can do what I suggested above. I also have cache/upload with 16GB of data and cache/images with a few more GB. What should I do with those folders in case I can get a fresh install and upgrade the DB? [/EDIT] don't know if it matters but my server runs Linux. (I don't think versions play a major rule on what I want to do, since I would only install most recent then I need up to date mysql, php, apache etc)
You could also try using the silent upgrader, which sometimes is more successful... < From that far back, a migration may be a better option. You can simply install the new version, and then dump your old data into the new data structure.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "linux, sugarcrm" }
Does firebase login:ci have access to all my projects? I am using the `firebase login:ci` token for CI/CD. But there is not enough documentation regarding the token. Does it have access to all my firebase projects where my account has access or only the current active project? Where can I see a list of all tokens and their activity? The solution I am going for is creating a throwaway email and adding that to the project I want to deploy. Is this ok?
When you run `firebase login:ci` you get prompted to log in with a Firebase account. After picking your account, you get a dialog that shows the permissions you're granting. This contains: > This will allow Firebase CLI to: > > View and administer all your Firebase data and settings So if you click `Allow` in that dialog, the Firebase CLI will have access to all Firebase projects that the account has access to. The generated token does (as far as I know) have access to the same scope.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 9, "tags": "firebase, firebase cli" }
Toast not showing on my project Ok to test the toast I simply put this on my Oncreate method: Toast.makeText(getApplicationContext(),"Hello",Toast.LENGTH_SHORT).show(); It don't show anything nor errors at all. BUT if I create a new blank project it works.
The solution was to create a new blank project and copy all the files in it. I guess the problem was produced by the automatic-created action bar.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -11, "tags": "android, toast" }
Does anyone know if an asp.net page can be opened in an asp classic frame? I am trying to find the way to accomplish the next thing: I have an asp classic page with frames and from it I am opening some other pages which are opened inside frames of the first page. One of this pages opens an asp.net page. I wonder if is any way to open this asp.net page inside a frame of the first asp classic page mentioned. I am trying to achieve this, but I don't know even if it is possible or not.
You can do this, because the browser renders the page inside the iframe, it has nothing relative to the server technology. You can even put a third party website page inside the iframe, no matter which technology was used in the server.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "asp.net, asp classic, window, frame" }
Is there a Scala function of type `Nothing => A`? Or how to construct one? Through Curry-Howard isomorphism Scala's `Unit` corresponds to logical true and `Nothing` to logical false. The fact that logical true is implied by anything is witnessed by a simple function that just discards the argument: def toUnitA: Unit = { } Is there a function that witnesses the fact that logical false implies anything, that is a function of type `Nothing => A`? Or is there an idiomatic way how to construct one? One can always do something like def fromNothingA: A = throw new RuntimeException(); but this is just ugly - it doesn't use the fact that `Nothing` has no values. There should be a way how to do it without exceptions.
You may do that def emptyFunction[A]: Nothing => A = {n => n} or def emptyFunctionA: A = n
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "scala, unit type, curry howard" }
公開しているWEBサイトのjavascriptコードを絶対に見られないようにする方法 WEBjavascript
> WebAssemblyFirefoxChrome Windows
stackexchange-ja_stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript" }
nested routes with optional parameter Hi there for localization reasion i need optional nested routes like /en/mypage , /ru/mypage , /my page, I already tried to work with `<Route` but didn't get it working. <Route path="/:lang(en|lt|ru)?" > <Route path="/surveys" exact component={Dashboard} /> </Route> Already found solutions above with earlier versions but it doesn't seem working now. How can i implement it? i know it's posible to add to every route parameter, but isn't here more elegant way.
You can't nest your routes in React-Router v4. Instead you should add nested routes in `component` or use `render` prop: <Route path="/:lang(en|lt|ru)" render={({ match: { url } }) => ( <> <Route path={`${url}/surveys`} component={Dashboard} exact /> </> )} /> In above example your available routes would be /en/surveys /lt/surveys /ru/surveys
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "reactjs, react router" }
Redirect a page without extension using htaccess I need redirect the page like this: < To this: Is this possible using htaccess? And if the answer is yes, how?
Yes, this is possible. Put the following code in your `.htaccess` file: RewriteEngine on RewriteRule ^home$ index.php Have a look at this website. It is a good reference.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": ".htaccess, redirect" }
embedded variable in R string I am trying to loop and rename colnames in a data frame. How can I embed a numeric variable in the R's colname string. I found the .(x) associated to the bquote/paste method for title in graphics but it doesn't work with a standard string. In Ruby I can embed a variable in a string using #{x} in the following way irb(main):005:0> (1..10).each{|i| p "hello no #{i}"} "hello no 1" "hello no 2" "hello no 3" "hello no 4" "hello no 5" "hello no 6" "hello no 7" "hello no 8" "hello no 9" "hello no 10" Thanks
You can simply use `sprintf()`. For example: i <- 4; data[[sprintf("hello.%1.2d",i)]] <- ...;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r" }
How to exit a sbt task? I run a sbt task. Normal scenario after it finishes, it should stop in the terminal. But the terminal is not waiting for next input meaning : my task keeps running. I assume some called threads were not exited after the task launched them. **How to exit clean and kill all processes started by the sbt task ?** I could debug which service was not stopped but it will take a long time to figure out. More details In the build.sbt lazy val refreshTranslations = taskKeyUnit fullRunTask(refreshTranslations, Compile, "tasks.TranslationTask") In the task object TranslationTask { def main(args: Array[String]): Unit = { // background stuff with ActorSystem() , AhcWSClient() Await.result(service.get, 20.seconds) ... } }
I found a way to exit the `ActorSystem` after the SBT task finishes. In the build.sbt , start the task in the different thread. lazy val refreshTranslationsFallback = taskKeyUnit fullRunTask(refreshTranslationsFallback, Compile, "tasks.TranslationTask") fork in refreshTranslationsFallback := true In the task, object TranslationTask { def main(args: Array[String]): Unit = { // background stuff with ActorSystem() , AhcWSClient() ... scala.sys.exit() // important } } Special thanks to SBT stop run without exiting
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "scala, sbt, task, actor" }
Techniques to Trigger Google Analytics Tracking from PDF Links Here's the scenario: I have a mailing list that contains a PDF download link. The PDF contains ads with clickable links. I need to get analytic data on the link clicks - preferably via Google Analytics (due to the richness of information available). The solution I have in mind is for the link to go to a web page that I host with some sort of ad-specific token. GA records the request and then I use a client-side technique to redirect to the actual target URL. The redirect page serves no purpose other than to track the click and so I'm not worried about it being perceived as cloaking by search engines. What I want to know is: * Are there any alternative ways to achieve the tracking without using an intermediate redirect page (could I perhaps call GA server-side somehow)? * If I do use the redirect page approach, what are potential pitfalls could I encounter? Thanks in advance for any advice.
dunno what server-side environment/language you use but for instance in php you can use cURL to send an image request to google, with the custom code appended to the url. Easiest way to do it is to output the code with javascript with your custom code and then capture the image request url with a sniffer, so you can replicate the format for your cURL request. Make sure to send header info, including fake browser info so GA doesn't weed it out as a bot. Then forward to the ad url. That way you don't need to output a page. Yeah you still have a 'redirect' happening but you cut out having to have the client download a page or worry about javascript being disabled, etc... unfortunately there really isn't anything better you can do.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "google analytics, analytics, click tracking" }
The math behind flappy bird You may have heard of this game called flappy bird, but even if you haven't, you should be able to understand this basic game: The player progresses through a series of obstacles. The probability of passing by any one obstacle is p, and the obstacles continue to come until the player fails to pass an obstacle, at which point the game ends. The player's score is the number of obstacles that he successfully passed before failing. Here is the question I have about this game: If the player plays the game, say, 100 times, how many times (on average) will he score a 1? a 2? etc. And what is his expected maximum score?
This is called a geometric distribution. The probability of getting through only the 1st obstacle is $p(1-p)$. Getting through 2 obstacles and then failing is $p^2 (1-p)$. etc. You could theoretically play forever, there is no maximum score. The mean after many plays is $\frac{1-p}{p}$.
stackexchange-math
{ "answer_score": 3, "question_score": 2, "tags": "probability, probability distributions" }
Logging in multi-processing and multi-threading python program? I am writing the back end of an Online Judge ( code checker) in python 2.7 which takes submissions from database(using mysql) evaluates the submission and writes the result back to database.I am running multi processes and each process runs multiple threads.For time being I am printing the evaluations status and other stuff directly to STDOUT. I haven't even put lock on printing(which is cumbersome because there are many print statements).Although I know lock is necessary in this condition.But initially my evaluator had only one process which had only one thread.I did not put lock that time and was redirecting `STDOUT` and `STDERR` to file from command line.But now the case is different.Also such log would difficult to be read and finding the error and other things if my evaluator crashes.Is there some neat way of logging in this case ??
You can use a variable like a counter that is a process or thread counter. So you can check this counter and you can use lock when counter bigger than 1.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, mysql, multithreading, python 2.7, multiprocessing" }