INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Custom images with UISlider doesn't show on the device
Everything works on the simulator without a problem. However when I put it on my device it only show the `ThumbImage`. It is just really strange. I'm thinking this could be a iOS version issue or memory issue. My device is iPhone 3GS iOS 4.1. Xcode Version 3.2.5.
@interface BlueChalkSlider : UISlider {}
@end
@implementation BlueChalkSlider
- (id)initWithCoder:(NSCoder *)decoder {
if ((self = [super initWithCoder: decoder])) {
self.backgroundColor = [UIColor clearColor];
[self setThumbImage:[UIImage imageNamed:@"Chalk.png"] forState:UIControlStateNormal];
[self setMinimumTrackImage:[UIImage imageNamed:@"ChalklineBlue.png"] forState:UIControlStateNormal];
[self setMaximumTrackImage:[UIImage imageNamed:@"ChalklineWhite.png"] forState:UIControlStateNormal];
}
return self;
}
@end
|
Problem Solved!!!
The simulator is NOT case sensitive. The Device is case sensitive. I've changed and make sure all my filenames are exactly the same with Case Sensitive.
e.g. `Chalkline` should be `ChalkLine`
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 2,
"tags": "ios, custom controls, uiimage, uislider"
}
|
Configuring address and ports for JGroups
When using JGroups, with a component such as Infinispan, it is possible to configure the ports and addresses that JGroups will use.
For example:
<UDP
mcast_addr="${jgroups.udp.mcast_addr:228.6.7.8}"
mcast_port="${jgroups.udp.mcast_port:46655}"
...
But here is what is confusing me. How can all members of the cluster all use the same port, addr?
I would have thought each member would have its own port and have to know the ports (and addresses) of the other members it needs to talk to?
Thanks
|
Multicast is a special address that can be used by multiple nodes to send/received data - think of it like 127.0.0.1, which is also available on most boxes with network installed.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 3,
"tags": "infinispan, jgroups"
}
|
Why is the value in the loop never greater than 2?
I have the loop below, the value of `unique` is never greater than `2`. `n` is the total number of integers in the array (I read integers from a file line by line).
I am completely stumped and have been for a long time. Why is the value of `unique` never greater than `2`?
int last = array[0];
int unique = 1;
int i;
for (i = 1; i < n; i++) {
if (array[n] != last) {
last = array[n];
unique++;
printf("i:%d\n", i);
printf("n:%d\n", n);
printf("last:%d\n:", last);
}
}
printf("unique:%d\n", unique);
OUTPUT:
i:1
n:9
last:0
:unique:2
i:1
n:4
last:4
:unique:2
i:1
n:5
last:4
:unique:2
i:1
n:5
last:4
:unique:2
i:1
n:5
last:4
:unique:2
unique:1
i:1
n:20
last:0
:unique:2
|
You mistyped the array index: use `array[i]` instead of `array[n]`.
Here is a simpler version:
int unique;
for (unique = 1; unique < n && array[unique] == array[unique - 1]; unique++) {
continue;
}
printf("unique:%d\n", unique);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c, arrays, if statement, for loop"
}
|
future continuous us present progressive
Could you let me know what mean these two sentences. Are they equal in terms of meaning ?
Next holiday we're staying in a five-star hotel. (the reservation has been made) Next holiday we will be staying in a five-star hotel.
In that case does it mean the reservation has been made
|
The present progressive can refer to future events (as can the simple present), but it's usually more immediate/certain than the future progressive (or simple future).
The present progressive (in your example) might imply the reservation has been made compared to future progressive, but it mostly implies that the plan ("staying in a five-start hotel") is more certain; it's the present plan, so it's stronger than the intention implied by using the future.
|
stackexchange-ell
|
{
"answer_score": 0,
"question_score": 1,
"tags": "grammar"
}
|
Is it possible to append JSX at runtime?
I have a stencil component that needs to append a child to a slotted node. Currently I do it like this:
const x = document.createElemet('x');
slotted.appendChild(x);
But I want to do something like this:
const xJsx = (<x></x>);
slotted.appendChild(xJsx);
The latter won't work because `appendChild` expects an Node, HTMLElement or DocumentFragement but is there a way to convert the JSX and append it at runtime using stencil?
|
Generally no you can't
To elaborate:
JSX is just a syntax, it only exists when you are at an editor writting code, it helps you write this specifc language which is easy to understand by human and later can be translated to javascript and html tags.
When you say runtime, you are refering to browser's javascript runtime, browser's JS engine don't know what is JSX. As a result it doesn't work.
Now here's what babel come to the play: it translates your JSX syntax code into javascript that browser support. And it happens in build time. (you prebuild it)
The reason I said "Genrally" is, no one stops a person try to use babel to transpile JSX in browser with some hack... however I personally wouldn't recommand it since it's very inefficient and need a lot of work to have it working
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, jsx, appendchild, stenciljs"
}
|
inject update-motd.d 00-header to run a script on ssh login
Is there a way to inject the 00-header to trigger a script that executes a shell upon ssh login.
I'm facing a scenario where the 00-header has root privileges and I can modify it. I'm trying to have it spawn a root shell when I ssh into the machine as a regular user.
sysadmin@********:/etc/update-motd.d$ echo "/bin/bash -i" >> 00-header
That didn't work... it didn't trigger a shell when I ssh'd into the machine... it did edit the 00-header file
|
echo "cp /bin/bash /home/name/bash && chmod u+s /home/name/bash" >> 00-header
Logging back out and in resulted in bash sitting in name home folder, with the suid bit set, and got to root via `./bash -p`.
|
stackexchange-security
|
{
"answer_score": 0,
"question_score": 1,
"tags": "ssh, privilege escalation"
}
|
What are these female connectors called?
I need help finding out what these female connectors/attachments are called so that I can buy them for my air tank project. Basically these are found on those portable air compressors which connect to schrader valves by screwing them on. I don't want those quick connect head types, just the regular screw on types where the knurled part rotates freely without rotating the hose attached to it. The hose I will be using is the 1/4" compressor hose and the valve I have is the generic tubeless tyre schrader valve.
I initially thought these were called barb connectors but I found out they don't have that push pin inside them which releases the air once the connector is tightened to the schrader valve.
Here are some images

if im.mode != "L": # rescale 16 bit tiffs to 8 bits
im.mode = "I"
im = im.point(lambda i: i * (1.0 / 256))
im = im.convert("RGB")
im.save("example.jpg", "JPEG", quality=100)
Here's an example of an offending image (which appears to be converted to PNG on upload to the site):

