INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Automatically adding numbers in Rails form_for
This is a `form_for` in my Rails view:
<div class="field">
<%= f.label :num1 %><br />
<%= f.text_field :num1 %>
<%= f.label :num2 %><br />
<%= f.text_field :num2 %>
<%= f.label :sum %><br />
<%= f.text_field :sum %>
</div>
I would like to make it so that, when the user inputs numbers into the first two fields, the third field automatically shows the sum of the two numbers, but the user can manually change the third field. I'm not sure how I could do this, maybe with some Javascript? | It's pretty simple with jQuery:
$('#num1').change(function() {
var one = this.val();
var two = $('#num2').val();
$('#sum').val(one + two);
});
$('#num2').change(function() {
var one = $('#num1').val();
var two = this.val();
$('#sum').val(one + two);
});
Done. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "javascript, ruby on rails 3, forms"
} |
Weierstrass Factorization Theorem
Are there any generalisations of the Weierstrass Factorization Theorem, and if so where can I find information on them? I'm trying to investigate infinite products of the form
$$\prod_{k=1}^\infty f(z)^{k^a}e^{g(z)},$$
where $g\in\mathbb{Z}[z]$ and $a\in\mathbb{N}$. | A vast generalization of Weierstraß's theorem is to Riemann surfaces.
Florack, inspired by methods due to Behnke-Stein, proved the following in 1948:
_Let $X$ be a non-compact Riemann surface. Let $D$ be a closed discrete set in $X$ and to each $d\in D$ attach a complex number $a_d$.
Then there exists a holomorphic function $f\in \mathcal O(X)$ defined on all of $X$ such that $f(a_d)=c_d.$_
One may think of $f$ as holomorphically interpolating some discrete data.
This result immediately implies that $X$ is a Stein manifold, a concept of fundamental importance in the theory of holomorphic manifolds: Stein manifolds are the analogues of affine varieties in algebraic geometry.
A complete proof is in Theorem 26.7 of Forster's awesome Lectures on Riemann Surfaces.
The special case where $X$ is an open subset of $\mathbb C$ is analyzed in John's answer. | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "real analysis, complex analysis"
} |
Cannot get CASE working for a NULL substitution.
My code sample below:
I want to look up contracts that have started, AND may or may not have an end date. If the end date is later than today, or not yet specified (NULL / empty), then great.
SELECT
ID, BeginDate, EndDate,
CASE
WHEN EndDate IS NULL
THEN curdate()+1
END as FinishDate
FROM
contracts
WHERE
(id=1) AND
(CURDATE() BETWEEN BeginDate and FinishDate);
But I'm getting
#1054 - Unknown column 'FinishDate' in 'where clause
What am I missing? | This is because `FinishDate` is not a column of the original table, so the scope of its identifier is limited to the `ORDER BY` clause; it cannot be used in the `WHERE` clause.
There are several ways to work around this problem. The simplest one is to copy the expression into the `WHERE` clause:
SELECT
ID, BeginDate, EndDate,
CASE
WHEN EndDate IS NULL
THEN curdate()+1
END as FinishDate
FROM
contracts
WHERE
(id=1) AND
(CURDATE() BETWEEN (CASE WHEN EndDate IS NULL THEN curdate()+1 END) and FinishDate);
Note: most RDBMSs have a special operator for providing null replacement expressions. In MS SQL Server that's `COALESCE` and `ISNULL`:
SELECT
ID, BeginDate, EndDate,
ISNULL(EndDate, curdate()+1) as FinishDate
FROM
contracts
WHERE
(id=1) AND
(CURDATE() BETWEEN ISNULL(EndDate, curdate()+1) and FinishDate); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "mysql, sql"
} |
"very nearly gotten the guy to confess"
_He’s discovered a new suspect, and this new suspect has just enough evidence against him to suggest that, hey, maybe he killed Andrea instead of Naz. Box has even tracked this new suspect down and **very nearly gotten the guy to confess** , in a superbly creepy scene._
Source: <
I am not sure whether the part in bold is the causative as in the sentence like this: Wait, I'll get someone to help you! Or is the meaning simply that Box very nearly achieved to get a confession from the guy? | from my understanding it seems that the subject, Box, does not make the man confess, however the man almost does confess, or become very close to confessing. the easier way to imagine this is a running race. Pretend as if the man very nearly gotten to the finish. from this understanding we can see that the person running the race never finishes. | stackexchange-ell | {
"answer_score": -1,
"question_score": 3,
"tags": "causatives"
} |
How to convert hypothesis with "if then else" equality into its consequent using coq?
How do I prove the following trivial theorem?
Theorem hmm : forall {A:Type} (b:bool) (x:A),
(if b then Some x else None) = None -> b = false.
Proof.
intros A b x H.
inversion H. (* duplicates the hypothesis? *)
Fail assumption.
Admitted
I was expecting `inversion H` to infer that `b = false`, but instead it duplicates the hypothesis. | You must first do a proof by cases on b
Theorem hmm : forall {A:Type} (b:bool) (x:A),
(if b then Some x else None) = None -> b = false.
Proof.
intros A b x H.
destruct b.
- inversion H.
- trivial.
Qed. | stackexchange-proofassistants | {
"answer_score": 1,
"question_score": 0,
"tags": "coq"
} |
Python and only Python for almost any programming tasks!
Am I wrong if I think that Python is all I need to master, in order to solve most of the common programming tasks?
**EDIT** I'm not OK with learning new programming languages if they don't teach me new concepts of programming and problem solving; hence the idea behind mastering a modern, fast evolving, with a rich set of class libraries, widely used and documented, and of course has a "friendly" learning curve programming language.
I think that in the fast evolving tech industry, specialization is key to success. | You are right and wrong.
**Right:** Knowing a single tool very well is very marketable and to be desired. And Python is good for OO, for scripts, for functional-ish programming, and it has excellent mathematical and scientific libraries.
**Wrong:** Python doesn't teach you everything a good developer should know. Sometimes you will need JavaScript to provide some client-side functionality. Sometimes you need to understand what's happening at a more fundamental level, such as the C underneath the Python. And sometimes you need to learn to think in different ways, as you would with Haskell or Clojure. | stackexchange-softwareengineering | {
"answer_score": 32,
"question_score": 7,
"tags": "python, language choice"
} |
Density of a set
Suppose $X$ is a topological space. We know by definition $A$ is dense in $X$ if $ \overline{A} = X $.
My question is. IS it enough that $\overline{A} \subseteq X$ to say that $A$ is dense in $X$ ?? | No. Take $X=[0,2]$ and $A=[0,1]$. Then $A= \overline{A} \subset X$, but clearly $A$ is not dense in $X$ (for example, $(1,2) \subset X\setminus A$). | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "general topology"
} |
Are there cummulative updates for "Language Pack for SharePoint Foundation 2010"?
I installed the SP1 for each language pack and i cannot find any cummulative updates for the language packs. Do they exist or am i up to date? | No, there are no CUs for language packs. | stackexchange-sharepoint | {
"answer_score": 2,
"question_score": 1,
"tags": "2010"
} |
VBA in PowerPoint doesn't work at OneDrive
I have the PowerPoint presentation with VBA. I'm saving this presentation as .pptm or .ppsm file, and on my local computer it work great. But when i'm upload this presentation at OneDrive, the VBA doesn't work. Please help me to understand why it happens? | Microsoft does not support the execution of macros in any Office application while stored on their servers. In addition, ActiveX controls may be removed so whilst you can upload a macro-enabled file and download it in order to run the code, ActiveX controls no longer be available.
References:
<
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "vba, powerpoint, onedrive"
} |
Is the spacing around my typographic elements correct?
The image below is a more or less standard paragraph example for the website I'm trying to design. It's probably not much help for the question I'm asking, but I will try to further detail what I'm doing there.
* font used is Roboto Black and Regular
* the section has a margin top and bottom of 50px
* the heading is 36px
* the heading has 30px margin bottom starting from the underline (yellow line)
* the paragraph is 18px with 27px leading (1.5 line-height)
* the design is based on a 1170px grid (Bootstrap) if that's of any use

