INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
How do you trim the XMP XML contained within a jpg
Through the use of sanselan I've found that the root cause of iPhone photos imported to windows becoming uneditable is that there is content (white space?) after the actual XML (for more details and a linked example of the bad XMP XML see <
I'd like to scan through my photo archive and 'trim' the XMP XML.
Is there an easy way to do this?
I have some java code that can recursively navigate my photo archive and DETECT the issue. I'm not sure how to trim and write the XML back though.
|
Obtain the existing XML using any means.
The following works if using the Apache Sanselan library:
String xmpXml = Sanselan.getXmpXml(new File('/path/to/jpeg'));
Then trim it...
xmpXml = xmpXml.trim();
Then write it back to the file using the solution to serializing Xmp XML to an existing jpeg.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "iphone, xml, image, xmp"
}
|
Attaching/Printing an image onto metal
I have a 507mm x 510.5mm metal sheet that I want to put a design onto. The design is rather complicated and I have no talent so painting is not an option. I'm looking for something similar to what this guy has done on the side panel of his computer case: :
self.eachMembership.append([])
for value in range(1, val+1):
self.eachMembership.append([value])
|
You can use `range` with `list`, and list comprehension:
>>> a = [3, 2, 4, 5]
>>> [list(range(1, x+1)) for x in a]
[[1, 2, 3], [1, 2], [1, 2, 3, 4], [1, 2, 3, 4, 5]
And to make all strings, add `map` with `str`:
>>>[list(map(str, range(1, x+1))) for x in a]
[['1', '2', '3'], ['1', '2'], ['1', '2', '3', '4'], ['1', '2', '3', '4', '5']]
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -1,
"tags": "python"
}
|
Pushing elements from a 2d to 1d vector
I am trying to push elements from a 2d integer matrix(created using vector of vectors) into a 1d integer vecto.While trying to push back if I do:
//declarations
//vector<vector<int>>nums
//vector<int>ans;int a
for(int i=0;i<nums.size();i++)
{
for(int j=0;j<nums[i].size();j++)
{
arr.push_back(nums[i,j]);
}
}
I am getting an error as no matching function call. However if I do this:
for(int i=0;i<nums.size();i++)
{
for(int j=0;j<nums[i].size();j++)
{ a=nums[i,j];
arr.push_back(a);
}
}
It works. I understand that ,nums[][] is getting read as a vector,but shouldn't nums[i][j] which is an integer be read as it is and not raise an error. Can somebody explain the difference in both the cases?
|
The answer to this question is not as simple as it seems. Let me break it down for you:
* Be careful when using commas in your code! C++ has its own comma operator rules, which means that `i,j` gets evaluated to `j`, so `nums[i,j]` is equal to `nums[j]`
* The operator `[]` on `vector<vector<int>>` returns an instance of the element type of this vector, which is `vector<int>`. Accessing an element of this inner vector can be done by using the `[]` operator again.
Thus If you want to access a single element in the 2d vector, you first have to select the outer vector and then its inner element, i.e. `nums[i][j]`.
**C++ has no special syntax for accessing multi-dimensional arrays/vectors!**
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "c++, c++11, vector"
}
|
How to order by a formula in MySQL
I have this query:
SELECT locations.id, 1609.34 * 3956 * 2 *
ASIN(
SQRT(
POWER(
SIN(
(55.170000 - abs(locations.latitude))
* pi() / 180 / 2), 2) +
COS(55.170000 * pi() / 180 ) *
COS(abs
(locations.latitude) * pi() / 180) * POWER(SIN((-7.400000 - (locations.longitude)) * pi() / 180 / 2), 2)
)
) as result
FROM locations order by result asc limit 10;
What I want is to get only the locations.id column, but at the same time order it by the formula so I can easily use hibernate.
I do not want to have in the select result table the "result" new column.
How can I do this in MySQL ?
|
Wrap your query in another query
SELECT
Location
FROM (
SELECT
locations.id as Location,
1609.34 * 3956 * 2 *
ASIN(
SQRT(
POWER(
SIN(
(55.170000 - abs(locations.latitude))
* pi() / 180 / 2), 2) +
COS(55.170000 * pi() / 180 ) *
COS(abs
(locations.latitude) * pi() / 180) * POWER(SIN((-7.400000 - (locations.longitude)) * pi() / 180 / 2), 2)
)
) as result
FROM locations order by result asc limit 10
) AS L
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "mysql, sql"
}
|
Why does the `edge` path operation create a spurious arrow head?
The following code
\documentclass[tightpage]{standalone}
\usepackage{tikz}
\begin{document}
\resizebox{20cm}{3cm}{
\begin{tikzpicture}[scale=40]
\node (aaa) {AAA};
\draw [->] (aaa.east) edge [out=-30, in=-150] (aaa.west);
\end{tikzpicture}
\begin{tikzpicture}
\node (aaa) {AAA};
\draw [->] (aaa.east) to [out=-30, in=-150] (aaa.west);
\end{tikzpicture}}
\end{document}
compiles to the result shown here:
` to `(aaa.east)` and a second path from `(aaa.east)` to `(aaa.west)`. If you don't want the main path to have an arrow, add the `->` to the options for the `edge` rather than the main path.
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (aaa) {AAA};
\draw (aaa.east) edge [out=-30, in=-150, ->] (aaa.west);
\end{tikzpicture}
\begin{tikzpicture}
\node (aaa) {AAA};
\draw [->] (aaa.east) to [out=-30, in=-150] (aaa.west);
\end{tikzpicture}
\end{document}
=x^4-2x^3-2x^2+2x-1$ over $\mathbb{Q}$?
I have polynomial $P(x)=x^4-2x^3-2x^2+2x-1$ and I have strong suspicions it's irreducible. Any ideas how to prove that?
Thank you.
|
The polynomial is irreducible over $\Bbb Z$ and $\Bbb Q$, because it is already irreducible modulo $3$, so over $\Bbb F_3$, which is easy to see.
Alternatively, you can use Eisenstein with a shift $x\mapsto x+1$, or just see it directly, like in this post: Show that polynomial is irreducible over $\mathbb{Q}$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "abstract algebra, polynomials, irreducible polynomials"
}
|
Community URL - Add Object ID
I have a **public** community (experience cloud) URL which is like: ...force.com/MyCommunityName/s/ Inside it, I have only a lightning component (which contains everything for the page).
I wonder if it would be possible to do like this (or something similar): ...force.com/MyCommunityName/s/0015r00000IhCERAA3
So that I could reference this Id on the Lightning component logic.
Does anyone know if is this possible?
|
Digital Experiences do not support URL addressable components (you find this documented here). You have to create a page in the site (with defined URL), drop the component on the page (ensure that your component has an API property, such as `recordId` that accepts the ID) and populate this property in the component properties in the experience page using an expression (this is all done through the Experience Builder).
If you define the URL to include a named parameter binding, like `/my-url/:recordId`, then the expression just needs to be of the form "{!recordId}". I.e. the binding name (after the colon in the URL) is used.
On the other hand, if you have the URL accept a query parameter, such that the page URL at runtime is like `.../my-url?id=00axxxxxx`, then the expression is of the form "{!id}". I.e. the query parameter name is used.
|
stackexchange-salesforce
|
{
"answer_score": 1,
"question_score": 0,
"tags": "community"
}
|
What's the different between AddObject and Attach when transfer a enttity from one context to another
If I have use database first to build a context, and instantiate this context twice. I want to query a specific entity from the first context and add it to the second context, what's the different between using AddObject and Attach. eg.
Student stu = context1.Students.First();
context1.Detach(stu);
context2.Attach(stu);
and
Student stu = context1.Students.First();
context1.Detach(stu);
context2.Students.AddObject(stu);
What's the difference between them? Thanks in advance!
|
The Attach method will attach the object or object graph in **Unchanged** state. That means if you don't do any modifications to the object after you attach it, EF will not issue any Update/Delete commands for that object when you call `SaveChanges()` method.
But when you use `AddObject` method EF will insert the object as a new entity in `SaveChanges()` method.
If the `context2` is connected to a different database and you want to copy the instance then you can use `AddObject`. Otherwise use the `Attach` method.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "entity framework, objectcontext"
}
|
How to have 2 sequently two retrofit requests and receive as a result Flowable<List<InfoDetail>>?
I have two retrofit requests
@GET("user/info")
Single<Infos> infoLists();
@GET("user/info/{id}")
Single<InfoDetail> shoppingListItem(@Path("id") int id);
Receiving the list of UserInfos I want to fetch more detail info for each user
public Flowable<List<Single<UserExtended>>> test() {
return fetchInfoItems().
map(Items::items).
toObservable().
flatMapIterable(items -> items)
.map(itemDetail -> fetchUserDetail(itemDetail.getId())
.map(userInfoDetail -> new UserDetail(userInfoDetail.id,.....))
.toList()
.toFlowable();}
I want to receive as return `Flowable<List<UserExtended>>` while I receive `Flowable<List<Single<UserExtended>>>`
|
Try flatMapSingle() and your gradle version should be 3.0.0-beta4
public Flowable<List<UserExtended>> test() {
return fetchInfoItems().
map(Items::items).
toObservable().
flatMapIterable(items -> items)
.flatMapSingle(itemDetail -> fetchUserDetail(itemDetail.getId())
.map(userInfoDetail -> new UserDetail(userInfoDetail.id,.....))
.toList()
.toFlowable();}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, retrofit2, rx java2"
}
|
Differentiability of a function on $R^2$ and $C$
Can a function $f:\mathbb R^2\to\mathbb R^2$ that is differentiable not be holomorphic-analytic?.
|
Consider the map $f: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ defined by $$f(x,y) := (u(x,y),v(x,y)) = (x,0).$$ This is differentiable since it's a polynomial. However it does not satisfy the C-R equations because for all $x,y \in \mathbb{R}$, $$\frac{du}{dx} = 1 \neq 0 = \frac{dv}{dy}.$$ It therefore is not analytic when considered as a map from the complex plane to itself.
|
stackexchange-math
|
{
"answer_score": 4,
"question_score": 1,
"tags": "complex analysis, derivatives"
}
|
Remove LF from the last line in file
The last line of my file should not have the LF as last character.
In vim I can do
:set noendofline binary
:wq
see <
How can I do that with a sed oneliner filter for a longer pipe?
Any other tool (headless vim? awk) is ok to me. no perl pls.
How about scala or haskell !?
|
If you want to lose all newlines, the following works:
awk '{printf "%s", $0}'
You could also use `tr -d '\012'` to delete LF (NL) characters; it is probably faster than `awk` for the job.
With a more elaborate `awk` script, you could keep all newlines except the last if that's what you want:
awk '{if (NR>1) print old; old=$0;} END { printf "%s", old }'
(You can't do _that_ with `tr`!) Both these `awk` scripts can be plugged into a pipeline. I don't know if `awk` will handle humongous 'single-line' files, but it probably will handle them OK. Remember that many Unix tools are based around lines -- beware of pushing them too hard, and test carefully before putting into production.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "scala, vim, haskell, sed, awk"
}
|
CSS Chrome transition bug
I'm working on a site and I get a weird bug using transitions.
Website: <
I explain my actions below:
So if you visit the homepage the site is working fine and the hovers as well. (You can hover the big blocks in the middle of the page.)
If you then press the arrow to the right once in Chrome the background changes to the background color of the article and the image disappear behind it!
If I turn off overflow: hidden, it works fine, but then the whole idea of the transition would be gone.
Is this a known bug? And are there any solutions?
Thanks in advance!
|
Add `translateZ(0)` :
.project figure img,
.service figure img,
.owl-item figure img,
.service-item figure img {
width: 100%;
height: auto;
transform: translateZ(0) scale(1);
-ms-transform: translateZ(0) scale(1);
-moz-transform: translateZ(0) scale(1);
-webkit-transform: translateZ(0) scale(1);
-o-transform: translateZ(0) scale(1);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "css, google chrome"
}
|
Local variables in java
I went through local variables and class variables concept.
But I had stuck at a doubt
" Why is it so that we cannot declare `local variables` as `static` " ?
For e.g
Suppose we have a play( ) function :
void play( )
{
static int i=5;
System.out.println(i);
}
It gives me error in eclipse : _`Illegal modifier for parameter i`_ ;
I had this doubt because of the following concepts I have read :
1. Variables inside method : scope is local i.e within that method.
2. When variable is declared as static , it is present for the entire class i.e not to particular object.
Please could anyone help me out to clarify the concept.
Thanks.
|
Because the scope of the local variables is limited to the surrounding block. That's why they cannot be referred to (neither statically, nor non-statically), from other classes or methods.
Wikipedia says about `static` local variables (in C++ for example):
> Static local variables are declared inside a function, just like automatic local variables. They have the same scope as normal local variables, differing only in "storage duration": whatever values the function puts into static local variables during one call will still be present when the function is called again.
That doesn't exist in Java. And in my opinion - for the better.
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 8,
"tags": "java, variables"
}
|
Understanding CTR in Google Webmaster Tools
I've got a site that's showing a 9% CTR for a phrase in Google Webmaster Tools, but the average position for my site is 14th (this includes 7 local results for this phrase).
I was a little confused as to what the CTR actually meant, is it :
* for each person who searches for that phrase 9% of them click my site.
or
* for each person who actually sees my site in the search results 9% of them click through (bearing in mind 14th is high on page 2 when the local listings are used).
|
The CTR is always a calculation of clicks divided by actual impressions of your link. The Webmaster Tools help page says the same, so the last statement would be true.
|
stackexchange-webmasters
|
{
"answer_score": 5,
"question_score": 5,
"tags": "google search console, google search, search results"
}
|
CSS Transforms Performance
I wondered what the difference between `-webkit-transform: translate(5px, 5px)` and `-webkit-transform: translateX(5px) translateY(5px)`
Is there any performance difference? Because `translateX` is also used for 3D transforms. So my question is: Is there any difference in calculating the transform? Can I say that `translateX` is faster, because it uses the GPU? Does it?
How can I meassure the performance?
|
No, but `-webkit-transform: translate3d(5px, 5px, 0)` will be quicker. The two syntaxes you've put are the same, mine uses the 3d context.
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 4,
"tags": "css, webkit, css transforms"
}
|
生活になぶられた、男の子は自殺した。Passive voice in Descriptive Relative clauses, and word choice
>
My translation:
> Tormented by daily life, the boy killed himself.
My other translation:
> The boy who was tormented by daily life killed himself.
I was wondering if there is any nuance when using the passive voice in descriptive relative clauses, and if some of my word choices like and sound natural in this context.
|
Unfortunately, is very rare in modern Japanese, except that the compound is occasionally used.
I'm not sure about the exact nuance of "tormented by daily life", but if I have to find a transitive verb that fits this situation, I would choose or . The latter is mainly used in its passive form ().
> *
> *
>
There is no problem with using passive voice in a relative clause. But don't insert a comma between the noun and the relative clause.
And generally speaking, Japanese language tends to avoid inanimate subjects with transitive verbs. See this discussion, or examples here. If you can replace the subject with , you can say this in various ways using , etc.
|
stackexchange-japanese
|
{
"answer_score": 1,
"question_score": 0,
"tags": "passive voice"
}
|
How to change font of current frame?
I have two displays and different frames on each. Each display has very different DPI so I need different fonts sizes for them.
How can I set different fonts sizes for different frames (font size changes not applied globally)?
|
You could also change font like so :- `(set-frame-font "PragmataPro 13")`, where the 2nd argument is the size you want to use.
EDIT: if you are running emacsclient by connecting to an emacs daemon process, the above answer will not work. Instead put this in your `init.el`: `(setq default-frame-alist '((font . "PragmataPro-13")))`
|
stackexchange-emacs
|
{
"answer_score": 3,
"question_score": 4,
"tags": "fonts"
}
|
Metadata Navigation in Docment Set
I have set Metadata Navigation in a SharePoint site (Classic Experience).
It works well in all document libraries, it works when I open a Folder in these document libraries but it disappears when I open a document set present in these document libraries.
Is it possible to enable Metadata Navigation in document sets?
Thanks in advance.
|
It is by default that metadata navigation cannot be used in a Document Set.
|
stackexchange-sharepoint
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sharepoint online, document library, document set, metadata navigation, classic experience"
}
|
Compilation failed in require when using "use" in Perl
I am using Perl in Eclipse.
In the same directory, I have a `.pl` file and two `.pm` files (pmFile1.pm, pmFile2.pm).
At the top of the .pl file, I use the command:
use pmFile1;
use pmFile2;
I get an error
> Compilation failed in require
I do not believe I had this error earlier. I have researched this error online, and cannot figure out what may have caused it, because I have not found a similar situation to mine that caused the error. I do not know what other information would be pertinent to include, but will add anything if asked...
Thank you.
|
I suggest you **check the module** pmFile1.pm for errors in a terminal shell
$ perl -c pmFile1.pm
syntax error at pmFile1.pm line 1, near "."
pmFile1.pm had compilation errors.
When entering a single dot . as a syntax error into pmFile1.pm and running the p.pl file then the errors below are shown in Eclipse, the same as you described. If you run the .pl file in a terminal shell then you get the same _compilation failed in require_ as in eclipse:
$ perl p.pl
syntax error at pmFile1.pm line 1, near "."
Compilation failed in require at p.pl line 1.
BEGIN failed--compilation aborted at p.pl line 1.
!EPIC output on syntax error
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 9,
"tags": "eclipse, perl, error handling, compiler errors"
}
|
How to access a mapping in a library?
library Lib{
struct Data {
mapping (uint => uint) a;
}
function inc(Data self) internal{
self.a[0] =+1;
}
}
contract Example{
address recipient = 0x0000cafebabe;
Lib.Data data;
function send(){
Lib.inc(data);
}
}
Leads to error
7:9: Error: Member "a" is not available in struct Data memory outside of storage.
self.a[0] =+1;
^----^
|
Have your code changed as below
function inc(Data storage self) internal{
self.a[0]=+1;
}
Note the `storage` part of it. Please understand the concepts of Internal Types for variables and In memory types
|
stackexchange-ethereum
|
{
"answer_score": 5,
"question_score": 4,
"tags": "solidity, contract development, mapping, library"
}
|
How to simulate a user using Nodejs
I want to get the content's of a specific page, but it requires me to login. So my first question is how do a post request with JSON data. And my next question is if I just do post/get request from node will it keep a session for me? Or do I have to something special to get it to work?
|
You will generally need to implement a cookie jar. `request` does this for you.
So all you need to do is turn the cookie jar on, make a HTTP request to `service/login`, then your session should be logged in. Now make a HTTP request to `service/doStuff` and do the stuff you need to do.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "node.js"
}
|
Copying pixels directly into GPU memory with PBO in OpenGL ES 2.0
I read it should be possible to transfer pixel data directly inside the GPU memory using pixel buffer objects. What I'm not understanding is if PBO is supported in OpenGL ES 2.0. I found incoherent information. Is PBO supported under OpenGL ES 2.0?
If not, is there any other way with OpenGL ES 2.0 to place data (RGBA32) directly into a texture?
|
Possibly not, it depends on the video graphics hardware driver you are using. Texas Instruments has provide a bc-cat driver to do the job on OMAP35x and AM35x platforms. Other company like Freescale , do not provide the same function. For opengl es standard, this function is not defined.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 5,
"tags": "opengl es 2.0, gpgpu, pbo"
}
|
sh scripting: how to mount a remote filesystem if it is not mounted?
In a bourne shell script (#!/bin/sh) how can check to see if a remote NFS share is mounted and, if it is not, mount it? I've got an ugly set of cat, greps and ifs using the output of 'mount' at the moment but it doesn't seem to be doing a reliable job.
|
If possible, setting up automount ( autofs ) would be the standard way to do this. It might already be in your distribution (comes with CentOS / Redhat default install ). Here is a tutorial.
Why use Automount?
> Automounting is the process where mounting and unmounting of certain filesystems is done automatically by a daemon. If the filesystem is unmounted, and a user attempts to access it, it will be automatically (re)mounted. This is especially useful in large networked environments and for crossmounting filesystems between a few machines (especially ones which are not always online).
|
stackexchange-serverfault
|
{
"answer_score": 5,
"question_score": 3,
"tags": "shell, nfs, bourne shell"
}
|
Change the output name when download with youtube-dl using python
I tried to follow the tutorial to download a video from youtube:
import youtube_dl
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['
But i see only when using the command(in command line) with option `-o` we can change the output video name. So, how to add change output name option embedded in python script? I think it should be add to `ydl_opts`, but i don't know the syntax, can anybody help?
|
Try like this:
import youtube_dl
ydl_opts = {'outtmpl': 'file_path/file_name'}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(['
Substitute the desired filename and filepath in ydl_opts. `file_path/file_name`
|
stackexchange-stackoverflow
|
{
"answer_score": 25,
"question_score": 15,
"tags": "python, youtube dl"
}
|
If for every cover of open balls there exists a finite sub-cover, then $K$ is sequentially compact
Let $(X,d)$ be a metric space, and let $K\subseteq X$. Suppose that every cover by open balls of $K$ has a finite sub-cover. I need to prove that $K$ is sequentially compact.
I thought on trying to take an arbitrary open cover, and maybe somehow use the fact that every open subset can be represented by a union of open balls, but that failed. Any hints?
|
You want to show that every sequence in $K$ has a limit point. Suppose the sequence $(a_n)$ has none. For each $x\in K$, there exists $\delta_x$ such that the sequence $(a_n)$ visits $B(x,\delta_x)$ only finitely many times.
The set of balls $\\{B(x,\delta_x):x\in K\\}$ is an open cover of $K$ by balls.
Can you finish and fill in the details?
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "general topology, metric spaces, compactness"
}
|
Is Sigma's lens hood LH-825-03 compatible with a 18-50 2.8 EX DC HSM Macro?
I'm looking for a replacement hood for my 18-50 f/2.8 EX DC HSM Macro, but I'm not having much success. I've instead found some hoods for the 17-50 OS (stabilized) version, which also has a 72 mm front element and compatible focal lengths.
As this hood snaps to the outer rim of the front element (with a similar mechanism), I'm wondering if it would be compatible with my lens. Does anybody know the degree of standardization?
**UPDATE:** I've been replied by a Sigma distributor, saying that the appropriate replacement is LH780-04. This does not say anything about the compatibility of LH-825-03 though.
|
Testing with two pairs of Sigma lenses shows that **no hood fits on any other lens**. You have to find a hood with the adequate mount. The lenses tested were:
* ⌀72mm: different generations of the 17-70mm
* ⌀77mm: 10-20mm vs 120-400mm
|
stackexchange-photo
|
{
"answer_score": 2,
"question_score": 1,
"tags": "lens, sigma, compatibility, lens hood"
}
|
What is this question asking for?
I have a question that is: Find a degree 3 polynomial with real coefficients whose leading coefficient is 5 that has -2, 1, and 4 as zeros?
I do not want the question answered for me what I want it explained what it is asking. I answered `5(x+2)(x-1)(x-4)`, but I was told I needed to finish the problem. Not exactly sure what there is to finish.
|
I think it is asking for a polynomial in the form $5x^3 + ax^2 + bx + c$.
So you would multiply out your answer.
As an aside, if that is what it is, it is a silly question. Your answer is fine, IMO.
|
stackexchange-math
|
{
"answer_score": 6,
"question_score": 3,
"tags": "algebra precalculus, intuition"
}
|
How do you provide domain credentials to ansible's mount module?
I've figured out how to use the shell module to create a mount on the network using the following command:
- name: mount image folder share
shell: "mount -t cifs -o domain=MY_DOMAIN,username=USER,password=PASSWORD //network_path/folder /local_path/folder
sudo_user: root
args:
executable: /bin/bash
But it seems like it's better practice to use Ansible's mount module to do the same thing.
Specifically, I'm confused about going about providing the options for `domain=MY_DOMAIN,username=USER,password=PASSWORD`. I see there is a flag for opts, but I'm not quite sure how this would look.
|
Here's the command I ended up going with:
- name: mount product image folder share
mount: state="present"
fstype="cifs"
opts="domain= MY_DOMAIN,username=USER,password=PASSWORD,file_mode=0777,dir_mode=0777" src="//network_path/folder" name="/local_path/folder"
sudo_user: root
sudo: yes
A few notes about it:
1. I don't think the `file_mode=0777,dir_mode=0777` should have to be required, but in my situation is was needed in order for me to have write access to the folder. I could read the folder without specifying the permissions, but I couldn't write to it.
2. This snippet is required right not because of this ansible bug I tested this on 1.9.0 and 1.9.1, and it was an issue in both versions.
`sudo_user: root sudo: yes`
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 7,
"tags": "ansible"
}
|
Why do I need double { but a single } in the following string?
Why do I need double `{` but a single `}` in the following string?
static void Main()
{
Console.Write("a={0}, b={1}, c={{", 1, 2);
foreach (var i in Enumerable.Range(1, 5)) Console.Write("{0},",i);
Console.WriteLine("\b}");
}
!enter image description here
|
Because when you use the templating approach with `string.Format()` or `Console.Write()` with `"{0}"` in strings, the bracket is a special symbol. Therefore, if you want to use an ACTUAL bracket, you need to escape it by doing `"{{"` which will output a single `{`
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 0,
"tags": "c#"
}
|
Construction of sequence with specific properties
I'm trying to costruct a sequence $(g_{n})_{n}$ such that it converges a.e to zero and $$\limsup\int g_{n}d\lambda=1,$$ $$\liminf\int g_{n}d\lambda=-1$$ with respect to Lebesgue measure.
I think $(g_{n})_{n}$ has to be a three step fuction of the form
$$g(x)_{n}=\left\\{\begin{matrix} -1 & \\\ 0& \\\ 1& \end{matrix}\right.$$
but I'm not quite sure what the support of each step for $g(x)_{n}$ has to be.
Any idea would be helpful.
|
Consider $$ g_n= \begin{cases}I_{[n,n+1]}&\text{$n$} \,\text{even}\\\ -I_{[-n-1,-n]} &n \,{\text{odd}} \end{cases} $$ for $n\geq1$.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "real analysis, measure theory, convergence divergence"
}
|
Showing $f(z) = \frac{z-a}{1-\bar{a}z}$ is a Moebius Transformation Given Conditions
As the title suggests, I want to show that $f(z) = \frac{z-a}{1-\bar{a}z}$ where $z,a \in \mathbb{C}$ is a Moebius transformation with $|a|<1$ and $1-a\bar{a} \neq 0$
I'm uncertain as to how to start.
Any help would be appreciated.
Thanks.
|
A Möbius transformation $T$ is most simply defined as a nonconstant fractional linear transformation: the latter means $$ T(z) = \frac{az+b}{cz+d}. $$ To see what nonconstant needs, let $z$ and $w$ be distinct points. Then a calculation shows $$ T(z) - T(w) = \frac{(ad-bc)(z-w)}{(cz+d)(cw+d)}, $$ so if $z \neq w$, $T(z) \neq T(w)$ if and only if $ad-bc \neq 0$. So in fact, $T$ is injective if and only if it is nonconstant.
* * *
So, since your function is already of the form $(az+b)/(cz+d)$, you just have to check that $ad-bc \neq 0$.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 0,
"tags": "complex analysis, mobius transformation"
}
|
Can an object with constant acceleration change its direction twice?
This question is from the book Sears and Zemansky's University Physics.
.
If $dv/dt$ is constant, then if it is positive, it is possible for $v$ to be initially negative and then go through zero. Or if $dv/dt$ is negative it is possible for $v$ to be initially positive and go through zero.
However, it is _impossible_ for the velocity to be zero on two separate occasions unless $dv/dt$ changes sign and thus the acceleration changes with time. Hence it is not possible to change direction twice under uniform acceleration.
|
stackexchange-physics
|
{
"answer_score": 3,
"question_score": 0,
"tags": "homework and exercises, kinematics"
}
|
How to flush frontend Cache from backend in Yii2
I am using YII2 Advanced, on the backend I needed an Action that invalidates the Cache in the frontend.
This is needed because I use yii2mod/yii2-settings, obiously, the settings are being cached on both ends. But I wasn't able to flush the cache from the backen with `Yii::$app->cache->flush();`, this will do it just in the backend.
|
So somehow I found that if I make a reference on the backend components, I end having access to flush on the backend.
On `\backend\config\main.php`
'components' => [
//...
'frontendCache' => [
'class' => 'yii\caching\FileCache',
'cachePath' => Yii::getAlias('@frontend') . '/runtime/cache'
],
]
Now in your controller
Yii::$app->cache->flush(); //backend flush
Yii::$app->frontendCache->flush(); //frontend flush
This took me a while to figure this out, so I hope this helps someone.
|
stackexchange-stackoverflow
|
{
"answer_score": 12,
"question_score": 4,
"tags": "php, yii2, yii2 advanced app"
}
|
How to use ax with Pandas and Matplotlib
I have a very basic question. I am using a pandas dataframe to make this plot, but I want to add highlighting around certain dates.
In[122]:
df1_99.plot(x='date', y='units', ylim=[0,11], figsize=[12,12])
Out[122]: !enter image description here
I found this code on stackoverflow to add highlighting.
fig, ax = plt.subplots()
ax.plot_date(t, y, 'b-')
ax.axvspan(*mdates.datestr2num(['10/27/2011', '11/2/2011']), color='red', alpha=0.5)
fig.autofmt_xdate()
plt.show()
My question is how can I use ax.avxspan with my current code? Or do I need to convert my x='date', and y='units' to numpy arrays and use the format as in the code above?
|
`pandas.DataFrame.plot` will return the matplotlib `AxesSubplot` object.
ax = df1_99.plot(x='date', y='units', ylim=[0,11], figsize=[12,12])
ax.axvspan(*mdates.datestr2num(['10/27/2011', '11/2/2011']), color='red', alpha=0.5)
plt.show()
If you want to create an `ax` object in advance, you can pass it into `plot` as below
fig, ax = plt.subplots()
df1_99.plot(x='date', y='units', ylim=[0,11], figsize=[12,12], ax=ax)
ax.axvspan(*mdates.datestr2num(['10/27/2011', '11/2/2011']), color='red', alpha=0.5)
plt.show()
Finally, you can usually get the current figure and axes objects using the following functions
fig = plt.gcf()
ax = plt.gca()
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 9,
"tags": "python, numpy, pandas, matplotlib"
}
|
How to read first n elements from array
sum=0
read n
read -a array
for i in "${array[@]}"
do
sum=$(( $sum + $i ))
done
echo $sum
I am new in scripting. Here I want to know what can I use to add condition so that reading array will be limited to n times.
Ex:
3
1 2 3 4
here it should add only 1 2 3 and it should not take 4.
|
I prefer the bash C for loop, it doesn't require conditionals to escape the loop and looks neater.
#! /bin/bash
sum=0
read n
read -a array
for ((x=0; x<n; x++))
do
sum=$(( sum + array[x] ))
done
echo "$sum"
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 2,
"tags": "arrays, linux, bash, loops"
}
|
Extract day,month,time of the day from date using Pig
**input format** : Mon, 09/20/10 01:04 PM
Have to extract Day,Month,Time of the day. I'm aware of the inbuilt functions `GetDay`,`GetMonth`,e.t.c
but im getting this following error while using it
> Could not infer the matching function for org.apache.pig.b
> uiltin.GetMonth as multiple or none of them fit. Please use an explicit cast.
even tried `GetMonth(ToDate(date))...` but of no use
|
Simple usage of ToDate() assumes the date string to be in ISO format, which yours is not. You need to provide the function with a format string that describes your date format. See < for details.
Something like
ToDate(date, 'E, M/d/Y K:m a')
should work.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "apache pig"
}
|
Find the median of binary search tree, C++
Once I was interviewed by "One well known company" and the interviewer asked me to find the median of BST.
int median(treeNode* root)
{
}
I started to implement the first brute-force solution that I came up with. I fill all the data into a `std::vector<int>` with inorder traversal (to get everything sorted in the vector) and got the middle element. So my algo is O(N) for inserting every element in the vector and query of middle element with O(1), + O(N) of memory. So is there more effective way (in terms of memory or in terms of complexity) to do the same thing.
Thanks in advance.
|
It can be done in `O(n)` time and `O(logN)` space by doing an in-order traversal and stopping when you reach the `n/2`th node, just carry a counter that tells you how many nodes have been already traversed - no need to actually populate any vector.
If you can modify your tree to ranks-tree (each node also has information about the number of nodes in the subtree it's a root of) - you can easily solve it in O(logN) time, by simply moving torward the direction of n/2 elements.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "c++, algorithm, vector, time complexity, binary search tree"
}
|
Nonlinear unbiased estimator with strictly smaller variance than OLS estimator
I want to find the following example: Construct a linear model $y=X\beta + \epsilon$, where $\epsilon $ is mean zero uncorrelated homoscedestic non-Gaussian noise and $X$ is deterministic, such that there exists a nonlinear unbiased estimator that has a strictly smaller variance than the least square estimator.
I have no idea how to proceed.
|
I would start with the one-sample case. Given the trivial linear model $y=\mu+\epsilon$, where $\epsilon$ is mean zero uncorrelated homoscedestic noise, the OLS estimator is just the sample average. What are some non-linear estimators of $\mu$? Can you choose $\epsilon$ so one of them is better than the sample average? If so, can you expand this to where $\mu=X\beta$ is non-trivial.
One choice for a non-linear estimator would be the median, so you need to find a distribution for $\epsilon$ where the median is unbiased for the mean but has strictly smaller variance than the mean.
|
stackexchange-stats
|
{
"answer_score": 5,
"question_score": 3,
"tags": "regression"
}
|
Ruby / CSV - Convert Dos to Unix
I currently use: < to manually convert DOS CSVs to UNIX. Just wondering if there's a ruby function for the CSV library that I'm missing? And / or if it's possible build a quick script / Monkey Patch.
|
Yes. The CSV docs say:
> The String appended to the end of each row. This can be set to the special :auto setting, which requests that CSV automatically discover this from the data. Auto-discovery reads ahead in the data looking for the next "\r\n", "\n", or "\r" sequence.
`:auto` is the default, so you should be able to feed your DOS CSV to Ruby unmodified.
However, if you want to convert to UNIX line endings:
str.gsub(/\r\n/, "\n")
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "ruby, csv"
}
|
MySQL #1093 - You can't specify target table 'giveaways' for update in FROM clause
I tried:
UPDATE giveaways SET winner = '1' WHERE ID = (SELECT MAX(ID) FROM giveaways)
But it gives:
> #1093 - You can't specify target table 'giveaways' for update in `FROM` clause
This article seems relevant but I can't adapt it to my query. How can I get it to work?
|
This is because your update could be cyclical... what if updating that record causes something to happen which made the `WHERE` condition `FALSE`? You know that isn't the case, but the engine doesn't. There also could be opposing locks on the table in the operation.
I would think you could do it like this (untested):
UPDATE
giveaways
SET
winner = '1'
ORDER BY
id DESC
LIMIT 1
Read more
|
stackexchange-stackoverflow
|
{
"answer_score": 30,
"question_score": 26,
"tags": "mysql, sql, select, subquery, mysql error 1093"
}
|
«Ну ты скажи!» — самостоятельное употребление
Можно ли употреблять « _Ну ты скажи!_ » как отдельную фразу для выражения сильного удивления, как синоним « _Да что ты говоришь!_ », « _Да ты что!_ » и тому подобных?
Насколько я помню, можно, но что-то я засомневался, хотелось бы услышать независимое мнение.
|
Что значит "можно"? Так говорят, в устной речи точно поймут. Поймут и в письменной, а если боитесь, что не поймут, добавьте какую-нибудь ремарку: удивился, удивлённо воскликнул, всплеснул руками и т.п. Да и так из контекста должно быть понятно.
|
stackexchange-rus
|
{
"answer_score": 0,
"question_score": 0,
"tags": "грамотная речь, выбор слов"
}
|
How to force Shotwell write metadata tags to video file?
I have a set of photos and videos that shares a common tag in Shotwell. I'm able to verify those photo files in Nautilus and assert that this tag is written in it. This is confirmed either by exiftools. However, this does not happens in video files. Nautilus doesn't detect any tag, as well as exiftool.
This way, I'm supposing that Shotwell isn't writting this tag to video files. How can I fix this?
|
Currently Shotwell Photo Manager doesn't support editing video metadata, as described in the Shotwell Help Files, the Shotwell mailing list, and the Shotwell Architecture Overview.
* * *
If you need a simple alternative option for single video metadata editing, I would suggest trying VLC.
Here's how to edit a videos' metadata using VLC.
* Click `VLC  -> String {
string.unicodeScalars.filter { !($0.properties.isEmoji && $0.properties.isEmojiPresentation) }.map { String($0) }.joined()
}
Tested with
let filtered = removeEmojisFromString("This is actually pretty easy iOS has a native categorization for emoji? ")
print(filtered)
and the result is `This is actually pretty easy iOS has a native categorization for emoji?`
There are some extra spaces you might need to remove as well but that is another thing.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "ios, unicode, emoji"
}
|
Wrapping std::map and provide pointer to element
I am using a library which offers a function `foo(Widget*)`.
My Widgets are stored in
struct WidgetManager {
std::map<int, Widget> dict;
??? getWidget(int id);
}
Originally I stored (raw) Widget pointers in the `std::map` just because it was convenient to pass them to foo. If I want to store the actual Widgets in the map, what should the return type of `getWidget` be so that I can pass a pointer of the Widget to foo?
I am compelled to make it of type iterator, but I don't like that I have to access `itr->second` to get the Widget(pointer).
|
You can use `&` just before you pass your widget to the `foo(Widget*)` function to get a pointer to it.
struct WidgetManager {
std::map<int, Widget> dict;
Widget& getWidget(int id);
}
usage
WidgetManager wm;
//...
Widget& w = wm.getWidget(id);
foo(&w);
//...
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "c++11, dictionary, iterator"
}
|
Pass Data $http.post From AngularJS and ASP.net MVC gets null
i'm trying to pass data from AngularJS to ASP.net MVC and is always getting null. Here's my code (only posting the essential, button, controller and c#:
HTML:
<a class="btn btn-grey btn-lg btn-block" ng-click="AddCar()">Save</a>
Controller
$scope.AddCar = function () {
$http.post("Cars/AddCar", JSON.stringify($scope.new.JsonCar)).success(function (data) {
Alert(ok)
})
c#
public string AddCar(string JsonCar)
{
try
....
}
In JSON.stringify($scope.new.JsonCar) i'm getting this:
> "{"Name":"FIAT 500","Description":"New car","MaxUserCapacity":5,"PhotoPath":"none"}"
What i'm doing wrong?
|
Pass your object directly as an object rather than stringifying it. As it's being passed right now, it's a string, not an object that can properly be deserialized.
$http.post("Cars/AddCar", $scope.new.JsonCar).success(function (data) {
Alert(ok)
})
Create a Car object that matches your payload. The serializer will handle your JSON object for you.
public Car AddCar(Car car)
{
try
....
}
My assumption is that at some point you are deserializing your string into an object regardless. This just saves you that extra step.
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 7,
"tags": "c#, asp.net mvc, angularjs, angularjs directive, angularjs controller"
}
|
How many ways are there to choose a group of $5$ people from $10$ men and $12$ women if at least $2$ are women?
Question: There are $10$ men and $12$ women. How many ways are there to choose a group of $5$ people where at least $2$ are women?
The correct answer is $${12 \choose 2} * {10 \choose 3} + {12 \choose 3} * {10 \choose 2} + {12 \choose 4} * {10 \choose 1} + {12 \choose 5} * {10 \choose 0}$$ which is pretty straight-forward and correct.
But say we chose $2$ women first, and chose the rest $3$ from the remaining people. So the combination becomes ${12 \choose 2} * {20 \choose 3}$. But it doesn't match with the first answer. What am I doing wrong in the second process?
|
The problem with your second approach is that you are over counting.
For instance, if the group you pick is one with three women, you would count the same group 3 times.
To see this let the people you pick be $A,B,C,D,E$ where $A,B,C$ are the three women. You could have $A,B$ be the women you first choose and then have $C,D,E$ by the people you choose from the rest. Or A,C could be the first women and $B,D,E$ be the rest. Or $B,C$ be the first women and $A,D,E$ be the rest.
In the first answer this group is correctly only counted once.
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 5,
"tags": "combinatorics"
}
|
Dynamic %%First Name%% personalization issues with French accents
Using MOVABLE-INK to display customer name with custom fonts in email as an image. In outlook 2016 PC French name with accent is not showing at all looks like a broken image path, even after using the URLEncode function. Did anyone experience this issue?
%%[var @FirstName set @FirstName = [First Name]]%%
%%[
VAR @encodedEmailFName
SET @encodedEmailFName = URLEncode(@FirstName,1)
]%%
<a href="
<img src="someimage.png? mi_name=%%= v(@encodedEmailFName) =%%"/>
</a>
using Movable-Ink
|
Found a fix for the PC Outlook issue. What I did is URLEncode the [First Name] first and then concatenate it to the URL. Then in the SRC I used RedirectTo or TreatAsContent both works.
%%[ SET @FisrtName = [First Name]; SET @endCodefirstName = URLEncode(@FisrtName,1,1) SET @concatIMg = Concat('< ]%%
|
stackexchange-salesforce
|
{
"answer_score": 1,
"question_score": 1,
"tags": "marketing cloud, email, ampscript"
}
|
std vector C++ -- deep or shallow copy
I wonder whether copying a vector I am copying the vector with its values (whereas this is not working with array, and deep copy need a loop or memcpy).
Could you hint to an explanation?
Regards
|
You are making a deep copy any time you copy a vector. But if your vector is a vector of pointers you are getting the copy of pointers, not the values are pointed to
For example:
std::vector<Foo> f;
std::vector<Foo> cp = f; //deep copy. All Foo copied
std::vector<Foo*> f;
std::vector<Foo*> cp = f; //deep copy (of pointers), or shallow copy (of objects).
//All pointers to Foo are copied, but not Foo themselves
|
stackexchange-stackoverflow
|
{
"answer_score": 127,
"question_score": 72,
"tags": "c++, vector, copy, std, deep copy"
}
|
Getting a string between 2 defined patterns with an end of line
The file under test will have text patterns like this:
name1: function(){
},
name2: function(){
},
name3: function(){
},
I need to get "name1" "name2" and "name3" in this example. So used this bash script:
v1='},'
v2=': function'
sed 's/'"$v1"'\(.*\)'"$v2"'/\1/g' test1.js > newfile2
This seems to work only if the pattern shows up like:
},name1: function
But of course the text file is not formatted this way. it's like this:
},
name1: function
What should I add to the regex that would accomplish what i need? I do not want to change from using `sed`
Thanks
|
sed -n 's/\s*\([^: ]*\): function.*/\1/p' test1.js
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "bash, shell, unix, sed"
}
|
How to show resolved SCSS names in WebStorm
I'm new to WebStorm, having come from VS Code. In my SCSS files in VS Code, if I hover the mouse over the second line in the following code:
.example {
table button.abc:hover {
padding-top: 20px;
}
}
A popup appears as so:
<element class="example">
...
<table>
...
<button class="abc" :hover>
I've found this to be an extremely helpful feature when working with complicated nested CSS rules, as I can see at a glance how it's being resolved. Does WebStorm (or any plugin for it) provide a feature like this?
|
There is no such feature, please vote for WEB-35464 to be notified on any progress with this request
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "css, sass, webstorm"
}
|
What's the probability of me being obliterated if Thanos snaps his fingers twice?
Thanos snaps his fingers and half the Earth's population disappear. He snaps again and half of the remaining half disappear. Now, what is the probability of any given person (for example, myself) disappearing after 2 snaps?
My simplistic reasoning was that, since after 2 snaps 75% of the population are gone, it means that any one person (e.g. me) has a 75% chance of having been eliminated as well.
My friend's asking for a formula, i.e. mathematical proof of this calculation and the best I can come up with is:
1. event (snap): 50% chance of being obliterated
2. event (snap): 50% chance of having survived the first snap and another 50% chance of perishing so 50% x 50% = 25% Sum of two events = 50% + 25% = 75%
Could someone please verify if my logic is sound and what's the correct math behind it.
Thanks so much!
|
Let $E_1$ denote the event that the person was not eliminated by the first snap.
Let $E_2$ denote the event event that the person was not eliminated by the second snap.
Then, a person survives if and only if events $E_1$ and $E_2$ **both** occur.
$p(E_1,E_2) = p(E_1) \times p(E_2|E_1).$
You are given that :
* $p(E_1) = (1/2).$
* $p(E_2|E_1) = (1/2).$
Note that this approach bypasses any need to consider whether any events are _independent_ of each other.
* * *
The confusing part of this problem is that you are actually given $p(E_2|E_1)$, rather than being given $p(E_2)$.
|
stackexchange-math
|
{
"answer_score": 5,
"question_score": 6,
"tags": "probability"
}
|
Calculate Rows per Column for CSS in VB.NET?
I am trying to figure out a calculation I can perform in C# to determine the rows per column. Let's say I know I am going to have 3 columns and my record count is 46. I know that I can mod the results to get a remainder, but I would like something more efficient than what I have tried. So I know I will have 16 rows per column with a remainder of 14 for the last column, but what is the best way to loop through the resutls and keep counts.
|
Integer divsion will give you the number of complete rows (46 / 3 = 15). You then check the modulus to see if you have any leftover (46 Mod 3 = 1; yep, you have one column to put in a final extra row.)
To loop through, just check the modulus of the current record index (zero-based) with your column count. That modulus is the (zero-based) column index. If it equals 0, you start a new row.
But from your question, it sounds like you already got this far. So am I misunderstanding the question?
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "vb.net, math"
}
|
How to see more items in Delphi7 "View Unit" frame?
I'm working in Delphi 7 on a project which as of late contains 56 units and will require a dozen more soon. I'm often switching between units using **View Unit** frame (Ctrl+F12). But it has one annoying flaw - the frame is rather small, it fits only 20 items. I have to scroll up and down to select unit I need to work on.
What are the solutions to make working with such many units easier? I'm especially looking forward to a patch or tweak to allow me to make **View Unit** frame taller, but I would like to avoid complex and/or costly plug-ins.
Thanks in advance!
|
try using the `View Units` of the ~~GExperts~~ `CnPack`
!enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "delphi, ide, delphi 7"
}
|
What is going on in this x86 instruction?
cmp %eax,0x80498d4(,%ebx,4)
I understand that the eax register is being compared to something, but I have no idea what eax is being compared to.
In other words, what does
x80498d4 (,%ebx,4)
mean?
|
It compares eax to the contents of address [0x80498d4 + (4 * ebx)]
Source: <
|
stackexchange-stackoverflow
|
{
"answer_score": 5,
"question_score": 1,
"tags": "assembly, x86"
}
|
How do I change UIView Size?
I have trouble with modifying my UIView height at launch.
I have to UIView and I want one to be screen size * 70 and the other to fill the gap.
here is what I have
@IBOutlet weak var questionFrame: UIView!
@IBOutlet weak var answerFrame: UIView!
let screenSize:CGRect = UIScreen.mainScreen().bounds
and
questionFrame.frame.size.height = screenSize.height * 0.70
answerFrame.frame.size.height = screenSize.height * 0.30
It has no effect on the app during run time. I use autolayout but I only have margins constraints...
Am I doing it all wrong?
|
Here you go. this should work.
questionFrame.frame = CGRectMake(0 , 0, self.view.frame.width, self.view.frame.height * 0.7)
answerFrame.frame = CGRectMake(0 , self.view.frame.height * 0.7, self.view.frame.width, self.view.frame.height * 0.3)
|
stackexchange-stackoverflow
|
{
"answer_score": 65,
"question_score": 76,
"tags": "uiview, swift, height, xcode6"
}
|
Sargability question - order of variables
I have a stored procedure that has a few lines:
AND ( @StartDate IS NULL OR @StartDate <= r.ReferralDate )
AND ( @EndDate IS NULL OR @EndDate >= r.ReferralDate )
Should it be re-written as:
AND ( r.ReferralDate >= @StartDate or @Startdate IS NULL )
AND ( r.ReferralDate <= @EndDate or @EndDate IS NULL )
I tried it both ways and looking at the execution plans. There is a small difference in estimated number of rows, but other than that I do not see a change, so I assumed that the order in the statement did not matter, but was hoping someone could verify.
|
The short answer is that the order you put these in makes no difference to SARGability. If you want this to be as efficient as possible, you can add a RECOMPILE hint, or use dynamic SQL to generate the appropriate WHERE clause.
Since you seem to understand the concepts involved, I won't beat any dead horses here, I'll just point you to a great source on the subject: Dynamic Search Conditions in T‑SQL
|
stackexchange-dba
|
{
"answer_score": 5,
"question_score": 1,
"tags": "sql server, t sql, performance, query performance"
}
|
fortran: how to pass a null pointer to a subroutine, in which it will be defined and returned
I want to have a small subroutine to make a duplicated copy of a pointer, which is already allocated /defined. I have the following test code:
implicit none
real ,pointer :: x(:),y(:)
real,target:: px
px=2.02
allocate(x(10))
x=20.0
call copy_1dptr(x,y) !code aborting
write(6,*)'size x is ',size(x)
write(6,*)'y is ',y
end
subroutine copy_1dptr(x,y)
real,pointer:: x(:),y(:)
allocate(y(size(x)))
y=x
end subroutine copy_1dptr
However, (using ifort), when I ran it, I always got the aborting error, with message saying:
> forrtl: severe (408): fort: (7): Attempt to use pointer Y when it is not associated with a target
Seems, the null pointer can't be used as an actual dummy like what I tried to do. Is that true? Are there any solution to this.
|
Pointer arguments require explicit interface. Place the subroutine in a module or make it internal:
contains
subroutine copy_1dptr(x,y)
end subroutine
end program
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "pointers, fortran, subroutine"
}
|
Can I use Windows Error images (Red circle with white cross) in my WPF project?
I have made a custom error message box for my project. In the View for this, I have an image which should be used for message type (Error, Info, Warn, etc.) which Windows already has built-in images for. Is there a way I can use these images via setting the source property in XAML programatically?
(I have been using this guide for making the box, if it helps)
|
I believe this works, if you want to do it the nasty way (it's the only way I know to get the "WinForms style" images):
var sii = new SHSTOCKICONINFO();
sii.cbSize = (UInt32)Marshal.SizeOf(typeof(SHSTOCKICONINFO));
Marshal.ThrowExceptionForHR(SHGetStockIconInfo(SHSTOCKICONID.SIID_WARNING, SHGSI.SHGSI_ICON, ref sii));
ImageSource = Icon.FromHandle(sii.hIcon).ToImageSource();
Note: I chose not to use this, and instead just included images in my resources to use as I needed them.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c#, wpf"
}
|
How to add country code dynamically in telephone field on Checkout in Magento 2
I want to develop custom module that is used for adding country code field before telephone field on checkout page in magento 2.3.4.
|
Here is the some free and paid extension available, you can use it:
Free - <
Paid - <
Thanks
|
stackexchange-magento
|
{
"answer_score": 2,
"question_score": 0,
"tags": "layout, knockoutjs, plugin, helper, custom block"
}
|
Applying for german residence permit after entering
I'm Ukrainian and I hold valid polish residence permit. However, I got accepted for the graduate study program in Germany, which lasts more than 6 months. Am I allowed to enter Germany using polish temporary residence permit and apply for german residence permit after entering? Or am I obligated to apply for german visa in order to enter Germany for study purposes?
|
No, you have to apply for a German student visa before you move to Germany. If you cross the border and try to get a Residence permit, you will be denied one as the paperwork in the German side is not available, since you didn't apply for a visa.
Getting a German visa inside the EU should not take long (around 2-3 weeks).
Additional information from here: <
> As long as you are not a citizen of a country whose citizenship allows you to enter Germany freely (please check the list of states below), you are residing legally in Poland (e.g. Karta pobytu, D-Visa) and you plan to stay in Germany for more than 3 months (family reunion, studying) or to work in Germany, you need a visa for entering the country.
|
stackexchange-expatriates
|
{
"answer_score": 4,
"question_score": 1,
"tags": "germany, residence cards"
}
|
Differentiation of exponential function?
How to solve derivative $\lim_{n\to\infty}e^{{}^n(x)}$ with respective of $x$ ? Here, ${}^n(x)$ is a tetration function $$ {}^n(x)= \begin{cases} x^{[{}^{n-1}(x)]} & \mbox{ if } {\;n>1}\\\ x & \mbox{ if } {\;n=1}\\\ \end{cases} $$ Anyone give me any idea how can resolve this problem ?
Thanks
|
If you have meant $$\displaystyle e^{(x^{x^{\cdots\infty}})}$$
I will write $$\displaystyle x^{x^{\cdots\infty}}=y\implies x^y=y\ \ \ \ (1)$$
Now, the problem becomes $$\frac{d(e^y)}{dx}$$ $$\text{ which is }=e^y\cdot\frac{dy}{dx}$$
Can you find $\displaystyle\frac{dy}{dx}$ from $(1)$
|
stackexchange-math
|
{
"answer_score": 3,
"question_score": 2,
"tags": "ordinary differential equations, derivatives, exponentiation, exponential function"
}
|
Insert None while iterating list of months
I have a list with a range of year/month. Then, I also have a count of users with this format: total_users, month, year.
Basically I need to insert `None` when there is no count value for the month in all_months_necessary.
all_months_necessary=('2015/1', '2015/2', '2015/3', '2015/4', '2015/5', '2015/6', '2015/7', '2015/8', '2015/9', '2015/10', '2015/11', '2015/12', '2016/1')
users_count=[(2L, 1.0, 2015.0), (1L, 3.0, 2015.0), (1L, 1.0, 2016.0)]
I am trying this code, but the problem is that I will have more Nones than expected.
data=()
for each_month in all_months_necessary:
for total, month, year in users_count:
if each_month == str(int(year))+'/'+str(int(month)):
data = data + (total,)
else:
data = data + (None,)
expected: `data=(2L, None, 1L, None, None, ..., 1L)`
|
It may be better to convert `users_count` to dictionary. Yet another ~~one~~ twoliner:
user_count_dict = {str(int(year))+'/'+str(int(month)): total for total, month, year in users_count}
# get(x) returns None if a key not in the dict
data = [user_count_dict.get(x) for x in all_months_necessary]
And plus to Jason for explanations
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 1,
"tags": "python, python 2.7"
}
|
Java Converting long to bytes - which approach is more efficient
I have two approaches to convert long to byte array.
for (int i = 0; i < 7; i++) {
data[pos + i] = (byte) (value >> (7- i - 1 << 3));
}
and
for (int i = 7; i >= 0; --i) {
data[p + i] = (byte)(newl & 0xff);
newl >>= 8;
}
which of the two operations is more efficient?
|
I suggest you look at how the Java code does it.
public final void writeLong(long v) throws IOException {
writeBuffer[0] = (byte)(v >>> 56);
writeBuffer[1] = (byte)(v >>> 48);
writeBuffer[2] = (byte)(v >>> 40);
writeBuffer[3] = (byte)(v >>> 32);
writeBuffer[4] = (byte)(v >>> 24);
writeBuffer[5] = (byte)(v >>> 16);
writeBuffer[6] = (byte)(v >>> 8);
writeBuffer[7] = (byte)(v >>> 0);
out.write(writeBuffer, 0, 8);
incCount(8);
}
as you can see, without a loop you have less operation.
The fastest way is to not do this at all and instead using Unsafe.writeLong() as this take a long and places it directly into memory instead of breaking it into bytes. This can be more than 10x faster.
|
stackexchange-stackoverflow
|
{
"answer_score": 13,
"question_score": 3,
"tags": "java, byte, bit shift, endianness"
}
|
referencing appSettings from usercontrols
In my .ascx usercontrol i'm trying to dynamically generate links using a value i've stored in web.config.
<a href="<%$appSettings.MYPATH%>/file.aspx">link</a>
and when i try running, i get a parser error
Literal expressions like '<%$appSettings.MYPATH %>' are not allowed. Use <asp:Literal runat="server" Text="<%$appSettings.MYPATH%>" /> instead.
I know i'm probably missing something relatively minor.
|
<a href="<%= System.Configuration.ConfigurationManager.appSettings("MYPATH") %>">link</a>
should work (it at least does on the IIS server I use). (Unfortunately it's more verbose)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "asp.net, user controls, web config, appsettings"
}
|
CGPDFDocumentCreateWithURL will download the file in to documents directory or not
I am accessing the PDF files available in my PHP server using my iPhone with the help of passing file url to CGPDFDocumentCreateWithURL. My question whenever i access the files it will downloaded to my iphone documents directory or not?
Because if my application in active for some time i am getting the error CFURLCreateDataAndPropertiesFromResource with error code -14. After getting this error my application is not crashed but it is not functioning properly.
I am not able to understand the internal process? Please help me in this issue?
|
I think you're misunderstanding what `CGPDFDocumentCreateWithURL` does. It does not download a PDF document to the filesystem. It creates a PDF in memory based off the URL provided. It doesn't save anything to the filesystem.
I would _strongly_ recommend you use a networking class (NSURLConnection, ASI, etc) to download the PDF _first_ and then open it. This will enable you to provide better feedback, and support more advanced download features such as resuming partial downloads, providing progress, and better thread management.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "iphone, pdf, cgpdfdocument"
}
|
Difference between can.Construct and can.Construct.extend
I am reading CanJS API documentation and came across **can.Construct.extend** < .I know that can.Construct creates a constructor function but not able to figure out the use of can.Construct.extend. Can anybody please explain me the difference between can.Construct and can.Construct.extend. If you can explain it with some example, that would be awesome.
Thanks in Advance
|
The two are functionally the same. Internally, `can.Construct()` and all of its derivative classes call `extend()`. It's all down to stylistic preference: `can.Construct()` or `<something derived from can.Construct>()` is slightly shorter but you might confuse it with `new <something derived from can.Construct>()` which creates a new instance, while using `<something derived from can.Construct>.extend()` is unambiguous
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "javascript, canjs, canjs construct"
}
|
if statement in SQL computed Column Specification
I'm trying to built in if statement in computed column What I'm trying to accomplish should look like this but this is more pseudo code: SalePrice-Cost-(if(isConsigned=1 Then Payout else 0))
How do I this and can I use if statement inside computed column or it should be something else?
|
This:
SalePrice-Cost-(iif(isConsigned=1, Payout, 0))
Or
SalePrice-Cost-(CASE isConsigned WHEN 1 THEN Payout ELSE 0 END)
|
stackexchange-stackoverflow
|
{
"answer_score": 12,
"question_score": 6,
"tags": "sql server, tsql, sql server 2016"
}
|
Trying to add images to a list
I am trying to store image sources in an array and then add them into a list using javascript.
here is my code:
var imgSrc = new Array ("images/hangings/1.jpg","images/hangings/2.jpg");
for (var i = 0; i < prices.length; i++)
{
$('#products ul').append('<li><img src="imgSrc[0]"/></li>');
}
When i load the site it displays the image boxes where i want them to be, but the images are blank. Whats wrong?/>
edit. i tried using single quotes but i got a "missing ) after argument list" error
|
`imgSrc` needs to be called as a function, not as a string.
Also `imgSrc[0]` should be `imgSrc[i]` so that it uses the current index your looping through (not `0` every time)
$('#products ul').append('<li><img src="' + imgSrc[i] + '"/></li>');
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "javascript, jquery, html, arrays, image"
}
|
Service Fabric Actors, ReceiveReminderAsync and CancellationTokens
I have an Azure Service Fabric actor that uses reminders.
* What happens if I delete my service or upgrade it while the actor is in the middle of the `ReceiveReminderAsync` method?
* Can I send a cancellation token to the `ReceiveReminderAsync` method?
|
Actors follow the single entry pattern by default. While a reminder callback is being processed, no other operations (like Deactivate) can occur. Deletions (unless forced) and upgrades are delayed until the operation completes.
The receive reminder uses the IRemindable interface. It has no cancellation support.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "azure, azure service fabric, cancellationtokensource, service fabric actor"
}
|
Entity Framework Code First mapping a Navigation Property as a Column in Database
I am using Code First Migration. The Customer `Role` Property is a navigation property but the entity framework maps this property as a Column in the Database! What's wrong in my code as follows:
public class Role
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public Role Role { get; set; }
public byte RoleId { get; set; }
}
|
Your `RoleId` data type in `Customer` class is mismatched! Make it `int` instead of `byte` as follows:
public class Role
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public int RoleId { get; set; }
public Role Role { get; set; }
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -1,
"tags": "c#, entity framework"
}
|
How to find lost Safari password on iPhone
I need to know how to access a password that I lost on my iPhone. The password was saved using Safari but for some odd reason I can no longer access those passwords
|
If the password isn’t showing on the website you intend, you can retrieve it manually. Settings -> Passwords & Accounts -> Website & App Passwords.
|
stackexchange-apple
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, ios, password, mobile safari"
}
|
Multiple arithmetic operations on single tensor
For a 2D tensor with even and odd numbers, I would like to do different arithmetic operation depending on if the number in the tensor is even or odd. I've created the tensor and created a corresponding true false (even or odd) tensor, but am not sure how to proceed.
import torch
list1 = [
[10, 25, 75, 10, 50],
[25, 30, 35, 40, 30],
[45, 50, 55, 60, 20],
[50, 20, 15, 20, 10],
[10, 25, 40, 50, 35]]
tensor2 = torch.tensor(list1)
tensor3=tensor2 % 2
print(tensor3)
print(torch.eq(tensor3, 0)) #even numbers
print(torch.eq(tensor3, 1)) #odd numbers
#do 3x+1 for odd numbers, ie the tensor where indexes are false for even
#do x/2 for even numbers, ie the tensor where indexes are true for even
|
You're looking for torch.where
In your case the code would be:
list1 = [
[10, 25, 75, 10, 50],
[25, 30, 35, 40, 30],
[45, 50, 55, 60, 20],
[50, 20, 15, 20, 10],
[10, 25, 40, 50, 35]]
tensor2 = torch.tensor(list1, type = torch.float64)
res = torch.where(tensor2 % 2 == 0, tensor2 / 2, tensor2 * 3 + 1)
>>> res
tensor([[ 5., 76., 226., 5., 25.],
[ 76., 15., 106., 20., 15.],
[136., 25., 166., 30., 10.],
[ 25., 10., 46., 10., 5.],
[ 5., 76., 20., 25., 106.]], dtype=torch.float64)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "pytorch"
}
|
Converting datetime to varchar with just the date portion
If `SELECT GETDATE()` produces `2014-09-05 11:06:38.927` and `SELECT CONVERT(VARCHAR(50), GETDATE(), 101)` produces `09/05/2014`, why, then, does `SELECT CONVERT(VARCHAR(50), '2014-09-05 11:06:38.927', 101)` produce `2014-09-05 11:06:38.927` instead of `09/05/2014`?
|
Your value in the third statement that you are converting is already a string. Convert will convert the value and drop the time if you first convert the string to a date:
SELECT CONVERT(VARCHAR(50), CAST('2014-09-05 11:06:38.927' as DATETIME), 101)
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "sql server, sql server 2008"
}
|
Command line utility to retrieve password, that has no echo back
Bash builtin read command doesn't seem to support it, now I need to let user input a password while no echo should be displayed, what tool can I use?
|
#!/bin/bash
stty -echo
IFS= read -p 'Enter password: ' -r password
stty echo
printf '\nPassword entered: %s\n' "$password"
* `stty -echo` turns off the terminal echo, which is the display you're talking about;
* `IFS=` is necessary to preserve whitespace in the password;
* `read -r` turns off backslash interpretation.
In `bash` you can also use `read -s`, but this feature isn't standard across shells.
|
stackexchange-unix
|
{
"answer_score": 23,
"question_score": 14,
"tags": "bash, input"
}
|
How do I set the src to an iframe with jQuery?
My iFrame looks like this:
<iframe id="iframe" name="iframe1" frameborder="0" src=""></iframe>
And my script looks like this:
<script type="text/javascript">
$(document).ready(function() {
$('#iframe').attr('src',
})
</script>
I've also tried putting quotes around the url:
<script type="text/javascript">
$(document).ready(function() {
$('#iframe').attr('src','
})
</script>
But neither is working.
What am I missing?
|
If you look at the browser's error console, you'll see the real problem:
> Refused to display '< in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
Google doesn't let you do that.
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 17,
"tags": "javascript, jquery, iframe, src"
}
|
MAAS for diskless computational hpc cluster
I'm considering to use MAAS to deploy OS for a computational cluster. All nodes are diskless. Only head node and (probably) MAAS rack controller will have hard drives. It seems MAAS have to finish a node commissioning before using it, but how possible to commission a node without system installation?
After one day search no result, only clouds with Juju. Any suggestions?
|
There's HPC system provisioners that will achieve what you want. Which is running stateless compute nodes from RAM. And it's recommended to use them because they are designed to provide the required resources for HPC systems.
I would recommend picking up any of the following:
* xCAT: <
* Warewulf: <
* Bright Computing Easy8: <
All of them are free, except Easy8, that is free up to 8 compute nodes. It's a proprietary software. Personally I would go for xCAT.
|
stackexchange-serverfault
|
{
"answer_score": 0,
"question_score": 3,
"tags": "cluster, deployment, hpc"
}
|
<a> onclick not clickable without href
<a class="btn2" onclick="alertbox()">link </a>
<script>
function alertbox() {
alert("alert box");
}
</script>
I have tried to use the css below to try and fix it but that does not make it clickable it only changes the cursor
.btn2 {
cursor: pointer;
}
but that only changes the cursor when i hover over it and dont make it actually clickable
sorry if really obvious answer only recently i started to do html
|
Add some text to `<a>` and it works:
.btn2 {
cursor: pointer;
}
<a class="btn2" onclick=alertbox();>Link</a>
<script>
function alertbox() {
alert("alert box")}
</script>
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html"
}
|
Most Important Limitations Of The Entity Framework
What are the most important limitations of the ADO.NET Entity Framework 4.0 that business application developers should be aware of?
I have used it in some pet projects of mine and it seems very efficient, but I am concerned about the problems I will face when I am building large, more complex data-driven business applications. I am especially interested in how choosing to use the Entity Framework to access my data might limit the different design patters/architectures that I might want to use when building my project.
Because I am thinking about using the entity framework in future projects, I am only interested in limitations of the current version of the Entity Framework.
|
You need to be aware of database chatter. Persisting an entire object graph is not really a good idea. When doing a complex query and update, EF will always try update the inserted objects. The solution to this is having complex query and update logic in a stored proc and by passing object graphs in via XML/string, etc for a single DB call.
Another issue with EF when doing design first or DB first modelling is that the Entity classes themselves are coupled to the framework via inheritance. There are several strategies around this, I have a blog post that lets to use POCO's while extracting an interface at the same time for mocking, which is really handy.
Getting the entity framework to Generate an interface for Mocking
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 4,
"tags": "entity framework, architecture"
}
|
Sun Grid Engine: submitted jobs by qsub command
I am using Sun Grid Engine queuing system.
Assume I submitted multiple jobs using a script that looks like:
#! /bin/bash
for i in 1 2 3 4 5
do
sh qsub.sh python run.py ${i}
done
`qsub.sh` looks like:
#! /bin/bash
echo cd `pwd` \; "$@" | qsub
Assuming that 5 jobs are running, I want to find out which command each job is executing.
By using `qstat -f`, I can see which node is running which jobID, but not what specific command each jobID is related to.
So for example, I want to check which `jobID=xxxx` is running `python run.py 3` and so on.
How can I do this?
|
I think you'll see it if you use `qstat -j *`. See < .
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "qsub, sungridengine"
}
|
How to get price of ETH to DAI within smart contract?
Is it possible to get the current price of Ethereum to Dai within a smart contract? Can this be done without a transaction, using a read operation by the nodes on some kind of existing decentralized exchange or the dai contract itself?
|
You can use MakerDAO's ETHUSD feeds to get price of ETH in USD. This should be extremely close (<1% difference usually) to ETHDAI in the short term, and average to much closer in the long term (<0.1% usually).
Alternatively, you can use the ratio of ETH to DAI in the Uniswap ETH/DAI exchange to estimate the price, which is located here
|
stackexchange-ethereum
|
{
"answer_score": 2,
"question_score": 1,
"tags": "stablecoins"
}
|
How do I pass a value into a python function without calling?
I was unable to find a reasonable way to create a variable which calls a function requiring parameters.
Here is a simplified version of my code. I would like ‘print_hello’ to print ‘hello’ when it is called, and not when it is defined.
print_hello = print(‘hello’)
When I define ‘print_hello’, it calls `print(‘hello’)`. When I call ‘print_hello’, it gives me an error. How do I fix this?
|
Just define `print_hello` as a lambda function
>>> print_hello = lambda: print('hello')
>>> print_hello()
hello
To delay execution, you'll have to wrap the call to `print` in another function. A lambda is less code than defining another function.
**Note:** that pep08 recommends using a def function rather than a lambda when assigning to a variable. See here. So @Sheldores answer is probably the way to go.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 4,
"tags": "python, function, parameters"
}
|
Zero Vectors for Vector Spaces other than $R^n$
I understand what a zero vectors is in $R^n$ but I need some help visualising other zero vectors:
For example, the vector space of all functions $${ y : \mathbb R \rightarrow \mathbb R \ \ | \ y''+xy'+e^xy=0 } $$ Is the zero vector just $z(x)=0$ ? Explicit examples of less obvious vector spaces would be greatly appreciate ted.
Another example could be the set of all functions $$y:\mathbb R\rightarrow\mathbb R \ \ | \ y''= 0$$
In this example wouldn't the zero vector be any functions $z(x)=ax+b$ but does this contradict the fact that the zero vector is unique? Or does that fact mean that the set above is NOT a vector space?
Kind Regards,
Hugh
|
Yes, the zero vector is the zero function $z(x) = 0$ (in both of your examples). In your second example, $z(x) = ax+b$ is NOT the zero element, because for a generic function $f(x)$, it is NOT true that $f(x) + ax + b = f(x)$. The "zero vector" must be an "additive identity", meaning if you add it to anything, it doesn't change.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "linear algebra"
}
|
Is it generally understood that tech recruitment emails are constantly sent out?
I'm a web developer, and I get usually 2-3 recruiter emails a day regarding various positions. Some are good/relevant offerings, and some seem to fall in the category of "this guy has worked with computers, so he's clearly relevant for this laboratory technician role".
Sometimes I'd like to share funny/bad/irrelevant offers I get emailed through, but I fear it could lead people to believe I'm secretly looking for another job.
Is it generally understood in the tech industry that job offer emails don't indicate that somebody is looking for a job, or should I just refrain from sharing?
|
I would say it's pretty darn commonplace. Personally, I would think a direct report posting a ridiculous offer would indicate they are either not shopping, shopping and totally oblivious, or shopping and don't care who knows it. I would expect that I know which category that person is likely in.
If you want to make it crystal clear, you could start the post with something like
> I constantly get unsolicited job ads and some of them are outrageously out of touch. Here's a great example...
|
stackexchange-workplace
|
{
"answer_score": 23,
"question_score": 15,
"tags": "job offer, united kingdom, tech industry"
}
|
Instance of an object in C#
I am encountering a bug in a game I am trying to make. I am getting the following error.
NullReferenceException: Object reference not set to an instance of an object
This same code works fine in one of my other scripts but in this one it continues to through this error. I thought I set it to an instance of the object but I guess not.
UnityEngine.Component book001GUIOld = GameObject.FindWithTag("Book001Canvas").GetComponent("Canvas");
UnityEngine.Behaviour book001GUI = (UnityEngine.Behaviour)book001GUIOld;
Any Suggestions? Let me know if you need more of the code. I have also tried.
UnityEngine.Behaviour book001GUI = GameObject.FindWithTag("Book001Canvas").GetComponent("Canvas") as behaviour;
|
From the GameObject.FindWithTag documentation:
> **Description**
>
> Returns one active GameObject tagged `tag`. Returns `null` if no GameObject was found.
So you might want to try to catch the error:
var book001Canvas = GameObject.FindWithTag("Book001Canvas");
if (book001Canvass != null)
{
UnityEngine.Component book001GUIOld = book001Canvas.GetComponent("Canvas");
}
else
{
// Recover from not finding an object with the Book001Canvas tag
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "c#, unity3d"
}
|
how add records to a partitioned delta table?
I am practicing with the partitioning of a table, I have this
df.write.format("delta").mode("overwrite").partitionBy("Month").save(path)
But I'm not sure how add records, maybe something like this
df2.write.format("delta").mode("append").partitionBy("Month").save(path)
|
Yes, if you just need to append new records, you need to use `append` mode instead of `overwrite`. In future, when you will need to update some records & insert other, then you need to look onto MERGE INTO command.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "pyspark, databricks, azure databricks, delta lake"
}
|
Testing if a password for an eCryptfs mount is valid
I'm using _"eCryptfs"_ on several directories on my dedicated Debian server. I mount them manually via
mount -t ecryptfs [dir] [mountpoint]
But after some weeks being mounted it's not easy to remember the exact passwords for each directory. I want to make sure that I got the right passwords before unmounting them or rebooting the server.
I thought of generating an _"eCryptfs"_ signature and comparing it with the directory's _"eCryptfs"_ signature. Which parameters do I need to know and what is the algorithm for the _"eCryptfs"_ signature? And is this the right way to verify my password?
|
You can use the ecryptfs-add-passphrase command to add a passphrase to your kernel keyring, which will also print the signatures (hashes) to standard out.
Once you've added a passphrase to the keyring, you might want to clear it, using the keyctl command.
eCryptfs uses a PBKDF2-like, key strengthening algorithm of 65536 rounds of SHA512.
( **Disclosure:** I am one of the authors and maintainers of eCryptfs.)
|
stackexchange-crypto
|
{
"answer_score": 4,
"question_score": 1,
"tags": "file encryption, password based encryption, disk encryption"
}
|
Comparing the same row in SQL Server table
How to display the result like India Vs Pakistan, India Vs Sri Lanka, India Vs Bangladesh, Bangladesh Vs Sri Lanka, Bangladesh Vs Pakistan, Pakistan Vs Sri Lanka from the below table?
Teams
-------
India
Pakistan
Sri Lanka
Bangladesh
For Example:
--Output:
Bangladesh vs. India
Bangladesh vs. Sri Lanka
Bangladesh vs. Pakistan
India vs. Sri Lanka
India vs. Pakistan
Pakistan vs. Sri Lanka
|
I guess you are looking for non repeating combinations of team matches. Try below:
CREATE TABLE temp
(
Team VARCHAR(100)
)
INSERT INTO temp
VALUES ('India'),
('Bangladesh'),
('Sri Lanka'),
('Pakistan')
SELECT t1.team + ' vs. ' + t2.team
FROM temp t1
CROSS JOIN temp t2
where t1.Team < t2.Team
DROP TABLE temp
Result
-----------
India vs. Sri Lanka
India vs. Pakistan
Bangladesh vs. India
Bangladesh vs. Sri Lanka
Bangladesh vs. Pakistan
Pakistan vs. Sri Lanka
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "sql, sql server 2012, oracle sqldeveloper"
}
|
Searching for a Facebook venue using geolocation
I'm trying to retrieve a venue's information by searching for it using a particular geolocation on facebook. I'm trying to do this using FQL.
For example, I want to retrieve a Starbucks places info (I know the Starbucks is actually there), so far i have come up with:
SELECT name, description, latitude, longitude, checkin_count
FROM place
where page_id in ( SELECT page_id from place where name = 'Starbucks' ) and distance(latitude, longitude, "9.961718","-84.054542") < 1000
But unfortunately I only get the following error
> "Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from < "
Does someone know what am i doing wrong or how to do what i'm trying to?
|
### FQL answer (deprecated)
_Since FQL is deprecated and unusable, you will now find the FQL way of doing this in the revision history of this post._
### Graph API (up-to-date)
To find a place, you can use the Graph API Search.
> **Places:** `/search?q=coffee&type=place`. You can narrow your search to a specific location and distance by adding the center parameter (with latitude and longitude) and an optional distance parameter: `/search?q=coffee&type=place¢er=37.76,-122.427&distance=1000`
So, the Graph API query that might interest you, would be:
/search?q=Starbucks&type=place¢er=9.961718,-84.054542&distance=1000
Also, note that `distance` represents meters.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 3,
"tags": "facebook, facebook graph api, geolocation, facebook fql"
}
|
scalajs-jquery jQuery get method?
I'm trying to rewrite some code from JavaScript with "jQuery" to "Scala js" with "scalajs-jquery"
Here is my code:
val imgWidth: Int = jQuery(".advertise-wrap img").get(0).asInstanceOf[dom.html.Image].naturalWidth
This gives me error in web browser console:
> jQuery$1(...).get(...) is undefined
What I'm doing wrong? How correctly to get first element?
|
It looks like you're doing the right thing. Make sure that `jQuery(".advertise-wrap img")` returns a non-empty selection. For example, you can test that with
println(jQuery(".advertise-wrap img").length)
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "scala.js"
}
|
linux setting ulimit -n over 1 million
I'm building an system where I have 1 million open connections open at the same time and some of them reconnect but the thread still waits the deadline.
ulimit -n 999999 is the maximum I can get everything over it will give an error message
`-bash: ulimit: open files: cannot modify limit: Operation not permitted`
How can I set this higher? Why is there even an limit?
|
Start by settting this in sysctl:
# sysctl -w fs.nr_open=1000000000
Then you can set the ulimit
# ulimit -n 1000000000
This will give you 1000000000 as your ulimit:
# ulimit -n
1000000000
1000000000 is the highest I could get it to go.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linux"
}
|
How to insert values from one table to another table?
I have authors table that contains author name and author_id(primary key). Another table called books has author name and author_id(foreign key) too. I have inserted values for author name in book table manually. Now, I want to insert values in author id in book table by using the following query:
insert INTO tblbooks (Au_id)
SELECT tblauthors.Au_id FROM tblauthors JOIN tblbooks ON
tblbooks.a_name=tblauthors.AuthorName;
But i am getting an error :
# 1062 - Duplicate entry '' for key 'PRIMARY'
|
As you already have data in books table, you need to update author id instead of insert.
UPDATE tblbooks b
INNER JOIN
tblauthors a ON b.a_name = a.AuthorName
SET
b.Au_id = a.Au_id;
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "mysql"
}
|
Getting a "Duplicate mapping key" error on dependencies
Set off to add Flutter to the toolbox. So far seems very interesting but already I can't get past step 1 of the official tutorial. It says I should add these dependencies to pubspec.yaml:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
english_words: ^4.0.0-0
I did that, but it results in the following error:
flutter_application_1] flutter pub get
Error detected in pubspec.yaml:
Error on line 32, column 3: Duplicate mapping key.
32 cupertino_icons: ^1.0.2
^^^^^^^^^^^^^^^
Why? I made sure indentation is as in the example, and tried changing it just in case. It still results in the error.
|
Remove the `cupertino_icons` dependency because flutter already has it included in the pubspec.yaml file. You can scroll down in the file to see if it is present or not otherwise post your entire yaml file
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "flutter, dart"
}
|
Networking Across Multiple Operating Systems
I understand that Winsock is used for networking on Windows OS's, and BSD is for Mac OS and Unix. Is there some type of "universal" socket that works across any of the three operating systems mentioned? Or would a server have to have both sockets somehow incorporated into it for compatibility with clients of differing OS?
|
Winsock and BSD Sockets are the names of two similar APIs that both implement the same thing: TCP/IP sockets, which in turn are endpoints of TCP connections or UDP datagram flows. Because the actual transport is defined by the TCP/IP RFCs, they interoperate. There is accordingly no necessity for a Winsock implementation on Unix, or a BSD Sockets implementation on Windows. Indeed the latter is what Winsock more or less is, modulo a few misunderstandings here and there.
In short, your question doesn't really make sense.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c++, networking, operating system"
}
|
How is normal equation related to support vector machines?
I know the normal equation is the closed form way of solving the linear regression problem. But how are they related to support vector machines?
I was asked this in an interview and did not know the answer.
|
If you have a point $p_0$ on a plane, and a vector $v$ which is orthogonal to the plane, then the plane can be expressed as the set of all points $p$ such that $v^T(p-p_0) = 0$. The goal of SVM is to find such a $v$ and a $p_0$ which maximizes the margin.
In fact, if $v$ is constrained to be a unit vector, then $|v^T(p-p_0)|$ is exactly the distance of point $p$ from the plane. Therefore the objective of SVM can be stated as finding the vector $v$ and $p_0$ such that all positive datapoints $p$ have
$$v^T(p-p_0) > \epsilon$$
and all negative datapoints $p$ have
$$v^T(p-p_0) < -\epsilon$$
for the largest possible $\epsilon$.
So to answer your question in a comment, $v^T(p-p_0)$ is the normal equation or normal form for a plane, which is different from what is called the normal equation for solving linear regression. It is also not the case that this is the normal equation for SVM -- it just happens to appear in the mathematical formulation of the SVM objective.
|
stackexchange-stats
|
{
"answer_score": 1,
"question_score": -2,
"tags": "regression, svm"
}
|
track down file handle
I have a huge ear that uses log4j and there is a single config file that is used to set it up. In this config file there is no mention of certain log files but, additional files apart from those specified in the config file get generated in the logs folder. I've searched for other combinations of (logger|log4j|log).(properties|xml) and haven't found anything promising in all of the jar files included in the ear. How do I track down which is the offending thread/class that is creating these extra files?
|
Try placing a breakpoint in the File class' constructors and the mkdir and createNewFile methods. Generally, code will use the File class to create its files or directories. You should have the Java source code for these classes included with your JVM.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "java, logging, file, jakarta ee, websphere"
}
|
Can i load swank lazily?
The following code works but i have to load swank no matter whether i need it or not.
(ql:quickload :swank)
(defun swank ()
(swank:create-server :port 4005 :donot-close t))
If i move "(ql:quickload :swank)" into function swank, then CL will not find package swank.
Sincerely!
|
Remember that reading is a separate phase in CL. First a form is read, then it is executed. When the reader read the DEFUN form, it didn't recognize the SWANK:CREATE-SERVER symbol because, at that point, QL:QUICKLOAD had not been executed yet. The solution is to use INTERN.
(defun swank ()
(ql:quickload :swank)
(funcall (intern (string '#:create-server) :swank) :port 4005 :dont-close t))
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "common lisp, swank"
}
|
JQuery and Angular: Add two functions in ng-keydown
Adding two functions in ng-keydown through the use of jQuery attr
How can I do this the right way.
$('#id').attr('ng-keydown', 'maxinput(), numericOnly()');
|
I agree with @pixelbits that you should create a custom validator for the purpose you are trying to achieve. In fact, you can even use ng-maxlength and set input type to `number` to have the validation you require OOTB.
But if you really want to call multiple functions in an `ng-*` handler (it can be click, keydown etc), you should separate calls with semicolon `;` instead of comma.
You might also want to read how to think in Angular way with jQuery background.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "jquery, angularjs"
}
|
Problem-shooting on 8070 "Super Car" with Power Functions
I have recently bought a used Lego Technic car (8070 Supercar). It was not fully built, and from the instructions I learned that it was fully built except for approximately the last 10 steps. I finished it and now there are some problems.
I assume the motor is not the most powerful for this heavy model, but it is not even possible to open the hood or the doors easily*. I have to sometimes touch the wheels to allow them to open. This leads to the second uncertainty: If the switch for example is in position "hood" the wheels also are moving. But in a video clip I saw them open without the car moving.
I want to locate the problem with the least effort. Worst case for me is to completely de-build and then have to rebuild new. Maybe this model has known weak points I can check first?
(Please comment if you need more information or pictures!)
(* I used new batteries ^^)
|
If built according to the instructions, the wheels should not be powered at all. The only motorized functions is opening the hood, doors and spoiler. Moving the wheels should not affect these functions, nor should the wheels move when operating the functions.
So my guess is that someone did a poor attempt at modding this model and you'll have to deconstruct the model further.
|
stackexchange-bricks
|
{
"answer_score": 4,
"question_score": 2,
"tags": "technic, power functions, electronics"
}
|
River Corridor Survey Symbols for MapInfo?
Has anyone got River Corridor Survey Symbols for MapInfo?
|
I assume you are talking about the UK River Corridor Survey methodology?
Not sure the symbols exist for any GIS system. I've not seen them. You could try and create your own? This paper lists the symbols.
|
stackexchange-gis
|
{
"answer_score": 1,
"question_score": 1,
"tags": "mapinfo"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.