INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Custom container traversal with range-based for loop In C++, some STL containers like vector, map, string can be traversed by for loops with colon in it. for instance: `for(auto c:v)` When I'm writing a custom container, can I make it traversed that way like Java (which only need to implement Iterable)?
Yes, you need to implement some form of iterator and override std::begin(container) and std::end(container) (might work also if you container has begin and end methods). Internally the code is equivalent to something like the following (this is just to get the point across, the compiler can write it slightly differently, see here for more details). auto _end = end(v); for (auto _it = begin(v); _it != _end; ++_it) { auto c = *_it; <the rest of loop code> } So if your iterator and overrides work as expected it will work for the for loop as well.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 6, "tags": "c++, c++11, traversal" }
C++ Stacks Pop General Theory I am confused on how the code below can be sent a variable and then change that variable to the value at the top of the stack without "returning" a value. So if 1 was at the top I could do stack.pop(variable) and then variable would equal 1. void DynIntStack::pop(int &num) { StackNode *temp; // Temporary pointer // First make sure the stack isn't empty. if (isEmpty()) { cout << "The stack is empty.\n"; } else // pop value off top of stack { num = top->value; temp = top->next; delete top; top = temp; } }
This is a parameter passed _by reference_. You can think of it as passing the actual parameter, not just the value. Any modification done to the parameter is reflected to the original variable just because they are the same variable. Actually the parameter is a reference (pointer) to the memory address of the real value.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c++, stack" }
Is it possible to Union 6 Columns with different tables different database and different server? Is it possible to Union 6 Columns with different tables different database and different server? **Please tell me if this is possible or not?**
AS previous answer you need linked servers for a start. When the servers have been added to your server where you are executing the query from you can run the query as follows SELECT Field1 , field2 FROM LINKED_SERVER1.DatabaseName.dbo.tableName_X UNION ALL SELECT Field1 , field2 FROM LINKED_SERVER2.DatabaseName.dbo.tableName_Y You can add as many tables to the union as you like, just following basic UNION rules. I.e all of the selects in the union must have the same number of fields, and of compatible datatypes
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "tsql, sql server 2005, union" }
Full-word selection in browser I understand that IE has a full-word selection feature, which people often want to turn off. I want the opposite. I want to automatically expand the selection to complete words in all browsers. Actually, for the moment, I don't really care about IE (but I will eventually). Anyone know of a solution for this? Thanks.
You may be able to do something in WebKit (and apparently Firefox 4) by using the modify method of the selection in conjunction with the `mousemove` event. It'll probably be quite tricky to get right though: you'll need to consider when it's appropriate to expand the selection. Here's a very simple example of using the `modify` method: <p>A paragraph with some nice text in it</p> <script type="text/javascript"> function expandSelection() { var sel; if (window.getSelection) { sel = window.getSelection(); if (sel.modify) { sel.modify("extend", "forward", "word"); } } } </script> <input type="button" onclick="expandSelection();" value="expand">
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript, cross browser, selection" }
dts-gen: fails to find globally installed modules I have installed dts-gen globally `npm i -g dts-gen` I installed the target module globally `npm i -g jhipster-core` When I run `dts-gen -m jhipster-core -o` I get the following output: `Couldn't load module "jhipster-core". Please install it globally (npm install -g jhipster-core) and try again. ` * * * I am working on a Windows 10 PC and executing the commands on the windows command prompt.
Installing NPM modules globally is usually a bad idea - you will eventually get into weird situations when the globally installed version accidentally gets used instead of the version specified in some package.json file. But in this case, the problem seems to be that "jhipster-core" requires the "chalk" module, but does not list it in package.json dependencies. This worked for me (just run it in some empty directory): npm install dts-gen jhipster-core chalk ./node_modules/.bin/dts-gen -m jhipster-core
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "node.js, typescript, typescript definitions" }
differentiate between instances of the same form with different prefixes in Django I am passing two form with different prefix in the template and each form has own submit button but how can I get data from these two form in submit button is pressed in any one of them and how to differentiate which form button was pressed return render(request,'part_details.html', {'part_stock_form': forms.part_stock_form(prefix='add'),'part_stock_edit':forms.part_stock_form(prefix='edit')}) template: add_app form object <form id="add_app_form" method="post" action="{% url 'parts:part_app_model' part_temp.part_id %}"> {% csrf_token %} {{ add_app.applicable }} <input type="submit"> </form> template: edit_app form object <form method="post" action="{% url 'parts:part_app_model' part_temp.part_id %}"> {{ edit_app.applicable }} <input type="submit"> </form>
since you have 2 submit button name them and check them, like <input type="submit" name="fom1">sumbit formm 1 <input type="submit" name="fom2">sumbit formm 2 if 'fom1' in request.POST: #statements elif 'fom2' in request.POST: #statements
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "django, django forms" }
What does the name of the ord() function stand for? The official Python documentation explains `ord(c)` > ord(c): > Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. For example, ord('a') returns the integer 97 and ord('€') (Euro sign) returns 8364. This is the inverse of chr(). It does not specify the meaning of `ord`, google searches are not helpful. What's the origin of it?
It stands for "ordinal". The earliest use of `ord` that I remember was in Pascal). There, `ord()` returned the ordinal value of its argument. For characters this was defined as the ASCII code. The same convention was also used in Modula-2. Later, Python (as well as PHP, some dialects of SQL etc) followed this convention, except that these days they're more likely to use Unicode rather than ASCII. It could well be that the origins of the term (and the function name) go back further than Pascal.
stackexchange-stackoverflow
{ "answer_score": 42, "question_score": 32, "tags": "python, unicode, built in, ordinal, ord" }
Selecionar parte de Texto no R Gostaria de filtrar elementos específicos de uma linha, semelhante ao filtro do Excel. Tenho o seguinte exemplo: NOME VALOR LEITO 1 10 LEITO 2 - HPP 20 LEITO 3 - HPP 30 LEITO 4 40 Preciso filtrar, na coluna nome, a linhas com os caracteres `HPP`. O resultado final do filtro deve ficar assim: NOME VALOR LEITO 2 - HPP 20 LEITO 3 - HPP 30 Como faço para fazer este filtro?
Os pacotes `dplyr` e `stringr` podem te ajudar nisso. Primeiro, vou criar o conjunto de dados: NOME <- c("LEITO 1", "LEITO 2 - HPP", "LEITO 3 - HPP", "LEITO 4") VALOR <- c(10, 20, 30, 40) dados <- data.frame(NOME, VALOR) A seguir, carrego os pacotes necessários: library(dplyr) library(stringr) Por fim, uma combinação das funções `filter`, que seleciona linhas de acordo com algum critério, e `str_detect`, que procura por um trecho específico de caracteres dentro de um conjunto maior de caracteres: dados %>% filter(str_detect(NOME, "HPP")) NOME VALOR 1 LEITO 2 - HPP 20 2 LEITO 3 - HPP 30
stackexchange-pt_stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "r, rstudio, dplyr, stringr" }
Is there a way to tell PowerPoint not to open Excel when creating charts? `Slide.Shapes.AddChart()` automatically opens Excel. Even if I quickly do `Chart.ChartData.Workbook.Application.Visible = false`, it still shows a little while. This makes automating chart creation error-prone as the user has to try not to touch the Excel applications that keeps popping up. Opening a presentation with `WithWindow = false` will still open Excel when creating new charts.
This behavior is "by design" and Microsoft is not interested in changing. This is the way the UI functions. What you could do would be to create the chart in Excel (using either the interop or OpenXML), then import (insert) that file into PowerPoint. Check this link from MSDN
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 7, "tags": "excel, powerpoint, office interop" }
GWT - how to set and get the value attribute of a Button() I've got a Button element and i would like to set and then get the value attribute of this button. Currently rendered: <button type="button" class="gwt-Button">page 1</button> What I want to achieve: <button type="button" class="gwt-Button" value="1">page 1</button> Code: final Button b = new Button("page 1"); // HOW TO: set value for the button b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // HOW TO: get value for the button } }); Documentation says nothing about this and the answer from this SO question doesn't even compile ("The method setValue(String) is undefined for the type Button")
I'm not a 100% sure about this but you could try to access the underlying button element itself and modify/read the value from there. Like: button.getElement().<ButtonElement>cast().setValue("1"); See more: * < * <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "gwt" }
How to get Android emoji code point I want to fill Android emoji code point to Mozc's emoji_data.tsv. While I found emoji data list, this list don't include latest Android emoji code point list. Is there latest Android emoji code point list? Or how to get Android emoji code point?
Not all emoji has Android (Google) PUA code points. Emoji made in Japanese carrier has had different code points, using private user area (PUA). They are called "Carrier Emoji". Each carriers PUA code points are mapped to Android (Google) PUA code points on Android phones. Thus, in case we show these carrier emoji on Japanese Android phones sold on a carrier's store, we should use Android (Google) PUA code point. After all, these carrier emoji were exported to Unicode 6.0 emoji. That is why only Uncode 6.0 emoji have their own Google PUA code points and newer Unicode 6.1 (or later) emoji do not.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "android, emoji" }
ASP.NET MVC 4 Default template has a different syntax for logout in _LoginPartial.cshtml I am using ASP.NET MVC 4 for the first time, so I started with the default template. In the _LoginPartial.cshmtl for Log off link I found the below code @using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) { @Html.AntiForgeryToken() <a href="javascript:document.getElementById('logoutForm').submit()">Log off</a> } I was expecting a code like the one below, which I have been using in MVC 3. @Html.ActionLink("Log off", "LogOff", "Account") Please can someone help me understand as to why this is necessary, and its advantages if any. Thanks
There's no big difference. MVC4 uses a HTML-form to logout, which is submitted via the javascript. The advantage is that the new way (with the form) uses javascript to submit the form, which is why the page does not have to reload.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 4, "tags": "asp.net mvc 4" }
Parsing XML in VBA I have an XML `ResponseXML` object. I'd like to loop throught all nodes called "XYZ". How do I do this?
Here are some functions you can use for **parsing** your **XML** : Private xml As MSXML.DOMDocument Private Sub loadXMLFile(xmlFile) Set xml = New DOMDocument xml.async = False xml.Load (xmlFile) End Sub Private Sub loadXMLString(xmlString) Set xml = New DOMDocument xml.LoadXml (xmlString) End Sub Public Function getNodeValue(xpath As String) As String getNodeValue = xml.SelectSingleNode(strXPath).Text End Function Public Function getNodes(xpath as string) As IXMLDOMNodeList Set getNodes = xml.SelectNodes(xpath) End Function Public Function getNode(xpath as string) As IXMLDOMNode Set getNode = xml.SelectSingleNode(xpath) End Function See MSDN for more information about MSXML: <
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 3, "tags": "xml, vba" }
Find path of BLAS or MKL that is linked to numpy I want to check the path of BLAS or MKL which is linked to the `numpy`. The system is already built by the others and I don't have root account. Is there any way to find the path in python command?
You can use the following command np.__config__.show() show_config command shows the libraries in the system on which numpy was built. Documentation link Thanks
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, numpy, blas, intel mkl" }
Dired: can't create a regexp to hide all the necessary files I read the following article: < about hiding certain files in dired mode. I decided to hide more files and added a shortcut Alt-q, that will toggle the visibility of: 1. All the hidden files, starting with dot. 2. All Emacs backup files, ending with '~'. I wrote the following code: (setq dired-omit-files "^\\.$|~$") (add-hook 'dired-mode-hook (lambda () (define-key dired-mode-map (kbd "M-q") 'dired-omit-mode) )) But only ~ files are hidded, not those, starting with dot. What is wrong?
Testing with `emacs -q` to ensure no customizations: (require 'dired-x) ;; provides dired-omit-mode `M-x dired` `~` -> Backup files and dot files are both present (had to manually add backups since I store them in a dedicated folder by default. 1. `M-x dired-omit-mode` -> Backup files are hidden 2. `M-x dired-omit-mode` -> All files visible again 3. `(setq dired-omit-files "^\\..*$")` -> Omit dotfiles 4. `M-x dired-omit-mode` -> Backup and dotfiles are hidden. Docstring for `dired-omit-mode` makes reference to `dired-omit-extensions`. Looking in there, the 2nd extension listed is `~` (emacs backup files). This comes from `completion-ignored-extensions` (following dock string). This means by default `dired-omit-mode` will already remove backups from the view, reducing the complexity of the regexp needed.
stackexchange-emacs
{ "answer_score": 6, "question_score": 4, "tags": "dired, regular expressions" }
Is a foreign equity holder liable for business debt? I'm an Indian citizen residing in India. **If I get 20% equity in a US company, am I responsible for the company's debts (current and future debts)?** Note that this is a **sweat equity** (no money invested). I'm getting this because of my contribution in product development. Thanks,
Usually no. < > A corporation is an incorporated entity designed to limit the liability of its owners (called shareholders). **Generally** , shareholders are **not personally liable for the debts of the corporation**. Creditors can only collect on their debts by going after the assets of the corporation. > > Shareholders will usually only be on the hook **if they cosigned or personally guaranteed the corporation’s debts**. However, shareholders may also be held liable **if a creditor can prove corporate formalities weren’t followed** , shareholders **commingled personal, and business funds** or the corporation was just a shell designed to shield liability. This is called piercing the corporate veil.
stackexchange-money
{ "answer_score": 1, "question_score": 1, "tags": "united states, india, debt, equity" }
Swift - How can I compare the values of a collection of variables? I have 7 variables called `averageMon`, `averageTue`, `averageWed`, and so on, and I need to compare the value stored in each variable to see which holds the highest value. I've been looking around but haven't found a way to do this. I'm brand new to this, and I'm sure this is a simple question, but any help would be appreciated. Thanks!
If I understand correctly, just call the max function: max(averageMon, averageTue, averageWed, averageThu, averageFri, averageSat, averageSun) <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "swift" }
What are the 2 nfl teams that played each other the least and the most? What are the 2 nfl teams that played each other the least and the most? P.S. This is between two teams that exist right now not defunct teams
As of the end of the 2020 season, all of the current NFC West have played only **4 games** against the **Houston Texans**. * Seattle Seahawks * San Francisco 49ers * Los Angeles Rams * Arizona Cardinals That the Texans are involved here is not surprising as they the most recent expansion franchise in the NFL, beginning play in 2002. Unless amended, the rotating schedule of NFL matchups pairs the NFC West with the AFC South in the 2021 season, so the Texans will play all the above teams in the 2021 season. The record for the most head-to-head matches goes to **Chicago Bears vs. Green Bay Packers** with a stunning **202 games**. _Stats taken fromhere (HOU), here (CHI)_
stackexchange-sports
{ "answer_score": 4, "question_score": 2, "tags": "american football, nfl" }
Why "respect you most" instead of "respect you more" in the following quote by Samuel Johnson? "Go into the street and give one man a lecture on morality and another a shilling, and see which will respect you most." British Literature 1640-1789 I can't figure out why Johnson used "most" instead of "more". Am I missing something here? Is it grammatical as it is?
There could be two scenarios. 1. A man who received a shilling respects you more than the other man (who was lectured) respects you. 2. A man who received a shilling respects you 100% wholeheartedly and the other man respects you only 50% halfheartedly. If you write the sentence based on the first scenario, I think using "more" is more appropriate. However, if it is based on the second scenario, I don't see any reason why the superlative can't be used for the sentence. I think the adverb _most_ in your example means > To the greatest extent For example: A: Who do you like more between Adel and Taylor Swift? B: I like Adel more than (I like) Taylor Swift. (comparison ) A: Who do you like most between Adel and Taylor Swift? B: I like Taylor Swift most (to the maximum extent that I can possibly like any person) I could be wrong, but this is the way I understand the difference.
stackexchange-english
{ "answer_score": 1, "question_score": 4, "tags": "comparatives, superlative degree, degree of comparison" }
What is the difference between Paypal "preapproved payments" and "automatic payments"? Trying to implement automatic payments via the Paypal Reference Transaction API. Manage to make it work on sandbox but I noticed on the customer summary page, it refers to the payments as "preapproved payments". Comparing it to services I used where automatic payments are enabled, the customer summary page shows them as "automatic payments". Now I'm wondering if these are two different things. Or maybe the sandbox site has outdated/updated naming. Are they the same?
Well, there are lots of different terms for these you might be seeing, but they are different things. If you see preapproved payments, preapproval, billing agreement, reference transaction, then that's referring to having an agreement on file that allows your application to process payments on behalf of the user. This could be for any amount at any time, so you can build much more flexible apps with this sort of thing. It's also harder to get approved because it gives you, the app owner, a lot of power. Your app would be in charge of triggering payments when necessary. Subscriptions, recurring payments, recurring billing would be referring to where you create a profile on the PayPal system, and their system takes care of triggering payments for you. These are more limited because it's a fixed amount that gets processed at a fixed interval.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "paypal, paypal sandbox, paypal subscriptions" }
Transfer data from java application to c# I need to transfer byte array from my java app to a c# app. One option is just store it into a file but its not so secure. I was thinking maybe there is a way to use a memorystream or something so the data wont be stored anywhere else than memory. EDIT: Just to give more information. Applications run on the same machine and C# applications is executing the java application.
You can expose methods in a way that will allow the two application to speak to each other. Here is a similar question with numerous answers.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 3, "tags": "c#, java" }
How to increment a variable by 1 each time it's accessed I'm coding a recyclerview with infinite scroll. `int number = 1` Let's say `string url = " + 'number'"` is the URL of the first set of list. Then when I'm appending the next page to the current page, the value of `number` in the `url` variable will become `2`. Next, it'll be `3` and so on. I'm thinking of checking the current value of `number` in `url` and then incrementing by 1 but I don't know how to go about it.
The correct way should be making it private and creating accesors private int number; public void setNumber(int number) { this.number = number } public int getNumber() { return number; } Once having this you can modify the getter so it says: public int getNumber() { return number++; } That will increment number by 1 each time you call getNumber() So you can just use string url = " + getNumber(); Hope this helps.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "java, android" }
Enhanced for loop unable to initialize object protected Day[] days= new Day[n]; for(int i=0;i<days.length; i++) { days[i]= new Day(5); } Above mentioned code works fine for me but modified for loop as mentioned below results in NullPointerException when I try to access the elements of the array. Can anyone explain why does it happens? protected Day[] days= new Day[n]; for(Day d:days) { d= new Day(5); }
When Java sees the enhanced for loop that you've made, it runs whatever you put inside it and makes a new variable (called `d`) and gives this variable a value of whatever is inside of your array. When you set `d` equal to a `new Day(5);` you are changing the value of the variable `d`, not the value inside the array. Here is a workaround: protected D[] days = new Day [n]; for(int i = 0;i<days.length;i++) days[i] = new Day(5); This reaches into the actual array to set values. Hope this helps!
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "java, for loop" }
Use extended REST functions like contains in Dynamics CRM As I noticed, fetching data in Dynamics CRM with REST is a lot faster then with SOAP especially for big data. Since I'm new to this topic (REST) I want to ask if it's necessary to include any additional library to use functions in my query for instance "contains". If I send the query: XrmServiceToolkit.Rest.RetrieveMultiple("ActivityPointerSet", "$filter=contains(Subject,'Test')&$top=10", function(results){ console.log(results); }, function(error){ console.log(error); }, function onComplete(){ }, false); I get the error message: Error : 400: Bad Request: Unknown function 'contains' at position 0. I got more or less intricate queries yet with fetchXML. Is it in most cases possible to alter them to REST? Best Regards
You cannot use the `C# QueryExpression` functions in `Odata Queries` directly. You have to modify them according to `Odata Syntax/Functions`. Please change your query to below and try again: select=*&$filter=substringof('Test',Subject)&$top=10 A very good tool to generate complex `Odata Queries`is Dynamics XRM Tools ![enter image description here]( Adding Selection Criteria to REST Queries in CRM 2011
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 1, "tags": "javascript, rest, dynamics crm 2011, odata, dynamics crm" }
Why should we have $\sin^2(x) = \frac{1-\cos(2x)}{2}$ knowing that $\sin^2(x) = 1 - \cos^2(x)$? > Why should we have $\sin^2(x) = \frac{1-\cos(2x)}{2}$ knowing that $\sin^2(x) = 1 - \cos^2(x)$? Logically, can you not subtract $\cos^2(x)$ to the other side from this Pythagorean identity $\sin^2(x)+\cos^2(x)=1?$ When I look up trig identities, however, it says $\sin^2(x) = \frac{1-\cos(2x)}{2}$. Why is this?
Notice that $\cos^{2}(x):=(\cos(x))^{2}$ is not the same thing as $\cos(2x)$. It is indeed true that $\sin^{2}(x)=1-\cos^{2}(x)$ and that $\sin^{2}(x)=\frac{1-\cos(2x)}{2}$.
stackexchange-math
{ "answer_score": 4, "question_score": 3, "tags": "trigonometry" }
How to evaluate $\lim _{x\to 0}\left(\frac{x\left(\sqrt{3e^x+e^{3x^2}}-2\right)}{4-\left(\cos x+1\right)^2}\right)$? I have a problem with this limit, I don't know what method to use. I have no idea how to compute it. Can you explain the method and the steps used? $$\lim _{x\to 0}\left(\frac{x\left(\sqrt{3e^x+e^{3x^2}}-2\right)}{4-\left(\cos x+1\right)^2}\right)$$
You get in the denominator $$ 2^2-(1+\cos x)^2=(3+\cos x)·(1-\cos x)=(3+\cos x)·2 \sin^2(x/2) $$ so that you can reduce the limit to $$ \lim_{x\to 0}\frac{x^2}{(3+\cos x)·(1-\cos x)}·\lim_{x\to 0}\frac{\sqrt{3e^x+e^{3x^2}}−2}{x} \\\ =\frac12·\lim_{x\to 0}\frac1{\sqrt{3e^x+e^{3x^2}}+2}·\lim_{x\to 0}\frac{3(e^x-1)+(e^{3x^2}-1)}{x} $$ which now has simple limits
stackexchange-math
{ "answer_score": 4, "question_score": 1, "tags": "calculus, limits, limits without lhopital" }
BB Marionette: best way to update a collection without re-rendering I have a very simple page that shows a collection in a table. Above it theres a search field where the user enters the first name of users. When the user types I want to filter the list down. Edit: I have updated the code to show how the current compositeView works. My aim is to integrate a searchView that can _.filter the collection and hopefully just update the collection table. define([ 'marionette', 'text!app/views/templates/user/list.html', 'app/collections/users', 'app/views/user/row' ], function (Marionette, Template, Users, User) { "use strict" return Backbone.Marionette.CompositeView.extend({ template: Template, itemView: User, itemViewContainer: "tbody", initialize: function() { this.collection = new Users() this.collection.fetch() } }) })
Divide your template in a few small templates, this increases performance at the client side, you don't have problems with overriden form elements and you have more reuseable code. But be aware of too much separation, cause more templates means more views and more code/logic.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "backbone.js, marionette" }
Deny access to imported module in a module I have a module in my code called `a.py` which looks a bit like this: import sqlite3 from sqlite3 import * """The point of importing twice in a different way is to have a.py imported by someone and have all the sqlite3 functions (with some overriden by a.py) but a.py still needs access to the source sqlite3 functions that he overrides""" def connect(database): #overriding sqlite3's connect() print "It worked!" return sqlite3.connect(database) and a file called `b.py`: import a a.sqlite3.connect("data.db") I want to make the code in `b.py` invalid as no one should be able access the original (non-overriden) functions through `a.py`, how can I do this?
I'm afraid that you can't! Check here for more details: < But you still can use `import sqlite3 as _sqlite3` and use it later like `_sqlite3.connect`. This will tell your module users (convention only) not to use this attribute. And you still can use `__all__` module variable as Ilja Everilä mentioned to prevent from a import *.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python" }
Syntax for DML update I am working on a cleanup of our EmailTemplate structure. Moving a lot of templates between various folders. What is syntax in Apex for the equivalent of this SQL... Update EmailTemplate set FolderID=(some ID) where ID IN ('id1', 'id2', 'id3' etc...)
If you already have the Id values you can do this: Set<Id> ids = new Set<Id>{'..', '...', ...}; Id someId = ...; EmailTemplate[] templates = new EmailTemplate[] {}; for (Id id : ids) { templates.add(new EmailTemplate(Id = id, FolderId = someId)); } update templates;
stackexchange-salesforce
{ "answer_score": 6, "question_score": 0, "tags": "apex, soql" }
how to manage hello.gram for conversation using sphinx and freetts in java I am developing small voice based interaction tool using sphinx (Speech to Text) and FreeTTS(Text to Speech) in java. for eg : FreeTTS gives voice command like Name : user will reply his name and age and place.everything is static. How to write hello.gram in sphinx to achieve this public<greet>=[<name>] [<age>] [<place>]; <name> = john | max; <age> = ten | nine ; <place> = France | Spain; Voice command : What is your name my reply : Max Observation : Max ten Voice command : what is your age my reply : nine Observation : nine France I want only names should be observed when i say name.its highly intermittent too :( Thanks in advance. # modified based on Alexander's answer.
You can use below code to avoid it . public <name> = john | max; public <age> = ten | nine ; public <place> = France | Spain;
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, speech recognition, grammar, speech to text, cmusphinx" }
Parse JSON Nested SubValues in Powershell to Table I converted the JSON string to Powershell in v5. The original json string is below: $j = @' [{ "id": "1", "Members": [ "A", "B", "C" ] }, { "id": "2", "Members": [ "A", "C" ] }, { "id": "3", "Members": [ "A", "D" ] }] '@ $json = $j | ConvertFrom-Json I would like the result set to look like the result set below. Eventually I will export to SQL: id Members ----- -------- 1 A 1 B 1 C 2 A 2 C 3 A 3 D
try this $json | % { $id = $_.id $_.members | select @{n='id';e={$id}}, @{n='members';e={$_}} }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "json, csv, powershell, parent child" }
Prove $0\le a<b\:\text{implies}\:0\le a^2<b^2\:\text{and}\:0\le \sqrt{a}<\sqrt{b}$ This proof can be done by using a contradiction. For proving a contradiction, if $0\le a<b$ implies $0>a^2\ge b^2\:\text{or}\:0>sqrt{a}\ge sqrt{b}$. If this is the right direction, then I would have to provide each case.
Hint: $u^2-v^2=(u-v)(u+v)\,$, and if $u,v \ge 0$ then $u+v \ge 0$, so $u-v$ and $u^2-v^2$ have the same sign. Use that twice, once for $u=a, v=b$, then for $u=\sqrt{a}, b=\sqrt{b}\,$. * * * [ _EDIT_ ] For example, with $u=a, v=b$ where $a,b \ge 0\,$, it follows from the above that: $$ a-b \le 0 \iff a^2-b^2 \le 0 \quad\style{font-family:inherit}{\text{which is the same as}}\quad a \le b \iff a^2 \le b^2 $$
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "real analysis" }
JQuery draggable div I am trying to create my first JQuery-based webpage. At the moment there is a little problem with my draggable div. I am able to move it and it works well but I am able to move it out of my screen. Is there a code like `maxleft=0px`? ### JQUERY: <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <script> $(function() { $( "#card" ).draggable({ axis: "x" }); }); </script> ### HTML: <div id="card" class="card"> <img src=" class="profil-pic" alt="img" /> </div>
You need give boundry div in which area it can be move. $("#card").draggable({ axis: "x", containment: 'body' });
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "javascript, jquery, html, jquery ui" }
get the image size with javascript i am using js for dynamic content now i want to get the size (width and height) of an image until now i used `img.clientWidth` and `img.clientHeight` but when i have set `img.style.width` and `img.style.height` the `img.clientWidth` and `img.clientHeight` changed as well. i need a variable which does not change during the webpage changes, since the src does not change as well. if there is any way, i would prefer no jquery
To find the _original_ (intrinsic) size of the image file, use the `.naturalWidth` and `.naturalHeight` properties of the element, if available.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "javascript, html, css, image" }
define a new way to use php tag and code in html **hello** , i want to know how a framework like laravel change <?php echo ?> to this {{ }} ? i have a few ideas to use json and javascript but i can't really understant it. maybe even using functions and define to make codes like "echo" smaller but php tag is something else, overall i want to know what is the best way to do this ? to change php tag and code to what i want and make html undrstand it ? sorry if my question is duplicated or else but it's making me crazy.
Laravel (and others like Twig) use a interpreter/compiler to transform their meta-language into PHP. You can find Laravel's compilers here and even some more specified compilers that translate into PHP code here. The compiled PHP is usually/always cached somewhere for performance reasons.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -1, "tags": "javascript, php, html, laravel" }
How can I set html and body padding to 0 in Vuejs without affecting bootstrap elements? I'm creating a bootstrap navbar in my Vuejs project and it's spaced with some left and right margin without adding any body or html padding to 0. When I go to welcome.blade.php file and set body and html padding to 0 like so: *{ padding: 0!important; } Then I get no right and left space on my bootstrap navbar but algo I get no space between elements inside my bootstrap navbar. I want to set HTML and body padding to 0 without affecting bootstrap element paddings/margins.
If you use * that means all tags and classes, You have to use body { padding: 0 !important; margin: 0 !important; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -1, "tags": "html, css, vue.js, padding" }
Why can't Drupal write to the database after migrate/restore? When I want to do more development on a live site, I usually make a copy of the files and database on my local LAMP install and play with it there. Now I'm finding that if I copy the database to local using Backup and Migrate or importing/exporting with phpMyAdmin, the local Drupal can only read from the database. It displays pages, but any edits or admin changes don't get saved. No errors, just nothing changes. I've tried clearing all caches and running update.php. I'm running the same Drupal version live and locally. If I install Drupal locally from scratch, no problems at all. What am I missing here... or is there a better way to achieve production/live cloning?
It was a schoolboy error on my part. I didn't have mod_rewrite enabled on my local environment, so clean URLs weren't working.
stackexchange-drupal
{ "answer_score": 2, "question_score": 2, "tags": "7, database, backups" }
How many newsletters can I subscribe? I have subscribed 12 newsletters. And I want to know how many newsletters can I subscribe?
As many as you want. There's no limit beyond the actual number of the sites we have, and even then you could subscribe multiple times for the same newsletter with different email addresses. I don't know why you'd _want_ to subscribe to 140+ newsletters, but hey. It's your inbox. :)
stackexchange-meta
{ "answer_score": 8, "question_score": 3, "tags": "support, newsletter" }
jQuery to get innerHTML not working on a HTMLFontElement object I have jQuery to select all `font` elements that are children of the element with `id="right"` within the html stored in the var `html`... when I do an alert to see how many elements it gets: alert($("#right > font", html).length); it gives me an alert of: `5` but when I try any of the following, I don't get any alerts... alert($("#right > font", html)[0].html()); alert($("#right > font", html)[0].text()); alert($("#right > font", html)[0].val()); Any Ideas? Thanks, Matt
Since the element is not an instance of jQuery, and its just a DOM object you can't use any of the jQuery methods. You can use innerHTML to get the result. alert($("#right > font", html)[0].innerHTML); If you want to apply any of the jQuery methods to the element you have to make it a jquery object like alert($($("#right > font", html)[0]).html()); or $("#right > font").each(function(){ alert($(this).html()); });
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "javascript, jquery, dom, alert, dom manipulation" }
Firefox not refreshing all tabs when it opens I upgraded recently from Firefox 12 to Firefox 17, now when I open up the browser (set to open up with all the tabs that were opened when it was closed last), it doesn't refresh each tab. I now have to click on each tab before it will refresh. Is there a way to get the old behavior of all tabs refreshing on open?
In FF open the `Option` menu and under `Tab` section uncheck the option **Don't load tabs until selected**.
stackexchange-superuser
{ "answer_score": 2, "question_score": 1, "tags": "firefox" }
Is 其他人 any different from 别的人? I guess the question could also be, is any different from ? Is one any more formal, any more slang, any more rude, anything of the sort, than the other? Or are they essentially the same?
They are similar in the meaning, however, not exactly the same. has a meaning of "the others", but it also has the meaning of "the rest", since this word is often used in the last when you are listing some categories, for example, ", , code review, ." this word has the meaning in dividing the scopes. also has the meaning of "the others", for example, ", ", in this sentence, the speaker tries to emphasize what he knows (""), since "", from the literature meaning, ""+"", has the meaning of different, so this word has the tendency in comparing and emphasis.
stackexchange-chinese
{ "answer_score": 9, "question_score": 7, "tags": "word choice, difference" }
How to show that the inequality is true? Let $ (a_n)_{n \geq 1}$ be a sequence in $\mathbb{R}$ and let $a \in \mathbb{R}$. Assume that $N \in \mathbb{N}$, $\epsilon > 0$ and for all $n > N$ the following is true: $|a_n - a| < \epsilon$. Show that for all $n > N$ the following inequality is true: $ \left| \frac{1}{n} \sum\limits_{k=N+1}^n a_k -a\right| \leq \epsilon + \frac{N}{n} |a|$ I tried the following: $\left|\frac{1}{n} \sum\limits_{k=N+1}^{n-1} a_k +\frac{1}{n}a_n - a\right| \leq \left|\frac{1}{n} \sum\limits_{k=N+1}^{n-1} a_k \right|+\left|\frac{1}{n}a_n - a\right| $ I also know: $\left|\frac{1}{n}a_n - a\right| + \left| \frac{n-1}{n}a_n \right| \geq \left| a_n-a \right|$ So: $\left|\frac{1}{n} \sum\limits_{k=N+1}^{n-1} a_k \right|+\left|\frac{1}{n}a_n - a\right| < \left|\frac{1}{n} \sum\limits_{k=N+1}^{n-1} a_k\right| + \epsilon -\left| \frac{n-1}{n} a_n \right|$ But I don't know how to continue from there. I would very much appreciate some help.
$\left|\dfrac{\displaystyle \sum_{k=N+1}^n a_k}{n} - a\right| = \left|\dfrac{\displaystyle \sum_{k=N+1}^n (a_k - a)}{n} + \dfrac{(n - N)a}{n} - a\right| = \left|\dfrac{\displaystyle \sum_{k=N+1}^n (a_k - a)}{n} - \dfrac{Na}{n}\right| < \left|\dfrac{(n - N)\epsilon}{n}\right| + \dfrac{N}{n}\cdot |a| < \epsilon + \dfrac{N}{n}\cdot |a|$
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "sequences and series, inequality" }
Rails 3.2.3 - twitter like pagination or endless pagination I went through many articles regarding twitter like paging using AJAX for Rails and now I'm a little bit confused. I think I didn't find yet what I was looking for. I have a web site, it shows the photos and has a table layout. <table> <% i = 0 tdCount = 3 @photos.each do |p| if i % tdCount == 0%> <tr> <%end%> <td> <%=image_tag(p.source , {:width => 240})%> </td> <%if i % tdCount == (tdCount-1)%> </tr> <%end%> <% i += 1 %> <% end %> </table> As far as I'm concerned it's quite difficult to use any "pageless" solution since I have a table layout. If not so, which one should I use? Which one is more modern than others and works good?
Never Ending page is nothing but the pagination in which you wont have links at the bottom like normal pagination rather your next page would get appended at the bottom of your current page when the scroll reaches at the bottom. Please refer [rails cast endless][1] [1]: < For better understanding. I have created it in Jquery ajax though in the link it is done using Javascript.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, ajax, ruby on rails 3" }
How to use a method that has a pointer to an array for an argument? I would like to make a method that has for argument a pointer to the first element of an array, and that then cycles through the array looking for something... void MyClass::myMethod(T *x) { // I know that *x points to the first entry in a properly defined array. // I want to cycle through this array, and try to find a member T of that array that // meets certain criteria. // I would then like to store a pointer to this T that meets my criteria. }
You also need to pass the size of the array explicitly. Then you can do: for(T *current = x; current < x + count; ++current) { // do something with current, compare or whatever } An alternative would be to use indexing notation, like below. Which one is better mainly depends on how exactly you want to access the data later on. for(int i = 0; i < count; ++i) { // current element is x[i] // pointer to current element is then x+i, or &x[i] } Usually you are better off using standard array containers, implementing your algorithms using iterators. Your function then takes two iterators defining the range on which it should operate, basically like this: template<typename Iterator> void doSomething(Iterator begin, Iterator end) { for(; begin != end; ++begin) { // current element is *begin } }
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c++, arrays, pointers" }
Easy to follow beginners tutorial for Titanium mobile/studio I'm new to Titanium mobile as well as titanium studio, but have heard good things about it. Can anybody recommend some easy to follow tutorials for beginners? I am also new to Mac - and javascript,- so go easy on me :)
Here are few links you can follow: 1- Titanium Wiki 2- Seven days with Titanium 3- Titanium WareHouse
stackexchange-stackoverflow
{ "answer_score": 55, "question_score": 43, "tags": "titanium mobile" }
Sending user generated string to SOLR I am running solr 4.3.0. I have three simple demands of my search feature 1. each word will be searched alone, results order will be presented by their existence and proximity. 2. "" words between quotation mark will be searched together (near) 3. (-) words next to minus sign will not apear in result. I believe this is a very common search definition, so my question is what is recommended way to translate user generated free text field to the solr search http request ?
You need to check the edismax query parser which will handle all of the above. 1. By setting the `qf (Query Fields), qs (Query Phrase Slop), pf (Phrase Fields), ps (Phrase Slop), pf2 (Phrase bigram fields), ps2 (Phrase bigram slop), pf3 (Phrase trigram fields), ps3 (Phrase trigram slop)` parameter you can control which fields would be searched upon. Usually the words are search individually on all the fields and the scored as per the proximity 2. mm would help you set how many query terms you need to match 3. phrase search is supported and would be searched together. 4. `-` is treated a negative operator and would result into the results being returned without the term.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "search, solr" }
Report Viewer using multiple reports Within vb.net we've got a report that works great it has it's header/footer details then then a table in the middle which repeats data and all of that is fine. But what the client wants now is for another button named 'Print Individual' and this will print the same report but instead of the repeated data within the table for each of those rows to be a single row on a page with the same header/footer. So for example on the first report if there is one page with 5 rows of details the 'Print Individual' report will print the same but have 5 pages and 1 row per report. If that makes sense :-) Obviously if I can do it where we use the same report instead of maintaing two reports would be good, as the report has a lot of information on it. Any ideas?
I ended up creating a new report and using the list box tool.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "vb.net, reportviewer, report viewer2010" }
What does ''formal" mean in "formal park" phrase? What does ''formal" mean in "formal park" phrase? Here is an excerpt: > Now to the Bicentennial Park itself. It has two areas, a nature reserve and a formal park with man-made features and gardens.
It talks about two distinct areas. One which is natural and the other that is manmade i.e. developed according to the plan. OALD has this definition. > formal \- _(of a garden, room or building) arranged in a regular manner, according to a clear, exact plan_
stackexchange-ell
{ "answer_score": 1, "question_score": 0, "tags": "meaning" }
Java - Get reference to a static class using reflection In Java, is it possible to access an instance of a static class (nested) using reflection? Supposing I have the following 2 classes defined in the package **Package1.SubPackage.SubSubPackage:** public class MyMainClass { public static class SalesObjectGrouper1 { public static final GrouperContext CONTEXT = new GrouperContext("MyDate"); } private static class SalesObjectGrouper2 { public static final GrouperContext CONTEXT = new GrouperContext("MyDate"); } } If I run the following code: try { xyz = Class.forName( "Package1.SubPackage.SubSubPackage.MyMainClass.SalesObjectGrouper1" ); } catch( ClassNotFoundException ex ) { // always hit the error } it will error indicating class cannot be found. Can this be done?
Have you tried referring to the nested class as MyMainClass$SalesObjectGrouper1 Nested classes are internally named ContainingClassName$NestedClassName
stackexchange-stackoverflow
{ "answer_score": 19, "question_score": 9, "tags": "java, reflection, class, static" }
Node serving session cookies instead of using maxAge I am using code from Stripe's rocket rides to serve cookies and remember users: const cookieParser = require('cookie-parser'); const session = require('cookie-session'); // ... const app = express(); // Enable sessions using encrypted cookies app.use(cookieParser(config.secret)); app.use( session({ // cookie expiration: 90 days cookie: {maxAge: 90 * 24 * 60 * 60 * 1000}, secret: config.secret, signed: true, resave: true, }) ); The problem is that the cookies served are session cookies (I inspected them with Chromium Developer Tools) and deleted when the browser window closes. I checked that the live server of Rocket Rides also serves session cookies. How can I enforce the `maxAge` for the cookie to persist for 90 days?
Here try this. app.use(cookieParser(config.secret)); app.use( session({ // Cookie Options maxAge: 90 * 24 * 60 * 60 * 1000, secret: config.secret, signed: true, resave: true, }) );
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "node.js, cookies" }
JSON.stringify(localStorage) - filtering by key I use a small code snipped to save the localStorage of my application as a string: `var saveStr = JSON.stringify(localStorage);` It works great at a first glance, but it basically dump the entire localStorage object, which I don't want. I'd like to stringify the localStorage, but only the keys that contains a certain string. For instance: `var saveStr = JSON.stringify(filteredLS("example"));` **filteredLS** should return the localStorage data, but only the keys that contains the string that was passed as an argument. Someone knows an easy snipped to achieve this? Thanks!
Try this function filteredLS(term) { var filteredObj = {}; Object.keys(localStorage) .filter(function (key) { return key.indexOf(term) >= 0; }) .map(function (key) { filteredObj[key] = localStorage.getItem(key); }); return JSON.stringify(filteredObj); }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "javascript, arrays, local storage, filtering" }
How to sort a table on basis of date of Birth when using angular js I want to sort my table on the basis of date of Birth. I am using angular js in my code but it is not working as it is sorting the date column as if date is a string. I am using below code for sorting- <th> <a href="#" ng-click="sortType = 'dob'; sortReverse = !sortReverse"> Date of birth <span ng-show="sortType == 'dob' && !sortReverse" class="glyphicon glyphicon-chevron-down"></span> <span ng-show="sortType == 'dob' && sortReverse" class="glyphicon glyphicon-chevron-up"></span> </a> </th> I have created a plunker here- < Can any one tell me how can I achieve that?
You should define the date of births as Date objects, and then use formatters to display the correct format in the view "dob": new Date(1980, 0, 12) See <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "angularjs, sorting, date, html table" }
How to change PDF format from A4 to Us Letter using html2pdf? I'm trying to change PDF format from A4 to US LETTER using html2pdf with PHP but I didn't get it. I tried to define width and height instead of A4 but it didn't work. Any solution, please? $html2pdf = new Html2Pdf('P', array($width_in_mm,$height_in_mm), 'fr', 'true', 'UTF-8', [0, 10, 0, 5]);
I have just found the answer. You need to use 'USLETTER' instead of 'A4'.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "php, html2pdf" }
How to move a div using CSS or javascript within parent container I am trying to use Bootstrap plugin which provides auto complete feature. While this plugin works well but at times when user is typing closer to border of the text box, the autocomplete div goes outside the textbox. See below image for more information. How can I using CSS or JavaScript ensure that the auto comeplete div never goes outside the textbox? ![enter image description here](
You can hook into the `show` event and check whether the popup is getting near the right border of the `textarea` (or whatever rule you wish to implement). If it is then change the dropdown's position so it displays on the left side of the caret: onshow: function (e) { var $dropdown = this.$dropdown.find('.dropdown-menu'); var textAreaWidth = this.$element.width(); var dropdownWidth = $dropdown.width(); var dropdownLeft = $dropdown.position().left; // display left of caret if menu gets near right textarea border if (dropdownLeft + dropdownWidth >= textAreaWidth) { $dropdown.css({left: dropdownLeft - dropdownWidth}); } } Full demo: <
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "javascript, jquery, css, css transforms" }
How fdupes can preserve second file Can I preserve second files in list, when works with fdupes? > fpupes -N -r . Preserve first files in list, but I need save the SECOND files. I have about 2000 duplicates and type for each 2 in prompt > fdupes -d -r . Is to hard..
You cannot do this with fdupes. But you can use fdupes to find the dupes and remove the first one yourself like this: fdupes -rn .|awk 'BEGIN{first=1} (first){print;first=0} /^$/{first=1}' This will print out all the first files found by fdupes, which you then can delete with: command | while read file do rm "$file" done Not tested, watch out!
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "linux, console, fdupes" }
Subtracting rows based on condition Suppose I have a table that looks like this: OrderNumber OrderType 1 D 1 D 1 R 2 D 2 R 3 D 3 D 3 D 3 R 3 R The result should be: OrderNumber OrderType 1 D 3 D Here, an R would indicate to remove one row from the order. We see in the first example we have 2 D's and 1 R, so we remove one D are replaced with 1 D. Is there a way to do this in SQL?
If your mysql version support cte and window function, we can try to use `ROW_NUMBER` window function make row number for each `OrderNumber` `OrderType` Then use `EXISTS` subquery to judge `OrderType = D` row number needs to be greater than the maximum row number from `R`. with cte as ( SELECT *, ROW_NUMBER() OVER(PARTITION BY OrderNumber,OrderType) rn, COUNT(*) OVER(PARTITION BY OrderNumber,OrderType) cnt FROM T ) SELECT c1.OrderNumber, c1.OrderType FROM cte c1 WHERE EXISTS ( SELECT 1 FROM cte c2 WHERE c1.OrderNumber = c2.OrderNumber AND c2.OrderType = 'R' AND c1.rn > c2.cnt ) AND c1.OrderType = 'D' sqlfiddle
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "mysql, sql" }
Javascript Deep thinking: Recursive setTimeOut function with a clearTimeout call on a button pressed? I have a quick question about using recursive `setTimeOut` recursively and a `clearTimeOut` that get called somewhere else. On rare cases, will there ever gonna be a bug where `clearTimeOut` doesn't actually stop the loop? Is it possible that the `timeOutID` get changes into a new value and `clearTimeout` is called on the old value? Here is the code: timeOutID = 0; function timeOutRecusive() { timeOutID = setTimeout('timeOutRecusive();', 1000); } function killTimeOutRecusive() { clearTimeout(timeOutID); } //when page started. start() { timeOutRecusive(); } //When a button is press, calls killTimeOutRecursive(); EDIT: I have some typo in my code. It should be 'timeOutID' instead of clockID. clearTimeOut should be 'clearTimeout' (using its built-in)
This approach is pretty bullet-proof, and a standard practice. > Is it possible that the `timeoutId` get changes into a new value and `clearTimeout` is called on the old value? No, this is not possible. JS code doesn't run in parallel, there are no data races from multithreading. The only edge case where `killTimeoutRecursive` does not work as expected is when it is called from within `timeoutRecursive`, after the old timeout occurred and before the new one was created: var timeoutId = 0; function timeoutRecusive() { callback(); timeoutId = setTimeout(timeOutRecusive, 1000); } function killTimeoutRecusive() { clearTimeout(timeoutId); } function callback() { // this might be user-provided killTimeoutRecursive(); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript" }
DataSource.Table.Where(stringOfConstraint) does not exist in LinqToSQL for OData support? I'm looking at this Telerik demo, and am unable to get the "count" statement to work. I believe that the following command is only supported on EntityFramework, and not Linq2SQL. return CurrentDataSource.Products.Where(where).Count(); The parameter "where" in lowercase is actually a string that is passed in the ADO.Net DataServices (OData) url. This URL _should_ be sent to the Linq provider to further constrain the query. If that is not supported in Linq2SQL, how can I make a similar statement?
You need to use a lambda expression for the predicate used by the `Queryable.Where` method: return CurrentDataSource.Products.Where(p => p.Id > 100).Count(); If you really want to use a string then take a look at Dynamic LINQ, starting with Scott Gu's blog post: Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library). Then you should be able to write queries similar to: return CurrentDataSource.Products.Where("Id > 100").Count();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "linq to sql, entity framework, linq to entities, odata, wcf data services" }
LESS selector for descendant or self Given two selectors e.g. "Div.aClass" and ".sub" is there a shorthand in LESS that would mean: Div.aClass .sub, Div.aClass.sub i.e. any element that has a `sub` class but is also either a `Div` with `aClass` or a child of such a div ? I suppose I can use: Div.aClass { &.sub, & .sub { } } but a shorter syntax would be nice.
You really do not have much shorter of a syntax available. The most you can eliminate is one `&`: Div.aClass { &.sub, .sub { prop: test; } }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "less" }
How to delete only one row from non unique set of rows in Postgres? I have this table create table order_details( id_of_product integer, id_of_person text ) both fields are not unique. How to delete one row from the table with specified **id_of_product** and **id_of_person** for example i need to delete one row with id of 6 P.S person is the same for this set of rows !sample data
You can use system column ctid to specify particular row, even if it has no unique values. WITH u AS ( SELECT distinct on (id_of_product, id_of_person) id_of_product, id_of_person, ctid FROM order_details ) DELETE FROM order_details WHERE id_of_product=6 AND id_of_person='ey...' AND ctid IN (SELECT ctid FROM u)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "postgresql, duplicates, sql delete" }
RSpec: how to test if a method was called? When writing RSpec tests, I find myself writing a lot of code that looks like this in order to ensure that a method was called during the execution of a test (for the sake of argument, let's just say I can't really interrogate the state of the object after the call because the operation the method performs is not easy to see the effect of). describe "#foo" it "should call 'bar' with appropriate arguments" do called_bar = false subject.stub(:bar).with("an argument I want") { called_bar = true } subject.foo expect(called_bar).to be_true end end What I want to know is: Is there a nicer syntax available than this? Am I missing some funky RSpec awesomeness that would reduce the above code down to a few lines? `should_receive` sounds like it should do this but reading further it sounds like that's not exactly what it does.
it "should call 'bar' with appropriate arguments" do expect(subject).to receive(:bar).with("an argument I want") subject.foo end
stackexchange-stackoverflow
{ "answer_score": 178, "question_score": 140, "tags": "ruby on rails, ruby, rspec" }
C - Trying to determine number of elements in buffer filled by getline() I have seen a lot of places saying that `sizeof(buf)/sizeof(buf[0])` should work in determining the size of the array, but this does not work for me char* buf = NULL; size_t len; len = 0; while(getline(&buf,&len,stdin) >= 0 ){ unsigned int i; size_t size= sizeof(buf)/sizeof(buf[0]); for (i = 0; i < size; i++){ char* s; int pos; s = strtok(buf, " "); unsigned int j; for (j = 0; j < strlen(s); j++){ doStuff(); } I want to deterine how many Strings are in `buf` so that I know how many times `strtok()` needs to be called in order to do something with each letter of the word.
`getline()` returns the **number of characters read**. Use the return if you need the number of characters read. If you need the number of tokens parsed by `strtok`, keep an `index` and increment it. len = 0; ssize_t n = 0; /* number of chars read by getline */ size_t index = 0; /* number of tokens parsed by strtok */ while ((n = getline (&buf, &len, stdin)) >= 0 ) { ... char *s = buf; for (s = strtok (s, " "); s; s = strtok (NULL, " ")) { index++; ... } ... for (j = 0; j < index; j++){ doStuff(); } **Note:** `buf` is _not_ preserved by `strtok` (it will have `null-terminating` characters embedded in it by `strtok`). If you need `buf` later, make a copy before calling `strtok`.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "c, getline, strtok" }
Linking Trello cards to code commits How can I integrate a card in Trello to one or more commits in a repository, beyond simply pasting a URL? I'm specifically interested in integration with bitbucket.org and github.com. For example, can I configure a board to know about my repository and when I type something that looks like a hash of a commit, Trello will try to turn it into a hyperlink.
This feature is new but only available for **Trello Business Class** Integrate Trello with GitHub
stackexchange-webapps
{ "answer_score": 1, "question_score": 3, "tags": "trello" }
Prosody, how to get the IP address of connected clients? I'm running Prosody server on ubuntu. I was wondering if there's a possible way to get the IP address of each client who connects to my server, basically, I want 2 things: 1) I want to get the IP address of the user who uses a JID of my server. 2) I want to get the IP address of the user who enters a conference on my server. Now there's a module that works kinda similar like what I need, but to get the IP, I have to use **prosodyctl** which doesn't help what I'm trying to do. So, is there a possible way to save their IPs in a file maybe? or any other way to get it rather than using **prosodyctl**? Thank you.
You need to enable `mod_log_auth` < Then you need to add the following on your config file: `log_auth_ips = "all"` This will log the IP of all incoming connections (failed or not).
stackexchange-serverfault
{ "answer_score": 1, "question_score": 2, "tags": "ubuntu, ip, xmpp" }
Get data in the POST request body Play Framework Play 2.4.x. How can we get the data that is send through the body of POST request as key value pairs? I'm sending a post request from the postman plugin, created a key value parit in the body. How could I get this value from the action function. I tried with request.body() but it could not get the value alone from it.. Is there any way I cloud get the value that is send in the body of post request
Try DynamicForm in play's action method. play.data.DynamicForm data = play.data.Form.form().bindFromRequest(); String username = data.get("username"); String password = data.get("password"); **Update:** From Play 2.5 on wards, inject `play.data.FormFactory` on your controller it allows you to access form. Reference @Inject play.data.FormFactory formFactory; play.data.DynamicForm data = formFactory.form().bindFromRequest();
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 2, "tags": "playframework, http post, body parser" }
MySQL PHP for SELECT AVG(column) returns Resource ID 3 I want to get the average value of my ratings column for my review table. This is what has been done so far $averagereviewquery = "SELECT AVG(review_rating) from reviews where product_id=".$primarykey; $averagereviewresult=mysql_query($averagereviewquery); if($insert_review){ //successful insert echo $averagereviewresult; } what happens is averagereviewresult returns "Resource Id 3". What do i do to change it to show me the average value?
mysql_query does return a resource. You need to expicitly read the value from your query in order to get the result. One way is to use mysql_result: echo mysql_result($averagereviewresult, 0);
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "php, mysql, html" }
Bootstrap 4 scss files I'm trying to install Bootstrap 4 with Yarn within a Symfony 4 project. On the Bootstrap page it states in the "Whats included" section which files will come, and those are only `.css` files. When I add the library with yarn, there are no `.scss` files in the directory. How can I get the SCSS version of Bootstrap 4? Thanks in advance!
You must install the bootstrap packet `yarn add bootstrap`. The folder named bootstrap will appear in the folder `/node_modules/` which will contain `scss` folder. For work with scss sources, you need a scss to css compiler and a bundler ![enter image description here](
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "bootstrap 4" }
Making sure I understand the power of Lagrange's Theorem Does Lagrange's Theorem lead to the result that if |G| = 20, for example, then I can expect to find subgroups of orders 1, 2, 4, 5, 10 **only** or just that those are some expected subgroup orders?
If $|G| = 20 $, it means that if $H$ is a subgroup of $G$ then it is necessary that $|H| \mid |G|$. However, note that Lagrange's theorem doesn't at all guarantee the existence of subgroups with orders that are divisors of 20. That is, Lagrange's theorem doesn't guarantee the existence of a single non-trivial subgroup. Therefore Lagrange's theorem doesn't assure us of the existence of subgroups with orders 2,4,5 and 10. But it does guarantee that if we happen to find any subgroup of $G$, then it will necessarily be a divisor of 20. Remember to not confuse Lagrange's theorem with its possible converse, which is false.
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "group theory" }
Parsing a JSON list into a normal string in Python? I have a JSON list which has this data: [ "B6y2z5jqUeFXJAre8ugXkHeYX87SU3hi6E", "B9bUMF8VLbj8r2b8uEQ7TY4R6TRDCjjhMV", "BJauzhHkcLKLdFsMuqLh6QrFGCTJjC7RQz", "BLcwoAVZNSLXLBMqQ7PQqEDFhN4owFLJo2", "BMaqYvfgrcZf6Wx1P3P8oBQzwjEHqGAEgy", "BMsXoM73RoxjwCVqbySNPcrVCKQqbLFn12", "BR5ptgmfcYceqka6JLxqkr21ce8J5T6Cvv" ] I want to take the first thing in the list (`"B6y2z5jqUeFXJAre8ugXkHeYX87SU3hi6E"`) and turn it into a normal Python string. How can I do this?
It is already a string. You can do: # IF: json_data = [ "B6y2z5jqUeFXJAre8ugXkHeYX87SU3hi6E", "B9bUMF8VLbj8r2b8uEQ7TY4R6TRDCjjhMV", "BJauzhHkcLKLdFsMuqLh6QrFGCTJjC7RQz", "BLcwoAVZNSLXLBMqQ7PQqEDFhN4owFLJo2", "BMaqYvfgrcZf6Wx1P3P8oBQzwjEHqGAEgy", "BMsXoM73RoxjwCVqbySNPcrVCKQqbLFn12", "BR5ptgmfcYceqka6JLxqkr21ce8J5T6Cvv" ] element_one = json_data[0] element_two = json_data[1] The list is a list of strings, and they can be accessed with that.
stackexchange-stackoverflow
{ "answer_score": -1, "question_score": -1, "tags": "python, json, parsing" }
Field extension of prime degree **Question:** Let $L$ be the extension of the field $K$ such that $[L:K]=p$, where $p$ is a prime number, and $\alpha \in L$. Prove that $K(\alpha)=K$ or $K(\alpha)=L.$ **Proof:** From $$ \alpha \in L \implies K \subseteq K(\alpha) \subseteq L, $$ we have $$ p=[L:K]=[L:K(\alpha)]\cdot [K(\alpha):K] $$ from which we have two cases, one being that $[L:K(\alpha)]=1$ and $[K(\alpha):K]=p$, or vice-versa. In each of the cases I then conclude either $K(\alpha)=K$ or $K(\alpha)=L.$ However, I am unsure if it is enough to state that i.e. $[L:K(\alpha)]=1$ implies that $L=K(\alpha)$. Is it?
To see it fully, formally and explicitly, recall the definition of $[E:F]$ for any field extension $E$ over $F$: it is the _dimension_ of $E$ as a vector space over $F$: $[E:F] = \dim_F E. \tag{1}$ If $[E:F]$ = 1, then there is a basis for $E$ as a vector space consisting of _precisely one_ element $e \in E$; then any element of $E$ may be written $\lambda e$ for some $\lambda \in F$; in particular the elements of $F$ may be so written; thus for each $\mu \in F$ there is $\lambda \in F$ with $\mu = \lambda e, \tag{2}$ or $e = \lambda^{-1} \mu \in F; \tag{3}$ since the basis element $e \in F$, we have $E = \\{ \alpha e \mid \alpha \in F \\} = eF \subset F; \tag{4}$ but $F \subset E$ is given; hence $E = F$. The present case is thus resolved by taking $L = E$, $K(\alpha) = F$; we conclude $L = K(\alpha)$.
stackexchange-math
{ "answer_score": 4, "question_score": 6, "tags": "abstract algebra, field theory, extension field" }
Implicit differentiation applied to $ z=\frac{1}{y}(f(ax+y)+g(ax-y)). $ I'm trying show that $$\frac{\partial^2z}{\partial x^2}=\frac{a^2}{y^2}\frac{\partial}{\partial y}( y^2\frac{\partial z}{\partial y})$$knowing that: $$ z=\frac{1}{y}(f(ax+y)+g(ax-y)). $$ I know that, to do this, I need to use partial differentiation, but I just have no idea where to start. Is there any way I can simplify $f(ax+y)$ and $g(ax-y)$?
This is just differentiating. Since $z=\frac1y[f(ax+y)+g(ax-y)]$, we clearly have $$ \frac{\partial^2 z}{\partial x^2}=\frac1y[a^2f''(ax+y)+a^2g''(ax-y)] $$ on the LHS. For the RHS, we start by differentiating $z$ with respect to $y$: $$ \frac{\partial z}{\partial y}=-\frac1{y^2}[f(ax+y)+g(ax-y)]+\frac1y[f'(ax+y)-g'(ax-y)] $$ So $$ y^2\frac{\partial z}{\partial y}=-[f(ax+y)+g(ax-y)]+y[f'(ax+y)-g'(ax-y)] $$ Differentiate with respect to $y$ again, \begin{align*} \frac{\partial}{\partial y}\left(y^2\frac{\partial z}{\partial y}\right)&=-[f'(ax+y)-g'(ax-y)]\\\ &\quad+[f'(ax+y)-g'(ax-y)]+y[f''(ax+y)+g''(ax-y)]\\\ &=y[f''(ax+y)+g''(ax-y)] \end{align*} Hence the RHS is $$ \frac{a^2}{y^2}y[f''(ax+y)+g''(ax-y)]=\frac{a^2}{y}[f''(ax+y)+g''(ax-y)] $$ So indeed $LHS=RHS$.
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "calculus, multivariable calculus, derivatives, partial derivative, implicit differentiation" }
What does one call a group of similar courses where only one can be taken for credit? Is there a word to describe the case when a student can only receive credit for one of a group of courses because they are versions of a single course? For example, "Accelerated Elementary Statistics" and "Elementary Statistics" - these have different course numbers but I would only want a student to be able to take one of these courses for credit. Context: I'm designing course scheduling software and want to be able to describe/refer to this situation concisely to inform students and communicate with administrators who are designing course catalogues and requirements.
A couple of universities that I've worked and/or studied that described the courses as having _equivalent content_. So, the prerequisites for an upper-level course might be listed as "MATH 344 or equivalent content." The reverse descriptor also came up sometimes. For example, the degree requirements for a given major might include: "Four additional courses at the 500 level, of _essentially different content_." Another school used _inequivalent content_ for the same thing.
stackexchange-academia
{ "answer_score": 24, "question_score": 24, "tags": "terminology, course design" }
How to get all cities with their population laravel $users = ApplicationPersonal::select(ApplicationPersonal::raw('count(*) as district')) ->groupBy('district') ->get(); I need help in such query in laravel. I want my data to be displayed as : > City1 : 10 ppl > > City2 : 20 ppl > > City3 : 30 ppl every city with its name and population. My db has a city field associated for every user. I want to count how many user inside each city. So my data return to ajax would be Cities and population for each city.
DB::table('tablename')->select('district', DB::raw('count(*) as total')) ->groupBy('district')->get(); This was the solution for my problem. Cheers!
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -3, "tags": "javascript, laravel" }
Error in sculpting, maybe corrupt file Recently I was attempting to sculpt from a tutorial on youtube and I encountered and error where the brush stopped working consistently and I got a line following the cursor instead. I'm curious if there is anything I can do rather than starting a new file. The problem does not seem to be attached to the object and it only occurs with the SculptDraw brush. ![enter image description here](
Na, it's fine... you just accidentally got your smooth stroke enabled. Disable it and you will be fine. ![enter image description here](
stackexchange-blender
{ "answer_score": 1, "question_score": 0, "tags": "sculpting, error" }
What is the term for making a cross in the air (like when passing a cemetery)? Is there a word for making a cross with your hands in the air? It's a four point motion that goes from head to chest, then shoulder to shoulder. An example situation where someone does this might be a funeral procession passing by.
The verb is cross and you "cross yourself." I hope that makes it clear. > cross > v.tr. > 6\. To make the sign of the cross upon or over as a sign of devotion.
stackexchange-english
{ "answer_score": 5, "question_score": 1, "tags": "single word requests" }
java not found after install but java programs run I updated my java to JDK 7 today and after installing I can run java programs and eclipse runs fine but < says no working java detected. Also Minecraft won't log in and tekkit cant load anything from the internet. I have tried adding java to the PATH variable to no avail. What am i missing?
Ok, java is not detected on my machine by this jsp as well. I believe this happens because JSP cannot _really_ detect java _installed_ on your machine. It can only detect version of Java plugin installed on your current browser. So, you have to install java plugin (if you need it).
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "java, java 7" }
How to immediately remove from memory a value that has just been removed from arraylist I am creating a java program, in which some data is added to an arraylist. Some of the processing is within a loop, and I am adding a new node to the list within the loop, performing operations using that node, and then deleting that node using arraylist.remove() just before end of an iteration of the loop. I am also running System.gc(); just before end of a loop iteration. However when I took a memory dump, I found that the arraylist still held all values that I had used in different loop iterations... How do I erase all of those values from memory? And I want to do this just before the end of an iteration of loop, so that the arraylist never grows in size?
Java have garbage collector for a reason, and that reason is to programmer don't have to think about removing object from memory. Only thing you can do (I don't recommend it) is to force start garbage collector by `System.gc()` method. But remember to do it twice because 1st time it will only prepare object to be removed by invoking it `finalize()` method.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, arraylist" }
how to passing multiple value from toast to multiple TextView? I would like to know, how to pass multiple value from Toast to multiple TextView. I have two classes, MainActivity and LoginActivity. The Toast originally show in MainActivity class, but I would like to show the value from toast to the TextView in LoginActivity class. here are the part of my code in MainActivity : double latitude = gps.getLatitude(); double longitude = gps.getLongitude(); // show Toast Toast.makeText(getApplicationContext(),"Lokasi latitude: " + latitude + " Longitude : " + longitude, Toast.LENGTH_LONG).show(); Intent i = new Intent(getApplicationContext(),LoginActivity.class); startActivity(i);
In your mainactivity class: Intent i = new Intent(getApplicationContext(),LoginActivity.class); i.putExtra("val1",latitude); i.putExtra("val2",longitude); startActivity(i); in your loginactivity class Bundle extras = getIntent().getExtras(); int value1 = extras.getInt("val1"); int value2 = extras.getInt("val2"); then show this value in text view: textview1.setText(String.valueOf(value1)); textview2.setText(String.valueOf(value2));
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -2, "tags": "java, android, textview, toast" }
Run a SQL query on a DB2 file with a dot "." in the name? I have a DB2 file with a name like "my.test". The DB2 filename contains a dot `'.'` If I try and run the following query via strsql: select * from my.test I receive the following error: Token . was not valid. Valid tokens: FOR USE SKIP WAIT WITH FETCH ORDER UNION EXCEPT OPTIMIZE. Is there a way around this? I tried surrounding it in quotes but that doesn't help.
Double quotes are the correct way to escape the file name. **The file name becomes case sensitive within quotes and must be specified in upper case**. SELECT * FROM "MY.TEST" * * * Note that in the IFS naming convention the "." operator is used to reference members within a file but it doesn't work with SQL. If you need to access a file named "MY" with a member named "TEST" you would need to create an alias to query against. CREATE ALIAS QTEMP/MYTEST FOR MY (TEST) SELECT * FROM QTEMP/MYTEST
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 5, "tags": "db2, ibm midrange" }
Check QGIS processing Saga version from a plugin I am writing a QGIS plugin using SAGA by Processing. Is is possible to test whether SAGA is installed and which version is on? For GDAL, it's OK with: processing.tools.raster.gdal.__version__
You might to want to look at some of the python code for SAGA algorithm providers, especially the module **SagaUtils.py** \- that has a `getSagaInstalledVersion()` function, and a few functions for building the paths etc. This is an example from the Python Console:- >>> processing.algs.saga.SagaUtils.getSagaInstalledVersion() '2.2.0' Looking at the code, it's a wrapper around an external call to `saga_cmd -v` with retry logic
stackexchange-gis
{ "answer_score": 5, "question_score": 3, "tags": "qgis, qgis plugins, saga" }
passing a column out of a matrix to a function in c I want to pass a particular column of the matrix that I have in my program to a function. If I use the call `<function_name>(<matrix_name>[][<index>]);` as the call then I get the error > error: expected expression before ‘]’ token So please help me in finding the suitable way Thanks
The syntax you used doesn't exist. Matrices are stored in memory by row (or better, by the second dimension, to which you give the semantics of rows), so you cannot natively. You could copy all your column elements in a vector (a single dimension array) and pass it. If you need to work only by column (and never by row) you could change the semantics you give to the first and to the second dimension: think of your matrix as `matrix[row][column]` instead of `matrix[column][row]`. Otherwise, if you need to do this often, look for a better data structure, instead of a simple array.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "c" }
What does the "Unloaded" prefix mean in a Windows stack trace? I've the hellish problem of a third party DLL appearing to cause a recursive stack overflow crash when it gets unloaded. I wind up with this pattern on the stack (using windbg): <Unloaded_ThirdParty.dll>+0xdd01 ntdll!ExecuteHandler2+0x26 ntdll!ExecuteHandler+0x24 ntdll!KiUserExceptionDispatcher+0xf <Unloaded_ThirdParty.dll>+0xdd01 ntdll!ExecuteHandler2+0x26 ntdll!ExecuteHandler+0x24 ntdll!KiUserExceptionDispatcher+0xf ... As you would guess, I don't have the source code to ThirdParty.dll. Q: What does the prefix "Unloaded_" mean in the stack dump. I haven't run across this before.
This means that `ThirdParty.dll` was no longer being referenced and has already been removed from memory at the time that the crash occurs. To find out the actual stack trace, you need to reload the .dll at its original place in memory with the following command: .reload /f ThirdParty.dll=0xaaaaaaaa Of course you need to replace `0xaaaaaaaa` with the original base address of the module. This may be somewhat hard to figure out if the module has already been unloaded, but if you have an `HMODULE` lying around that refers to the dll, the value of that `HMODULE` is the base address. Worst case, you can add a debugger trace statement to your code that logs the `HMODULE` of the dll just before you unload it.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "windows" }
Does spell resistance from Oath of Ancients protect against dragon breath attacks? I'm trying to find some clarification on something that seems a little vague to me: I'm going to be turning level 7 soon as a Paladin, and my oath gives me resistance against spell damage. I'm not sure if breath attacks count as spells, since there is nothing to clarify either way IMO. The save DC for a dragonborn PC is calculated exactly the same way as a spell would, they deal the same types of damage as spells, and the DMG says dragons are innately magical, so does dragon breath count as spell damage for the purpose of Oath of Ancients spell damage resistance?
A breath weapon is not a spell. From the Dragonborn entry: > Breath Weapon: You can use your action to exhale destructive energy. Your draconic ancestry determines the size, shape, and damage type of the exhalation. Spells require some combination of Verbal, Somatic, and Material components. A breath weapon requires... exhalation... The introduction to spellcasting says: > Spell Level > > **Every spell has a level** from 0 to 9. A breath weapon doesn't have a level. Therefore, it is not a spell.
stackexchange-rpg
{ "answer_score": 15, "question_score": 6, "tags": "dnd 5e, paladin, dragons, damage resistance" }
About shaping 2d dataframe to 3d by index I would like to ask is there any function in pandas can reshape dataframe from 2d to 3d by it's index. col1 col2 col3 id 1 1 2 3 1 4 5 6 1 7 8 9 For example, I have 3 rows with the same id(+1 id row) each one has 3 cols, drop the id and the dataframe is 1x3 (for each row), I want to make it (3x1x3)(by the same id). I tried groupby concat and join, but didn't work. Thanks
You could use the underlying numpy array: r, c = df.shape df.values.reshape(r, 1, c) output: array([[[1, 2, 3]], [[4, 5, 6]], [[7, 8, 9]]]) NB. if you want the other dimension: `df.values.T.reshape(c, 1, r)`
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python, pandas" }
updating a table in VFP There are two tables in my database. I am trying to update a column in table2 by setting it equal to one of the columns in table1. I've already looked at this answer visual foxpro - need to update table from another table And tried to do this on my code, however, I kept having a syntax error on UPDATE table2. Why? Here is what I have. ALTER TABLE table2; ADD COLUMN base2 B(8,2); UPDATE table2 WHERE table2.itemid=table1.itemid from table1; SET table2.base2=table1.base;
Using 'standard' VFP language syntax and RELATED Tables, you could quite easily do the following: USE Table1 IN 0 EXCLUSIVE SELECT Table1 INDEX ON ID TAG ID && Create Index on ID field USE Table2 IN 0 SELECT Table2 SET RELATION TO ID INTO Table1 REPLACE ALL Table2.ID WITH Table1.ID FOR !EMPTY(Table2.ID) You might want to spend some time looking over the free, on-line tutorial videos at: Learn Visual Foxpro @ garfieldhudson.com The videos named: * Building a Simple Application - Pt. 5 and * Q&A: Using Related Tables In A Report Both discuss using VFP's language to work with Related Tables Good Luck
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "visual foxpro, foxpro" }
Triggering a Visual Studio build from a Linux Host I am starting work on a very Windows-specific project, but I am much more familiar with a Linux development environment (ie, emacs and zsh). All I need to do with my Windows code is compile it - I have a network share on which I can edit the code, and I can deal with viewing the logs remotely with tail. Is there any way I can trigger a build on a Windows server remotely? On Linux this is trivial - simply remotely execute your build script via SSH, or use Jenkins or some other CI to trigger the build through a web interface. I'm really wondering whether there is some sort of functionality I am missing with Windows that would allow me to run "MsBuild.exe" or "cl.exe" from a separate Linux host.
I'd say you probably want to run a SSH server on windows. This question has a few options, you should then be able to invoke msbuild from the command line.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "linux, windows, msbuild" }
how to start learning JavaScript I am experienced in the technical support like Linux, oracle, sunos etc and but if i say scripting i know little bit of bash. Now i promoted to manage technical engineers including some JavaScript developers, so i want to learn JavaScripting so that i can understand engineers. Hope you understand. Can you please advise me how can i start JavaScripting and point me to some simple docs and examples.
Look at A Beginner's Guide to JavaScript, it includes tips and examples and Javascript Tutorials for Beginner's
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "javascript" }
Get shown component in JScrollPane I have a JScrollPane containing a JPanel. I fill this JPanel with many buttons. Is there any possibility to get the currently shown buttons? I know I can access the children of a JPanel via `jpanel.getComponents()` but those are all components in this pane; I want only the ones that are currently on screen.
I assume that this container is already visible on the screen, then I suggest 1) to extract JViewPort from JScrollPane, 2) addChangeListener to `JViewPort` 3) each visible `JComponent(s)` returns Rectangle 4) and Rectangle#intersects returns `Boolean` value if is `JComponent(s)` visible or not in `JViewPort`
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "java, swing, jpanel, jscrollpane, scrollpane" }
cvs2svn changes binary files I'm using cvs2svn to migrate from CVS to SVN. I've noticed a problem with my binary file after the conversion was completed. I'm using auto-props file, which is very helpful. After the conversion I took the file from CVS and compared it to the same file from SVN. The file is binary. Using WinMerge, I see that there is a difference between the files. What can be the problem?
Are you using cvsnt? If you do, cvs2svn doesn't understand that your file is binary, because cvs and cvsnt flag binary files differently. It is simple enough to write a program that converts this. I had to do that. Now, if you have a binary file that isn't marked as binary in cvs, or it is marked using the cvsnt syntax, and the file contains patterns like "$Id" or "$Date", then Subversion will substitute those patterns when you check out the files. Usually that means your binary file will get corrupted. How to convert: If the file contains "kopt b;" assume it is binary, although technically a file may be binary in some revisions and not in others. For all binary files, insert "expand @b@;" before "symbols" near the top of the file, so the header looks something like this: head 1.1; access; expand @b@; symbols When you do this, be careful not to change anything in the rest of the file, e.g. line endings.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "binary, mime types, cvs2svn" }
Possible orders of special element in a group > Let $G$ be a group. Let $x$ be an element of order $3$ and $y(\neq e)$ be an element of $G$ such that $xyx^{−1} = y^3$. Then what are the all possible order of the element $y$? **My attempt:** Since the order of the element $y$ and $y^3$ are same then if order $y$ is finite, then $\gcd (3,n)=1$, i.e $3 \nmid n$. Now consider $H = \left<x\right>$ and $K = \left<y\right>$ then $H,K$ are subgroups of $G$ suppose if $HK$ is a subgroup. If $3\mid (n-1)$ then we can find a group that has order $3n$ and that is non-Abelian. So $n=3k+1$.
_Hint:_ We have $x^nyx^{-n}=y^{3^n}$ for all $n\ge 1$. For $n=3$ we have $x^3=e$, so that $y=y^{27}$, i.e., $y^{26}=e$. Now the possible orders are included in the set $\\{2,13,26\\}$. Note that $y\neq e$.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "abstract algebra" }
How do I recycle old MacBook Pro batteries? Can I return an old 15-inch MBP rechargeable battery to Apple, or does it have to be disposed of locally?
The disposal and/or recycling of batteries will differ depending on your local jurisdiction, namely because of local laws. In some jurisdictions you can take your old electronic equipment, including batteries, to any Apple Retail Store. The local store will ensure that it will be recycled in a responsible manner. Based on your profile, I see you're based in Germany. Germany is one of those places where Apple will happily take your batteries. For more info, see So einfach wie Apple Produkte sollte auch ihr Recycling sein1. * * * 1 The UK english version of the above referenced page is: Recycling an Apple product is as easy as it is good for the planet.
stackexchange-apple
{ "answer_score": 1, "question_score": 2, "tags": "battery" }
Centralizer of a reductive subgroup Let $G$ be a reductive group over $\mathbb{C}$ and $H\subseteq G$ a reductive subgroup. Let $\rho$ be a faithful irreducible finite dimensional representation of $G$ over $\mathbb{C}$. Assume that $\rho|_H$ is reducible. Then is it always the case that the centralizer $Z_G(H)$ is strictly larger than the center $Z(G)$?
$\DeclareMathOperator\GL{GL}$No. Take $H=\GL_2$ embedded diagonally into $G=\GL_2\times \GL_2$ and take $\rho$ equal to $\mathbb C^2 \otimes (\mathbb C^2)^*$ with the natural action of $\GL_2$ on $\mathbb C^2$.
stackexchange-mathoverflow_net_7z
{ "answer_score": 1, "question_score": 0, "tags": "rt.representation theory, lie groups, algebraic groups, reductive groups" }
Prove/disprove $||A^2|| \leq ||A||^2$ for a nxn matrix The question is: Prove/disprove $||A^2|| \leq ||A||^2$ where A is some nxn matrix. I've played around with a while few matrices and I'm pretty sure that this is correct but I can't quite figure out how to prove it. My first guess is just define some arbitrary matrix A, and show that for any vector $x$ of size 1, $||A^2 x|| \leq ||Ax||^2$ however this method seems rather involved. Any tips would be great! :) Edit: $||A||= \max ||Ax||$, where $|x| = 1$ Edit: Wow this was rather fast. Thanks everyone.
Recall that by the definition of $\|A\|$ we have $$\|Ay\| \leq \|A\|\|y\|.$$ For any $x \in \mathbb{R}^n$, using this inequality twice (on $y = Ax$ and on $y = x$), we have $$\|A^2x\| = \|A(Ax)\| \leq \|A\| \|Ax\| \leq \|A\| \left( \|A\| \|x\| \right) = \|A\|^2 \|x\|.$$ Therefore $$\|A^2\| = \sup_{x \neq 0}\dfrac{\|A^2x\|}{\|x\|} \leq \|A\|^2.$$ Note that what the matrix norm is does not matter in the proof, as long as the norm is an induced norm.
stackexchange-math
{ "answer_score": 5, "question_score": 1, "tags": "linear algebra" }
JSP global variable I have this code <%! public String class_name = ""; %> <c:choose> <c:when test="${WCParam.categoryId != null}"> <% class_name = "my_account_custom"; %> </c:when> <c:otherwise> <% class_name = "my_account_custom_3"; %> </c:otherwise> </c:choose> <p>Class name = <c:out value='${class_name}' /></p> WCParam.categoryId is null or not But my class_name variable is always empty. What i am doing wrong Thanks
Scriptlets (`<%...%>`) and expression language (`${...}`) are completely different things, therefore their variables belong to different scopes (variables used in EL expressions are actually request attributes of different scopes). If you decalred `class_name` as a scriptlet variable, you should access it using scriptlet as well: <p>Class name = <c:out value='<%=class_name%>' /></p> However, you can write it without using a variable at all: <p>Class name = <c:out value='${WCParam.categoryId != null ? "my_account_custom" : "my_account_custom3"}' /></p>
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 5, "tags": "java, jsp, global variables" }
Posting a link as Submit Button <form method="POST" action="auth/signin"> Username: <input name="username" type="text" value=""/> Password: <input name="password" type="password" value=""/> <a href="auth/signin">Log In</a> </form> How do I post the parameters when the "Log In" link is clicked (instead of using the submit button)?
I think you need Javascript, something like this: <a href="javascript:document.yourform.submit();">Log In</a>
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "html, form submit" }
Accessing Steam Guard File I am trying to use a Python package from GitHub with which I can access many information on steam: . However, in order to log in, I would need to provide use the path to my "Steam Guard File". Or get this information: { "steamid": "YOUR_STEAM_ID_64", "shared_secret": "YOUR_SHARED_SECRET", "identity_secret": "YOUR_IDENTITY_SECRET" } In order to access the information, I need to login using: steam_client = SteamClient('MY_API_KEY') steam_client.login('MY_USERNAME', 'MY_PASSWORD', 'PATH_TO_STEAMGUARD_FILE') There was another site Github page recommended to access this information, but it was mainly for mobile Steam Guard and I use my email address. Can anyone help me to access the path to this Steam Guard file or the information it contains? Many thanks in advance!
You can find your Steam Guard File in your Program Files (x86) / Steam Folder: ![enter image description here]( Please remember to not give anyone access to this file, as it could compromise your Account. (The hidden file seems to be a honeypot, so you shouldn't need it)
stackexchange-gaming
{ "answer_score": 1, "question_score": 3, "tags": "steam" }
Deleting an account(website) from Google Analytics? Where exactly is the option to remove an account in Google Analytics? I have checked several of the settings tabs and I am still unable to locate the delete option.
1. Go to ` 2. Click the profile that you want to edit 3. Click `Admin` on the right hand side of the screen !enter image description here 1. Click the name of the profile from the `profiles` tab 2. Click the `profile settings` tab !enter image description here 1. On the bottom right of the screen click the `Delete this profile` link and go through the confirmation steps !enter image description here **Note** that this will permanently delete that profile and all data associated with it. If this profile is used by others and you just want to remove it from your list of profiles than you should ask another Administrator to remove you from the list of users.
stackexchange-webapps
{ "answer_score": 3, "question_score": 2, "tags": "google, account management, google analytics, delete" }
$_SERVER['REQUEST_URI'] generating extra & in URL Having an issue here where the $_SERVER['REQUEST_URI'] is spitting out: `/dev/nava2/store/index.php?route=product/product&amp;product_id=48` the actual URL is `/dev/nava2/store/index.php?route=product/product&product_id=48` obviously, the difference being the `&amp;` on the top vs. the `&` on the bottom full code looks like this: $currentpage = $_SERVER['REQUEST_URI']; $classic = "/dev/nava2/store/index.php?route=product/product&product_id=48"; if ($currentpage == $classic) { $classicclass = "current"; } else { echo "";} Any suggestions?
`&amp;` is the html entity corresponding to `&`. You can obtain to original string back with html_entity_decode : $original = html_entity_decode($_SERVER['REQUEST_URI']);
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "php" }
Boolean property used as a statement in c++ I was translating some C++/CLI code to c# and I saw the below snippet within the constructor of a class. if( !prop1 ) prop2; Prop1 and prop2 are 2 public boolean properties of the same class with only the get methods defined. public: property bool prop1 { bool get(); } property bool prop2 { bool get(); } What does the above statement mean? How can a boolean property be used as a statement on its own? What would it translate to in c#?
The code seems to be using a C++ extension of some sort, perhaps based on this, I'm not really sure. Regardless, it seems clear from what you've posted of the code that the statement in question is a no-op, so I'd just leave it out. Interesting question though.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, properties, c++ cli, boolean" }
Can LiveCode objects be anchored to one or more sides of a form? If so, how? ... Just for clarity, if there are 2 pixels between a form and object's edges, and I resize the form, I'd like the distance between the form and object to still be 2 pixels after resizing. Thank you, as always.
There's a few ways to do this but the simplest and most reliable is to script it with a resizeStack handler in your card script: on resizeStack pWidth,pHeight put the rect of field "name" into tRect put pWidth-2 into item 3 of tRect set the rect of field "name" to tRect end resizeStack
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "livecode" }