if im.mode not in ("L", "RGB"): # rescale 16 bit tiffs to 8 bits
im.mode = "L"
im = im.point(lambda i: i * (1.0 / 256))
im = im.convert("RGB")
im.save("example.jpg", "JPEG", quality=100)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, python imaging library, jpeg, tiff"
}
|
What is the equivalent of bash's !$ and !! in the fish shell?
I've been using bash for a decade or so and have gotten used to being able to type !$ to repeat the last argument, e.g.:
$ mkdir foo
$ cd !$
cd foo
(That last line is printed by the shell to tell you what your command evaluated to). Likewise I often to the following:
$ make_sandwich
-bash: make_sandwich: Permission denied
$ sudo !!
sudo make_sandwich
I'm really liking the fish shell, but my muscle memory is pretty established. Is there an equivalent in fish? Can I configure fish to use the same commands?
|
`Alt`-`Up arrow` gives you the last argument from the previous command. Subsequent pushes cycle throught prior arguments.
I haven't found a satisfactory equivalent to `!!`, except `Up` then `Ctrl`-`A`
|
stackexchange-superuser
|
{
"answer_score": 39,
"question_score": 43,
"tags": "command line, bash, shell, fish"
}
|
Adding a Huge Dataset into Oracle Database
I have a huge data set of two number sets ~ Millions that need to be processed at one time in a batch.
Is using an ArrayList of objects the best way to store these objects into memory then into a database
List<Object> objects = new ArrayList<Object>()
objects.add(new Object("101", "101"))
I then read these items one by one into a database using Spring's jdbcTemplate.
for(Object object: objects)
jdbcTemplate.update("INSERT INTO TABLEOFNUMBERS(ITEM1, ITEM2) values(?, ?)", object.get1(), object.get2();
Is there any way that I can get this added into the database at a quicker rate?
|
This is how I ended up doing it using Spring's JDBC Template.
jdbcTemplate.batchUpdate("INSERT INTO TABLEOFNUMBERS(ITEM1, ITEM2) values (:1, :2)",
new BatchPreparedStatementSetter() {
public void setValues(PreparedStatement ps, int i ) throws SQLException {
ps.setString(1, batch.get(i).getITEM1());
ps.setString(2, batch.get(i).getITEM2());
}
public int getBatchSize() {
return batch.size();
}
});
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, oracle, jdbc, dataset"
}
|
I can't write in Windows partition, but I've done it before
Before, I could save images downloaded from the web in the Windows partition. Even I could transfer files and all that. But today, I can't do it anymore.
Some days ago, I was trying to resize Ubuntu and Windows partition. I downloaded GParted, and I tried to shrink the Windows partition, then increase the Ubuntu partition, but as I couldn't do that, I never applied the Windows' shrinking.
I mentioned this because I think it caused this problem. When I tried to transfer some file or save an image from the web as I did before, there appears a message which says the partition has no writing permission, that is read-only, or something like that.
Could someone help me? If you need more specific info, ask me please.
|
I already solved it. I looked up on the web, and this worked. < Unfortunatelly, I don't do it methodologically. First I went to Synaptic and searched ntfs, such as indicated in the link. But at the same time, I was uninstalling GParted. It seems GParted installs others things with it, wich affects the default writing permissions on ntfs. So I don't know exactly what solved the problem. After that, I tryed to "write" on the Windows partition and I get the same message. Then I reboot hoping it was all needed, and it was so. I can write on Windows partition again.
|
stackexchange-askubuntu
|
{
"answer_score": 1,
"question_score": 1,
"tags": "partitioning, permissions"
}
|
Does JPA only refer to RDBMS
JPA is all about data persistence; is data persistence only limited to RDBMS ? if not what are all the different persistence mechanisms (like Excel,File System,XML, NON RDMS etc ..) we can achieve with JPA specifications ?
|
JPA is designed for RDBMS, and looking at the API and metadata you can see that this is the case. It is possible to apply JPA to other datastores, but approximations have to be made for some concepts, particularly when querying. On the other hand the JDO API was designed for all datastores, and such approximations don't have to be made.
DataNucleus was the first implementation to provide JPA across a range of other datastores (Excel, ODBMS, ODF, LDAP, BigTable, HBase, MongoDB, etc), and has provided these for the last 2+ years. It also provides JDO access for the same datastores.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 2,
"tags": "java, jpa"
}
|
Inputting document-term frequency matrix in TfidfVectorizer()?
I am coming up with a made-up example of bag of words from three documents (I am demonstrating how tf-idf works given a document-term frequency matrix), and I want to transform my bow matrix into a tf-idf matrix. I don't actually have text data, just the number I made up in my example? How can I use that to produce tf-idf output? I am getting the error message "'numpy.ndarray' object has no attribute 'lower'" on the last line (and I am assuming it is because `fit_transform` is expecting text data. Is it possible to specify or override this somehow?
bow = np.array([[15,0,5,0,20], [20,30,0,25,0], [15,10,10,20,15]])
vectorizer = TfidfVectorizer()
vectorizer.fit_transform(bow)
|
You can use TfidfTransformer instead of TfidfVectorizer.
from sklearn.feature_extraction.text import TfidfTransformer
import numpy as np
bow = np.array([[15,0,5,0,20], [20,30,0,25,0], [15,10,10,20,15]])
transformer = TfidfTransformer()
transformer.fit_transform(bow)
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, scikit learn, tf idf, tfidfvectorizer"
}
|
How to avoid RewriteRule for specific directory?
This is my current `.htaccess` data.
# permalinks
RewriteEngine on
# users
RewriteRule ^([a-z0-9_-]{2,15})$ /user.php?username=$1 [QSA,L]
Which obviously means that
is parsed as:
The website also has an **inc** directory in the root, and if I open this url
it actually redirects to:
How can I avoid that behavior for existing directories that are in the root of the website?
|
> How can I avoid that behavior for existing directories that are in the root of the website?
Use:
# permalinks
RewriteEngine on
# skip all files and directories from rewrite rules *below*
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^([a-z0-9_-]{2,15})$ /user.php?username=$1 [QSA,L]
# more rules here
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "apache, .htaccess"
}
|
sqlalchemy Lambda module import error
I am trying to connect my redshift database from AWS Lambda function. I am getting below error when I try to achieve the connection.
**Unable to import module 'lambda_function': No module named 'sqlalchemy'**
Below is the import code that I am using in my lambda. I have tried all possible import function. Still noting works. Results in the same error.
from __future__ import print_function
import sqlalchemy as sa
from sqlalchemy.orm import sessionmaker
from flask_sqlalchemy import SQLAlchemy
from flask.ext.sqlalchemy import SQLAlchemy as sa
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, String
from sqlalchemy.orm import sessionmaker
|
As 'sqlalchemy' is not a part of AWS SDK you should include it in your deployment package. If you are deploying it as a .zip file then make sure you have included it in the zip
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "python 3.x, sqlalchemy, aws lambda, flask sqlalchemy, amazon redshift"
}
|
How to convert decimal to hex and send hex using expect(TCL) script
I am writing a small expect(TCL) script to send a series of numbers in hex format and expect something. I am iterating over a loop to send the bytes one by one. but I am not able to send the number in hex form.
Below is a sample code. I need to send the first line over a loop with numbers in 0x form. second line is something I tried out.
send "show hardware internal qengine inst 0 memory ib_rr0_span_dc3hdr start 0x0 num 0x2 \r"
expect "#"
for {set i 0} {$i < 16} {incr i 1} {
puts stdout "i val: $i '\x$i'"
}
|
Long time since I did TCL but I believe the following will do what you want
puts stdout [format "i val %d '\x%x'" $i $i]
The %d and %x placeholders are almost the same as you would find in a C printf/sprintf statement and allow such things as leading zeros, field sizes etc
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "linux, shell, unix, tcl, expect"
}
|
Firefox web-extension api captureVisibleTab refturns undefined
I have been trying to create a Firefox add-on using the web extensions API. My add-on should take a screenshot of the current page the user is browsing using chrome.tabs.captureVisibleTab but it returns undefined. They say that its already implemented in the API on < but I can't seem to get it to work.
Here is my code:
chrome.tabs.captureVisibleTab(null, {}, function(data) {
console.log("screenshotData: " + data);
});
I have also tried passing in a window.id as the first parameter even though in the docs it says its optional, but this also returns an undefined value for data.
Does anyone have any experience with this in particular?
|
It works for me in Nightly 49.0a1 (2016-06-04).
Make sure you have the following permission in your manifest.json file:
"permissions": [ "<all_urls>" ]
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "firefox, firefox addon, firefox addon webextensions"
}
|
How can I fourier transform this function, with a special character inside
!picture of function
This is the function I'm dealing with, and I'm wondering what the special characteristics are of one such function, especially when observing the special function name, that would normally be "f".
I'm to fourier transform it, and it shouldn't be too hard except that I think that I have to do something to the function before transforming it because of the unknown special characteristics it might have.
|
\begin{align*} \mathcal{F}\\{e^{-|t|}\\}(\omega) &= \int_{-\infty}^{\infty} e^{-|t|} e^{-i t \omega}\,dt \\\ &= \int_{-\infty}^{0} e^{t(1-i\omega)} \,dt + \int_0^{\infty} e^{-t(1+i\omega)} \,dt \\\ &= \frac{1}{1-i\omega} + \frac{1}{1+i\omega} \\\ &= \frac{2}{\omega^2+1} \end{align*} Is this detailed enough for you?
If what you want is the Fourier transform of $\displaystyle\frac{2}{\omega^2+1}$ then the easiest way to go is certainly to apply the
> **Inversion theorem:** Let $f \in L^1(\mathbb{R})$ such that $\mathcal{F}\\{f\\} \in L^1(\mathbb{R})$. Then, at every point $t$ where $f$ is continuous, we have $$ \mathcal{F}\\{\mathcal{F}\\{f\\}\\}(t) = 2\pi f(-t) $$
Hence \begin{align} \mathcal{F}\\{\mathcal{F}\\{e^{-|t|}\\}\\}(t) &= \mathcal{F}\left\\{\frac{2}{\omega^2+1}\right\\}(t) \\\ &= 2\pi e^{-|-t|} \\\ &= 2\pi e^{-|t|} \end{align} for all $t \in \Bbb{R}$.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "fourier transform"
}
|
Rails routes not matching 'new' pattern with RESTFul routes
I got this error:
No route matches {:action=>"show", :controller=>"video_publications", :campaign_id=[...]
With this url:
/campaigns/514be3834413790249000025/video_publications/new
I have this in the routes:
resources :campaigns do
resources :video_publications
end
I got the error when I am redirecting to:
new_campaign_video_publication_path(@campaign)
I am confused, any ideas?
Using:
* Rails 3.2.11
* Mongoid 3.0.23
|
The error is not in your `new` path, but in your `show` action.
It is complaining about:
:action=>"show", :controller=>"video_publications"
In your code change parts of the code for show action to something like this:
<%= link_to 'Show', campaign_video_publication_path(@campaign, @publication) %>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails, ruby on rails 3, rest, mongoid, url routing"
}
|
When does the commit reference associated with a submodule get updated in its containing superproject?
From reading through the Git documentation (specifically this page, as well as associated command reference pages: < I still felt it was a little unclear exactly when the associated SHA for the submodule, as reported by "git diff --cached SomeSubModule", gets updated, as the text is not very explicit on the subject.
What appears to be implied is that the reference updates when the currently checked out commit in the submodule is changed (such as via a "git submodule update --remote") and then a commit is made in the superproject to reflect this change. However, I would like to verify if that is correct or if I misunderstood.
|
> the reference updates when the currently checked out commit in the submodule is changed
Yes, but not just on `git submodule update --remote`.
It changes if any commit is made (or fetched) in the submodule.
> and then a commit is made in the superproject to reflect this change
More precisely, to add and commit a changed element, that element being the **gitlink** (special entry in the main repo index)
You can also update that gitlink from the parent repo: see "Git Submodule has a wrong reference to its remote repository".
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "git, git submodules"
}
|
Deploy python flask project into a website
So I recently finished my python project, grabbing values from an API and put it into my website.
Now I have no clue how I actually start the website (finding a host) and making it accessible to other people, I thought turning to here might find the solution.
I have done a good amount of research, tried "pythonanywhere" and "google app engine" but seem to not really find a solution.
I was hoping to be able to use "hostinger" as a host, as they have a good price and a good host. Contacted them but they said that they couldn't, though I could upload it to a VPS (which they have). Would it work for me to upload my files to this VPS and therefor get it to a website? or should I use another host?
|
I just deployed my first app and used Heroku. I'm very happy with it so far and it was fairly straight forward to set up. It does require a basic git understanding but was not hard to learn
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "python, web, flask, hosting"
}
|
construction of Martingales
Consider a random sample of independent and identically distributed random variables with mean 1 . Consider another random variable which is the product of the first n of such random variables as these. Show that the second random variable forms a Martingale.
To answer this question I considered that the expectation of the product is the product of expectations and hence it is one which is a real number.
Now the the expectation of the future random variables given all the past is the expectation of the present given the present which is just the present.
Is that proof okay
|
We have the "sample" $X_1, X_2, \dots$ Now define $Y_n := X_1 \cdot X_2 \cdots \cdot X_n$
Let $\\{ \mathcal F_n\\}$ be generated by $\\{X_n \\}_{n\geq 1}$. In particular that makes $Y_n$ $\mathcal F_n$-adapted. Then we have $E[Y_{n+1} \mid \mathcal F_n] = E[Y_{n}\cdot X_{n+1} \mid \mathcal F_n]$. Since $Y_n$ is $\mathcal F_n$-measurable, $$ E[Y_{n}\cdot X_{n+1} \mid \mathcal F_n] = Y_{n}\,E[X_{n+1} \mid \mathcal F_n] = Y_n\,E[X_{n+1}]=Y_n $$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "probability"
}
|
$\frac{{\sin \theta \cos \theta}}{1!}+\frac{{\sin 2\theta \cos ^2\theta}}{2!}+\frac{{\sin 3\theta \cos ^3\theta}}{3!}+...\infty$
I have tried replacing $\ x$ with $\cos x$ in the maclaurin series of $\ e^x$, but stuck with the $\sin$ terms. Is there any other method to solve this question.
|
Try $x\rightarrow \cos \theta \cdot e^{i\theta}$ in the same Maclaurin series. Then the imaginary part is what you are looking for.
$$e^{\cos\theta(\cos\theta + i\sin\theta)}=1+\frac{\cos\theta(\cos\theta + i\sin\theta)}{1!}+\frac{\cos^2\theta(\cos2\theta + i\sin2\theta)}{2!}+\frac{\cos^3\theta(\cos3\theta + i\sin3\theta)}{3!}+...$$
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 7,
"tags": "sequences and series, complex numbers, taylor expansion"
}
|
Re-Enable Visual SVN in Visual Studio 2017
I installed Visual SVN for `Visual Studio 2017`. It was working fine. After some days, i got a message box in visual studio to disable the `Visual SVN` for best performance. I disabled it but now, i don't know how to enable it again.
I tried installing `Visual SVN` again but it says that it is already installed. I checked the **Tools -> Options -> Source Control** but it has only `TFS` and `Git` options and didn't find the Visual `SVN` options.
Any help would be appreciated.
|
You should be able to re-enable Visual SVN in **Tools** \- **Extensions and Updates**.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "visual studio, svn, visualsvn"
}
|
Django: what is the most appropriate way to provide administrators with the ability to change small snippets of text
Using Django, what is the most appropriate way to provide administrators with the ability to change small snippets of text, for example in one of my sites there is a small piece of text on the front page I would like the administrator to be able to easily change in the backend, however I do not want to create a whole new app or model because then they would be able to create more than one area of text in this way, but I only want it to show up in one place on the homepage.
Any advice?
|
This might be a bit more than you're looking for, but django-chunks lets you embed snippets of text into your templates and allow administrators to edit them. Because the only way to put a chunk into a template is by embedding it yourself, you don't have to worry about someone creating additional chunks - they just won't show up anywhere on the site.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "django, django models, django admin"
}
|
How to find the tangent space of a general submanifold?
Given a submanifold $(S,\phi)$ of a manifold $M$, how do we find the subspace of $T_pM$ that is equal to $T_pS$ for $p\in \phi(S)$. I know how to do it for level sets. Is there a way for general submanifolds?
|
For a point $p \in \phi(S)$, put local coordinates $(x_1,\dots,x_n)$ on $S$ around the point $\phi^{-1}(p)$. Then the tangent space $T_{\phi^{-1}(p)}S$ is spanned by $\frac{\partial}{\partial x_1}, \dots, \frac{\partial}{\partial x_n}$. The tangent space $T_p\phi(S)$ as a subset of $T_pM$ should then be the image of $T_{\phi^{-1}(p)}S$ under the pushforward map $\phi_*$. That is, the space you are looking for should be the linear span of $\phi_* \frac{\partial}{\partial x_1}, \dots, \phi_* \frac{\partial}{\partial x_n}$ in $T_pM$.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 3,
"tags": "differential geometry, manifolds, smooth manifolds"
}
|
HTML5, take images from one div and put into another right aligned
When I put images from one div to another, they are left aligned. I want them right aligned .
|
Code below will show you the image is floated right.
**Code:**
<style>
img {
float: right;
}
</style>
<p>In this example, the image will float to the right</p>
<p><img src="someimage.jpg" alt="image" style="width:100px;height:100;margin-left:15px;">
Text blablabla. Lorim Ipsum...</p>
Just copy paste this and see the result. From there on you can edit your CSS.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "html, alignment"
}
|
Creating custom size PDF document with Debenu Quick PDF
Hi I am using Debenu Quick PDF Lib. I couldn't see any sample or info about creating custom size PDF document. For example I want to create a new document in size of 80mm x 100mm in 300 dpi. Is that possible with QP ?
Thank you .
|
user3253797,
QP.SetMeasurementUnits(1); // Set the measurement units to mm QP.SetPageDimensions(80.0, 100.0); // Set the page size to 80mm x 100mm
In a PDF file there is no DPI value as nearly all the values in a PDF are based on floating point numbers.
When SetMeasurementUnits is set to 1 then all values you use for drawing are assumed to be in millimetres. ie. QP.DrawLine(0, 0, 25.4, 25.4); will draw a diagonal line from the bottom left corner (0,0) to a point 1 inch up and 1 inch to the right of the bottom corner of the page. If you need the Origin to be based a the top right then you need to call QP.SetOrigin(1); first.
Also, the "Debenu Quick PDF Library 10 Developer Guide.pdf" is the perfect place to start to learn about Debenu Quick PDF Library. It explains the basics of creating PDF files using the library and some of the fundamentals of PDF files.
Andrew.
Disclaimer: I work for Debenu.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#"
}
|
Renomear tabela no firebird
Como renomear tabela no `firebird 2.5`?
Estou usando a `query`: `ALTER TABLE cliente RENAME TO clientes;`, mas aparece o erro:
> invalid toke 'rename'.
|
Victor,
conforme o FAQ do Firebird não é possível renomear tabela no firebird, conforme informado neste link. Você pode criar uma nova tabela ou uma view selecionando dados da tabela antiga.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 1,
"question_score": 4,
"tags": "sql, banco de dados, firebird"
}
|
angle of rotation and axis of rotation of 3x3 matrix
\begin{pmatrix} √ 3/2 & -1/4 & √3/4\\\ 1/2 & √3/4 & -3/4\\\ 0 & √3/2 & 1/2 \end{pmatrix}
I have found the angle of rotation to be Cos^-1 (3√3 + 2)/8. Can anyone verify if this is correct? Also I am struggling to find the axis of rotation after getting 2 different answers.
|
Using the formula $${\rm trace}(A)=1+2\cos\alpha$$ gives $$\alpha=\pm\cos^{-1}\Bigl(\frac{3\sqrt3-2}{8}\Bigr)\ .$$ The sign will depend on which direction you take for the axis. Also **note** : I have not checked but am taking your word for it that this is a rotation matrix, if not then this answer will be meaningless.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "geometry"
}
|
Using Multiple T-SQL Statements in ADO.NET
Scripting in management studio with T-SQL works very well, but I am having a question about ADO.NET.
I am able to code a simple select statement in ado.net.
How to use the set statement in ado.net ?
e.g.
SET @polygon = (SELECT GEOM FROM Polygons WHERE NAME = 'Area1');
SELECT NAME FROM Points WHERE @polygon.STDistance(GEOM) <= .4;
|
If you put that in one big sql string that you assign to an SqlCommand object's command text and run in one function call, it should run fine: just like it would in management studio.
If you try to run it in two seperate SqlCommand objects or run over SqlCommand function calls, the 2nd command won't know anything about the first anymore.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "tsql, ado.net"
}
|
Android Gallery Background
I have followed a gallery tutorial and have it working fine, but the problem that I need help solving is that I want to change the background colour of the gallery. If I just use:
setBackgroundColor(Color.BLACK);
then it messes up and I lose the border also. I want to keep the border, but change the colour from the default grey. I've also tried using different resources such as:
R.styleable.gallery1_android_colorBackground
but that also does not work. Does anyone have any idea how to solve this?
Cheers
|
In your `getView()` from your `ImageAdapter`add the following attribute:
imageView.setBackgroundColor(Color.BLACK);
Hope this help.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, android layout, android gallery"
}
|
Elementary Number Theory proof
Let $n,k$ be natural numbers, $n\geq 2$. Prove that
$(n-1)^2|(n^k-1)$ if and only if $(n-1)|k$.
I was given a hint to use $n^k=((n^k-1)+1)$ and use the Binomial Theorem but I still haven't been able to crack this proof.
|
We write $$n=(n-1)+1$$ from which we see that $$n^k= \left( (n-1)+1\right)^k=(n-1)^k+k(n-1)^{k-1}+\cdots +k(n-1)+ 1$$ $$\implies n^k-1=(n-1)^k+\cdots + k(n-1)$$
Visibly, $(n-1)^2$ divides every term in the sum except possibly the last one. Thus $(n-1)^2$ divides the left hand iff it divides $k(n-1)$ and we are done.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "number theory"
}
|
Listing options
How could the following list be improved:
You must either;
a) signup for x, or
b) signup for y, or
c) pay for z.
|
I would run it this way:
> You **must** choose one (and only one) of the following three options:
>
> 1. Sign up for x.
>
> 2. Sign up for y.
>
> 3. Pay for z.
>
>
My rationale for handling the list in this way is that running the three options as separate simple sentences maximizes their readability and their distinctness as independent options.
The best place to make clear that the user/reader/participant must choose an option but must not choose more than one option is in the instructions preceding the list; if you do a good job of it there, you don't have to tangle up your enumeration of the options themselves with conjunctive _or_ s and a single prolonged but piecemeal sentence presentation.
Ultimately, of course, there is no single right or best way to handle a question like yours. We are deep in "primarily opinion-based question" territory here.
|
stackexchange-english
|
{
"answer_score": 1,
"question_score": -2,
"tags": "punctuation, lists"
}
|
Find $\lim_\limits{x\to 0} \frac{\sin x}{e^x -1 -\sin x}$
I have to find $$\lim_\limits{x\to 0} \dfrac{\sin x}{e^x -1 -\sin x}.$$
By using L'Hopital, $$\lim_\limits{x\to 0} \frac{\sin x}{e^x -1 -\sin x}= \lim_\limits{x\to 0} \frac{\cos x}{e^x -\cos x}.$$
Wolfram now states that $\nexists$ because $\lim_\limits{x\to 0^+} \frac{\sin x}{e^x -1 -\sin x}=\infty$ and $\lim_\limits{x\to 0^-} \frac{\sin x}{e^x -1 -\sin x}=-\infty$, but I don't see why $\lim_\limits{x\to 0^-} \frac{\sin x}{e^x -1 -\sin x}=-\infty$
|
Let's consider the function $f(x)=e^x-\cos x$, whose derivative is $f'(x)=e^x+\sin x$. Since $f'(0)=1>0$, there exists $\delta>0$ such that $f$ is increasing in $[-\delta,\delta]$; in particular \begin{align} e^x-\cos x &< 0 && \text{for $-\delta<x<0$} \\\\[6px] e^x-\cos x &> 0 && \text{for $0<x<\delta$} \end{align} Therefore $$ \lim_{x\to0^-}\frac{\cos x}{e^x-\cos x}=-\infty \qquad \lim_{x\to0^+}\frac{\cos x}{e^x-\cos x}=\infty $$ By applying l'Hôpital, $$ \lim_{x\to0^-}\frac{\sin x}{e^x-1-\sin x}=-\infty \qquad \lim_{x\to0^+}\frac{\sin x}{e^x-1-\sin x}=\infty $$
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 1,
"tags": "real analysis, limits, exponential function, substitution"
}
|
wxWidgets 3.0 - MSW application build does not start properly
I write an application of mine that is composed by main apps and libraries. I currently build it on Linux (Ubuntu) and Windows (Win7).
Since I updated wxWidgets libraries from v2.8 to v3.0, the Win build does not start anymore (the Linux one still works properly).
If I start the debugger in Windows, I see that the application process exits right after entering the `IMPLEMENT_APP` macro, with following kind of output:
[Inferior 1 (process 3516) exited with code 01]
Does anyone know how to fix this problem?
I use Code::Blocks IDE, on Win7 64-bit.
|
Rebuilding wxWidgets library and the whole application binaries with latest wxWidgets 3.0.1 cleared the issue. Now the application works; I am not sure if this was due to a wrong configuration of my project files or to a wxWidgets bug.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 3,
"tags": "windows, wxwidgets, codeblocks"
}
|
Tkinter checkbox executing command only once
x = tk.IntVar()
def test():
print(x.get())
checkBox = tk.Checkbutton(text="test",command=test(),variable=x)
checkBox.grid(row=12,column=2)
b=tk.Button(text="test",command=test)
b.grid(row=12,column=0
this is some code I put in my program for testing, when I check the checkbox the value does change (I can confirm it with the button I made to test) but the command does not get executed.
|
Remove **()** in command
command= test
This works fine:
import tkinter as tk
win = tk.Tk()
x = tk.IntVar()
def test():
print(x.get())
checkBox = tk.Checkbutton(text="test", command=test, variable=x)
checkBox.grid(row=12, column=2)
win.mainloop()
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, tkinter"
}
|
How to create a custom CSS file for Flows?
I need to completely change the design of a Visual Workflow (Flows) I have made,
I know that I can provide a static CSS file as follows:
`<apex:stylesheet value="{URLFOR{$Resourse.styles, 'styles.css')}"/>`
But I don’t understand how to control the changes in each part of my Flow in the CSS file,
In Visual force markup language, this is straight forward, as this webpage show:
<
I can define which parts are `h1`, `p`, or even define a style class.
But how can I do this with flows? How do I even know the names of the objects in the flows?
I’m just calling the flow in my visual force page using one line:
`<flow:interview name="Name"/>`
Can anyone guide me to a website, pdf, or a webinar that demonstrates how to create/change a CSS static file for FLOWS?
|
You can customize the flow appearance by applying custom CSS styles:
> "Using a combination of flow attributes and CSS classes, you can customize the individual parts of a flow, such as the button location, button style, background, and the look and feel of the screen labels."
See Customizing a Flow’s User Interface in the docs.
|
stackexchange-salesforce
|
{
"answer_score": 6,
"question_score": 6,
"tags": "visual workflow"
}
|
How to read hard disk utilization and stats using node.js or electronjs for windows and mac
I'm wondering how could I read hard disk utilization / idle time, hdd type using Javascript for Windows and MacOS. I have access to nodejs and electron API for my app. I can't seem to find any API or npm packages that allow reading of harddisk stats and disk utilization.
|
There is 1 npm package "systeminformation" which provides these details : Below is the reference : <
const si = require('systeminformation');
setInterval(function() {
si.mem(function(data) {
console.log('Memory-Information:');
console.log(data);
});
}, 1000)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, node.js, windows, macos, electron"
}
|
Extension of Liouville's Theorem?
Liouville's Theorem states that if a function is bounded and holomorphic on the complex plane (i.e. bounded and entire), then it is a constant function.
What if we consider the following, slightly modified scenario:
Suppose a function $f$ is holomorphic and has constant modulus on a bounded domain $D$ (e.g. a small disk).
Can we use Liouville's Theorem to somehow conclude that $f$ is a constant function? (either on $D$ or on the whole of the complex plane?)
|
I don't see how you could use Liouville's theorem to prove that, but it does follow from Cauchy-Riemann's equations.
If you assume that $f$ is entire, use Cauchy-Riemann's equation on $|f|^2 = u^2 + v^2$ to show that both $u$ and $v$ must be constant on $D$. After that it follows from the uniqueness theorem that $f$ is constant everywhere.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "complex analysis, analyticity"
}
|
Volume of a Truncated Right Prism with generic base convex polygon
I can find lots of pages online saying the volume of a Truncated Right Triangular Prism is $\frac{A}{3}(h_1 + h_2 + h_3)$, where $A$ is the area of the base and $h_i$ is the height of vertex $i$ of the top face. Or, in other words, to find the volume you "flatten" the top face by finding the average height of its 3 vertices, and then the volume is just that of a regular prism.
My question is: for a generic base convex polygon, does the same argument apply? Is the volume equal to $\frac{A}{n}\sum_{i=1}^nh_i$, where $n$ is the number of vertices of the base/top? Is there a proof for this anywhere?
My intuition says it's true, but what if the base shape was like a _really_ long kite; wouldn't the height of the vertex at the bottom tip of the kite skew the average height of the top face?
|
Your formula for the volume cannot be true, in general, for $n>3$. Here's a counter-example with $n=4$.
Take a truncated right quadrangular prism with its base on the $z=0$ plane and its top vertices given by: $$ V_1=(0,0,0),\quad V_2=(1,0,a),\quad V_3=(0,1,b), \quad V_4=(2,2,2a+2b), $$ with $a$ and $b$ positive constants. Note that those points all lie in the same plane, because $\vec{V_1V_4}=2\cdot\vec{V_1V_2}+2\cdot\vec{V_1V_3}$
The volume of this solid can be computed dividing it into two truncated triangular prisms with a plane passing through $y$-axis and $V_4$. Both their bases have unit area, hence applying the formula for the triangular case with $h_1=0$, $h_2=a$, $h_3=b$, $h_4=2a+2b$ we get:
$$V={A_1\over3}(h_1+h_2+h_4)+{A_2\over3}(h_1+h_3+h_4)= {1\over3}(3a+2b)+{1\over3}(2a+3b)={5\over3}(a+b).$$
On the other hand, if your generalised formula were true, we would have: $$ V={A_1+A_2\over4}(h_1+h_2+h_3+h_4)={3\over2}(a+b). $$
Hence the generalised formula doesn't work.
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "geometry"
}
|
Cope with brightness in grayscale template matching
I am using opencv for real-time template matching. The camera yields at 52fps grayscale images. The software works just fine but sometimes the matching fails because of bad light condition.
The camera doesn't provide a way to adjust the brightness (it simply adjusts it automatically). It turns out that sometimes the image is either too dark or too light and the template matching fails.
How would you cope with this? Is there a way to make it working?
Thanks.
|
If you are within the dynamic range of your camera, normalize the brightness before matching. There is a number of techniques to do this, but quite often it is sufficient to accumulate the brightness over the whole image and adjust every pixel by a fixed factor.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "c++, opencv, template matching"
}
|
ASP.NET show and hide image at runtime
I want to show loading picture when I'll click the button. And after finish my some calculation, make this picture is invisible. How to do it without AJAX and not using [WebMethod]? I know some tricks how to do it with AJAX or PageLoad, but I'm interesting, how to do it in the **different threads** , is it possible?
For example my code:
protected void btnDelete_Click(object sender, EventArgs e)
{
imgLoading.Visible = true;
lblCount.Visible = false;
//doing some work
bool isDone = TProfile.Delete(userId, someData);
if (isDone)
{
imgLoading.Visible = false;
lblCount.Visible = true;
}
BindList(true);
}
|
You can use the OnClientClick to load an image, and by the time the page will finish the cycle to your server and the page will be reloaded it will disappear.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "c#, asp.net, multithreading"
}
|
Uninstalling HyperV from Windows 8
Let me be the first to say that I love that my copy of Win8 Pro comes automatically installed with HyperV. Unfortunately, I use Workstation instead and have been unable to figure out how to uninstall HyperV(Workstation will not install with HyperV installed).
Is it possible to uninstall this from Windows 8?
|
try launching:
appwiz.cpl and then going to add / remove feature. Search for it there.
Bring up the Run box, command prompt, or Start Search and type "appwiz.cpl" without the quotes.
Once the Add / Remove programs dialog opens, click Add / Remove features on the left.
Find the Hyper-V add-in and _un-check_ it.
In fact, a quick search confirms this should work.
|
stackexchange-superuser
|
{
"answer_score": 7,
"question_score": 7,
"tags": "vmware workstation, hyper v"
}
|
Should I use Flash or Flex?
Here at SO, I asked what language I should use to create a web app that would capture video from the user webcam and send it to the server when he clicked 'submit' and the answers were mostly Flash.
But searching the web I got confused with this Flash/Flex thing as they say Flash is to make animations and Flex is to really create web apps.
So what should I use? By Flash they meant Flex? Or for a program like that Flash is fine? Should I use Flash Pro. or Flash Builder? Learn ActionScript or XMXL?
It may look there are tons of contents about this on the web, but the more I read, more I got confused.
Thanks in advance.
|
This is not entirely true. You may use Flash Professional to develop and write code in native Actionscript 3 while also being able to develop at the Designer level creating images/animations and so on.
To answer your question, if you wish to code in MXML, then you need to use Flash Builder. If you want to write in native AS3 you may use either of the two. Both will work, however, from personal experience you have more freedom using native AS3. Also, for the type of application that you wish to make, performance would probably be of great priority, thus having full control using AS3 is recommended.
EDIT: Also, if you are familiar with C++ or Java, or any other object oriented, I believe programming in ActionScript3 will feel very much like home.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 6,
"tags": "apache flex, flash, adobe, flexbuilder"
}
|
Session Logout in every two minutes
I have Web Application in asp.net. Where I am maintaining Session for every User. And every Time I got logout in Approx 2 min. I tried to increase this time through web Config File upto 60 min but it is not working For me and I m getting same problem.
I have created A class file For maintaining session.I am Using This Code.
public static void createSession(System.Web.SessionState.HttpSessionState session)
{
Session = session;
}
This is my class file code.
And I am calling this function in login Page load like this.
BusinessClasses.SessionHandler.createSession(Page.Session);
Then After I am Checking In everyPage.
But this code is not working for me. Please Give Suggest me correct solution for this problem.
|
That function of yours is doing nothing, just assigning a variable to itself. Anyway, as they told you, you should delete this function and use the built-in asp .net session management.
Try to change the web.config to something like:
<sessionState timeout="99999">
</sessionState>
It should work.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "asp.net"
}
|
How to select the CLICKED item with jQuery?
I am using this code to remove and a CSS class:
$('.called').click(function() {
$('called').removeClass('fa-phone-square').addClass('fa-check');
})
The problem is, it removes and adds classes to ALL tags with the class '.called'. I want this function to work only for the single item that has been clicked.
How would I do this?
|
You would have to do this:
$('.called').click(function() {
$(this).removeClass('fa-phone-square').addClass('fa-check');
})
"this" inside the click handler refers to the element that has been clicked and which you want to apply the changes.
If you instead apply the ".called" selector again it will select all items with the "called" class and apply the removeClass and addClass to all of them which is the behavior you are experiencing now.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "javascript, jquery"
}
|
How to add more padding between hexagons without losing responsiveness?
I'm working on a personal website where I want to show hexagonal images/tiles on front page. I found a solution here for responsive hexagon html and css blocks.Now I want to add more padding between these hexagons without losing responsiveness.
I'd tried adding padding but it destroy overall responsiveness.
This is the original code I found here.
I want more padding between two hexagons like padding of 15px or 20px.
|
I couldn't find a way to have padding in pixels, but here is what worked for me,
.hexIn {
width:86%;
padding-bottom: 99.307%; /* = width / sin(60) */
}
Reduce the value of width of the hexIn block and the padding accordingly. You can visually analyze the padding in-between the blocks, try reducing/increasing until you fill comfortable.
padding-bottom = (width * 2)/1.7320
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "html, css"
}
|
Update Attribute Table on clipped shapefiles using QGIS
I would like to find a way to automatically update the attribute table for shps generated from the `clipping tool`. My interest is to get an updated area calculation. All my new shapefiles would contain the same attributes since they all come from one single shp, but will have different geometries.
I'm familiar with the use of the Attributes Form option. I tried saving the style of one shp with my fields linked to a default value (let's say `$area`), but when copying the style into another shape it won't update its area until I first modify its geometry.
Is there a way to refresh the geometry alltogether so the _Attributes Form_ procedure can work?
QGIS Version: 3.20.3-Odense
|
You can use a virtual field in your table. This will be updated automatically and will be part of the layer style. Copying the style and giving it to a second layer will keep the virtual field and update the area calculations in the second layer. see attached screenshots:

I'm using `ti.inappbilling` module for in-app billing on Android. I use `titanium sdk` 5.1.2
But when I call it's always returning an error:
var InAppBilling = require("ti.inappbilling");
InAppBilling.queryInventory({});
InAppBilling.addEventListener('queryinventorycomplete', function(e) {
if (e.success) {
purchase = e.inventory.getPurchase(productID);
}else{
Ti.API.error('queryinventorycomplete: ' + e.responseCode + " - " + responseString(e.responseCode));
}
});
> queryinventorycomplete: -1003 - IAB VERIFICATION FAILED
|
sorry it's my fault, I set an undefined PUBLIC_KEY in the setup. now it's correctly
Thank you for your answers
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, appcelerator, in app billing, appcelerator titanium"
}
|
Odoo function not working
OpenErp 8 - Python
I have field. When use change `compute_date` then click button Save. Change state_for_date :
if `compute_date` > 20 then state_for_date = comp
if `compute_date` < 20 then state_for_date = new
`state_for_date` is `statusbar`
compute_date = fields.Integer('Int')
state_for_date = fields.Selection([('new', 'New'),
('comp', 'Comp')],
'State', default='new', required=True)
def write(self, vals):
if self.compute_date < 20:
vals = {'state': 'new'}
if self.compute_date > 20:
vals = {'state': 'comp'}
return self.write(vals)
**Not working** , **help me** _Error : RuntimeError: maximum recursion depth exceeded_
|
You are calling recursive write method instead of calling super method. You need to call super method.
def write(self, vals):
if self.compute_date < 20:
vals = {'state': 'new'}
if self.compute_date > 20:
vals = {'state': 'comp'}
return super(class_name, self).write(vals)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, odoo"
}
|
Why do we flatten the data before we feed it into tensorflow?
I'm following udacity MNIST tutorial and MNIST data is originally `28*28` matrix. However right before feeding that data, they flatten the data into 1d array with 784 columns `(784 = 28 * 28)`.
For example, original training set shape was (200000, 28, 28).
200000 rows (data). Each data is 28*28 matrix
They converted this into the training set whose shape is (200000, 784)
Can someone explain why they flatten the data out before feeding to tensorflow?
|
Because when you're adding a fully connected layer, you always want your data to be a (1 or) 2 dimensional matrix, where each row is the vector representing your data. That way, the fully connected layer is just a matrix multiplication between your input (of size `(batch_size, n_features)`) and the weights (of shape `(n_features, n_outputs)`) (plus the bias and the activation function), and you get an output of shape `(batch_size, n_outputs)`. Plus, you really don't need the original shape information in a fully connected layer, so it's OK to lose it.
It would be more complicated and less efficient to get the same result without reshaping first, that's why we always do it before a fully connected layer. For a convolutional layer, on the opposite, you'll want to keep the data in original format (width, height).
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 9,
"tags": "tensorflow, deep learning, mnist"
}
|
Passing arguments to javascript file, how does it work?
From the tutorial ScriptJSONOptions of FirebugLite page, I found the below:
* * *
# Script JSON options
It is possible to set options using a JSON object inside the linked script:
<script type="text/javascript"
src="
{
overrideConsole: false,
startInNewWindow: true,
startOpened: true,
enableTrace: true
}
</script>
* * *
It means that we can pass the arguments to javascript file.
But I don't know how does it work?
### Update:
> My question is how to get the arguments inside the js file?
### P/S:
I also looked into code, but I could not find the code is implemented this feature.
|
I think this can be achieved by finding the correct "script" dom node and then eval() its text content. In jQuery
eval("var mySettings = " + jQuery("script[src*='firebug']").text() );
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 2,
"tags": "javascript"
}
|
How to get the path of the exexuter in C++?
I am using Visual studio 2008 and I want to get the absolute path of the .exe file? meaning when the user opens the exe file, I need to know its absolute path??
thanks in advance
|
Under Windows try the following:
char ExeName[8192]; // or what ever max. size you expect.
if (0 != GetModuleFileName (NULL, ExeName, sizeof (ExeName)))
{
printf ("Your array was probably not large enough. Call GetLastError for details\n");
}
If you compile for unicode use wchar_t.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "c++, visual studio 2008, path"
}
|
Adding a custom field or metabox to the post-thumbnail widget?
Is it possible to add a custom field to an existing "widget" in the backend?
What I wanna do is provide a way to have a checkbox to apply a thumbnail that is double the size of the normal one on the frontend. So I'm thinking of simply adding a custom field as a checkbox that says "Double the size" and when checked I return a different output on the frontend.
That is not the problem, I know how to do so.
However I wonder if it possible to locate this checkbox in the post-thumbnail widget in the backend?
!enter image description here
Normally when adding a custom field it appears underneath the excerpt or content area. Is it possible to locate this checkbox inside the post-thumbnail widget?
Thank you in advance
|
Just filter `admin_post_thumbnail_html` and append your checkbox HTML:
add_filter( 'admin_post_thumbnail_html', 'wpse_71501_thumbnail_options' );
function wpse_71501_thumbnail_options( $html )
{
return $html . <<<html
<p>
<label for="big_thumbnail">
<input id="big_thumbnail" name="big_thumbnail" type="checkbox" />
Use big thumbnail
</label>
</p>
html;
}
|
stackexchange-wordpress
|
{
"answer_score": 4,
"question_score": 2,
"tags": "custom field, metabox, post thumbnails, thumbnails"
}
|
UIButton image and retina display
I have some button with custom background image, and here is how I do this:
UIImage *buttonImage2Normal = [UIImage imageNamed:@"greyButton.png"];
[showModal setBackgroundImage:buttonImage2Normal
forState:UIControlStateNormal];
UIImage *buttonImage2Pressed = [UIImage imageNamed:@"greyButtonPressed.png"];
[showModal setBackgroundImage:buttonImage2Pressed
forState:UIControlStateHighlighted];
And I made four images, greyButton.png, greyButtonPressed.png and @2x versions to support retina.
But, on retina (iPhone simulator) I see ok my buttons, but on iPhone (3G) I think that is uses bigger images because my buttons are almost without rounded corners.
**This is the right method for doing this?**
|
You are doing it correctly as long as you name your Retina Display images like this: `filename.png` and `[email protected]`
You might want to simply test by making a non-Retina image that's a red colour, then a Retina image that's a blue colour.
On iPhone Simulator with Retina scale you should be seeing a blue button and on your 3G iPhone you should be seeing a red button.
|
stackexchange-stackoverflow
|
{
"answer_score": 10,
"question_score": 3,
"tags": "iphone, ios, uibutton, retina display"
}
|
If I select Improved Natural Attack (Claws), does that apply to Rake attacks too?
Claws and Rakes are listed as separate attacks, but Rake's are extra attacks by the creature's claws.
If I selected Improved Natural Attack for my Lion Animal Companion, do my Rake attacks also benefit from larger damage dice provided by Improved Natural Attack?
|
### Yes, Rake attacks benefit from Improved Natural Attack (Claws).
From the AONPRD on Rake ( **emphasis mine** ):
> A creature with this special attack gains extra natural attacks under certain conditions, typically when it grapples its foe. In addition to the options available to all grapplers, a monster with the rake ability gains two free **claw** attacks that it can use only against a grappled foe. The bonus and damage caused by these attacks are included in the creature’s description.
Rake attacks _are_ claw attacks. They differ from normal claw attacks in that they can only be made under specific circumstances and that they can _potentially_ have a different _base_ damage die (i.e. a creature could have a d8 claw attack and a d6 rake attack; Improved Natural Attack for claws would increase these to a d10 and a d8 because they are both claw attacks).
|
stackexchange-rpg
|
{
"answer_score": 5,
"question_score": 5,
"tags": "pathfinder 1e, damage, animal companions, natural weapon"
}
|
Initializing obj with/without default values
In c#:
public class SomeClass
{
int x;
int y;
SomeClass (int x, int y)
{
this.x = x;
this.y = y;
}
}
Is there easy way to make new SomeClass without setting x and y instead to have default values for them and if I set values to set them else to have the default values?
|
Sure, with C#6 you can use auto-implemented properties:
public class SomeClass
{
public int X { get; } = 123;
public int Y { get; } = 456;
public SomeClass(){ }
public SomeClass(int x, int y)
{
this.X = x;
this.Y = y;
}
}
Of course you need a parameterless constructor.
If you instead mean default values of the type, that is done automatically(0 for numerical types).
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "c#"
}
|
Beautifulsoup4 ImportError
from bs4 import beautifulsoup4
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-57-a31e5d379afe> in <module>
----> 1 from bs4 import BeautifulSoup as bs
C:\ProgramData\Anaconda3\lib\site-packages\bs4\__init__.py in <module>
29 import warnings
30
---> 31 from .builder import builder_registry, ParserRejectedMarkup
32 from .dammit import UnicodeDammit
33 from .element import (
ImportError: cannot import name 'builder_registry' from 'bs4.builder' (unknown location)
I can not figure out why I am getting this import error. I have try to reinstall beautifulsoup4 several times.
Thank you.
|
use this,
from bs4 import BeautifulSoup
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "python, beautifulsoup, import, importerror"
}
|
Am I confused about how to diversify into bonds?
I held several Vanguard equity ETFs (VFIAX, etc.) I wanted to diversify into bonds (as discussed in "A Random Walk Down Wall Street"), so I sold some of them and bought BLV.
As stocks have declined, BLV has declined even more severely.
Do I misunderstand how to diversify into bonds?
|
> Do I misunderstand how to diversify into bonds?
No. You diversified just like you're supposed to, by adding other asset classes (presumably with a low correlation of returns) to your portfolio. Diversification to a lower-risk asset like bond ETFs does not mean that the bond ETF will ALWAYS move less than the equity ETF, or that they will move in opposite directions. It simply means that _on average_ , the movements of the bond ETF will be less than the equity ETF.
I would not panic too much if the bonds dropped more than the equity in a short time. It's possible that recent interest rate movements hurt the bonds, but did not hurt the equities as much (or other factors helped offset the losses sue to interest rates).
The downside is that you can not expect the bond ETFs to rise more than the equities going forward for the same reasons. One thing you might consider is to rebalance slightly, buying more bond ETFs while they're down, but that's up to you.
|
stackexchange-money
|
{
"answer_score": 5,
"question_score": 2,
"tags": "stocks, investing, etf, bonds, diversification"
}
|
Sort multi-dimensional array built from CSV data using PHP
Trying to sort an array in PHP that is being populated from a CSV. I would also, ideally, LOVE to be able to control the sort by clicking on tabs in the table here .. Right now, though, my first task at hand is just sorting the damn thing.. been working on this for over 3 days now.. any help is GREATLY appreciated!! Cheers!
PHP
<?php
$fp = fopen("
$rows = array();
while (($row = fgetcsv($fp)) !== FALSE) {
$rows[] = $row;
}
fclose($fp);
$headers = array_shift($rows);
foreach ($rows as $row) : list($ShowKey, $ShowFeedURL, $ShowLink, $ShowIcon, $ShowTitle, $ShowTag, $ShowCategory, $ShowEps, $ShowLastUpdate, $ShowNew) = $row;
$oddpost = ( empty( $oddpost ) ) ? '_odd' : ''; ?>
|
Instead of sorting the table in PHP, you may consider doing it client-side in Javascript. For instance have a look at this jQuery plugin: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, arrays, sorting, csv, multidimensional array"
}
|
When do I get experience while fighting with companions?
I am currently traveling with Fawkes and Dogmeat and sometimes, when killing enemies, I do not get experience points. I am assuming that I need to inflict a certain percentage of the damage to get the experience - but how much is it?
|
You have to deal at least 30% of the damage necessary to kill an opponent to receive the experience for the kill.
|
stackexchange-gaming
|
{
"answer_score": 1,
"question_score": 1,
"tags": "fallout 3"
}
|
How to refresh sys.path?
I've installed some packages during the execution of my script as a user. Those packages were the first user packages, so python didn't add `~/.local/lib/python2.7/site-packages` to the `sys.path` before script run. I want to import those installed packages. But I cannot because they are not in `sys.path`.
How can I refresh `sys.path`?
I'm using python 2.7.
|
As explained in What sets up sys.path with Python, and when? `sys.path` is populated with the help of builtin `site.py` module.
So you just need to reload it. You cannot it in one step because you don't have `site` in your namespace. To sum up:
import site
from importlib import reload
reload(site)
That's it.
|
stackexchange-stackoverflow
|
{
"answer_score": 23,
"question_score": 17,
"tags": "python, python 2.7, package, reload, sys.path"
}
|
std::size_t or std::vector<Foo>::size_type?
When I loop on a `std::vector<Foo>` (or every container having random access iterator) I use an unsigned integer variable `i`. If I want to respect the norm, should I use `std::size_t` or the type given by the container itself : `std::vector<Foo>::size_type` ?
If I chose `std::size_t` (for readability reasons), can I be sure that every implementation of every container in `std` namespace uses `std::size_t` as `size_type` ?
Note : I use C++98 only (for compatibility reasons).
|
It is not _necessarily_ true that `std::vector<Foo>::size_type` is the same as `std::size_t`. This is true even for C++11.
But personally I use `std::size_t` for a `std::vector` index irrespective of the type.
You could always use a static assertion if you're feeling particularly diligent. Obviously `static_assert` is a later addition beyond what's in C++98, but in that standard you could use something like
static char wrong_size_1[1 + sizeof(std::size_t) - sizeof(std::vector<Foo>::size_type)];
static char wrong_size_2[1 - sizeof(std::size_t) + sizeof(std::vector<Foo>::size_type)];
which would induce compile time failures if type types are not the same size.
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "c++, stl, c++98, size t, size type"
}
|
Como apagar os dados de uma tabela em VBA Access
Preciso de um comando em vba para excluir os registros da minha tabela `REPETIRTEL` no momento em que fecho o meu formulário. Esse formulário não tem essa tabela como origem de dados, por isso preciso que o comando chame essa tabela e depois desabilite a mensagem de confirmação de exclusão.
|
Primeiro criei uma consulta exclusão da tabela REPETIRTEL com a Query de Delete, depois chamei essa consulta e pronto, ficou assim:
Private Sub Form_Close()
Application.DoCmd.SetWarnings False
DoCmd.OpenQuery "deleteREPETIRTEL", acViewNormal
Application.DoCmd.SetWarnings True
End Sub
Primeiro desabilitei as mensagens do Access Chamei a Query Habilitei novamente as mensagens.
|
stackexchange-pt_stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "ms access, vba"
}
|
Must files using jsx in TypeScript have the extension tsx?
It seems as if TypeScript and tslint would not accept jsx code in a file with the extension ts. Is it mandatory in TypeScript to use the extension tsx for source files using jsx?
|
Yes, it is mandatory to put jsx in in tsx files. This is explained in the docs
> In order to use JSX you must do two things.
>
> 1. Name your files with a .tsx extension
> 2. Enable the jsx option
>
This was done both to mimic the extension used by `jsx` traditionally but probably more importantly because Typescript has some syntactic conflicts with jsx (for example the old type assertion operator `<type>`) so using a separate extension helps with backward compatibility.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "typescript, tslint"
}
|
Duplicate and modify words in bash with sed
I'm on Linux OS. I have a file to modify in my bash script.
My original file is like that:
...
ERIC-1898
HELENE-5456
THOMAS-54565
IRON-06516
...
And I'd like to modify this file with duplicate words (and `-SYSTEM-` word in second field), and add double quotes. So, the result has to be like that:
...
"ERIC-1898" "ERIC-SYSTEM-1898"
"HELENE-5456" "HELENE-SYSTEM-5456"
"THOMAS-54565" "THOMAS-SYSTEM-54565"
"IRON-06516" "IRON-SYSTEM-06516"
...
How can I do that, for example with sed?
|
With sed and two capture groups:
$ sed 's/\(.*-\)\(.*\)/"&" "\1SYSTEM-\2"/' infile
"ERIC-1898" "ERIC-SYSTEM-1898"
"HELENE-5456" "HELENE-SYSTEM-5456"
"THOMAS-54565" "THOMAS-SYSTEM-54565"
"IRON-06516" "IRON-SYSTEM-06516"
Assuming that there is exactly one hyphen per input line.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "bash, awk, sed"
}
|
Organize C# usings in Visual Studio 2019?
I assigned a keyboard shortcut for remove and sort usings but, I wanna know if it possible to organize usings on save or on format document?
|
I'm using Power Commands extension to do that, as I used before on Visual Studio 2017 and it works very well.
After installing, in _Tools -> Options_ you have a new _Productivity Power Tools_ option that allows configuring to **Format document on save** and **Remove and Sort Usings on save**. 
{
}
When I'm debugging, the Page_Init method is getting fired twice!
Whats going on?
|
Let's make sure we cover the basics here:
Do you have any controls on your page that have server events? If so, remember that _every_ postback re-creates the _entire page._ So, to handle an event means running _all_ of the code required put the page together, including your Init and Load events.
> Always two there are, no more no less. A request and a response.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 5,
"tags": "asp.net"
}
|
How do i upload a folder directly into a github repository?
Its a java project, i need to upload all the contents in a folder not just the source files
|
git add .
then just push without a .gitignore and entries in your `.git/info/exclude` file.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "java, github, netbeans 7.4"
}
|
Clearing shopping cart after checkout
I have implemented a shopping cart in laravel using sessions. Now, i think I am kinda unclear as to how I would clear the cart for each user after checkout. My understanding is that sessions are created when the browser is open and destroyed when it is closed. I also get that sessions are created on the users machine. How would i go about destroying that session object after user has checked out?
What, i have is that, a status code would be sent back to a route in my application that would trigger the clear cart function if the payment was successful. Have i misunderstood how sessions operate?
I expect that when a user completes a transaction, the payment gateway will return a code and i could use that code to clear session.
|
Yes, you can clear the session value for cart on successful transaction.
Assuming you store your cart details in session in a key called **cart** , you can delete it from session like this:
$request->session()->forget('cart');
or using the helper method like this:
session()->forget('cart');
This is if the cart details are stored in session, if they are stored in your db, you can begin a mysql (given you are using mysql) transaction at the beginning of your checkout and clear the cart for that particular user. In case of a payment failure, you can rollback the transaction leaving everything intact in cart.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "php, laravel, session, shopping cart"
}
|
Does granting cancan ability to create automatically imply access to new action?
I have a cancan ability that says a user can `create` a `Message` if it's theirs
can [:create], [Message] do |message|
message.user_id == user.id && message.conversation.sender_id == user.id
end
This works as expected, but, surprisingly, this rspec test for whether the user can access the `new` action for a message fails:
it 'A user should not be able to access their own message new action' do
expect(ability).to_not be_able_to(:new, message)
end
So the user _**can**_ access the `new` action for their message. Why is this? Does access to the `create` action somehow imply access to `new` as well? Or have I misinterpreted or made a mistake somewhere?
|
Yes `:new` is an alias of `:create`
See here:
<
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ruby on rails, cancan, cancancan"
}
|
Why 1 in For loop?
for(let i = 1; i<=5; i++)
{
console.log(i);
}
Here I don't know why 1 is printed since the condition of i <=5 and it should add 1 right? So it should print 2 first instead of 1.Thankyou.
|
The first value is 1. i++ will be executed after the loop is done.
for(let i = 1; i<=5; i++)
{
console.log(i);
}<--- i++;
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "for loop"
}
|
Access ndarray using list
Can you access ndarray by indice list? I use the following script by that but it's too heavy I think.
import numpy as np
def getIndex(indice, data_num):
index = 0
for i in range(len(data_num)):
index += indice[i] * data_num[i]
return index
def at(ndarr, indice):
indice_num = ndarr.shape
data_num = np.ones(ndarr.ndim)
for vi in range(len(indice_num)-1):
for ni in range(len(data_num)-vi-1):
data_num[ni] *= indice_num[len(indice_num)-vi-1]
print indice_num
print data_num
return ndarr.reshape(ndarr.size)[getIndex(indice, data_num)];
ndarr = np.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])
print at(ndarr, [1,1,1]) # 5
|
Yes, you just have to use a tuple instead of a list:
>>> ndarr = np.array([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])
>>> indices = [1,1] # row,col
>>> ndarr[tuple(indices)]
5.0
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "python, numpy"
}
|
How to get the URL of a route without the route in Angular 8+
My full URL is ` which I can get using `location.href`
However all I need is to know the URL I'm on without the route. So just `
Is there a way of using the router in Angular to do this or will I need to split the string? If I need to split the string then how would I do so to just get the one part of the URL that I need?
|
What you are looking for might be `window.location.origin`, which will return the hostname with the HTTP protocol.
// Please note that the snippet run in an IFrame,
// so the url is not going to be stackoverflow.
console.log(window.location.origin)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "angular, routes"
}
|
Why does very cold water in a thermos cause there to be strong suction on the cap?
After putting ice-cold water in a thermos, the cap is strongly held on by what feels like suction. I assume the cold water condenses the air, thus lowers the pressure inside, but can someone explain why this causes suction?
|
When the thermos is closed, the air at the top of the thermos will be warm relative to the ice-cold water below it. As time proceeds, the two materials that are in contact with each other at the surface of the water will exchange heat due to their different temperatures. This will cool the air.
When gasses are cooled they move more slowly and they don't collide with surfaces as fast. Pressure comes about from the number of molecules striking a surface per second AND the speed at which they strike it. The molecules striking a surface per second will remain approximately the same, but with lower speed, the pressure produced will be reduced.
Meanwhile on the other side of the closed cap, the molecules will have the same speed they have always had, and they will exert normal atmospheric pressure on it. Hence, the DP that is observed and the apparent "suction" that you describe.
|
stackexchange-physics
|
{
"answer_score": 3,
"question_score": 2,
"tags": "pressure, vacuum"
}
|
Filling not closed PathGeometry to the bottom
Suppose I have `PathGeometry`, consisting of **lines** , like this (the rectangle == panel, for example `Grid`): !Examples I want to fill them to the bottom of the panel, like this: !enter image description here The quick and not very good solution I see is to create additional curve with 2 additional points in the bottom and use it for filling.
Is there some better way to solve the task? Something like this (pseudocode):
<Path Data=... FillStyle = "ToTheBottom" Fill="Blue"/>
|
There is no standard way of doing this; there is no Fill like this defined in WPF.
You could put two path geometries on top of each other. The bottom one would have a stroke thickness of 0 and has 2 extra points (those on the lower edge of the rectangle)
The second one the top would simply be the geometry you have now.
If you need to draw a lot of these you might create a custom control that does this for you.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 4,
"tags": "wpf, fill, pathgeometry"
}
|
Problem with multiple ORDER BY that must respect the first clause
I have a query to fetch the top 50 entries based on a `total_score` field. From these top 50, I need to be able to order them by any of their other fields. I tried using multiple ORDER BY statements, but the result set never changes. Here's my query:
SELECT
e.id, e.name , e.total_score
FROM
entry e
ORDER BY
e.total_score DESC, e.name ASC
I think I understand _why_ this doesn't do what I need, so I suppose my question is how can I achieve my goal? In the end I always need the 50 entries with the highest `total_score`, but this selection should be then orderable by any other field.
If this isn't possible in MySQL, I can do it with PHP, but I'd rather let the DB handle this.
Note: I'm using Doctrine 1.2 on top of a MySQL 5 DB.
Thanks!
|
ORDER BY, when used with multiple columns, only uses the subsequent columns in case of tie in the previous ones.
Try using nested queries
SELECT * FROM(
SELECT TOP 50
e.id, e.name , e.total_score, e.(YOURFIELD)
FROM
entry e
ORDER BY
e.total_score DESC ) x ORDER BY x.(YOURFIELD)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "mysql, doctrine"
}
|
Find numbers in a sentence by regex
I need a regular expression that will find all the numbers on a sentence. For example: "I have 3 bananas and 37 balloons" I will get:
3
37
"The time is 20:00 and I have 7 tanks" I will get:
20
00
7
|
The regex itself is as simple as `\d+`, but you will also need to set a flag to match it globally, the syntax of which depends on the programming language or software you are using.
**EDIT:** Some examples:
Python:
import re
re.findall(r"\d+", my_string)
JavaScript:
myString.match(/\d+/g)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "regex"
}
|
In Windows 8, does passing object between pages pass their reference or a copy of them?
I have the following scenario:
Image img = new Image();
img.Visibility = false;
img.Source = "..some path here..";
Frame.Navigate(typeof(Photos), img);
upon navigating to the new Photos page, I'm passing the `image` object I just created.
Would this new `image` object be passed as a copy of the original object, thus allocating some more memory, or would this object continue on to the new page as a reference?
If this won't pass as a reference - how would you implement this? moving an object along the lifecycle of my app from page to page without having to recreate it each time?
|
As Image is a reference type, a reference is passed.
I suggest reading a C# beginner book front to end - the concept of reference types is core fundamental to the whole design of the language.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, reference, windows 8, pass by reference"
}
|
How to collate multiple csv files into one csv file, removing the headers each time?
I have downloaded about 100 csv files from the web using python. Each file is is for a month in a year, so effectively I am downloading time series data.
Now what I want is to put all of these csv files into one csv file in time order, i'm not sure how to do this one after eachother?
Also I should note that excluding the first time, I want to remove the headers every time I put a new csv file in.
This will make sense why when you see my data:
 and then just concatenate all of them together. This is probably easier to do in bash than in python but here's a python solution (untested):
