INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Unity3D OffNavMesh jump issue
I have set up Unity navigation meshes (four planes), navigation agent (sphere) and set up automatic and manual off mesh links. It should now jump between meshes. It does jump between meshes, but it does that in straight lines.
In other words, when agent comes to an edge, instead of actually jumping up (like off mesh link is drawn) it just moves straight in line but a bit faster. I tried moving one plane higher than others, but sphere still was jumping in straight line.
Is it supposed to be like this? Is it possible to set up navigation to jump by some curve? Or should I try to implement that myself? | Its recommended to solve your problems via animation. Just create a `Jump` animation for your object, and play it at the correct time. The position is relative, so if you increase the Y-position in your animation it will look like the object is jumping.
This is also how the Unity sample is working, with the soldiers running around. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "unity3d, navigation, mesh, curve"
} |
Compute next element of list based on previous elements
I want to define an infinite list where each element is a function of all the previous elements.
So, the `n+1`th element of the list would be `f [x1, x2, ..., xn]`.
This seems simple, but I cannot seem to get my head around how to do it. Can anyone help? | gen f = xs where xs = map f $ inits xs
Or
gen f = fix $ map f . inits | stackexchange-stackoverflow | {
"answer_score": 11,
"question_score": 6,
"tags": "haskell"
} |
Python Unicode Conversion for character 'ñ'
I have to print Unicode of char 'ñ' E.g. Input - 'Piñeiro' Output - 'Pi\xf1eiro' (Codecs Used - raw_unicode_escape) **Expected - 'Pi\u00f1eiro'**
I tried other standard encoding and text encoding codecs from < but seems non of this from the table is producing the required output
Any suggestions on which encoding module is required to get required output? | If you are trying to print out `Pi\u00f1eiro` \-- a string of length 11 -- and not `Piñeiro` \-- a string of length 7, you could do
In [93]: mytext = "Pi\u00f1eiro"
In [94]: print(mytext)
Piñeiro
In [95]: new_text = "".join(["\\u{:04x}".format(ord(c)) if ord(c) > 0x7f else c for c in mytext])
In [96]: print(new_text)
Pi\u00f1eiro
In [97]: new_text
Out[97]: 'Pi\\u00f1eiro'
How you determine which characters to show like this is up to you. I somewhat arbitrarly picked any characters whose unicode code unit is greater than 007F. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python"
} |
Extraction paragraph Number of text
dim a as string = "select id from table"
I want, for example, the second paragraph as such :
second paragraph = "ID"
There paragraph = "from"
...... | Split string based on spaces in VB:
Dim words As String() = MyString.Split()
In C#:
string[] Parts = MyString.Split(new char[0]);
or
string[] Parts = MyString.Split(null); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -4,
"tags": "vb.net"
} |
Wigner-Eckart theorem: what is $q $? How does $T^{(k)}_{q}$ relate to an operator?
We saw in class that the Wigner-Eckart theorem is,
$$ \langle \alpha', j',m'|T^{(k)}_{q}|\alpha, j, m \rangle = \langle j,k;m,q|j',m'\rangle \frac{\langle \alpha', j'||T^{(k)}||\alpha, j \rangle}{\sqrt{2j + 1}} $$
In the context of the perturbation theroy, if we consider a perturbation of the Hamiltonian,
$$ \Delta V = eEz $$
For the hydrogen atom inside an electric field along $z$, neglecting the spin of the electron, we saw that we could write the spherical tensor as $$ T^{(k)}_{q} = T^{(1)}_0 = eEz $$ I was wondering, how can we know that $q$ here is equals to $0$ ? It's maybe obvious but I'm a little bit lost about this spherical tensor and Wigner-Eckart Theorem. | In your notation $k$ is the degree and $q$ the component of the tensor. You can easily verify that $z$ is proportional to the $0$th component since the components satisfy $[L_z,T^{(k)}_q]=q T^{(k)}_q$. Moreover $z\sim Y_{10}(\theta, \phi)$, confirming the value $q=0$ for the component (and for that matter that $k=1$). | stackexchange-physics | {
"answer_score": 1,
"question_score": 0,
"tags": "quantum mechanics, angular momentum, notation, perturbation theory, wigner eckart"
} |
How to properly setup linear deformation in Hook modifier?
The goal is to make right mesh (with orange outline) to look exactly straight like on the left side. But these horizontal loopcuts are completely destroying Hook setup. As you can see falloff is set to Linear and it is still has curvature.
Left side mesh has all vertices asigned to hook except top two. Right side - all of them. ;
function fav(id)
{
if (actcookies=='undefined' || actcookies=='null')
{
alert("OK detect");
}
else
{
alert("BAD Not detect Result : "+actcookies);
}
}
</script>
<div onclick="fav(1);">Test Now 1</div>
I have tried this in different browsers, with the same result. I don't understand this. | it will not return `undefined` you need to change your controller as
if (typeof actcookies=='undefined' || !actcookies)
{
alert("OK detect");
}
else
{
alert("BAD Not detect Result : "+actcookies);
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 5,
"tags": "javascript, jquery, cookies"
} |
perl, unix: fastest way to merge thousands of small files into one file
what is the fastest way to merge thousands of small files into one file?
thanks | The `cat` command works nicely:
cat *someglob* > output.txt
It's name (short for con **cat** enate) even gives away its purpose.
If your argument list is too long (i.e. too many files are matched by the glob) you can always use the `find` command and pipe the arguments to `xargs`.
find . -name \*someglob\* -print0 | xargs -0 cat > output.txt | stackexchange-stackoverflow | {
"answer_score": 14,
"question_score": 0,
"tags": "perl, unix"
} |
MSSQL Speed Up Query 365 Millon Rows
I have roughly 365 Million Rows inside my tables and each day we add an additional Million rows after the data is a year old it gets moved to a different table that archives our data.
I have a PK Clustered index on DataCollectionID.
I have one other index: a Unique Nonclusted index on AssetID, DataPointID, and DatapointDate
I need to run multiple select queries against the table pretty quickly... here is my select Query:
SELECT [DataPointID]
,[SourceTag]
,[DatapointDate]
,[DataPointValue]
FROM DataCollection
Where
DatapointDate >= '2012-09-07' AND
DatapointDate < '2012-09-08' AND
DataPointID = 1100
ORDER BY DatapointDate
This query should return 8,640 rows which it does but it takes 00:00:08 (8 seconds) to execute. Even if I said give me top 10 it still takes 8 seconds. Can someone please help me speed up this process? | I think a more effective index to help this query would be on DataPointID, DataPointDate, in that order. This will allow the optimizer to quickly narrow down the field with an equality operator on the first index column, then find the date range within that set.
There are some good examples of indexes and similar queries here:
< | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "sql, sql server, sql server 2005"
} |
Change Tab Size In QTabWidget
I recently learned about QTabWidget and tried using it in python. My question is, can I change the height, width and background of each individual tab?
I tried doing
self.Tab1.setStyleSheet("background: white")
but that did nothing.
Thanks in advance. | You must use:
{your QTabWidget}.setStyleSheet("QTabBar::tab { height: 100px; width: 100px; background: 'red'}") | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 5,
"tags": "python, pyqt, pyqt4, qtabwidget"
} |
Arimasu as a parting phrase
Hope this is an appropriate question!
I visited Tokyo back in September and got by on some very basic Japanese (though more often with the help of their good grasp on English).
Anyway, there was a couple of times I heard as a parting phrase... once from a barman and I believe another in a restaurant. I thought it was just "arimasu" or "arimasen" by itself though I may have missed a particle or other word. I tried to look it up when I was there and have searched many times over the last few months to decipher it but with no luck.
The curiosity is still getting to me, could anyone here shed some light on how that might be used as a parting phrase? | I guess you've misheard heavily slurred .
When spoken very quickly, can be pronounced like or or And can be more like or
Similarly, slurred can sound like , , or even . | stackexchange-japanese | {
"answer_score": 6,
"question_score": 2,
"tags": "greetings"
} |
Fill image problem with generated_color in python, into paint workflow
After creating a new image,i know that `D.images['my_image'].generated_color = (1,1,1,1)` It makes the image all white, in short, it fills it `(R,G,B,A)`
The problem arises, when I go into texture paint mode, I paint over my image, and then I save the project, exit, and am asked to save the changes made to the image (And I confirm)
When I return to Blender, I realize that `D.images['my_image'].generated_color = (1,1,1,1)`
it won't work anymore. For example, if I go on to paint and try again to use generated_color, it will always revert to the previous paint I had at the time of the previous save. Therefore it will no longer be possible to do the "Fill" in solid colors
Anyone have any idea why? | Images have a source, `D.images['my_image'].source`, that specifies where the image comes from.
A "Generated" image (`source == 'GENERATED'`) is generated based on some parameters, `generated_type` and `generated_color`. For example, when Generated Type is "Blank", it will generate a solid color image with the `generated_color`, like you observed.
When you paint over an image and save it, the source is changed to "Single Image" (`source == 'FILE'`). Now the image comes from a single file (possibly packed into the .blend).
The `generated_color` is only used for "Generated" images (and even then, only "Blank" type), it won't affect other source types. But if you switch back to "Generated" you'll see the color you set.
D.images['my_image'].source = 'GENERATED'
If you open the Image Editor and open the sidebar (shorcut: `N`), you can see all this under the Image tab. It might help to play around with it.
.newInstance();
Casted str=(Casted)objInstance;
Why it make `ClassCastException`? | Casting requires that Class `Casted` must be a subclass or subinterface of Class `initObject`. For example:
List<String> list = new ArrayList<String>();
ArrayList<String> castedList = (ArrayList<String>) list; //works
Integer int = (Integer) list; // throws ClassCastException
An alternative to casting could be a helper method that will convert related objects. Such an example is the Collections.toArray) method.
Casting is usually discouraged as you are basically telling the compiler that you know what type the casted object is, and of course you could be wrong. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 0,
"tags": "java, casting, classcastexception"
} |
What game is this (possibly recolored) sprite of a girl with a sword from?
I'm developing a game and have some concerns about the originality of the artwork that a collaborator has shown me. A friend of mine tells me that this sprite looks familiar to him but he can't quite place it.
!enter image description here
Is this a (possibly recolored or otherwise modified) sprite from an existing game?
Update: It is stolen art. The original has been found here thanks to Martin Sojka. | That's pretty obviously Lightning, from Final Fantasy 13. They've made a sprite version, so not completely the same, but not at all original.
For comparison:
!enter image description here | stackexchange-gaming | {
"answer_score": 15,
"question_score": 18,
"tags": "game identification"
} |
NodeJS: Adding items to a collection with one unique and one duplicate value
In a case where you have a collection for a group of people:
let collection = [];
My intent is to add "John" multiple times within this collection as there are two people with that name, as such I add a unique hash each time `collection.push()` is called. However, when I attempt to do so:
collection.push({
hash: crypto.randomBytes(64).toString('hex'),
person: 'John'
});
The result is that only the hash gets updated, but the amount of objects within the collection stays the same: a single entry for John.
How would I be able to add the two or more Johns within this collection? | The code works for me:
let collection = [];
collection.push({
hash: crypto.getRandomValues.toString('hex'),
person: 'John'
});
collection.push({
hash: crypto.getRandomValues.toString('hex'),
person: 'John'
});
collection.push({
hash: crypto.getRandomValues.toString('hex'),
person: 'John'
});
console.log(collection) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js"
} |
Long division, explain the result!
I have this: $$ \frac{x^2}{x^2+1} $$ Wolfram Alpha suggests that I should do long division to get this: $$ 1- \frac{1}{x^2+1} $$ But I don't understand how it can be that, please explain. | This is the calculation taking place:
$$\frac{x^2}{x^2 + 1} = \overbrace{\frac{x^2 + 1 -1}{x^2 + 1}}^{Adding\,+1-1} = \underbrace{\frac{x^2 + 1}{x^2 + 1}}_{=1} - \frac{1}{x^2 + 1} = 1 - \frac{1}{x^2 + 1}$$ | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "polynomials"
} |
Constructor calling itself
I have recently found out that no argument constructor and multiple argument constructor cannnot call each other in turns. What is the underlying reason of this limitation? Some might say that constructors are where resources are initialised. So they must not be called recursively. I want to know if this is the only reason or not. Functions/methods/procedures can be called recursively. Why not constructors? | The answer lies in the fact that the call to another constructor is the first line of any constructor and hence your if condition to break out of recursion will never be executed and hence stack overflow. | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 6,
"tags": "java, asp.net, vb.net, c# 4.0, c# 3.0"
} |
ggplot fails to plot smallest points
I find when plotting points using `scale_size_area` the smallest points are omitted when the data ranges across several magnitudes. Possible bug due to rounding to zero somewhere?
require(ggplot2)
d = data.frame(x=1:4, y=rep(1,4), v=10^(1:4))
ggplot(d, aes(x, y, size=v)) + geom_point() +
geom_text(aes(label = v), size=2, col='red') +
scale_size_area(max_size = 50) +
theme(legend.position = "none")
!enter image description here | This does seem to be a bug, thusly therefore I've reported it: < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 6,
"tags": "r, ggplot2"
} |
How to create a textbox that display message when mouseover?
I have a sql query that obtain a string **called description** from the database
Also , i have a table that contain a mail list
I would like **for each mail list name, when the mouse over it, it display a text block that contain the description**
Are there any plugin , or how to do that? Thank you. | I use a jQuery plug-in called TipTip, which is very simple to implement. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery, html, css"
} |
Check if a certain app is installed on device with React Native
From my app, I'm trying to check if another app is installed (in my example, Google Maps). So I tried to use:
Linking.canOpenURL('comgooglemaps://?daddr=' + address + '&directionsmode=walking').then(supported => {...}).catch(err => console.error('An error occurred', err));
But it returns that it's not supported so it's like Google Maps is not installed. Do you know a way to solve this issue? | I'm assuming you're having this problem with iOS.
Starting with iOS 9, you have to declare the URL scheme you want to use. See this other answer with the details.
Or the official doc: < | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 7,
"tags": "react native"
} |
Nilpotent Elements and the Socle
Let $R$ be a ring with identity such that the quotient ring $R/S_r$ is abelian, i. e., all idempotents of the quotient are central. Here, $S_r$ means the right socle of the ring $R$. Do the nilpotent elements of $R$ belong to $S_r$? I have sent before, a post in reverse. Thanks for any answer! | Let $R=K[x]/(x^3)$. Then the socle is $S_r=(x^2)/(x^3)$ and the quotient is abelian because $R$ is abelian. The element $x mod x^3$ is nilpotent but not in $S_r$. | stackexchange-mathoverflow_net_7z | {
"answer_score": 4,
"question_score": -1,
"tags": "ra.rings and algebras, noncommutative rings"
} |
CSS - Side by Side div equal width, but at tablet size take up full screen
I am creating a form and I have 2 `divs` that are side by side. Here is my current html:
<div class="form-row-fluid">
<div class="form-field">
<label>First name</label>
<input class="input-thick">
</input>
</div>
<div class="form-field">
<label>Middle name</label>
<input class="input-thick">
</input>
</div>
</div>
And css:
.form-row-fluid {
width: 100%;
display: inline;
}
.form-field {
width: 46%;
}
I have looked at another answer that said to use a `display: table`, but I can't get that to be as responsive as I need. When I get to tablet size, I want each `form-field` to go to `width: 100%`. What am I doing wrong? | Just use floats (and media queries of course).
.form-row-fluid {
width: 100%;
}
.form-field {
width: 46%;
float: left;
display: block;
}
@media screen and (max-width:768px){
.form-field { width: 100%; }
}
Here's the fiddle | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "html, css, responsive design"
} |
How to make child element width 30 precent of parent elements width using css?
I have this div:
#edj{
width:50%;
border-style: solid;
border-width: 5px;
}
</style>
</head>
<body>
<div id = "edj">
<p><label>Faculty <input type="text" class = "k"> </label></p>
<p><label >Departmet <input type="text" class = "k"> </label>
</div>
I want to make textboxes width 30 percent of the div width.
How can I implement this using css code? | This is an answer in it's simplest form, this will make input fields 30% of parents width.
input {
width: 30%;
} | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 4,
"tags": "html, css"
} |
How to convert TypeScript object type to union type like Object.values() in TypeScript?
I have a type like this:
type MyType = {
type1: {
type1property: string;
};
type2: {
type2property: number;
};
};
How can I convert above `MyType` to `Result` like this:
type Result =
| {
type1property: string;
}
| {
type2property: number;
};
How can I achieve this? | It is just lookup by available keys:
type Result = MyType[keyof MyType];
Playground
* * *
Or reusable:
type Values<T> = T[keyof T];
type Result = Values<MyType>;
Playground | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "javascript, typescript"
} |
How to create foreign key by Laravel migration?
How can we make a `referenced key` and `foreign key` in `laravel` by `migrations`. Think I have two migration files in database directory in laravel, both of them create a different table in my database. the first migration creates a table that is for posts which has a column in the name of Id. the second migration create comments table that has a column in the name of post_id. Now `the Id column in posts table is referenced key` and the `post_id in comments table is foreign key`, how can I connect these two columns together? | It would be better to set `unsignedInteger` for foreign key type
$table->unsignedInteger('category_id')->nullable();
$table->foreign('category_id')
->references('id')
->on('categories')
->onUpdate('cascade')
->onDelete('some action');; | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 7,
"tags": "laravel, laravel 5"
} |
Linux Maldetect Not Sending Email Reports
I've set Linux Malware Detect to send me emails of the reports it generates, but haven't received a single one even though it has produced several reports. Relevant maldet settings /usr/local/maldetect/conf.maldet include:
email_alert="1"
email_addr="[email protected]"
email_ignore_clean="0"
I've also used the command:
whereis mail
to make sure the "mail" command is installed and it returns "/etc/mail" to verify it's installed.
What do I need to do to receive emails from maldet? | Your system doesn't have the `mail` command installed. To resolve the problem, install it. For instance:
yum install /usr/bin/mail | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 0,
"tags": "linux, command line interface, sendmail, malware"
} |
CheckBox with variable default value
What's the best way to create a checkbox that gets a default status but can still be modified.
<div className="master">
<input className="tgl tgl-skewed" id={id} type="checkbox" onChange={onChange} name={flag} checked={lock}/>
<label className="slave tgl-btn" data-tg-off={flag + " is OFF"} data-tg-on={flag + " is ON"} htmlFor={id}></label>
</div>
In this example above I get a default status (lock) that can be "true" or "false" this changes the checkbox from "checked" to "unchecked". Unfortunately this also makes it impossible to change this status by clicking on the relevant checkbox.
Any ideas ? | You can use `defaultChecked` props for the input tag in react.
<input className="tgl tgl-skewed" id={id} type="checkbox" onChange={onChange} name={flag} defaultChecked={lock}/> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "html, reactjs, checkbox"
} |
Some clever ways to segregate/separate these data rows
I've been playing around with borders but haven't seen that aesthetically pleasing look that soothes my soul. Any ideas I can do here to make these rows of data flow nicely?
 ~s.t.~\frac{f(\eta)}{\int_a^{\eta} f(t){\rm d}t}-\frac{g(\eta)}{\int_{\eta}^b g(t){\rm d}t}=2021$.
