INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Diophantine equation and regular polygons Consider Diophantine equation: $$(m-4)n=2m.$$ It can be rewritten as: $$\frac{1}{n}+\frac{2}{m}=\frac{1}{2}.$$ If we search for positive solutions only, we have at least $4$ pairs: $$(m,n)\in\\{(5,10);(6,6);(8,4);(12;3)\\}$$ They can be illustrated in the following way using regular polygons: ![enter image description here]( > How are the equation and the polygon combinations related? Do we have any other positive solutions?
It's $$mn-2m-4n=0$$ or $$(m-4)(n-2)=8$$ and we get a finite number of cases: 1. $m-4=1$ and $n-2=8$, which gives $(m,n)=(5,10)$; 2. $m-4=2$ and $n-2=4$, which gives $(m,n)=(6,6)$; 3. $m-4=4$ and $n-2=2$, which gives $(m,n)=(8,4)$ and 4. $m-4=8$ and $n-2=1$, which gives $(m,n)=(12,3)$. Easy to see that these all natural solutions.
stackexchange-math
{ "answer_score": 4, "question_score": 4, "tags": "geometry, elementary number theory, discrete mathematics, diophantine equations, polygons" }
Space Delimiter Arrays Shell Script Array is taking "space" as default delimiter: str="HI I GOT;IT" arr2=$(echo $str | tr ";" " ") for x in $arr2 do echo " $x" done Output: HI I GOT IT I want the output to be: HI I GOT IT
You haven't said which shell this is, but it looks like `bash`, so I'll go ith that. This is a job for `IFS`, which determines how `bash` splits words. Here we set it to `;` for a single command, to split up your string. You also need to iterate over the array properly (using quotes and `[@]`) so that it's not split again by bash at this point. str="HI I GOT;IT" IFS=\; arr=($str) for x in "${arr[@]}" do echo "$x" done
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "arrays, shell, delimiter" }
How to know which exact .NET assembly is used I need to know exactly which FSharp.Compiler.dll file the Fsc.exe is using. I have reasons to believe that it is not using the file adjacent to it, so I want to know which one it does use. The version numbers are the same, but the locations are different. Any ideas how to find out?
Could always load up Process Explorer and see which DLLs are loaded.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": ".net, fsc" }
how to compare SQL dates with null I want to count the number of rows having date is null.i tried following SELECT R.COUNTRY_CD,COUNT(R.EFFECTIVE_END_DT) AS d_null FROM REIMBURSEMENT R GROUP BY R.COUNTRY_CD,R.EFFECTIVE_END_DT HAVING R.COUNTRY_CD = @COUNTRY_CD AND R.EFFECTIVE_END_DT IS NULL but it's giving d_null as 0... how can i compare a date for `NULL`
`COUNT` only counts non-`NULL` entries. Try `COUNT(*)` or `COUNT(1)` instead of `COUNT(R.EFFECTIVE_END_DT)`. Since you provide a `Country_CD` as parameter, and you only want `NULL` dates, you can probably simplify your query to: SELECT R.Country_CD, COUNT(*) AS d_null FROM Reimbursement R WHERE R.Country_CD = @Country_CD AND R.Effective_End_DT IS NULL
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "sql" }
regex for url parameter value in c# I would like to get the cid value of the url, in this case: " Can I use regex for this or there is some better way to do it, except the old IndexOf string trimming.
You can try using HttpUtility.ParseQueryString.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "c#, asp.net, regex" }
Python class mutual static (class) variables In Python, if I have something like: class A(object): b = B() class B(object): a = A() Will produce an error `NameError: name 'B' is not defined` How would you elegantly resolve this ?
Try: class B(object): pass class A(object): b = B() B.a = A()
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "python, oop, class, static variables" }
How can I stop the enter key from triggering a completion in company mode? I often want to go to a newline while the company mode suggestion is showing. How can I set up company mode so only the tab key triggers a completion?
This is defined in `company-active-map`. You can unbind the return key in that map: (define-key company-active-map (kbd "<return>") nil) Note however that return and tab do different things when there are multiple candidates. Tab is bound to `company-complete-common`, while return is bound to `company-complete-selection`. If you unbind the return key then you won't be able to use `M-n` and `M-p` to pick a completion from the list. You may want to pick some other key to use for `company-complete-selection`, for example: (with-eval-after-load 'company (define-key company-active-map (kbd "<return>") nil) (define-key company-active-map (kbd "RET") nil) (define-key company-active-map (kbd "C-SPC") #'company-complete-selection))
stackexchange-emacs
{ "answer_score": 15, "question_score": 25, "tags": "key bindings, completion, company mode" }
Query account running balance with php Please assist, how to write php code for the following query: SELECT transactions_id, trn_date, trn_dt_total, trn_ct_total, trn_description, trn_bank_reference, balance FROM (SELECT t.*, @n := IF(@g <> transactions_id, 0, @n) + COALESCE(trn_dt_total,0) - COALESCE(trn_ct_total, 0) balance, @g := transactions_id FROM transactions t, (SELECT @n := 0) n, (SELECT @g := 0) g WHERE trn_building_id = 1 and trn_unit_id = 1 and trn_tenant_id = 1 ORDER BY transactions_id, trn_date) query My php page query $details = $db->query(); When running the query in MySql without the "query" line i get the error: 1248 - Every derived table must have its own alias
The error is self explanatory. You should name an alias for the table you created. After the subquery in the parenthesis, you should write `as t_name` where **tname** would be your table alias
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -4, "tags": "php, mysql, coalesce" }
is calling getWidth() and getHeight() on android.View expensive? I have an application that draws Bitmaps and drawing primitives on `android.View` `Canvas`. I call operations `getWidth()` and `getHeight()` on a view and/or its `Canvas` a couple of dozen times per frame and the view size can sometimes change. What are the factors that could make these operations expensive? Please refrain from answers like "did you profile it?" etc.
Actually getWidth() and getHeight() methods from View just only returns private members value from the class so, it doesn't do any **major operation** internally so, you are safe to use these methods.. public final int getWidth() { return mRight - mLeft; } public final int getHeight() { return mBottom - mTop; } For more detail about what can be internally going in this class.. take reference from here.. View Class Reference
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "android, performance, android layout" }
How to disable the "auto format" feature of VisualStudio2008 editor? When writing the HTML part of a page in a VS2008 Web App, the editor keeps formatting the HTML with linebreaks that break the readability of the code (to my eyes). Can this feature be disabled? Thanks
Have you tried Tools/Options/Text Editor/HTML ?
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "visual studio" }
Http request to the call to API not working in React When I try to fetch some data from weather API using `fetch` request in React application its not getting the response from the api below are the code which I wrote: import React from 'react' class App extends React.Component { constructor() { super(); this.state = { datatemp: {}, loading:true } } componentDidMount() { loading:true; fetch(' => response.json()).then(data => { this.setState({ datatemp: data, loading: false }); }); } render() { console.log(this.state.datatemp); return ( <p>ddd</p> ) } } export default App; all the help will be much appreciable.
**Look bro I have changed url to test! Just check it** import React from "react"; class App extends React.Component { constructor() { super(); this.state = { datatemp: {}, loading: true }; } componentDidMount() { fetch(" .then(response => response.json()) .then(data => { this.fetchedData(data); }); } fetchedData = data => { this.setState({ datatemp: data, loading: false }); for (let i = 0; i < this.state.datatemp.length; i++) { console.log(this.state.datatemp[i].body); } }; render() { return <p>Good Luck</p>; } } export default App;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "reactjs, fetch" }
Asymptotic formula for $k$-partitions of a number Asymptotic formula for all the partitions of a number is given by $$p(n) \sim \frac{1}{4n\sqrt{3}} e^{\pi \sqrt{\frac{2n}{3}}}$$ Only fraction of those will be $k$-partitions. What is asymptotic formula for $k$-partitions of a number? $$p(n,k) \sim ?$$
The growth rate is $\Theta(n^{k-1})$. The total number of $k$-combinations (partitions where order matters) is $\binom{n-1}{k-1}$. Therefore $$ \frac{1}{k!} \binom{n-1}{k-1} \leq p(n,k) \leq \binom{n-1}{k-1}. $$ It's also easy to obtain a generating series by considering the conjugate partitions: $$ P_k = \frac{1}{1-x} \cdot \frac{1}{1-x^2} \cdots \frac{1}{1-x^k}. $$ The root with highest multiplicity is $1$, with multiplicity $k$. Partial fraction decomposition gives $$ P_k = \frac{1}{k!(1-x)^k} + \cdots. $$ The coefficient of $x^n$ in $(1-x)^{-k}$ is $\binom{n+k-1}{k-1}$. Therefore we have $$p(n,k) = \frac{1}{k!} \binom{n+k-1}{k-1} + O(n^{k-2}) = \frac{n^{k-1}}{k!(k-1)!} + O(n^{k-2}). $$
stackexchange-math
{ "answer_score": 5, "question_score": 5, "tags": "number theory, combinatorics, asymptotics" }
What is the difference and why both need in NSDate: timeIntervalSince1970 and timeIntervalSinceReferenceDate? There is two `NSDate` method, and I do not know when, which to use. Any idea? NSDate(timeIntervalSince1970: <#NSTimeInterval#>) //reference date is 1970.01.01 NSDate(timeIntervalSinceReferenceDate: <#NSTimeInterval#>) //reference date is 2001.01.01 Which one do you prefer to use, is it any compatibility concern, I mean i.e. `CloudKit` interpret date referring to 1970. Does oher system use different reference date, is this the goal to have two method for same purpose?
Any of the various `NSDate timeIntervalSinceXXX` methods return the number of seconds since some specific epoch. You choose one based on how the resulting time interval needs to be used. If you are sending the time interval to some Unix based server, it is probably best to use `timeIntervalSince1970` since times in Unix are based on January 1, 1970. If the time interval will be used to create an `NSDate` in iOS or OS X, use `timeIntervalSinceReferenceDate`. Simply look at how the time interval will be used to know which method is appropriate for your need.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -4, "tags": "ios, nsdate" }
IIS Redirect Request I have a site names WebPortal configured in IIS 8: ![enter image description here]( The bindings are: ![enter image description here]( Now, I can call the site with < Can someone help me, what I have to do, that I can call it also with < directly? Thank you very much.
You can add a redirect in the default file (index.html) in the IIS root. Adding below should work. Make sure index.html is the default file for the IIS root. <!DOCTYPE html> <html> <head> <meta http-equiv="refresh" content="0; url=/WebPortal" /> </head> <body> </body> </html>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "redirect, iis" }
Making the jquery.anythinglider responsive I am using the anythingslider and having major problems trying to make it compatabile with a mobile responsive view. Basically what I am doing is when the window resizes I change these variables: var lists = jQuery('.page-home .featured-rotator ul li'); var slider = jQuery('div.anythingSlider'); var shadow = jQuery('div.region-home-featured') to match this variable which is updated on resize: var slider_width = jQuery('.home-featured').width(); Some things are looking better in terms of the whole view container, but the slides are still transitioning at their original width, making multiple slides appear in one view. Anyone else tried to alter the width? I read in another answer about how you can set a variable which makes it responsive in one line of code but I had no luck trying to implement that. Am I doing it wrong or does it not apply to this slider?
> Adjusting Size > > For example, if you wanted to make the slides 580px wide instead of 680px wide, you just need to change some CSS. Change the width of .anythingSlider ul li to 580px, change the width of .anythingSlider .wrapper to 580px, and reduce the width of .anythingSlider 100px to 660px. < Not only do you need to resize the wrapper but also the li elements. i.e., in your case the `.featured-rotator ul li`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, css, responsive design, anythingslider" }
Properties of finite group and their subgroup. Let $G$ be a finite group and $a, b \in G$ such that $ab = ba$. Then the subgroup generated by $\langle a, b \rangle = \\{ a^i b^j : \; 0 \leq i \leq |a| -1, \; 0 \leq j \leq |b| -1 \\} $ is a subgroup of $G$. Define a map $\psi : \langle a, b \rangle \rightarrow \langle a \rangle \times \langle b \rangle$ by $a^i b^j \mapsto (a^i, b^j).$ If $b \in \langle a \rangle$, then $b = a^k$ for some $0 \leq k \leq |a| -1$. This mapping is not well defined because $\psi(ab) = \psi(aa^k) = (a^{k+1}) = (a, a^k)$ and $\psi(ab) = \psi(a^2a^{k-1}) = (a^2, a^{k-1})$. If $a \notin \langle b \rangle$ and $b \notin \langle a \rangle$. This map gives us an isomorphism and $\langle a, b \rangle \cong \langle a \rangle \times \langle b \rangle $. I feel that the arguement which is given by me is properly right or not. Please look at this. Thanks
$\renewcommand{\phi}{\varphi}$$\newcommand{\Set}[1]{\left\\{ #1 \right\\}}$$\newcommand{\Size}[1]{\left\lvert #1 \right\rvert}$$\newcommand{\Span}[1]{\left\langle #1 \right\rangle}$If $\Span{a} \cap \Span{b} \ne \Set{1}$, then $$ \Size{\Span{a, b}} = \frac{\Size{a} \cdot \Size{b}}{\Size{\Span{a} \cap \Span{b}}} < \Size{a} \cdot \Size{b} = \Size{\Span{a} \times \Span{b}}, $$ so will not have an isomorphism. To get an isomorphism, you thus _have to_ require $\Span{a} \cap \Span{b} = \Set{1}$, not just $a \notin \Span{b}$ and $b \notin \Span{a}$. In any case, it is probably advisable to start with the homomorphism, that is always well-defined \begin{align} \phi : & \Span{a} \times \Span{b} \to \Span{a, b}\\\ & (a^{i}, b^{j}) \mapsto a^{i} b^{j}. \end{align} Its kernel is $$ \ker(\phi) = \Set{(a^{i}, b^{j}) : a^{i} = b^{-j}}. $$ So you see that $\ker(\phi)$ is trivial iff $\Span{a} \cap \Span{b} = \Set{1}$, and then the argument with orders shows that $\phi$ is an isomorphism.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "abstract algebra, group theory, finite groups" }
How to investigate an error inside python unittest load_tests method? Python unittest has a method load_tests, which, in theory, can be used inside a module to define the tests to be loaded. I have tried to use the ‘do nothing’ example literally: def load_tests(loader, standard_tests, pattern): # top level directory cached on loader instance this_dir = os.path.dirname(__file__) package_tests = loader.discover(start_dir=this_dir, pattern=pattern) standard_tests.addTests(package_tests) return standard_tests and get an error: ERROR: LoadTestsFailure test_example Without specifying the `load_tests` in my module the test function correctly. How can I find out the problem I have?. More information: `this_dir` is a valid path, `loader` is a `<unittest.loader.TestLoader`` object and`pattern` is empty.
If you are using an ide like PyDev you can add a breakpoint, or alternatively you can add a try/except block: def load_tests(loader, standard_tests, pattern): # top level directory cached on loader instance try: this_dir = os.path.dirname(__file__) package_tests = loader.discover(start_dir=this_dir, pattern=pattern) standard_tests.addTests(package_tests) except Exception as e: print 'Error loading tests: %s' % str(e) return standard_tests
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "python, unit testing, python 2.7" }
How to parse Jason data from node.js console.log (response.body); I have been trying to get this right. My node.js code below returns to console log body of the response. The response has a access_token (JWT bearer). I need to have only the access_token out from the response and reuse the token for the next steps as parameter. Any suggestions appreciated. var request = require('request'); var options = { 'method': 'POST', 'url': ' 'headers': { 'Content-Type': 'application/json' }, body: JSON.stringify({ "grant_type": "client_credentials", "audience": "urn:", "client_id": "id", "client_secret": "secret" }) }; request(options, function (error, response) { if (error) throw new Error(error); console.log(response.body); });
request(options, function (error, response, body) { if (error) throw new Error(error); const stringBodytoJason = JSON.parse(body); const token = stringBodytoJason.access_token; console.log(token); }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, node.js, lambda" }
Can I throttle Liferea? After I log in, my laptop takes a really long time to load. Watching `top`, it seems like one thing that is using a ton of juice is Liferea. I do want it to sync my feeds, but I'm wondering if there's a good way to throttle it so that it doesn't use more memory than I have to spare.
If the problem primarily happens during login, one option is to delay Liferea until the rest of the login processes have quieted down: * How can I reduce the time taken to login by postponing/delaying some startup applications? If the problem is solely due to CPU usage, consider running Lifearea under cpulimit: * Can I limit the CPU usage of a single application?
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 2, "tags": "10.10, startup, memory, liferea" }
How to retrieve servletRequest.attributes on client side I am trying to test a servlet which sets attributes on ServletRequest. I am using jbehave with restTemplate and apache httpClient to send request to that servlet. Is it possible to verify what attributes were set on servletRequest? here is what I am basically trying to do in servlet: public void doGet(HttpServletRequest request, HttpServletResponse response) throws OException, ServletException{ request.setAttribute("attributeName","SIMPLE_NAME"); ... } and client: HttpEntity entity = HttpEntity.EMPTY; Map<String, String> map = new HashMap<String, String>(); restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory()); HttpEntity<String> response = restTemplate.exchange(uri, HttpMethod.GET, entity, String.class, map); so in that case I would like to verify that attributeName was set with value SIMPLE_NAME
No, this is not possible. `HttpServletRequest` attributes are a server side implementation detail that has nothing to do with the HTTP protocol. As such, an HTTP client has no knowledge of this (and shouldn't). If you want to check that the attribute was added from the server side, you can implement and register a `ServletRequestAttributeListener` in your web application.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, jsp, http, servlets, resttemplate" }
Regex: Split String with repeated end pattern Minor updates to the string as I did not phrase the problem statement clearly the first time round. I have a string: `'( 5m 3s ) John: Hi <br> Hello <br>( 6m 2s ) Jane: Hello<br>'` I am trying to match the string to extract each message as 1 line each. 1st group: ( 5m 3s ) John: Hi <br> Hello <br> 2nd group: ( 6m 2s ) Jane: Hello<br> Can someone advice on the regex for this? This is what I am trying to use currently and I am unable to tell the last break in the regex: `(.*?).*?:.*?<br>`
I take it, the actual delimiter pattern is "`<br>` followed by an opening round bracket". The generic approach to match "something followed by ..." is to use positive lookahead construct (`(?=...)`): \(.*?\).*?:.*?<br>(?=\(|$) Here we restrict our `<br>` to match only if it is followed by `(` or end of string. Please also note that parenthesis should be escaped; otherwise they define a capture group (or some other special regex construct depending on what goes after the opening one.) Demo: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "regex, apex" }
Server Cluster and Virtulisation Can I do this? I have 4 Dell 1U rackmount servers with 4GB RAM each and a 3.0Ghz processor each, over a gigabit network can I get them to act as one server in Ubuntu or something like openmosix. Second if I can do that how do I get OS virtualization such as Xen to work on the cluster so I can run 10 VPS's over on 4 servers? So I can keep adding more 1u servers adding to the total computing 'power'. Edit: Thanks for your responses, I will probably use Xen on the more powerful server then i will use the others for clustering using openMOSIX or Ubunutu's clustering.
You can configure each host to support virtual machines. However each individual VM cannot execute on more than one host simultaneously. Each VM is restricted to the resources available within its host server. You can 'Live Migrate' a VM from one server to another without bringing the VM offline. However as above, at any one time you only have the resources of a single host available to the VM. With the resources you have, you may be better served by taking the RAM and CPUs from two of the hosts and using them to stack the other hosts as fully as possible (2 x dual-processor, 8Gb hosts). Then set those more powerful hosts up to host VMs. This relies on there being enough RAM and CPU slots spare within the hosts to expand them. Hope this explanation helps. If someone does figure out a way to aggregate multiple hosts into a unified VM-hosting platform, I'm pretty sure they'll clean up. It's pretty much a virtualization holy grail ;)
stackexchange-serverfault
{ "answer_score": 1, "question_score": 0, "tags": "linux, cluster" }
Add animation to uiview moving from point A to point B I have a gesture which action moves a UIView to point B from point A. How can I add a nice transition of the UIView moving from point A to point B. I am looking at making it slowly move from point A to point B. How would I do this? At the moment to move the item I set the frame to point B.
check this code and set frame what you want [UIView animateWithDuration:0.75 animations:^{ button.frame = CGRectMake(10, 70, 100, 100); }];
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "ios, objective c, uiview" }
Identifying outlier loci in R I have done some genome scan analysis and I want to identify the outlier loci. For an expected value of the FRD equal to q = 10, a list of candidate loci can be obtained by using the Benjamin-Hochberg procedure as follows: q=0.1 L = length(adjusted.p.values) W = which(sort(adjusted.p.values) < q * (1:L) / L) candidates = order (adjusted.p.values)[w] and this is part of the outliers and my output head(candidates) [1] 3 4 9 10 13 But I need the output in a different type. I want to assign TRUE if a locus has been chosen as outlier and FALSE if it has not head (desired_output) [1] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE TRUE FALSE FALSE TRUE Any idea how can I modify the Code?
As Devon said, removing the `which` will give you `W` as a logical vector that can be used to index the _sorted_ p-values. To get a logical vector that can be used to subset the original (unsorted) values you’ll need to go a step further: candidates = is.element(1 : L, order(adjusted.p.values)[W]) However, I’m not sure this will work with your data: the name `adjusted.p.values` suggests that these values are _already_ FDR-adjusted. So you cannot/should not perform additional correction on them. If they are already adjusted, then you can get candidate loci simply by candidates = adjusted.p.values < q
stackexchange-bioinformatics
{ "answer_score": 3, "question_score": 0, "tags": "r" }
Do WD HDDs work with Linux? I'm planning on my first pc build and have decided to use a WD Blue WD10EZEX 1TB as hard drive. I've heard someone say that this drive had an encryption that made it useless with Linux. Is this true, and in that case, how do you decrypt it? Is it worth buying it for a Linux build, and if not: which HDD should I buy instead?
It's a standard SATA drive. There should be no reason you can't. Hard drives don't come encrypted out of the box.
stackexchange-askubuntu
{ "answer_score": 2, "question_score": 0, "tags": "hard drive, encryption, compatibility" }
magento how checkout register method work i'm trying to understand how checkout register method work, what i need is to now when the customer is created, because i add an **alias** attribute to the customer and i want set this attribute equal to the name when the user register in the checkout, untill now i can't found how to do this, need some help thanks
If Im understand your question correctly, you're going to want to look mostly at the class `Mage_Checkout_Model_Type_Onepage` Another option I believe would be writing your module to be triggered on a checkout event. < 1.4.1.x hook list, you can get the same list with a simple grep also... <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, magento" }
Merge two DataFrames on ranges intersections I am trying to merge two DataFrames based on the intersection of min-max values. Does anyone have a nice way to do it with Pandas? ## min max x1 ## min max x2 ##0 1 20 0.5 ##0 1 12 1.2 ##1 20 30 1.5 ##1 12 30 2.2 Desired output: ## min max x1 x2 ##0 1 12 0.5 1.2 ##1 12 20 0.5 2.2 ##2 20 30 1.5 2.2 Thx!
This gives you what you're looking for based on your data set above, but I have the feeling it may not work in more complex situations. **Code:** # Simple data frame append - since it looks like you want it ordered, you can order it here, and then reset index. df = df1.append(df2).sort_values(by = 'max')[['min','max','x1','x2']].reset_index(drop = True) # Here, set 'min' for all but the first row to the 'max' of the previous row df.loc[1:, 'min'] = df['max'].shift() # Fill NaNs df.fillna(method = 'bfill', inplace = True) # Filter out rows where min == max df = df.loc[df['min'] != df['max']] **Output:** min max x1 x2 0 1.0 12 0.5 1.2 1 12.0 20 0.5 2.2 2 20.0 30 1.5 2.2
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, pandas" }
What does "taste" mean in "The air is thick enough to taste"? < > (A woman looks at a view of Seoul shrouded by fine dust.) > > To the untrained eye, it seems like a foggy day in Seoul. **The air is thick enough to taste** and the visibility is just metres. Out of the haze emerge businessmen hurrying to work, women heading to the shops, mothers and children on the school run. Even in this fashion conscious city, they are all wearing the same thing: surgical style masks, as if scared to show their faces. I know what "the air is thick", kind of foggy and dusty, but what does it mean by "air is thick enough _to taste_ "? Is it a figurative expression?
It means just that, "taste" as in "sense with your mouth". There is no hidden meaning. It's a figurative expression that should translate easily. Normally air can be _smelled_ , but not _tasted_. Air you can taste would be unpleasantly full of particles or smoke or some substance that stays in the mouth long enough to be sensed.
stackexchange-ell
{ "answer_score": 2, "question_score": 0, "tags": "meaning in context" }
How to get wifi to connect at boot on Centos I'v got a CentOS 5.3 install that I want to connect to the wifi on boot. As the wifi adapter was installed via ndiswrapper there no /etc/sysconfig/network-scripts/ifcfg-wlan0 on the computer. I tried following this guide: < , however I ended up with strage errors about wpa-supplicant and dbus, although I am pretty sure dbus was running. Any help appreciated.
The easy way is to put the command in /etc/init.d/rc.local. You could also write a proper init script, with start and stop commands and use rcconf to integrate it into the startup/shutdown procedure.
stackexchange-serverfault
{ "answer_score": 0, "question_score": 1, "tags": "centos, boot, wifi, wpa" }
Project deployment stuck at Registering the application to run from layout I have created a Windows Store 8.1 app and I'm trying to deploy on the local machine. The project builds correctly, but it is not deployed. Visual Studio 2013 looks like it is working but on the Output window I see following lines, and the deployments gets stuck there: 1>Creating a new clean layout... 1>Copying files: Total <1 mb to layout... 1>Registering the application to run from layout... It doesn't show any errors. I have tried by rebuilding the project and restarting VS, but I'm still not able to deploy the project. Any ideas?
Renew your developer's license, then restart the computer. # Steps 1. Open any Windows Store apps project and go to the "Project" menu. 2. Select Store > "Acquire Developer License..." 3. In the Window, click "I Agree" (after reading all of the terms, conditions, and privacy statement, right?) 4. Sign in with your developer account. 5. If everything works, your developer license should be renewed. 6. Restart your computer.
stackexchange-stackoverflow
{ "answer_score": 14, "question_score": 11, "tags": "visual studio, windows store apps, visual studio 2013, windows 8.1" }
Initialize a static const array member of class in main(...) and not globally? Suppose `class Myclass { private: static const int myarray[2]; }` If I wanted to initialize `myarray` I should put the following statement in global scope: `const int Myclass::myarray[2] = {1,1};` What should I do If I want to initialize my array in main() (at some **runtime** calculated values eg at `{n1, n2}` where `n1` and `n2` are values calculated at runtime in main() based on the command line arguments)
There's nothing much you can do. You could create a member function that would initialize the values, and call it. But, if it's `static`, `private` and `const` \- then you can't even do that and out of options. You cannot _initialize_ a `static` member at run-time, you cannot access a `private` member from outside of class (unless you make friends), and you cannot change a `const` member once initialized. If you give up `const`, then you can change it. You still have to initialize at global scope, but you can change values. Note that as long as its `private`, you won't be able to access it from `main`, but you can write a wrapper function member to do that for you (or make it `public`).
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c++, arrays, class, static, constants" }
Are group profiles allowed? Say a company (or a team of contributors to a FOSS project, or whatever other group of people) wants to show off its expertise in some area. Would it be ok for it to create a profile on SO and let the people in the group use the account to answer questions?
It's ultimately up to Jeff and wouldn't be easy to enforce, but this feels contrary to what Stack Overflow is about, from using the rep earned to establish trust in the contributors to using it as a way to build personal brands. For example, if a major contributor on your team leaves for greener pastures, does your team still deserve that score? If you want to show off your team's skills, build a nice gravatar to share, use your team as part of your display name, and link to your team-mates in your profiles. I could see them going another level with Careers, allowing employers to indicate Stack Overflow users that already work there. After a few users verify the relationship, the employers careers page could show total and average rep.
stackexchange-meta
{ "answer_score": 15, "question_score": 5, "tags": "support, rules, shared accounts" }
Мнимые числа в python Добрый день, есть список, примерно такой: [(0.55773011861+0.966016929j), (1.63099590361+2.82465006773j), (2.4131580717499039+4.17971238644j)] нужно у комплексных чисел взять мнимые или реальные части, т.е получить: [0.5577301186126, 1.630812759959036, 2.413158071749903] И наоборот, что-то пока не пойму как это сделать, а в поисковике ничего толкового не нашёл. Заранее спасибо за помощь.
m = [(0.55773011861+0.966016929j), (1.63099590361+2.82465006773j), (2.4131580717499039+4.17971238644j)] [n.real for n in m] [0.55773011861, 1.63099590361, 2.413158071749904] [n.imag for n in m] [0.966016929, 2.82465006773, 4.17971238644] Думаю вы об этом
stackexchange-ru_stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "python" }
How to clear TextView on any event? I am making an app that shows a result in a TextView and I would like to clear this TextView whenever a spinner, button, segmented control (excluding my calculate button) is pressed. Is there anyway to implement this without having to put TextView clearing code in every Click event in the layout?
this may help you. public void onClick(View v) { if(v!= calculateButton) { textView.setText(""); } } All onClick events you can handle like this but for spinner event or any other layout event you have to do this textView.setText(""); Hope this help ..
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "android, xamarin.android, textview" }
nginx restart fails, but reload works I've added a new SSL certificate to my nginx server (I've done this many times before). However, when I restart nginx, no sites are working. When I run configtest, it says: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful If nginx is running and I run nginx reload, the sites and the new ssl certificate are working. Only when Nginx restarts, I get following: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful Stopping nginx: [ OK ] Starting nginx: So nothing happens after the Starting nginx. No message is written to the nginx error logs neither. If I just use "start", often it does work. What can I do to fix this and what could cause this?
How are you running restart? Via an init script or using service, or are you just running 'nginx restart' To debug nginx the correct way is to add `debug` to the end of your error_log directive under HTTP. See < But my money is on your PID file not being cleared when restart is called. First kill nginx and start it up again in foreground mode by adding `master_process off` or `daemon off` to your nginx.conf file. Run: nginx -c /etc/nginx/nginx.conf | tee ~/nginx.log now in a different terminal run: nginx -s restart And i hope you get lots of errors. You could also attach yourself to the main nginx process by running `strace -fqp <pid>` And try and see what its doing. (this I guess is a hail-mary approach but when you want to know exactly why the hell stuff isnt working, why not get all the information).
stackexchange-serverfault
{ "answer_score": 0, "question_score": 2, "tags": "nginx" }
Combining grep flags I'm trying to find lines that start with 'query' or the following sign: '>' but I don't know how to do this. If this is the dataset: query=345 query=4565 brink=980 >ehlhdhdk >blonk I want to only preserve the lines 1,2,4 and 5. I have tried: `grep -e 'query=' filename.txt||grep -F '>' filename.txt > newfile.txt ` and: `cat filename.txt | grep -e 'query='||grep -F '>' > newfile.txt`. But these do not work and they do not output the newfile.txt and instead they just output into the terminal.
Use multiple patterns with option `-e`: grep -e '^>' -e '^query' file Output: query=345 query=4565 >ehlhdhdk >blonk
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "grep, flags" }
How do I call Ruby script from a shell script? I am trying to write a watchdog for a Ruby application. So far, I have a cron job which is successfully calling a shell script: #!/bin/sh if ps -ef | grep -v grep | grep adpc.rb ; then exit 0 else NOW=$(date +"%m-%d-%Y"+"%T" ) echo "$NOW - CRITIC: ADPC service is down! Trying to initialize..." >> che.log cd lib nohup ruby adpc.rb & exit 0 fi This code runs correctly from command line, but I am not able to make the shell script execute the Ruby script when called from a cron job. Please any help would be appreciated. 1. The Ruby file has `+x` permissions. 2. The nohup.out file is empty. **Solution** : replace bare "ruby" command with full path (which ruby output). Thanks to all for the replies =)
This is usually caused by an incorrect environment. Check the Ruby output in the created `nohup.out` file and log the stderr of nohup itself to a file. It's frequently solved by starting the script with: #!/bin/bash source ~/.bash_profile source ~/.bashrc This will ensure that you run with `bash` instead of `sh`, and that any settings like PATH you've configured in your init files will be set.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby, shell, nohup" }
No 'Access-Control-Allow-Origin' header is present on the requested resource $http({ method: 'POST', url: ' headers: { 'Content-Type': 'application/json', 'Accept': 'application/json'}, data: JSON.stringify(data) }).then(function (response) { $scope.myData = response.data.message; this is working only when I enable CORS Filter plugin in chrome.Searched a lot for solution. None of them are working properly. please help.
Solved....! I hosted the client on the same domain on which the web service is running. Now client and server are on the same domain.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "javascript, angularjs, json" }
Channel Views from YouTube API? I am looking to get the amount of channel views a YouTube channel has through their API. I have been looking through the documentation and been googling but I cannot seem to find how. Channel views aren't being shown on actual channels anymore but they are being shown on the mobile site (example) and also there are sites which are tracking them still (example) so I assume that they must be available via the API. If anyone knows how they are available (preferably outputted with JSON) I would appreciate it, thanks.
I managed to figure it out for anyone wanting to know, this is using `PHP` and `JSON`, using Google's youtube channel as an example. The URL is: < To parse it you would do: $json = file_get_contents(" $data = json_decode($json, true); echo 'Channel Views: ' . $data['entry']['yt$statistics']['viewCount'];
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "php, json, youtube, youtube api" }
D3 leaves wrong elements on screen My d3 selection starts with a large dataset, appending a circle to my SVG for each element in it and setting the ID of the circle element to match the ID of the data item it represents. Then, I call `.data()` on that same selection, passing in a smaller subset of the original. As expected, the number of circles on the screen after I do so matches the number of items in the smaller dataset. However, when I inspect the elements on the screen, their IDs do not match the IDs of the items in the new dataset. Why might this be?
If you don't pass a key function to data, the data is associated to existing elements via their position. You probably want something like .data(data, function(d) { return d.id; }); From the documentation: > To control how data is joined to elements, a key function may be specified. This replaces the default by-index behavior; the key function is invoked once for each element in the new data array, and once again for each existing element in the selection.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, d3.js" }
Windows - C#- Directory.Move Is it guaranteed that Directory.Move only renames and not copy/delete as long as it is on the same logical drive?
In fact `Directory.Move` fails if you attempt to move a directory to a different volume. If you want to perform such a move you have to do the Copy/Delete yourself. I think you can safely assume that `Directory.Move` will only ever succeed if the operation can be performed without copying files.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "c#, windows, io" }
Promise request after finishing one by one I've used `Promise.all()` to get every request. But I have got an error message from the server that I requested too many calls in a short period because the number of array I requested is over 100. How can I improve my Promise codes to calling a next request after finishing the first request? public getProfits(data) { return Promise.all( data.map((obj) => { return this.getProfit(obj.symbol).then(rawData => { obj.stat = rawData return obj; }); }) ).then(data => { this.data = this.dataService.ascArray(data, 'symbol') }) }
If your environment allows for using async/await, the simplest solution might be this: public async getProfits(data) { for(const obj of data) { obj.stat = await this.getProfit(obj.symbol); } this.data = this.dataService.ascArray(data, 'symbol'); } Otherwise you might need to do this: public getProfits(data) { let p = Promise.resolve(); for(const obj of data) { p = p.then(() => { return this.getProfit(obj.symbol).then(rawData => obj.stat = rawData); }); } p.then(() => { this.data = this.dataService.ascArray(data, 'symbol'); }); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "angular, asynchronous, promise, angular promise" }
Finding uppercase characters in a user's string and counting them i wanted to get the uppercase characters in the string and also there count package TEST; import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern; public class case_test { public static void main(String agrs[]) { String str1 = "", regx; regx = "[A-Z]+"; Scanner sc = new Scanner(System.in); Pattern pattern = Pattern.compile(regx); Matcher matcher = pattern.matcher(str1); int count = 0; System.out.println("ENTER A SENTENCE"); str1 = sc.nextLine(); while (matcher.find()) System.out.println(str1.substring(matcher.start(), matcher.end()) + "*"); count++; } } I wanted to get the uppercase characters in the string and also their amount.
You can use string intersection (Intersection of two strings in Java) using originalString & originalString.toUpperCase().
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, regex" }
Data conversion in LABVIEW I am trying to convert an analog value to a digital value (8 bit A/D converter, input range 0-5V ). I have used the formula (input*255/5) to convert to digital, then i have used digital to binary vi to convert this digital value to 8 bits. The problem here is the data type mismatch between my output from the formula, which is a double data type and the input of the vi which is a digital data type, so how to solve this problem ? Thank you in advance
The digital data you mention is On/OFF. The example below illustrates the type of data that is entered and output from _digital to binary.vi_ ![enter image description here]( On the left hand side is three samples of digital data in continuous signal format from three separate sources, (signal 0, signal 1, signal 2). The first sample gives binary 2 (010). As you can see this would be not be of any use for a single signal. If you still want to do the above, you could use _DWDT Boolean Array to Digital_ as illustrated below: ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "type conversion, labview" }
Habiter (dans) cette maison > Il y a quatre ans que j'habite dans cette maison. > > Il y a quatre ans que j'habite cette maison. Y a-t-il des différences entre les deux phrases ? Laquelle est la plus correcte et laquelle la plus courante ?
Selon le TLFi, habiter s'emploie aussi bien en forme transitive qu'intransitive bien que la version 8 du dictionnaire de l'Académie (1932 si je ne me trompe pas) ne reconnait que la forme transitive. On peut donc utiliser les deux formulations, néanmoins une analyse Google Ngram donne une nette préférence pour la forme transitive _« habiter une maison »_.
stackexchange-french
{ "answer_score": 3, "question_score": 0, "tags": "usage, prépositions" }
Hide content from anonymous without modifying master page I want to hide sections in seattle.master, but without modifying the master page in office 365. How can I achieve that? I know I can inject javascript in my master page based on the user that's logged it, but this functionality is only client side and users will be able to go around this and view the sections I need to hide anyway. how do I do it?
How about adding only webParts set with a Target Audience? ![]( (source: netdna-cdn.com)
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 3, "tags": "permissions" }
Translating php to vba please I need some help converting this php line into vba I don't need to validate $pre, I just need to compute the changes of any variables in this line (e.g: $dx+=$ay..) `$pre = $dy % 2 && ($dx += $ay %2 ? 0.5 : -0.5);` so basically this is my attempt: If (dy Mod 2) Then If ((dx + ay) Mod 2) Then dx = dx - 0.5 Else dx = dx + 0.5 End If End If I ran some tests and it I don't get the same results with this vba code
I think it should be: If (dy Mod 2) Then If (ay Mod 2) Then dx = dx + 0.5 Else dx = dx - 0.5 End If End If
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, vba" }
CSRF-protection using authentication token in HTTP header? I'm working on a web application which stores an authentication token in a cookie. The only CSRF-protection is referrer checking. I am considering improving this by moving the authentication token from cookies to a custom header, such as X-AuthToken. The application is a single page application created using JavaScript. I believe this should be a robust protection against CSRF-attacks, because if an evil site forces a users browser to do a HTTP POST, the auth header won't be included and the request will fail. The auth token is generated on a per-session basis. Am I right that this would offer CSRF protection or am I missing something?
**Short answer** : yes, it would be secure if correctly implemented (long enough, random, unique tokens, one per session, etc). **Long answer** : If you decide to add a custom header to the requests sent to the server using JavaScript code, it is similar to sending an anti-CSRF value in the POST parameters (the more often used approach). POST /test Host: www.example.com X-AuthToken: unique_random_value p1=val1&p2=val2 or POST /test Host: www.example.com p1=val1&p2=val2&x-authtoken=unique_random_value So it's up to you to decide which option is easier to implement, but both should work in a secure manner.
stackexchange-security
{ "answer_score": 2, "question_score": 2, "tags": "web application, csrf" }
Why is this linear program infeasible in GLPK? I have the following problem set up in glpk. Two variables, p and v, and three constraints. The objective is to maximize v. p >= 0 p == 1 -v + 3p >= 0 The answer should be v==3, but for some reason, the solver tells me it is infeasible when using the simplex method, and complains about numerical instability when using an interior point method. This problem is generated as a subproblem of a bigger problem, and obviously not all subproblems are as trivial or I would just hardcode the solution.
Because, for some reason, by default, columns variables are fixed at 0 (GLP_FX) and not free. I don't see how that default makes sense.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "glpk" }
remove duplication I have a class contains 10 methods which are doing almost the same things apart from one key event. Two examples are given below: Public String ATypeOperation(String pin, String amount){ doSomething(); doMoreStuff(); requestBuilder.buildATypeRequest(pin, amount); doAfterStuff(); } Public String BTypeOperation(String name, String sex, String age){ doSomething(); doMoreStuff(); requestBuilder.buildBTypeRequest(name, sex, age); doAfterStuff(); } As you can see from the above methods, they are similar apart from calling different methods provided by requestBuilder. The rest 8 are similar too. There is a lot duplicated code here. I feel there is a better way to implement this, but don’t know how. Any ideas and suggestions are appreciated. Thanks, Sarah
Use something like `RequestBuilder`, that accepts all these kinds of parameters: public RequestBuilder { // setters and getters for all properties public Request build() { doStuff(); Request request = new Request(this); doAfterStuff(); return request; } } and then new RequestBuilder().setAge(age).setName(name).build();
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "java" }
How do I add and view *.ecw raster images in QGIS 2.2.0 on Ubuntu 14.04 LTS How do I make ECW files work in Quantum GIS on my Ubuntu 14.04?
By now, wating for ubuntuGIS repository updating for "trusty", I'd advise this procedure (python must be already installed): 1. Download (after "sign up") the SDK 5.0 from here; 2. Be careful to the licence; 3. Install/compile the SDK in a directory (e.g./usr/local/ecwjp2_sdk); 4. Download GDAL/OGR source from here; 5. Install/Compile GDAL with the following syntax: .`/configure --with-python=yes --with-ecw=/usr/local/ecwjp2_sdk` 6. Install Qgis from standalone version or from source; That's all!!
stackexchange-gis
{ "answer_score": 1, "question_score": 1, "tags": "qgis 2, ubuntu, ecw" }
What does operator ~= mean in Lua? What does the `~=` operator mean in Lua? For example, in the following code: if x ~= params then
the `~=` is `not equals` It is the equivalent in other languages of `!=`
stackexchange-stackoverflow
{ "answer_score": 63, "question_score": 46, "tags": "lua, operators" }
Select same columns from multiple tables I have a MySQL database with multiple tables and those tables contain multiple columns that are equal. For example: `table1` contains `productid`, `price`, and a couple of columns specific for that table. `table2` contains `productid`, `price`, and a couple of different columns (not in `table1`) `table3` also has `productid`, `price` and more unique columns, etc etc. Is it possible to select `productid` and `price` from all three tables in one query and get the result in one output? One way would be to select into some temporary table, but is there an easier/better/nicer way?
using the union : select productid,price from table1 union select productid,price from table2 union select productid,price from table3
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 7, "tags": "mysql" }
Calling characters from a string In JS I am currently trying to grab a 9 character string from a title, the start of the list is always "BC-" and then it is always six digits following, so for instance a complete thing would look like - "BC-004352" my problem is that I can grab everything after the "BC-" however if there is something after that like "Words Words BC-004352 Words words" it then grabs the "BC-004352 Words Words". This will mess up my program, so is their any way of only capturing the "BC-004352"? How could I then make the script self executable as at the moment it is running of a button and that isn't helpful <!--BC-Check six digit--> <script type="text/javascript"> function bc_check() { var str = "FUCKCKCKKC BC-040300 Has broken"; var res = str.substring(str.indexOf("BC-") + 0); document.getElementById("recognize").innerHTML = res; } </script>
Or you can do this with Regular Expressions: const testString = "FCKCKCKKC BC-040300 Has broken"; const regex = /.*?BC-(\d+).*?/; //Capture any number of digits following BC- const matches = testString.match(regex); //Get the match collection console.log(matches[1]); //Match collection index 1 holds your number
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript" }
AJAx HTTP ERROR, can't add views to Drupal 7 site, same behavior on 2 different sites I get these errors when creating views at every step, in Chrome errors says 200 in Firefox says 500... I can get as far as having the view created, by ignoring the error, but then I can't add any fields, so it renders my Drupal site useless basically. I have played around with Jquery versions and no solution seems to work. Additionally, this behavior can be seen on 2 different website, identical... Sites are both up to date Drupal 7, on status report everything is immaculate, they both run Boostrap theme but the admin Theme is Bartik ![enter image description here](
It was a problem with the hosting company....but they were great and changed to PHP 5.4(native) right away, fixed it. Great job namecheap.com hosting, as usual, they are actually really good
stackexchange-drupal
{ "answer_score": 0, "question_score": 0, "tags": "ajax, javascript" }
Riemannian Volume Form There is a following exercise in my text: > Let $S^n$ be $n-$ dim sphere in $R^{n+1}$ with inclusion function $i:S^{n}\to R^{n+1}$. Let $$\omega=\sum_{i=1}^{n+1}(-1)^{i-1} x_i dx_1 \wedge... dx_{i-1}\wedge dx_{i+1}\wedge ... \wedge dx_{n+1}.$$ Prove that $i^*\omega \in \Omega^n(S^n)$ is Riemannian volume form on $S^n$. I treied to manually compute this expression and the one which uses definition of Riemannian volume form when they act on some vectors in $T_xS^n$ but things gets complicated when $n$ is large and involves sum of matrix determinants which I don't know how to resolve. I managed to prove the result for small values of $n$. How would you go with the general case?
It's not so hard once you show that the volume form of a submanifold $N^{n-1}\subset M^n$ of codimension 1 is given by $\mathrm d vol_N(x) = (\iota_Z \mathrm{d}vol_{M})(x)$ for $x\in N$, where $Z$ is a normal vector field to $N$, $\mathrm d vol_M$ is the Riemannian volume form of $M$ and $\iota_Z \omega$ denotes the interior product. In your case $Z(x) = x$ gives you a normal vector field when restricted to $N = S^{n-1}$ and for $M = \mathbb R^n$ we have $\mathrm d vol_{\mathbb R^n} = dx^1 \wedge \dots \wedge dx^n$. So \begin{align} \mathrm d vol_{S^{n-1}}(x) &= (\iota_Z dx^1 \wedge \dots \wedge dx^n)(x) \\\ &= \sum_{i=1}^{n-1} (-1)^{i-1} x_i \; dx^1 \wedge \dots \wedge dx^{i-1}\wedge dx^{i+1}\wedge \dots\wedge dx^{n} \end{align} for $x\in S^{n-1}$.
stackexchange-math
{ "answer_score": 10, "question_score": 9, "tags": "differential geometry, differential forms" }
Using Function from Model Users.php (model): ... public function hashPassword($password){ $hashed = hash('sha256', $password . self::HASH_CODE); return $hashed; } ... UserIdentity.php ... else if($user->password!==Users::hashPassword($this->password)) ... Error: Non-static method Users::hashPassword() should not be called statically, assuming $this from incompatible context
You'll need to define `hashPassword()` as a static function in order to call it with `Users::hashPassword()`: public static function hashPassword($password) { ... Otherwise, you can create an instance of the `Users` class and call it in a non-static manner: $users = new Users(); $users->hashPassword($password); In a strictly-`yii` sense, you may be able to call it with the following (depending on your setup): Yii::app()->Users->hashPassword($password);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, yii" }
Codable with NSOrdered set? It looks like NSOrdered does not support the the Codable protol. I'm using codable to parse data with alamofire and coredata.What is the way to achieve that please ? Txs for help ! :) self.photos = try values.decodeIfPresent([Photo].self, forKey: .photos)
JSON does not have ordered sets. It just has arrays. So you need to convert the array into an NSOrderedSet by calling its initializer: self.photos = NSOrderedSet(array: try values.decodeIfPresent([String].self, forKey: .photos) ?? []) (That said, I would strongly recommend getting rid of NSOrderedSet. It's a mess of a data structure, and plays poorly with Swift. You're almost always better wrapping up an Array and just controlling when you insert into it. If you believe there's a performance difference, you should do a lot of profiling on your actual data before assuming that.)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "swift, codable" }
How do I add a number to every single element in python? How do I add a number in my element? lets say I want to add 10 to every single element in my array I want my input to be [1,2,3,4,5] and my output to be [11,12,13,14,15] This is what I came up with so far def func(z): numbers = [1, 2, 3, 4,5] num = 10 for i in z: numbers.append(i + num) i = numbers[-2:] return i This prints 5,20 instead of 14 and 15.
Using a list comprehension is a fast, compact way of getting the answer that you want. It's a useful tool for you to learn to write better Python. number_list = [1, 2, 3, 4, 5] def add_num_to_each(num, number_list) return [ii + num for ii in number_list] print(add_num_to_each(10, number_list)) >>> [11, 12, 13, 14, 15]
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 5, "tags": "python, arrays, function, for loop" }
Add a normal distribution line in histogram I've met a weird problem that I can't figure it out totally. I'm supposed to add a normal distribution line upon a histogram.I input every step's code but after typing lines function there's no response. I don't know what's wrong.Hope anyone help me! MY code are: grades<-mydata$Exam1 hist(grades,breaks=20,freq=T) #A correct histogram comes out. mean(grades,na.rm=T) #there is NA in the column so I remove it when calculating mean. [1] 75.15278 sd(grades,na.rm=T) [1] 16.97443 x<-seq(0,100,0.01) y<-dnorm(x,mean=mean(grades,na.rm=T),sd=sd(grades,na.rm=T)) lines(x,y)#and there's no response!no line showed up! Is anything wrong with my code? Thanks for your help!
I assume it's R code - then try this: grades <- mydata$Exam1 hist(grades, prob=TRUE) curve(dnorm(x, mean=mean(grades), sd=sd(grades)), add=TRUE) Note that if you compare normal distribution to the histogram, you probably want histogram to display probabilities rather than frequencies.
stackexchange-stackoverflow
{ "answer_score": 21, "question_score": 7, "tags": "r, lines" }
Return List<this> Is it possible to use `this.GetType()` as the type of a `List`? I have the following `class` that is inherited by several objects: public class MainRepository { // ??? should be the type of this public List<???> GetAll() { return new List<???>(); } } I know it can be done as a generic method like this: public List<T> GetAll<T>() { return new List<T>(); } But I wonder if it can be done without explicitly defining the type in the calling method.
I believe you could do this, if that is a viable option for you?: public class MainRepository<T> { public List<T> GetAll() { return new List<T>(); } } If I'm not mistaken, that should allow you to call the method without specifying the type in the method-call (though you obviously have to specify it for the class instead). I'm assuming you want to do this in order to have some general generic repository, which can be sub-classed, or something similar? You could then do something like (just a rough idea): public class BaseRepo { } public class MainRepository<T> : BaseRepo where T : BaseRepo{ public List<T> GetAll(){ return new List<T>(); } }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, generics, inheritance, .net 4.5" }
<wheel user> is not in sudoers file for NetBSD 7.0 I installed `sudo` on NetBSD 7.0 using `pkg`. I copied `/usr/pkg/etc/sudoers` to `/etc/sudoers` because the docs say `/etc/sudoers` and possibly `/etc/sudoers.local` is used. I uncommented the line `wheel ALL=(ALL) ALL`. I then added myself to the `wheel` group. I verified I am in `wheel` with `groups`. I then logged off and then back on. When I attempt to run `sudo <command>`, I get the standard: jwalton is not in the sudoers file. This incident will be reported What is wrong with my `sudo` installation, and how can I fix it?
sudo(8) as installed by pkgsrc is configured to look in /usr/pkg/etc/sudoers. It will not look at /etc/sudoers. If you're updating your access control via visudo(8), it should be modifying the correct file. If you're not updating the sudoers file via visudo(8), please start doing so.
stackexchange-superuser
{ "answer_score": 3, "question_score": 1, "tags": "permissions, sudo, netbsd" }
Can I run docker diff from a container on the same host as the container I want to run the diff on? I have two containers running on a host. When I'm in container A I want to run a diff on container B compared to it's image to see what has changed in the filesystem. I know this can be ran easily from the host itself, but I'm wondering is there any way of doing this from inside container A, to see the difference on container B?
You can run any docker commands from within container which will communicate with host docker daemon if: * You have access to docker socket inside container * You have docker client inside container You can achieve first condition by mounting docker socket to container - add following to your `docker run` call: `-v /var/run/docker.sock:/var/run/docker.sock`. The second condition depends on your docker image. If you are running bare Ubuntu image you can have shell inside container which will be able to do what you want with following command: `docker run -it -v /var/run/docker.sock:/var/run/docker.sock ubuntu:latest sh -c "apt-get update ; apt-get install docker.io -y ; bash"`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "linux, bash, shell, docker" }
Appending char/wide char to the c-string #ifndef UNICODE #define UNICODE #endif #include <stdio.h> #include <Windows.h> int main(void) { TCHAR greeting[50] = L"Hello world"; TCHAR exclamation=L'!'; //???? wprintf("%s",greeting); return 0; } What should be done, so that the output would be greeting with the exclamation mark? Instruction `greeting[wcslen(greeting)]=exclamation;` fulfils the remaining part of array with Chinese characters. PS. I need to output only "greeting" variable, so the code except of `//????` is unalterable.
At `greeting[wcslen(greeting)]` there is a null terminator character `L'\0'`, signaling the end of the string. Whatever is besides that point is undefined (chinese characters seems to be in your case). What you need to do is _move_ such null terminator to the next position in the array. TCHAR greeting[50] = L"Hello world"; TCHAR exclamation=L'!'; greeting[wcslen(greeting)+1] = L'\0'; greeting[wcslen(greeting)] = exclamation; Note that you have to do it in that order, or otherwise `wcslen` would give a different (indeterminated) value. If you used the standard append functions, this would be done for you.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "c" }
Cloning PostgreSQL database I want to have a clone of a postgresql database. If I copy the entire data directory from one machine and replace another machine's data directory with it, will there be any problems? both of them have the same OS, btw (CentOS)
Certainly if you stop the server and then copy it, that's fine. If you don't, the cloned server will have to do recovery, which isn't so good. Or just use pg_dumpall to produce a script to recreate the data on the new machine.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "linux, database, postgresql, clone" }
Dependency Types - MIPS/Pipelining I need to determine the dependency types present in the following block of instructions. Unfortunately, the book I'm using is extremely unclear as to how to go about this. This is what I came up with: SW R16, -100(R6) --> RAW on R16 LW R4, 8(R16) --> WAR on R16 ADD R5, R4, R4 --> RAW on R4 Am I on the right track? Can the first instruction have a Read-After-Write dependency type even though it is the first instruction in the pipe?
SW R16, -100(R6) --> possible RAW on R6 and/or R16 LW R4, 8(R16) --> none: R16 was read in the previous instruction, so it can be read safely here ADD R5, R4, R4 --> RAW on R4
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "dependencies, mips, pipeline" }
Help in understanding a simple proof. Let $Ax + By + C = 0$ be a general equation of a line and $x\cos \alpha + y\sin \alpha - p = 0$ be the normal form of the equation. Then, $${-p\over C } = { \cos \alpha\over A} = { \sin\alpha\over B}\tag{1}$$ $${p\over C } = { \cos \alpha\over -A} = { \sin\alpha\over -B} \tag{2}$$ $${p\over C } = { \cos \alpha\over -A} = { \sin\alpha\over -B} = {\sqrt{\sin^2 \alpha + \cos^2 \alpha}\over \sqrt{A^2 + B^2}} = {1\over \sqrt{A^2 + B^2}} \tag{3}$$ $$\therefore \bbox[ #FFFDD0, 10px, Border:2px solid #DC143C]{p = {C\over \sqrt{A^2 + B^2}}, \cos \alpha = {-A\over \sqrt{A^2 + B^2}},\sin\alpha = {-B\over \sqrt{A^2 + B^2}}} $$ I did not get the $(3)$ part. Where does $\displaystyle{\sqrt{\sin^2 \alpha + \cos^2 \alpha}\over \sqrt{A^2 + B^2}}$ come from ?
I'd do it differently: since $A$ and $B$ are not both zero, we can divide by $-\sqrt{A^2+B^2}$, getting $$ \frac{-A}{\sqrt{A^2+B^2}}x+\frac{-B}{\sqrt{A^2+B^2}}-\frac{C}{\sqrt{A^2+B^2}}=0 $$ and we can choose $\alpha$ so that $$ \begin{cases} \cos\alpha=-\dfrac{A}{\sqrt{A^2+B^2}}\\\\[6px] \sin\alpha=-\dfrac{B}{\sqrt{A^2+B^2}} \end{cases} $$ and set $$ p=\frac{C}{\sqrt{A^2+B^2}} $$ * * * For the mysterious formula, observe that, if $$ k=\frac{\cos\alpha}{-A}=\frac{\sin\alpha}{-B} $$ then $$ A^2k^2=\cos^2\alpha,\quad B^2k^2=\sin^2\alpha $$ so also $$ (A^2+B^2)k^2=1 $$ and $$ |k|=\frac{1}{\sqrt{A^2+B^2}} $$ Of course one needs to be _very_ precise about the choice of $p$, using this method. It is implied that $p<0$ if $C<0$ and $p>0$ if $C>0$; a special case should be made when $C=0$. The method above is independent of these considerations.
stackexchange-math
{ "answer_score": 1, "question_score": 4, "tags": "analytic geometry" }
ldap query error handling I am querying LDAP for a user `HomeDirectory`, which I am able to do fine and write it to a textbox. How do I handle errors when that user doesn't exist in LDAP? If TextBox2.Text = "" Then MsgBox("Please enter a Network ID") TextBox2.Focus() Exit Sub End If Dim yourUserName As String = TextBox2.Text Dim ADSearch As New DirectorySearcher() Dim de As DirectoryEntry = GetDirectoryEntry() ADSearch.SearchRoot = de ADSearch.Filter = "(sAMAccountName=" & yourUserName & ")" 'ADSearch.PropertiesToLoad.Add("homedirectory") Dim ADResult As SearchResult = ADSearch.FindOne() Dim ADEntry As DirectoryEntry = New DirectoryEntry(ADResult.Path) TextBox1.Text = (ADEntry.Properties("homedirectory").Value.ToString)
Why not just check the `ADResult`, and then process accordingly? Dim result As SearchResult = ADSearch.FindOne() If result Is Nothing Then Return "Not a valid Active Directory Account" Else Dim ADEntry As DirectoryEntry = New DirectoryEntry(ADResult.Path) TextBox1.Text = (ADEntry.Properties("homedirectory").Value.ToString) End If If you want to handle lower level LDAP errors, just wrap your search code in a `Try`...`Catch`.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "vb.net, active directory, ldap" }
What should be the php/MySql query for sending and receiving data from the following database design this is my database design for a ques n ans page. A user can ask as many questions, receive as many answers to a single question. ie. one question and many answers. All i want to know is _mysql query_ that'll be required for fetching the answers for a particular database. Also the _php code_ that'll be involved in sending and thereby retrieving the results. db design: create table user ( name varchar(14) not null. id int(11) auto_increment; CREATE TABLE questions ( question_id int(11) NOT NULL AUTO_INCREMENT, user_id int(11) references user(id), title varchar(255), content text, PRIMARY KEY (question_id); CREATE TABLE answers ( answer_id int(11) NOT NULL AUTO_INCREMENT, question_id int(11) REFERENCES questions(question_id), content text, PRIMARY KEY (answer_id);
If you already know the ID for the particular question, then all you need to do is select all the records in `answers` with that question_id. If you're selecting based on some other attribute of the question, then you'd select that question from `questions` with `LEFT JOIN answers on questions.question_id = answers.question_id` in order to get all the relevant answers. As for PHP code, read up on mysqli or PDO. This should be a textbook case of running a query and then fetching the results. Check out example 1 on this page for how to create a DB connection and example 1 on this page for a very simple query example. But note that if you're searching on a user-provided string, a simple query like that creates huge security holes! You should use the prepare() function instead.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "php, mysql, database" }
C++ Make Lower Function I wrote a simple function in c++ to turn a string in to all lower case letters using chars and iterating through each char in the string. Can someone please explain why when I run this program in the console window, I get an output in addition to my original input if the function never references cout. #include <iostream> #include <cctype> #include <cstdlib> using namespace std; string makelower(string text) { int iter = 0; char cha; string newtext; while (iter < text.length()) { cha = text[iter]; cha = tolower(cha); newtext+=cha; iter++; } return(newtext); } int main() { string a; cin>>a; a = makelower(a); cout<<a; }
putchar writes a character out to stdout <
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "c++, string, tolower" }
Show that $E$ is the splitting field of some polynomial in $F[x].$ Let $K$ be the splitting field of some polynomial over $F$. If $E$ is a field extension contained in $K$ and $[E:F]=2,$ I want to show that $E$ is the splitting field of some polynomial in $F[x].$ I believe I can use something related to Galois theory to deal with this but I am confused here.
Since $K$ is the splitting field of a polymomial over $F$, it is Galois over $F$. Thus there is a correspondence between the intermediate fields of $K/F$ and the subgroups of $Gal(K/F)$. Let $N \subseteq Gal(K/F)$ be the subgroup corresponding to $E$ under the Galois correspondence. Note that $|Gal(K/F)| = [K:F] = [K:E][E:F] = 2[K:E]$. But $[K:E] = |N|$. So \begin{align*} [Gal(K/F):N] &= \frac{|Gal(K/F)|}{|N|}\\\ &= \frac{|Gal(K/F)|}{[K:E]}\\\ &=2. \end{align*} So $N$ is a normal subgroup of $Gal(K/F)$. But then this implies that $E$ is Galois over $F$. And so $E$ is the splitting field of a polynomial in $F[x]$.
stackexchange-math
{ "answer_score": 1, "question_score": 3, "tags": "abstract algebra, galois theory" }
Updating information from the vertex shader In the vertex shader program of a WebGL application, I am doing the following: Calculate gl_Position P using a function f(t) that varies in time. My question is: Is it possible to store the updated P(t) computed in the vertex shader so I can use it in the next time step? This will be useful for performing some boundary tests. I have read some information on how textures can be used to store and updated vextex positions, but is this feasible in WebGL, since even texture access from a vertex program is unsupported in OpenGL ES 1.0? For a more concrete example, let us say that we are trying to move a point according to the equation R(t) = (k*t, 0, 0). These positions are updated in the vertex shader, which makes the point move. Now if I want to make the point bounce at the wall located at R = (C, 0, 0). To do that, we need the position of the point at t - dt. (previous time step). Any ideas appreciated. Regards
In addition to the previous answers, you can circumvent vertex texture fetch by PBOs, but I do not know, if they are supported in WebGL or GLES, as I have only desktop GL experience. You write the vertex positions into the framebuffer. But then, instead of using these as vertex texture, you copy them into a vertex buffer (which works best via PBOs) and use them as a usual vertex attribute. That's the old way of doing transform feedback, which I suppose is not supported.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 5, "tags": "glsl, webgl" }
Converting a List type<Integer> to String[] Array using method reference I am trying to convert a List of type Integer to an Array of Strings. I want to do it using the method reference passed to toArray() as below, which must work somehow since my CS professor showed this to us in class. List<Integer> strawberry = IntStream.rangeClosed(1, 100) .boxed().collect(Collectors.toList()); String[] plum = strawberry.toArray(String[]::new); However I got the following error message: Exception in thread "main" java.lang.ArrayStoreException: arraycopy: element type mismatch: can not cast one of the elements of java.lang.Object[] to the type of the destination array, java.lang.String at java.base/java.lang.System.arraycopy(Native Method) How can this be fixed? I know there are easier ways of doing this, but I want to learn how to use this method correctly. Thanks.
You need to first map to a string stream: String[] plum = strawberry.stream() .map(String::valueOf) .toArray(String[]::new); But you can do both in one step: String[] plum = IntStream.rangeClosed(1, 100) .mapToObj(String::valueOf) .toArray(String[]::new);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "java, arrays, string, java 8, java stream" }
How to add DropDownList in MVC I'm new one for MVC. I have a two tables in my database call 'company' and 'Department' So One company has many Department. In my project I add my data base to Model as ADO.net Entity Model. I create primary key and Forging key. So when I create a new Department I want to show the company list in the drop down list. I don't know how to do it? I try like this @Html.DropDownListFor(model => model.tblCompany.PKComID, Model.tblCompany) but It it not working How can I do it?
Assuming you have something like this public class Company { public int PKComID { get; set; } public string Name { get; set; } } Populate a `ViewBag.AllCompanies` property in your controller. Then use this code in your view: @{ var allCompanies = ViewBag.AllCompanies as IEnumerable<Company>; } @Html.DropDownListFor(n => n.tblCompany.PKComID, new SelectList(allCompanies, "PKComID", "Name"))
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c#, asp.net mvc" }
How does Eclipse know whether the Swing Designer is available for a JFrame-derived class? I am using Google Web Toolkit's Swing Designer in Eclipse to create and edit components like custom JFrame's. The problem is that the Design View is sometimes broken for my class (probably because the project is also being edited by another person in a different platform), and I want to know how to restore it. In other words, I am able to edit the code for a custom JFrame, but I cannot use the visual editor to modify the JFrame anymore. I notice that the icon for my JFrame's source code also changes to a normal java-source-code icon when the design view is broken. In which file does Eclipse keep track of what JFrame's can be edited using the visual editor and which ones not? Thanks in advance.
If you want to open a file in the designer, but that's not happening by default, then use right-click _Open With>WindowBuilder Editor_.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 0, "tags": "java, eclipse, swing, user interface, gwt" }
Create GRASS 7.6 environment in PyQGIS I am working on PyQGIS in QGIS 3.10 (Windows). My goal is to create a GRASS environment to be able to run modules like `r.in.gdal` among others. but i can't find the way to execute the modules. I have never worked with GRASS in PyQGIS modules. I tried to use `processing.run` but it returns error since it can't find the module.
Have a look at this topic: Calling GRASS modules in pyQGIS? You can easily call GRASS modules into PyQGIS but I don't think you can call GRASS add-ons that are not already available in the QGIS processing toolbox.
stackexchange-gis
{ "answer_score": 2, "question_score": -1, "tags": "pyqgis, qgis grass plugin" }
mv filename .. (Where will the file go?) [root@localhost /home/chankey/Desktop/Downloads]# ls myproject.plx [root@localhost /home/chankey/Desktop/Downloads]# mv myproject.plx .. I had the file in Downloads folder. I used mv command as shown above and now I can't see the file. It is neither in the Desktop folder nor in the Downloads.
Check if `/home/chankey/Desktop/Download` for some reason would be a symlink to for example `/home/chankey/Download` ... If so, it may be that that the file is in `/home/chankey/`
stackexchange-unix
{ "answer_score": 12, "question_score": 5, "tags": "rename" }
When does acceleration due to gravity equal positive/negative? For example a projectile is launched at an angle. What would $a$ in $y=vt +.5at^2$ be? Let's say I choose up to be positive. How do you not confuse yourself whether to use positive or negative $a$?
It depends on what direction you assign to be positive in your coordinate system. To avoid confusion, just remember which direction acceleration is acting and which direction you assigned to be positive.
stackexchange-physics
{ "answer_score": 3, "question_score": 0, "tags": "gravity, newtonian gravity, kinematics, projectile, coordinate systems" }
How to calculate multiple calc() on LESS? How I can get only result from calc ? @winh: `$(window).height()`; @re: calc(~'@{winh}px - 125px'); .lgrid(@width, @height) { height: ~"@{re} * 21.25% * @{height}" !important; } Result on my file.less height: calc(675px - 125px) * 21.25% * 4 !important; I try another way with height: calc(~"@{re} * 21.25% * @{height}") !important; but I have multiple calc calc(calc(675px - 125px) * 21.25% * 4) !important; But it's not working on my browser (chrome). How I can calc this ?
If you really want to use the css `calc()` function as your final calculator, then you would need your LESS code to be something like this: height: ~"calc(@{re} * calc(21.25% * @{height}))" !important; Producing css like this: height: calc(calc(601px - 125px) * calc(21.25% * 4)) !important; But it probably would be best to do all the calculations in LESS, which is challenging because of bugginess at present, so really it needs to be all in the javascript. Maybe something more like this: @winh: `$(window).height()`; .lgrid(@width, @height) { @calcHeight: `function(){return (@{winh} - 125) * (.2125 * @{height})}()`; height: ~"@{calcHeight}px" !important; } This assumes the final result is intended to be pixels.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "css, less" }
Open Source software for 2D graphic animation like this: Can someone suggest me a good software of graphic 2D animation, for animating images, and also a software for insert some more or less static text during a video? I'll post an example of my animation what should looks like, it start at 1:05 minutes in the video; while the text is for example the name of the people who are speaking :) < Thank you
# Open source * NodeBox * Processing * Your browser (serioulsy, you can do this with css and javascript easily) * Blender (2d is just a subset of 3D) # a NodeBox3 Example A simple example of using NodeBox to make text appear, I had not used NodeBox 3 before so it took me 15-20 minutes to get up to speed (tough i have used shake and nuke which are very similar). Its a good alternative if you abhor code, but still needs some polish. !NodeBox animation **Image 1:** Simple example animation made with nodebox3. !NodeBox graph **Image 2:** The NodeBox3 graph. * * * # Closed source (order of applicability) * Blackmagic Design: Fusion (download for free BUT not open source) * Vvvv (free but not open source)
stackexchange-graphicdesign
{ "answer_score": 4, "question_score": 3, "tags": "animation, video, open source" }
Event IDs for event log source "ASP.NET 2.0.50727.0"? When I create an entry in the Application event log with source "ASP.NET 2.0.50727.0" and Event ID 0, the following text is added to the top of the entry's text: > The description for Event ID 1310 from source ASP.NET 2.0.50727.0 cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer. > > If the event originated on another computer, the display information had to be saved with the event. > > The following information was included with the event: Where do I learn what event IDs _can be found_? Put another way, where do I learn what event IDs I'm allowed to use?
Maybe the Event code.aspx) can help you. Also some codes are here: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "asp.net, event log, event id" }
How can I drag sortable element into an other sortables elements I have 2 lists of sortables elements and I need to be able to drag an item from list to an other list: I have tried to do it but it seems that it doesn't work correctly. My code: <div class="sortableCard"> <div class="draggable">car 5</div> <div class="draggable">car 6</div> </div> <div class="sortableCard"> <div class="draggable">car 1</div> <div class="draggable">car 2</div> <div class="draggable">car 3</div> </div> $(function() { $(".sortableCard").sortable({ revert: true }); $(".draggable").draggable({ connectToSortable:'.sortableCard', revert: "invalid" }); }); Fiddle: <
Take a look at < $( ".sortableCard" ).sortable({ connectWith: ".sortableCard" }).disableSelection();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery, jquery ui" }
Storage type used in app like Instagram I want to make an app like Instagram but the problem is where to store all text and images data, I have used Instagram when there is no connectivity available then app will show the last feeds even when app is freshly openend (not from background). It uses core data or sqlite.
It's not known what Instagram uses. Use whatever you feel most comfortable with. Anything is possible with any storage technology, although some might fit better than others. Also, regarding your question on "core data or sqlite", you can use Core Data with an SQLite database as a backend (way easier than accessing raw SQL). You can also use other backends with Core Data: binary and XML.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone, ios, xcode, instagram" }
Can someone explain the phrase "order-preserving permutation of a totally ordered set"? If a set is totally ordered, then any nontrivial permutation would destroy that order, so I'm clearly missing something. I have seen this exact phrase in many papers and books, mostly those dealing with ordered groups.
It is not true that any nontrivial permutation destroys a total ordering. This is true for finite sets, but "most" infinite sets are counter examples. For example, $x\to x+1$ preserves the total order on the integers, rationals, and reals. Another example is to take $\mathbb{Q}$ and double every number bigger than $0$, and leave the rest fixed. Just these two will let you produce many, as the composition of order preserving permutations is an order preserving permutation.
stackexchange-math
{ "answer_score": 6, "question_score": 4, "tags": "order theory" }
How make multiline fields in GROCERY CRUD? What do I need to change to make two lines (or more) fields presentation in GROCERY CRUD (CodeIgniter framewoks)? In examples on site I see table like I need. But I make view and see my table like this example I have some columns 50-100 characters long, and I need to show all content of them. But now I getting something like `My field cont...` instead of: 'My field content'
If you are using GC version 1.3+, you can change `grocery_crud_character_limiter` config option to zero: //The character limiter at the list page, zero(0) value if you don't want character limiter at your list page $config['grocery_crud_character_limiter'] = 30; in this file: > application/config/grocery_crud.php This is system-wide setting. If you want to affect only some lists, you will have to add some code: $crud->callback_column('text_to_show', array($this, '_full_text')); function _full_text($value, $row) { return $value = wordwrap($row->text_to_show, 100, "<br>", true); } Credits goes to this page: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, codeigniter, frameworks, grocery crud" }
Load Image Src from Byte[] Asp.Net MVC 3 I have an ASP.net MVC 3 application where I want to store an image as bytes in the model and then load it from the model into the src attribute of an html image tag. e.g. //Property in Model public byte[] Image { get; set; } But when I try this it errors: <img src = "@Model.Image" alt=""/> How can I load the image from bytes? I want to avoid calling the Controller again to get the image as a FileResult. Is it possible?
The easiest way is something like this: <img src="data:image/png;base64,@System.Convert.ToBase64String(Model.Image)" alt=""/> This assumes a PNG payload and is not very well supported by legacy browsers. I would actually recommend saving it to disk and letting your web server host it up separately.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 4, "tags": "c#, asp.net mvc 3, image, src" }
How do I find point B of line AB with only point A, distance, and slope? Good morning. There is a line AB and A is at point (x, y). x and y are known. So is the slope (m) and distance (time). Is there a formula to calculate the x and y value separately of point B?
I believe time is straightforward and B is later then A. Then $$x_B=x_A+ distance \cdot \frac{1}{\sqrt{1+slope^2}}$$ $$y_B=y_A + distance \cdot \frac{slope}{\sqrt{1+slope^2}}$$
stackexchange-math
{ "answer_score": 0, "question_score": -2, "tags": "trigonometry, slope" }
Convert date string to date sql server I have a table `tbl` with column `cln varchar(50)`. Data is stored in format `'January-2008'`, `February-2009`, `March-2010` etc(full `month` name) I want to `convert` it to `date` (for `comparison`, `sort` etc).
please try below query DECLARE @v varchar(20) SET @v='January-2008' SELECT CAST('01-'+@V as DATE) Since you don't get the day data and only -, we'll add '01-' to complete the date day part. sql fiddle link: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, tsql, sql server 2014" }
Get document id firestore angular I tried to create a auto document id in firestore and get the document id in angular 8 using the following code but I am getting the document Id after the completion of the execution.Can anyone help me?Thanks in advance this.db.collection("testdata2").add({ "name": "Tokyo", "country": "Japan", "Date": this.date }) .then(function(docRef){ component.docid=docRef.id; console.log("Document written with ID: ", docRef.id); }) .catch(function(error) { console.error("Error adding document: ", error); }); console.log(component.docid);
So you're using promises which means the callbacks in `then` and `catch` will be called after everything else - in this case they will actually be called after the final `console.log(component.docid)`. If you can specify your method as `async` (See MDN on async function) then it should make it easier to reason about it. Rewriting your code would then look like this: try { const docRef = await this.db.collection("testdata2").add({ "name": "Tokyo", "country": "Japan", "Date": this.date }); component.docid = docRef.id; console.log("Document written with ID: ", docRef.id); } catch (error) { console.error("Error adding document: ", error); } console.log(component.docid);
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "angular, typescript, google cloud firestore" }
What is a passenger disturbance level? I was listening to RealATC for a United Flight UAL1074 which declared an emergency needing to return to Washington Reagan National Airport. During the ATC recording, the flight declares an emergency due to a passenger disruption. ATC asks for something called the Passenger Disturbance Level. The Copilot replies with a Disturbance Level of 2. As I had never heard this asked for before, I was curious as to what the levels are for and what they each mean?
The FAA has categorized disturbances into four levels: > Level 1: Disruptive behavior - suspicious or threatening > Level 2: Physically abusive behavior > Level 3: Life-threatening behavior > Level 4: Attempted or actual breach of the flight deck These are also ICAO standard classifications from the restricted Doc 9811, according to IATA. I'm not sure who came up with them first. That IATA document also provides sample things that might be considered to be each level.
stackexchange-aviation
{ "answer_score": 40, "question_score": 35, "tags": "faa regulations, air traffic control" }
Перевод столбца в строки Работаю с файлом, загруженным в Jupyter Notebook, использую в основном Pandas. Есть таблица (данные в файле CSV): ![введите сюда описание изображения]( Количество продуктов у одного покупателя не ограничено. Необходимо получить: ![введите сюда описание изображения]( Пробовала и `merch`, и `pivot`, но, видимо, моих знаний пока не достаточно.
res = (df .assign(x=df.groupby("customer").cumcount()+1) .pivot(index="customer", columns="x", values="product") .add_prefix("product_") .rename_axis(None) .rename_axis(None, axis=1)) * * * результат: In [16]: res Out[16]: product_1 product_2 product_3 product_4 product_5 product_6 product_7 a apple lemon NaN NaN NaN NaN NaN b kiwi apple NaN NaN NaN NaN NaN c grapes lemon NaN NaN NaN NaN NaN d banana apple kiwi lemon melon NaN NaN e banana kiwi melon NaN NaN NaN NaN f plum melon pear mango orange banana kiwi
stackexchange-ru_stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "python, pandas, numpy, csv, pivot" }
How do I put an article in a block? I don't think I understand Drupal too well yet. I have an article. In the theme I chose it has the various blocks. How do I put an article on a given block area of a theme? I see the modules I can assign to a block in a specific region, but I have things articles I want to put in the block. I don't need who's online, recent comments, etc.
If you want to put a node, where in your case it will be a node from an article content type, you can use the node as block module. You also have other module options, including: * < * < These modules allow you to add your nodes inside a block. Afterwards, you can configure which block to show in which region on the block administration page. For example if you want to hide the 'who is online block' simply set the region for the block to none and it will not show up any more.
stackexchange-drupal
{ "answer_score": 6, "question_score": 5, "tags": "blocks, nodes" }
What program can I use to create and edit json files? I'm using osx and want to create and edit json files. Is there a program that I can use to do this automatically? For example I have an excel file that I want to convert into JSON format. I thought I could read in the file using python and write it out according to the json schema, but I was not sure if there was an easier way to do it.
If you want to convert an Excel document to JSON you can use something like: < If you're just looking to manipulate JSON data visually you can use something like: <
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 6, "tags": "json, macos" }
Formatting Time Entries in Excel 2010 I have an Excel Spreadsheet. Essentially, I'm trying to use this spreadsheet for time tracking purposes. I have the following columns: Date (Formatted as a Date in Column A) Start Time (Formatted as a Time in Column B) End Time (Formatted as a Time in Column C) Duration (Formatted as a Time in Column D with a formula of C# - B#) The calculation of the duration cell looks to be correct. However, I want to format it in decimal format rounded to the nearest tenth. For instance, if my Start Time value is 10:00 AM and my End Time value is 11:06 AM, I want the Duration to show 1.1. How do I format a Time value as a Decimal rounded to the nearest tenth? Thank you!
* Change the format of column D to general * Insert this formula to column D: `=(C1-B1)*24` The trick is to multiply it with 24 * * * The harder part is to round it to the nearest tenth. I only know a solution using VBA. This is an example for rounding to any quarter of an hour Private Function RoundMyTime(mytime As Date) As Date If Minute(mytime ) Mod 15 < 8 Then RoundMyTime= DateAdd("n", -Minute(mytime ) Mod 15, mytime ) Else RoundMyTime= DateAdd("n", 15 - Minute(mytime ) Mod 15, mytime ) End If End Function
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "microsoft excel 2010, worksheet function" }
PayPal SDK REST API state "approved" vs "completed" vs "verified"? While using PayPal SDK REST Api, **How to confirm that payment has "completed" as in _completed-completed_?** Right now the API is returning multiple attributes which is a bit confusing on what attribute to depend upon to proceed with the checkout process. There is this `state` field in the root attributes of the response object. state -> approved Then there is this `payer` field which has a `status` of its own, and its showing ... status -> VERIFIED Then there is this `sale` object inside the `transactions` object and it also has a `state` which is showing.. `state-> completed`
So as per the Docs > A sale is a completed payment. Which implies that we need to check for the `sale -> state` flag. $transactions = $payment->getTransactions(); $related_resources = $transactions[0]->getRelatedResources(); $sale = $related_resources[0]->getSale(); $sale_state = $sale->getState(); // 'complete' Or 'pending' or etc..
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, paypal rest sdk" }
T-SQL : How to output whitespaces with Substring on an empty column I am trying to convert a Informix select query to T-SQL. On a Date column thats in YYYYMMDD format, the Informix query has below Statusdate in Select and I wrote the equivalent T-SQL which works perfectly to output Statusdate in the format YYYY-MM-DD. Informix: Date[1,4]||"-"||Date[5,6]||"-"||Date[7,8] as StatusDate T-SQL: SUBSTRING(Date,1,4)+'-'+SUBSTRING(Date,5,2)+'-'+SUBSTRING(Date,7,2) AS StatusDate But if the Date column is empty, the Informix output is [ - - ] i.e 4spaces-2spaces-2spaces while SQL output is [--] i.e no white spaces. How can I updated the T-SQL query to get output similar to Informix when column is empty.
You could just use a `CASE` expression here to explicitly handle the output for `NULL` dates: CASE WHEN Date IS NOT NULL THEN LEFT(Date, 4) + '-' + SUBSTRING(Date, 5, 2) + '-' + RIGHT(Date, 2) ELSE ' - - ' END AS StatusDate
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "tsql, substring, whitespace, informix" }
Название салата должно быть в кавычках? Вот конкретный пример. Нужно ли названия блюд писать в кавычках? > Салаты Лемберг и Теплый вечер. В каких случаях нужно использовать кавычки в названиях блюд при составлении меню.
_Кавычек можно избежать, однако выделение названий тем или иным способом необходимо._ Салаты ЛЕМБЕРГ и ТЕПЛЫЙ ВЕЧЕР / Салаты **_Лемберг_** и **_Тёплый вечер_** / _Салаты_ Лемберг _и_ Тёплый вечер. Для акцидентной продукции предела разнообразия способов выделения не существует.
stackexchange-rus
{ "answer_score": 0, "question_score": 0, "tags": "пунктуация, кавычки" }
TFS 2017 - Get the Solution's name in C# I'd like to know how can I get the name of the solution that the XAML Build Definition is using. For instance in the configuration of my Build Defnition I have this path to chose which solution I want to apply this Build Definition: $/test/SolutionName/SolutionName.sln How can I get "SolutionName" for my Activity Code, using C# code. **EDIT:** My variable, what can I put as Default yield? ![enter image description here]( The code: public InArgument<string> BuildSettings { get; set; } .... string nameSolutionAuto = System.IO.Path.GetFileNameWithoutExtension(this.BuildSettings.ProjectsToBuild[0]);
The projects/solutions info is stored in ProjectsToBuild variable, so you just need to pass this variable value to your Activity (InArgument) and get the solution or project name by this code (InArgument variable:solutionPaths): foreach(string solution in solutionPaths) { Console.WriteLine(solution.Split(new char[] { '/' }).Last()); } An example to display selected solutions/projects in build definition to build log: 1. Add ForEach active (TypeArgument: String; Values: ProjectsToBuild 2. Add WriteBuildMessage active to ForEach active body (Importance: Microsoft.TeamFoundation.Build.Client.BuildMessageImportance.High; Message: item 3. Queue build with this process template ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, visual studio, tfs, build" }
How to speed up Windows 8 on Samsung laptop? I just bought a Samsung Series 5 notebook, with Windows 8, but I found it unreasonably slow to reboot and install updates. Last night I waited for 1h30 for it to install 1 update and reboot, when I finally gave up and switched it off during reboot. Another thing that I noticed is that HD I/O is too high for a reboot - the HDD light doesn't turn off during the process, and the notebook gets really warm. I tried to reboot it another day, without any updates to install, and after 4 hours it was still in the reboot screen. I had to do a hard reboot. I found specially weird that even with a worse machine, Windows 7 would do both things (install updates AND reboot machine) faster. Does anyone know a way to speed things up? Is there any configuration that I can make? Is this a Windows 8 bug?
One of my friends also has a Samsung Windows 8 laptop, and disabling the Samsung service "IntelliMemory" service solved all of his issues. 1. Run services.msc 2. Locate "IntelliMemory" 3. Right Click -> Properties 4. Startup Type -> Disabled 5. Click "Stop" 6. Click "OK" 7. Reboot IntelliMemory is a product which is installed by default on Samsung Windows 8 laptops. Samsung pre-loads IntelliMemory on most of their Windows computers, and it's the first thing to remove from a machine with an SSD drive. It can speed up slower conventional spinning hard disks by caching lots of stuff to RAM (memory), but when you have an SSD this isn't helpful and it tends to hog all the RAM. It can be safely removed from a system using an SSD drive.
stackexchange-superuser
{ "answer_score": 18, "question_score": 11, "tags": "windows 8, laptop, performance" }
accessing multiple web pages at a time using c# my project need to read multiple web pages at a time(eg: for a particular keyword google will display 100 pages result maximum) I tried to read that 100 pages using 'for' loop in URL.But it is showing http request exception in c#.How can i read that pages within sort period of time???
this is really nice < < But maybe you can not use RX .
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c#" }