P.S. I feel like a tone deaf person trying to sing when I'm doing typography, so any constructive criticism is much appreciated. | This is always ultimately going to come down to the eye of the viewer. To my eye the vertical rhythm (and that's an important phrase, and one you can Google to learn lot more) looks fine in general, but I think the underline beneath the heading looks a little cramped. I'd open that up by about 5px. (ie, add 5px to whatever the padding on the heading is currently set to)
The line-lengths are a little long though. Aim for about 60 characters, whereas you have what looks at a glance to be about 100 (I haven't counted!), so either make your image larger in relation to the text column, or simnply reduce the text column and don't (ever) be afraid of white-space.
One tip to make typographic sites really sing, is to look into a jQuery based hyphenation plugin, and a relevant hyphenation dictionary. Just a random tip :) | stackexchange-graphicdesign | {
"answer_score": 0,
"question_score": 0,
"tags": "website design, typography, critique"
} |
Google SignIn not working for iOS 10
I have integrated the `GoogleSinIn API` in my project with `Swift 4.0`. It is working on `iOS 11.0` but when I'm testing the same on `iOS 10.0` it is opening the `Google` login page on the `Safari` browser or the device and after signing successfully it is opening the `Google` search page.
1. When I click the `GoogleSignIn` button shown below it opens the browser shown in next image.
2. Then I fill up the credentials.
3. After the successful signed in, It redirects to the `Google` page instead of the application page. | I was using wrong handler in `AppDelegate`.
**Previously I was using:**
private func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool
**But it should be:**
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 12,
"tags": "ios, google signin, swift4, ios10.3"
} |
Magento 2 - Cache warmer for multiple server
I have integrated a cache warmer module. Using **cronjob** it runs and creates `cache` for **all the pages** , and it's working properly.
I have **multiple servers** (Let's say 2 servers), until now there is no need to `schedule cronjobs` for all `servers`, I used to `schedule cronjobs` only on first server.
Since cache used **local storage** to save **cached data** , if I **schedule cronjob** on one server, then **cache warmer** wont work on other server.
Now my question is, **how can I create cache for both servers while cron is scheduled on first server** | In local cache environment it is impossible to create cache for both servers while executing cron on one server.
There is only one option left, **make cache centralize**.
To do this you need to use either **Varnish** or **Redis**. I have read multiple articles and all of them saying that **Varnish** is better approach. But I have used **AWS Elasticache Redis** on my server as it is more cheap and I have less knowledge of Varnish right now :D
To implement redis I have executed this command on shell (Putty)
php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=127.0.0.1 --page-cache-redis-db=1
I have used my server details in above command (Obviously)
And now I have centralized storage of Full Page Cache, and I have scheduled cronjob on one server and it is working fine for both servers. | stackexchange-magento | {
"answer_score": 5,
"question_score": 7,
"tags": "magento2, magento2.2, cache, cronjobs, cache warmer"
} |
SnackBar from top. Is this possible?
I wanted to provide the `SnackBar` animation from top, instead of the regular behavior that displays the `SnackBar` from bottom. Is this easily hackable? | No it is not possible. The documentation states that
> They show a brief message at the **bottom** of the screen on mobile and lower left on larger devices. Snackbars appear above all other elements on screen and only one can be displayed at a time.
You could use a third part library, like Crouton for instance | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 15,
"tags": "android, android support library, android support design, android snackbar"
} |
Modern way to filter STL container?
Coming back to C++ after years of C# I was wondering what the modern - read: C++11 - way of filtering an array would be, i.e. how can we achieve something similar to this Linq query:
var filteredElements = elements.Where(elm => elm.filterProperty == true);
In order to filter a vector of elements (`strings` for the sake of this question)?
I sincerely hope the old STL style algorithms (or even extensions like `boost::filter_iterator`) requiring _explicit methods_ to be defined are superseded by now? | See the example from cplusplus.com for `std::copy_if`:
std::vector<int> foo = {25,15,5,-5,-15};
std::vector<int> bar;
// copy only positive numbers:
std::copy_if (foo.begin(), foo.end(), std::back_inserter(bar), [](int i){return i>=0;} );
`std::copy_if` evaluates the lambda expression for every element in `foo` here and if it returns `true` it copies the value to `bar`.
The `std::back_inserter` allows us to actually insert new elements at the end of `bar` (using `push_back()`) with an iterator without having to resize it to the required size first. | stackexchange-stackoverflow | {
"answer_score": 180,
"question_score": 155,
"tags": "c++, c++11, stl"
} |
Question regarding the $\mathcal{O}$ notation used on constant functions
I'm having difficulties to understand the following passage out of the CLRS book, when the Counting Sort algorithm is introduced:
> Counting sort assumes that each of the elements is an integer in the range $1$ to $k$, for some integer $k$. When $k = \mathcal{O}(n)$, the Counting-Sort runs in $\mathcal{O}(n)$ time.
>
> Remark: $n$ is the length of the input array
I don't understand the mathematical background of the requirement $k = \mathcal{O}(n)$. If I'm not mistaking the claim $k = \mathcal{O}(n)$ always holds, because for $ C := k$ holds $k \leq C *n = k*n$. But the fact that the quoted paragraph stresses this requirement makes me think that I overlook something.
I'd be thankful if you could help me with this. | If we have an array such that $a(n) = n^2$, then $k = n^2$ which is not $O(n)$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "algorithms, asymptotics, sorting"
} |
Voltage drop on batteries when connected to ups/inverter
I have recently installed a solar system and trying to understand the voltages of batteries when they are being charged and when they are providing power to load. Here is what I observed:
I have 2 Lead Acid 12v Deep Cycle 200ah batteries connected in series with a 24 volt solar inverter/charger.
During the charging phase I notice that the voltage of batteries as shown on the lcd display go up as high as 29.1 and then stops.
At night when connected with load and providing about 100 watts 220v the batteries read 25.9 in the beginning and drops to about 24.9 in about 6 hours.
Is it normal for a battery to charge upto 29.1v but then read 26v when it starts to provide power to inverter for dc to ac inverter? | That is a normal range of voltage for lead-acid batteries. The voltage may go as low as 22 volts as the batteries discharge.
The "12 volt" battery in a car can be up to 14.5 volts when charging, about 13 volts after sitting not being charged or used for a while, and down to 11 volts under load. | stackexchange-electronics | {
"answer_score": 3,
"question_score": 3,
"tags": "voltage, batteries, lead acid"
} |
Problem bytes to str
I'm new in jython and I try to convert bytes to str.
do you know how I can do this? Thanks | from array import array
a = array('b', [30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47])
print ', '.join(map(str, a)) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "jython"
} |
My app crash using OpenAL but only in Release Mode
I'm building up a complete game engine so, basically, it integrate a sound system. The problem is that a line make me crash in my code. The strange thig is that my app crash ONLY when I compile using Release mode, in Debug Mode it run just fine.
I'm using MSVC 16.XX (I don't know exact version, but it is the latest at the time I am asking this question)
(language used is c++)
void PSound::GetDevice()
{
const ALchar* DeviceList = alcGetString(NULL, ALC_DEVICE_SPECIFIER); //This Line make app crash
if(DeviceList) {
while(strlen(DeviceList) > 0) {
Devices.push_back(DeviceList);
DeviceList += strlen(DeviceList) + 1;
}
}
} | Ok, I fixed it. It was a very silly problem. There was a project which where not well linked and all the projects were not using the same Runtime Library. | stackexchange-gamedev | {
"answer_score": 0,
"question_score": 0,
"tags": "c++, openal"
} |
Prove or Disprove $xa \equiv 1 \pmod{ n}$
If $a\in\mathbb{Z}, n\in\mathbb{N}$, then the equation $xa\equiv1\pmod {n}$ has a solution for some $x\in\mathbb{Z}$.
I'm not quite sure where to start. I know that $n|(xa-1)$, so $ns=xa-1$ for some integer $s$.
Should I start plugging in numbers to find one that makes it possible for a to divide $(ns+1)$?
$(xa-1)\equiv0 \pmod {n}$, so this means that $xa=\pm 1$?
I feel so dumb when it comes to proofs, so please go easy on me.
Thank you. | If your question means $\forall a\in\mathbb Z.\forall n\in\mathbb N.\exists x\in\mathbb Z.xa\equiv 1\pmod n$, then we have many counter-examples, e.g. $a = 4$, $n = 6$, then $4x \equiv 0, 2 \text{ or } 4 \pmod 6$ for any $x$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "elementary number theory, modular arithmetic"
} |
how to clear ImageUpload and Checkbox in ASP NET?
I'm building a sales page and setting up the Admin page at the moment. I have 4 Asp:Fileupload and three asp:checkboxes i want to clear when the user press the Add button. I tried to search for the answer and looks like a foreach could fix it but i don't know what to write inside the ( ) . Can't find the right way to point out where the boxes are inside the AddProduct.aspx.cs .
The add method is called btnAdd_Click and the .aspx page is called AddProduct.aspx. The checkboxes is called chFD, ch30Ret and chCOD . The Fileupload is fulmg01, fulmg02, fulmg03. | As my comment worked perfectly i am posting as answer.
`fulmg01.PostedFile.InputStream.Dispose();`
for file upload and
`chFD.Checked = false; `
for checkbox should do the work | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "c#, asp.net"
} |
Reading unicode one byte at a time
I'm trying to create a simple encryption-decryption program (still stuck at I/O, tho):
ifstream f("a.in", ios::binary);
ofstream g("a.out");
char x1, x2;
int x,j=0;
f.get(x1);
while(f.get(x2))
{
if(j==10)
{
g<<'\n';
j=0;
}
x=x1+x2;
x1=x2;
g<<x<<' ';
j++;
}
Now, the code runs perfectly with ASCII text, however, fails to do so with unicode.
My idea was that, by reading one byte (the 8 bits kind) at a time, I wouldn't have to worry about multi-byte characters and I assumed binary mode would allow me to do that.
Sounds great in theory, not so much in practice, as the program crashes at the very first unicode character. Can anyone point me in the right direction here? I've searched the web quite extensively, but, apparently it's not something often asked.
tl;dr: How do I read 8 bits at a time, regardless of their content? | Try
f.read(&x1, 1);
get() is intended for text, not binary data. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c++, unicode"
} |
import error; no module named Quandl
I am am trying to run the Quandl module on a virtualenv which I have uninstalled packages only pandas and then Quandl,
I am running Python 2.7.10 - I have uninstalled all other python versions, but its still giving me the issue of 'ImportError: No module named Quandl'. Do you know what might be wrong? Thanks | Try with lower case, import is case sensitive and it's as below:
import quandl
Did you install with pip? If so ensure quandl is among the listed installed modules with
pip list
Otherwise try
help('modules')
To make sure it was installed properly. If you don't see quandl listed , try to reinstall. | stackexchange-stackoverflow | {
"answer_score": 54,
"question_score": 21,
"tags": "python 2.7, importerror, quandl"
} |
I am trying to get an integer input from tkinter, but keep getting this error
I am trying to get an integer input from tkinter but I keep getting an error, but I'm not sure why.
The error is :
> value = int(enter_box.get()) ValueError: invalid literal for int() with base 10:
My code:
enter_box = Entry(win,bd = 5)
enter_box.pack(side = TOP)
value = int(enter_box.get()) # this is the line that keeps having the error
value = (int(value))
value = ((value) -1)
results = (results[value])
print (results)
It should just get an integer from the users input that I can add and subtract from. | You're calling the get method about one millisecond after creating the widget. – Bryan Oakley
The way you structure your instructions needs to be rearranged to avoid this error. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "python, tkinter"
} |
Pandas find distinct destination where ALL users have visited
I have a dataframe with 2 columns. One for users and the other for destinations. I am looking to find the destination where ALL users visited. This is the dataframe
df1
user destination
0 1 dest1
1 2 dest3
2 3 dest4
3 2 dest1
4 2 dest4
5 3 dest1
6 4 dest2
7 4 dest1
8 1 dest4
9 4 dest4
Desired Output:
dest1
dest4
I am working with a dataset with thousands of users and destinations so this must scale out. | You could try:
# find number of unique users
nunique = df.user.nunique()
# find number of unique users by destination
destinations = df.groupby('destination').user.nunique().to_frame().reset_index()
# find the destinations that match
result = destinations[destinations.user == nunique].drop('user', axis=1)
print(result)
**Output**
destination
0 dest1
3 dest4 | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "python, pandas"
} |
Close file in C
Under Linux I use this code to redirect stdout and stderr on a file, as shown in the code the file is opened using fopen(f) and is it closed using close(fd).
int fd;
FILE *f;
f = fopen("test.txt", "rb+");
fd = fileno(f);
dup2(fd,STDOUT_FILENO);
dup2(fd,STDERR_FILENO);
close(fd);
My question is whether the **close(fd)** statement closes all file descriptors, or is it necessary to use **fclose(f)** as well ? | The rule is to close the outermost level. Here the FILE object pointed to by `f` contains the `fd` file handle but also internal data like a possible buffer and various pointers to it.
When you use `close(fd)`, you free the kernel structures related to the file, but all the data structures provided by the standard library are not released. On the other hand, `fclose(f)` will internally close the `fd` file handle, but it will also release all the resources that were allocated by `fopen`.
TL/DR: if you use `fd= open(...);` to open a file, you should use `close(fd);` to close it, but if you use `f = fopen(...);`, then you should use `fclose(f);`. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "c, linux, file, fclose"
} |
Ubercart payment option without gateway?
I'm new to this forum, and I'm maintaining a Drupal 6.x webshop using Ubercart 2.4 for a client. The client wants to add a new payment option for business to business customers. These customers wouldn't need to pay at all, but would be invoiced manually from the client.
The client would have to check weather the customer is actually a valid customer for this "payment method", and decide if they can take the order or not, but this would be a separate issue.
**How can I add a new payment method that just stores the order with shipping and billing address to my database, no more?**
**Could I refactor the "Other" option from Payment Pack?** | I ended up copying the "Other" option from payment pack. Then I changed all references to "busniess_invoice". Works like a charm! | stackexchange-drupal | {
"answer_score": 1,
"question_score": 1,
"tags": "ubercart"
} |
Google Geocoding API, free?
I found the the Google Geocoding API service which is very useful.
but in all sample appears necessary to put an argument called `Key` for provide the google `Api Key`. That implies that it involves costs, but I saw that it works well without this argoment. example:
You can count on? they have any limitations? | **Usage Limits**
The Google Geocoding API has the following limits in place:
Users of the free API:
* 2,500 requests per 24 hour period.
* 5 requests per second.
Google Maps API for Work customers:
* 100,000 requests per 24 hour period.
* 10 requests per second. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 5,
"tags": "google api, licensing, google geocoding api"
} |
How to rename duplicate rows
I have an Excel sheet with I have around 25k rows of data in the following format:
**Column1 | Column 2**
A | value1
A | value2
A | value3
B | value1
B | value2
C | value1
C | value2
and so on. I would like to rename the duplicate rows and put an integer in place of it. I would like the new data to be:
**Column1 | Column 2**
1 | value1
1 | value2
1 | value3
2 | value1
2 | value2
3 | value1
3 | value2
How can this be done? | Im assuming your Column 1 is in Col A and your Column 2 is in Col B and that you just simply want to convert letters (capital letters) to number.
Insert a new column as Col A. So now your letter are in Col B. Then type the formula
=CODE(B2) - 64
in cell A2 (assuming row 1 is for headings) and drag it down.
Then copy the whole of Col A, right click on cell A1 and choose paste values. Then delete Col B.
* * *
Based on your comment do the following instead.
Insert a column between the two in you example. In the top cell of the column put the value `1`. In the next cell `=IF(A2<>A1,B1+1, B1)` and then drag down.
!enter image description here | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "excel, excel formula, excel 2010, excel 2007, worksheet function"
} |
Trying to combine href attribute and location.search
I would like to add a search query result to all subsequent page URL's that a visitor clicks on my site. However when a person on my page called "directions.html" clicks on the " **About Us** " link it comes up as:
<
The problem is that the link is going to directions.html and not about.html? Does anyone know what is causing that?
Javascript
$("#aboutHtml").attr("href", "about.html" + location.search);
HTML
<a id="aboutHTML" href="#">About Us</a> | Make sure your jQuery code runs after the links load.
$(document).ready(function() {
$("#aboutHTML").attr("href", "about.html" + location.search);
}); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "javascript, jquery, html, href"
} |
Data on refugee migration
Are there any current data sets on the migration of refugees in Europe available? As information seems to be sparse, I don't really care what kind of data. For example, data on migration routes or registration data would be interesting, preferably from the governments or the EU. | Check global-refugees.info's data. It's available as a excel spreadsheet (.xlsx). And they also have some code explaining the process they used for making the visualizations on their website and on github <
**UNHCR database**
The main source of all the articles and visualizations is this <
**UNDATA**
Some journalists also use this as their source although many argue that it's basically UNHCR's data afterreported. | stackexchange-opendata | {
"answer_score": 6,
"question_score": 11,
"tags": "data request, migration"
} |
Why does asp.net wrap the page in a form?
I'm a PHP developer who has to work on ASP.net projects and I'm wondering why every page is wrapped in a form. This just doesn't make sense to me.
Also What's with all the hidden input fields especially the "View State" one. | ASP.Net tries to make it so that the programmers can pretend that the web is a stateful platform, and that it behaves like a desktop application. The ViewState is basically a serialized block of the state of the page when it was generated. When the page gets posted back the server side model gets initialized to the values in ViewState, and then the new values from the posted form are applied.
Part of becoming a decent ASP.Net programmer is learning when to use ViewState and not, because the default is to use it everywhere which causes a lot of bloat in the downloaded page. | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 9,
"tags": "asp.net, viewstate, webforms"
} |
Common location for systemd unit files on Ubuntu and RHEL
I would like to create a scripted install for a list of `Systemd` services. This installation should support both Ubuntu (starting with version 16.04) and RHEL/CentOS (starting with version 7.2)
I read RHEL docs and found three paths that I could store unit files in, these paths are:
* /usr/lib/systemd/system/
* /lib/systemd/system/
* /etc/systemd/system
What is the correct location for services that fulfills these criteria:
* Unit files are there for non-system level services (application specific services)
* No already existing OS level services are overwritten
* The location is identical on Ubuntu and RHEL/CentOS | In default Red Hat distributions, `/lib` is a symlink to `/usr/lib`, but it appears those are different locations in Ubuntu.
According to the systemd documentation, `/usr/lib/systemd/system/` is designated to hold upstream unit files that would not be edited by users and instead be provided and updated via packages.
The `/etc/systemd/system` is designated as where user provided unit files would be. Packages should not override or update anything in `/etc/systemd/system`. You can also use `/etc/systemd/system` to override existing unit files.
So using `/etc/systemd/system` should be the most compatible between different distributions. | stackexchange-unix | {
"answer_score": 14,
"question_score": 13,
"tags": "ubuntu, centos, rhel, systemd"
} |
Is there anything using command blocks to check if an entity is greater than certain ranges of a command block?
I was wanting to run a command based off of when a player gets out of the range of a command block, or if they are within two ranges. For example, like this where when the player gets inside of the red range that then the player gets a command run on them. Is there any way to do this as easily as possible? | In the newer versions of minecraft you can use `/execute as @a[distance=x..y] run <command>`
x is the distance in blocks from which to start targeting
y is the furthest it will target players in blocks
The two `..` are important
`Example: /execute as @a[distance=10..15] run effect @s give minecraft:levitation 1 1 true` | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "minecraft, minecraft commands"
} |
DLL as `src` of `<script>`
I was browsing the source code of some website, and noticed a dll file being used as the `src` of a `<script>`.
(`view-source:
It was something like: `<script src="some-dll-file.dll"></script>`
Several questions:
* I didn't know a `<script>` could be anything besides js. What else can it be used for?
* Can you point me in the direction of some more information on this topic? I've tried ggoogling around, but realized that I don't know what I should be googling exactly.
* Is this cross-platform? I mean if I were to try this on epiphany on an ubuntu box, would it function and serve its purpose? I'm on a windows box right now and won't have access to anything else for a while, so I can't test it myself. | Only JavaScript can be used as the client-side scripting language (and VBScript too, in IE). The `src` attribute just specifies some URL, and that URL will return the JavaScript.
So, the URL < actually does return JavaScript. If you save its contents as a local text file, you can read the script.
Without knowing anything about the site or its JavaScript, I would guess they are dynamically generating some part of the script file from the DLL.
Edit: actually, looking at generated JS, I guess it's dynamically compressing the script on its way to the client. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "javascript, html, dll, scripting, client side"
} |
Why do I want to avoid non-default constructors in fragments?
I am creating an app with `Fragments` and in one of them, I created a non-default constructor and got this warning:
Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead
Can someone tell me why this is not a good idea?
Can you also suggest how I would accomplish this:
public static class MenuFragment extends ListFragment {
public ListView listView1;
Categories category;
//this is my "non-default" constructor
public MenuFragment(Categories category){
this.category = category;
}....
Without using the non-default constructor? | Make a bundle object and insert your data (in this example your `Category` object). Be careful, you can't pass this object directly into the bundle, unless it's serializable. I think it's better to build your object in the fragment, and put only an id or something else into bundle. This is the code to create and attach a bundle:
Bundle args = new Bundle();
args.putLong("key", value);
yourFragment.setArguments(args);
After that, in your fragment access data:
Type value = getArguments().getType("key");
That's all. | stackexchange-stackoverflow | {
"answer_score": 112,
"question_score": 176,
"tags": "android, android fragments"
} |
Nat Loopback - Access external IP from internal
I have a static IP and I've made a webserver that is running fine from WAN (domain points to my IP).
However, when I access my external IP/Domain from my LAN, it redirects me to my router login page.
What can I do to fix this?
I've read something about editing the Windows `hosts` file, but what should I put in there?
xx.xx.xx.xx mydomain.com (Should this do the job?)
Thanks!
**Setup: Huawei HG658 Router, Windows 10, BitNami WAMP Stack 7.0.22-1**
Screenshot | Don't use external IP to access to your server inside local network. Use server's local IP address. Many operating systems (include Microsoft Windows) read `hosts` file before send DNS query to resolve domain name to IP address. That's why `x.x.x.x` must be server's IP address in your local network and `mydomain.com` must be full real domain name of your server (not local). | stackexchange-serverfault | {
"answer_score": 0,
"question_score": -1,
"tags": "web server, router, nat, local area network, loopback"
} |
Adding foreign key on multiple columns
I'm trying to create a foreign key on two columns of a table to point to the same column of another table, but I seem to get an error...
Here's what I do:
CREATE TABLE test2 (
ID INT NOT NULL AUTO_INCREMENT,
col1 INT NOT NULL,
col2 INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk FOREIGN KEY (col1, col2)
REFERENCES test1(ID, ID)
ON UPDATE CASCADE
ON DELETE RESTRICT
) ENGINE=InnoDB;
But I get
`ERROR 1005 (HY000): Can't create table 'DB.test2' (errno: 150)`
If I only have one column, however, the table is correctly created.
Could someone point out to me where the error is?
Thanks n | Tried it here and got the same error. This works though:
CREATE TABLE test2 (
ID INT NOT NULL AUTO_INCREMENT,
col1 INT NOT NULL,
col2 INT NOT NULL,
PRIMARY KEY (ID),
CONSTRAINT fk FOREIGN KEY (col1)
REFERENCES test1(ID)
ON UPDATE CASCADE
ON DELETE RESTRICT,
CONSTRAINT fk2 FOREIGN KEY (col2)
REFERENCES test1(ID)
ON UPDATE CASCADE
ON DELETE RESTRICT
) ENGINE=InnoDB
Yes, I know - your script _should_ work (even if it doesn't seem to make much sense). Yet, I guess this new version is better. | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 10,
"tags": "mysql, foreign keys, mysql error 1005"
} |
Audio output on AMD HD 3450
I've just installed this graphics card under Windows 7 32 bit and I'm unable to find any reference to the onboard audio driver. AMD's own website says that it should have 5.1 surround, and the card has an HDMI output which I would hope outputs both video and audio.
I'm currently running it off DVI to HDMI with a passive converter (was the only cable I had lying around and don't want to fork out for an HDMI if this works fine).
Does anyone here have any ideas on how to convince the card it has audio capabilities?
Edit: To respond to the questions by @afrazier, the catalyst interface says nothing about audio at all, and I've looked through all of the inf files (using the add new hardware wizard) and not found any audio drivers. No audio device shows up in the control panel, nor does a question marked "unknown item". | It would appear that I'd missed out an important piece of information from my original question. I have the AGP version of this card, which does not have support for sound. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "hdmi, dvi, amd radeon"
} |
Prove f is continuous and that f'(0) DNE
$$f(x) = \begin{cases} x\sin(1/x) & : \text{if }x \neq 0 \\\ 0 & : \text{if }x=0 \end{cases}$$
I have to show that f is continuous. I know that it's continuous when x doesn't equal 0 since f is a composition of continuous functions. But how do I show that it is continuous when x=0?
And then to show that f'(0) DNE, do I just need to take the derivative of the function and then plug in 0 for x?
Thank you! | You have (replacing $x$ by $1/y$) $$ \lim_{x\to 0}x\sin(1/x) = \lim_{y\to\infty}\frac{\sin y}{y}. $$ Now, use that $\sin$ is a bounded function. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "calculus"
} |
What is, in this sentence: アンタらみてえにご立派な目標はねえし, みたいに modifying
I stumbled upon this sentence in bold:
> ****
The spaces just indicate that it starts a new column (it's vertical writing in the manga)
What is it that here is modifying? I'm not sure really about the whole -part, because doesn't this make an adverb (here it would mean "looks like ")? | has two meanings:
> 1like
>
> 2look; seem
The one in the example is used in the first sense.
I guess the can be translated both _like_ and _unlike_ :
* Unlike you guys, I'm not aiming high
* I don't have a respectable objective like you
To my knowledge, English _un/like_ have the same ambiguity in a negative sentence.
* * *
(Edit) I forgot to answer the original question: in terms of 'modifying', modifies (or ... as a whole). | stackexchange-japanese | {
"answer_score": 3,
"question_score": 0,
"tags": "grammar"
} |
browser specific css attributes
Where can I find a complete "browser specific css attributes" reference?
I mean some attributes such as `-moz-border-radius` that is just for Firefox or `-webkit-min-device-pixel-ratio`. These examples work just in a specified web browser. I want a complete reference for these attributes. | Each vendor should maintain a list of custom CSS extensions. The ones I've found are linked below.
* Mozilla (Firefox)
* Opera
* Safari (merged with standard CSS properties)
* Internet Explorer (outdated)
Ones I can't find ...
* Chrome (same engine as Safari, some slight differences in vendor extensions supported) | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 4,
"tags": "css, internet explorer, firefox, google chrome, safari"
} |
object is possibly undefined angular unit testing
I was working on unit testing I am getting below error
> Object is possibly 'undefined'
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(this.dataSource.filter).toEqual('filterValue');
})
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(this.DMDataSource.filter).toEqual('filterValue');
})
I am getting error inside expect(this) what is the mistake here.
Please let me know. | You should use `component.dataSource` rather than `this.dataSource` inside `expect` block
You need to evaluate the `dataSource` defined inside `component` instance
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(component.dataSource.filter).toEqual('filterValue');
})
it('should set the dataSource filter to the provided argument', () => {
component.applyFilter('filterValue');
expect(component.DMDataSource.filter).toEqual('filterValue');
}) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "angular, typescript, unit testing, jasmine, karma jasmine"
} |
Deducing the base type from a template parameter
Visual Studio 2017, C++ with C++17
Is there any way to use a template parameter and deduce the base type?
Example: If the template parameter is `std::string` I want to declare a `char` inside the function. If the template parameter is `std::basic_string<unsigned char>` I want to declare an `unsigned char` inside the function:
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
typedef unsigned char uchar;
typedef basic_string<uchar> ustring;
template <typename str>
void exampleFunc(vector<str> &vec)
{
// Pseudo-code to be evaluated at ***compile time***
if (typeof(str) == ustring)
uchar c;
if (typeof(str) == string)
char c;
// ... code ...
}
int main()
{
vector<string> vec;
vector<ustring> uvec;
exampleFunc(vec);
exampleFunc(uvec);
} | If you only want `std::basic_string` parameterised by different character types, say so:
template <typename Chr>
void exampleFunc(std::vector<std::basic_string<Chr>> &vec) ... | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "c++, templates"
} |
Chrome: No autocomplete in address bar
I use firefox since ages.
I think about switching to chrome.
One thing I am missing:
In firefox the autocomplete in the address bar is great.
Example: If I enter "foo_bar" firefox shows me the last URLs which contain this pattern.
This does not work in chrome.
Is there a way to tell chrome to search in the browser history if I enter characters in the address bar?
Some prediction does happen. Words get predicted. If I type "Stacko" I see "Stackoverflow" in a list below the address bar.
Example:
I visited < with chrome yesterday. Today I enter "company_p" into the address bar and get no matching autocomplete result. That's sad. I need to stay with firefox since I need this feature often. | I have a theory. Any text linked with an underscore is treated by Chrome as a single word. So it can only find what you're looking for if you type it from the beginning. Example:
URL: <
Can be found by searching:
* _tes_
* _test__
* _test_usa_
Cannot be found when searching:
* _usage_
* __usage_
* _est_usage_
It's worth noticing that this does not happen with dashes. | stackexchange-superuser | {
"answer_score": 2,
"question_score": 1,
"tags": "google chrome, autocomplete"
} |
Difference between SMS and Network SMS
I need to know the difference between one simple SMS and one Network SMS? | These are _just guesses_ but would need to know the context to give a proper answer.
* Could mean the difference between an SMS that is sent cross-network, from one mobile phone provider's network to another one. So a 'simple' SMS stays within the one network.
* If the SMS is sent from the mobile phone provider to multiple phones eg. a special offer, marketing type blurbs... that is sometimes referred to as a network SMS, though I wouldn't consider it a standard piece of terminology. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "mobile, sms, mobile phones, network protocols"
} |
Is it ok to put nickel plated strings for an electric guitar on an acoustic guitar?
I have Fender Nickel Plated .12-.52 strings for electric guitar - is it bad to put those on an acoustic guitar? I do not seek perfection, although I wouldn't want to hurt my instrument. | When you state acoustic guitar, as long as you don't mean classical guitar, it's o.k. I have an Epiphone acoustic that has been strung in his way for 35+ yrs. No problem. I feel that 12s may be a little too heavy a gauge, I'd go for 10s or 11s, but a good move will be to check what gauge the existing strings are. Like for like will cause no problems, as the tension should be the same.
DO NOT do this on a guitar that was designed for nylon strings - you'll probably pull the bridge off, and/or bend the neck. If you decide to go for lighter than existing strings, you may need to adjust neck tension, and a faint possibility of intonation with the saddle/bridge, but the action could be lowered to make it more playable. It depends on your personal preference. | stackexchange-music | {
"answer_score": 4,
"question_score": 1,
"tags": "electric guitar, strings, acoustic guitar"
} |
$.get is not working in my server
The following code is working when I run with visual studio:
$.get('@Url.Content("Content/templates/new_story.htm")', function (tr) {
$("#table_body").append(tr.replace(/#story/g, storyNumber));
});
But, when I publish in IIS 7.5, the new HTML is not loaded into `#table_body`.
Why? | I've seen this when I publish to a virtual directory. I think what you'll want to do is add a tilda to your URL:
$.get('@Url.Content("~/Content/templates/new_story.htm")', function (tr) {
$("#table_body").append(tr.replace(/#story/g, storyNumber));
}); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "jquery, .net, asp.net mvc 3"
} |
Singleton for webdriver instance in javascript
Is there a reasonable way to create a singleton for the webDriver in javascript?
Reading through some documents about them and it seems in js it's somewhat of a headache to create one. | var webdriver = require('selenium-webdriver');
const SingletonFactory = (function(){
function singletonClass() {
}
let driver = new webdriver.Builder().withCapabilities(chromeCapabilities).build();
driver.manage().setTimeouts({implicit: (100000)});
Object.freeze(chromeOptions);
Object.freeze(driver);
return {
getInstance: function(){
if (driver == null) {
driver = new singletonClass();
// Hide the constructor so the returned object can't be new'd...
driver.constructor = null;
}
return driver;
}
};
})();
That's the answers code. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, selenium, singleton"
} |
how do i dynamically change my format rendering engine in rails?
My default templating engine is haml, but I would to sometimes change it to erb if i specify a specific parameter?
For example, I am pasting in some html code and would just like to test the code without HAML complaining about its format.
Any idea how to do this? | do something like:
if params[:render_erb]
render 'file.html.erb'
else
render 'file.html.haml'
end
and call the action with ?render_erb=true
or
render "file.html.#{params[:render]}" ir params[:render]
and call it ?render=haml or ?render=erb (or nothing and it will use the default
at the end of the controller's action that you are using | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "ruby on rails, haml, erb"
} |
order data.table along numeric column puttint special Value (residual category) of other column last
is there a possibility to order a data.table along a numeric column while putting a special row (residual category) last (based on label of another column)?
DT <- data.table (a =c("a", "sd", "set", "c", "s", "REST", "sde", "de"),
b=c(5,1:4, 2.5, 1:2))
Expected Output would be something like
a b
1: sd 1.0
2: sde 1.0
3: set 2.0
4: de 2.0
5: c 3.0
6: s 4.0
7: a 5.00
8: REST 2.5
I've put one answer below, but I wonder if there is one possibility without rbind. This is complicated, and I suppose this will also copy the whole data.table ;) | You can pass expressions to `order`.
DT[order(a=="REST", b)] # internally optimised to use data.table's fast ordering
If you would like to use `setorder` instead (which reorders by reference):
DT[, tmp := a == "REST"]
setorder(DT, tmp, b) | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "r, data.table"
} |
php query alwaysfalse no matter what
I have tried to read and do (incorporate) anything I find on here. But I have not found the solution. I'm using wamp server and I have a user table with 2 users one with email and password as test and test1 and no matter what I try the if statement always returns false.
<?php
$user = "root";
$pass = "";
$db = "testdb";
$db = new mysqli("localhost", $user, $pass, $db) or die("did not work");
echo "it connected";
$email = "test";
$pass1 = "test1";
$qry = 'SELECT * FROM user WHERE email = " '. $email .' " AND password = " '.$pass1.' " ';
$result = mysqli_query($db, $qry) or die(" did not query");
$count = mysqli_num_rows($result);
if( $count > 0)
echo " found user ";
else
echo " did not find user or password";
?>
I have tried to augment mysqli_num_rows but then it comes out always true | I needed to eliminate the blank spaces in the encapsulation of the variable
<?php
$user = "root";
$pass = "";
$db = "testdb";
$db = new mysqli("localhost", $user, $pass, $db) or die("did not work");
echo "it connected";
$email = "test";
$pass1 = "test1";
$qry = 'SELECT * FROM user WHERE email = "'. $email .'" AND password = "'.$pass1.'"';
$result = mysqli_query($db, $qry) or die(" did not query");
$count = mysqli_num_rows($result);
if( $count > 0)
echo " found user ";
else
echo " did not find user or password";
?> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "php"
} |
Commas do not echo with line
I have a file that contains multiple lines, kind of like a log. Each column in the file is separated by a comma. I am using an array to echo the lines to the output but when I run the script against the file, it does not seem to include the commas. They are in the file, why do they not print? Here is my code; Any help would be greatly appreciated. Thanks!
while IFS=, read -ra line;
do
if [ "${line[1]}" != "" ]
then
echo -n "${line[@]}, Hash Value: " && echo "${line[1]}" | openssl dgst -sha1 | sed 's/^.* //'
else
break
fi
done | Try something like this (though it would help if you can provide sample input):
while IFS=, read -ra line;
do
if [ "${line[1]}" != "" ]
then
(IFS=, ; line="${line[*]}"; echo -n "$line, Hash Value: ") && echo "${line[1]}" | openssl dgst -sha1 | sed 's/^.* //'
else
break
fi
done | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "arrays, shell, csv"
} |
Excel Autofilter on cell separated by semicolon
I am trying to do exactly what is posted here, but not on double clicking a cell. I am trying to assign the event to a button on another sheet. Keeping getting an "object required" error and cant figure out why.
Dim Arr 'Array to SPLIT string
Dim i As Long 'Index to loop through Arr
Dim Filt 'Array to filter range
Sheet2.Cells.AutoFilter
Arr = Split(Sheet2.Range("g2"), ";")
ReDim Filt(LBound(Arr) To UBound(Arr))
For i = LBound(Arr) To UBound(Arr)
Filt(i) = CStr(Arr(i))
Next i
Sheet2.Range("z5:z5000").AutoFilter 25, Filt, xlFilterValues | thanks to @BigBen, i was able to overcome the error. Here is the working piece of code should anyone else need help:
Dim Arr 'Array to SPLIT string
Dim i As Long 'Index to loop through Arr
Dim Filt 'Array to filter range
Arr = Split(Sheet2.Range("g2"), ";")
ReDim Filt(LBound(Arr) To UBound(Arr))
For i = LBound(Arr) To UBound(Arr)
Filt(i) = CStr(Arr(i))
Next i
Sheet2.Range("z4").AutoFilter 25, Filt, xlFilterValues | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "excel, vba"
} |
How to embed ruby/erb code into an inline html style tag?(progress bar)
I am trying to do a progress bar on a rails index page. I loop through assignments on each page and then show their completion percentage.
However I have the following bootstrap code in here to show the progress bar:
<% class:"progress-bar", role:"progressbar", aria-valuenow:"60", aria-valuemin:"0", aria-valuemax:"100", style:"width: 60%;" %>
I need to somehow be able to change the style:"width: 60%;" to be able to read something like `<%= width: assignment.completion %>` so that it each assignment has the completion saved in the database for that assignment.
How is something like this achieved? | **You can try this style:** `width: <%= assignment.completion %>` | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "css, ruby on rails, twitter bootstrap, ruby on rails 4, erb"
} |
Intuitive explanation of dividing outer product matrix by inner product
For some vector $v$, the matrix $P=vv^T$ is an orthogonal projector that projects onto the line on which $v$ lies. What is the intuitive meaning of the matrix $M$ obtained by dividing $P$ by $v^Tv$? $$ M=\frac P{v^Tv} $$
$M$ shows up in the classical definition for Gram Schmidt orthogonalization. For linearly independent vectors $v_1,\ldots,v_n$, define: $$ u_1=\frac{v_1}{\left\Vert v_1\right\Vert} $$ and $$ u_i=\left(I-\sum\limits_{j=0}^i\color{red}{\frac{v_jv_j^T}{v_j^Tv_j}}\right)v_i $$
The set of $u$ vectors is then orthonormal.
What is the purpose of dividing $v_jv_j^T$ by $v_j^Tv_j$? The outer product matrix is already an orthogonal projector. Does dividing by $v_j^Tv_j$ cause $u_i$ to have unit magnitude? (How?) | If $v$ is not unit then $v v^T$ is not even idempotent: $(v v^T)(v v^T)=\| v \|^2 v v^T$. So the normalization is needed to even make it a projector in the first place.
To put it another way, just $v v^T$ acts on the span of $v$ by multiplying by $\| v \|^2$, rather than doing nothing as it should if it is to be a projector. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "projection matrices, gram schmidt"
} |
The displacement of a body executing Simple harmonic motion
> The displacement of a body executing Simple harmonic motion is given by $x= A\sin(2πt + π/3)$. The first time from t=0 when velocity is maximum is
>
> Options :$ 1/12 s , 1/6 s, 1/3s , 1/2s$
So I tried the question and I got answer 1/3 but the correct answer is 1/12 s .I am confused. Can someone tell which answer is correct from above mentioned options. | Max speed occurs at zero displacement, which for $A\sin{x}=0$ means $x=0$ or $x=\pi$. Given the phase, term: choose $\pi$--it's the 1st crossing after $t=0$:
$$ 2\pi t+ \pi/3 = \pi$$
$$ 2t = 2/3 $$
$$ t = 1/3 $$. | stackexchange-physics | {
"answer_score": -1,
"question_score": -3,
"tags": "homework and exercises, newtonian mechanics, particle physics, waves, experimental physics"
} |
Cakephp - one variable accessible in view and controller
I want to define an array which I can use in `AppController` and in the default layout.
How can I do this in CakePHP? | $this->set('arr', array('one', 'two'));
// Accessible in controller as
$this->viewVars['arr'];
// Accessible in view/layout as
echo $arr; | stackexchange-stackoverflow | {
"answer_score": 26,
"question_score": 5,
"tags": "cakephp, variables, global"
} |
why doesn't nmap outputs simultaneously during scan
While running a scan over a huge range, we have to have to wait for the entire scan to complete, is there a specific reason why nmap doesn't output simultaneously? or its just to save time? | Because nmap is most often used to generate a result file; if none is specified, the results are written to stdout. That is what you are probably referring to.
It's just easier to have a single routine that collects data and then transforms it in the correct format for output.
More importantly: Depending on the scan you are executing, there might be multiple results rolling in on different hosts at a time.
Thus, real time output of findings would be unstructured and unhelpful. If you rather want to know more of what is going on in the background, you can use the verbosity and debug flags to generate much, much, much more output. | stackexchange-security | {
"answer_score": 5,
"question_score": 3,
"tags": "nmap"
} |
Future Value of Annuity
> Textbook: If you invest $2000 a year (at 9%) from ages 31 to 65, these funds will grow to $470,249 by age 65.
***the textbook did not say how they got this number, I just assumed it used FVA because it is in the same section
My calculation:
FVA = 2000 (( 1.09 )^35 - 1)/0.09)
FVA = 431,421.5093
Not sure if 35 is the correct amount of years, but regardless I did not get the answer from the book. What am I missing? | Assuming 9% nominal compounded monthly, calculate the effective annual rate `r`.
r = (1 + 0.09/12)^12 - 1
c = 2000
n = 35
a = future value
For calculation details see Calculating the Future Value of an Annuity Due.
^n - 1)/r) (1 + r) = 470249.45
The future value is $470,249.45 | stackexchange-money | {
"answer_score": 4,
"question_score": 4,
"tags": "investing, interest rate, annuity"
} |
Android Espresso - Web browser
I have a question
I want to test whether after button click the web browser is beign launched using espresso. And the question is: is it even possible to test such thing? If so any ideas how would I do that? | Actually no. Espresso will allow you to click in the button and once the browser is fired up, the test will end. The alternative you have is having your class that fires the browser Intent mocked, so that you can test the remaining flow (if any).
HAve a look in this answer: Controlling when an automation test ends - Espresso, where I describe how you could achieve that. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 14,
"tags": "android, android testing, android espresso"
} |
How can I add markers to implicit_plot?
The plot is generated by the following commands in Maxima. How can I add dots / markers at given coordinates?
load(implicit_plot);
ip_grid_in:[15,15]$
implicit_plot ([x^2 = y^3 - 3*y + 1, y=x^2], [x, -4, 4], [y, -4, 4],
[gnuplot_preamble, "set zeroaxis"]);
I have tried adding `[discrete, [[1.0,1.0], [1.0, 2.0]]]` to the list of equations but apperantly `implicit_plot` cannot handle it (perhaps because it is not an equation). | I'm no maxima wizard, but in gnuplot, I would add points using `set label`.
set label 1 at 1,1 point
set label 2 at 1,2 point
Based on what you have above, I would think you could just add this to the preamble:
implicit_plot ([x^2 = y^3 - 3*y + 1, y=x^2], [x, -4, 4], [y, -4, 4],
[gnuplot_preamble, "set zeroaxis;set label 1 at 1,1 point;set label 2 at 1,2 point"]);
It's a bit ugly, but I'm betting that it works :)
Of course, you may need to `unset` those labels in a later preamble if maxima re-uses the same gnuplot instance and doesn't issue a `reset` implicitly:
unset label 1; unset label 2
There are lots of things you can do to customize the appearance of the points (color, point-type, etc). in gnuplot, `help label` should discuss a bunch of those options if you're interested. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "plot, gnuplot, maxima"
} |
Angular momentum commutativity
I was reading about the angular momentum in quantum mechanics and I am wondering why different components of the angular momentum cannot be measured simultaneously.
Is there any explanation behind the non-commutativity and the relation $[L_i,L_j] = \mathrm{i}\hbar \varepsilon_{ijk} L_k$ or is it just an axiom of quantum mechanics? | The commutation relations between the angular momentum components can be derived from
* the canonical commutation relations between position and momentum: $[r_i, p_j]=i\hbar\delta_{ij}$
* and the definition of angular momentum: $\vec{L}=\vec{r}\times\vec{p}$, or $L_i=\sum_{jk} \varepsilon_{ijk}r_j p_k$ | stackexchange-physics | {
"answer_score": 3,
"question_score": 0,
"tags": "quantum mechanics, angular momentum"
} |
My output is stuck on the same thing
import java.util.Scanner;
public class QuestionThreeB {
public static void main(String[] args) {
int number;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter 1, 2, or 3: ");
number = keyboard.nextInt();
switch (number) {
case '1':
System.out.println("You entered 1.");
break;
case '2':
System.out.println("You entered 2.");
break;
case '3':
System.out.println("You entered 3.");
break;
default:
System.out.println("That's not 1, 2, or 3!");
}
}
}
When I compile and run the program I end up with the last output line ("That's not 1, 2, or 3!") as an output no matter what value I put in. I've attempted to use if then statements to fix this, it compiles but the result is the same | Variable `number` has type `int`. Switch statement is checking chars (number is in single quotes '1').
1 is not the same that '1'. You need to remove single quotes to compare ints.
public class QuestionThreeB {
public static void main(String[] args) {
int number;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter 1, 2, or 3: ");
number = keyboard.nextInt();
switch (number) {
case 1:
System.out.println("You entered 1.");
break;
case 2:
System.out.println("You entered 2.");
break;
case 3:
System.out.println("You entered 3.");
break;
default:
System.out.println("That's not 1, 2, or 3!");
}
}
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "java, switch statement, break"
} |
How to make action (hide) on all table cells, which ID is not containing some string
I got whole table, which has cells with particular ID's, example: "2012-01-01_841241" etc etc. Date, then some number.
I want to filter my table, so I send some request and get for example three numbers which should be only shown.
I want to hide all cells without these numbers in their IDs - is it any other way than iterating over all of them and check if their ID matches my ID string? (It looks costly).
So, i'm trying to avoid it (especially, when I will have a table of someNumbers :) ):
$('td').each(function(){
if($(this).attr("id") != someNumber) $(this).hide();
})
Thanks! | Well here is a way you can do it (jsFiddle here):
Essentially you can hide everything then make the ones you want visible:
$("#myTable td").hide();
showCells("2012-01-01_841242", "2012-01-01_841247");
function showCells() {
for (var i = 0; i < arguments.length; i++)
{
$("#" + arguments[i]).show();
}
}
The problem however with doing this on a table is that you can end up with an uneven number of `<td>` tags inside your various `<tr>` tags so you may want to find a different way to lay them out. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, jquery, user interface"
} |
Update to Chrome 36, black screen, no address bar, can't uninstall
I just updated to the latest (as of 7/18/14) Chrome, version 36 and when I relaunched the browser, it's just the window frame and a black screen.
It seems like a page (google.com) is loaded but it's just black. I can right click and get context menus, even a "save image" when I click where the google doodle would be. The cursor changes to text insert when hovering near the address bar. So everything's there... but it's not.
I try to uninstall it and a "Are you sure you want to uninstall Chrome?" dialog flashes quickly then disappears. And that's it. Nothing else.
I restarted my computer and ran a registry scan and nothing related to Google or Chrome came up.
I'm on Windows 7 and have all latest updates installed.
Any thoughts on how to troubleshoot this or force an uninstall?
!Chrome 36 black screen | Okay, the only answer that did work...
1. Add **\--disable-gpu** to the chrome shortcut
2. Chrome should now launch properly
3. Go into settings and **turn off hardware acceleration**
**Add --disable-gpu:**
!Add --disable-gpu
**Turn off hardware acceleration:**
!Turn off hardware acceleration
After you do that you can remove the --disable-gpu flag from your chrome shortcut.
< (thanks Mindflux!) | stackexchange-superuser | {
"answer_score": 5,
"question_score": 6,
"tags": "windows 7, google chrome, installation"
} |
How to write a spirial function in python?
I'm trying to write a function in python that takes two arguments `(x,y)`, and returns an angle in degrees in a spiraling direction.
Suppose the center of the spiral is at location `(x0,y0)`. Then given `(0,0)`, it returns `45`. Given some other point say `(0,90)` which is the second intersection from the top on the y axis, the angle is around `170`. For any point not touching the red line, it should return an angle of what you would expect the direction to be. The spiral is just a general thing to show the direction of the angles.
Does anyone know how to write such a function?
Thanks
!enter image description here !enter image description here | That's an Archimedean spiral curve. As the page says in polar coordinates the formula of the curve is r = aθ, usually the scalar `a` is _1_ i.e. r = θ. Polar to cartesian conversion is
x = r cos θ, y = r sin θ
Hence
x = θ cos θ, y = θ sin θ
Varying θ from 0 to 6π would give the curve you've. When you vary the parameter θ and get x and y values what you get would be relative to the origin (0, 0). For your case, you've to translate i.e. move the points by the x and y offset to position it accordingly. If you want a bigger version of the same curve you've to scale (before translation) i.e. multiply both x and y values by a constant scalar. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "python, math, trigonometry, curve"
} |
print dictionary element in a list of dictionaries using python
I have a list that contains several dictionaries - The list looks like this:
[{'DeltaG': -9.82, 'BasePairs': 4}, {'DeltaG': -9.25, 'BasePairs': 6}, {'DeltaG': -8.96, 'BasePairs': 8}]
What I want to do is to print `DeltaG` value if the `BasePairs` == 6 is found. If the `BasePairs` == 6 is NOT found then print the `deltaG` for the first `BasePairs` < 6:
I tried the code below but it gives the DeltaG= -9.82 which is for the first BasePairs == 4 while it should first search if there is BasePiars== 6 first.
for tuple in results:
if float(tuple["BasePairs"]) == 6:
deltaG = float(tuple["DeltaG"])
print(deltaG)
else:
if float(tuple["BasePairs"]) < 6:
deltaG = float(tuple["DeltaG"])
print(deltaG)
Anyone can help me with this? Thank you | Starting from your code, you can check something like this:
found = False
for tup in results:
if float(tup["BasePairs"]) < 6 and not found:
deltaG = float(tup["DeltaG"])
found = True
if float(tup["BasePairs"]) == 6:
deltaG = float(tup["DeltaG"])
break
print(deltaG)
Or if you want to use the smaller value:
min_base_pairs_val = float('inf')
for tup in results:
if float(tup["BasePairs"]) < min_base_pairs_val:
deltaG = float(tup["DeltaG"])
min_base_pairs_val = float(tup["BasePairs"])
if float(tup["BasePairs"]) == 6:
deltaG = float(tup["DeltaG"])
break
print(deltaG)
Note, don't use `tuple` as variable name, as it is a function in Python. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, list, dictionary"
} |
Searching for a Prolog predicate
I need a predicate in Prolog, that produces progression like:
[0, 0.1, 0.2 , 0.3, ..., defined end].
I only know the built-in between/3, but that produces only integers like 0,1,2,3...
Thanks for your help!! | Here is a reduction to between (no error checking and it may have some precision errors for some floating point numbers):
between_step(First, Last, Step, Var) :-
NrSteps is integer((Last - First) / Step),
between(0, NrSteps, TempVar),
Var is First + Step * TempVar.
Some usage examples:
?- between_step(2.5, 3, 0.1, X).
X = 2.5 ?;
X = 2.6 ?;
X = 2.7 ?;
X = 2.8 ?;
X = 2.9 ?;
X = 3.0
?- findall(X, between_step(0, 1, 0.1, X), Xs).
Xs = [0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0]
yes | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "prolog"
} |
What happens when square root is performed in inequalities?
Simplify: $x^2 > 1$.
My solution: Taking square root on both sides:
$±x > ±1$
So my results are:
1. $x > 1$
2. $x > -1$
3. $-x > 1$ $\implies$ $(-1 > x)$
4. $-x > -1$ $\implies$ $(1 > x) $
But I strongly feel this is wrong. What is wrong here?
A step-by-step explanation will help me. | You can just go from $x^2 > 1$ directly to $|x| > |1|$.
Now obviously $|1| = 1$, so $|x| > 1$, therefore either $x > 1$ or $x < -1$. | stackexchange-math | {
"answer_score": 5,
"question_score": 7,
"tags": "algebra precalculus, inequality, radicals"
} |
Is Adcolony support windows universal
Currently I'm using a Unity plugin for `Adcolony`. There are 3 platforms that `Adcolony` supports: `iOS`, `Android`, `Amazon`.
My question is: does `Adcolony` currently support Windows universal and can I share my apps with `Adcolony` ads on Windows store? | Short answer is No. We don't support Ads on Windows OS. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "windows, adcolony"
} |
window.open() not working in IE11
I've searched many links for my query. But couldn't get the one I want. Am using in `window.open(url, '_blank')` in my script on click of button(am not using any html here, I want it to be on button click only). Its working in Chrome, IE8. I want to open a new tab in the same window in **IE11**. I don't want to do any settings in Internet Options of IE. Because the script has to work in every system, if I go with manual settings the script won't run in all the systems where ever I test. Is there any bug with IE11 ? | Window.open() itself opens in new tab, Just remove "_blank". Use the below code.
window.open(url); | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 6,
"tags": "javascript, internet explorer"
} |
Does knowing the asker have an impact on answering their questions?
I'm doing some research on Stack Exchange users.
Suppose you know someone, e.g. off site or after already answering a lot of their questions. Would you answer this user's questions only because you know them?
Does anything besides expertise and interest influence your decision to answer a question? | I don't generally discriminate against individual people when deciding which questions to answer.
When I answer something, it's because:
* I happened upon the question
* The question is well-posed and doesn't take long to understand
* The answer wouldn't take long to write
* I'm in a good mood
* I have the free time
If all of these conditions are met, I'll answer.
If all of these conditions are _mostly_ met, and the OP is an individual of high standing and who has been helpful in the past, I may consider answering anyway because they have earnt some quantity of leeway with me.
If the OP is in my personal blacklist, I will not answer or respond in any way even if the above conditions are met. They've done something in the past which has left me feeling, frankly, that they don't deserve my free time. After all, it's mine to give as I see fit. Nobody's entitled to free help.
* * *
But that's just me. Everybody has their own reasons for playing. | stackexchange-meta | {
"answer_score": 25,
"question_score": 6,
"tags": "discussion, answers"
} |
What is the correct way to declare this?
What is the correct way to declare this? My errors are marked with `**asterisks**` (since bold does not work in code snippets)
I would greatly appreciate any help anyone can give me.
setContentView(R.layout.**activity_main**);
currentX = (TextView) findViewById(R.id.**currentX**);
currentY = (TextView) findViewById(R.id.**currentY**);
currentZ = (TextView) findViewById(R.id.**currentZ**);
maxX = (TextView) findViewById(R.id.**maxX**);
maxY = (TextView) findViewById(R.id.**maxY**);
maxZ = (TextView) findViewById(R.id.**maxZ**);
} | looks like you have imported the wrong **R** file is imported R file is of your project or **android.R** Look and import correct **R** file that is your package name ( **com.example.R** ) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -6,
"tags": "android, android layout"
} |
Accessing data from URL query string
How can I use query string variable in second page? For example in page 'a.php' I have generated these links
<?php
echo '<a href="www.domain.com/b.php?id=1">Comedy</a>';
echo '<a href="www.domain.com/b.php?id=2">Family</a>';
echo '<a href="www.domain.com/b.php?id=3">Action</a>';
Now how I can use the id in page b.php to run a query on database like
SELECT * FROM products WHERE id =
As you can see I need to pass the id getting from the URL query string at here | The ID will be in the $_GET variable:
$sql = 'SELECT * FROM products WHERE id = ' . (int)$_GET['id']; | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "php"
} |
How many solutions does $2^z=1$ has, where z is a non-zero complex number.
Suppose $z=x+i y$
Then $2^z=2^{x+i y}=1$
Now how to proceed further? Is it correct to take $\log_2$ on both sides? Does the RHS, then become zero? | You can write $2$ as $e^{\ln 2}$, so that $2^z = e^{z\ln 2}$. Then $2^z = 1 \Rightarrow e^{z\ln 2} = 1$. Does that help?
As $z = x + iy$, $e^{z\ln 2} = e^{x\ln 2 + iy\ln2} = e^{x\ln 2}[\cos (y\ln) 2 + i\sin (y\ln 2)]$, by using Euler's formula $e^{i\theta} = \cos \theta + i \sin \theta$.
Therefore, $e^{x\ln 2}[\cos (y\ln) 2 + i\sin (y\ln 2)] = 1$. As the imaginary part must be $0$, we have $\sin(y\ln 2) = 0 \Rightarrow y\ln 2 = n\pi \Rightarrow y = n\dfrac{\pi}{\ln2}$, and $\cos(y\ln 2) = \cos n\pi = (-1)^n$.
Thus, $(-1)^n e^{x\ln 2} = 1 \Rightarrow x = 0$ and $n$ is even.
So, $z = \dfrac{2k\pi i}{\ln 2}, k \in \mathbb{Z}$. | stackexchange-math | {
"answer_score": 3,
"question_score": 1,
"tags": "complex analysis"
} |
Problems Mounting NFS Shared Drive Using Fstab (Ubuntu - Lucid Linux)
Currently I have clients hooked up to a server through NFS such that user home folders mount to the clients (if you want more info on that, let me know).
I am trying to set up a shared drive, in which every file and folder can be edited by any user. Therefore, I have this fstab entry:
babbage:/home/Shared /media/shared nfs nolock,rw,dmask=027,fmask=137,relatime 0 0
I used the information (regarding fmask and dmask) from this forum post
<
However, whenever I use any form of *mask, the drive does not mount (I know this because when I remove the *mask, the drive mounts, however with incorrect permissions).
Any ideas how I can solve this issue?
Thank you. | dmask and fmask are only applicable for FAT and NTFS partitions.
In short, there's no simple way which I can think of to do exactly what you are saying while preserving ownership information. If file ownership information is not important then you could setup the NFS export with the `all_squash` option (assuming you're using Linux for your NFS server):
/home/Shared *(rw,all_squash)
This would effectively make all file accesses (reads, writes, creates, etc) run as the anonymous user on the NFS server. `/home/Shared` would need to readable/writable by the anonymous user on your system (probably `nfsnobody` on Linux), either by setting ownership or by setting world rwx permissions. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 0,
"tags": "permissions, ubuntu 10.04, nfs, share, fstab"
} |
Reading plotting files (CTB/STB) using autodesk object ARX or executable
Hello I am working on developing an application that involves usage of plot files **(CTB/STB)** from autocad. Plot files have color mapping in it and i need a way to read it programatically May be a API or executable to read CTB STB file? | There are two things I would suggest:
1. Take a look at the list of all the formats supported by the Model Derivative service: < If your file format is there, you can use the Model Derivative service directly to convert your plotting files into a format viewable by the Forge Viewer.
2. If the format can be processed by AutoCAD (or Inventor, Revit, or 3ds Max), and if you could implement an AutoCAD plugin reading/converting your files, you could then use the Forge Design Automation service to run AutoCAD with that plugin remotely, on the Autodesk servers, in an automated way. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "autodesk forge, autocad plugin, objectarx"
} |
What are the Differences Between "php artisan dump-autoload" and "composer dump-autoload"?
I am pretty new to Laravel 4 and Composer. While I do Laravel 4 tutorials, I couldn't understand the difference between those two commands; `php artisan dump-autoload` and `composer dump-autoload` What's the difference between them? | `Laravel's` `Autoload` is a bit different:
1. It will in fact use `Composer` for some `stuff`
2. It will call `Composer` with the optimize `flag`
3. It will '`recompile`' loads of files creating the huge `bootstrap/compiled.php`
4. And also will find all of your Workbench packages and `composer dump-autoload` them, one by one. | stackexchange-stackoverflow | {
"answer_score": 179,
"question_score": 200,
"tags": "php, laravel, laravel 4, laravel artisan"
} |
How do I get technical information on my video card? (Model, RAM, Mhz, etc)
I'd like to get as much technical information about my MacOSX's video card as possible... technical details, even serial number if the card has a unique identifier.
I intend to use this information do research what GPU specific commands I can run on a given laptop. | Click on the Apple icon in the upper left hand corner of your menu bar and select `About This Mac` from the menu.
In the dialog that appears click on the `More Info...` button to bring up the detailed about dialog.
!enter image description here
Click on the `System Report...` button and you'll get a split-window dialog that has hardware components down the left side and details on the right.
!enter image description here
Click on `Graphics/Displays` on the left. Pick a graphics card from the right side and you'll see all the details the system provides about it.
!enter image description here
You can also get to the System Report by running Applications -> Utilities -> System Information. | stackexchange-apple | {
"answer_score": 12,
"question_score": 12,
"tags": "mac, hardware, video adapter, system information"
} |
jQuery - find not a function?
could someone please explain why the following code is throwing an error?
// JavaScript Document
$(document).ready(function(){
$(".port-box").css("display", "none");
$('ul#portfolio li a').bind('click', function(){
var con_id = $(this).attr("id");
if( con_id.length !== 0 ) {
$.get('./act_web_designs_portfolio', function(data){
var content = data.find("#" + con_id + "-content").html();
alert(content);
});
return false;
}
});
});
Firefox says:
> data.find is not a function
Any help much appreciated, regards, Phil | `data` is going to be a string.
If you're expecting `data` to contain HTML, try
var content = $(data).find(....) | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 6,
"tags": "jquery, get, find"
} |
two lines in a button text with different sizes
I found reference by googling that led me to think the following would give me 2 lines of text in a button, first line normal size and second line smaller. However it just wraps all the copy and in the same size. any suggestions please? This is the line in my strings.xml
<string name="teststr"> String I am testing\n <small><small>(with a sub comment)</small></small></string> | You can use
myButton.setText(Html.fromHtml("String I am testing<br/><small>(with a sub comment)</small>"));
or to read the string from your strings.xml
myButton.setText(Html.fromHtml(getString(R.string.teststr)));
Remember that you need to use <br/> instead of \n to get a new line. | stackexchange-stackoverflow | {
"answer_score": 20,
"question_score": 17,
"tags": "android"
} |
Customizing portal's navigation bar
I want to customize the navigation bar in my theme. I searched for the CSS file that styles the navigation bar in the css directory but I couldn't find it.
In the `nagivation.vm` file, the navigation is declared as follows:
<nav class="$nav_css_class" id="navigation">
and using firebug I found out that the class is
`sort-pages modify-pages`.
I appreciate your help.
Thanks | The css file is called `css/navigation.css`. However, best practice is to do all modifications in `_diffs/css/custom.css` \- this file is loaded last and all settings in there will override those in navigation.css and any other files. As a side effect, you'll have all of your settings neatly separated from Liferay's and are in a better position during updates.
custom.css is supposed to be empty in all themes that are meant for extension. If you start with the classic theme, you'll see that custom.css in there is not empty - this means, that the classic theme is not meant to be extended. Technically you can still do so of course, but Liferay might change this theme without notice in future versions and you'll end up upgrading then. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "liferay, liferay 6, liferay velocity, liferay theme"
} |
What high-level enemies respawn in Borderlands?
Much like this question's author, I'm interested in gaining good XP at a high level. But rather than doing challenges (which often get done in the course of normal playing, especially the _'kill X of Y'_ type) I'd prefer to do it specifically by fighting enemies.
George Stocker mentioned in his answer that Motorhead respawns every 15 minutes, but surely he can't be the only unique enemy/boss who respawns. Skyscraper giving 23k XP would be great but as far as I know he's a one-off. It seems that an exhaustive list of respawning enemies would be quite useful.
Is there a list of farmable enemies, and where to find them? | All enemies respawn when you exit/reenter the game (with the possible exception of the destroyer). Some respawn if you simply leave the area (such as Crawmerax). If you have the Secret Armory of General Knoxx DLC, I would suggest farming crawmerax (best experience, and the only way to reach max level of 69). The added bonus is he also drops a lot of high level loot, including pearlescent weapons. | stackexchange-gaming | {
"answer_score": 2,
"question_score": 3,
"tags": "borderlands"
} |
Does this time format look familiar?
Can someone help me tell what datetime format is this, or what are it's parts?
e.g.
* `201106020539Z0000031552001001`
* `201106020702Z0000000000001`
* `201105140701Z0000000000001`
* `201105170207A0000018560001001`
I think I've got the first few parts (`201106020539` is `yyyymmddhhmm`), but from the `Z` / `A` character onward, I have no clue. Is it possible that the rest isn't a datetime at all? | The Z implies Zulu or UTC time < as for what comes after, I don't know since all other time data has already been indicated prior to the Timezone Character.
Also, the fact that your timestamps don't seem to end in the same number of characters suggests they might not be the same format/spec? Where did you obtain them? | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "datetime, format"
} |
Silverlight 3 missing ScrollViewer.ScrollChanged event workaround?
I want to be notified of changes to the VerticalOffset of the vertical scrollbar of a ScrollViewer. In WPF there is a ScrollViewer.ScrollChanged event, but in Silverlight 3 this is missing. Does anyone know a workaround? | You can use element binding, here is a daft example:-
<Grid x:Name="LayoutRoot" Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60" />
</Grid.RowDefinitions>
<ScrollViewer x:Name="ScrollSource">
<StackPanel>
<TextBlock>Hello</TextBlock>
<TextBlock>World</TextBlock>
<TextBlock>Yasso</TextBlock>
<TextBlock>Kosmos</TextBlock>
</StackPanel>
</ScrollViewer>
<TextBox Grid.Column="1" Text="{Binding VerticalOffset, ElementName=ScrollSource}" />
</Grid>
As the `ScrollViewer` is scrolled the Text property of the TextBox is advised of the new value. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 9,
"tags": "silverlight, scrollbar, scrollviewer"
} |
How to redirect page from view
how do I redirect a page from my views.py? Since each view method expects a response, how would I go about returning to the home page as an example (127.0.0.1:1234/) | Found it in the documentation: (of course after I ask , google gives me an answer..(did google beforehand))
exc.HTTPFound(request.route_url("home")) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, pyramid"
} |
Modify .suo file
I need to modify a .suo file.
Basically, I have a client-server application. The client needs a "cookie" to log into the server, which is generated every day and retrieved on the client machine by another process. This "cookie" needs to be set in the "Debugging Command Arguments".
I want to automate this process by modifying the .suo file directly through another app / script. Is there a way I can do this?
I looked at Tool to view the contents of the Solution User Options file (.suo), but that did not help much. I have no idea about those methods and would need a bit more direction. | I think that the Command Line Debug parameters are stored in the proj.user file, yeah? That's just an XML file and should be easy enough to modify. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "visual studio, suo"
} |
how to get responsive equal borders with imgs?
!Borders
This is what I Tried, but the borders are not equal.
.foo{
width: 100%;
height: 100%;
background: #999;
padding-left: 2%;
padding-top: 2%;
}
img{
width: 47%;
margin-top: 0;
margin-bottom: 2%;
margin-right: 2%;
padding: 0;
}
and the html:
<div class="foo">
<img src=" alt="">
<img src=" alt="">
<img src=" alt="">
<img src=" alt="">
</div>
<
or maybe my approach is bad | **DEMO:<
**CSS**
body {
margin: 0;
padding: 0;
}
.foo {
width: 100%;
height: 100%;
background: #999;
box-sizing: border-box;
padding: .5%;
}
img {
width: 50%;
float: left;
padding: .5%;
box-sizing: border-box;
}
.clear {
clear: both
}
**HTML**
<div class="foo">
<img src=" alt="">
<img src=" alt="">
<img src=" alt="">
<img src=" alt="">
<div class="clear"></div>
</div> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "html, css, layout, responsive design"
} |
Image of the multiplication of a function by a scalar
$f$ is a linear function that maps from a vector space $E$ to $E'$. How can I prove that $\operatorname{Im}f = \operatorname{Im} \alpha f$?
Lets say that $f(a,b,c) = (2a, 2b, 2c)$, the image is $(2a, 2b, 2c)$. Now $2\cdot f(a,b,c)$ has image $(4a, 4b, 4c)$ which is not the same... | Because clearly $\operatorname{Im}\alpha f\subseteq\operatorname{Im}f$, and the reverse inclusion is true because $f=\alpha^{-1}(\alpha f)$. | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "linear algebra, linear transformations"
} |
Riemann Integrability via Riemann sums
I know that if a bounded function is integrable on a compact interval $[a,b]$ and if $ lim_{||P||\to 0} \sum_{i=0}^n f(t_i) \Delta x_i $ exists
where $||p|| $ is the mesh of a partition $P$ of $[a,b] P=${$x_0=a, x_1, x_2....x_n$}$ n \in N $ and $t_i$ is an arbitrary point in the interval $\Delta x_i=[x_{(i-1)},x_i]$, the definite integral is equal to the limit of the sum say $I$.
But does the converse hold, if the limit holds for any particular choice points $t_i \in \Delta x_i $ does it imply the function is integrable, or should it be proved that for any arbitary point $t_i$ the limit holds and if so is it sufficient to deduce that the function is integrable? | No. For example the function
$$f(x)=\begin{cases}1&,\;\;x\in \Bbb Q\cap [0,1]\\\\{}\\\0&,\;\;x\in [0,1]\setminus\left(\Bbb Q\cap[0,1]\right)\end{cases}$$
isn't Riemann integral in $\;[1,0]\;$ , yet if you get to choose the points in each subinterval of each partition then the corresponding Riemann sums converge.
The definition for Riemann integrability _requires_ the points in each subinterval of each partition **must** be artbitrary.
What you _can_ do is: if you already know the function is R. integrable, then you can freely choose the points in the subintervals. | stackexchange-math | {
"answer_score": 3,
"question_score": 0,
"tags": "real analysis, integration"
} |
How to enable code suggestions in Visual Studio?
I have been working with IntellIJ before. There I get suggestions on which function of my library I might want to use when typing. I noticed that in Microsoft Visual Studio this is not the case. Can I enable it somewhere?
.
If this is not in the drop down, select "Browse..." from drop down, go into Visual Studio installation path, by default in Windows OS "C:\Program Files (x86)\Microsoft Visual Studio\XXX(2017, 2019,....)\Enterprise\Common7\IDE" and select "devenv.exe" file.
Now in the drop down, Visual Studio will have appeared. Close the Preferences window and open the project from "Assets -> Open C# Project". and please check the using too, I hope it helps to solve the problem! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "c#, visual studio, ide"
} |
I would like php to "execute" a variable into a string
I use JSON to organize my PHP code.
I don't know if it's possible but I stocked inside of my Json a PHP variable. I would like to get it in my PHP script.
I've created my JSON file :
{
"link" : "?id=$org_id"
}
In my php, I use the json_decode function. Then in PHP, I stock the result in a variable
Thus,
$org_id = 456;
echo $res; //output "?id=$org_id" while I wanted "?id=456"
What can I do? | `echo strtr($res, array('$org_id' => $org_id));`
Should substitute the string '$org_id' with the variable $org_id | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, json, variables, var"
} |
Display image/media entities view from node to twig template
Would like to ask how I can output or display the image entities from my entity browser/entity view to the twig template. I'm using the `media entity module` on drupal and then using views to select and display the images that are selected.
Apologies if my explanation is bit sloppy since I'm still new to drupal.
**Setup Media Bundle**
 }}">
{% endfor %} | For an image in a media entity you need one step more. Something like this should work:
{% for media in node.field_slider_image %}
<img src="{{ file_url(media.entity.field_image.entity.uri.value) }}">
{% endfor %}
But without debugging tools this is hard to find out. You have three nested entities and their field values, the node with the media field, containing media entities with the image field, containing file entities, where you finally find the uri field.
An easier options might be to let Drupal do the rendering by configuring this in UI and theme the field, not the node. | stackexchange-drupal | {
"answer_score": 2,
"question_score": -1,
"tags": "media"
} |
Dúvida sobre métodos e classes estáticas
Tenho uma duvida sobre métodos e classes estáticas, dado o código abaixo:
static List<MaterialRCM> mr = new List<MaterialRCM>();
[Authorize]
public void AddMaterial(int Qtd, int Id)
{
mr.Add(new MaterialRCM(Id, Qtd));
}
Agora, como classes e métodos estáticos não são tipos por referencia, se dois usuários utilizarem a mesma funcionalidade corre o risco de na lista ter dados dos dois usuários? Pra ficar mais claro, esse método é chamado via Ajax, cada vez que o usuário adiciona um material esse método é chamado e adiciona o Id do Material e a quantidade na lista, e se dois usuários estiverem solicitando materiais? | Sim, não apenas se dois usuários mas qualquer requisição feita ao servidor vai acessar exatamente o mesmo valor.
No geral não é recomendado usar variáveis estáticas com o ASP.Net, não apenas por ter um único valor para todas as requisições mas também pelo fato de poder causar problemas de concorrência, já que o valor poderia ser acessado e modificado por mais de uma thread ao mesmo tempo, se você precisa manter valores no servidor eu diria para usar alguma outra forma, como Session por exemplo. | stackexchange-pt_stackoverflow | {
"answer_score": 1,
"question_score": 3,
"tags": "c#, asp.net mvc, orientação a objetos"
} |
Bash script to compare two text files
I'm trying to write a condition to compare two text files (simple "if [ file1 == file2 ]" doesn't work I think), I need to open those files, and then compare them. Can anyone help me? | Why can't you use built-in `diff` command like
diff file1.txt file2.txt | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "bash, file"
} |
hiding a div with certain time bound
> **Possible Duplicate:**
> how to hide a div after some time period?
i need to hide a div (like mail sent successfull in gmail)after certain time period when i reload the page ? any body please help me by giving codes.. | Try this:
var timePeriodInMs = 4000;
setTimeout(function()
{
document.getElementById("myDiv").style.display = "none";
},
timePeriodInMs); | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -5,
"tags": "javascript"
} |
how to return results like google?
i wonder how you get the search results that is highlighted like Google?
They search a text for the keyword you entered and then chop the text some nr of letters before and after the keyword and highlight it?
How do you accomplish that with PHP. What functions should you use to search the keyword and then return a specific length before and after the keyword? | > They search a text for the keyword you entered and then chop the text some nr of letters before and after the keyword and highlight it?
Yes
> How do you accomplish that with PHP. What functions should you use to search the keyword and then return a specific length before and after the keyword?
It's not done only with PHP, you'll need ajax too. There are several jquery plugins available (search for jquery dropdown search)! | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "search, full text search, keyword"
} |
Files take up more space on the disk
When viewing details of a file using `Finder`, different values are shown for how much space the file occupies. For example, a file takes up 28.8KB of RAM but, 33KB of the disk. Anyone know the explanation? | Disk space is allocated in blocks. Meaning, in multiples of a "block size".
For example, on my system a `1 byte` file is `4096 bytes` on disk.
That's `1 byte` of content & `4095 bytes` of unused space. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "macos, disk, ramdisk"
} |
Can I tell the inner diameter of my 1" head tube without removing the headset?
I need to replace my 1" threaded headset, but to my surprise the replacement headset is available for either 30.0mm or 30.2mm inner head tube diameter. Is it possible to tell which one I need without removing the headset cups? | Probably not.
Knowing the manufacturer of your bike gives a clue but not always definitive.
One is the Italian size and more common. The other is Japanese. | stackexchange-bicycles | {
"answer_score": 3,
"question_score": 2,
"tags": "headset"
} |
jQuery(this).find('title').next().next().next().eq(0).text();?
what's the better/elegant way to do this?
jQuery(this).find('title').next().next().next().eq(0).text(); //THIS WORKS
i tried using
`jQuery(this).find('title').eq(3) //DOESN't WORK`
but it doesnt... | What about `nextAll().eq(2)` ? That should be the third item. And append `.text()` afterwards. If that's not it, can you provide the markup? | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 1,
"tags": "jquery, jquery traversing"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.