Suppose $f(x),g(x) \in C[a,b]$ and $f(x),g(x)>0$ for every $x \in (a,b)$. Show that there exists a $\eta \in (a,b)$ such that $$\frac{f(\eta)}{\int_a^{\eta} f(t){\rm d}t}-\frac{g(\eta)}{\int_{\eta}^b g(t){\rm d}t}=2021.$$
This problem comes from here, a website of China. | **HINT.** We can generalize $2021$ to arbitrary $k$. Let $$ F(x)=\int_{a}^{x} f(t)\mathrm{d}t ,G(x)=\int_{x}^{b} g(t)\mathrm{d}t $$ And the original claim is equivalent to $$ \frac{F'\left( \eta \right)}{F\left( \eta \right)}+\frac{G'\left( \eta \right)}{G\left( \eta \right)}=k $$ Then $$ F'\left( \eta \right) G\left( \eta \right) +G'\left( \eta \right) F\left( \eta \right) =kF\left( \eta \right) G\left( \eta \right) \\\ F'\left( \eta \right) G\left( \eta \right) +G'\left( \eta \right) F\left( \eta \right) -kF\left( \eta \right) G\left( \eta \right) =0 $$ Let $$ H (x)=C e^{-kx}F(x )G(x ) $$ What can we say about $H(x)$?
> $$ H'(x)=C (F'\left( \eta \right) G\left( \eta \right) +G'\left( \eta \right) F\left( \eta \right) -kF\left( \eta \right) G\left( \eta \right) ) $$ Since $H(a)=H(b)=0$, we can apply _Rolle's Theorem_. | stackexchange-math | {
"answer_score": 3,
"question_score": -2,
"tags": "real analysis, calculus, integration, definite integrals"
} |
How to run gulp tasks in Visual Studio for Mac?
I have an ASP.NET Core web app with some Gulp tasks (minify and uglify) in gulpfile.js .
Now on Visual Studio 2017 For Windowns. I can specify when to run those tasks through the tasks explorer.
How can I do the same with Visual Studio For Mac ? | Put this in your .csproj and it should work
<Target Name="MyPreCompileTarget" BeforeTargets="Build">
<Exec Command="gulp clean" />
</Target> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 3,
"tags": "visual studio, asp.net core, gulp, visual studio code"
} |
Classes of nodes given by graph automorphisms
I've been trying to formalise the following idea in graphs: I want to say that two nodes are "similar" if the rest of the graph looks the same from their point of view. For example, in a cycle every node is in the same class, but a star has two classes: all the leaf nodes are similar to each other but distinct from the centre. Similarly, an extended star has 3 classes.
Here's my attempt at the definition: "nodes $u$ and $v$ are [similar] in $G=(V,E)$ if there exists an automorphism $\varphi: V \rightarrow V$ such that $\varphi(u) = v$." This seems well-defined and seems to capture the intuition correctly.
My question is does this concept have a name in graph theory or group theory? It seems very natural to me but I couldn't find anything. If my definition doesn't work, is there a reasonable definition that captures the notion of "similarity" described above? | That is how "similar nodes" are defined in Frank Harary, _Graph Theory_ , 1969, and G. Chartrand and L. Lesniak, _Graphs & Digraphs_, Third Edition, 1996, except that Harary calls nodes "points" while Chartrand & Lesniak call them "vertices".
In my opinion your definition is the right one, and "similar" is the right word. | stackexchange-math | {
"answer_score": 0,
"question_score": 1,
"tags": "graph theory, algebraic graph theory, automorphism group"
} |
A good video editor/creation tool
> **Possible Duplicate:**
> Video editing on Ubuntu
I'm looking for a good video editor/creation app for Ubuntu. Something similar to that on Windows would work just fine for my purposes. I would prefer something that could add in titles and transitions. Any suggestions would be appreciated! Oh, and the video file type doesn't make a huge different for my need either. | Theres AVIDemux, and LIVEs. LIVEs is pretty cool. | stackexchange-askubuntu | {
"answer_score": 0,
"question_score": 0,
"tags": "video editor"
} |
Не учитывать регистр в ссылках?
Сайт на Symfony 2, при переходе по ссылке < получаю 501 ошибку, а если < то страница отображается.
Подскажите, пожалуйста: 1\. Как автоматически исправлять все большие буквы на маленькие? 2\. Как сделать редирект на страницу с маленькими буквами? | Существует несколько способов:
1. Настроить веб-сервер, чтобы он это делал. Тут конфиг будет зависеть от веб-сервера и можно задать отдельный вопрос, о том, как настроить конкретный сервер на редиректы или принятие запросов в зависимости от регистра.
2. Можно провести настройку на уровне приложения. Это может пригодиться в случаях, когда не хочется жертвовать чувствительностью к регистру сразу во всех роутах.
Так как вопрос касается именно фреймворка Symfony, рассмотрим пример конфигурации роутов для отображения одной страницы по роутам независимо от регистра:
new_pizza:
pattern: /{category1}/{category2}
defaults: { _controller: Bundle:Controller:Action }
requirements:
category1: (?i:[^/]+)
category2: (?i:[^/]+)
Как видно в примере, конфигурация роута позволяет использовать стандартный синтаксис RegExp, чтобы определить, будет ли параметр чувствителен к регистру или нет. | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php, symfony2"
} |
HTML- Login system- Prevent direct access of html-page
I have implemented a simple login system in javascript where an user has to input the correct username and password. If correct, he is redirected to log1.html. There, the user can reach several subpages like log1-sub.html. Now, I haven't found a good solution to prevent a user to just type the url in the address bar of the browser to reach the log1.html page.
Can anyone of you give me a short hint please?
Thanks much!
Regards,
enne | Javascript is a poor solution for this since someone can just turn it off and foil your entire system.
If your server is Apache you can use `.htaccess` for simple authentication. For IIS see this resource Anything more fancy and you will have to handle it with a server-side language as mentioned in the comments. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "html"
} |
general formulation for 1/g(x) derivative
Is there a general formulation for $\frac {d^n(g(x)^{-1})}{dx^n}$ ? Something like $$\frac {d^n(g(x)^{-1})}{dx^n} = \sum_{i=1}^{f(n)}\prod_{k=1}^{h(n)} ...$$ | It's just the formula of Faà di Bruno
!enter image description here
with $f(x)=\frac{1}{x}$ | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "derivatives"
} |
Time it takes python to process a given function?
I've written a python script and it's conducting a lot of string comparisons with a number of functions. If I were to run the current process it would take a month to complete. I would like to make the code more efficient but am not sure where I should focus.
Is there a way of having python tell you how long it takes for it to go through each of the functions?
Obviously, having it calculate the time it takes to process the function will take up resources.
thank you | What you're looking for is a profiler, here's a good place to start: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, function, processing"
} |
Is there a way to programmatically receive if Windows is shutting down or restarting?
Is there a way to capture if Windows shutting down, or it is restarting? For shutdown, i found some solutions, but not for restart. For me it would be important to be able to determine if Windows is restarting, or just shutting down.
Thanks! | There is a way to detect whether it is shutting down and also there is a way to detect when it starts up.
So, you can note the time when it is shutting down. Note the time when it is starting by running an exe at startup (add your exe here in registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce).
If the time difference is very less then you can treat it as a 'Restart'.
Also you can use WTSRegisterSessionNotification api for exact events. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 3,
"tags": "c++, windows"
} |
Limiting the monitor to a region in Linux
I have a laptop with a broken 13 inch display. The left half of the display is completely black and I cant's fix it for now. I was wondering if it's possible to write a program in any language to limit the display to the right, that means either:
1. Changing the resolution to have half of the width it currently has **or**
2. Keep the aspect ratio but zoom out the display and send it to the right.
I am preferably looking for a method that can be used in Linux (Windows will be in second priority)
The language is not an issue (though I am assuming C++ would be the way to go) and I'm looking for some hints.
Thanks in advance. | You can change resolution using xrandr Linux command. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "c++, linux, graphics, monitor, x11"
} |
Show text on image background
I am trying to do something new for my project. I have an icon, lets say kind of like Mail icon.
When a page is loaded, the icon also gets rendered. Based on a query count I do in the background during page load, I would like to display that number (count) inside/on the icon. Kind of like how I see Facebook notifications displayed on top of the icon or Gmail shows there is 2 new emails on the icon, etc.
Initially, I was thinking of having a different icon for each number, since I had finite max limit for the count. But I am considering other options that are better to do programmatically. | I would recommend making the icon image the background of a div or so, then you can place the number on top of it as plain text, moving it around using padding. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 1,
"tags": "html, css, user interface"
} |
Find missing among 1000 numbered files
I have folder that should contain 1000 files, named `out_x.dat`, where `x` is a number from 1 to 1000. When I do `ls out_* | wc -l`, I see that there are 996 files. I would like to know which four are missing. How can I achieve this? I can list the existing files with this:
ls out* | awk -F '_' '{ print $2}'
Is there something that'll allow me to list the ones that don't exist within the 1000 files? | You can use a simple script to check the existence of each of the files in turn, eg:
for (( i=1; i<=1000; ++i )); do [ -e out_$i.dat ] || echo out_$i.dat missing; done
If the number is formatted, say to 4 digits, the command line can be elaborated to:
for (( i=1; i<=1000; ++i )); do printf -v n out_%04d.dat $i; [ -e $n ] || echo $n missing; done
Alternatively (thanks to @dave_thompson_085's comment):
for i in {0001..1000}; do [ -e out_$i.dat ] || echo out_$i.dat missing; done | stackexchange-superuser | {
"answer_score": 4,
"question_score": 0,
"tags": "linux"
} |
How to replace part of string in a column, in oracle
I am using oracle, toad.
I want to replace , with backspace.
Column consists of: `bla bla foo ,CALL HELPDESK`
It has to replace: `bla bla foo CALL HELPDESK`
Basically , should be removed
I tried like this:
UPDATE Mytable t
SET column = REPLACE(t.U_MSG, ''%, CALL HELPDESK'', '% CALL HELPDESK') | `REPLACE` doesn't use wildcards, it simply replaces all instances of the first string with the second string. This should work:
UPDATE Mytable t
SET column = REPLACE(t.U_MSG, ', CALL HELPDESK', ' CALL HELPDESK') | stackexchange-stackoverflow | {
"answer_score": 14,
"question_score": 8,
"tags": "sql, oracle"
} |
Finding words from random input letters in python. What algorithm to use/code already there?
I am trying to code a word descrambler like this one here and was wondering what algorithms I should use to implement this. Also, if anyone can find existing code for this that would be great as well. Basically the functionality is going to be like a boggle solver but without being a matrix, just searching for all word possibilities from a string of characters. I do already have adequate dictionaries.
I was planning to do this in either python or ruby. Thanks in advance for your help guys! | I'd use a Trie. Here's an implementation in Python: < (credit to James Tauber) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "python, ruby, word, anagram, boggle"
} |
WCF "Global" Operation Invoker
Here is what I want to achieve. In a IIS hosted WCF service I would like to be able to read the incoming message headers and based on a specific header value perform some custom actions. This header reading should take place before any web service method is executed. Can you please provide some guidance? | You didn't mention what you want to do with a message headers so perhaps it will not satisfy your needs but you can try using custom message inspector. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "wcf, wcf binding, wcf security, wcf client"
} |
Java List.add() and Map.put()
Working with `Lists` and `Maps`, I started thinking, why Map method for adding `Object` is called **put** and for List it is `add`?
It is just developers will, or there was something under naming those methods different.
May be the methods names let the developer know while adding to `Map`/`List` what kind of data structure he is working with? Or those names describes the way they works? | The difference is :
1. .add() means to insert something at the end or wherever you want to(you know where to add) whereas
2. .put() means to add an element wherever it needs to be placed, not necessarily at the end of the Map, because it all depends on the Key to be inserted (you don't know where to add). | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "java, add, put, difference"
} |
Как добавить стандартную кнопку Google+ Sing-In
Я установил Google Play Services в SDK, после чего добавил в свой 'Layout' код гугл кнопки
<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
и мне показывает
Rendering Problems The following classes could not be found:
- com.google.android.gms.common.SignInButton (Fix Build Path, Create Class)
Tip: Try to build the project.
Говорят вроде есть баг в Google Play Services (5.0) и нужно понизить версию и добавить в раздел dependencies
dependencies{
compile 'com.google.android.gms:play-services:4.4.52'
...
}
Я новичок в этом можете подсказать где найти этот раздел и правильно ли я нашел решение проблемы? | на самом деле добавлена не правильная 'dependency' нужно добавить этот
compile 'com.google.android.gms:play-services-auth:8.4.0' | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "java, android, dependencies"
} |
Let $N$ be a normal subgroup of finite group $G$. Prove that if order of $H$ and order of $G/N$ are relatively prime then $H$ is a subgroup of $N$.
> Let $N$ be a normal subgroup of finite group $G$. Prove that if order of $H$ and order of $G/N$ are relatively prime then $H$ is a subgroup of $N$.
Can someone help me to understand the intuition behind this question and why is this happening with example?
I am basically clueless about how to start. | By the first isomorphism theorem, the order of a homomorphic image of a group divides the order of the group.
Consider the canonical projection $π:G\to G/N$. Then $|π(H)|\mid|H|$.
And by Lagrange, $|π(H)|\mid|G/N|$.
So $π(H)=0$. So $H\le N$. | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "group theory, examples counterexamples, normal subgroups, quotient group"
} |
how many custom attributes type in magento
$setup->addAttribute('catalog_category', 'image1', array(
'input' => 'image',
'type' => 'varchar',
'group' => 'Slider Image',
'label' => 'Image 1',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'backend' => 'catalog/category_attribute_backend_image',
'frontend_input' =>'',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible_on_front' => 1,
));
how many input type for custom attribute like text,textarea
'input' => 'text',
can we add **button** as custom attribute and set action on it | There are some issue in your installer please try below
$installer->addAttribute("catalog_category", "image1", array(
"type" => "varchar",
"backend" => "catalog/category_attribute_backend_image",
"frontend" => "",
"label" => "Image one",
"input" => "image",
"class" => "",
"source" => "",
"global" => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
"visible" => true,
"required" => false,
"user_defined" => false,
"default" => "Image",
"searchable" => false,
"filterable" => false,
"comparable" => false,
'group' => 'Slider Image',
"visible_on_front" => true,
"unique" => false,
"note" => ""
)); | stackexchange-magento | {
"answer_score": 1,
"question_score": 2,
"tags": "magento 1.7, category, attributes, catalog, sql"
} |
What's the easieat way to get the latest uploaded file in S3 (when other existing files get overwritten) - Python
I have a S3 bucket and some Python code, the code read all the available files for the current day and download them to s3 ( **it reads the files from FTP in an ascending order, based on the datetime in the filename when the file gets uploaded to FTP** ), so for example I have downloaded `file 1` and `file 2` in the last run and uploaded them to S3, now I know FTP has a new file `file 3` available, then a new run will download files in the following order: `file1` `file2` and `file3` and upload all the files again in the same order to the same S3 path (`file1` and `file2` gets overwritten, and new file `file 3` will also be uploaded to s3).
My question is what's the easiest way to identify the newly-uploaded file `file3` in Python? | The easiest way I can think of to see the difference between 'updated' files and newly created files is simply doing a try/except GetObject before the PutObject. This is preferred over first doing the PutObject then trying to figure out what changed since S3 has no easy way of retrieing objects by 'Modified date' or simular.
So if your question was about checking which files were already present in S3 before uploading, try doing the GetObject first :). | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "python, python 3.x, amazon web services, amazon s3, ftp"
} |
How to check which item is open in sidebar in VS Code?
When you click on item on **Activity bar** , that item window is opened in **Side bar**. For example: `SearchViewletVisible` and `ExplorerViewletVisible` for **Explorer** and **Search** resp. There are other items on my activity bar, like **extensions** , **debugger** , **outline** e.t.c, How can I get their names? | `activeViewlet: "workbench.view.debug"`
and the same for the others, like
`activeViewlet: "workbench.view.extensions"`
You can check these for yourself by using the `Developer: Inspect Context Keys` command and then searching for `debug` for instance to see if you get anything promising.
See < for how to use the `Context Keys` command.
And < on how to use these values in a keybinding. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "visual studio, visual studio code"
} |
How to export data with tab delimiters using Apex Data Loader?
The internet vaguely says that this is possible. I need this feature to export translation values from a custom object and then import this back into Salesforce using translation workbench. Translation workbench accepts:
1. Field delimiter: Tab
2. Character delimiter: None
How can we achieve a tab delimited data export from a custom object using Apex Data Loader? | Try Jitterbit Dataloader
In the Jitterbit Dataloader , you can create a FileFormat for both Source and Target side. In the FileFormat , you can specify the delimiter to be Comma(,), Pipe(|), Tab(\t) etc as per your requirement. | stackexchange-salesforce | {
"answer_score": 1,
"question_score": 1,
"tags": "data loader"
} |
Loop through and check type of object TS/JS
I wish to loop through an object in Typescript/Javascript and check for a specific type.
interface inter {
first: string;
second: number;
third: string[];
}
let test: inter = {
first: "first thing",
second: 52,
third: ["ZERO", "ONE", "TWO"],
}
In this case, I wish to check to see if the key is an array. To generalize the question, how would I check for any type of object? Ex: what if one of the attributes is of type PizzaType (class or enum) and I wish to check if there is an attribute in any given object? | The answer depends on the kind of type. The test loop would be something like:
class PizzaType {}
interface inter {
first: string;
second: number;
third: string[];
}
let test: inter = {
first: "first thing",
second: 52,
third: ["ZERO", "ONE", "TWO"],
}
Object.keys(test).some(key => {
const value = (test as unknown as any)[key];
// examples for different types below
return typeof value === "string";
return typeof value === "boolean";
return typeof value === "number";
return typeof value === "undefined";
return value === null;
return value.constructor === Date
return value.constructor === PizzaType
}
You can't test for a specific interface or enum, because these don't exist at runtime. Instead you have to check for something that you know about enum, such as its value. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, typescript"
} |
What is the significance of @javax.persistence.Lob annotation in JPA?
When should I use `@javax.persistence.Lob` annotation in JPA? What datatypes can be annotated by this annotation? | `@javax.persistence.Lob` signifies that the annotated field should be represented as BLOB (binary data) in the DataBase.
You can annotate any `Serializable` data type with this annotation. In JPA, upon persisting (retrieval) the field content will be serialized (deserialized) using standard Java serialization.
Common use of `@Lob` is to annotate a `HashMap` field inside your Entity to store some of the object properties which are not mapped into DB columns. That way all the unmapped values can be stored in the DB in one column in their binarry representation. Of course the price that is paid is that, as they are stored in binary format, they are not searchable using the JPQL/SQL. | stackexchange-stackoverflow | {
"answer_score": 66,
"question_score": 62,
"tags": "java, jpa, annotations, java ee 7"
} |
execute if statement in variable value assignement powershell
Sometimes I need to check if a pathname ends with "\" adding it if necessary, the code is pretty simple, something like this
if ($destFolder[-1] -ne '\') {
$destFolder += '\';
}
Is there a way to evaluate an if statement inside `()` so that I can use it in variable assignement? I mean something like this
$finalName = $destFolder + (if ($destFolder[-1] -ne '\') { '\' } ) + $fileName
Given that `if` is not a cmdlet I get this error
> if : The term 'if' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. | You need a subexpression here (`$()`):
$finalName = $destFolder + $(if ($destFolder[-1] -ne '\') { '\' }) + $fileName
The expression operator (`()` without the `$`) only allows simple statements/expressions. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "powershell, if statement, variable assignment"
} |
Cannot implicitly convert IQueryable<string> to IQueryable<Proj.Models.Foo>
My code:
public IQueryable<Foo> GetMajors()
{
var query = (from u in db.Specializares
select u.NumeSpec).Distinct();
return query;
}
Error: `Cannot implicitly convert type 'System.Linq.IQueryable.string' to 'System.Linq.IQueryable.Project.Models.Foo.'. An explicit conversion exists (are you missing a cast?)` | Well... yes: you're saying "take the `NumeSpec` of each item, now take the disctinct set of those specs; now return those specs as `Foo`s" - that just won't work.
I expect you mean "use the NumeSpec to find distinct-looking Foos"
There are custom implementations of `DistinctBy` that would do what I expect you want, but that only works for `IEnumerable<T>`, not `IQueryable<T>`. For example:
public static IEnumerable<TSource> DistinctBy<TSource, TValue>(
this IEnumerable<TSource> source,
Func<TSource, TValue> selector)
{
var distinct = new HashSet<TValue>();
foreach(var item in source)
if(distinct.Add(selector(item)))
yield return item;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, sql, asp.net mvc, linq, linq to sql"
} |
is possible to do this in php? $code->Info_.$code
I was looking at several locations, but does not like looking, I want to perform this operation
$tpl = new Savant3();
$tpl->Info_.$db_code["name"] = $db_code["info"];
$tpl->display('index.tpl.php');
php echo $this->eprint($this->Info_Name);
is it possible?. Thank you. | You can simply do
$tpl->{"Info_$db_code[name]"} = $db_code["info"];
see also the manual for this: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "php, savant3"
} |
Android keystore password field
I have finished developing an android application and decided to signed it with a keystore. I have no problem for this process, but I do have a question regarding the keystore's password. I'm creating the keystore from eclipse, at `Keystore selection` window, i chosed to `create new keystore`. After i pressed next, under the `Key Creation` window, im required to key in details for the keystore ; alias, validity, password etc.
What i wanted to ask is, is there any difference between the password field in the `Key Creation` windows and the `Keystore selection` windows? I tried putting in same passwords for both and it works fine for me. Can i chose to put in different password? Does it affect anything for that particular keystore? Hopefully anyone could provide me an insight for this. | Keystores hold **many** keys. Whereas your key is a single item **contained** in the keystore. They _can_ have the same password, but that compromises your keystore if your key's password is leaked somehow. I would recommend having the keystore and key password differ.
So yes, the password fields are for two separate things because you are creating two separate items, and following good password practices, they should each have two separate passwords. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 2,
"tags": "android, passwords, keystore"
} |
End of brake cable touches tire
On my Trek Domane SLR the end of the front brake cable touches the tire. It makes an enerving sound and I am a afraid it destroys my tire. I thought about using some tape, but that is not possible because of the moving brake arm. Is there any possibility to push the cable to the side without renewing the while cable?
Edit: there's also a relevant paper called "On circular cylinders by 4 or 5 points in space" by Devillers, Mourrain, Preparata and Trebuchet. | stackexchange-mathoverflow_net_7z | {
"answer_score": 3,
"question_score": 2,
"tags": "ag.algebraic geometry, real algebraic geometry"
} |
swing: appropriate Listener for JTextField change events
Which type of Listener do I use for listening to changed text events in a JTextField? (I should know this or be able to tell from the Javadoc but I can't seem to figure it out.) | Use the underlying document:
myTextField.getDocument().addDocumentListener(); | stackexchange-stackoverflow | {
"answer_score": 20,
"question_score": 10,
"tags": "swing, listener, jtextfield"
} |
what is the termination condition for this C for loop
i found the linked code and found this for loop which is a bit strange for me. i would appreciate if someone could explain me the syntax of this loop to me. MFG
void patch(Ptrlist *l, State *s)
{
Ptrlist *next;
for(; l; l=next){
next = l->next;
l->s = s;
}
} | This for loop
for(; l; l=next){
is equivalent to
for(; l != NULL; l=next){
or
for(; l != 0; l=next){
That is the for loop is executed until the controlling expression is equal to 0. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c, for loop, pointers, null pointer"
} |
Solving functional equation $f(x+y)=f(x)+f(y)+xy$
We are given $f(0)=0$. Then when $x+y=0$: $$0=f(-y)+f(-x)+xy$$ Can I now use $x=0$ and obtain: $$0=f(-y)?$$ Is this correct? Is there a better way to solve this equation? | Set $f(x) = g(x) +\dfrac{x^2}{2}$ then plugging in gives $$\fbox{1}\,g(x+y)=g(x)+g(y).$$ This is Cauchy's functional equation. And under certain regularity assumptions for $g$ you get that $g(x)=ax$. But if none are given then $g$ is just a linear function over $\mathbb{Q}$ the rational numbers and so any of those would be an appropriate solution. | stackexchange-math | {
"answer_score": 10,
"question_score": 7,
"tags": "functional equations"
} |
going from apex 5.0 to 5.1.2. will a 5.0 app run on 5.1.2 without being "touched" in a developer instance?
when we went from apex 4 to apex 5, we had to access all our apex 4 apps in a developer instance (which apparently did some conversion/upgrade), and then export them and re-install them in our runtime-only apex 5 production instance. is this the case with an upgrade form apex 5.0 to 5.1.2? or will our apex 5.0 apps just run on a 5.1.2 instance? | Yes, that's the plan.
All applications should work as they did in previous versions. This is made possible via a number of features, one being compatibility mode in app settings.
See here for more detail about how APEX does a pretty good job at leaving existing apps alone. <
This doesn't mean to say you can skip regression testing or expect everything to run smooth. It can depend on how you've built your apps. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "oracle apex, oracle apex 5, oracle apex 5.1"
} |
Brillouin function - Classical Limit
The Brillouin function, defined as
$$B_j(x) = \frac{j+1/2}{j} \coth\left(\frac{j+1/2}{j} x\right) - \frac{1}{2j}\coth\left(\frac{1}{2j} x\right),$$ tends to the Langevin funcion
$$ \mathcal{L}(x) = \coth(x) - \frac{1}{x}, $$
in the limit when $j \rightarrow\infty$. My lecture notes refer to this limit as the classical limit.
This function comes up in the study of spin interaction in the presence of a magnetic field, and is of particular interest in Statistical Mechanics. Here, $j$ is the spin number of a particle.
My question is: how does $j \rightarrow\infty$ make this system classic? | The total angular momentum $j$ is quantized. If you take the limit $j \rightarrow \infty$ then a huge amount of states will become accesible to the system (more specifically 2$j$ + 1 states). Due to this, $j$ (a vector), can now point in almost every direction just like a normal "classical" vector can take on every value. So you can treat the system in a classical way.
In addition, this is justified by something which is known as the "correspondence principle". It states that in the limit of large quantum numbers every quantum system converges to a classical system. | stackexchange-physics | {
"answer_score": 3,
"question_score": 0,
"tags": "statistical mechanics, quantum spin"
} |
Tumblr Post on Facebook does not include Post Contents
My blog: blog.go-jewellery.com, a tumblr blog, when I try to share posts, on facebook by either:
1. posting links - e.g. a post from my blog: <
2. using facebook sharing button at my post level
It will never pull in the post content, image, to be posted onto facebook. All it pulls in is the blog url.
Is it possible to include the contents from the post, when posting on Facebook?
Many thanks for your help. | Looks like it is working now so I'm guessing you figured it out! You can always debug this using Facebook Debugger tool, putting your URL in gives:
<
All the OG meta tags are correct. For anyone else looking at this, I recommend reading: < . | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "facebook, facebook like, tumblr, facebook opengraph"
} |
Why do Python function docs include the comma after the bracket for optional args?
The format of the function signatures in the Python docs is a bit confusing. What is the significance in putting the comma after the open bracket, rather than before? What is the significance of nesting the brackets?
How they are:
RegexObject.match(string[, pos[, endpos]])
I would expect one of the following:
RegexObject.match(string, [pos], [endpos])
RegexObject.match(string[, pos][, endpos]) | The square bracket means that the contents are optional, but everything outside of square brackets is compulsory.
With your notation:
RegexObject.match(string, [pos], [endpos])
I would expect to have to write:
r.match("foo",,)
The nesting is required because if you supply the third parameter then you must also supply the second parameter even though it is an optional parameter. The following non-nested alternative would be ambiguous:
RegexObject.match(string[, pos][, endpos]) | stackexchange-stackoverflow | {
"answer_score": 22,
"question_score": 11,
"tags": "python, documentation, notation"
} |
How to Remove All Desktop Icons
In Ubuntu 19.04, how can I make it to where the desktop doesn't try to mirror the desktop folder? I don't want to see any icons on my desktop.
I'm not sure how this is suppose to be by default, but my desktop shows a trash bin, a folder with my user name, and a file I put into /home/username/Desktop. Instead I would like it to show nothing.
I have nemo installed, and I can't tell whether nemo or nautilus is responsible for this, but I'm unable to find settings in either that would remove all desktop icons. | Either go to here to turn off the `Desktop Icons` GNOME Shell extension, or use the `Tweaks` application to do the same thing.
Click on the gear (settings) icon to change the settings for select desktop icons. | stackexchange-askubuntu | {
"answer_score": 3,
"question_score": 8,
"tags": "desktop environments, 19.04, .desktop, desktop icons"
} |
Can I choose where to publish my NPM module - either to the public or a private repo?
We have recently started using a private NPM repository at work. I also write various modules that are hosted in the main public NPM repo. The private repo does **NOT** replicate up (it just replicates down). Is there any way to specify to which repository I want to publish an NPM package?
Naturally, I want to publish work stuff to our private NPM repository and open-source modules to the public repository.
My ~/.npmrc file looks similar to this (obviously, values are taken out)
_auth = AUTH_TOKEN
email = MY_EMAIL
registry = URL_FOR_PRIVATE_REPO
Having done a bit of Googling, I found things like this, but it does seem rather out-of-date (it's closed 2 years ago). | In the package.json file:
{
"publishConfig": {
"registry":"
}
}
The `npmrc` stuff is a bit tricky to manage. We're working on rewriting a bunch of stuff so that all those configs will be scoped to a specific registry, but it'll be a while before that's done. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "node.js, npm"
} |
How to launch Google Maps Navigation from iOS app?
I can open Google maps app using `[NSURL URLWithString:@"comgooglemaps://...."]` But how to open Navigation mode? | The navigation mode is explained here, "Add navigation to your app" : <
Try this code :
NSURL *testURL = [NSURL URLWithString:@"comgooglemaps-x-callback://"];
if ([[UIApplication sharedApplication] canOpenURL:testURL]) {
NSString *directionsRequest = @"comgooglemaps-x-callback://" + @"?daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York" + @"&x-success=sourceapp://?resume=true&x-source=AirApp";
NSURL *directionsURL = [NSURL URLWithString:directionsRequest];
[[UIApplication sharedApplication] openURL:directionsURL];
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ios, google maps, google maps api 3"
} |
Как правильно оформить select запрос последней записи столбца
Как правильно оформить select-запрос в SQL, который берет только последнею запись со столбца `finished`?
Вот скриншот таблицы  and vote for or against certain suggestions.
Can employees working on the application (dev / ux / management / etc): \- Formulate new suggestions from this site? \- Vote for or against existing suggestions?
What are the arguments for/against if any? | I think there are two questions here.
**First:** Can the Development Team formulate new suggestions from this site?
YES!
You can make a weekly or biweekly meeting (name: Grooming) (time box: half hour) where you can collect all new suggestions.
**Second:** Can the Development team vote for or against certain suggestions?
NO!
It will be better to push suggestions to the Product Owner or Investor or some person who takes care of the product. The Development Team has to talk about what and how to implement but not about whether it will implement or not! That is a job for someone else.
I hope this was helpful. Best regards! | stackexchange-pm | {
"answer_score": 7,
"question_score": 7,
"tags": "product management"
} |
Helm template prefixes range index with an underscore
We can access the index by this way :
{{- range $i, $s := (some list) }}
{{$i}}
{{-end }}
output:
0
1
..etc
However when the list is a result of a string split, the index becomes prefixed with an underscore
{{- range $i, $s := (split "X" "aaXbbXcc") }}
{{$i}}
{{-end }}
output:
_0
_1
..etc
why? | The `split` function returns a dict, whose index members are prefixed with a `_` character before. It is useful when you are planning to use dot notation for accessing members and not ideally suited for iteration with `range`.
For accessing the result as a list of strings with their indices, use `splitList`. See documentation for more information
{{- range $i, $s := (splitList "X" "aaXbbXcc") }}
{{$i}}
{{- end }} | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "kubernetes helm, go templates"
} |
Recode utf8..cp1250 outcome in iso-8859-1
I have CSV file that appears to be correctly encoded in UTF-8.
iconv -f UTF-8 file.csv -o /dev/null # returns 0
When I try to recode the file to cp1250 (tried recode/iconv even Perl), resulting file is encoded in iso-8859-1 - at least according to
file -i resulting_file.csv
resulting_file.csv: text/plain; charset=iso-8859-1
Locale setting on the server is
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
I can´t figure out why. Any help appreciated, thanks. | Iso-8895-1, iso-8895-15 and Windows-1252 (CodePage1252) character sets are very similar, only differing by a handful of characters and/or locations. For example, iso-8895-1 doesn't have a euro (€) symbol. Windows-1252 and -15 do, but it's mapped to different bytes.
`file` uses "magic" lookup to guess the encoding. If the characters that make those character sets differ don't exist in the text, then `file` can't differentiate between the three.
It certainly sounds like you have some non-ASCII Latin characters but not enough for `file` to know any difference.
You can rest easy though - your file is compatible with Windows-1252 encoding. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "shell, encoding, utf 8"
} |
BackgroundWorker and Deleting large files
Writing part of an application that is supposed to clean up any old files, but some of these are quite large so i start some BackgroundWorkers to do the bulk of the work. My question is, if i am calling a file.Delete call on a FileInfo object on a BackgroundWorker and the application exits:
* What will happen to that file, is it going to hang around in an invalid state?
* Will the application hang, or will the BGWorker stay alive?
* Is the file left invalid?
* Is BackgroundWorker the correct class to be using in this case? | Ok, to get around this issue i have switched to using the Thread object. This creates a foreground thread, and application shouldn't exit until all foreground threads have been completed.
Sorry about the hassle. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, asynchronous, backgroundworker"
} |
How to find AAC-LC (non-ADTS) audio packet length
I have AAC-LC audio stream coming directly from audio encoder.
Its a raw stream, No ADTS headers, no container data as I want to stream encoded audio directly as it arrives.(before file gets saved).
I want to determine the frame boundaries/frame lengths/packets lengths in incoming encoded raw AAC stream. (AAC has variable packet lengths.)
Can I search for any fixed frame headers/patterns so that I can determine frame boundaries?
Is it possible with AAC?
Thanks in advance for your valuable inputs. | If you are taking AAC encoded data directly from encoder then it's up to encoder to send frame by frame. It should not send "packets", but single frames. Otherwise I don't see a way you can parse for frames.
I'd first check if it really sends more than one frame at a time?
If yes, then one solution would be to tell encoder to send ADTS header, then parse info from ADTS, and finally strip down ADTS from the frame and stream it as raw.
Does that help? | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 6,
"tags": "audio, streaming, audio streaming, aac"
} |
Let $X(t) = e^{r(T-t)}/S(t)$. Find the SDE of $X(t)$ provided that $S(t)$ satisfies the BSM model.
This is the last part to a 3 part question! I am nearly done going through the questions I had difficulty with while studying, again, anyone's help would be greatly appreciated!
Let $X(t) = e^{r(T-t)}/S(t)$.
Find the SDE of $X(t)$ provided that $S(t)$ satisfies the BSM model.
Make sure the drift and diffusion terms are expressed in terms of $X(t)$ rather than $S(t)$. | Consider the function $f(x,t) = \frac {e^{r(T-t)}}{x}$. Then $X = f(t, S)$ and you can use Ito lemma to say that
$$dX_t = \frac{\partial}{\partial t}f(t,x)\mid_{ t,S} dt + \frac{\partial}{\partial x}f(t,x)\mid_{ t,S} dS_t+\frac 12\frac{\partial^2}{\partial x^2}f(t,x)\mid_{ t,S} d \langle S \rangle _t$$
Which results in
$$dX_t = \frac {-e^{r(T-t)}}{S_t}dt - \frac {e^{r(T-t)}}{S_t^2} dS_t + \frac {e^{r(T-t)}}{S_t^3} d \langle S \rangle _t$$
Given that $$\frac{dS_t}{S_t} = \mu dt + \sigma dW_t$$, we find
$$d \langle S \rangle_t = \sigma^2 S_t^2 dt$$ and substituting we find
$$dX_t = \frac {-e^{r(T-t)}}{S_t}dt - \frac {e^{r(T-t)}}{S_t} (\mu dt + \sigma dW_t) + \frac {e^{r(T-t)}}{S_t} \sigma^2 dt$$
Now given that $X_t = \frac {e^{r(T-t)}}{S_t}$ we find $$dX_t = -X_t dt - X_t(\mu dt + \sigma dW_t) + X_t \sigma^2 dt$$ or
$$\frac {dX_t}{X_t} = (\sigma^2 - \mu - 1)dt - \sigma dW_t$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 2,
"tags": "stochastic processes, stochastic calculus, brownian motion, differential"
} |
wronskian of solutions of $y''+p(t)y'+q(t)y = 0$ is zero. What can I say about $p$ and $q$?
My book is asking about what can I say about $p(t)$ and $g(t)$ when the wronskian of any two solutions of $y''+p(t)y'+q(t)y = 0$ is $0$.
I know a theorem that says that the wronskian of $y_1$ and $y_2$, being solutions for this equations, is:
$$W(y_1,y_2) = c\exp\left(-\int p(t) \ dt\right)$$
but how can equating it to $0$ help me find that $p(t)=0$ as my book says? | I don't think the wording of your problem is precise. First of all, suppose $W(t) = c \neq 0$. Let $y_1, y_2$ be solution of the ode. Then since it can be shown by taking derivative of $W(t) = y_1 y'_2 - y_2 y'_1$ that $W'(t) + p(t) W = 0$, this implies $p(t) = 0$. Note that this argument does not work if $W(t) = 0$.
On the other hand, suppose the book asks " **show** $W(t) = 0$, **given** $p(t) = 0$." Then this is different, since the solutions to $y'' + q(t) y = 0$ are linearly dependent, meaning $W(t) = 0$. | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "calculus, ordinary differential equations, derivatives"
} |
ScrollView height does not update when deleting items inside
I have a ScrollView in my app which can contain enough content where I need to scroll to get at the bottom.
However if I scroll to the bottom and then delete some items, while the content inside the ScrollView gets smaller then ScrollView height stays the same as there is some space left under the last elements.
Only after I scroll the ScrollView for just a bit does the height of the ScrollView adapt to the content.
I tried to put a ref on ScrollView and then using
onContentSizeChange={()=> scrollViewRef.current.scrollToEnd()}
However that also scrolls scrollview to the end when the Screen is mounted and also once I delete an element for some reason I am not able to delete any of the other elements.
Like...something breaks.
Any idea what else I could do for the height of the ScrollView to resize before I do any movement of the ScrollView? | Adding this prop seems to solve the problem for me:
maintainVisibleContentPosition={{ minIndexForVisible: 0 }} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, css, react native, react native scrollview"
} |
Telegra.ph text formatting
It is said that < is an editor that is able to format a text via HTML tags or markdown. In online editor neither the first nor the second method is working. What am I doing wrong? How to format text? | You can see API document, there support only limited tags.
You can select text on Telegraph Editor, you will see floating menu which contains formatting options.
I think you mistake Telegraph as Bot API, which provides `Markdown` and `HTML` formatting options. | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 8,
"tags": "telegram"
} |
Python: See for which of the values in a list the "if any"-statement was true
I have a list of users (uniqueUsers) that I've sorted out from a Log-file.
Now I'd like to see which user is doing what and at what point and have used this if statement to check the entire log-file that I've read in:
if any(x in line for x in uniqueUsers) and "borrow" in line or "return" in line:
What I've done after this is to use a regular expression to get the user's ID from the line, but I started wondering if there would be any way for me to in a very short form get the user that Python found from this condition:
any(x in line for x in uniqueUsers) | Move the condition to a predicate and store the result (by using a list comprehension instead of a generator expression):
users_in_line = [u for u in uniqueUsers if u in line]
if users_in_line and "borrow" in line or "return" in line:
# do something with list users_in_line
...
This uses the fact that empty lists act "falsy" in a boolean context, while non-empty lists (no matter their content) act "truthy". | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python, if statement"
} |
Why jQuery object has a property, but hasOwnProperty says it doesn't?
. Since `className` is inherited, `hasOwnProperty` returns false as `hasOwnProperty` does not traverse the prototype chain.
From the question "Is there a way to check if an object has an inherited property?" below: inherited properties like `className` above would appear in that object's prototype chain.
In the DOM node example from the question:
$(".comment")[0].hasOwnProperty('className'); // -> false because className comes from the prototype chain.
'className' in $(".comment")[0].__proto__; // -> true: className is inherited from up the chain | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "javascript, jquery"
} |
Excel - find nth match
I created a like to follow the inventory on an item.
I'm looking to find "What's the next date of availability?"
I found my answer with a index match function, but the problem is :
For each orders, what's available to promise... when my Running Total is not covered by the next "stock Arrival" how to find the "2nd" best match (next arrival)..
Maybe I'm overthinking this..
Here is my workbook : <
Anyone is an Excel guru? | You can check edited file. This formula is very comlicated, but it takes into account that, what would be if the second
Put this array formula and press `CTRL`+`SHIFT`+`ENTER` and fill down:
=IF(K2=0,INDEX(A3:E$17,MATCH("05 - arrival",A3:A$17,0),5),IF(SUM($G$2:G2)+INDEX($G$2:$G$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),1)-1)+INDEX($G$2:$G$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),2)-1)>0,INDEX($E$2:$E$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),2)-1),INDEX($E$2:$E$17,SMALL(IF($G$2:$G$17>0,ROW($G$2:$G$17)),3)-1)))
Hope this will help. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "excel, excel formula"
} |
Scaling everything up and down for different devices in UIStoryboard
Is it possible to have the storyboard scale everything up or down depending on the screen size or do I have to do it programmatically? For example the UI on iPhone 6 plus would look exactly like the one on iPhone 5 but just larger. | You can do it by using Aspect Ratio property of AutoLayout.
You can follow this tutorial. It gives a very nice explanation on how to scale everything up by using fix aspect ratio.
< | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "ios, uistoryboard"
} |
AsyncTask doesn't invoke onPostExecute()
I am writing an `AsyncTask` as below:
class Load extends AsyncTask<String, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... aurl) {
//do job seconds
//stop at here, and does not run onPostExecute
}
@Override
protected void onPostExecute(String unused) {
super.onPostExecute(unused);
wait = false;
new Load().execute();
}
}
And the other method as below:
public void click() {
new Load().execute();
while(wait) {
;
}
}
The wait is a global boolean value. | This code:
public void click() {
new Load().execute();
while(wait) {
;
}
}
will block the UI thread while the task executes. This is as bad as just running the background task in the foreground and should cause an Application Not Responding (ANR) error. Please don't do it.
Note that `AsyncTask.onPostExecute()` will not be called if the task is cancelled. It also won't be called if `doInBackground` throws an exception. Whatever is going on in `doInBackground` may be causing this. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "android, asynchronous, android asynctask"
} |
Netgear A7000 on Ubuntu 16.04 not working
output from _lsusb_ :
Bus 002 Device 004: ID 0846:9054 NetGear, Inc.
and from _iwconfig_ :
lo no wireless extensions.
enp0s25 no wireless extensions.
Im new to linux and currently tethering connection from my windows desktop any help is appreciated | I suggest that you get a temporary working internet connection by ethernet, tether or whatever means possible. Open a terminal and do:
sudo apt-get update
sudo apt-get install git dkms
git clone
sudo dkms add ./rtl8814au
sudo dkms build -m rtl8814au -v 4.3.21
sudo dkms install -m rtl8814au -v 4.3.21
Reboot with the device inserted and your wireless should be working. | stackexchange-askubuntu | {
"answer_score": 5,
"question_score": 2,
"tags": "networking"
} |
how to show file on asp.net form
how to get file on asp.net form so that user can download it? suppose i have created one excel file and i want to upload it on form so that user can download it, fill the details when they are offline. | You can use
Response.AddHeader("content-disposition", "attachment; filename=test.txt");
Response.WriteFile(@"test.txt");
Response.End();
Otherwise if it's a specific file you can use a normal `<a href="">Download Me</a>`and point it to the files location. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, asp.net, excel, xml serialization"
} |
Deployed Keter App Logs Users Out With a New Keter Bundle
Keter has been awesome so far. For my little toy project, I used to create the keter bundle on the production server and push it keter's incoming directory and everything worked fine.
Now I wanted to learn how to setup a staging environment and so I tried compiling my bundle on staging server (it is an image copy of the production server). When I push this bundle to my production server (via scp), it logs out signed-in users. The app itself is fine after logging back in.
What has changed:
* Some templating code has changed but nothing drastic and such changes were fine when compiled on the production server before
* Yesod's settings.yml changed to use the staging server's IP address for development testing
* Keter.yaml was not modified.
What am I doing wrong? Why does Keter care where my .keter bundle was created? Is there a way to create these bundles without disrupting signed-in users?
Thanks! | Most likely, the issue is that a new client_session_key file is being created each time your app is being deployed. Instead, you need to generate a key file once and reuse it. This is generally handled correctly by the Yesod scaffolded site, but providing an implementation of `makeSessionBackend` that stores the key file in `config`.
What is your current implementation of `makeSessionBackend`? And do your keter bundles include a file `config/client_session_key.aes`? | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "haskell, yesod"
} |
Which is better to create a webapp in which multiple users will sign up for events - Python or Java ?
I intend to create a webapp in which members of an organization will sign in, filter and search for events, and sign up to attend events. I'm just making this for one organization, but I'll most likely make it open source when I'm done.
I have my own hosting space on GoDaddy, but then I found Google's App Engine and figured it would be more efficient.
I also plan on using Twitter Bootstrap and HTML5 Boilerplate (maybe?). UI is important to me. I'll also make an iPad app with the same function that uses the same data sometime soon.
So Python or Java? What are the advantages and disadvantages for this application for each? I've learned the absolute basics of both languages but have not used either of them for the web.
I'd consider the Go Programming Language, but it doesn't look as community-supported.
TIA! | @Blender and @Barranka are right. Both languages are equally well supported on App Engine, with only very minor differences. The web client libraries you mention should integrate equally well with either, and you won't easily be able to port code to iOS in either language. (If you also plan an Android app, that might be a vote for Java, but you didn't mention that.)
So the answer is, pick the language you prefer. Both will work.
(If you don't have a preference, maybe lean toward Python, since it's higher level and supports rapid development a bit better, and Java's advantages (performance, static typing, etc.) aren't as important for what you want to build.) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -3,
"tags": "java, python, google app engine, web applications, twitter bootstrap"
} |
Sharing DataContracts between java web services (or reuse types) for WCF Client
How to provide common data contracts in the multiple java web services (hosted e.g. on the jboss), so they will be generates one time by adding a ServiceReference in the VS2010 and reused in a WCF client.
For the WCF services to wcf client the solution is clear, like it was written here Sharing DataContracts between WCF Services.
How to solve it for java web services? Is it possible? | The recommended approach for interoperability is
* Start by defining the message formats in XSD.
* generate the code in your Java web services framework
* and generate classes for use in .NET
The XSD is what allows you to "re-use classes", but the specific steps required will vary depending on the web services stack you use on the Java side.
For some tutorials you can scan < \- there are writeups on using AXIS2, JAXWS, and others. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, wcf, web services, datacontract, reusability"
} |
Как создать таблицу без колонки id?
Я создаю таблицу SQLite с тремя столбцами и колонкой id. Можно как-то ее не создавать? | Без колонки `_id` не будут работать все классы фреймворка Android, которые взаимодействуют с БД SQLite, в частности `Cursor`. Вам придется писать свои, не думаю, что вы этого хотите.
Кроме того, вся работа с БД построена на связях таблиц (один к одному, один ко многим, многие ко многим), которые реализуются через `ID`.
Но вы конечно можете не создавать этой колонки, если считаете, что она вам в самом деле не нужна.
Просто удалите строку из скрипта создания таблицы `CREATE_TABLE` с записью:
_id INTEGER PRIMARY KEY AUTOINCREMENT | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "android, android sqlite"
} |
Dynamic Data PHP error
I'm a inexperienced webmaster for my Boy Scout troop. I have recently set up MAMP on my map and then tried to use MySQL PHP server for dynamic data. When testing locally, everything worked. When I uploaded everything to my web server (for which I only have FTP access) I get this message when I try to access the php page.
Fatal error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in
Can anyone tell me what I'm doing wrong?
More info:
* Mac Pro 1,1 running 10.7
* Dreamweaver CS6
* MySQL Server 5.3.3 | I solved this problem. My error was that I didn't have MAMP set up to allow connections from the outside. Google it, there are many good resources out there to help you set it up. After I did that and made sure root access from any IP was enabled, I was good to go. Thanks for everyones help. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, mysql, dreamweaver"
} |
Increasing the Data Locality in Matrix Multiplication
In matrix multiplication we do something like this
for (i = 0; i < N; i = i + 1)
for (j = 0; j < N; j = j + 1)
A[i*N + j] = (double) random() / SOME_NUMBER;
for (i = 0; i < N; i = i + 1)
for (j = 0; j < N; j = j + 1)
B[i*N + j] = (double) random() / SOME_NUMBER;
for (i = 0; i < N; i = i + 1)
for (j = 0; j < N; j = j + 1)
for (k = 0; k < N; k = k + 1)
C[i*N + j] = C[i*N + j] + A[i*N + k]*B[k*N + j];
How can we increase the locality of data to optimize the multiplication loop | Store B in transposed form:
B[j*N + i] = ramdom() / SOME_NUMBER;
You'll also have to access the transposed array in that order:
C[i*N + j] = C[i*N + j] + A[i*N + k]*B[j*N + k];
If that's not possible, rewrite the multiplication to loop on j first, then rewrite the first product of column j of B (with row 0 of A) to extract the elements of B[*;j] into a sequential N-vector, and use that sequential copy throughout the rest of the products for that column.
The idea is to get the columns of B into consecutive memory words. The transpose does that, very naturally, but it may not be practical to keep in that format. (For example, if B is later multiplied on the right, then the original order works better. The second suggestion keeps a copy of one column into an array of consecutive words, while computing an one sum of products to make full use of the memory reads on that copy. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c, optimization, matrix multiplication"
} |
How minimally can I cut a cake sector-wise to fit it into a slightly undersized square tin?
In geometrical terms, what is the smallest number $n$ such that a disc of unit radius can be cut into $n$ sectors that can be reassembled without overlapping to fit into a square of side $2-\varepsilon$, where $\varepsilon>0$ is as small as you like? The question could be set for arbitrary straight cuts; but I like to serve my guests with traditional sector-shaped pieces. | With John’s configuration, the maximum possible value of $\varepsilon$ is approximately $0.0291842223$:
$\hspace{1.5in}$ !solution
The pieces have angles approximately $228.8124035475^\circ$, $113.1341370910^\circ$ and $18.0534593614^\circ$.
Note that the large pieces are no longer positioned symmetrically. | stackexchange-math | {
"answer_score": 5,
"question_score": 12,
"tags": "geometry, packing problem"
} |
Convert whitepspaces in selects to nbsp;
I have a select:
<h:selectOneMenu id="treeNode" label="#{msgs.treeNode}" value="#{treeNode}">
<f:selectItems value="#{treeItems}" />
</h:selectOneMenu>
which uses these selectItems:
List<SelectItem> treeItems = new ArrayList<SelectItem>();
treeItems.add(new SelectItem("1", "Parent"));
treeItems.add(new SelectItem("2", " Child 0 0"));
treeItems.add(new SelectItem("2", " Child 0 0 0"));
treeItems.add(new SelectItem("2", " Child 0 0 1"));
treeItems.add(new SelectItem("2", " Child 0 1"));
My problem is that the output in the select should look like a tree, but since the whitspaces are gone I have a "flat"-view.
Is there a way how I could convert the whitspaces into a nonbreakable-space?
Thanks Jonny | Just replace them by ` ` yourself and set the `escape` attribute to `false`. It's the 5th argument of the `SelectItem` constructor.
List<SelectItem> treeItems = new ArrayList<SelectItem>();
treeItems.add(new SelectItem("1", "Parent", null, false, false));
treeItems.add(new SelectItem("2", " Child 0 0", null, false, false));
treeItems.add(new SelectItem("3", " Child 0 0 0", null, false, false));
treeItems.add(new SelectItem("4", " Child 0 0 1", null, false, false));
treeItems.add(new SelectItem("5", " Child 0 1", null, false, false)); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "jsf 2, tags"
} |
How can I stop github to redirect all project pages to my domain?
I setup a custom domain for my personal page, but it makes all my other project pages been redirected to it, for example: <
So is there any way to stop github to redirect all the other project pages to my domain?
Thanks! | No, it is not possible to do that. If you set-up a custom domain for your personal GitHub repo - then all your project pages will be under that domain. See this FAQ page for GitHub pages (under Project pages): <
> A custom domain on user/org pages will apply the same domain redirect to all project pages hosted under that account, unless the project pages use their own custom domain. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 4,
"tags": "github"
} |
How to require a file and use its subroutine
how can I use a subroutine in a required file, when the subroutien has to get variables:
file.pl:
...
sub func{
my ($var) = @_;
..
}
main.pl:
..
require "file.pl";
func(1);
..
this is not working for me, I'm getting an error says `Undefined subroutine &main::func` .. | Perl was telling you that no `main::func` exists (`main` is default package), so you need to prefix your function with qualified package name,
require "file.pl";
Naming::func(1); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "perl"
} |
(in a List Modify View, under Style) Difference between Default Table VS Basic Table
From my recent suffering, somehow changing it to 'Basic Table' fixed the issue.
I am happy that I see the status lights back to work in my current O365 site but at the same time, I am afraid that it will break other things.
What are the differences?! | Here's a list of the View Styles with screen shots: (a little dated, but still applies)
<
Starting with SharePoint 2013, selecting any view but "Default" will hide the new command bar at the top of the list/library. | stackexchange-sharepoint | {
"answer_score": 1,
"question_score": 0,
"tags": "list"
} |
PHP7 Rename all files in directory within iterator (windows 10) 64-bit XAMPP
I need to rename all the songs to integer (numbers) with the following php code, but it shows an error:
Warning: rename(abc.mp3,2.4): The system cannot find the file specified. (code: 2) in D:\xampp\htdocs\hta\file_renames.php on line 14
command PATHINFO_EXTENSION is also not working here? i am using windows 10 with xampp (php7)
<?php $total = 0;
$dir = "songs/";
foreach (new DirectoryIterator($dir) as $fileInfo) {
if(!$fileInfo->isDot()){
$total +=1;
$file = $fileInfo->getFilename();
rename($file,$total.'.'.PATHINFO_EXTENSION);
}
}
echo('Total files: '.$total);
?>
how to rename my all .mp3 files to a number.mp3 file? within loop? | You need to supply the complete path (can be relative) to `rename`. Regarding the `PATHINFO_EXTENSION`, you are simply misusing it. Here is the fixed code:
<?php
$total = 0;
$dir = "songs/";
foreach (new DirectoryIterator($dir) as $fileInfo) {
if(!$fileInfo->isDot()){
$total +=1;
$file = $dir.$fileInfo->getFilename();
$ext = pathinfo($file, PATHINFO_EXTENSION);
$newFile = $dir.$total.'.'.$ext;
rename($file, $newFile);
}
}
echo('Total files: '.$total);
?> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "php, oop, iterator, rename, file rename"
} |
Fill empty pandas dataframe with data from list
I want to fill an empty dataframe using a list.
Here is the empty dataframe.
old_dates= pd.date_range((today -dt.timedelta(days=2)), (today-dt.timedelta(days=1))).strftime("%d %b")
columns=old_dates
df_verif=pd.DataFrame(columns=columns)
df_verif
24 Jun 25 Jun
All of the column names are dates (and will be longer through time). I then want to fill only the first row with one value for each day. Let's say I have a list that contains two values. How would I then add those values, in the order that they appear in the list, under the corresponding date?
test=[2.5,2.5]
Expected output:
0 24 Jun 25 Jun
1 2.5 2.5 | If I'm not mistaken, it should be:
`df_verif.loc[0] = test`
This adds the elements of test to the row at index 0 in the order in which they are in test. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, pandas, dataframe, datetime"
} |
Can I make a Smart Card using a flash drive?
I want to require a user to plug in a flash drive before letting them authenticate with his/her password.
Are there any solutions that work well for laptops, preferably Macs?
I'm not looking for a Smart Card, I want something more portable and off the shelf. | Welcome to Superuser!
The company I worked for used a solution by Rohos, here's a link to their website: <
They offer flash drive login authentication for both Windows and Mac operating system. It comes with Two-factor authentication with PIN code which makes our system more secure.
I hope my answer helped, please ask if you have additional questions. | stackexchange-superuser | {
"answer_score": 2,
"question_score": 3,
"tags": "mac, usb, security, usb flash drive, smartcard"
} |
Caching javascript and css files in browser
I an developing a web app and I want to ensure that the client browser caches the static js and css files and updates it only when files are modified. So if files are modified - one month later - no requests for js and css files would be made for a month. If files are modified within hours, the new files will be requested and delivered. I am wondering if its possible to get the browser to first ask if files have been modified - or any other way maybe? | You are certainly looking for something like **App Cache.**
Please check HTML5 Rocks and Mozilla Docs
It's always good to set an **_expiry date_** when your **_HTTP Request_** is send to cache this files so that going ahead in time the old versions shouldn't be cached. This is the general usecase of highly scalable Modern Full Stack Javascript Application.
Hope that answers your Query. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "http, browser cache"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.