INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Access token after authorize in Auth0 Should I keep the token in the local store itself, or should I save it myself? I call the method `angularAuth0.authorize()`; Then in another controller I check the token using the `authService.isAuthenticated()` method and it constantly returns false.
You can use `localStorage` or `sessionStorage` ... ,a better way to share data between controllers is to use services and to check authenticity, expired-token etc... you can use interceptors
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "angularjs, auth0" }
T-SQL query fails when data is lowercase because database holds it in capitalization In my database all the data is capitalized, for example Last Name (`BRIERTON`). When I run my query in lowercase like (`brierton`), it will not find it. Is it possible to put something in the query to search both capital or lowercase so that it does not think it does not exist for `[pye_nlast] AS "Name Last"`? SELECT [pye_nlast] AS "Name Last", [pye_nfirst] AS "Name First", [EmployeeTC_No] AS "Employee TC #", [EmploymentType] AS "Employment Type", [RetentionCode] AS "GS #" FROM [OnBaseWorking].[dbo].[Employees] WHERE EmployeeTC_No != 'Not Assigned' AND pye_nlast = '@primary' Any help with this would be greatly appreciated!
You can just force lower case: lower(pye_nlast) = lower(@primary) I'm not sure why you are enclosing `@primary` in single quotes. That is suspicious. Or, if the data really is all in upper case: pye_nlast = upper(@primary)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, sql server, tsql" }
Are basic replacement ciphers always bad for structured data encryption? I have read that basic replacement ciphers, such as replacing one byte with another specific byte at each location, are far less effective with non-randomized data. My question is, can this problem be mitigated to the point where basic ciphers can be effective on structured data by encrypting the data with other methods before passing it through the basic cipher? For encrypting exclusively highly structured data, are basic substitution ciphers useful from early on in the encryption process, such as directly after something simple like a single XOR, or only after heavy encryption or should such basic replacements be avoided for this purpose all together?
A good encryption should produce data that are indistinguishable from a random stream. If you simply replace bytes with other bytes, and each byte has always the same replacement, many statistical characteristics of the original message remain. For instance, if the original message is text, then the frequency of each letter will remain also after applying byte-by-byte replacement. > by encrypting the data with other methods before passing it through the basic cipher If you encrypt the data with other methods, for instance with AES, there is no need to do any further encryption of the encrypted message. AES is unbreakable. The question about multiple encryption was answered on SE many times. See for instance this.
stackexchange-crypto
{ "answer_score": 3, "question_score": 1, "tags": "encryption, substitution cipher" }
Joomla Upgrade, stuck on checking and cleaning i am trying to upgrade joomla from 1.5 to 2.5.2 but it stucks on Checking and cleaning... i am using google chrome, My Problem Screen Shot:< i have also tried the solution from here jUpgrade Extension stuck during the update to Joomla 2.5.8 but didn't worked. please help.
I have found very useful information please follow these steps to upgrade joomla. 1- CURL must be enabled, which was my originally error. 2- Go to the administrator panel and set the temp path to /tmp 3- Enable the Gzip 4- Upload and install. com_jupgrade-2.5.2 file. enjoy!.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "joomla2.5, upgrade, joomla1.5" }
What would the magento 2 equivalent of Mage::getModel('customer/customer')->loadByEmail(); be? What is the equivalent of this code in magento 2? Mage::getModel('customer/customer')->loadByEmail();
Please use this code: <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $customer = $objectManager->get('Magento\Customer\Model\Customer'); $customer->setWebsiteId('1'); $customer->loadByEmail('[email protected]'); ?>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "model, magento2" }
JSONP AJAX Call Error in IE9 I am making a jsonp call as below .Its a cross domain call Which works fine in FF but in IE9 it fails and I see following message in IE . SEC7112: Script from was blocked due to mime type mismatch I saw this article < where it says it will ignore response with No-Sniff response. So that header depends on server ? How do I fix it ? Is there any workaround ? $.ajax({ type: 'POST', url: ' data: 'action=delete&id=121', contentType: 'application/javascript', dataType: 'jsonp', success: function(data) { alert(data.fromname); }
As the error in MSDN says: > SCRIPT and STYLESHEET elements will reject responses with incorrect MIME types if the server sends the response header X-Content-Type-Options: nosniff. This is a security feature that helps prevent attacks based on MIME-type confusion. try sending the "X-Content-Type-Options: nosniff" in the server side of your page, if this does not works with ie, you just need to touch the www.othersite.com server headers. ie sometimes is a headache.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "jquery, ajax, internet explorer, cross domain, jsonp" }
run nfs server version 3 only I'm a RHEL guy, and new to debian/ubuntu, I have just setup an nfs server, and when I mount a share on a client, it uses version 4, how can I get the server to run with nfs version 3 only? PS: our company usues JAVA application and it only works with NFS V3, if we use V4, the application starts acting up. Thank you
You can force the version with the `nfsvers` mount option: mount -t nfs -o nfsvers=3 nfs:/home /home
stackexchange-serverfault
{ "answer_score": 3, "question_score": 2, "tags": "linux, ubuntu, debian, nfs" }
mean of the select number of numerical values from a column From the column Age I want to select age group between (15 & 45) and then replace the missing values with the mean of age group (15 & 45) [IN]: train['Age'].isnull().value_counts() [OUT]: False 714 True 177 Name: Age, dtype: int64 how do I write this code? Most solutions are referring to boolean based outputs train['Age'].fillna((train['Age'] > 15 & train['Age'] < 45).mean()) TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool] train['Age'].fillna((train['Age'] > 15 & train['Age'] < 45).mean()) Age groups are spread out between 1 and 80 From the column Age I want to select age group between (15 & 45) and then replace the missing values with the mean of age group (15 & 45)
Add parentheses and `loc` for column `Age`: m = train.loc[(train['Age'] > 15) & (train['Age'] < 45), 'Age'].mean() Or use `Series.between`: m = train.loc[train['Age'].between(15, 45, inclusive=False), 'Age'].mean() And laste replace missing values: train['Age'] = train['Age'].fillna(m)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, pandas, numpy, mean" }
Why is $A \propto 1/r^3, B \propto 1/r^4$, far away from circular loops Two equal circular current loops are placed coaxially with each other. The loops have equal but opposite currents $I$. $$ A \propto r^{-l} $$ $$ B \propto r^{-k} $$ , where $A$ is the vector potential, and $B$ is the magnetic field. What is $l$ and $k$, when you are at a distance far away? I thought that I could approximate this system as a dipole system, which should imply that $A \propto r^{-2}, B \propto r^{-3}$, however the correct answer is $l=3, k=4$, and I can't seem to understand why. ![enter image description here](
A single current loop is already a magnetic dipole, thus having a far field $$A \propto r^{-2},$$ $$B \propto r^{-3}.$$ (See especially the section Magnetic dipole - External magnetic field produced by a magnetic dipole moment.) Hence, when combining two opposite current loops (i.e. two opposite magnetic dipoles) separated by a small distance, you get a magnetic quadrupole. The far fields of the two dipoles nearly cancel, and you get one more power of $r^{-1}$ in the resulting quadrupole field: $$A \propto r^{-3},$$ $$B \propto r^{-4}.$$
stackexchange-physics
{ "answer_score": 2, "question_score": 0, "tags": "magnetic fields, electric current, magnetostatics, multipole expansion" }
AWS - Create an AmazonSNSClient I want to create a AmazonSNSClient, I use this piece of code: AmazonSNSClient snsClient = (AmazonSNSClient) AmazonSNSClientBuilder.standard().withCredentials(new AWSStaticCredentialsProvider(new PropertiesCredentials(is))).build(); but I get this error: > Exception in thread "main" java.lang.UnsupportedOperationException: Client is immutable when created with the builder. > > at com.amazonaws.AmazonWebServiceClient.checkMutability(AmazonWebServiceClient.java:937) > at com.amazonaws.AmazonWebServiceClient.setRegion(AmazonWebServiceClient.java:422)
It is better if you can put the parameters which you have passed as `is` or else you can try building the client as below, If your `is` is referring to a credential file then you can use the credentials directly with this method, BasicAWSCredentials basicAwsCredentials = new BasicAWSCredentials(AccessKey,SecretAccessKey); AmazonSNS snsClient = AmazonSNSClient .builder() .withRegion(your_region) .withCredentials(new AWSStaticCredentialsProvider(basicAwsCredentials)) .build(); or else if you are going to give permission through an IAM role then you can use InstanceProfileCredentialProvider like below, AmazonSNS sns = AmazonSNSClientBuilder .standard() .withCredentials(new InstanceProfileCredentialsProvider(true)) .build();
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "java, amazon web services, amazon sns" }
Moving Windows.Form in Word Is it possible to move for example a checkbox in word? There is no method provided for the controls so I tried to remove and then add it again at the new location. My problem with this "solution" is, that the control gets completly white and it's events doesn't work anymore. Many thanks in advance for your help and sorry for my english.
OK i found a solution ... and it's so simple. **Switch into the designer mode and you can move it anywhere you want to.** I know this sounds strange but it works for me and solved my problem.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, winforms, ms word, vsto" }
Limit a number to a range (Haskell) I am exposing a function which takes two parameters, one is a minimum bound and the other is a maximum bound. How can I ensure, using types, that for example the minimum bound is not greater than the maximum bound? I want to avoid creating a smart constructor and returning a Maybe because it would make the whole usage more cumbersome. Thank you
This doesn't exactly answer your question, but one approach that sometimes works is to change your _interpretation_ of your type. For example, instead of data Range = {lo :: Integer, hi :: Integer} you could use data Range = {lo :: Integer, size :: Natural} This way, there's no way to represent an invalid range.
stackexchange-stackoverflow
{ "answer_score": 16, "question_score": 10, "tags": "haskell, types, functional programming, type theory, hindley milner" }
Expectation of Stopping Time w.r.t a Brownian Motion How do you take the expectation of a stopping time with respect to a Brownian motion? The specific question is: $$ \tau = \inf\\{ t \ge 0: B(t) \in \\{-a, b\\}\\} $$ I understand the optional stopping theorem tells us that $E[M_\tau ] = E[M_0]$ but how do I use that to find the expectation?
We want to use the optional stopping theorem on the two martingales $(B_t)_{t\geq 0}$ and $(B_t^2-t)_{t\geq 0}$. Note that $\tau<\infty$ a.s. so $B_\tau \in \\{-a,b\\}$ a.s. and hence by the optional stopping theorem, we have $$ \begin{align*} 0&=E[B_0]=E[B_\tau]=-aP(B_\tau=-a)+bP(B_\tau=b)\\\ &=-a(1-P(B_\tau=b))+bP(B_\tau=b) \end{align*} $$ which implies that $$ P(B_\tau=b)=\frac{a}{a+b},\quad P(B_\tau=-a)=\frac{b}{a+b}. $$ Using the optional stopping theorem on $(B_t^2-t)_{t\geq 0}$ we get that $$ 0=E[B_0^2-0]=E[B_\tau^2-\tau] $$ and hence $$ E[\tau]=E[B_\tau^2]=a^2P(B_\tau=-a)+b^2P(B_\tau=b)=ab. $$
stackexchange-math
{ "answer_score": 19, "question_score": 13, "tags": "probability theory, stochastic processes, brownian motion" }
How do I split string into an array using blank lines as delimiter in ruby? How do I split string such as: aaaaa bbbb aaaaa ccccccc aaa rrrrt into an array using blank lines as delimiter?
Well, with `String#split` 'aaaaa bbbb'.split => ["aaaaa", "bbbb"] > `split(pattern=nil, [limit]) → an_array` > > Divides str into substrings based on a delimiter, returning an array of these substrings. > > [...] > > If `pattern` is `nil`, the value of `$`; is used. If `$`; is `nil` (which is the default), `str` is split on whitespace as if `' '` were specified. UPDATE: To split on empty line, you can use `/\n{2,}/` pattern. It also handles paragraphs separated with more than one empty line: a = <<END aaaaa bbbb aaaaa ccccccc aaa rrrrt END a.split(/\n{2,}/) => ["aaaaa\nbbbb", "aaaaa\nccccccc", "aaa\nrrrrt\n"]
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 4, "tags": "arrays, ruby, string" }
Fetching data from facebook game application to iPhone application I have an application where I need to connect to a game app within facebook and fetch data from that app. Say, a user has been playing certain game app in facebook and I need to fetch the points he has scored in that game from my iPhone application. Is it possible ? If so then how to implement it ? Can anyone pls help me out of this ? Thanks in Advance.
I don't think that is possible. My arguments: 1. Retrieving game-dependent information for a given user and game seems impossible to me, since that kind of information is usually stored and handled by servers that run that game, not Facebook. 2. Facebook API does not provide such a mechanism. You cannot query such information using FQL on any of its tables. See < Good luck.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "iphone, facebook" }
Finding an Integral of $\int_{-a}^{a}\frac{x*dy}{( x^2 + y^2 )^{\frac{3}{2}}}$ How can I find the integral of this expression: $$\int_{-a}^{a}\frac{x*dy}{( x^2 + y^2 )^{\frac{3}{2}}}$$ Please would yo people give me a step by step solution. I am stuck in this
As suggested, we have $$\begin{align} \int_{y=-a}^{a} \frac{x\,dy}{(x^{2}+y^{2})^{\frac{3}{2}}} &\,=\, \frac{1}{x^{2}}\int_{y=-a}^{a} \frac{dy}{(1+\left(\frac{y}{x}\right)^{2})^{\frac{3}{2}}} \,=\, \frac{1}{x}\int_{u=-\frac{a}{x}}^{\frac{a}{x}} \frac{du}{(1+u^{2})^{\frac{3}{2}}} \\\\[0.3cm] &\,=\, \left.\frac{1}{x}\cdot \frac{u}{\sqrt{u^{2}+1}}\right|_{u=-\frac{a}{x}}^{\frac{a}{x}} \end{align}$$ using the substitution $y=ux$. You should be able to take it from there.
stackexchange-math
{ "answer_score": 0, "question_score": -4, "tags": "integration, definite integrals" }
Asp.net MVC Controller Index method doesn't fire on Redirect from another controller public ActionResult Index() { var tickets = DependencyContainer.DomainController.ShowTickets(); if(tickets==null) { ViewData.Add("Error","Associate not found"); return RedirectToAction("Index", "Home");//Doesn't fire the index? } return View(); Home controller method is as follows and only fires on the debugger startup, and after the redirect IF I hit F5. public ActionResult Index() { ViewData["Message"] = "Welcome to Home Loans and Insuring Technology Ticketing"; //if (TempData.ContainsKey(ErrorKey)) //{ // ViewData[ErrorKey] = TempData[ErrorKey]; // TempData.Remove(ErrorKey); //} return View(); } Redirect doesn't fire the controller?
1. You must use `TempData` when redirecting. `ViewData` _will not work_ when set before a redirect. 2. Do you cache the site index? Does the browser cache it? Look at the request and response with Firebug or Fiddler.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "asp.net mvc" }
Manipulating Javascript array of objects I have an array of objects and need to create a new array which contains the values of a specific key within the objects. Is there a more elegant way than the following code (note: without using anything more than JQuery). Expected result is: 455, 387, 495 var arr=[{sid:387,rank:2},{sid:455,rank:1},{sid:364,rank:4},{sid:495,rank:3}]; var topThreeTemp = arr.filter(function(a){return a.rank<4;}).sort(function(a,b){return a.rank>b.rank;}); var topThreeSIDs=[]; for(var i=0;i<topThreeTemp.length;i++){ topThreeSIDs.push(topThreeTemp[i].sid); } console.log(topThreeSIDs.join(", "));
Use ES6 `map`, instead of `for` and ES6 arrow functions (syntax sugars): const arr = [ { sid: 387,rank: 2 }, { sid: 455,rank: 1 }, { sid: 364,rank: 4 }, { sid: 495,rank: 3 } ] const topThreeSIDs = arr .filter(({ rank }) => rank < 4) .sort((a, b) => a.rank > b.rank) .map(({ sid }) => sid) console.log(topThreeSIDs.join(', '))
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "javascript, arrays, object" }
Default value for file path in function gives SyntaxError. Work around? for this, import os.path def f(data_file_path=os.path.join(os.getcwd(),'temp'),type): ... return data I get this, SyntaxError: non-default argument follows default argument Is there a way to make this work or do I have to define a variable such as, rawdata_path = os.path.join(os.getcwd(),'temp') and then plug that into the function?
Move `type` before `data_file_path` def f(type,data_file_path=os.path.join(os.getcwd(),'temp')): Assigning values in the function parameter called default arguments, those should come afther non-default arguments
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "python, function, default value" }
Angular CLI add a script outside of node_modules I have a problem with adding a script to Angular 2 with ng cli outside of the node_modules folder. The script doesn't exist ( or at least I didn't find it ) in the npm registries and it's just a single file I wish to load but cannot: This is in angular-cli.json : "scripts": [ "assets/one-signal-sdk.js" ], This throws a syntax error, saying: "Unexpected token ? in JSON at position 0" But, if I manually add the package to node_modules and load it like this: "scripts": [ "../node_modules/one-signal/one-signal-sdk.js" ], It's working perfectly fine. Of course, I cannot just add it manually and leave it there because no one will be able to download it via npm install. Is there a way to add a custom script to the build? Thanks.
This should work fine "scripts": [ "assets/one-signal-sdk.js" ], Try to put in this file something simple like `document.write("test");`. If that works, the problem is specific to the content of `one-signal-sdk.js`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript, angular" }
SDL is pure opengl or not? if it is what are the differences? I my collage i have to do a assignment in opengl and they intimidate us to do that in pure opengl. What it is just simply create and shown a transparent cube and put table inside it all of the model must create by the program they can't import by other modeling software like blender, 3dmax etc. And also they expect very high level lighting atmosphere in that cube. I am new to side and i heard that SDL is a game engine. I wonder if i use SDL in my assignment may i end up with zero mark if it is not contain opengl? If there is good way to do this simple task please let me know!
Well, SDL is not a game engine and it is not pure OpenGL. However, you can build pure OpenGL applications using the windowing API that SDL gives you. SDL is just one of many options for window management and GL context creation. SDL can set up a window for you, can set up the OpenGL context, and handle user input. From there, you can write pure OpenGL and render your cube or whatever. If you have not used OpenGL or SDL before, then you probably have a lot of work ahead of you. As another difference, SDL does have an additional 2D rendering API. If your assignment is to do 3D with OpenGL, then obviously DO NOT use this 2D API.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "sdl" }
Quickest way to return list of Strings by using wildcard from collection in Java I have set of 100000 String. And for example I want to get all strings starting with "JO" from that set. What would be the best solution for that? I was thinking Aho-Corasick but the implementation I have does not support wild cards.
If you want all the strings starting with a sequence you can add all the String into a NavigableSet like TreeSet and get the `subSet(text, text+'\uFFFF')` will give you all the entries starting with `text` This lookup is O(log n) * * * If you want all the Strings with end with a sequence, you can do a similar thing, except you have to reverse the String. In this case a TreeMap from reversed String to forward String would be a better structure. If you want "x*z" you can do a search with the first set and take a union with the values of the Map. if you want contains " _x_ ", you can use a Navigable<String, Set<String>> where the key is each String starting from the first, second, third char etc The value is a Set as you can get duplicates. You can do a search like the starts with structure.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 0, "tags": "java, search, collections" }
Cannot import Django modules in IPython Notebook I'm starting my IPython Notebook from my vagrant server as follows: ipython notebook --ip='*' When I try to import a Django module, I get the `ImproperlyConfigured` exception: > ImproperlyConfigured: Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings. From the normal Shell, I just run `export DJANGO_SETTINGS_MODULE=web.settings` and then I can load Django modules from any Python interpreter, however, this hasn't worked with a notebook. I tried running the following in the notebook, to no avail: !export DJANGO_SETTINGS_MODULE=web.settings !DJANGO_SETTINGS_MODULE=web.settings So, how do I set environment variables in IPython Notebook so I can import Django modules?
You should be able to use `os.environ`: import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web.settings") I guess the "!export" way does not work because it spawns a subprocess to execute those commands, and a child process does not affect the environment of its parent
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "django, import, module, ipython" }
How to differentiate and integrate something with a square root? How do I solve these, I am not sure how. 1. integrate$$\int_0^2 2\sqrt{1+x^2} \,dx$$ 2. differentiate $$2\sqrt{1+2t^2}$$
The first is a fairly standard "trigonometric substitution" integral. I presume you know that $sin^2(\theta)+ cos^2(\theta)= 1$. Divide both sides by $cos^2(\theta)$ to get $tan^2(\theta)+ 1= sec^2(\theta)$. That implies that, for something involving a square root of $1+ x^2$ we should try the substitution $x= tan(\theta)$. Then $dx= sec^2(\theta)d\theta$. When x= 1, $\theta= arctan(1)= \pi/4$ and when x= 2, $\theta= arctan(2)$. The integral becomes $2\int_{\pi/4}^{arctan(2)} sec^3(\theta)d\theta$. The second does not ask you to integrate- it asks you to differentiate $2\sqrt{1+ 2t^2}= 2(1+ 2t^2)^{1/2}$. Let $u= 1+ 2t^2$ so that the function is $2u^{1/2}$ and use the "chain rule": $\frac{2u^{1/2}}{dt}= \frac{2u^{1/2}}{du}\frac{du}{dt}$. Can you differentiate $2u^{1/2}$ with respect to u and $u= 1+ 2t^2$ with respect to t?
stackexchange-math
{ "answer_score": 0, "question_score": -2, "tags": "integration, ordinary differential equations" }
If $a^HUa=0$ for all $a$, can we conclude that $U=0$? I have the following equation: $a^HUa=0$ where '$a$' can be any arbitrary vector and $U$ is a matrix ($H$ means Hermitian). Can we conclude that $U=0$? Any reference? Thanks.
We can conclude that $U$ needs to be a square matrix for the involved expression to make sense. Let $U$ be an $n\times n$ matrix. $$ \text{ the $i$th component of vector $Ua$: } (Ua)_i = \sum_{k=1}^n U_{ik}a_{k}. $$ and similarly $$ \begin{align*} a^HUa &= \sum_{j = 1}^n a^H_{j} (Ua)_j \\\ &= \sum_{j} \sum_{k} a_j^*U_{jk}a_k \end{align*} $$ Let $a_j = \delta_{r,j}$, which is $1$ only index $r$ and zero elsewhere. Then, $$ a^HUa = 0 = U_{rr} $$ So you can conclude that the diagonal of $U$ is zero. Letting $a_j = (1, 0, \dots, 1, \dots, 0)$ (a $1$ in the $s$ and $t$th places). Then you have $U_{st} + U_{ts} = 0$. So the matrix is anti-symmetric. Lets try the same thing with $i$ and $1$. Then we have $$ (-i)U_{st} + iU_{ts} = 0 $$ Thus the off-diagonal elements are anti-symmetric and equal, hence _zero_. QED
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "matrices" }
What happens when you remove a token creature from the game, and then return it under it's owner's control? 1. Player A plays Roar of the Wurm 2. Player B plays Astral Slide 3. Player B recycles a card and returns the Wurm token What happens then?
Tokens disappear whenever they leave the battlefield. The relevant rules are: > **110.5f** A token that's phased out, or that's in a zone other than the battlefield, ceases to exist. This is a state-based action; see rule 704. (Note that if a token changes zones, applicable triggered abilities will trigger before the token ceases to exist.) > > **110.5g** A token that has left the battlefield can't move to another zone or come back onto the battlefield. If such a token would change zones, it remains in its current zone instead. It ceases to exist the next time state-based actions are checked; see rule 704. So the Wurm token would be gone for good in this example.
stackexchange-boardgames
{ "answer_score": 19, "question_score": 8, "tags": "magic the gathering" }
Explain "community wiki" to new users of Stack Overflow > **Possible Duplicate:** > What are "Community Wiki" posts? As a new user at Stack Overflow I haven't figured out what the purpose of the community wiki checkbox is as I cannot see any way to access a wiki and there is no explanation of it in the FAQs section. I think it would be helpful to make this clearer to new users.
Did you read the Meta FAQ question about it? Or just the page linked "faq" at the top of every site? The Meta page is more useful. (I had a hard time finding it my first time looking, too.)
stackexchange-meta
{ "answer_score": 2, "question_score": 3, "tags": "feature request, community wiki, new users" }
Split then stack large dt with numerous columns PD0_Code PD0_Flock PD0_Tag PD0_Value PD1_Code PD1_Flock PD1_Tag PD1_Value PD2_Code PD2_Flock PD2_Tag PD2_Value Hi I have a data table that contains 384 columns. I need it transformed from wide into long format. I cannot use melt or split/stack as the column headers are different. Above is the format of column headers I am dealing with. What I need is the large dt split into 4 columns (Code, Flock, Tag, Value) and then stacked on top of each other. I have tried the following and it splits it correctly - now I just need to be able to stack it all together split(dt2, (seq_along(4))) x <- cbind(obj.list) I would really appreciate some help with this. Thanks
We can use `melt` from `data.table` which can take multiple `patterns` in the `measure`. library(data.table) melt(setDT(df1), measure = patterns("Code$", "Flock$", "Tag$", "Value$"), value.name = c("Code", "Flock", "Tag", "Value")) ### data df1 <- structure(list(PD0_Code = c(1L, 3L, 5L), PD0_Flock = c(4L, 9L, 7L), PD0_Tag = c(3L, 4L, 3L), PD0_Value = c(4L, 6L, 4L), PD1_Code = c(2L, 4L, 6L), PD1_Flock = c(1L, 8L, 9L), PD1_Tag = c(4L, 4L, 3L), PD1_Value = c(1L, 5L, 4L), PD2_Code = c(1L, 6L, 5L), PD2_Flock = c(3L, 9L, 4L), PD2_Tag = c(3L, 4L, 2L), PD2_Value = c(1L, 3L, 7L )), .Names = c("PD0_Code", "PD0_Flock", "PD0_Tag", "PD0_Value", "PD1_Code", "PD1_Flock", "PD1_Tag", "PD1_Value", "PD2_Code", "PD2_Flock", "PD2_Tag", "PD2_Value"), class = "data.frame", row.names = c(NA, -3L))
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "r, data.table" }
NuGet: Run C# Code on Install/Update/Uninstall I'm just getting to grips with nuget after avoiding it for a while. I was wondering if it was possible to run some C# code when you install, update or uninstall a nuget package? For example I'd like to run a set of database changes which are within a .sql file within my package once the package is installed. I'd appreciate if someone could let me know if this is possible and if so point me in the right direction. Thanks
Yes, you can use powershell so you can write some c# code and run please check link Well instead of copy paste not my own job here is link to real example
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "c#, nuget" }
Apache Flink 1.4 with Apache Kafka 1.0.0 I am trying to get Apache Flink Scala project to integrate with Apache Kafka 1.0.0. When i attempt to add the flink-connector-kafka package in my build.sbt file I get an error saying it cannot resolve it. When i then look at the options available in the maven repository, there is no maven dependency available for Apache Kafka 2.11-1.0.0 for any version above 0.10.2 val flinkVersion = "1.4.1" val flinkDependencies = Seq( "org.apache.flink" %% "flink-scala" % flinkVersion % "provided", "org.apache.flink" %% "flink-streaming-scala" % flinkVersion % "provided") "org.apache.flink" %% "flink-connector-kafka" % flinkVersion) Does anyone know how to integrate these versions correctly so that I can connect Apache Flink 1.4 to Apache Kafka 2.11-1.0.0, as nothing I seem to try works (and i do not wish to downgrade the Kafka version I am connecting to).
This should work. Try: val flinkVersion = "1.4.2" libraryDependencies ++= Seq( "org.apache.flink" %% "flink-streaming-scala" % flinkVersion, "org.apache.flink" %% "flink-connector-kafka-0.11" % flinkVersion )
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "apache kafka, sbt, apache flink, flink streaming" }
How to wire a solid state relay according to code I want to build an outlet that I can control on a timer or through a device like a smartphone. I am planning on using a solid state relay for this job. I'm aware of the electrical code stipulation that all low voltage and high voltage wires must be separated by a permanent barrier, as explained in this question. I was going to use a double gang box from home depot like this one to accomplish this. My question is, with the separator there, how do I connect the relay to the low voltage control?
You can mix Class 2 conductors with power conductors in boxes if the power circuit conductors are introduced solely to connect to the equipment connected to the Class 2 circuit. Class 2 circuits voltage and current limits are well-defined by National Electrical Code (NEC.) Also, NEC defines spacing between the class 2 conductors and power inductors. See NEC article 725 for more.
stackexchange-diy
{ "answer_score": 3, "question_score": 1, "tags": "electrical, code compliance" }
Multithreading and process signalling I have a worker process that is executed via a Windows service (vb.net). It executes every 5 minutes and checks a "jobs" table in a database. I also have a web application (asp.net vb) that allows users to "pause" currently running jobs in the case of an error. What is the best way for the web application to signal the Windows service to stop processing? They are running on the same machine, however if you have a suggestion for if they were running on different machines that would be great. I would like to avoid database or filesystem calls to check a "status" during every iteration. I have a database which stores custom info for each worker process - I could store a thread ID or process ID if it is retrievable via .Net to enable the Web application to message the service application?
You probably want to make your service a WCF server. Then you can communicate with it from your web app or wherever is convenient. You can also provide a progress / feedback API as well as a command / control API - it's up to you.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": ".net, multithreading, ipc" }
Special bacteria in infants This question is similar to a previous question, but is not the same. I was told, you are born with a bacteria in your digestive track that are made by the body. Can a body in development create it's own bacteria from nothing? Also said by the teacher the first time you take an antibiotic it is gone forever? Can a body in development create it own bacteria from stem cells? Is there such a bacteria, can it be cultured and re-introduced into the body?
No, no human (or any other eukaryote lineage) are able to "create bacteria". The story you were told is wrong. However and interestingly, female parasitoid wasps seem to "create viruses" (Herniou et al. 2013). The viruses are part of the wasp genome (lysogenic phase) and detach (lytic phase) in the ovaries only. The viruses, then infect the caterpillar in which the mother lay its eggs. The viruses ensure to reduce the immune system of the caterpillar in order to protect the wasp egg (and later larvae) and ensure its development to adulthood.
stackexchange-biology
{ "answer_score": 3, "question_score": 1, "tags": "bacteriology, development, digestive system, stem cells, symbiosis" }
OpenCV4Android - Displaying text on created rectangles I would like to know if there is any simple way to display text on created rectangles. I have my rectangles stored in array: Rect[] facesArray = faces.toArray(); for (int i = 0; i < facesArray.length; i++) { Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3); } That means I have also x,y of each rectangle. I don't know methods which might allow me to display numbers on them. I want to display place of each rectangle in array on each rectangle, so I can create interface in the future that will let user to choose one of them. If you could help me or provide some useful source of knowledge which I can study in that matter/example I would be glad.
Rect[] facesArray = faces.toArray(); for (int i = 0; i < facesArray.length; i++) { Core.rectangle(mRgba, facesArray[i].tl(), facesArray[i].br(), FACE_RECT_COLOR, 3); Core.putText(mRgba, "Face"+i, new Point(facesArray[i].x, facesArray[i].y), 3, 1, new Scalar(255, 0, 0, 255), 1); } Worked for me
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "android, c++, opencv, rectangles" }
Find a list of panache entities from their corresponding ids I have a list of ids of a PanacheEntity. I want to find the list of PanacheEntities corresponding to these Id. Is there a built in or suggested API which can do this. public class Person extends PanacheEntity { public String name; } After a previous search, I have with me a list of ids of the Person entity. I would now like to get a list of the Person objects in a single DB query. I tried `Person.list("id", listOfIds)`, but this fails when there is more than one object in the list. Is there a better way than this
You should be able to do: Person.list("id in ?1", listOfIds)
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 3, "tags": "quarkus" }
primorials and percentage of coprime numbers to it. Recall that the primorial $P_n$ is the product of the first $n$ primes. We say that a number $m$ is good if and only if for every $N$ the fraction of numbers in the range $\\{1,2,3,\dots, N\\}$ that are relatively prime to $m$ is greater than or equal to $\varphi(m)/m$. Determine all good primorials. * * * Clearly it suffices to check for $N\in \\{1,2,3,\dots, m\\}$
Let $P_n$ be the $n$-th primorial and $p_n$ the $n$-th prime. Then $$\frac{\varphi(P_n)}{P_n}=\prod_{i=1}^n(1-p_i^{-1}),$$ and the only integer in the set $\\{1,\ldots,p_{n+1}-1\\}$ coprime to $P_n$ is $1$, so the fraction of integers coprime to $P_n$ in this range is $\frac{1}{p_{n+1}-1}$. I'll leave it to you to verify that $$\prod_{i=1}^n(1-p_i^{-1})>\frac{1}{p_{n+1}-1},$$ for every $n>1$, so the only good primorial is $P_1=2$.
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "number theory, elementary number theory, prime numbers, sieve theory" }
On IBM i (AS/400, iSeries) what is DW4 and DW5 data storage? What is DW4 and DW5 data storage? On the following web page about IBMs Query/400 product under General operating characteristics, it mentions "Accessibility from DW4 and DW5 for data merge." IBMs Query for i5/OS V6.1
DW4 and DW5 refer to IBM's DisplayWrite word processor, versions 4 and 5. It's extremely unlikely that you'll ever run into any DW uses. (But if you're still using something as old as Query/400, I suppose it's possible.)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ibm midrange, db2 400" }
How to spawn child process and communicate with it Deno? Suppose I have 2 script, father.ts and child.ts, how do I spawn child.ts from father.ts and periodically send message from father.ts to child.ts ?
You have to use the Worker API **father.ts** const worker = new Worker("./child.ts", { type: "module", deno: true }); worker.postMessage({ filename: "./log.txt" }); **child.ts** self.onmessage = async (e) => { const { filename } = e.data; const text = await Deno.readTextFile(filename); console.log(text); self.close(); }; You can send messages using `.postMessage`
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "deno" }
F_GETPIPE_SZ undeclared I'm trying to get size of pipe: printf("pipe 0 size: %d bytes\npipe 1 size: %d bytes\n", fcntl(fd[0], F_GETPIPE_SZ), fcntl(fd[1], F_GETPIPE_SZ)); Used headers (half of them used by another parts of code): #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/wait.h> When I'm trying to compile, **gcc** fails with this error: > ‘F_GETPIPE_SZ’ undeclared (first use in this function) > > kernel version - 5.4.0-88-generic > > libc6-dev version - 2.31-0ubuntu9.2 > > gcc version - 4:9.3.0-1ubuntu2
Since this macro is not part of POSIX, you must define the `_GNU_SOURCE` feature test macro before including `<fcntl.h>`. This is stated in the `fcntl(2)` man page, in the "Conforming To" section. See What does "#define _GNU_SOURCE" imply?
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c, linux" }
Ext.form.field.File disable button I have the following filefield: { xtype: 'filefield', name: 'photo', fieldLabel: 'Photo', labelWidth: 50, allowBlank: false, buttonText: 'Select Photo...' } I try to disable the button of the filefield with: if (f instanceof Ext.form.field.File) { //f is a field in my form f.button.setDisabled(true) } This works like I expect visually but after I enable this button the handler of the button does not get called anymore. I can hear you think _Why don't you call`setDisabled()` on the field?_ .. because the form won't submit its value if the field is disabled. And I implemented my own way of disabling items with CSS. My question is: **How can I disable the button of a _**`filefield` **_in ExtJS 4.1.2?**
It appears to be a bug in ExtJs 4.1. This is resolved in version ExtJS 4.1.3
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 3, "tags": "extjs, extjs4" }
A criterion for freeness over a local ring Let $A=K[[X_1,\dots,X_n]]$ where $K$ is a field. Let $M$ be a finitely generated torsion-free $A$-module, such that 1. for all $k$, the $A[1/X_k]$-module $M[1/X_k]$ is free of rank $d$; 2. for every $i \neq j$, we have $M = M[1/X_i] \cap M[1/X_j]$. Does this imply that $M$ is free? It certainly does if $n=1$ (easy), and also if $n=2$ (reduce $M$ modulo $X$), but things seem trickier if $n \geq 3$. This question comes up when trying to prove that some $(\varphi,\Gamma)$-modules over rings in several variables are free.
No, this is false as soon as $n ≥ 3$. A second syzygy $M$ of the residue field $K$ gives a counterexample: each $M[1/X_i]$ is projective, hence free, and it is reflexive, so the second condition is satisfied. On the other hand the projective dimension of $K$ as a module is $n$, so $M$ can not be free.
stackexchange-mathoverflow_net_7z
{ "answer_score": 8, "question_score": 8, "tags": "ag.algebraic geometry, ac.commutative algebra, nt.number theory, modules" }
C++ explicit constructor that takes a pointer I've recently stumbled across an explicit constructor that receives a single pointer argument. I wonder if the explicit keyword is necessary in this case? as there is no constructor for a pointer so there cannot be any implicit conversion. class Foo { public: explicit Foo(int* int_ptr); }
The following code: void f(Foo) {} int main() { int* p; f(p); } * Fails to compile with `explicit`. * Happily compiles without it. **live example on godbolt.org**
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 1, "tags": "c++, instantiation, explicit conversion" }
An SQL problem, there are multiple products in an order An SQL problem, there are multiple products in an order. You want to query all order information including product a, product B, and product C. Thank you very much for your help database:oracle Order Details orderNo goods 1001 A 1001 B 1001 C 1001 D 1002 A 1003 A1 1003 B1 1003 C 1003 D 1004 A ………… How can I find 1001? Thank you very much for your help!
You need `GROUP BY` with `HAVING` as follows: SELECT ORDERNO FROM YOUR_TABLE WHERE GOODS IN ( 'A', 'B', 'C') GROUP BY ORDERNO HAVING COUNT(DISTINCT GOODS) = 3 Cheers!!
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "sql, oracle, group by" }
jquery call a function outsite i have a problem when i call a function from another file js. i have a.html with the content. <html> <head> <script src="${resource(dir: 'js/demo', file: '.js')}"></script> <script type="text/javascript"> updateConfigurationMap ({ urlaa:'${createLink(controller: 'cc', action: 'bb')}', }); </script> </head> <body> <select from="" onchange="checkRequiredInformation(this.value)" /> </body> </html> and i have a folder js/demo and demo.js inside this folder function checkRequiredInformation (tt){ if(tt!= "") { $('#dd').load(configurationMap.urlaa); } else { $('#dd').html(""); } }; i have an error : Failed to load resource .... the url not correct .... but if i take this script into the same file ... everything is ok ? please help me seperated this function to another file . thanks
Try this. <script src="/js/demo/demo.js" type="javascript" language="javascript"/>
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "jquery" }
Why doesn't this time conversion from UTC to local code work? let dateFormatter = DateFormatter() let dateFormatter2 = DateFormatter() dateFormatter.timeZone = TimeZone(abbreviation: "UTC") dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" let date = dateFormatter.date(from: event!) dateFormatter2.timeZone = TimeZone.current let dateString = dateFormatter2.string(from: date!) let finalDate = dateFormatter2.date(from: dateString) return finalDate! I have sports events that give me string dates in UTC which I am trying to convert into local time. This code is similar to the dozens of examples given in this site when asked this question, yet it doesn't work.
This is the iso8601 formatter : static let iso8601: DateFormatter = { let formatter = DateFormatter() formatter.calendar = Calendar(identifier: .iso8601) formatter.locale = Locale(identifier: "en_US_POSIX") formatter.timeZone = TimeZone(secondsFromGMT: 0) formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" return formatter }() This turns your string into a `Date`. You will need to add the time difference, most likely through `TimeZone.autoupdatingCurrent`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "ios, swift, nsdate, nsdateformatter" }
Stylesheets not working on Heroku I've been trying to get my CSS to work correctly in my Rails app. I just added `config.serve_static_assets = true` to my `config/application.rb` to try to get the assets to precompile. Before some of the CSS was working but not enough, and now all of the styling has been removed and its just displaying the HTML. I ran `rake assets:precompile` but that didn't work either. What can I do to get my styling to work in production?
Remove your assets pre-compiled files and try to push to heroku again. Heroku will compile it. Hope it helps.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "html, css, ruby on rails, heroku, asset pipeline" }
How to Turn Statsmodels Warning into Exception Python and Panda newbie here. I'm trying to use statsmodels to fit a logistic regression to calculate the probability that a voter casts a ballot. I'm working at the precinct level; so sometimes the function doesn't converge, and I get the following error: Warning: Maximum number of iterations has been exceeded. I have already increased the maximum number of iterations to 1000. I then tried to turn that "Warning" into an exception. I have imported warnings and included warnings.simplefilter('error', Warning) to try to capture it, but it doesn't seem to be a true Python warning. Rather, it's something that statsmodels prints out when it hits the maximum number of iterations. So now I'm wondering if there's a way to say: if sm.Logit(y, covs).fit(maxiter=1000) doesn't converge: do something else
**Edit** : You can also check the converged flag in the returned results class and raise this exception yourself it the model did not converge. For example, dta = sm.datasets.spector.load_pandas() y = dta.endog X = dta.exog X['const'] = 1 mod = sm.Logit(y, X).fit() if not mod.mle_retvals['converged']: do something else Indeed, these warnings are printed. That's bad form. I filed an issue. PRs welcome on this. < Alternatively, try using another solver via the method keyword. Hopefully they'll raise a proper warning or an exception on the way. If you can share the data that leads to this on that issue, then that would be helpful. There might be something else going on.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "python, warnings, statsmodels, convergence" }
Is it possible to use bash to search for a certain phrase on a website? I was just curious if this was possible. I have tried googling it, but nothing seems to show up. I'd also rather not download the site beforehand and just through the html file that way.
Try `curl <url> | grep <pattern>` as another user detailed. But be cognizant that that will show all matching results, which may not be ideal. If you want to match the first (or a select set of results), use `curl<url> | grep -m <count> <pattern>`. For example: `curl | grep -m 1 "possible"` will only return the first match.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "bash, web" }
Как использовать getString в отдельных классах? Надо в отдельном классе получить текст из _values/strings_. Класс находится не в _Activity_ , а в отдельном файле. class Subject { val s = getString(R.string.defaultName) } _getString_ считается ошибкой.
Передайте контекст в конструктор вашего класса `Subject`: import android.content.Context class Subject(context: Context) { val s = context.getString(R.string.defaultName) }
stackexchange-ru_stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "android, kotlin, android resources" }
How to disable/enable all products in commerce? The Commerce Backoffice module allows to delete all selected products from the list. But how about to change the status for all products or for the selected ones?
It will take just a few steps to create a view for your commerce product fields values manipulation: * add a new View: * "show group" set to Commerce Product "of type" - type of you commerce product, you want to change fields values; * "display format" set to "Table"; * press "Continue & Edit"; * In "fields" group add "Bulk operations:Commerce Product" field: * set checked "Modify entity values " in "Bulk operations" group; * press "Apply" button; That are the main settings for your operation view. Just add fields and filters whatever you want. Save your view and use it for change field values using bulk operations.
stackexchange-drupal
{ "answer_score": 3, "question_score": 2, "tags": "commerce" }
Тренировочные задачи по JavaScript Где взять интересные, а главное не тривиальные задачки по JavaScript?
Вот посмотри Quizful - тесты онлайн Тут тесты. Для тренировки вообще норм. Проверить себя да и попрактиковаться.
stackexchange-ru_stackoverflow
{ "answer_score": 6, "question_score": 5, "tags": "javascript" }
Parceljs import javascript file as string I have a very particular use case. I want to import a javascript file as a string and inject it into html responses at will in a service worker. I can't see how to do this using parceljs beyond hosting the javascript file somewhere and doing fetch at runtime to load the js file into memory. However, I want to do this at build time. How best to do this? Note: Ideally the dependencies of javascript file I am importing should be bundled into the string.
Seems to be possible in parcel 2 with import js from "bundle-text:./b.ts"; console.log(js); <
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "javascript, bundle, service worker, parceljs" }
How can I use Mongrel for my non-rails ruby webapp? I've got a non-RoR but ruby webapp in the works. So far, I've just been using requests, hacks, and mod_ruby; but I'd really like to try out Mongrel--which seems to work really well for RoR sites. I looked at the examples given in GitHub, and none of them does dynamic changing of content w/o having to restart Mongrel like you can do in RoR under dev mode. How can I do this? (Just using `load` doesn't work.)
I use Sinatra with a Mongrel backend; hello world really is as easy as it says on the front page. I actually started with Sinatra, and then changed the server from webrick to mongrel after experimenting around with which gave better performance. See this question for how that testing worked out.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ruby, mongrel" }
How to re-mount a different partition as /home? When I installed Ubuntu 10.04, I installed it on a single 16GB partition which includes /, /boot, /home etc. I have another partition on the system (ext3). It is easily accessible from the GNOME desktop Places menu: I just click that Filesystem HDD icon on the Places menu and it is automatically mount as '/media/1326f40a-45df-4ec'. How do I make that partition re-mount as /home instead? (permanently, that is)
Here is the official Ubuntu documentation for moving to a separate /home partition: < Just skip the step for creating a new partition as you already have it.
stackexchange-askubuntu
{ "answer_score": 13, "question_score": 17, "tags": "mount, home directory" }
air: maximising window on startup In my air app I am maximizing the app window on creation complete event. Because of this I initially get a smaller window for a few milliseconds which is maximized after all UI elements are rendered. Is there any way I can specify that the initial size of the window should be maximal? Hard coding the size will not works as the screen sizes may change. My current code is: <s:WindowedApplication .... creationComplete="maximize();"> . . . </mx:WindowedApplication>
Make the initial window not visible (in the app.xml file). Then in an applicationComplete event handler maximize the window and make it visible.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "apache flex, air" }
Make computer give the choice to boot from my partitions I have a new computer that came with windows 8.1. I installed ubuntu 15.04 on another partition, so that I had the choice to boot from either windows or ubuntu when the computer starts up. But there was a hardware failure in my computer, which means I had to send it in where I bought it. They fixed the hardware failure. But now when I start my computer, it only boots in windows, not giving me the chance to boot from ubunty. At first, I thought they deleted ubuntu, but when I wanted to install ubuntu again from usb, I can see that my ubuntu 15.04 is still there with all its data. How do I make it so that I can choose to boot from windows and ubuntu again? I am fairly new to linux Thanks
All you need is to restore the GRUB bootloader. This is official wiki page on the problem.
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 0, "tags": "14.04, partitioning" }
PHP Ajax Form, What If The JS Was Disabled I have a simple PHP form like <form action="" id="searchForm"> <input type="text" id="name" name="theName" placeholder="Your Name" /> <button id="send">Send data</button> </form> and I am using ajax to send the POST values to the PHP file $("#send").on("click", function(){ var name= $('#theName').val(); var data='name='+name; var request = $.ajax({ type: "POST", url: "assets/map.php", data: data, cache: false }); }); This works correctly when using JavaScript but I am thinking what if the JS was disabled in a browser? How we can still send the data to the server? should I add the `map.php` file into the form `action` attribute? if so how to prevent sending double `POST[]` values?
You should use onsubmit and prevent the default action (the ordinary submit action) for the JS part, then indeed fill in the action attribute with the same url that you use for the ajax post. $("#searchForm").submit(function(e){ e.preventDefault(); var name= $('#theName').val(); var data='name='+name; var request = $.ajax({ type: "POST", url: "assets/map.php", data: data, cache: false }); }); And the HTML: <form action="assets/map.php" id="searchForm" method="post"> <input type="text" id="name" name="theName" placeholder="Your Name" /> <button id="send" type="submit">Send data</button> </form>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "javascript, php, ajax" }
Find the Fourier Transform of $e^{i x t}$. Find the Fourier Transform of $e^{ixt}$, where $x$ is a real parameter, $t\in \mathbb R$. I started writing: $$\int_{-\infty}^\infty e^{ixt} e^{-i\omega t}dt$$ but I do not know how to go on!
$$\int_{-\infty}^{+\infty} e^{ixt} e^{-i \omega t} dt=\int_{-\infty}^{+\infty} e^{ixt-i \omega t} dt=\int_{-\infty}^{+\infty} e^{i(x- \omega )t} dt=2 \pi \delta(x- \omega)$$ **EDIT:** It is known that: $$\delta(x-a)= \frac{1}{2 \pi}\int_{-\infty}^{\infty} e^{ip(x-a)} dp$$
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "fourier analysis" }
Почему @font-face не вытеснило предыдущие методы объявления семейства шрифта? Несмотря на появление в CSS3 правила `@font-face`, которое, казалось бы, должно полносью решить проблему отсутствия каких-либо шрифтов на стороне клиента, определение шрифта по старым версиям HTML и CSS всё ещё продолжает использоваться. Единственная причина существования по сей день длинных описаний типа `font-tamily: "PT Sans", "Arial", serif;`, которую я могу предположить - это совместимоть со старыми браузерами, но есть ли ещё какие-нибудь причины?
Причина раз: > The @font-face CSS at-rule allows authors to specify online fonts to display text on their web pages. > > @font-face CSS "над-правило" позволяет автором указать онлайн шрифты для отображения текста на их веб-страницах. Причина два: > The font-family CSS descriptor allows authors to specify the font for an element. > > font-family CSS свойство позволяет авторам указать шрифт для элемента. Простыми словами для этих элементов стоят разные задачи, которые они выполняют. К примеру, как сказано в вопросе, @font-face **объявляет** шрифт, а font-family уже его непосредственно **использует** для конкретного элемента.
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "html5, css3" }
Determine the curves along the vector field Consider the vector field $\vec{v} = x \vec\imath + y \vec\jmath$ for $0\le{x}\le{\infty}$ and $0\le{y}\le{\infty}$. Determine the parametric equations for the curves along which $\vec{v}$ has constant magnitude and for the curves along which $\vec{v}$ has constant direction. I know how to draw the vector field, and I have already done so for a few points. I am confused on how you would use this vector field to get the parametric equations for curves along the constant magnitude and constant direction. What does it mean to say "along the constant magnitude" and "along the constant direction"? I appreciate any answer I can get.
a) The magnitude of the field is $\sqrt{x^2+y^2}$. When it is constant, we have $$ \sqrt{x^2+y^2} = k $$ for some constant $k$. In other words, the curves for which the magnitude is constant are circles. Can you find parametric equations of such circles? b) The curves of the vector field are such that the vectors are tangent to the curves, therefore, they satisfy \begin{cases} dx = k\cdot x \\\ dy = k \cdot y \end{cases} where $k$ is constant. It follows that for $x,y >0$: $$k = \frac{dx}{x} = \frac{dy}{y} \quad \Rightarrow \quad \ln x = \ln y+ C \quad \Rightarrow \quad \ln \frac{x}{y} = C \quad \Rightarrow \quad \frac{x}{y} = e^C$$ We have thus shown that the curves are of the form $$ y= A x $$ where $A=e^{-C}$ is a positive constant. This is a linear equation, which shows that all curves have constant slope (or direction).
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "calculus, multivariable calculus, vectors, vector fields" }
Create an alias for a SQL Server named instance pointing to sql default instance I have an installation of SQL Server 2012 Std Ed on Windows 2012 R2 running in a default instance, and an app that wants to connect to it using a named instance (can't be changed) E.g. * ServerName - `mySQLServer` * Alias required by app - `mySQLServer\CrazyApp` I've tried to create an alias as follows: ![enter image description here]( * Alias Name - .\crazyapp * Port No - 1433 * Protocol - TCP/IP * Server . I've: * checked TCP/IP protocol is enabled * have started SQL browser (not needed, I believe) * restarted SQL (several times) * tried with the machine name instead of "." * tried with no port number instead of 1433. * _banged head against wall_ ...all to no avail. Is it possible to do this, if so, would some kind person tell me what I'm doing wrong. Thanks!
My observation is it is necessary to use cliconfg.exe on the **application server** in order for it to map a specific instance (e.g. '\crazyapp') to the default instance on the remote SQL server. On the application server, I have set aliases using cliconfg.exe, using both: * C:\Windows\System32\cliconfg.exe (64bit) and * C:\Windows\SysWOW64\cliconfg.exe (32bit) (thanks, @DaniSQL) From the application server, I have configured: ![alias settings]( I then successfully tested this from the application server, using SSMS to the remote SQL instance. Creating the alias on the server hosting SQL Server does not work, even if the application server can resolve the SQL Server name via DNS. In order to map from a named instance to a default instance, the alias must be created on the application server. Thanks to @ypercube for guiding me in the right direction.
stackexchange-dba
{ "answer_score": 8, "question_score": 3, "tags": "sql server, sql server 2012" }
The name of this type of matrix whats the name and the rules of a matrix thats like this. 1 2 3 4 5 6 1 X . . . X . 2 . . . X . . 3 . . . . X . 4 . . . . . . 5 . . . . X . 6 X . . . . X and it gets turned into this. 1 2 3 4 5 6 1 1 1 1 1 2 2 2 1 1 1 2 3 3 3 1 1 1 2 4 4 4 1 1 1 2 4 4 5 1 1 1 2 5 5 6 2 2 2 3 6 7
Well, the rule seems to be that the value of each element corresponds to the number of 'X' that are both above and to the left.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "matrix" }
How can I change the date time format in my query I am running a Query to select files with a certain date range at the end of the file name. WHat i have looks for date format YYYMMDD, But I need it to check for MMDDYYY. Can anyone give advice on how to format? MySQL through MySQL Workbench. LOAD DATA LOW_PRIORITY LOCAL INFILE 'C:\\Talend\\importall'+CONVERT(VARCHAR(8), GETDATE(), 112)+'.csv' INTO TABLE `production`.`pendi_complete`
Check out the DATE_FORMAT and the STR_TO_DATE functions, it should do the trick.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "mysql" }
Using generic methods, is it possible to get different types back from the same method? Could I have something like this: int x = MyMethod<int>(); string y = MyMethod<string>(); So, one method returning different types based on T. Of course, there would be logic inside the method to ensure it was returning the correct thing. I can never get something like this to run. It complains that it can't cast the return value to T: public static T MyMethod<T>() { if(typeof(T) == typeof(Int32)) { return 0; } else { return "nothing"; } }
Try the following public static T MyMethod<T>() { if ( typeof(T) == typeof(Int32) ) { return (T)(object)0; } else { return (T)(object)"nothing"; } } The trick here is the casting to `object`. What you are trying to do is inherently unsafe since the compiler cannot infer that 0 or "nothing" are convertible to any given `T`. It is unbounded after all. So just tell the compiler explicitly it's not safe with casting to `object`.
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 5, "tags": "c#, generics" }
yum install specific version of python package I want to yum install python-pyside, but I don't want any old/new version of pyside, I want pyside version 1.2.1. How can I do this? I currently have: yum install python-pyside
First check which versions are available in your repos yum --showduplicates list python-pyside | expand Then use the following to install a specific version that is listed from the command above yum install <package name>-<version info> Which means if v1.2.1 is available, you would need to run the command: yum install python-pyside-1.2.1 If it's not available then you need to enable a repo which has that version.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 6, "tags": "pyside, centos7, yum, python packaging" }
Passing variables to jquery function I'm trying to pass a changing variable to jquery function below but missing a piece. $(document).ready(function(){ var area = "NW"; $("#NWbutton").click(function (){ $('#mainmap > img').attr('src', "some_web_"+area+"_address_forpics_time.gif"); }); }); For the "NWbutton" I need var area = "NW". I have 20 or so buttons with corresponding variables. How do I pass these for each button instead of writing out each variable?
`data` attributes provide the perfect solution to this problem. You can put whatever data is related to that button into the attribute, which you can then read in the `click` handler. Something like this: <div id="mainmap"> <img src="foo.jpg" data-area="NW" /> <img src="bar.png" data-area="SW" /> </div> $("#NWbutton").click(function (){ $('#mainmap > img').attr('src', function() { return "some_web_" + $(this).data('area') + "_address_forpics_time.gif"; }); });
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, variables" }
How to screen mirror Android to non-smart TV? I bought a USB C-HDMI cable to mirror my Samsung Galaxy M11 to my non-smart TV, but I get no signal. The TV has 3 HDMI ports and with every single one, I get no signal. Is it a setting that I have to change on the phone or maybe on TV?
The cable you bought is an MHL cable using the USB Type-C (MHL Alternate Mode)). For such a cable to work the phone needs to include special hardware. Additionally the TV has to support MHL, too as it's HDMI socket has to be MHL-enabled. The MHL web site contains a list of devices that support MHL. There you can filter for Samsung devices. In my opinion MHL is today an outdated technology originally developed for phone with Micro-USB socket. You can also see that on the list of supported devices. The last Samsung galaxy phone that supported MHL is the Galaxy S5 released in 2014. The last Samsung device with MHL support I recognize was released in 2015.
stackexchange-android
{ "answer_score": 1, "question_score": 1, "tags": "hdmi, screen mirroring" }
Frequent VS 2010 is very slow and crashes on specific solution/file? My Visual Studio 2010 always slows down or crashes when working with a specific solution. And by slow, I mean SLOW! For example, I can type in 4-5 characters per minute. And usually the UI freezes, and sometime ultimately crashes down. So, basically I can't work with the solution. I tried these solutions with no effect: 1. Disabling and uninstalling all extentions. 2. Removing .suo, bin, and debug folders 3. Disabling IntelliSense, text editor options,... 4. Rebooting the system 5. Trying it on different computers with same versions of VS and Windows (7). Any idea on how to fix it?
So, after hours of trying out everything, I figured out that the crash happens when working on a specific file. Particularly, the issue was with this line of code: d = sd.Categories.Max(cat => cat.Subcategories.Max(d => d.Data.Where(a => a.CountryName != "World" && a.CountryName!="Asia Pacific").Max(a => a.AnnualData.Max(ad => ad.Value))); Apparently, since the line uses many lambda expressions, the VS parser cannot handle it efficiently, though it is a syntactically and semantically correct expression, and it's compiled and executed correctly. Solution: Remove or comment the line, and use a set of shorter expressions to perform the same functionality. I just used some nested foreachs to replace the expression.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "visual studio 2010, c# 4.0, lambda, crash" }
How do I cure Orb Piercer poison? I got poisoned by an Orb Piercer on the 4th Layer of the Abyss. The poison effect is purple and drains both my health and hunger. The Red, Blue, and Paralysis antidotes don't have any effect. How do I cure Orb Piercer poison? ![Dying from purple orb piercer poison](
The first thing you need to do is meet Nanachi, who you can find by: > Killing yourself with fall damage. (Source and tips here) Then, you should be able to acquire the Orb Piercer Venom. ![enter image description here](
stackexchange-gaming
{ "answer_score": 1, "question_score": 1, "tags": "made in abyss binary star" }
Parsing CSV header into list of parsers I want to parse first line of CSV file and to get list of parsers as a result, and fail miserably. After some simplifications I got code I think should work, but it does not, and I don't understand why. Here it is: {-# LANGUAGE OverloadedStrings #-} import Data.Text import Data.Attoparsec.Text import Control.Applicative doTestSep :: [String] -> Parser [String] doTestSep t = do (endOfLine >> return t) <|> (char ';' *> doTestParse t) doTestParse :: [String] -> Parser [String] doTestParse t = do (string "<FIELD1>" *> doTestSep ("field1" : t)) <|> (string "<FIELD2>" *> doTestSep ("field2" : t)) test = parseOnly (doTestParse []) "<FIELD1>" I call `test`, expecting to get something like > Right ["field1"] but instead I get > Left "Failed reading: takeWith" What am I doing wrong?
A problem is wrong input: my title line will definitely have `\n` or `\r\n`, which will be catched by `endOfLine`, and my example input did not have `\n` in it. Working version is test = parseOnly (doTestParse []) "<FIELD1>\n"
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "parsing, haskell, attoparsec" }
Spectator's Mode, Fog of War feature Wouldn't this feature allow for one team who has an active spectator watching the game without fog of war to give advices of incoming ganks, jungle invades, Baron, Dragon kills etc.? The source of why I know theres a _Fog of war_ feature is here Next Patch: The Full Release of Spectator Mode!
There's a 3 minute delay in spectator mode, so the only cheats that people have cautioned about so far would be watching a ward get dropped. Since a ward is alive for 3 minutes long, a spectator could communicate that to someone on a team, and the team would instantly know that the ward there was now gone.
stackexchange-gaming
{ "answer_score": 4, "question_score": 2, "tags": "league of legends" }
How do you use the $spacer variables in Bootstrap 4.5? Here's the code for $spacers in Bootstrap's _variables.scss file: $spacer: 1rem !default; $spacers: () !default; // stylelint-disable-next-line scss/dollar-variable-default $spacers: map-merge( ( 0: 0, 1: ($spacer * .25), 2: ($spacer * .5), 3: $spacer, 4: ($spacer * 1.5), 5: ($spacer * 3) ), $spacers ); Cool, that all looks useful. But how do I actually use these in scss? I've tried `$spacer-4`, `$spacer(4)`, `$spacers(4)`... All throw errors :(
Use `map-get`. For example: .foo { padding: map-get($spacers,4) } Demo: <
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 4, "tags": "twitter bootstrap, bootstrap 4, sass" }
How do I load sound resource? URLForResource returns nil I've been following this tutorial. This line of code returns nil... let url = NSBundle.mainBundle().URLForResource(filename as String, withExtension: "caf") Here's my resources... ![enter image description here]( Here's my build phase... ![enter image description here]( `NSBundle(forClass: self.dynamicType)` doesn't improve the situation.
The code worked when I dragged the sound file into the project instead of into the project's asset catalogue. I'm guessing that the latter's items are referenced by id instead of file name and type. I also needed to add the sound file to the "Copy Bundle Resources" section in "Build Phases".
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "xcode, bundle, assets" }
UserTerritory2Association Object I want to rename the label of the field. Can we change the field label for RoleInTerritory2 field in UserTerritory2Association object?
Its possible by using VF page. In Standard page is not possible to rename label of the field.
stackexchange-salesforce
{ "answer_score": 1, "question_score": 1, "tags": "territory management, territory, winter15" }
R function handling a vector I have a function that takes one argument and prints a string: test <- function(year){ print(paste('and year in (', year,')')) } I input a vector with one element year(2012) it will print this: "and year in ( 2012 )" How do I write the function so if I put test(c(2012,2013,2014))it prints this? "and year in ( 2012,2013,2014 )"
You could try using ellipsis for the task, and wrap it up within `toString`, as it can accept an unlimited amount of values and operate on all of them at once. test <- function(...){ print(paste('and year in (', toString(c(...)),')')) } test(2012:2014) ## [1] "and year in ( 2012, 2013, 2014 )" The advantage of this approach is that it will also work for an input such as test(2012, 2013, 2014) ## [1] "and year in ( 2012, 2013, 2014 )"
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "r, function" }
patterns for masking a XSS url to test against I'm going to allow users to set an image with a link on my site. e.g. a profile picture and a profile link. I will not let them upload said image, but let them give an url that i will insert into a img src. I want to do basic checks for the best know xss patterns someone may use my site for, but thing is, i have no list of samples to check my functions works. As it is, even if I write a full RFC compliant parser to check every aspect of the URL, i will still not know what i should guard against.
I would do the following * Check that the URIs start with http:// or https:// * URI encode the URI before printing it on the img src. The first one is to make sure no javascript:, vbscript: etc. URLS are allowed. The second one is to escape any character that can cause damage (like ", ', <, > etc.). Still a good resource for pattern, though a bit dated: < Another great resource: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "url, xss, validation" }
How can I show lines in common (reverse diff)? I have a series of text files for which I'd like to know the lines in common rather than the lines which are different between them. Command line Unix or Windows is fine. File _foo_ : linux-vdso.so.1 => (0x00007fffccffe000) libvlc.so.2 => /usr/lib/libvlc.so.2 (0x00007f0dc4b0b000) libvlccore.so.0 => /usr/lib/libvlccore.so.0 (0x00007f0dc483f000) libc.so.6 => /lib/libc.so.6 (0x00007f0dc44cd000) File _bar_ : libkdeui.so.5 => /usr/lib/libkdeui.so.5 (0x00007f716ae22000) libkio.so.5 => /usr/lib/libkio.so.5 (0x00007f716a96d000) linux-vdso.so.1 => (0x00007fffccffe000) So, given these two files above, the output of the desired utility would be akin to `file1:line_number, file2:line_number == matching text` (just a suggestion; I really don't care what the syntax is): foo:1, bar:3 == linux-vdso.so.1 => (0x00007fffccffe000)
On *nix, you can use comm. The answer to the question is: comm -1 -2 file1.sorted file2.sorted # where file1 and file2 are sorted and piped into *.sorted Here's the full usage of `comm`: comm [-1] [-2] [-3 ] file1 file2 -1 Suppress the output column of lines unique to file1. -2 Suppress the output column of lines unique to file2. -3 Suppress the output column of lines duplicated in file1 and file2. Also note that it is important to sort the files before using comm, as mentioned in the man pages.
stackexchange-stackoverflow
{ "answer_score": 246, "question_score": 213, "tags": "command line, diff" }
Add match to the same group when using pipe How to make both matches belong to group 1? _**regex:**_ ^.{7}(.*).{4}|(.*).{4} _**values:**_ QOQSNT.ini QOQSNT_MSSQLSERVER.ini _**Result:**_ ![enter image description here]( > Red is Group 1 > > Green is Group 2
In PCRE and Boost, you can use a branch reset group: (?|^.{7}(.*).{4}|(.*).{4}) ^^^ ^ ^ See the regex demo. However, you may also use ([^_]+)\.[^.]+$ See the regex demo. **Details** * `([^_]+)` \- Group 1: any one or more chars other than `_` * `\.` \- a dot * `[^.]+` \- 1+ chars other than a dot * `$` \- end of string.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "regex" }
iOS - How To Know If I Need A Routing App Coverage File I tried to submit an app to the Apple App Store on iTunes Connect and I got this error message: _"To configure this app as an iOS routing app, upload a routing app coverage file on the app's Version page in My Apps on iTunes Connect."_ My app uses MapKit to show the locations of various monuments in the user's city, and to provide directions on how to get to them. I Googled this error and interestingly most people that have answered it seem to be saying that the file is actually not needed, but I'm not sure if that applies to the features my app offers. How do I know if I actually need a routing coverage file? And if I do need one, can I make it cover the whole globe (i.e. the app should work anywhere in the world)?
The answer was to turn off MapKit altogether, eg. to uncheck it in the project capabilities tab. MapKit only needs to be turned on for "routing", which is a term I misunderstood. Routing means that other apps, such as Apple/Google maps, can use your app to display directions. I only wanted to show directions within my app, so turning on MapKit was unnecessary.
stackexchange-stackoverflow
{ "answer_score": 13, "question_score": 3, "tags": "ios, routes, mapkit, app store connect" }
Cannot push to Heroku main I'm trying to deploy using Heroku. When pushing my code to Heroku git through its HTTPS URL, I see an error like this > **git push heroku main** fatal: unable to access ' The requested URL returned error: 502 I already removed Heroku and added a new Heroku but it still didn't work. Can anyone help me? done
You're trying to use the address where your app is _hosted_ as a Git remote: But the address where your app is hosted and the address its Git service uses are different. Instead of adding the remote manually, I suggest you remove the existing one using `git remote rm heroku` and then ask the Heroku CLI to add a remote for you: heroku git:remote -a mfal-project You should now see a new remote called `heroku` that looks more like
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "sql server, git, heroku" }
Get Unique Key-Value count as an object I've got the following response from the server: ![enter image description here]( I want to get the unique key with the occurrence count. In the following format: 0:{"name":"physics 1","count":2} 1:{"name":"chem 1","count":6} I've already checked How to count the number of occurrences of each item in an array? but that is not I want.
Here is an es6 solution. const data = [{ id: 0, name: 'physics 1', questionId: 1, questionNr: 1 }, { name: 'physics 1', }, { name: 'chem 1', }, { name: 'chem 1', }, { name: 'chem 2', }]; const grouped = data.reduce((groups, cur) => { const key = cur.name; groups[key] = (groups[key] || 0) + 1; return groups; }, {}); const result = Object.keys(grouped).map(key => ({name: key, count: grouped[key]})); console.log(result);
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "javascript, angular, typescript" }
How to run nmake in one bat file When I run the following commands one by one in windows command prompt, they work fine. %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"" cd C:\\Program Files (x86)\\Jenkins\\jobs\\gdal_win32_develop\\workspace\\codes\\deps\\gdal\\gdal_1.8_rtc nmake -f makefile.vc clean nmake -f makefile.vc When I write them into one bat file and try to execute the bat file in windows command prompt, it only output the first command, the left three commands are not executed. How to do this? I need this because I want to run it in one Jenkins build project.
Replace line `%comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat""` with CALL "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat" You are not aware of it but while typing commands in command line, after first, you got a new instance of cmd.exe and next commands are typed in this new instance. You will need two `EXIT` commands to exit command prompt. Typing commands, you could just type `"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"` instead of `%COMSPEC% ...`, but in batch it would break batch execution, so you have to prepend `CALL`.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 2, "tags": "batch file, nmake" }
Migrating certbot/letsencrypt certificate to new server I have a server out there that supports HTTPS using a certbot/letsencrypt certificate. I am doing a general software upgrade so to minimize risks and downtime, I'm installing new releases on a new server on which I import the live server data for tests. When everything works I'll have the DNS record changed to point to the new server. My question is what should I do for the certificate? Can I just copy over the existing one and let it get renewed when necessary? Or will the certificate be incompatible and/or LE will complain that the address has changed during the auto-renewal process? Will LE be sensitive to reverse DNS (it may take some more delay for the reverse DNS to work). Is there any other problem I didn't think about?
By default, Certbot/Letsencrypt stores their configuration files and generated certificates in `/etc/letsencrypt`. So you just need to install Certbot into the new server and copy the directory from the old one. Of course you're gonna have to configure the webserver (Apache, Nginx, whatever you're using), pointing to the certificates in the new server.
stackexchange-serverfault
{ "answer_score": 7, "question_score": 3, "tags": "lets encrypt, certbot" }
mysql query compare MAX value and given parameter and return 0 or 1 if max is qual to given one i have this UNION query mysql> SELECT gpio_lastevent FROM `GPIO_setup` WHERE gpio_id = 5 UNION select max(gpio_lastevent) from GPIO_setup; the result is: +---------------------+ | gpio_lastevent | +---------------------+ | 2015-11-29 14:36:30 | | 2015-11-29 17:28:47 | +---------------------+ on mysql level I need to compare if MAX is equal to given parameter and return 0 or 1 in another column if true or 0 if false what i expect as result is: +---------------------+------------------- | gpio_lastevent |gpio_latestevent_true +---------------------+------------------- | 2015-11-29 17:28:47 |1 +---------------------+------------------- i think this is quite simple, but I cannot figure out how to place query. thanks for helping out
One way is to use a subquery: SELECT gpio_lastevent, gpio_lastevent=max_lastevent FROM `GPIO_setup` CROSS JOIN (SELECT MAX(gpio_lastevent) as max_lastevent FROM GPIO_Setup) m WHERE gpio_id = 5 here on the subquery I'm getting the last event, then I'm joining this subquery with all rows, then `gpio_lastevent=max_lastevent` will be 1 if the current event is the last event, 0 otherwise.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "mysql, compare, max" }
If $A$ is dense in $S$ and $S$ is dense in $T$ , then $A$ is dense in $T$ In a metric space $M$, if the subsets satisfy $A \subseteq S \subseteq \bar A$ where $\bar A$ refers to the closure of $A$, then $A$ is said to be dense in $S$. If If A is dense in S and S is dense in T , show that then A is dense in T. **Attempt:** Given that $A$ is dense in $S \implies A \subseteq S \subseteq \bar A$ and $S$ is dense in $T \implies S \subseteq T \subseteq \bar S$. We need to prove that $S \implies A \subseteq S \subseteq T \subseteq \bar A$. Let us suppose that $A \subseteq S \subseteq \bar A \subseteq T \subseteq \bar S \quad\ldots(1)$. Then it can be inferred that $A $ is dense in $S$, $S$ is dense in $\bar A$, $S$ is dense in $T$. Hence, $\bar A$ might contain some accumulations points of $S$ . $T$ might also contain some accumulation points of $S$. How do I proceed to bring about a contradiction to assumption $(1)$? Thank you for your help.
You are given $A\subset S\subset\bar A$ and $S\subset T\subset\bar S$, and you must show $A\subset T\subset\bar A$. From the hypotheses, you have $A\subset S$ and $S\subset T$, so $\boxed{A\subset T}$. From the hypotheses, $T\subset\bar S$; you also have from the hypotheses that $S\subset\bar A$, so $\bar S\subset\overline{(\bar A)} = \bar A$. Thus $\boxed{T\subset\bar A}$. The boxed conclusions above demonstrate that $\boxed{A\subset T\subset\bar A}$ as required. $\blacksquare$
stackexchange-math
{ "answer_score": 4, "question_score": 3, "tags": "real analysis, general topology" }
How to sync and optimize an Oracle Text index? We want to use a `ctxsys.context` index type for full text search. But I was quite surprised, that an index of this type is not automatically updated. We have 3 million documents with about 10k updates/inserts/deletes per day. What are your recommendations for syncing and optimizing an Oracle Text index?
I think 'SYNC EVERY' option, as described in previous answer only available in Oracle 10g or newer. If you're using older version of Oracle you would have to run sync operation periodically. For example, you can create following stored procedure: CREATE OR REPLACE Procedure sync_ctx_indexes IS CURSOR sql1 is select distinct(pnd_index_owner||'.'||pnd_index_name) as index_name from ctx_pending; BEGIN FOR rec1 IN sql1 LOOP ctx_ddl.sync_index(rec1.index_name); END LOOP; END; and then schedule it run via DBMS_JOB: DBMS_JOB.SUBMIT(job_id, 'sync_ctx_indexes;', SYSDATE, 'SYSDATE + 1/720'); As for index optimization, following command can be used (also can be scheduled with DBMS_JOB or via cron): alter index my_index rebuild online parameters('optimize full maxtime 60'); There is also CTX_* package with similar function available.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 10, "tags": "oracle, full text search, oracle text" }
Repeat alphabets in Python How do you ensure that a word taken in through a function repeats each of its alphabets in the output. Example: word("Hello")`should return`HHeelllloo` word("Hi-Tech")`should return`HHii--TTeecchh`
This should do the trick. def word(txt): new_txt = "" for letter in txt: new_txt += letter*2 return new_txt Basically, for every letter, you add 2 of the letter (`letter*2`) to a string, which you return at the end.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "python, python 3.x" }
How can we find the line? I want to find the line that passes through $(3,1,-2)$ and intersects at a right angle the line $x=-1+t, y=-2+t, z=-1+t$. The line that passes through $(3,1,-2)$ is of the form $l(t)=(3,1,-2)+ \lambda u, \lambda \in \mathbb{R}$ where $u$ is a parallel vector to the line. There will be a $\lambda \in \mathbb{R}$ such that $3+ \lambda u_1=-1+t, 1+ \lambda u_2=-2+t, -2+ \lambda u_3=-1+t$. Is it right so far? How can we continue?
The line you're given is $$(-1,-2,1)+t(1,1,1)$$ Thus, as you said, you want a line $\;(3,1,-2)+\lambda u\;$ , with $\;u\perp(1,1,1)\;$ , so if $\;u=(a,b,c)\;$ , you need $$u\cdot(1,1,1)=a+b+c=0$$ From here it is easier, I beleive.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "calculus" }
Select a random position in an array Is there a way to select a random position in a 2d array of bools (bool[,]) with a negative value without bruteforcing?
Here's a non-brute-force method, but it involves an initial scan of the entire table: int[] negOffsets = new int[data.Length]; int dataOffset = 0, count = 0; foreach(bool x in data) { if(!x) negOffsets[count++] = dataOffset; dataOffset++; } if(count == 0) { // nothing to pick } else { int index = negOffsets[rand.Next(0, count)]; int x = index / data.GetLength(1), y = index % data.GetLength(0); // assertion: the following should be false bool b = data[x, y]; } Also, you'd probably want to keep `offsets` around and re-use it between iterations.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "c#, arrays, brute force" }
How to convert List<string> to List<int>? My question is part of this problem: I recieve a collection of id's from a form. I need to get the keys, convert them to integers and select the matching records from the DB. [HttpPost] public ActionResult Report(FormCollection collection) { var listofIDs = collection.AllKeys.ToList(); // List<string> to List<int> List<Dinner> dinners = new List<Dinner>(); dinners= repository.GetDinners(listofIDs); return View(dinners); }
listofIDs.Select(int.Parse).ToList()
stackexchange-stackoverflow
{ "answer_score": 480, "question_score": 205, "tags": "c#" }
Entering line breaks in NSString I need to set mail Body in MFMailComposeViewController to separate some text in number of lines. I am using the following line of code but it isn't working. [mail setMessageBody:[NSString stringWithFormat:@"Hi I am Interested to buy a vehicle for me Name :%@ %@ \n Contact No. : %@ \n Email : %@\n",txtFirst.text, txtLast.text, txtContact.text, txtEmail.text ] isHTML:YES]; also i tried this [mail setMessageBody:[NSString stringWithFormat:@"Hi I am Interested to buy a vehicle for me Name :%@ %@ </br> Contact No. : %@ </br> Email : %@</br>",txtFirst.text, txtLast.text, txtContact.text, txtEmail.text ] isHTML:YES]; is there any solution to do it.
Try this [mail setMessageBody: [NSString stringWithFormat:@"First:%@ \r\n Second:%@ \r\n Third:%@ \r\n Fourth:%@", txtFirst.text, txtSecond.text, txtThird.text, txtFourth.text ] isHTML:YES];
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 7, "tags": "iphone, iphone sdk 3.0, mfmailcomposeviewcontroller" }
QPixmap load doesnt work I'm trying to put image to my form using QPixmap and QLabel. But i cant load image to QPixmap. Here is what i have: qDebug() << QFile("C:/img.png").exists(); - true qDebug() << map.load("C:/img.png"); - false I have this file but still cant load it. I use Qt 4.8 with static linking.
The issue could possibly be with the particular file you're trying to load. Try loading another file and see if you have the same problem.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c++, qt4" }
php radio box values Given that when using an html radio box, to send values to a php script, only the selected values is sent to the php script, still holds true. Do I still need to check that the user has selected something, when I am only interested in the selected value being sent to the php script, if the user does not select anything we do nothing or I guess I could prompt the user to select something. If so, whats the best way to handle this with regards to radio boxes? <!--Using the radio box, a single selected value is sent to the php script for processing--> <td width="100px" height="30px"> <input type = "radio" name = "selection" value = "Lays" />Lays Chips 0.99c<br /> <input type = "radio" name = "selection" value = "Ruffles" />Ruffles $1.85<br />
The user will be able to click the "submit" button even without selecting an option from your radiobox. If it's ok to send the form without a selection and you just want to do something different (or ignore it) when nothing is selected, you can do this: <?php if (isset(($_POST['selection'])) { //Use it.. and make sure to validate user input. } else { //nothing was selected. Do something or just ignore? } ?> OTOH, if you want to prevent submiting without a selection, you will need to use some JavaScript to do it.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php, radio button" }
pdo if rowcount is zero I want to run a python script if the dans_code doesn't exist. i use the following code for this: $dbh = new PDO("pgsql:host=localhost;dbname=import", $user, $pass); $stmt = $dbh->prepare("SELECT dans_code from import where dans_code = ':code'"); $stmt->bindParam(':code', $dans); $stmt->execute(); if($stmt->rowCount() == 0) { exec("C:\\Python34\\python.exe code.py $dans"); } but when i run the script also the variables that exist in my database trigger the if statement. How is this possible? i m using a postgresdatabase I have this code from this question Thanks
`Wrap off quotes` form your placeholder just use $stmt = $dbh->prepare("SELECT dans_code from import where dans_code = :code"); Other wise your where become `where dans_code='".'$dane'."'` and you always get 0 result
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, pdo" }
Qt Application and window Icon under windows I have created a simple application icon by embedding a standard windows resource file containing an icon. However I would also like to use this icon on my main application window. Is there an easy way to do this? So far it seems the only way would be to seperately load an icon that contains the window icon rather than reusing the already exisiting icon. This seems like a horrible solution. Amongst other things the actual icon is embedded in my executable I don't want to have to distribute it twice. Anyone know how to do this?
Actually ... turns out its very very simple ... HICON hIcon = (HICON)LoadImage( GetModuleHandle( nullptr ), MAKEINTRESOURCE( IDI_ICON1 ), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADTRANSPARENT ); setWindowIcon( QIcon( QtWin::fromWinHICON( hIcon ) ) ); ::DestroyIcon( hIcon );
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "c++, windows, qt, icons" }
Unhashable Type Error Whilst Finding Mode I'm trying to write a Python function `one_mode(l)` that takes a non-empty list `l` and returns a pair with its mode and the frequency of the mode. (In case there are several modes, an arbitrary one can be returned.) So far I have... from scipy import stats def one_mode(l): return stats.mode(l) which works for the followings tests: one_mode([5, 6, 7, 5]) == (5,2) But not for the test: one_mode([5, 6, 7, 5, 6]) in {(5, 2), (6, 2)} In this case it gives me > unhashable type: 'numpy.ndarray' Is there any way around this using my current code?
If you force the results of `stats.mode` to a tuple, your lookup will work: **Code:** from scipy import stats def one_mode(l): mode = stats.mode(l) # return first mode results as tuple return mode[0][0], mode[1][0] **Test Code:** assert one_mode([5, 6, 7, 5]) == (5, 2) assert one_mode([5, 6, 7, 5, 6]) in {(5, 2), (6, 2)}
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "python, list, python 3.x, numpy, scipy" }
Discord.py making bot respond in certain channels I want the users with my bot to be able to configure the bot to only run in certain channels. I was able to achieve this when I was using the `on_message` function by checking which channel the message was coming from. Now I'm using Cogs and I'm not sure how I would approach this problem. My Old Code was something like this: val_channels = ['a', 'b', 'c'] if message.channel in val_channels: # Do Something else: print('The bot was configured to: ' + ', '.join(val_channels))
You can verify if the `ctx.message.channel.id` matches with your list. class Greetings(commands.Cog): @commands.command() async def hello(self, ctx): """Says hello""" if ctx.message.channel.id in val_channels: await ctx.send('Hello!') else: await ctx.send('You can not use this command here.') But if you still want to use a `on_message` event inside a cog, you will need do modify the decorator. Link to doc class Greetings(commands.Cog): @commands.Cog.listener() async def on_message(self, message): if message.channel.id in val_channels: # Do something else: print('The bot was configured to: ' + ', '.join(val_channels))
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "discord, discord.py" }
How to use up-to-date with time indications The last time my data were updated in my report was last midnight. I want to write below the report something like: "The data in this report are up-to-date to last midnight" but it sounds awful. How should I write? Yes, I know I could simply write "Last Update: 18/03/2019 00:00" but I would like to write it in a different way. Thankx. W.
The data in this report is up-to-date as of midnight last night.
stackexchange-english
{ "answer_score": 4, "question_score": 1, "tags": "word usage" }
How to connect google font to page? I have used recommendations in Google Fonts how to set fonts. So I did the following actions: 1) Added this ependency on the page: <link href=" rel="stylesheet"> 2) Set CSS to body tag: html, body { font-family: 'Roboto', sans-serif; background: #f7f7f7; } When I tried to set font for another elements like: a { font-family: Roboto-Light; } It does not work. ![enter image description here](
a { font-family: 'Roboto'; /* You don't need this since you say html {font-family: 'Roboto'}*/ font-weight: 100; } /*Font's family name need to be inside quotes "MyFontName"
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "css, html, fonts, google webfonts" }
influxdb how to assign create/alter retention policy privileges to non-admin users influxdb is it possible to assign create/alter retention policy privileges to non-admin users Currently non-admin user have ALL privileges to a test db. But when tried to create/alter retention policy on test db, throws an error with "requires admin privilege" influxdb version - 1.1.0
**Q:** Is it possible to assign create/alter retention policy privileges to non-admin users **A:** Short answer: **No.** In `influxdb` version 1.1.x, even now (1.3.1), only `administrators` can perform `administrative queries` to; 1. Create or drop database 2. Drop series or drop measurements 3. **Create, alter or drop retention policy** 4. Create or drop continuous query. A normal `user` can only hold `Read`, `Write` or `BOTH (ALL)` privileges for databases. "Database privilege" only allows user to go about changing/reading point data for a `measurement`, nothing more.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "influxdb" }