from glob import glob
# Fetch a sorted list of all .csv files
files = sorted(glob('*.csv'))
# Open output file for writing
with open('cat.csv', 'w') as fi_out:
# iterate over all csv files
for i, fname_in in enumerate(files):
# open each csv file
with open(fname_in, 'r') as fi_in:
# iterate through all files in the csv file
for i_line, line in enumerate(fi_in):
# Write all lines of the first file (i == 0)
# For all other files write all lines except the first one (i_line > 0)
if i_line > 0 or i == 0:
fi_out.write(line)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, csv, pip, urllib"
}
|
Catching informations about running processes in Windows
My task is to make a program, which counts a time of running processes in windows. Can you suggest me how or from where can I catch that informations?
|
For list of currently running processes under Windows use EnumProcesses win32 API
<
example how to do this:
<
From your question I'm not sure if you need process timing information (CPU time,etc.) or to count instances of given process in memory. Could you please explain this more clearly ?
You can use GetProcessTimes function to get process timing information.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -4,
"tags": "c++, windows, qt"
}
|
Linear approximation (surface area question)
!enter image description here
The surface area of a sphere of radius $r$ is given by $A=4{\pi}r^2$. Use the linear approximation or differentials to compute the approximate percent change in the surface area if the radius of the sphere decreases by $3$%
I attached my solution.
|
$A = 4\pi r^2$
r decrease by 3%, Hence the new r = 0.97r
The new area $A_1 = 4\pi )(.97r)^2 = 4\pi (0.9409) r^2$
Change in area $ = (0.9409-1) (4\pi r^2)$
Percentage change$ = \frac{-0.0591 (4\pi r^2)}{4\pi r^2} = -5.91$%
This is the right answer.
You can also use what you have mentioned which is $\frac{dA}{A} = \frac{8\pi rdr}{4\pi r^2} = \frac{2dr}{r}$
But you know $\frac{dr}{r} = -0.03$ Hence percentage change $= 2\times (-0.03)=-0.06 = -6$% $ \approx -0.0591 = -5.91$% Thanks
Satish
|
stackexchange-math
|
{
"answer_score": 1,
"question_score": 0,
"tags": "calculus"
}
|
How to show popup when user tries to leave the page window or close the tab?
I used `onload="myFunction()"` on body tag, And I used javascript code like this
function myFunction() {
//alert("Page is loaded");
document.getElementById("test").style.display = "block";
}
function hidePopup() {
// alert("Hidden");
document.getElementById("test").style.display = "none";
}
<div id="test" style="z-index: 20000;display: none;">
<div id="popup">
<div id="close" onclick="hidePopup()">x</div>
<div id="popup_img" class="hos_modal" style="height:900px; width:900px; margin:0 auto;">
<a href="javascript:void()" target="_blank"><img src="files/image.jpg" alt="free trial" style="width: auto; height: auto;"></a>
</div>
</div>
</div>
The above code is showing popup when the browser is loaded. And I also used `onunload` and `onmouseout` events.
|
If the goal is to display a message to the user then the solution is a very simple fix.
window.onbeforeunload = function() {
alert("Wait don't go!");
return false;
}
returning false with this event handler allows you to create a popup message with `alert("");` and prevents the user from leaving the page until they click a confirmation
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 3,
"tags": "javascript, html, css"
}
|
Jquery validator vs. bidimensional arrays
I'll just start with the example of my problem:
<form>
<input name="course[0][name]" />
<input name="course[0][type]" />
<input name="course[1][name]" />
<input name="course[1][type]" />
...
...
</form>
**obs:** this is, of course, simplified.
So...how can i validate those since i can't predict the name? Is there a way to use regular expressions or something? utopic example:
rules: {
/course\[([0-9]+)\]\[name\]/: {
required: true
}
}
I couldn't find the solution in the documentation since its a bit confusing. thank you (:
|
As an alternative you can do something like this
$.validator.addClassRules({
inputName: {
required: true,
minLength: 5
},
inputType: {
required: true,
remote: "remoteurl"
}
});
<input name="course[0][name]" class="inputName"/>
<input name="course[0][type]" class="inputType"/>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, html, forms, jquery validate"
}
|
Comparison between exponential and factorial results
I'm developing an algorithm to compare if the result of $n!$ is bigger than $k^m$, but I have problems with big integers, then I need to know if there's some property that I can use to do this without knowing the results.
Help please. :/
|
Take natural logs of both and use Stirling.
$$\ln(k^m) =m \ln(k) \text{ and } \ln(n!) \approx \frac12 \ln(2 \pi)+(n+\frac12)\ln(n) - n. $$
Comparing these should be no problem.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 0,
"tags": "exponential function, factorial"
}
|
Django admin fieldset exclude or header field
I'm trying to create a new admin view that: 1\. has a header of some kind 2\. excludes 3 of my fields
Fieldset gives me the header I want, but doesn't seem to support "exclude", and I have not been able to find a "header" field.
Is there: 1\. a header field that I don't know about 2\. a way to exclude fields within Fieldset?
|
You can't exclude things the way you want to, unfortunately. You'll have to verbosely list every field that you want to include, like this:
fieldsets = (
('Basic Information', {
'fields': ('first_name', 'last_name', 'address', )
}),
)
And so on!
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "django, header, admin, fieldset"
}
|
At what point the function $f(z)=|z|^2+i\bar z+1$ is differentiable?
> The function $f(z)=|z|^2+i\bar z+1$ is differentiable at
1. $i$
2. $1$
3. $-i$
4. no point in $\mathbb{C}$
So we need to use the definition $f'(z)=\lim_{\Delta z\to 0}\frac{f(z+\Delta z)-f(z)}{\Delta z}$, right? I can write it as $f(z)=z\bar z+i\bar z+1$. How should I proceed next? Any hint ? Thanks.
|
**Hint** $$f(x+iy)=(x^2+y^2+y+1)+ix$$ and use Cauchy-Riemann.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "complex analysis, derivatives"
}
|
Use 'virtual' in an array of objects (Mongoose)
I have two schemas as the following:
const castListSchema = new Schema({
id: String,
roleInVideo: String
});
const videoSchema = new Schame({
castList: { type: [castListSchema], default: [] }
});
I want to get data by the following structure:
castList: [
{
details: { ... },
roleInVideo: 'director'
},
...
]
I want to use `virtual` not `aggregate` and etc...
Is it possible? How?
|
Yes, you can use the virtual function inside the array of objects.
Use the following code to use the virtual function for the array of objects.
videoSchema.virtual("castList.castData", {
ref: "new_assets",
localField: "castList.castListSchema",
foreignField: "_id",
justOne: true
});
In populate also use this "castList.castData" as key to retrieve the data.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, mongodb, mongoose, schema, mongoose schema"
}
|
How to oppen base application from extension in iOs
I'm trying to open base application from iMessage app, which is an extension in my xcode project(added as target app). Im using`[self.extensionContext openURL:url completionHandler::^(BOOL success) {}];`
but it doesn't work. here is info.plist in base app
 \rightarrow R(y,x)$ and $ \forall x \lnot R(x,x)$.
