INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
How to create cyrillic input on windows phone? On my `Nexus 7` input keyboard I have an option to switch languages (`Bulgarian`, `Russian` and `English`). I want to create such input on windows phone application, but was not able to find a way to do that? I am not going to deploy the application on the store, just wanted to enabled this on the emulator.
Users can set this for themselves in the keyboard settings. You can't interact with the keyboard as a developer aside from setting it's inputscope (eg. web address, e-mail, numbers).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "visual studio 2013, windows runtime, windows phone 8.1" }
How to run executable with Python code inside I have the following file: $ cat my_exec.sh #!/usr/bin/env python print(10) It should just print `10`. However, I can't get it to do so: $ sudo ./my_exec.sh sudo: ./my_exec.sh: command not found $ sh my_exec.sh my_exec.sh: line 3: syntax error near unexpected token `10' my_exec.sh: line 3: `print(10)' How do I run my file?
You can run it via the python command: $ python my_exec.sh To run it as simply ./my_exec.sh, you need to make the file executable first: $ chmod 755 my_exec.sh Also note that by convention python files end in .py .
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, bash, sh" }
If I know the coordinates of a right angle triangle how can I find the distance between the centroid and the incircle? I have points $A(6,0)$, $B(6,8)$ and $C(0,8)$
Draw $\Delta ABC$. $AB=8$, $AC=10$ and $BC=6$. Thus, $r=\frac{6+8-10}{2}=2$ and the incenter $I(6-2,8-2)$ or $I(4,6)$. In another hand the centroid $M\left(\frac{6+6+0}{3},\frac{0+8+8}{3}\right)$ or $M\left(4,\frac{16}{3}\right)$. Thus, $IM=6-\frac{16}{3}=\frac{2}{3}$
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "geometry, euclidean geometry, analytic geometry" }
Proof of inequality involving surds Determine whether $ \frac{1}{\sqrt{2}} - \frac{1}{\sqrt{6}}$ is greater or less than $\frac{3}{10}$ So what I did was: Add the fraction with surds to get $\frac{\sqrt{6}-\sqrt{2}}{\sqrt{12}}$ Then squaring both sides results in $\frac{8-4\sqrt{3}}{12} = \frac{2-\sqrt{3}}{3}$ Therefore we have $\frac{2-\sqrt{3}}{3} ? \frac{9}{100}$ (using question mark in place of < or > therefore $200-100\sqrt{3} = 27$, but $1\times1 = 1$ and $2\times2 = 4$ thefore $1<\sqrt{3}<2$ and since $100-100\times1 = 0 <27$, $\frac{1}{\sqrt{2}} - \frac{1}{\sqrt{6}} < \frac{3}{10}$ I checked the answer and they had a method but same result, however would this suffice?
Assume the LHS is $<$ the RHS. Square the LHS $$\frac{1}{2} + \frac{1}{6} - \frac{2}{\sqrt{12}} = \frac{2}{3} - \frac{1}{\sqrt{3}} < \frac{9}{100}$$ Subtract $2/3$ from the LHS and the RHS and we are assuming that $$ \frac{1}{\sqrt{3}} > \frac{2}{3} - \frac{9}{100} = \frac{173}{300}$$ Square both sides again: $$\frac{1}{3} > \frac{29929}{90000}$$ which is true, and therefore the assumption is true. Therefore $$\frac{1}{\sqrt{2}} - \frac{1}{\sqrt{6}} < \frac{3}{10}$$
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "algebra precalculus, inequality" }
Attempting to create new state, but property is resolving to 2 I'm new to react and redux, and I'm attempting to create new state, but it appears that I'm not updating the state properly. here's the code inside my case: case SUBMIT_NOTE: console.log(payload.note); return{ ...state, notes: state.notes.push(payload.note)}; `payload.note` resolves to the object I want to push into the array, but in redux-logger it shows as `state.notes = 2` Not sure how this happened. I'm new to the spread operator, and pure functions.
I'm going to assume that `.push()` mutates in some way, or simply returns the number of indexes in the array, and can't be used for state operations. `.concat(note)` worked.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "react redux" }
Move object element position in javascript I'm trying to find a way to move an object element to a specific position. For example, I've this object : { "element1" : {} // object, "element2" : {}, "element3" : {} } And I search to move element3 at the first position : { "element3" : {}, "element1" : {}, "element2" : {} } Thanks for your help !
JavaScript objects don't have ordering. You should use an array of objects instead. var arr = [ { id: 'element1' }, { id: 'element2' }, { id: 'element3' } ] You could then reorder it something like: var first = arr.splice(0, 1); arr.push(first); Maybe you could then grab specific elements based on id: var out = arr.filter(function (el) { return el.id === 'element1'; });
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "javascript, object" }
Groovy Grape configuration on intellij idea 13.1 I have recently migrated to IntelliJ IDEA 13.1 and I'm using it with groovy 2.3. I have used the IDE's support for grab annotations in groovy scripts where with just the key stroke of alt+return the IDE smartly downloads grab dependencies and adds it to the projects classpath. But all of a sudden it has stopped working and I have no clue what's wrong. It also does not log anything specific other that it can't find the dependencies. The same script works perfectly fine when launched from groovy console. Let me know if anybody has encountered this or if you know where to look for the problem.
It was a proxy setting issue. There is no way to override the proxy settings for grapes in the IDE. So the IDE proxy settings were affecting Grapes download.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "grails, groovy, intellij idea, groovy console" }
How to convert a List to a java.util.ArrayList[String] I'm trying to convert Scala `List` to a Java `ArrayList`. import collection.JavaConverters._ val list: java.util.ArrayList[String] = List("hello", "world").asJava It doesn't seem to be working. How can I do this?
The `asJava` function returns an object that implements the `java.util.List` interface. This object is backed by your original list. You can find the documentation for this here (check the `seqAsJavaList` function): < If you want an instance of `java.util.ArrayList`, you can create one using the constructor that takes a `Collection`. Like this: import java.util.ArrayList val list = new ArrayList(List("hello", "world").asJava)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "scala" }
How to convert all timestamp values to a numeric value in a dataframe column Python Pandas I have a pandas data frame which has int, float, timestamp datatypes.I would like to convert the timestamp values to a numeric value Something like 2018-08-20 18:57:07.797 to 20180820185707797 and store it as a numeric replacing the original timestamp column. How can I do this in Python
Timestamp is stored internally as int64 as the number of nanoseconds from 1970-01-01 (I think). You can get this number by: df['time'] = pd.to_datetime(df['time']).astype(np.int64) Or if you really want what the format you said, try: df['time'] = pd.to_datetime(df['time']).dt.strftime('%Y%m%d%H%M%S%f').apply(lambda x: int(x[:-3]))
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "python, pandas" }
Php Active Record Domain Expired (Their Site is currently down) Php Active Record Domain Expired < the above link is currently down. is there any alternate link, so that i can refer docs.?
I found that, this below link has enough information, about Php Active Record. <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php" }
How to acces the data of root folder(/) of an android device? I'm storing the DB file to the path `/data/data/somefolder/` in my application. I want to get the file from this folder in my system or in my device so that I can view the content in it. I'm able to pull the file from emulator, but I'm not able to get the file from device. Is there any app which can do this? PS: Programatically I'm able to access the file
You can see that Here to get the "/data/data/somefolder/" directory with `getExternalStorageDirectory()` method While inserting and retrieving you path you have to store fullpath to get solve out your problem. **EDITED :** AFAIK its not possible to access internal data but you can create your same folder in external directory for future Use and access it when you required. If you want to Access it from device then you can also create Folder at path `"sdcard/YOUR_APPLICATION/XYZ/"` location with Full path location in database.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "android, filesystems" }
The equivalent of torch.nn.Parameter for LibTorch I am trying to port a python PyTorch model to LibTorch in C++. In python the line of code within a subclass of a torch.Module object `self.A = nn.Parameter(A)` where `A` is a torch.tensor object with `requires_grad=True`. What would be the equivalent of this for a torch::Tensor in a torch::nn::Module class in C++ ? The autocomplete in my editor shows the classes ParameterDict, ParameterList, ParameterDictImpl, ParamaterListImpl, but no Parameter. Do I need to wrap it in a list of size 1 or is there something else I'm missing. I wasn't able to find what I needed from a google search or the documentation, but I wasn't sure precisely what to search to be honest.
To register a parameter (or tensor which requires gradients) to a module, you could use: `m.register_parameter("A", torch::ones({20, 1, 5, 5}), True)`; in libtorch.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "pytorch, libtorch" }
Initializing a Global Struct in C What is the best way to accomplish the following in C? #include <stdio.h> struct A { int x; }; struct A createA(int x) { struct A a; a.x = x; return a; } struct A a = createA(42); int main(int argc, char** argv) { printf("%d\n", a.x); return 0; } When I try to compile the above code, the compiler reports the following error: "initializer element is not constant" The bad line is this one: struct A a = createA(42); Can someone explain what is wrong? I'm not very experienced in C. Thanks!
Why not use static initialization? struct A a = { 42 };
stackexchange-stackoverflow
{ "answer_score": 19, "question_score": 24, "tags": "c, struct, constants, initialization" }
What is $2^{32} - 1$ in decimal notation? I came across decimal notation, and surprisingly I have never heard of it. I have heard of _scientific notation_ and just thought this was decimal notation. However, when I want to find a definition on the internet, it isn’t clear. Could somebody please explain to me? This looks to be a very basic thing in maths which I should know by now so I don’t understand why I don’t know it. As an example, what is $2^{32} - 1$ in decimal notation? Is this also the same as _decimal expansion_? Thank you in advance.
They could simply mean the usual base 10 representation. $$ (d_m \dotsc d_0)_{10} = \sum_{k=0}^{m} d_k 10^k $$ thus $$ 2^{32}-1 = 4294967295 = (11111111111111111111111111111111)_2 $$ where I assumed $32$ to be given in base $10$ already, as no base has been provided for it. :)
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "decimal expansion" }
Multi value parameters SSRS I have 2 parameters `@ProductID` and `@Customer`. `@ProductID` and has `Product1_ID` has customer Say `Cust1` and `Product2_ID` has same Customer `Cust1`. When cascaded using MDX in SSRS report to select all available values for Customer for each ProductID's it shows two values in the cascaded drop down list for `Cust1` but selects only the first `Cust1` (which points to `Product1_ID`). Is there a way in which I can get the report to select all values even when two ID's have same Customers in MDX. I set available values and default values using dataset which has `ProductID`, Customer filterd on `ProductID`)
Found a workaround to resolve this issue. <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "reporting services, parameters, ssas, ssas 2012" }
Examples of Banach spaces and their duals There are many representation theorems which state that the dual space of a Banach space $X$ has a particularly concrete form. For example, if $X = C([0,1],\mathbb R)$ is the space of real-valued continuous functions on $[0,1]$, then $X^*$ is the space of Radon measures on $[0,1]$. When you are confronted with some Banach space, where do you go to figure out a representation of its dual space? Is there a book or survey article with a rich set of examples? Here is the particular example which motivates this question. Let $\operatorname{Sym}$ be the space of symmetric $n \times n$ real matrices with a usual matrix norm. Let $U \subseteq \mathbb R^n$ be compact, and let $X = C^{2+\alpha}(U, \operatorname{Sym})$ with the obvious norm. What is the dual space of $X$?
In wikipedia, there is a list of banach spaces with its dual space and it also tells you if it is reflexive, for example.
stackexchange-mathoverflow_net_7z
{ "answer_score": 1, "question_score": 4, "tags": "fa.functional analysis, examples, reference request, banach spaces" }
How to set up a Doctrine MongoDB respository in the Symfony 2 service container How do I correctly set up the service container in my Symfony 2 application to support custom Document repositories? What I have so far is: services: acme.repository_user: class: Acme\Repository\UserRepository arguments: [@doctrine.odm.mongodb.document_manager] However, when I look at the constructor of the `DocumentRepository` class, of which my `UserRepository` inherits, I can see the following arguments: public function __construct(DocumentManager $dm, UnitOfWork $uow, Mapping\ClassMetadata $class) I seem to have injected the document manager but how do I inject the Unit of Work and the class meta data?
Try to define service as(sorry for xml): <service id="acme.repository_user" class="Acme\Repository\UserRepository" factory-service="doctrine.odm.mongodb.document_manager" factory-method="getRepository" public="false"> <argument>AcmeBundle:User</argument> </service>
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "php, symfony, doctrine orm, doctrine odm" }
Lightning Button Variant for "outline-brand" I'm trying to apply a specific variant to a lightning button. Lightning Design System says there is a button variation called outline-brand. It applies the `slds-button_outline-brand` class to the button. However, the component documentation doesn't show that variant option available. I've tried something like this: <lightning:button variant="outline-brand" label="Cancel" /> Can this be done as a `variant` or do I need to use `class` instead?
The Lightning Component Library (LCL) tends to lag behind the Salesforce Lightning Design System (SLDS) by about one release on average; two different teams are working on these two parts of Salesforce, so it is strictly true that there must be some lag time between when a style is defined and when it makes it in to the LCL. For now, assuming the style is available (I haven't checked), you should be able to use it as a class in this release, and it will likely become a variant you can use in the next release (note: there's no guarantee of this, but it seems reasonable). The class version, of course, will always work in to the foreseeable future now that SLDS has stabilized its design patterns.
stackexchange-salesforce
{ "answer_score": 1, "question_score": 1, "tags": "lightning aura components, lightning" }
high availability websites what's the best way to achieve high availability for a dynamic website? If I create a second copy on another server and do not wish to use a load balancer since it will mess up user sessions, what are the best alternatives?
You can store session data in a database instead, which gets around that problem, then you can round-robin the requests to the application servers. (Good) Load Balancers can be configured to be "sticky" which means they send requests from the same IP to the same server each time.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "apache, web, load balancing, high availability" }
delta coronavirus: Why isn't similar viral load in vaccinated people causing as severe adverse effects as in unvaccinated people? In latest news, it is reported that: > if vaccinated people get infected anyway, they have as much virus in their bodies as unvaccinated people. That means they're as likely to infect someone else as unvaccinated people who get infected. > But vaccinated people are safer, the document indicates. "Vaccines prevent more than 90% of severe disease" I've understood in general viral load is related to severity of the sickness. Do we know why would it not be in this case?
I believe the news report you cited is not accurate in its reporting. Of course, it's not actual science, and we will wait for the release of the actual science, but here's my understanding (which may end up being wrong): > if vaccinated people get infected anyway, they have as much virus in their bodies as unvaccinated people. This seems to be incorrect. My understanding is that the CDC info looks at vaccinated people who were infected AND developed COVID symptoms, not all vaccinated and infected people. Also, the tests did not look at the virus levels in the whole body, just in the nose and throat. Obviously, the nose and throat release virus into breath which is exhaled, so that directly impacts how contagious a person might be. However, what should be important for the person's own level of illness is the amount of virus in the lungs and other internal systems, not the nose and throat. This mis-reporting would seem to account for the apparent discrepancy you noted.
stackexchange-biology
{ "answer_score": 4, "question_score": 2, "tags": "coronavirus, vaccination, mrna, covid" }
Intel SSE intrinsics: Difference between si64 si64x I just noticed that there is a `_mm_cvtsd_si64` and a `_mm_cvtsd_si64x` intrinsic in the SSE2 instruction set. According to the intel intrinsics guide, both do exactly the same. So where is the difference, or, if there is none, why are there two identical intrinsics? This is only an example, there are more intrinsics with an si64 and an si64x version which seem to do the same.
It's probably historical, going back to the early days of MMX/SSE and probably some discrepancies between different sets of intrinsics. Note that even now some intrinsics have `64` and `64x` versions because they take different argument types, even though they do the same thing, e.g. __m128i _mm_set1_epi64x (__int64 a) and __m128i _mm_set1_epi64 (__m64 a)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "intel, sse, intrinsics" }
Concatenate cells based another worksheet? Would anybody know how to concatenate, if a cell value is equal to a cell in different range and concatenate with another relevant cell based on unique ID; the result tab we should have DAS G45 e.g: ![enter image description here]( Thank you, A
Use TEXTJOIN and FILTER: =TEXTJOIN(" ",TRUE,FILTER(Sheet2!A:B,(Sheet2!A:A=A2)*(Sheet2!C:C=B2),"")) Where Sheet2!A:A = Worksheet 2 column 1 Sheet2!C:C = Worksheet 2 column 3 Sheet2!A:B = Worksheet 2 column 1 & 2 A2 = Worksheet 1 Column 1 first row of data B2 = Worksheet 1 Column 2 first row of data ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "excel formula" }
Lightning Web Component (LWC) for Visualforce was fails to run Just follow the official document. < I created an aura application - lwcvf.app <aura:application access="GLOBAL" extends="ltng:outApp" > <aura:dependency resource="lightning:button"/> </aura:application> And, add a new visualforce page <apex:page > <apex:includeLightning /> <div id="lightning" /> <script> $Lightning.use("c:lwcvf", function() { $Lightning.createComponent("lightning:button", { label : "Press Me!" }, "lightningvf", function(cmp) { console.log("button was created"); } ); }); </script> </apex:page> But the result is failed and the error message is **Lightning out App error in callback function** ![C]( Any idea?
There is a typo in code mentioned in the documentation example. The correct code is as below <apex:page> <apex:includeLightning /> <div id="lightning" /> <script> $Lightning.use("c:lwcvf", function () { $Lightning.createComponent("lightning:button", { label: "Press Me!" }, "lightning", function (cmp) { console.log("button was created"); } ); }); </script> </apex:page> Notice that the " **lightning** " is the ID of the domLocator where lightning out DOM should be injected and not " _lightningvf_ "
stackexchange-salesforce
{ "answer_score": 5, "question_score": 1, "tags": "visualforce, lightning web components" }
recursive max function for list of list python I am trying to write a recursive function in order to find the max integer in a list of list. I know how to write a func for list of ints. Can anyone give me some tips for this?I I am thinking doing it with no Max function. ex. a = [1, [2,3], 4, [[2], 1]] find_max(a) ->4
You can iterate through your list and call the `MAX()` function if data type is a list: l = [[54,65,464,656,5],[568,49,7,8,4,3,3515],[312,64,598,46]] def MAX(l): mx = None for item in l: if isinstance(item, list): tmp = MAX(item) else: tmp = item if mx < tmp: mx = tmp return mx
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "python, recursion" }
How do I modify my simple Python code, to take into account HTTP headers? def URLRequest(url, params, method="POST"): r = urllib2.urlopen(url, data=urllib.urlencode(params)) return r In this method, I send a POST request to a certain URL. What if I want to do headers as well? I want to send a dictionary of additional headers (in addition to standard headers).
def URLPost(url, params, method="POST", headers = {}): req = urllib2.Request(url) for k, v in headers.items(): req.add_header(k, v) r = urllib2.urlopen(req, data=urllib.urlencode(params)) return r
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python, http, api, url, rest" }
Regex replace all occurences with something that is "derived" from the part to be replaced I have the following line from a RTF document 10 \u8314?\u8805? 0 (which says in clear text `10 ⁺≥ 0`). You can see that the special characters are escaped with `\u` followed by the decimal unicode and by a question mark (which is the replacement character which should be printed in the case that displaying the special character is not possible). I want to have the text in a string variable in C# which is equivalent to the following variable: string expected = "10 \u207A\u2265 0"; In the debugger I want to see the variable to have the value of `10 ⁺≥ 0`. I therefore must replace every occurence by the corresponding hexadecimal unicode (#207A = 8314 and #2265 = 8805). What is the simplest way to accomplish this with regular expressions?
If I understood your question correctly, you want to parse the unicode representation of the RTF to a C# string. So, the one-liner solution looks like this string result = Regex.Replace(line, @"\\u(\d+?)\?", new MatchEvaluator(m => ((char)Convert.ToInt32(m.Groups[1].Value)).ToString())); But I suggest to use a cleaner code: private static string ReplaceRtfUnicodeChar(Match match) { int number = Convert.ToInt32(match.Groups[1].Value); char chr = (char)number; return chr.ToString(); } public static void Main(string[] args) { string line= @"10 \u8314?\u8805? 0"; var r = new Regex(@"\\u(\d+?)\?"); string result = r.Replace(line, new MatchEvaluator(ReplaceRtfUnicodeChar)); Console.WriteLine(result); // Displays 10 ⁺≥ 0 }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, .net, regex" }
What does the ^ character mean when used in C++ declarations? > **Possible Duplicate:** > What does the caret (‘^’) mean in C++/CLI? > In C++/CLR, what does a hat character ^ do? What does the **^** character mean in C++ when applied to the data type in a variable declaration, as in: String^ input; or List<String^>^ phoneNumbers;
Assuming a Microsoft-compiler, this is not from C++ but from Microsoft own C++ dialects called _C++/CLI_. It denotes a .NET-garbage collected object.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "c++ cli" }
How to check in ESXi CLI if DVD is inserted in to DVD-Drive? I have ESXi 5.5, Dell R430, a DVD rom installed in it. How can I check the most easiest way, if a DVD is inserted into the DVD drive? The reason I want to know this, is that when the system is rebooted, and the boot order is set to DVD, I want to avoid to start any install from there. Tried to check things in /dev/cdrom, but have not found a working solution yet. It would be okay, to have the boot order check as well, I want to make it automatized in the end - that's why I need a CLI command solution. Thanks for the help in advance!
Can't you just change the boot order?
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "linux, vmware esxi, dell, drac" }
Fit a circle to a region of an image I would like to develop a routine that associates a size with images such as that below. My idea is to find the radius of the circle (centered at the origin) that contains (say) 95% of the total density. How can I achieve this? Also, are there better image processing techniques for associating a size to this region? Date file: < ![enter image description here](
If `img` is your image, you can use `Binarize` to find a fixed fraction of black pixels: img = Import[" bin = Binarize[img, Method -> {"BlackFraction", .1}] ![enter image description here]( Then you can use `ComponentMeasurements` to find the centroid and radius: comp = ComponentMeasurements[ ColorNegate@bin, {"Centroid", "EquivalentDiskRadius", "Circularity"}, #Circularity > 0.5 &]; HighlightImage[img, {comp /. (index_ -> {c_, r_, __}) :> Circle[c, r]}] ![enter image description here]( * * * **Response to comment:** @anderstood asked why `ComponentMeasurements` finds two components. We can use the `Mask` measurement to get a binary mask for each component: HighlightImage[img, Image[#]] & /@ ComponentMeasurements[ColorNegate@bin, "Mask"][[All, 2]] ![enter image description here]( and see that the first component is the black border around the image.
stackexchange-mathematica
{ "answer_score": 10, "question_score": 6, "tags": "image processing, fitting, image" }
What is the correct way for them to buy my crypto only with ethereum? I am making a token for a play to earn game, and I would like that token, only to be bought with Ethereum, that it cannot be bought with any other cryptocurrency, that way I would only receive ethereum, right? Or if a buyer buys me for example with bitcoin using a non-centralized exchange, what currency do I receive as payment for that user? Thank you
Since you are the one making the contract for the token, you could have a function accepting the ether price, and require that it was paid on that call, no way someone can pay you with an erc20 unless you write your code like that. What I'm saying is to create a function like this: function buytoken(uint tokenId) public payable{ require(msg.value >= getTokenPrice(tokenId), "You are not sending the right amount for the token"); //Your code here } This is assuming of course you handle the price with a `getTokenPrice` function, but that's the part of the implementation that answers the question.
stackexchange-ethereum
{ "answer_score": 0, "question_score": 0, "tags": "blockchain" }
Pygame sceen.fill() not filling up the color properly I've just started learning Pygame . I'm following this tutorial. I ran the following program but it shows black color instead of blue : import pygame h = input("Enter the height of the window : ") w = input("Enter the width of the window : ") screen = pygame.display.set_mode((w,h)) running = True while running: event = pygame.event.poll() if event.type == pygame.QUIT: running=0 screen.fill((0,0,1)) pygame.display.flip()
For Blue color, you should use `255` as the third element in the tuple, not `1`. Example - while running: event = pygame.event.poll() if event.type == pygame.QUIT: running=0 screen.fill((0,0,255)) pygame.display.flip()
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 10, "tags": "python, pygame" }
C# - Loop input until EOF This is my code to loop input until eof: string input; List<string> s = new List<string>(); while((input = Console.ReadLine()) != null && input != ""){ input = Console.ReadLine(); s.Add(input); } foreach(string h in s){ Console.WriteLine(h); } The input keep looping each line until I pressed 'ctrl-z'. Each input is assigned into list s, but it seems that not all input assigned into list s. output: ![enter image description here]( The output should be: > a > > b > > c > > d Thanks for help;
You were calling `Console.ReadLine()` twice for every loop. The easy fix is to remove the second call. string input; List<string> s = new List<string>(); while((input = Console.ReadLine()) != null && input != ""){ s.Add(input); } foreach(string h in s){ Console.WriteLine(h); } You may as well write the while statement like this: while (!string.IsNullOrEmpty(input = Console.ReadLine())){ s.Add(input); }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "c#, eof" }
Is every finite field of the form $GF(p^2)$ isomorphic to $(\mathbb{Z}/p\mathbb{Z})[i]$? I heard that finite fields are either $GF(p)$, or $GF(p^k)$, with $p$ prime and $k > 1$. One obtains a $GF(p^k)$ through an algebraic quotient of polynomials over $GF(p)$; the polynomial ideal used in the quotient should itself be based on an irreducible polynomial. For $k = 2$, the irreducible polynomials are of the form $X^2 - r$, which can be reduced to $X^2 + 1$; and we get spaces isomorphic to $(\mathbb{Z}/p\mathbb{Z})[i]$. But I was wondering if $(\mathbb{Z}/p\mathbb{Z})[j]$, with $j^2 = 1$ like the split-complex numbers, were also a (different) solution, with $X^2 - 1$ as the generator for the ideal. If not, why not?
Concretely: for $f\in \Bbb{F}_p[x]$ irreducible then $\Bbb{F}_p[x]/(f(x))$ is an integral domain with $p^{\deg(f)}$ elements, thus it is a field with $p^{\deg(f)}$ elements. All such fields with $p^{\deg(f)}$ elements are a splitting field of $x^{p^{\deg(f)}}-x\in \Bbb{F}_p[x]$, they are isomorphic, so we can consider the field with $p^{\deg(f)}$ elements as being unique. For your question: it remains to find an **irreducible** polynomial of degree $2$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "abstract algebra, polynomials" }
Count times ID appears in a table and return in row SELECT Boats.id, Boats.date, Boats.section, Boats.raft, river_company.company, river_section.section AS river FROM Boats INNER JOIN river_company ON Boats.raft = river_company.id INNER JOIN river_section ON Boats.section = river_section.id ORDER BY Boats.date DESC, river, river_company.company Returns everything I need. But how would I add a [Photos] table and count how many times Boats.id occurs in it and add that to the returned rows. So if there are 5 photos for boat #17 I want the record for boat #17 to say PhotoCount = 5
You could add a `LEFT JOIN` to a sub query as follows: LEFT JOIN (SELECT COUNT(p.id) num, p.boatID FROM photos p GROUP BY p.boatID) sub_photos ON (sub_photos.boatID = Boats.id) And then reference `sub_photos.num` in your `SELECT` fields. It would look something like this: SELECT Boats.id, Boats.date, Boats.section, Boats.raft, river_company.company, river_section.section AS river, sub_photos.num AS number_of_photos FROM Boats INNER JOIN river_company ON Boats.raft = river_company.id INNER JOIN river_section ON Boats.section = river_section.id LEFT JOIN (SELECT COUNT(p.id) num, p.boatID FROM photos p GROUP BY p.boatID) sub_photos ON (sub_photos.boatID = Boats.id) ORDER BY Boats.date DESC, river, river_company.company
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "sql, sql server, select, count, row" }
Limit Javascript from PHP? I'm trying to achieve something I can't wrap my mind around. The thing is that when a specific user is logged, I store in session the user and that he is logged. Before telling me yes, I know this isn't best practice but the purpose of this page is internal only and there is no possibility to be hacked or so because you can only access it internally. Anyway, the point is that there are some editable fields in a table which should be editable only by admin but that should only be seen by the rest. To achieve the editable table I used datatables library together with some ajax and JQuery. I can't think of a method to restrict editing when the logged user is not admin other than: var logged = <?php echo $_SESSION['logged_user'];?>; if (logged=='admin') { // action here } Do you know a better method or easier to understand? Thank you very much!
One solution would be to have the function/functions that edit the tables around a check with pure php instead, so the "normal" users don't have to load or can even see the javascript that makes this. <?php If(isAdmin) { ?> Javascript here <?php } ?> This also makes it so normal users just don't inspect element -> remove the if statement and then can do the same things.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 5, "tags": "javascript, php" }
Should we be looking for extra-terrestrial life on comets? I have just read What elements are a possible basis for life? and I find myself wondering whether instead of seeking advanced life-forms at remote locales a La SETI, and perhaps fundamentally differently, we ought to be looking for similar microscopic life forms on comets that pass off-and-on. Granted, a comet may be near absolute 0 for a lot of the time, but microscopic life-forms are known to be capable of surviving lean periods by using a cyst, for instance. As far as the rest is concerned, comets probably contain some amount of ice, and hence water, too. Similarly a comet's sprint around the sun could provide some limited amount of gravity/mass too. So, should we be looking for life on comets?
Yes we should be and we are! Scientists have been analysing cometary material - but its a challenging task. The problem with looking at meteoritic material from comets on Earth is that it is generally contaminated with material _from_ Earth. In addition, meteorites get physically altered during their passage through the Earth's atmosphere due to the high temperatures of re-entry. So, the trick is to send missions to the comet. However, then the difficulty is in designing a mission that can analyse samples _in situ_. NASA's Stardust mission got around this by sample return to Earth. The probe visited comet Wild-2 and found the amino acid glycine among other interesting organic compounds. However, no evidence of life was found (metabolic products, organisms etc.) Further missions to comets (and asteroids) are planned, but they are not going to explicitly look for life. Elsila, J.E., Glavin, D.P., & Dworkin, J.P. 2009, Meteoritics and Planetary Science, 44, 1323
stackexchange-biology
{ "answer_score": 4, "question_score": 8, "tags": "biochemistry, microbiology, astrobiology" }
What is the current rise time of a discharging capacitor? There are many questions about capacitor discharge rise time here on the electrical engineering board but all involve transistors or are oscillating circuits rather than a purely shorted out capacitor. The capacitor discharging equation assumes that current at time zero is at peak. However, I find it difficult to believe that the current rise time is effectively infinitesimal in real capacitors. Does the current of an RC circuit truly peak at time zero?
Real capacitators have an internal inductance, called _Equivalent Series Inductivity L_ (short: ESL). This one causes a rise time > 0. And of course, the outer circuit has an inductance, too.
stackexchange-electronics
{ "answer_score": 3, "question_score": 0, "tags": "capacitor, short circuit, discharge, rise time" }
Which part of my wallet should I NOT lose? .wallet file or private/public key? Simple question. I keep reading "don't lose your wallet", but which is the actual important part? The .wallet file or the public/private key combo? Or is it both?
In the original Satoshi wallet (BitcoinQt), your private keys are stored in the `wallet.dat` file. SO essentially, you may not lose either. You private keys are the data that grant you access to your coins, so those are the ones you should keep safe at any time. Most wallet clients call the file they store your keys in your "wallet". Various wallet apps will save the file under a different name, but mostly you can export it using the app itself or find it in their data directory.
stackexchange-bitcoin
{ "answer_score": 2, "question_score": 0, "tags": "wallet" }
How would I move a standalone Ubuntu Server to an virtual server (ESXi) I need to move an ubuntu server to a virtual server and everything on it with users, etc. The most logical way would be to move the entire HDD to an virtual disk on VMWare ESXi but how would I do that? Exporting all data, all userdata, configurations, etc seems like an unnecessary hassle. Could anyone guide me in the right direction?
You need the VMWare Converter Standalone (i.e. free) version.
stackexchange-serverfault
{ "answer_score": 4, "question_score": 1, "tags": "ubuntu, vmware esxi, migration" }
Switch a SuperClass I have a `Class` called `Mineral` and other classes which extend this one, like `Gold`, `Iron` and `Coal`. I'm trying to **switch** a `Mineral` **class** , in order to find out which Mineral has been **passed** through the following `addMineral` method: public List<Mineral> addMineral(Mineral mineral, int amount){ switch (mineral){ case Gold: break; } } But I don't know how to insert the classes which extend Mineral as the cases. In fact the example above doesn't work. Is this achievable? Is this the right way or is there a better solution?
You cannot switch on arbitrary object. You cannot switch on the class of an object. But you can switch on the name of a class of an object: switch (mineral.getClass().getName()) { case "some.pkg.Gold": // some stuff } Or you could use `mineral.getClass().getSimpleName()` and switch on the class name without the package name, etcetera. However, both switching on the class name and testing using `instanceof` are often "code smell". If possible, it is better to use polymorphism rather than hard-wiring special case handling for different subclasses in other code; e.g. if (mineral.hasSomeProperty()) { // do stuff }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "java, switch statement" }
PostgreSQL 9.3 How to set start-type to manual on Ubuntu? my psql9.3 server is starting every time I turn on my computer. I've heard that it can make your computer slower so I'd like to start postgresql service on demand only. According to this website it's quite simple to do on Windows but I can't see such option for Linux. I have also read here that if you want to set your start-type to auto on Linux you can > "Copy the file start-scripts/linux from PostgreSQL's contrib directory to /etc/rc.d/init.d/postgresql and then Execute the command /sbin/chkconfig". So is it good idea to remove that file to switch on manual type?
First of all, if PostgreSQL is idle it takes less CPU time than your mouse does. It may take some ram, but unless you are trying to run your computer without any GUI (shell prompt only) and have less than 1 GB this will be negligible. If you feel you have to manually start PostgreSQL, you can always do the procedure you have listed in your question. Do a backup first and be prepared to reinstall PostgreSQL should everything go wrong.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "startup, postgresql 9.3" }
SQL Conceptual Modelling - Can a password be a property of an entity? I'm currently making a conceptual model for a project and one of my entities happens to be a USER. It's key is a userID, and the properties include firstName, lastName, emailAdr, and userName. A user will have a password after the project is implemented which makes me wonder if I should add it as a property... or would that jeopardize confidentiality?
Conceptually you have to keep a password for the user so it makes sense to store it in the user entity. However, as pointed out by @stepio, when you look at how you will implement that, keeping a hash (in fact, a strong secure hash) is a good way to store it so it is not exposed if compromised. On another side if you use an ORM that instantiates the entity from the table ,for example, and you have some concern about the hash traveling through out the application you may choose to put the real hash in a separate table, and keep a reference to it in the user's table. Something like a Unix shadow password.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, properties, entity, conceptual model" }
Vanishing of local cohomology and primary decomposition Let $R$ be an $n$-dimensional Noetherian ring with proper ideal $I$. If $I = \mathfrak{a} \cap \mathfrak{b}$ and $H^n _\mathfrak{a}(M) = H^n _\mathfrak{b}(M) = 0$, for some $R$-module $M$, show $H^n_I(M) = 0$. I ask this in reference to exercise 8.1.5 in Brodmann and Sharp's _Local Cohomology_ book, where they ask a similar question instead using minimal primes belonging to $I$. So, if it is necessary, one may assume that $\mathfrak{a}$ and $\mathfrak{b}$ are minimal primes belonging to $I$.
Using _Mayer–Vietoris, 3.2.3,_ and _Vanishing theorem, 6.1.2,_ we have: $$H^n _\mathfrak{a}(M) \oplus H^n _\mathfrak{b}(M) = 0\to H^n_I(M) \to H^{n+1}_{\mathfrak a+\mathfrak b}(M) = 0.$$
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "commutative algebra, local cohomology" }
Is okHttp part of Android or not? According to some references, e.g. Does Android use OkHttp internally? Android is using (or at least was using) okHttp internally under HttpUrlConnection. Still in some recent discussions (e.g. Why HTTP/2 is not supported by Android's HttpUrlConnection?) it is recommended to use okHttp from GitHub rather than Android http APIs. So I am confused. Does anyone have a definitive answer?
From Android 4.4 onwards using OkHttp for its internal `HttpUrlConnection` implementation Source: < Versions of OkHttp used in Android: * Android 4.4: OkHttp 1.1.2 * Android 5.x: OkHttp 2.0.0 * Android 6.0: OkHttp 2.4.0 * Android 7.x: OkHttp 2.6.0 * Android 8.0+: OkHttp 2.7.5 You can check what version of OkHttp Kitkat uses here: < For other Android releases replace `kitkat-release` in the URL with `<your-dessert>-release`.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "android, okhttp" }
How to access previous versions of a Google Docs document We are working simultaneously on some text document using google docs. After one week we need to check some changes so just tried "revision history" (which worked at the beginning) but now it does not work. We tried different browsers and operating systems but it crashes. I would be happy if at least I could get the last version and some other one, so using another "diff" tool I could check the changes. But right now I do not know how to access a previous version. Is it there any way to do this?
1. Open any document 2. Select `File` > `See revision history`.
stackexchange-webapps
{ "answer_score": 4, "question_score": 5, "tags": "google workspace" }
Script keeps prompting me to insert disc into drive G: I have the following script which will delete a file off a BlackBerry. However, every time I run it, it prompts me to insert a disc into drive G. Is it possible to rework it so it does not do that? @ECHO OFF CLS IF EXIST F:\home\user\videos\Star.avi ( ECHO "File Exists" DEL F:\home\user\videos\Star.avi ) ELSE ( IF exist E:\home\user\videos\Star.avi ( ECHO "File Exists" DEL E:\home\user\videos\Star.avi ) ELSE ( IF EXIST G:\home\user\videos\Star.avi ( ECHO "File Exists" DEL G:\home\user\videos\Star.avi ) ELSE ( ECHO "File Doesn't Exist" ) ) )
@ECHO OFF CLS SET DRIVE= FOR %%D IN (E: F: G:) DO ( IF EXIST %%D\home\user\videos\Star.avi ( SET DRIVE=%%D GOTO EXIT ) ) :EXIT IF DEFINED DRIVE ( ECHO "File Exists" DEL %DRIVE%\home\user\videos\Star.avi ) ELSE ( ECHO "File Doesn't Exist" )
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "file, batch file, blackberry, delete file" }
How to use php json_encoded array in jQuery In my php code, I have <?php $test = json_encode($array);//$array is a valid multidimensional array ?> I am passing this variable to a javascript function and I am trying to set this variable to javascript. <script> var test = "<?php echo $test;?>"; </script> (To clarify I am using codeigniter framework and for simplicity I did not use how I am sending the variable to the page) But when I execute the above code, I am getting Uncaught SyntaxError: Unexpected identifier I have checked all my syntax. Thank you in advance.
Don't put the decoded json array inside double quotes in the javascript. Change to this. var test = <?php echo $test;?>;
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "php, javascript, json" }
Pandas: create dataframe from list of namedtuple I'm new to pandas, therefore perhaps I'm asking a very stupid question. Normally initialization of data frame in pandas would be column-wise, where I put in dict with key of column names and values of list-like object with same length. But I would love to initialize row-wise without dynamically concat-ing rows. Say I have a list of namedtuple, is there a optimized operation that will give me a pandas data frame directly from it?
The function you want is from_records. For `namedtuple` instances you must pass the `_fields` property of the namedtuple to the `columns` parameter of `from_records`, in addition to a list of namedtuples: df = pd.DataFrame.from_records( [namedtuple_instance1, namedtuple_instance2], columns=namedtuple_type._fields ) If you have dictionaries, you can use it directly as df = pd.DataFrame.from_records([dict(a=1, b=2), dict(a=2, b=3)])
stackexchange-stackoverflow
{ "answer_score": 41, "question_score": 43, "tags": "python, pandas, dataframe" }
MySQL update rows. Need to update lots of unique rows I am using PHP scripts on my mySQL database. What I have is an inventory of products that is being pulled for a search page. I have this working fine, and my search page is working flawlessly. The only thing I cannot figure out is how to update the stock of each product in the database. I have a new file that needs to match up with the product number and then replace the data in one column of the mysql database. Much like this below mysql database: ProductNumber..................ProductStock 12345678....................................1 New file: 12345678..................5 Basically I need the new file to match with the product number on the mysql and replace the product stock with the new number. All of this in PHP.
You don't say how many rows you got in that database. Usually individual UPDATEs are pretty slow. You can * load your "new stocks" file into a temporary table using LOAD DATA INFILE * make an UPDATE using a JOIN to set the values in your products table This will be a few orders of magnitude faster. Update with the syntax to use on mysql : UPDATE products p JOIN temp_products t ON (p.id=t.id) SET p.stock = t.stock; Note that you need special privileges for LOAD DATA INFILE. You can also use LOAD DATA INFILE LOCAL (check the docs). Or, you can parse the file with PHP, generate an INSERT with multi-values in a temp table, and do a joined update. This will be a little slower than LOAD DATA INFILE, but much much faster than doing 27000 queries.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "mysql" }
What is the probability that after this process the content in two bags remains unchanged? Each of Alice and Bob has an identical bag containing 6 balls numbered 1, 2, 3, 4, 5, and 6. Alice randomly selects one ball from her bag and places it in Bob’s bag, then Bob randomly selects one ball from his bag and places it in Alice’s bag. What is the probability that after this process the content in two bags remains unchanged? I would have thought that the probability would be $\frac{1}{6} + \frac{2}{7}$ as Alice picks 1 out of balls, now Bob has 7 balls and 2 contain the same number. Or should I have multiplied them in this scenario? The balls are indistinguishable.
After the action of Alice there are exactly $7$ balls in the bag of Bob, and for exactly $2$ of them it is true that placing it back in the bag of Alice will restore the original situation. So the probability of this event is $\frac27$.
stackexchange-math
{ "answer_score": 2, "question_score": 4, "tags": "probability" }
QGIS GDAL toolbox - can't edit console call I've noticed a few answers for QGIS/GDAL questions that show how one can edit the console call e.g. < Im using QGIS Essen 2.14.3 via OSGeo4W on Windows 7, and I can't see the pencil button indicated so I'm stuck editing a call in notepad and pasting it into the OSgeo4w shell. Is there an option somewhere I need to change to enable in-tool editing? Has the option simply been removed? ![screenshot of gdal tool window](
Thats because you are running it from the processing toolbox. Don't know why it happens, but it happens for me too. Try going: Raster (menu at top of the screen) > Projections > Warp You should see the pencil button and be able to edit the GDAL code
stackexchange-gis
{ "answer_score": 2, "question_score": 4, "tags": "qgis, gdal" }
Double affiliation: is it understood as simultaneous part-time in each of them? If I write a double affiliation, would it be understood as 1. I'm in both institutes 2. I was in one institute and I am working for the other.
There are many interpretations for dual affiliations. You must explicitly provide an interpretation, if required. You could do so in a footnote on the first page or in the acknowledgements, for example.
stackexchange-academia
{ "answer_score": 3, "question_score": 0, "tags": "affiliation" }
`fprintf` with SD.h's File type I'm using the `SD.h` library to write onto an SD card with the Arduino Uno. I need to write out in a file a template string with some placeholder replaced by certain values, in the way of `printf` behaves. I would use the `fprintf` function, but when I tried this: File dataFile = SD.open("myfile.txt", FILE_WRITE); fprintf(dataFile, "mynumber: %d\n", 100); I got this error: > cannot convert 'File*' to '__file*' for argument '1' to 'int fprintf(__file*, const char*, ...)' How can I manage this?
**printf() makes your executable object ~1000 bytes larger, so you may not want to use it if size is a problem.** The `fprintf` is not intended to use with the SD.h so I think The simple solution that comes into my mind is using sprintf to format your text then write it to the file with the println function File dataFile = SD.open("myfile.txt", FILE_WRITE); char text[100]; sprintf(text,"My number: %d",yournumber); dataFile.println(text);
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "arduino, sd card, printf" }
Is there a way to create a textbox on one page, based on the actions in another page? I give the option for a user to delete a special offer on the `DeleteSpecialOffer` page . If they click "Submit", it will return them to the `SpecialOffers` page. I want to be able to display a message on the `SpecialOffers` page that confirms that the SO was successfully deleted. Is there a way to create this textbox from the `DeleteSpecialOffer` page or possibly just make a hidden textbox visible?
Sure, here's one option: Have the textbox hidden (Visible="False") on the `SpecialOffers` page and when you redirect the user from the DeleteSpecialOffer page, pass a parameter in the URL as so: Response.Redirect("SpecialOffers.aspx?Success=Y"); In `SpecialOffers` check whether this parameter is "Y" and make the textbox visible programmatically. Something like: if(Request.QueryString["Success"]=="Y")) { txtBox.Visible=true; }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c#, asp.net" }
Suppress Duplicate Rows only in the Same Page I am using Suppress Duplicate function to prevent the same item code to be displayed more than once. I have just one question: Is it possible to hide the duplicates only in the same page? For example, Item Code "1111" is displayed in Page-1, no duplication is shown under it. But in case "1111" has a long list in other columns and continues to Page-2, is it possible to display the item code in the first row of Page-2 and then suppressed again? So if it has an even longer list and extends to Page-3, the item code can be displayed again in the top row?
You could add a group by on the item code and place the information about in the group header. That way there are no duplicates, but you have the option to repeat the header with information on each new page.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "birt" }
How to get centriod coordinates of multiple points in binary image_matlab Hi I need to find the centriod coordinates of each points (multiple points in one binary image). ![dotfig.png]( When I use the code A=imread('dotfig.png'); B=im2bw(A) [b,a]=find(B==0); So, I get coordinates in terms of a,b for rows and cols. I got multiple a and multiple b (for 7 points in pic). Actually, I just would like to get seven a and seven b, which represent coordinates for centriods of seven dots in the pic. I know `ginput` might give me similar value. But dont' want to use manual input in my codes. Any suggestion is appreciated!
just use `regionprops`: stats = regionprops(B,'Centroid') Here's a detailed way in how to use it: First I'll generate some random points a=zeros(50); a(ind2sub(size(a),randi(numel(a),7,1)))=1; a=padarray(a,[10 10]); a=conv2(a,fspecial('gaussian',7,1),'same'); b=a>0.02; imagesc(b); Then use regionprops: stats = regionprops(b,'Centroid'); This is just to plot the various centroids: hold on; for n=1:numel(stats) plot(stats(n).Centroid(1),stats(n).Centroid(2),'rx'); hold on text(stats(n).Centroid(1)-4,stats(n).Centroid(2)-4,... ['x=' num2str(stats(n).Centroid(1)) ', y=' num2str(stats(n).Centroid(2))],'Color','w' ); end ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "matlab, binary" }
How to print PDF data from InAppBrowser (PhoneGap) I am using PhoneGap / Steroids for an iOS app. In PhoneGap, I request a pdf from the server. The pdf is received in base64 format. I am able to successfully preview the pdf using InAppBrowser: window.open( "data:application/pdf;base64," + pdf.data, "_blank" ); However what I really need is to send this pdf data to the printer via AirPrint. Is it possible to do this using InAppBrowser? If not, what is the recommended method? Thanks (in advance) for your help
Well, I don't think there is any use for InAppBrowser for this purpose. What you should look instead is for plugin that connects to AirPrint such as Cordova Print Plugin. This allows you to connect to AirPrint from within your JavaScript code. I'm not sure about if it fits all of your purposes, though, but take a look.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "javascript, cordova, pdf, inappbrowser" }
3rd highest salary sql I try to get all 3 highest salary from top 5 employees like this salary 35000 34000 20000 12000 500 40000 25000 41000 90000 550000 query select top 5 (SELECT MAX(grosssalary) FROM Detail) maxsalary , (SELECT MAX(grosssalary) FROM Detail) sec_max_salary, (SELECT MAX(grosssalary) FROM Detail WHERE grosssalary NOT IN (SELECT MAX(grosssalary) FROM Detail )) as third_max_salary but this shows data like this maxsalary sec_max_salary third_max_salary 550000 550000 41000 where as i want data like this maxsalary sec_max_salary third_max_salary 550000 90000 41000
Do a `CTE` and get the `ROWNUMBER()` on `salary DESC` and in outer query fetch the record with rownumber equal to 3. ;WITH CTE AS ( SELECT RN = ROW_NUMBER() OVER (ORDER BY salary DESC), Salary FROM [YourTable] ) SELECT Salary FROM CTE WHERE RN <= 3 **Note:** If you want 3rd highest salary use `RN=3` if you want all top 3 salary then use `RN<=3` If you want top 3 highest salary then you can do this as well: SELECT TOP 3 Salary FROM [YourTable] ORDER BY Salary DESC
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "sql, sql server, highest" }
Rotate corner of triangle around opposite edge I have two triangles in $R^3$: 1. $p_1$, $p_2$, $p_3$ 2. $p_1$, $p_2$, $p_4$ The triangles share points $p_1$ and $p_2$ and thus edge $p_2 - p_1$. I would like to rotate $p_4$ such that it will be diametrically with respect to $p_3$, i.e. the angle between $p_3$ and $p_4$ should be $180$ degrees or $\pi$. I can derive the current angle between $p_3$ and $p_4$: $d_1 = (p_3 - p_1) \times (p_2 - p_1)$ $d_2 = (p_4 - p_1) \times (p_2 - p_1)$ $rad = \arccos(d_1 / |d_1| \cdot d_2 / |d_2|)$ The next step would be to rotate $p_4$ around edge ($p_2 - p_1$) by $\pi - rad$. However I do not know how to rotate a corner of a triangle around the opposite edge. Therefore I was wondering if anybody would know how to accomplish this.
You have the angle $\phi$ and the axis of rotation $\hat{n} = \frac{p_2-p_1}{|p_2-p_1|}$. You only need Rodrigues' rotation formula: $$p_{\text{rot}} = p_4 \cos\phi + (\hat{n}\times p_4) \sin\phi + \hat{n}(\hat{n}\cdot p_4)(1-\cos\theta).$$
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "linear algebra" }
natural log of pi to sixty digits, a reference needed I have found a table of the logs of gamma functions at basic fractions, accurate to 60 decimal digits. It omits $\ln(\Gamma(1/2)) = \ln(\pi)/2$ and I want that number. Where is a cit-able source that contains this this number to high accuracy?
(In know this question is old and answered, but...) For $\ln(\pi)$ the Online Encycolpedia of Integer Sequences has a value to 105 decimal places. It is also citable.
stackexchange-math
{ "answer_score": 3, "question_score": 3, "tags": "pi" }
Minimum packages required to send email I have a fresh install of Ubuntu 12.04 and have configured logrotation on it. Now, I need to know which package I need to install so that it is able to email me the logs. Will just installing `postfix` will work or will I have to install `mailutils` or `sendmail`. Thanks. P.S. As it is a fresh install I don't want to install un necessary packages.
You can use the package `ssmtp` to send emails. I am using this package to send me reports of my daily backups. To install: `sudo apt-get install ssmtp` You will need to edit the files `/etc/ssmtp/ssmtp.conf` and `/etc/ssmtp/revaliases` to use your email account. To test if it works, try to send yourself an email: `ssmtp <your email address>` Then type your message, press `enter`, and finally press `ctrl+d`. For detailed instructions on setting up `ssmtp`, check out this article.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 2, "tags": "12.04, software recommendation, mail" }
elem as this in function I have jquery function: function handleSplittingPrices() { var customerId = $(this).val(); loadSplittingPrices(customerId); } I want to execute it with elem as "this": var elem=$('...'); handleSplittingPrices() <-- here elem will be this How can I do it?
You're looking for the `call` method: handleSplittingPrices.call(elem); Note that `elem` is a jQuery object, not a DOM element, so you won't need to call `$` inside the function.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery" }
Returns all rows which have same column value based on other column value Consider I have the following table: Id | sid | email ___________________________________________________ 1 | 10 | [email protected] 2 | 11 | [email protected] 3 | 10 | [email protected] 4 | 10 | [email protected] 5 | 12 | [email protected] I would like to query all rows which have same "sid" by passing known "email" So if I pass the email as "[email protected]", it should return rows with id number 1, 3, and 4.
Try this : select * from yourtable a inner join ( select sid from yourtable where email = "[email protected]" ) b on b.sid = a.sid
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "mysql, sql" }
Making each word of input an array element For example, say I have input like follows: " see all of these cool spaces " Omit the quotes. What I'm looking for is how to turn that into an array of words. Like this: ['see', 'all', 'of', 'these', 'cool', 'spaces'] Thanks
Here's one way: Use `split` (see String#split): string.split By default, `split` will split the string into an array where the whitespace is, ignoring leading and trailing whitespace. Exactly what you're asking for. This is the same as using the more explicit `string.split(" ")`.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "ruby" }
How can I control a 4026 counter chip from my raspberry pi? I have a 4026 counter chip controlling a seven segment LED display. The current set up is every time I press a button it advances by one digit on the display. See circuit below. This circuit runs on 9v so I haven't been too adventurous in my testing from fear of frying the Raspberry Pi. How can I control this with an Raspberry Pi, regarding 9v vs Raspberry Pis 3,3 volt ? Example circuit. ![enter image description here](
Since there are only output from the Raspberry Pi that should drive the 4026 7-Segment Counter there are only need for a driver circuit. This can be done with transistors, MOSFETs or a driver IC. A simpler way is to change the voltage for the 4026 from 9 volt to 3,3volt its within the IC's working parameter (3-15v). And then replace the current limiting resistors to the 7-segment LED display to fit the new voltage. And now you can interface the 4026 directly to your Raspberry Pi. Ref.: <
stackexchange-raspberrypi
{ "answer_score": 3, "question_score": 0, "tags": "gpio, electronics" }
How to add a legend to a pyplot whose items depend on integer variable? I am implementing a K-Means clustering algorithm. I want to show the clustered data-sets (each a different color) in one scatter-plot. I do this as follows: for i in range(k): plt.scatter(np.array(clustersets[i])[:, 0], np.array(clustersets[i])[:, 1], c=c_map(i)) , where k is the number of centers (-> number of cluster-sets) in my scatter-plot. I now want to add a legend that contains 1 item for each of these data-sets. This hence depends on the pre-defined number `k`. How can I add a legend such that it will cover all the different items in my scatter-plot, disregarding what `k` is?
If I understood correctly, you want a legends going from `0` to `k`. You can use the `label` option with a fiel specifier `%d` to specify the dataset. for i in range(k): plt.scatter(np.array(clustersets[i])[:, 0], np.array(clustersets[i])[:, 1], c=c_map(i), label='Dataset %d' %i) plt.legend()
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, matplotlib, legend, k means, scatter plot" }
Homography as a product of two perspectivities > Prove that if we work with the field $\mathbb{C}$, an homography defined in a line $l$ of the projective plane $h : l\to l$ can be expressed as a product of two perspectivities. With $\mathbb{K}=\mathbb{R}$, give and example of a homography that required to be the result of the product of three perspectivities. I studied that an homography $h:l \to l$ can be expressed as a product of three perspectivities and I understood the proof, but I don't see what changes in $\mathbb{C}$.
In $\mathbb{C}$ every projectivity has a fixed point. Let $F\in l$ be a fixed point of $h$. Let $s$ be an arbitrary line through $F$ and $P$ be an arbitrary point outside $l$ and $s$. If $A$ and $B$ are two points on $l$ let $A'$ be $PA\cap s$, $B'$ be $PB\cap s$ and $Q=A'h(A)\cap B'h(B)$. Then the product of projectivities $$l\overset{P}{\doublebarwedge}s\overset{Q}{\doublebarwedge}l$$ is $h$.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "problem solving, projective geometry" }
Button in LCDUI for Symbian S60 5th edition Hi I am an Android developer but I am new to development on Symbian. I couldn't find any classes to put a button on the form. How do I do it on Symbian. Am not sure whether I am doing the right thing.
Use TextItem and set its style to button. This is a pure J2me thing and has nothing specifically to do with Symbian
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, java me, mobile, symbian, nokia" }
Find the value of $α^3+β^3+γ^3+δ^3$ given that $α,β,γ,δ$ are roots of $x^4+3x+1=0$ Let $α,β,γ,δ$ be the roots(real or non real) of the equation $x^4-3x+1=0$. Then find the value of $α^3+β^3+γ^3+δ^3$. I tried this question as $S_1=0, S_2=0, S_3=3, S_4=1$ and then I used $S_1^3$ to find the the value of asked question, but i am not able to factorise it further and it seems like a dead end. Moreover it is very lengthy method so can you tell of any other more elegant way of approaching this question?
$$x^4-3x+1=0\implies x^3=3-\frac{1}{x}$$ This is satisfied by each of the roots, so $$\Sigma x^3=\Sigma3-\Sigma\frac{1}{x}$$ Can you finish?
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "polynomials, roots" }
Plugin for editing options on multisite? does anyone know of a plugin for mass editing of settings on a multisite installation? Something like Plugin Commander for Settings?
i think this is what you looking for: <
stackexchange-wordpress
{ "answer_score": 1, "question_score": 8, "tags": "multisite, plugins, options" }
Bootstrap columns not get alligned when using columns of varying height I have 4 divs, div 2 is very lengthy, div 1,3,4 are of equal sizes, I want them to display in a compact form, but it displays full contents of div2 then only displaying div3 ,it displays div 3 as a new row after all the contents of first row <div class ="row"> <div class="col-xs-12"> //content 1 </div> <div class="col-xs-12"> //content 2 </div> </div> <div class ="row"> <div class="col-xs-12"> //content 3 </div> </div> <div class ="row"> <div class="col-xs-12"> //content 4 </div> </div> please help me
Solved the problem myself Used row inside col div <div class="row"> <div class="col-xs-6"> <div class="row"> <div class="col-xs-12"></div> <div class="col-xs-12"></div> </div> </div> <div class="col-xs-6"> <div class="row"> <div class="col-xs-12"></div> </div> </div> </div>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "css, twitter bootstrap" }
How to create a newsletter sign up block in Drupal What is the best way to create a e-news subscribe block in Drupal with the form to collect information such as first and last name, email address and interests? I have spent some time Googling how to do this but am running into only very outdated information. Can someone point me in the right direction? Thanks! Using Drupal 7.50 with CiviCRM 4.7.15
If you are using Drupal 7 I would use Drupal Webform \- together with the Webform CiviCRM integration module, since the Webform module let's you set the form to show within a block. These are pure drupal webform settings. This is done under Adv Settings, which is on the Form settings tab ie at node/xx/webform/configure "Available as block: If enabled this webform will be available as a block." There are then controls as to whether you show the whole node in the block or just the form, which probably isn't an issue in your case. Then set the civicrm settings on the webform to collect the various fields you want and add them to the Group that is used for the newsletter.
stackexchange-civicrm
{ "answer_score": 3, "question_score": 4, "tags": "drupal, newsletter, subscribe" }
Angular, how to check map keys I have the problem with below map, I know, that there is a object (key value), but when I checked it in if loop: > if (!!state.get(namePersons).has(workData)) { console.log('true'); } I got error about: > cannot read property has Map is: Map<namePersons, Map<workData, InformationModel>>>
If the value of **`namePersons`** is not exitsed in Map then `get()` will return undefined that's the reason you are getting the error.. Try this : if (!!state.get(namePersons) && !!state.get(namePersons).has(workData)) { console.log('true'); } (may be you need check the condition as per requirement), refer here for more info about **`Map in Typescript`**
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "angular, typescript, ngrx" }
Revalidate field using BootstrapValidator I got a project from a new cutomer and the old programmer used BootstrapValidator 0.4.5 in this project. The problem is that I build a autofil action for some fields, but the validation it not working for this fields after autofill or more excat after the autofill the validation is not call. The validation only works for real user action. Here is a part how I made the autofill. // autofill if (options.targetBank) { options.targetBank.val(data.bankData.name).change(); } // maybe how to call the revalidation action $( "#inputBank" ).change(function() { $(this).revalidation(); }); And I dont know how to call the validation, because there is no more documentation for 0.4.5. Has anyone an idea ?
You could use the API method **`revalidateField`** , It's used when you need to revalidate the field which its value is updated by other plugin : $( "#inputBank" ).change(function() { $(this).closest('form').bootstrapValidator('revalidateField', $(this).prop('name')); }); Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "javascript, jquery, bootstrapvalidator" }
Replace language specific characters in python with English letters Is there any way in Python 3 to replace general language specific characters for English letters? For example, I've got function `get_city(IP)`, that returns city name connected with given IP. It connects to external database, so I can't change the way it encodes, I am just getting value from database. I would like to do something like: city = "České Budějovice" city = clear_name(city) print(city) #should return "Ceske Budejovice" Here I used Czech language, but in general it should work on any non Asian langauge.
Try `unidecode`: # coding=utf-8 from unidecode import unidecode city = "České Budějovice" print(unidecode(city)) Prints `Ceske Budejovice` as desired (assuming your post has a typo). Note: if you're using Python 2.x, you'll need to decode the string before passing it to `unidecode`, e.g. `unidecode(city.decode('utf-8'))`
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 6, "tags": "python, string, encoding, character encoding, decoding" }
GAE ndb design, performance and use of repeated properties Say I have a picture gallery and a picture could potentially have 100k+ fans. Which ndb design is more efficient? class picture(ndb.model): fanIds = ndb.StringProperty(repeated=True) ... [other picture properties] or class picture(ndb.model): ... [other picture properties] class fan(ndb.model): pictureId = StringProperty() fanId = StringProperty() Is there any limit on the number of items you can add to an ndb repeated property and is there any performance hit with storing a large amount of items in a repeated property? If it is less efficient to use repeated properties, what is their intended use?
Do not use repeated properties if you have more than 100-1000 values. (1000 is probably already pushing it.) They weren't designed for such use.
stackexchange-stackoverflow
{ "answer_score": 33, "question_score": 12, "tags": "python 2.7, google app engine, google cloud datastore, app engine ndb" }
Phrase for arranging a meeting - 'anytime you can' I want to arrange an interview, pointing out that I am available at any time convenient to him. I don't know the correct form for saying this. And although he has not asked for my contact information I do want to send it. Are these sentences correct? > anytime be convenient for you works for me. > > and for offering contact information: > > MY skype name is ... and my phone number is ...
The traditional phrase is _at your convenience_. > We are so interested that we are willing to come to Waterside, at your convenience, to talk with you and your guardians about doing a movie about your life. — Source.
stackexchange-english
{ "answer_score": 2, "question_score": 0, "tags": "expressions, phrase requests" }
mySQL Datatype for storing numbers with abbreviated suffix? What would be the proper datatype for a number with an abbreviated suffix (such as m for million)? For example, normally the datatype for **100.20** would be: `DECIMAL` of 5,2. What should the datatype be for **100.20M**? Is there a proper datatype similar to `DECIMAL` that would maintain such rigidness?
There is no datatype that will "understand" the abbreviations. If you want MySQL to treat the data as numbers (for expression evaluation or sorting) it is best for you to evaluate the abbreviaton yourself and store the number with all the digits, so 100.20M is 100200000-- specifying as many digits as your data will require. Formatting it with the suffix is for the presentation layer, not the DB.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "mysql" }
adding date column to the appending output csv file in python I use this code below to combine all csv files : below each file has 10,000 rows : billing_report_2014-02-01.csv billing_report_2014-02-02.csv : fout=open("out.csv","a") for num in range(1,10): print num for line in open("billing_report_2014-02-0"+str(num)+".csv"): fout.write(line) for num in range(10,29): print num for line in open("billing_report_2014-02-"+str(num)+".csv"): fout.write(line) fout.close() but now I want to add new date column to the out.csv file how can I add date column and have value of "2014-02-01" to every row that I append billing_report_2014-02-01 to out.csv, and value of "2014-02-02" to every row that I append billing_report_2014-02-02 to out.csv how can I approach this ?
List the filenames you want to work on, then take the data from that, build a generator over the input file that removes trailing new lines, and adds a new field with the date... eg: filenames = [ 'billing_report_2014-02-01.csv', 'billing_report_2014-02-02.csv' ] with open('out.csv', 'w') as fout: for filename in filenames: to_append = filename.rpartition('_')[2].partition('.')[0] with open(filename) as fin: fout.writelines('{},{}\n'.format(line.rstrip(),to_append) for line in fin)
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "python, csv, append" }
Deleting a category from WordPress admin does it remove it completely from the database? When you delete a category in the admin of WordPress does it completely remove it from the database? I had a few categories with the same naming conventions (different slugs) but now deleting any categories having the same names and creating a complete new category but I wanted to make sure the old categories is completely erased out of the database, does this happen automcatically?
Yes, the categories are stored in `wp_terms` table which contains the term_id, name and slug. Deleting the category in admin panel removes the three values along with it.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "categories, database" }
The localization of a ring at a maximal ideal I am working on the following problem: If $R$ is a local ring whose maximal ideal is denoted $\mathfrak{p}$ then show that $R \cong R_\mathfrak{p}$. $R_\mathfrak{p} := \\{\frac{r}{u} : r\in R, u\in R\setminus\mathfrak{p}\\}/\sim$ where $\frac{r}{u} \sim \frac{r'}{u'}$ if $\exists \tilde{u}\in R\setminus\mathfrak{p}$ such that $\tilde{u}(ru' - r'u) = 0$. So far I have shown that any element $x \in R\setminus\mathfrak{p}$ must be a unit. Then i thought about trying to show that the homomorphism $\phi:R\to R_\mathfrak{p}$ is a bijection however I cannot see how to show either injectivity or surjectivity. For the surjective case I thought perhaps one could show that every element $\frac{r}{u} \in R_\mathfrak{p}$ is equivalent to $\frac{r}{1} \in R_\mathfrak{p}$ but this does not seem to work. Any help is much appreciated, thanks.
Just define $f: R \longrightarrow R_{\mathfrak{p}}$ as $f(x) = \frac{x}{1}$. This is a well defined ring homomorphism. Injectivity: Suppose $\frac{x}{1} = 0 = \frac{0}{1}$. Then there exist $u \in R \setminus \mathfrak{p}$ such that $u(x - 0) = 0$. But $u$ is invertible, so $x = 0$. Surjectivity: for all $\frac{x}{y} \in R_{\mathfrak{p}}$ we have $y\in R \setminus \mathfrak{p}$, so $y$ is invertible. Since $\frac{x}{y} = \frac{xy^{-1}}{1}$, the we have that $f$ is surjective.
stackexchange-math
{ "answer_score": 7, "question_score": 6, "tags": "commutative algebra, localization, local rings" }
How to repeat the same image a number of times in html? I want to repeat an image-"box1" throughout the width of the page. I tried the following but it isn't working. var count = $(window).width() / $("#box1").width(); for (var i = 1; i <= count; i++) { var paragraph = document.getElementById("top-section"); paragraph.innerHTML += "<img src='images/box1.png' id='box1'html>"; } #top-section { float: left; } <div id="top-section"></div>
This one works fine for me. Check it out... Just clone element what u need and append it inside the section. var count = $(window).width() / $(".box1").last().width(); for (var i = 1; i <= count; i++) { $("#top-section").append($(".box1").last().clone(true)); } #top-section { float: left; } <script src=" <div id="top-section"> <img src="images/box1.png" class="box1"> </div>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "javascript, jquery, html, css" }
Need suggestion on how can i start implementing the attached UI I am new to building UIs, as a part of a project i was asked to come up with a UI (screenshot attached). Before posting it here, i have done my research and could not find a solution. Please look at the attached screenshot, and need your suggestion on how can i achieve it, or, suggest any site which has UI similar to attached UI design.![enter image description here]( Thanks for your help.
It's a 3D carousel, a component for cycling through elements. I found this intro to CSS 3D transforms, there is not exactly what you need, but working on the angles of rotation I think you can achive your concept.
stackexchange-ux
{ "answer_score": 0, "question_score": 0, "tags": "carousel" }
Get Timestamp from Database I have data stored in a db table, with an auto timestamp. In a module I want to then display a result based on the latest timestamp. It's not working and I'm getting an error Warning: strtotime() expects parameter 1 to be string The query I've written is: //Get Latest Update TimeStamp $db = JFactory::getDBO(); $query = "SELECT MAX( timestamp ) FROM #__service_status ORDER BY timestamp DESC LIMIT 1"; $db->setQuery( $query); $timestamp = strtotime($db); Then I'm trying to echo it with: <?php echo date("m-d-Y", $timestamp);?>
You need to add this in your code, after $db->setQuery( $query); $db->setQuery( $query); $var1= $db->loadResult(); $timestamp = strtotime($var1); Hope this help
stackexchange-joomla
{ "answer_score": 3, "question_score": 4, "tags": "php, module, joomla 3.4, mysql" }
Replace Printed Statement with timing sequence in C I want to create a program to print out the first printf statement, Then in the next line, it will clear the first printf statement and print the next statement. Please help me fix the code. printf("Please wait while Loading..."); Sleep(2132); printf("Done Loading");
Assuming `stdout` is a terminal or window that supports overwriting of text, then the simple solution is to output a `'\r'` (carriage return), overwrite with spaces, and then print the second string. printf("Please wait while Loading..."); fflush(stdout); Sleep(2132); printf("\r"); /* output the number of space characters equal to length of the preceding string */ printf("\r"); printf("Done Loading"); fflush(stdout); There is the problem that not all terminals/windows support this correctly. In that case, you'll need to use techniques specific to the terminal/window and host system. This approach may also not work if standard output has been redirected to a file or pipe.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "c" }
free group actions on a contractible topological space Let $\Sigma_k$ be the symmetric group on $k$-letters. Let $W$ be a **contractible** topological space with a **free** $\Sigma_k$-action (from the left). Let $X$ be a $CW$-complex and let $X^k$ be the Cartesian product of $k$-copies of $X$. Let $\Sigma_k$ act on $X^k$ from the right by permuting the order of coordinates. Then we have a space $$ W\times _{\Sigma_k} X^k=W\times X^k/ (\sigma\cdot w,a)\sim (w,a\cdot \sigma) $$ where $w\in W, a\in X^k$ and $\sigma\in \Sigma_k$. **Question:** whether do we have $$ W\times _{\Sigma_k} X^k\simeq X $$ or not? What shall I do when meeting such problems?
A couple of scattered things to address the "how to deal with" part of the question. * * * If $X$ is connected, then probably so is $X^n$, and so you are looking at a fibration $$ X^n \to X^n // \Sigma_n \to \mathbf{B}\Sigma_n $$ for which the Leray-Serre spectral sequences are usually called Cartan-Leray, and they look like $$ H^{\mathrm{gp}}_p ( \Sigma_n ; H_*(X,\mathbb{k})^{\otimes n}_q ) \Rightarrow H_{p+q} (X^n // \Sigma_n ; \mathbb{k}) $$ * * * In the very special case that $X$ is a strictly abelian group (that is, a product of Eilenberg-MacLane spaces), one can extend the power sequence $n\mapsto X^n$ to a functor on the category **FPartial** of finite partial functions: for $f : s \nrightarrow t$ and for $x : s \to X$, define $$ (f_* x)_j = \sum_{i : f(i) =j} x_i $$ With this data one can use some work by Stanislaw Betley to study what happens to particular $H_p(X^n // \Sigma_n)$ as $n\gg p$.
stackexchange-mathoverflow_net_7z
{ "answer_score": 1, "question_score": 1, "tags": "at.algebraic topology, gt.geometric topology, homotopy theory, group actions, symmetric groups" }
Change hostname for windows server 2012 R2 data center Currently we are having 3 production domain servers in azure with BizSpark subscription 1. Windows Server 2012 R2 datacenter - AD, DNS server (Server-03) 2. Windows Server 2012 R2 essentional server (Server-06) 3. Windows Server 2012 R2 datacenter - File server (server-10) Now we have decided to move for Pay-as-go subscription. since all the server in azure while recreating the servers with latest image in new subscription we have decided to change its hostname orderly as 1.Server-01, 2.Server-02, 3.Server-03 Currently 50 client computer is connected to this domain How we have to prepare for changing the host name? What process need to be done at server and client computer side? Please kindly share your best suggestions Thanks, Nihal
Assuming there isn't anything special about a Domain Controller in Azure, you can simply rename the servers. They'll update their corresponding A records (and optionally PTR records) in the AD DNS zone. You shouldn't need to do anything on the client machines, but if you'd like you can either flush their DNS cache or reboot them after the server rename to make sure they resolve the new server names correctly.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 0, "tags": "domain name system, active directory, windows server 2012, azure" }
Give an example of a measure which is not complete Give an example of a measure which is not complete ? A measure is complete if its domain contains the null sets.
The canonical example is the Borel measure on the Borel $\sigma$ algebra (the $\sigma$ algebra generated by the open intervals) on $\mathbb{R}.$ This example is often used as a motivation for the construction of the Lebesgue measure.
stackexchange-math
{ "answer_score": 11, "question_score": 2, "tags": "real analysis, measure theory" }
Save pandas csv to sub-directory I am trying to save the output of the following code to a subdirectory: for gp in g: filename = gp[0] + '.csv' print(filename) gp[1].to_csv(filename) I have created the subdirectory first: os.makedirs('MonthlyDataSplit') But I can't find any information as to how to use `to_csv` to save to a subdirectory rather than the current directory. One approach I was thinking was to use the `with "MonthlyDataSplit" open as directory` but I can only find the equivalent for opening a file in a subdirectory.
Basically you can build a path including subdirectories and pass this as the path arg to `to_csv`: root = 'MonthlyDataSplit' for gp in g: filename = gp[0] + '.csv' print(filename) gp[1].to_csv(root + '/' + filename) You need to add slash separators to indicator what is a directory name and what is a filename, I would propose using `os.path.join` to simplify this process: In [3]: import os root = 'MonthlyDataSplit' os.path.join(root, 'some_file.csv') Out[3]: 'MonthlyDataSplit\\some_file.csv' For further subdirectories you can just add a new level: In [8]: import os root = 'MonthlyDataSplit' day = 'Day' subdir = os.path.join(root, day) final_path = os.path.join(subdir, 'some_file_name') final_path Out[8]: 'MonthlyDataSplit\\Day\\some_file_name'
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 9, "tags": "python, csv, pandas, filepath" }
Get current user network credentials from within WWF custom activity I'm developing custom workflow step for MS CRM 2011. I wondering is it possible to retrieve `NetworkCredentials` object representing current user who running this workflow? Does this information present in `CodeActivityContext` object? Here is how Activity definition looks like: public class CustomActivity : CodeActivity { protected override void Execute(CodeActivityContext context) { ... } }
Nope. I believe that you would not be able to do that. All the async jobs are done in security context of account that is used for AsyncService login.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, dynamics crm 2011, workflow foundation" }
$n\le 20$ What is the maximum number of digits representing $n$ with base $4$? > $n\le 20$. What is the maximum number of digits representing $n$ with base $4$? This is a question on a sample test that I'm studying for. My prof hasn't gone over it in class, can someone direct me or help me with the procedure to this question? So to write 20 in base 4 notation would mean (thanks to nikita2) $20=16+4=4^2+4^1=1⋅4^2+1⋅4^1+0⋅4^0$
If $n=20$, $20=16+4 = 4^2 + 4^1= 1\cdot4^2 + 1\cdot4^1 + 0\cdot4^0$ So $20 \sim 110$, and maximum number is $3$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "algebra precalculus, discrete mathematics" }
Prerequisite mathematics for nonlinear systems I have a background in electrical engineering and linear control systems. I want to learn nonlinear systems. There is a book Nonlinear systems by Hassan K. Khalil. The book has a lot of advanced mathematics with proofs. My question is, are there some good books to learn the math that is in this book?
You will need some (linear) algebra, analysis, and dynamical systems for that book. For linear algebra and analysis, any book would do the job. For dynamical systems you may look at the books by Strogatz, "Nonlinear Dynamics and Chaos" or by M.W. Hirsch, S. Smale, and R.L. Devaney, "Differential equations, dynamical systems, and an introduction to chaos". They are both quite accessible.
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "reference request, self learning, book recommendation, nonlinear system" }
Hosting classical asp project in local iis 7 I have one classic asp project. and i am trying to host on local IIS7 but i am getting below error when i tried to browse that web application. An error occurred on the server when processing the URL. Please contact the system administrator. If you are the system administrator please click here to find out more about this error.
Try this guide: < And this other to show error details: <
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "asp classic, iis 7" }
Will installing .NET 1.1 or 2.0 on my computer that already has .NET 4.5 screw things up? I sometimes feel like looking at the source code as it might have been inside an assembly when it was in .NET 2.0 or .NET 1.1. For example, the APM methods such as `FileStream.BeginRead` etc. have since .NET v4.0 been implemented using TPL but I want to see what the source code of this method was like during .NET 2.0 days or at .NET 1.1 time. So, I would like an earlier version of the whole framework on my machine though I would not want it to replace anything in the GAC or screw up ASP.NET or IIS installations telling them that they need to use it because it was installed later than the presently existing .NET 4.5.x. Will installing .NET 1.1 on my 64-bit Windows 7 Home Premium Edition laptop be safe or will it screw things up?
Not according to MSDN.aspx): > ## Compatibility and side-by-side execution > > If you cannot find a suitable workaround for your issue, remember that the .NET Framework 4.5 runs side by side with versions 1.1, 2.0, and 3.5, and is an in-place update that replaces version 4. For apps that target versions 1.1, 2.0, and 3.5, you can install the appropriate version of the .NET Framework on the target machine to run the app in its best environment. For more information about side-by-side execution, see Side-by-Side Execution in the .NET Framework.aspx). But note that .NET 1.1 is not compatible with Windows 8 or later - you _might_ be able to unpack the installer to get to the assemblies if you just want to decompile them, though.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": ".net" }
.NET DateTime Does Not Have a Predefined Size Since DateTime is a struct with members that appear to break down into simple mathematical values, I'm not sure why using sizeof() on it produces the message in the question title.
Because the CLR can only determine the size at runtime... one of the reasons for this is "padding" (platform dependent)... > For all other types, including structs, the sizeof operator can be used only in unsafe code blocks. Although you can use the Marshal.SizeOf method, the value returned by this method is not always the same as the value returned by sizeof. Marshal.SizeOf returns the size after the type has been marshaled, whereas sizeof returns the size _as it has been allocated by the common language runtime, including any padding_. Ref. see also How do I check the number of bytes consumed by a structure?
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": ".net, datetime, struct, size, sizeof" }
How many elements of order $10$ are there in the symmetric group $S_7$? I have a feeling you use Sylow's Theorems but I'm not sure where to start, any hints?
If you write a permutation in disjoint cycle notation: $(\alpha_1 \alpha_2 ... \alpha_{n_1})(\beta_1 ... \beta_{n_2})...$ then the order of the permutation is the lowest common multiple of the $n_i$. So it is clear that elements of order $10$ in $S_7$ must have cycle type $(a b)(c d e f g)$. How many of these are there? Well there are $7$ choices for $a$, then for each choice there are $6$ choices for $b$ etc. We get $7!$ choices for $a,b,c,d,e,f,g$. Divide by $2$ to account for counting $(a b)$ and $(b a)$ as the same. Divide by $5$ to do the same for the $5$-cycle $(c d e f g)$. Thus there are $7!/10 = 504$ elements of order $10$ in $S_7$.
stackexchange-math
{ "answer_score": 3, "question_score": 1, "tags": "abstract algebra" }
How do I turn on port forwarding with Ubuntu? $ssh -f -N -D 0.0.0.0:80 localhost Permission denied (publickey). I don't have anything in my `~/.ssh` directory. I'm logged in as root.
You need to create key pair first. do this: ssh-keygen -t dsa cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
stackexchange-serverfault
{ "answer_score": 0, "question_score": 0, "tags": "linux, ubuntu, unix, http" }
How to merge path in Eclipse package explorer hierarchical view I'm using eclipse in MacOS,and I set package explorer to hierarchical view now,package look like this: > **util** > > * org > * abc > * db > * sql > * Connection.java > but in win7,look like this: > **util** > > * org.abc.db.sql > * Connection.java > they can auto merge empty package path how can I merge empty package path in eclipse @ MacOS?
Open the little triangle menu on the top of the view and select filters. This will open a dialog window where you can configure several aspect of the view. One of them is "empty parent packages" which will hide those packages if it is enable.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "eclipse" }
Python split array into intersecting subarrays I would like to split an array into equally long intersecting subarrays (last element of previous array coincides with first element of the next array and with periodic boundary conditions). E.g. myarray = np.arange(18) output: splitarray = [[0,1,2,3,4],[4,5,6,7,8],[8,9,10,11,12],[12,13,14,15,16],[16,17,0,1,2]] (the 3 last elements of the last subarray correspond to the first 3 elements of the initial array!) What is the most efficient way to implement this in Python?
You could use skimage's `view_as_windows` to take overlapping views of the input array, and concatenate the first `w-1` items accordingly for the last window: from skimage.util import view_as_windows def view_strided_with_roll(a, w): a = np.r_[a, a[:w-1]] return view_as_windows(a, window_shape=w, step=w-1) * * * myarray = np.arange(18) view_strided_with_roll(myarray, 5) array([[ 0, 1, 2, 3, 4], [ 4, 5, 6, 7, 8], [ 8, 9, 10, 11, 12], [12, 13, 14, 15, 16], [16, 17, 0, 1, 2]])
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "python, arrays, numpy" }
Can I create a single style or data trigger for 50 WPF Labels that changes background color depending on view model boolean values I have a requirement to display around 50 Labels that would change background color depending on the value of a view model boolean property. Each Label is associated with a different view model boolean property. How can I create a single style to do this that I can associate with all 50 labels, so that I don't have to declare a style for every label. Is there a way I can apply a SINGLE style and/or data trigger to ALL 50 labels, since each label will be bound to a different view model boolean property.
> I am well aware of how global styles work. My SPECIFIC question: is there a way I can apply a SINGLE style or data trigger to ALL 50 labels, since each label will be bound to a different view model boolean property. No. You cannot dynamically change the binding of a `DataTrigger` unless you create it programmatically. I am afraid there is no way to dynamically just replace the binding path of a `DataTrigger` and re-use the rest of the style or template in XAML.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "c#, wpf, styles, label" }