How to extend the structure and/or axioms to express a 5 colourable graph?
|
General ideas:
* Require that each vertex ($\forall x \ldots$) satisfies at least one color predicate (Use $\lor$ among five color predicates).
* Also require that no vertex ($\lnot\exists x \ldots$) has two distinct colors (you can enumerate all the ten distinct pairs: $\lnot({\sf red}(x)\land{\sf blue}(x))\land \lnot(\ldots)\land \cdots$).
* For each color (repeat this axiom five times, once for each color), require that if $x$ has that color and $R(x,y)$ then $y$ has not that color (e.g. $\forall x y.\ {\sf red}(x)\land R(x,y) \implies \lnot{\sf red}(y)$).
|
stackexchange-cs
|
{
"answer_score": 2,
"question_score": 1,
"tags": "graphs, logic"
}
|
Capture filter value, within xslt, passed in from connected web part
Is it possible to get hold of the value of a filter being passed in by a connected web part?
For example, if a sharepoint list filter is sending a filter value of "1" to webpart A (a dataview webpart), I would like to re-use that value within the xslt of the dataview web part.
Thanks in advance. KS
|
It's not possible to access the Filter Value passed in by another web part.
|
stackexchange-sharepoint
|
{
"answer_score": 0,
"question_score": 0,
"tags": "data view web part, xslt, filter"
}
|
MathJax with Node partials
I'm using Node and Express with MathJax to make a comment system with TeX. The problem is, the TeX is only rendered when the page first loads, or when I refresh the page, but does not load when rendering a partial. Any advice?
Thanks.
|
See the MathJax documentation on dynamic pages, which will suggest that you use
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
after adding math to the page.
Also, you could check out the MathJax-node project, which implements APIs for interacting with MathJax through node.js programs.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "node.js, express, latex, ejs, mathjax"
}
|
Show that $p(x)=rq(x)$ for some rational number $r$
> Let $p(x)$ and $q(x)$ be two quadratic polynomials with integer coefficients. Suppose they have a non-rational zero in common. Show that $$p(x)=rq(x)$$ for some rational number $r$.
If the common root is an irrational number then the discriminant must be a positive non square integer. This is because all the coefficients are integers. Apart from this I can't think of anything else.
Is it worth trying to define $f(x)=p(x)-rq(x)$ and investigating the properties of $f(x)$?
|
Let $x_1$ be the irrational root that is shared by $p$ and $q$. Then, by the Irrational Conjugate Roots Theorem (#16 on this list of polynomial theorems), the irrational conjugate of $x_1$ must also be a root of both $p$ and $q$.
Explicitly, for any rational $a,b$ and irrational $\sqrt{c}$, if $$x_1 = a + b\sqrt{c}$$ is a root of $p$, then $$x_2 = a - b\sqrt{c}$$ must also be a root. The same reasoning implies that $x_2$ is a root of $q$.
* * *
Since $p$ and $q$ are quadratics whose two roots are the same, they must be proportional, up to a constant. Since we have integer coefficients, the constant of proportionality $r$ must be rational, so we are done.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "polynomials, roots, quadratics"
}
|
SSL certificate for multiple domains on a single server?
> **Possible Duplicate:**
> Multiple domains with SSL on same IP
You'll have to forgive me as I'm somewhat new to SSL certificates. I'd like to basically set up my servers to encrypt **all** traffic (as much as is possible) over HTTPS. I'm running on a GoDaddy shared hosting account, and I have multiple domains pointing to one server which serves different content based on the domain.
For this kind of setup, would I need multiple SSL certificates or can I get away with just one?
|
You probably just want a UCC (sometimes called a multiple SAN) certificate. It's one certificate with multiple names on it. You have to specify all of the names when you purchase it, and you're limited to whatever number the issuer will sell you (usually 5, 10, or some reasonable number).
Downside is that it is not easy to change the names, usually you have to buy another cert. If they're subdomains of a single domain, you can get a wildcard cert too.
|
stackexchange-serverfault
|
{
"answer_score": 1,
"question_score": 0,
"tags": "apache 2.2, ssl, ssl certificate"
}
|
Measure of the set $\{(x+f(x), x-f(x)):x\in \mathbb R\}$ in $\mathbb R^2$ is 0
> Let $f:\mathbf R\to \mathbf R$ be a Lebesgue measurable function. Then the set $S=\\{(x+f(x), x-f(x)):x\in \mathbf R\\}$ is Lebesgue measurable in $\mathbf R^2$ and its measure is $0$.
I am completely stumped here. I think we need to use Tonelli or Fubini's theorem intelligently once we establish that the set $S$ is measurable.
Thanks.
|
The linear map $(x, y) \mapsto (x + y, x - y)$ sends the graph of $f$ onto your set. The claim follows [Why?].
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 3,
"tags": "measure theory, lebesgue measure"
}
|
horizontalalingment in textblock don't work
I have code like this in xaml:
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{DynamicResource Referee}" Width="120" FontWeight="Bold" Margin="0 0 5 0" HorizontalAlignment="Right"></TextBlock>
<TextBlock Text="LOL" Margin="0 0 5 0"></TextBlock>
</StackPanel>
</ListBoxItem>
The problem is fact that first textBlock is not aligned to right but still to left.
There are many listbox items and i want to have align first column to right and second column to left. In each stackPanel first textblock has width 120. ListBox is in grid column which column width is set to Auto.
How can I solve that problem?
|
Set the TextAlignment property
<TextBlock Text="{DynamicResource Referee}" Width="120" FontWeight="Bold" Margin="0 0 5 0" TextAlignment="Right"></TextBlock>
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "wpf, xaml, listbox"
}
|
Does Chewie still owe a life debt to Han according to the Solo film?
During _Solo: A Star Wars Story_ , we see
> Han and Chewbacca's first time meeting. There's clear allusions to Legends in how it goes down (Han as an Imperial, helping free Chewie, a captive, and being on the run from the Empire afterwards).
However, the way this goes down
> means that Han didn't rescue Chewie so much as they worked together to escape. Han made no sacrifice, which means it no longer makes sense for Chewie to owe him a life debt. This is supported by the fact that it never comes up during the movie, and instead we see a strong inference that Chewbacca sticks around simply because he chooses to.
Up until now, even in canon we still see it commonly stated that much of why Chewie does what he does is because of the life debt he owes Han. Would it now be safe to assume that this is no longer true of their relationship?
|
The Solo film should be taken into consideration with the rest of the Disney canon. According to the post ROTJ book "Life Debt" - Han says:
> "I saved him, at least that's what he says, the big fuzzy fool, but really, he saved me. I was on a bad path, and Chewie, he put me straight. Saved my shanks more than once, too. He said it was part of some _life debt_ \- he has a word for it, but if I try to say it in his tongue I'll probably strain something. Even if I can't say it, I know what it means. It means that he owes his life to me." - Star Wars: Aftermath - Life Debt
Whether or not the life debt came from this particular meeting is currently unknown, but Han and Chewie both still think Chewie owes Han a life debt post-ROTJ
** note: the canon book "Star Wars: Last Shot" may have some additional information but I haven't read that yet :)*
|
stackexchange-scifi
|
{
"answer_score": 10,
"question_score": 11,
"tags": "star wars, han solo, chewbacca, solo a star wars story"
}
|
Animated WebP browser support
Does Chrome support animated webP? Is there an example of such an image? I'm not finding one.
|
No, animation is not stabilized yet and as such not included in Google Chrome yet. Source
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "google chrome, webp"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.