INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Is This a Bessel Function?
Is the function
$$y(x) = c \int_{-1}^1 \cos(xt)(1-t^2)^{n-\tfrac{1}{2}}dt = c \sum \tfrac{(-1)^m x^{2m}}{(2m)!} \int_{-1}^1 t^{2m}(1-t^2)^{n-\tfrac{1}{2}}dt$$
given here a bessel function? It doesn't look like the one given in 9.1.20 here yet the method of producing it (Laplace transforms, given here) seems rock-solid, what's going on here, why is it different from the standard one? | Use the change of variables $t^2=y$ and the $\beta$ function to evaluate the integral
$$ 2\int_{0}^1 t^{2m}(1-t^2)^{n-\tfrac{1}{2}}dt = \int _{0}^{1}\\!{y}^{m-1/2} \left( 1-y \right) ^{n-1/2}{dy}= {\frac {\Gamma \left( n+1/2 \right) \Gamma \left( m+1/2 \right) }{ \Gamma \left( m+n+1 \right) }}.$$
If you sum the series you will get the result
> $$ 2^n \sqrt {\pi }\,c\, \Gamma \left( n+1/2 \right)\, x^{-n} J_n(x),$$
where $J_n(x)$ is the Bessel function of the first kind. | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "integration, definite integrals, bessel functions"
} |
is data stored in iphone encrypted by default?
according to the following website: <
it is stated that iphones encrypt all data stored in them: The iOS operating system on Apple iPhones and iPads has to deal with a similar problem. To ensure a user’s data can be quickly and completely wiped when the device is factory reset, it has a trick up its sleeve. All data on the device is encrypted by default using the hardware encryption feature. When you choose to set up encryption, the device is protected with your own encryption key. Even if you never set up encryption, the files are stored on the device in encrypted form so any bits of deleted files appear as random gibberish on the device’s storage after it’s reset. The data can’t be recovered.
im confused.
is all data stored in iphones encrypted by default? specifically iphone 5s | Yes, the data is encrypted by default. However it is not "secure" in the sense that if you do not set up a sufficiently good pass code, it is easy to read the data if you have access to the phone. | stackexchange-apple | {
"answer_score": 2,
"question_score": 3,
"tags": "iphone, encryption"
} |
Homomorphism between Lie group and transformation groups
Let $M$ be a differential manifold. Let $\mathfrak{X}(M)$ be the set of smooth vector field over $M$. Let $g$ be a finite Lie subalgebra of $\mathfrak{X}(M)$. Let $G$ be a connected, simply connected Lie group whose Lie algebra is $g$.
Suppose $g$ has the property that $\forall X\in g$, $X$ is complete. We can thus define the transformation $X_t\in\mathrm{Diff}(M)$. The group generated by all such transformations is a subgroup of $\mathrm{Diff}(M)$, denoted $H$.
If $\dim g=1$, $\exp(tX)\rightarrow X_t$ defines a homomorphism $G\rightarrow H$.
In general, how do we prove that there exists such a homomorphism?
(in Kobayashi, page 13, it is stated that the group $G$ acts locally on $M$, which, I believe, is equivalent to the existence of such a homomorphism. The homomorphism is also used in the proof of lemma 1 on the same page). | Here I give a proof idea:
Let $N=G\times M$ and $g_\times$ be the vector field defined by $(g,m)\mapsto(X_{\mathfrak{X}(G)}(g),X_{\mathfrak{X}(M)}(m))$. Then by Frobenius theorem there exists a unique submanifold $\mathcal{L}_m$ passing by $(e,m)$ integrating $g_\times$. We prove that $\mathcal{L}_m\simeq G$ by the first projection, and there exists $\mathrm{Diff}(\mathcal{L}_m)\rightarrow\mathrm{Diff}(M)$ a group homomorphism induced by the second projection (which concerns picking a pre-image in $\mathcal{L}_m$ the choice of which which leaves the overall operation invariant). And finally we observe that the composite morphism:
$$G\rightarrow\mathrm{Diff}(G)\rightarrow\mathrm{Diff}(\mathcal{L}_m)\rightarrow\mathrm{Diff}(M)$$
sends $\exp(tX)$ to $X_t$. | stackexchange-math | {
"answer_score": 0,
"question_score": 2,
"tags": "differential geometry, lie groups, lie algebras"
} |
Getting specific column in Laravel relation returning empty array
I want to get specific column from Model relation in Laravel, but the relation model returning empty array.
**Eloquent Query**
$medicines = Medicine::with(['weightage' => function($query) {
$query->select('name');
}])->get(['name', 'description']);
**Medicine Modal**
public function weightage()
{
return $this->hasMany('App\MedicineWeightage', 'medicine_id');
} | You always need to also select the primary and foreign keys of the table to make the relation work:
$medicines = Medicine::with(['weightage' => function($query) {
$query->select(['id', 'name', 'medicine_id']);
}])->get(['id', 'name', 'description']); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "php, laravel, eloquent"
} |
Assigning and retrieving an array of strings to a void pointer
I'm quite unfamiliar with how pointers work. I'm working with a function that callbacks a function with a `void *` context as an argument.
How would I go about assigning an array of strings to a `void *` and then retrieving them?
char callback_value[2][16];
snprintf(callback_value[0], sizeof(callback_value[0]), "string1");
snprintf(callback_value[1], sizeof(callback_value[1]), "string2");
// pass an array of strings into the void * callback context
void *callback_context = callback_value;
// Illustration only, doesn't work
// retrieve it here
char **retrieved_strings = (char **)callback_context;
printf("%s", retrieved_strings[0]); // Want "string1"
printf("%s", retrieved_strings[1]); // Want "string2" | #include <stdio.h>
void func(void* arg)
{
char (*tmp)[16] = arg;
printf("%s\n%s\n", tmp[0], tmp[1]);
}
int main(void)
{
char callback_value[2][16] = {"string1", "string2"};
void *callback_context = callback_value;
func(callback_context);
return 0;
}
`char**` is not compatible with `char[2][16]`, you have to use a pointer to an array of char `char (*)[16]`.
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -3,
"tags": "c, arrays, string, pointers"
} |
Why, in Coq, a record projection expects a Type as argument?
I would like to formalize a data structure (a string concatenation) in Coq:
Require Import List.
Record SeedPassword (A: Type): Type := {
seed: list A;
password: list A
}.
Record SeedPasswordConcatenation {A: Type} (S: SeedPassword A): Type := {
concatenation: list A;
proof: concatenation = (seed S ++ password S)
}.
However, I get an error in the last record:
The term "S" has type "SeedPassword A" while it is expected to have type "Type".
Why does it expect a `Type`? The projection `seed` should take a `SeedPassword A`, right? | About seed.
returns:
>
> seed : forall A : Type, SeedPassword A -> list A
>
> Argument scopes are [type_scope _]
> seed is transparent
> Expands to: Constant Top.seed
>
So, `seed` needs the type, otherwise `A` in `SeedPassword A` will be unbounded.
You can solve the issue with implicit arguments, which Coq will try to infer. One way to do it is to put
Set Implicit Arguments.
into your file (usually after the imports). Or you can use `Arguments` command like so:
Record SeedPassword (A: Type): Type := {
seed: list A;
password: list A
}.
Arguments seed {A} _.
Arguments password {A} _. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "coq"
} |
Xamarin.Forms: How to expand row from listview over full screen after tap or click?
I have two **cell templates** that appears in **ListView**. After clicking or taping on a cell, loading the second _expanded_ (resized) template which is longer and shows more information. Problem is that I would like second template to expand and extend over the **entire screen** (from the toolbar to the bottom), not only as much as the content of template. To be perfectly clear, I do not want to open up a new window (Navigation.PushAsync), but to **expand whole content in full screen.** For now I have a way to fix the height of the extended cell after clicking, but that's not what I want, because every mobile device is different and has a different resolution.
Is there any easy way to do this, or I have to use some Nuget?
**_Thanks in advance!_** | For list view cell you could use a grid. Then binding width and height with a column definition. How to do it you can find on the internet. Screen width and height you can get in platform specific project. On android width you can get like that:
App.ScreenWidth = ( int )( Resources.DisplayMetrics.WidthPixels / Resources.DisplayMetrics.Density );
Something similar will be with height. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "listview, xamarin.forms, expandablelistview"
} |
How to install .patch file
I want to install World of Tanks, and I'm following this tutorial <
There is a thing with raw input mouse, and I don't know how to install it, the file name is raw3.patch and it's on desktop, and I always get this error :
~/Desktop$ patch -p1 < raw3.patch
can't find file to patch at input line 11
PerhAaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|commit 51e1810634de2c212e6515fbfb2ea92a3e2409ad
|Author: Vincas Miliūnas <[email protected]>
|Date: Wed Feb 22 21:48:26 2012 +0200
|
| RAW
|
|diff --git a/dlls/user32/input.c b/dlls/user32/input.c
|index 050fb2b..23ad6f7 100644
|--- a/dlls/user32/input.c
|+++ b/dlls/user32/input.c
--------------------------
File to patch: | This is a patch file that is meant to be applied to the source code of wine before compiling.
To do that, read up on how to compile wine and apply the patch (through the command you already found) before compiling and installing wine. | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 0,
"tags": "kernel, wine, patch"
} |
Is the London pass valid(/free) for multiple entries to same tourist attraction?
I am planning to buy 10 a day London pass to visit all the attractions in London. Can I enter into the same attraction, such as the Thames River Cruise, multiple times with this London pass, without paying entry fee second time?
**UPDATE after using London Pass:** Collected London pass after showing email on phone. Using London pass, collected City cruise 24 hour ticket at 2PM and boarded once on same day and second time next day morning too. Seen one tourist, showing London pass email on phone at Windsor castle to get entry without the actual London pass tag.
What a great city London is!!! I wonder why London is not part of 7 world wonders. | From How does the London Pass work?:
> Note: Passes can only be used at each attraction once.
However, as noted by JakubJ, for the Thames boat trip, what you actually get is
> ### Make the most of your London Pass:
>
> * Free 24 hour hop-on, hop-off cruise ticket worth over £18
>
So for this attraction (alone), you get as many trips as you like, within a single 24 hour period.
So given that the Thames River Cruise is listed as one of the attractions, I'd say the answer is **no** to both your questions. | stackexchange-travel | {
"answer_score": 10,
"question_score": 8,
"tags": "london, sightseeing, tips and tricks, history"
} |
oF: error C2039: '_Dynamic_tag' : is not a member of 'std::tr1'
I've just started using openFrameworks and am using the 0072 Visual Studio version. When I tried to build the empty sample project oF provided me with, it gave me only this error:
error C2039: '_Dynamic_tag' : is not a member of 'std::tr1'
I'm using Visual Studio 2012 Express and seemingly this issue has already been solved, but in VS2010 version, here.
I've checked the ofTypes.h with the solved one and there was not a difference.
Any idea? | My understanding is that VS2012 takes `std::tr1::` out entirely in favour of having the new C++11 features in `std::`, though you may be able to put it back with some compiler option.
If nothing else, it looks like OFW is using internal, implementation variables (the leading underscore is a clue), which was a pretty silly thing to do.
The implication then would be that OpenFrameWorks needs another update. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c++, openframeworks"
} |
How to Convert Double Byte String to Single Byte String?
I am a newbie at C#.
I have a `Textbox` and it is allowed to accept `double_byte` string and it is used to input/show **Date Value**. Now I am having a problem and I don't know how to solve this.I googled about it,and can't find any solution for it.
When I wrote `Double_Byte` Characters( **** ) ,I want to change this value to ( **2012/12/31** ) at `Leave_Event` of TextBox or `Text_Changed` Event of this TextBox. So, How can I solve the problem.
**Edit** ->My Solution is Window Application.
Thanks in advance. | Thank you for all of your answers and interests.
I searched a solution for this and not found any answer .Finally ,I got a nice answer from my colleague. Therefore, I share the answer of this problem.
1. Add Reference Microsoft.VisualBasic
2. write code like this(test like sa_ddam213's answer)-
using Microsoft.VisualBasic;
private void button1_Click(object sender, EventArgs e)
{
string inputText = textBox1.Text;
string singleByteString = Strings.StrConv(inputText, VbStrConv.Narrow, 0);
textBox2.Text = singleByteString;
textBox3.Text = inputText;
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, textbox"
} |
How to remove margin from zurb foundation text-field
Zurb Foundation's text field have a `1em` bottom margin that I want to remove.
I couldn't find custom scss in zurb foundation documents.
I'm overwriting the stylesheet by using `!important` option. But if possible I don't want to use it.
Is there better way to remove the margin from foundation form text field? I'm using foundation in a rails project. | You can override the styles without using !important option.
If there are multiple contradictory CSS file then whichever gets called LAST will override the previous one.
For example if you add below styles in your CSS file and include it after docs.css then it gets highest priority.
Have a look at the JS Fiddle
input[type="text"]{
margin: 0;
} | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "css, ruby on rails, zurb foundation"
} |
ASP.Net MVC 3.0 DateTime Format on View?
I am trying to format the DateTime to Just display just date with out time.
Can any one suggest on that please?
@Html.DisplayTextFor("", String.Format("{0:dddd, MM/dd/yyyy}", Model.DOB)) | Conversion On View Use this one..
@Html.DisplayTextFor("", String.Format("{0:MM/dd/yyyy}", Model.DOB))
and for Conversion in ViewModel you can simply use this..
(DateTime.Now).ToShortDateString(); | stackexchange-stackoverflow | {
"answer_score": -2,
"question_score": 1,
"tags": "datetime, format"
} |
Sum of two Columns of Data Frame with NA Values
I have a data frame with some NA values. I need the sum of two of the columns. If a value is NA, I need to treat it as zero.
a b c d
1 2 3 4
5 NA 7 8
Column e should be the sum of b and c:
e
5
7
I have tried a lot of things, and done two dozen searches with no luck. It seems like a simple problem. Any help would be appreciated! | dat$e <- rowSums(dat[,c("b", "c")], na.rm=TRUE)
dat
# a b c d e
# 1 1 2 3 4 5
# 2 5 NA 7 8 7 | stackexchange-stackoverflow | {
"answer_score": 49,
"question_score": 36,
"tags": "r"
} |
Form Navigation
So, on iOS, you can allow users to navigation forms. (next & previous fields with arrows above the keyboard) Is there something similar to this on WP7? My app requires some amount of sequential order, and I'd like for the user not to have to tap every single field. | There is no built in functionality which is equivalent to that in iOS.
You can, however, add the functionlaity to advance the focus to the next field when the user presses the enter key. And then submit the page when pressing enter on the last field.
There is a good encapsulation of this functionality inside a behaviour at < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "forms, windows phone 7"
} |
How to bulk Edit Dates in Media Library?
I can't seem to find this option, but is there a way to bulk edit the dates of media items? I'm trying to go through my media and clean it up and I'd like to batch edit the dates of images (they'd be the same date for each batch), but can't seem to find a reference at all to this issue. | You can use a plugin called Media Library Assistant.
1. After you install it go to your **Media > Assitant** (`wp-admin/upload.php?page=mla-menu`).
2. Select all the images or the ones you want to edit.
3. Click on **Bulk Actions**.
4. Click on **Edit** and then **Apply**.
5. Then you will see **Uploaded on** and use the date you wish.

My guess is that I lack some basic understanding of how transistors operate. Maybe I chose the wrong transistor or I need to apply higher voltage between emitter and collector? | 1. Make sure that the GND connection at the emitter of the transistor also connects back to the GND of the Arduino board.
2. Check that you have the diode installed the right direction. If the diode has a line or band marked end that side should be connected to the +5V.
3. Normally you would check the voltage when the buzzer is in place instead of removing it. Since you removed the buzzer and measured less than a volt it is an indication you have the diode installed backwards.
4. If you had the diode installed backwards replace your transistor with a new one. You likely damaged it. | stackexchange-electronics | {
"answer_score": 6,
"question_score": 2,
"tags": "arduino, transistors, piezo buzzer"
} |
How do I multiply integers within a nested list?
I need to write a function that takes a list of numbers and multiplies them together. Example: [1,2,3,4,5,6] will give me 1*2*3*4*5*6. I could really use your help. This also need to work if there is a nested list. Please help! This is the code I attempted.def multiplyNums(p): total = 1 for i in p: if i == type(int) or type(float) total = total * i elif i == type(list): total2 = multiplynums() if p ==
print(total)
product_list([2,3,4,[2,4],2])
As you can see a portion of the code is missing but I just don't know what to do at this point. | from collections import Iterable
def product_of(items):
if isinstance(items, Iterable):
# list of items - reduce it
total = 1
for item in items:
total *= product_of(item) # <= recursive call on each item
return total # (could be a sub-list)
else:
# single value - return it
return items
then
product_of([1, 2, [3, 4], 5, [6, [7, 8]]]) # => 40320
* * *
**Edit:** If you want to avoid imports, you can just replace `if isinstance(items, Iterable):` with `if isinstance(items, list):` (but then it will fail unnecessarily if `items` is a tuple, generator, set, etc). | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": -1,
"tags": "python, list, nested"
} |
GeoServer - Unaccent function
PostgreSQL databases have an extension called unaccent to remove accents from words. Is there some function on GeoServer to do the same? | Not currently, but it would be easy for you (or someone) to add, the actual code would be pretty simple:
Looking at this question gives the necessary clues, so:
public static String strRemoveAccents(String s1) {
if (s1 == null) return null;
return StringUtils.stripAccents(s1);
}
The hard bit is finding some test cases etc.
**Update** see this issue for progress. | stackexchange-gis | {
"answer_score": 5,
"question_score": 3,
"tags": "geoserver"
} |
Debug Slow Razor View
I have ASP MVC 4 web application. One of the actions return very slowly. I use MiniProfiler to profile the application.
We handle the duration of the action itself which is now 14ms, the problem is that there is still about 1.5s on the step of the request itself, without the time of the action on the controller (please see the attached image).
!MiniProfiler screen shoot
As you can see the first line duration (1262.3) is the duration **without** the children. As far as I understand this is the time of the razor engine rending. It is important to note the slowness persist, it is not just the first request. It never goes bellow 800ms and sometime up-to 2s.
How can I profile the rendering itself? The view is quite complex with several partial views in it. | See if Glimpse gives you more insight
<
Rendering a View can take very long if Routes are calculated. Check how long rendering takes if you remove all ActionLinks and similiar Html Helpers. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 4,
"tags": "performance, asp.net mvc 4, razor"
} |
What am I doing wrong in this inequality?
Q. The solution set of the inequality $$||x|-1|<|1-x|, x \in R$$
My Solution:
Case1: If $x≥0$
$||x|-1|<|1-x|$
=> $|x-1|<|1-x|$
Hence, S1=>$ x \in ∅ $
Case2: If $x<0$
$||x|-1|<|1-x|$
=> $|-x-1|<|1-x|$
=> $|x+1|>|x-1|$
=> $|x+1|-|x-1|>0$
Critical Points are -1 and 1
Subcase1: If $X<-1$
$|x+1|-|x-1|>0$
=>$-(x+1)-[-(x-1)]>0$
=>$-2>0$
Hence SubSolution1=> $x \in ∅$
Subcase2: If $-1<x<1$<br $|x+1|-|x-1|>0$
=>$x+1-[-(x+1)]>0$
=> $x>0$
Hence SubSolution2=> $x \in (0,1)$
Subcase3: If $x>1$
$|x+1|-|x-1|>0$
=>$x+1-(x-1)>0$
=>$2>0$
Hence SubSolution3=> $x \in (1, \infty)$
Hence Solution2=> $Subsolution1 \cup SubSolution2 \cup Subsolution3 $
=> $∅ \cup (0,1) \cup (1, \infty)$
=>$(0, \infty)$
Final solution=> $ S1 \cup S2$
=> $∅ \cup (0, \infty)$
=> $(0,\infty)$
But the actual answer is $(-\infty, 0)$ | In your case 2 your implication $\vert -x -1 \vert \lt \vert 1-x\vert $ implies $\vert x +1 \vert \gt \vert 1-x\vert $ is wrong as
$$\vert -x -1 \vert =\vert x+1 \vert \lt \vert 1-x\vert $$ | stackexchange-math | {
"answer_score": 2,
"question_score": 3,
"tags": "inequality, absolute value"
} |
VBA select case multiple ranges
I am trying to figure out how to use the select case for the problem below.
1. In cell A1 I will have the text "white" or "black"
2. In cell B1 is a number
3. In cell C1 is the result i am looking for to be shown
If A1=white and B1<2 then C1=25
If A1=white and B1>=2 then C1=49
If A1=black and B1<2 then C1=14
If A1=black and B1>=2 then C1=30 | You could use the following:
Select Case True
Case Range("A1") = "white" And Range("B1") < 2: Range("C1")=25
Case Range("A1") = "white" And Range("B1")>=2: Range("C1")=49
Case Range("A1") = "black" And Range("B1") < 2: Range("C1")=14
Case Range("A1") = "black" And Range("B1")>=2: Range("C1")=30
End Select | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "vba"
} |
Camera "Jitter" When circling around object
So I made a simple camera rig (camera clamped to nurbus circle and parented to an empty, dead center in middle) but I get this unwanted jitter, not sure what causes it, if someone knows solution, I would be grateful, thanks!
Problem shown in a Youtube video attached
Youtube Link | Sounds like there is a conflict, two constraints fighting for control of the camera - the path and the empty. To avoid this, have an empty follow the path, and parent the cam to the empty. This will allow independent use of the cam, i.e. 'look at', rotation, etc.
 | No, you can't expose the entry points to your C# DLL as Win32-style APIs. If you really, really need to create procedural entry points for a .NET library, probably the best thing to do is create a mixed-mode wrapper library using C++/CLI. But this seems like hard work: exposing your C# classes as COM objects is likely to be a lot less effort and much easier to maintain. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "c#, api, vb6"
} |
Oracle. Memory usage of object instances
For example i have following code:
CREATE TYPE t_object IS OBJECT (field1 NUMBER
,field2 VARCHAR2(10));
/
DECLARE
v_object t_object;
BEGIN
FOR i IN 1 .. 3000000 LOOP
v_object := NEW t_object(i, to_char(i));
END LOOP;
END;
If i understood correctly, on each iteration, oracle creates new instance of object. But how oracle allocates memory for each of created instance? Where oracle stores these instances (PGA?) ? And when it cleans memory? | PL/SQL variables are allocated in PGA because each executed instance has its own set of values. The objects in PL/SQL have well defined scope so they are destroyed when the scope is left, local variables when leaving function/procedure, global variables when their session is terminated. You can monitor the process' PL/SQL memory using
SELECT
PROGRAM,
SPID,
ROUND(ALLOCATED / 1048576, 1) ALLOCATED,
ROUND(USED / 1048576, 1) USED,
ROUND(MAX_ALLOCATED / 1048576, 1) MAX_ALLOCATED
FROM
V$PROCESS P,
V$PROCESS_MEMORY PM
WHERE
P.PID = PM.PID
AND BACKGROUND IS NULL
AND CATEGORY = 'PL/SQL'
AND ADDR = (SELECT PADDR FROM V$SESSION WHERE SID = :SID) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "oracle, oracle11g"
} |
Where is My Classpath in Windows?
Hello I am using IntelliJ Idea 13.0.1 and I downloaded the seaGlass LAF. The website instructed me to put it into my classpath but I have no idea where that is on my windows machine. I am not using a special package or anything. I'm just using the src folder and I tried putting the JAR file everywhere. No working. Can I get some help please. A SIMPLE classpath explanation would be good too. | By adding dependencies in IntelliJ you are in turn configuring the classpath of your application.
1. Create a java project in IntelliJ
2. Open the Project Structure | Module Dependency
3. Add your jar for seaglass LAF to the dependency list in the dialog
4. Add your java code to the project
5. Add the code for applying the seaglass LAF to your program
As you start your application the IDE will generate the java execution with the appropriate classpath. This classpath is created from the list of dependencies, one of which is your LAF. You can inspect the java program execution with the classpath parameter in the console output in the lower window in the IDE.
There are much better places than here to learn about what a classpath is. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": -2,
"tags": "java, swing, intellij idea, classpath"
} |
Group by data based with same group occuring multiple times
Input data
id group
1 a
1 a
1 b
1 b
1 a
1 a
1 a
expected result
id group row_number
1 a 1
1 a 1
1 b 2
1 b 2
1 a 4
1 a 4
1 a 4
I require the rwo_number based on the above result. If the same group occurring the second time generates different row_number for that? I have one more column sequence of date top to end. | This is an example of a gaps-and-islands problem. Solving it, though, requires that the data be ordered -- and SQL tables represent _unordered_ sets.
Let me assume you have such a column. Then the difference of row numbers can be used:
select t.*,
dense_rank() over (partition by id order by grp, (seqnum - seqnum_g)) as grouping
from (select t.*,
row_number() over (partition by id order by ?) as seqnum,
row_number() over (partition by id, grp order by ?) as seqnum_g
from t
) t;
This does not produce the values that you specifically request, but it does identify each group. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "sql, amazon redshift"
} |
Asynchronous import in Python
I need to import something large and computationally expensive but don't need it right away in my application. Is there a way to import something asynchronously in python, i.e. have whatever the import needs to do be done in the background while my script is running? Google has not been helpful so far. | You can call the python importer as a function in a different thread instead of using `import foo`. Since this import is computationally expensive and python only allows one thread to run at a time (unless its something like `pandas` that releases the GIL), you may find little benefit. Still,
import threading
import time
def begin_load_foo():
global foo_thread
foo_thread = threading.Thread(target=load_foo_thread)
foo_thread.start()
def load_foo_thread():
global foo
print("start importing")
foo = __import__('foo')
print("done importing")
def wait_foo():
print('wait')
foo_thread.join()
print('done')
def do_other_things():
time.sleep(1)
begin_load_foo()
do_other_things()
wait_foo()
foo.bar() | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "multithreading, python 3.x, asynchronous, python import, python multithreading"
} |
What does your team do to stand out?
Where I work, we have small teams of 2 - 5 people. As a dev lead, what are some things that you've implemented which makes your team stand out from the others? Meaning, it makes the others teams say, "that's cool" or "why didn't we think of that". Just some thinking out of the box that made your team extremely efficient. | Automated unit testing and an automated build system (like CruiseControl) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "performance, lead"
} |
Why does this code alert three undefined values?
Why does this code alert three undefined values?
<html>
<head>
<script type="text/javascript" language="javascript">
function doIt(form){
alert(form.elements.length)
for (var i in form.elements){
alert(form.elements[i].value);
}
}
</script>
</head>
<body id="body">
<form method="GET" action="
<input type="button" value="Go" onclick="doIt(this.form)">
</form>
</body>
</html>
Thank you in advance. | You've having a problem because the array in `form.elements` isn't a true array. its a `HTMLCollection` which is an array-like object. As a result it isn't iterable with a for...in loop. Switch to a standard for loop and it works as expected.
The for...in loop is really meant for iterating through the properties of an object. It is not recommended for use on arrays (see the description section here). | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "javascript, dom"
} |
Ничем НЕмотивированные. НЕ слитно или - раздельно?
> В данном случае у больного, страдающего в течение ряда лет периодически обостряющейся шизофренией, имеют место непонятные для него, **ничем немотивированные** состояния страха и тревоги, возникающие всегда при соприкосновении с окружающими людьми и сопровождающиеся неясными опасениями какой-то опасности со стороны этих людей.
Так написано в книге 1957 года "Шизофрения: клиника и механизмы шизофренического бреда", автор - Елена Николаевна Каменева.
Слитное написание "НЕ" \- ошибка? | По современным правилам должно писаться **ничем не мотивированный**.
Надо учесть, что современные правила (в том числе и то, которое регламентирует написание в данном случае "не" раздельно с прилагательным) были приняты в 1956 г. Так что возможно, что книга 1957 г. издания просто не была ещё редактирована в соответствии с обязательными унифицированными правилами, ведь книги готовятся к изданию раньше, чем издаются. | stackexchange-rus | {
"answer_score": 1,
"question_score": 0,
"tags": "грамотная речь, орфография"
} |
Adding background color of notes to Sphinx-generated PDF files?
I am able to generate notes using the Sphinx directive `.. notes::`. However, the notes in html file have a background color while those from the generated PDF don’t.
How can I add color to Sphinx-generated PDF files? | You can add something like this in your `conf.py` file (see the doc for the options for the LaTeX output):
latex_custom = r'''
\definecolor{Admonition}{RGB}{221,233,239}
\makeatletter
\newenvironment{admonitionbox}{
\begin{lrbox}{\@tempboxa}\begin{minipage}{\columnwidth}
}{
\end{minipage}\end{lrbox}
\colorbox{Admonition}{\usebox{\@tempboxa}}
}
\renewenvironment{notice}[2]{
\begin{admonitionbox}
}{
\end{admonitionbox}
}
\makeatother
'''
latex_elements = {'preamble': latex_custom}
This is a basic example, it will change the background color of all the admonitions boxes (note, warning, tip, etc.). | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 5,
"tags": "latex, python sphinx, restructuredtext"
} |
Does PayPal Standard automatically retry to charge the client if a payment fails?
I have to integrate PayPal Standard Payments in my Saas for a monthly subscription.
I found a few tips in the PayPal documentation about using API but it's not my case.
If after a few months a payment fails because the client has no money, does it automatically retry to charge the client in the next days or should I set a custom field? | There is a variable **sra** when set to 1 , PaYPal will try to collect the payment two more times before canceling the subscription. More information on Recurring Payments Reattempts
> How PayPal Reattempts Failed Recurring Payments
_PayPal reattempts to collect recurring payments three days after the day on which recurring payments fail. If the first reattempt to collect a recurring payment fails, PayPal waits 5 days to reattempt a second time. If the second reattempt fails, PayPal cancels the subscription._ | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "paypal, paypal subscriptions"
} |
Netflix DRM error (Ubuntu 12.10, VirtualBox, Win7)
Has anyone seen the Netflix DRM error described below? If so, is there a way around it?
To attempt to solve the problem of viewing Netflix on Ubuntu, I have created a virtual machine running Windows 7. This approach has been suggested in the answers to Is there a way to stream Netflix? and can be seen working in this video.
I am running Ubuntu 12.10, VirtualBox 14.1.18, Windows 7, and Firefox 16.0.2. I am able to login to Netflix, select a show to watch, and see the show start to load, but then I get the following error.
!enter image description here
# Solution
The solution is on the link provided by bford16.
Remove/rename the `mspr.hds` file.
Windows 7 location:
C:\ProgramData\Microsoft\PlayReady\mspr.hds
Windows XP location:
C:\Documents and Settings\All Users\Application Data\Microsoft\PlayReady\mspr.hds | I have seen this error myself. I plan to try the fix in this link:
< | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 3,
"tags": "12.10, netflix, drm"
} |
Mixed Type XSD Validation help
I've been tasked with building an XSD to validate a given xml, my issue is that some of the XML elements are of the form
<ElementName description="i am an element">1234567</ElementName>
I need to build the XSD that validates the Element 'value' not the attribute so with my increadibly limited experience in building XSDs (I've read the W3C tutorial) i tried this
<xs:element name ="ElementName" type="xs:int">
<xs:complexType mixed="true">
<xs:attribute name="description" type="xs:string"/>
</xs:complexType>
</xs:element>
and lo and behold ... it doesn't work, it says:
> "The Type attribute cannot be present with either simpleType or complexType"
i'm sure it's some thing stupid i've done but couldn't find an answer/misinterpreted answers elsewhere !
Thanks in advance | Mixed types are something different. You need a complex type with simple content:
<xs:element name="ElementName">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:int">
<xs:attribute name="description" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
See also:
* < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "xml, xsd validation"
} |
Processing.js sketch flickering when downloaded from OpenProcessing
I tried downloading this sketch: < However when I run it on my version of Processing V2.1.2 in JavaScript mode it starts to have horrible flickering. As if there are two instances of the code running on top of each other.
When run off the website, the sketch runs perfectly.
What is different about what I am doing and what can I change to stop the flickering?
I have tried creating my own sketch and a similar problem is occurring.
My sketch and code is here: < | I figured this out. I had multiple versions of processing.js in root and web-export folders. I don't know why this caused the flickering, but deleting all the files and letting Processing create its own file made it work | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, html5 canvas, processing, flicker, processing.js"
} |
find time conflicts between two dates
I am working on a query that should find lunch times between two dates. for example, lunch time is between 14:00 PM and 15:30 PM. and dates are: '2016-06-09 10:00:00.000' and '2016-06-11 10:00:00.000' lunch time occures two times between these dates. and another examples:
'2016-06-09 15:00:00.000' and '2016-06-11 10:00:00.000' : 2 Times
'2016-06-09 17:00:00.000' and '2016-06-11 10:00:00.000' : 1 Time
'2016-06-09 13:00:00.000' and '2016-06-11 15:00:00.000' : 3 Times
but I can never do it :( | Try this and make tweeks according to your requirements:
DECLARE @date1 DATETIME = '2016-06-09 08:30:00.000';
DECLARE @date2 DATETIME = '2016-06-13 18:00:00.000';
DECLARE @lunchStart DATETIME = '2016-06-13 14:00:00.000';
DECLARE @lunchEnd DATETIME = '2016-06-13 15:30:00.000';
DECLARE @output INT = 0;
SELECT @output = DATEDIFF(DAY, @date1, @date2)
IF DATEPART(HOUR, @date1) > DATEPART(HOUR, @lunchStart) OR (DATEPART(HOUR, @date1) = DATEPART(HOUR, @lunchStart) AND DATEPART(MINUTE, @date1) <= DATEPART(MINUTE, @lunchStart))
SET @output = @output - 1
IF DATEPART(HOUR, @date2) < DATEPART(HOUR, @lunchEnd) OR (DATEPART(HOUR, @date2) = DATEPART(HOUR, @lunchEnd) AND DATEPART(MINUTE, @date2) = DATEPART(MINUTE, @lunchEnd))
SET @output = @output - 1
PRINT @output | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "sql, sql server"
} |
How does one disable W3 logging using Powershell?
So far I have not been able to find an answer to this with Google searching or searching this site. I was wondering how one might turn off w3 logging using powershell.
To find the setting by opening the application you open IIS and then go to the server you are looking for. You should see Logging under the IIS section. That is the logging I want to disable using powershell. Does anyone have any idea how? | Taking ideas from this Powershell command to set IIS logging settings question, how about:
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' `
-Location 'example.com site name' `
-Filter "system.webServer/httpLogging" `
-Name "dontLog" -Value "True" | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "powershell"
} |
Duplicate a line the same number of times as column 1
There are several questions about how to duplicate lines, I want to automatically duplicate each line the specific number of times as found in field one of a file. I have a large file with two fields, field one is a number, field two is the information in question, like this.
12 AAA
18 BBB
25 CCC
33 DDD
I would to duplicate each line so it is represented the same number of times as the number in field one. So, I want 12 lines that say "12 AAA" and so on.
I know that I can manually paste each line x number of times in vim (copy and then "12p") but this seems onerous for a large file. Does anyone know a script that can do it automatically? | With `awk` same as JigglyNaga's answer:
awk '{ c=0; while ($1>c++) print }' infile | stackexchange-unix | {
"answer_score": 2,
"question_score": 1,
"tags": "linux, bash, shell"
} |
Presburger Arithmetic Decision Procedures
What are good textbook references for Presburger Arithmetic decision procedures? | John Harrison's handbook on automated theorem proving contains a fairly detailed description of Cooper's algorithm, including the steps necessary for an implementation in ML.
Harrison, J. (2009). _Handbook of practical logic and automated reasoning._ Cambridge University Press. | stackexchange-cstheory | {
"answer_score": 3,
"question_score": 3,
"tags": "reference request, lo.logic"
} |
Table cell stretching
I have two columns in my table with equal width (50%, 50%). I am showing search results URL in them. For big urls the columns are stretching and destroying the layout.
Any suggestion to the problem? | SEE **How to wrap long lines without spaces in HTML?**
These may help too:
Best word wrap algorithm?
Word-wrap in an HTML table | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "cell, stretch"
} |
SourceTreeでブックマークした(Local)リポジトリのパスを変更したい
SourceTree 2.6.6 WindowsOSWindows 10
RemoteLocalgit
GUI |
C:\Users\\AppData\Local\Atlassian\SourceTree\bookmarks.xml
bookmarks.xml | stackexchange-ja_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "sourcetree"
} |
Adding leading zeros to string value in QGIS
I have a `"field"` with string values like
field | new field
---|---
3 | 0003
5 | 0005
22 | 0022
999 | 0999
What is the right expression for the QGIS Field calculator to get a 4-character string-field like `"new field"`? | in Field calculator "lpad" does what you want:
> Returns a string padded on the left to the specified width, using a fill character. If the target width is smaller than the string's length, the string is truncated.
> Syntax: lpad(string,width,fill)
so in your case it would be:
lpad("Your_field_name",4,'0') | stackexchange-gis | {
"answer_score": 2,
"question_score": 1,
"tags": "qgis, field calculator, fields attributes, leading zero"
} |
A Java HTTP Server
I want to implement a Java HTTP server locally, I mean the server computer would be in my control. I'm expecting not more than 20 clients to send requests to it. I was wondering how to go about it:
1. Should I use a J2EE servlet container, like Apache Tomcat?
2. Could I use J2SE classes and just build it using them?
3. Are there any existing alternatives?
What does your experience suggest? | There's a simple HTTP server embedded in the Sun 1.6 JRE. It's not JavaEE or servlet-compliant, it's very lightweight, but it might be good enough for your requirements. No need to download any 3rd party stuff if this is all you need.
The javadocs, rather bizarrely, are out on their own, here. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 4,
"tags": "java, http"
} |
What is the Java `static {}` keyword all by itself?
> **Possible Duplicate:**
> Static Block in Java
I came across the following use of `static` and did not figure out what it does. I am aware of using for example `static String hello = "World";` but I do not understand the following.
static {
loadFromProperties(new Properties());
} | It's called a static initializer. It's a block of code that runs when the class is initialized.
Related question (probably a dup actually):
* Static Block in Java | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 5,
"tags": "java, static"
} |
what is ['1','2','3'].map(parseInt) result
['1','2','3'].map(parseInt)
return `[1, NaN, NaN]`
I don't know why? In my opinion is like this:
['1','2','3'].map(function(i){return parseInt(i,10)})
return `[1, 2, 3]`
======================================================
and other
`['1','2','3'].map(parseFloat)`
return `[1, 2, 3]` | Check out this article: <
The callback function is specified as:
callback
Function that produces an element of the new Array, taking three arguments:
currentValue
The current element being processed in the array.
index
The index of the current element being processed in the array.
array
The array map was called upon.
Therefore your `map()` function expands into:
parseInt('1', 0, the_array) # 1
parseInt('2', 1, the_array) # NaN
parseInt('3', 2, the_array) # NaN | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 10,
"tags": "javascript"
} |
Ninepatch inconsistent for arrow button
!Nine-patch image
!Image after rendering
The problem with rendered images is that the left side triangle isn't smooth enough. There is a bit of jagged edge on the slopes. This was found in the draw9patch tool's preview too, but couldn't tackle it so far.
Any hint regarding solution will appreciated. | This happens because you specify too wide area for the height shrink/stretch. Put just one black pixel in the leftmost pixel column (it's tricky where to put it, actually. I'd put one pixel in the very top of your image and one more - in the very bottom). | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "android, android layout"
} |
Objective-C + Cpp rvalues and arrays
I need create array:
const UInt8 *pixels[3] = { yuvFrame.luma.bytes, yuvFrame.chromaB.bytes, yuvFrame.chromaR.bytes };
But Xcode show me error:
Cannot initialize an array element of type 'const UInt8 *' (aka 'const unsigned char *') with an rvalue of type 'const void *'
I am mixing C++ code with Objective-C. So how can I fix this? I need this const UInt8 *pixels[3]. Any suggestions? | Try the following initialization
const UInt8 *pixels[3] =
{
( const UInt8 * )yuvFrame.luma.bytes,
( const UInt8 * )yuvFrame.chromaB.bytes,
( const UInt8 * )yuvFrame.chromaR.bytes
};
In C++ there is no implicit conversion from a pointer of type `void *` to a pointer to an object of any other type. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++, ios, objective c, opengl es"
} |
Spritekit constraint zRotation
I have a node with SKAction infinite repeat a zRotation, and i need to rotate another node with the exact same zRotation at the same time. (I can't put those nodes in a same node container) I would like to use an SKConstraint but this kind of constraint do not exist Any idea ? | There is a method in SKScene that you can override called `didEvaluateActions` This is the moment in the update cycle that all actions have performed their tasks (but not necessarily completed).
Set the 2nd node's `zRotation` to the first nodes during this moment. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ios, sprite kit, rotation, skaction"
} |
C# Linq-to-sql server name when creating a release
I'm working on C# linq-to-sql application over SQL Server express 2008 . My database is inside SQL server.
I'm using Windows Authentication to connect to sql server from my application. The server name used in connection string is related to my pc user name, so I'm wondering if I create a release of my application and put it on client pc which have SQL Server installed with another server name, would my application work?
my connection string is
<add name="WindowsFormsApplication1.Properties.Settings.OPTICA_MDFConnectionString"
connectionString="Data Source=ENG-MEDIAN-PC;Initial Catalog=OPTICA.MDF;Integrated Security=True"
providerName="System.Data.SqlClient" /> | Because the app and the sql server are on the same host you can use `"Data Source=.\<instance name>"` which may be the default MSSQL.
That default would look like this:
connectionString="Data Source=.\MSSQL; ... "
For another example, our developer boxes' app.config uses this:
connectionString=".\DEVSQL;Initial Catalog=..."
Note that the "." is the host and that "DEVSQL" is the sql server instance name. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, sql server 2008, linq to sql"
} |
Google dictionary api does not return pure json?
I have the following code:
var json = new WebClient().DownloadString(string.Format(@" "bar"));
This returns something like this:
> dict_api.callbacks.id100({"query":"bar","sourceLanguage":"en","targetLanguage":"en","primaries":[{"type":"headword","terms":[{"type":"text","text":"bar",....
Why is it returning a function rather than just the json? Am I using web client incorrectly? | As I understand it, this is JSONP \- JSON which is "padded" with a function call to allow cross-domain data transfer. I strongly _suspect_ that if you pass in a different callback name on the URL, you'll see that other name come back in the response.
(Note that although I work for Google, this answer is not an "official" response from Google in any way, shape or form.) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "json, google api"
} |
Why is my CSS breaking?
I have been looking at my code for long time now and I still fail to see why this is breaking. Other pages in the same folder have the EXACT same code for the navbar however on this one it breaks.
www.orikina.com/HDD/dev/classes.php //This one is broken
www.orikina.com/HDD/dev/index.php //This one is not.
Thanks, Tim | see the html source line 23:
> `<li<a href="index.php">Home</a></li>` | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -4,
"tags": "css, html"
} |
Is Hyper-graph Isomorphism preserve the size of edges or Rank of Hyper-graph?
Informally, hypergraph is a generalization of a graph in which an edge can join any number of vertices.
A **hypergraph** $G=(V, E)$ is a two tuple, where $V$ is the set of vertices and $E$ is a set contain subsets of the vertex set of $V$. An example of hyper-graph is given below and for example edge $e_3$ is a subset contain $v_3,v_5,v_6$ and similarly for other edges.
$ and $H(V,E')$ are isomorphic if there is a permutation $g$ on $V$ such that, $\forall $ $e \in E$, $$e\in E \iff g(e) \in E'$$
**Question** : Is the hypergraph isomorphism preserve the size of edge (edge is a subset of vertex set here) i.e. an edge $e$ that contain say $l$ vertices will be mapped to edge $g(e)$ whose size is also $l$ or it is not required.
**Reference** : < | Whether it's expressly stated or not, it must be the case that hypergraph automorphisms send an edge containing $\ell$ points to another edge containing $\ell$ points.
This follows from the fact that $g: V \to V$ is a permutation (i.e., bijection). The very _definition_ of two sets having the same size is that there is a bijective map from one to the other. Here, $g$ restricted to any subset of $V$ (say, $E$) is a bijective map from $E$ to $g(E)$, hence $E$ and $g(E)$ contain the same number of vertices.
And hopefully this agrees with your intuition about isomorphisms; isomorphic objects should be "the same" in every essential way, and the number of vertices contained in a given edge seems pretty essential, when it comes to hypergraphs! | stackexchange-math | {
"answer_score": 4,
"question_score": 4,
"tags": "graph theory, graph isomorphism, hypergraphs"
} |
Защита аутентификации
К примеру есть любая соц. сеть, она же хранит залогиненых пользователей с помощью токена сессии? Т.е. где-то в локальном хранилище браузера храниться ключ, который отправляется на сервер, сервер смотрит в свою БД есть ли такая сессия, и в зави симости от наличия отправляет либо залогиненую html либо нет.
Но, разве это безопасно? Нужно всего лишь узнать этот ключ и можно на своем браузере зайти на чужую страницу, разве нет других, более безопасных решений?
Можно проверять ip, и другие штуки, но тот же youtube при смене ip не выкидывает, а загружает аккаунт (конечно при одной и той же сессии). | Я все свои деньги храню в кошельке. Но разве это безопасно? Ведь любой, кто возьмет мой кошелек сможет расплачиваться моими деньгами.
Итого, если вас беспокоит безопасность, у вас есть два варианта:
1. После завершения работы с сайтом нажимать Logout
2. Не давать работать посторонним людям под своей учеткой в ОС
Там, где это критично (например, личный кабинет в банке) сессия автоматически закрывается через 10-20 минут неактивности. | stackexchange-ru_stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "сессия, браузер, защита, аутентификация"
} |
Linux: aliases when using `screen`
I'm using `screen`, and I have several aliases in my `~/.bash_profile`, for example `python=python-2.6`. But for some reasons these aliases don't work when I work in `screen`. How can I make them work? | `.bash_profile` gets run when in a login shell. You'll probably want to put your aliases in the `.bashrc` file. Or you could just execute your `.bash_profile` each time that you start up a shell in `screen` | stackexchange-superuser | {
"answer_score": 4,
"question_score": 6,
"tags": "linux, gnu screen, alias"
} |
mysql_fetch_array/row only fetch 1 data
The problem is probably quite simple.
$q = "SELECT id FROM users
WHERE name LIKE '%$u%' OR active LIKE '%$u%'";
echo $q;
$u = mysql_query($q) or die("There is a server error : " . mysql_error());
$u = mysql_fetch_array($u);
print_r($u);
But it returns me
[id] => 6
When I execute the query in Mysql Workbench it returns
6
7
8
It's probably a fetching problem but I don't understand why. Thanks :) | `mysql_fetch_array()` only returns one row. To get more rows, you need a loop.
Also `mysql_fetch_array()` returns both a string association and a integral indexing. What you want to use is `mysql_fetch_assoc()` like so:
while ($data = mysql_fetch_assoc($u)) {
echo $data['id'];
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "php, mysql"
} |
Should I use a .NET Windows service for this issue?
I have a ASP.NET website in which a user makes a request. Every request kicks off a long process that may take several minutes (worst case of 20 mins). At the end of the request a file is created for the user to download.
Currently, I have this request kick off the process asynchronously (using Async pages) but I am getting time out errors. I suspect my approach is flawed. To make this process scalable, my next guess is to have a windows service that executes the long running process. When a user makes a request, I add the request details in a database table. The Win Service picks it up and processes it. In the meantime, the user is redirected to a page that asks them to wait while the file is being created.
Would this be the ideal approach? If so, do I have to refresh the page every x minutes to check if the windows service has completed the processing? | You can either use a Windows service or a background thread.
A Windows service has the advantage that you could potentially run more than one of them on remote machines ("compute servers").
Passing messages to a background thread can be done using in-memory queues. With a service, you should use a more formal message passing system, such as SQL Server's Service Broker. Service Broker also handles persistence and provides some clean mechanisms for scaling.
In case it helps, I cover Service Broker and background threads in my book, including code examples: Ultra-Fast ASP.NET. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": ".net, asp.net, windows services"
} |
BJT Constant Current Driver
I'm currently working on this circuit and I ran into 2 questions that I'm not sure I understood them correctly ( I have U1 = 15V , URE = 2 V , β = 180 , UCE = 5V and a constant current I = 2mA )
[0]}'%';
I thought it's s string so can I use split to get the separate values in the string.
This doesn't work. is there another way to do this. | Sure you can:
const PageLayout = styled.div`
flex-basis: ${(props) => props.twoCol.split(",")[0]}%;
`;
But a better option might be passing the values instead of manipulating a string:
<PageLayout twoCol={[60,40]}>
const PageLayout = styled.div`
flex-basis: ${(props) => props.twoCol[0]}%;
`;
The main problem with your snippet is that you need to write a real **CSS** inside the string literal:
// not '%' like ${(props) => props.someProp}'%'
flex-basis: ${(props) => props.someProp}%; | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "reactjs, styled components"
} |
How do I tell PHPUnit where my tests are located?
After spending several hours today searching and seeing several people having the same issue, I thought I turn to SO.
I run a WAMP stack; I have successfully installed PEAR and PHPUnit 3.6 using PEAR. I'm able to run phpunit over command line.
My WAMP folder is located at C:\wamp - I have several www folders - for sake of example let's say I have an MVC application located at C:\www\myproject.
/myproject
/application
/controllers
/models
/modules
/forum
/controllers
/models
/tests
/views
/views
/public_html
/tests
I'd like to know where PHPUnit is looking when I run something like
> phpunit ArrayTest
Any help greatly appreciated, Thanks | It is looking for your /tests in the current directory. Change (cd ..) to the directory containing your project and run phpunit. | stackexchange-stackoverflow | {
"answer_score": -2,
"question_score": 0,
"tags": "php, phpunit"
} |
USB 3.0 Ethernet dongle (AX18879) not working with 10.11.4
I have been using the StarTech USB 3.0 Gigabit Ethernet dongle which was working until I upgraded to the latest OSX Beta 10.11.4. Now it has stopped working--not even showing any indicator lights when plugged in.
I reinstalled the latest drivers on their site but still nothing. When I try to check kernel extensions with `kextstat` but didn't see the driver there. However, when I check extensions in the system profiler, and i see this
 {
ConnectivityManager connectivityManager
= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
and if it returns false I make a toast to the user saying that there's no internet;
but when the internet is poor the app gets an error or it just blocks and gets a black screen for 30sec and then show the error... so what can I do to fix this how can I see if internet is poor and avoid this... | You can make the timeouts shorter than 30000 milliseconds to give up earlier. But there really isn't a way to make a poorly working connection work correctly. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "android"
} |
What is wrong with my integration? Finding expected value. Statistics
I am aware that I could have equally used the Beta distribution but I just wanted to check where in my solution did it go wrong.
I wanted to solve $I=\int_{0}^{1}x^r(1-x)^{n-r}dx$ where $n$ and $r$ are both integers. I shall proceed this with integration by parts.
**My thoughts**
Let $\frac{dv}{dx}=1$ and $u=x^r(1-x)^{n-r}$. We shall have that $\frac{du}{dx}=rx^{r-1}(1-x)^{n-r}-(n-r)x^r(1-x)^{n-r-1}$ and $v=x$.
So we have $I=\int_{0}^{1}x^r(1-x)^{n-r}dx$=$-\int_{0}^{1}rx^{r}(1-x)^{n-r}-(n-r)x^{r+1}(1-x)^{n-r-1}dx=-rI+\int_{0}^{1}(n-r)x^{r+1}(1-x)^{n-r-1}dx$.
I noticed that $\int_{0}^{1}x^{r+1}(1-x)^{n-r-1}dx=I$ if we do a transformation by $m=r+1$, say. Hence I deduced, $I=-rI+(n-r)I$. Then I am stuck at this point, I couldn't find the value of $I$. | More precisely, if we write $I_{n,\,r}=\int_0^1x^r(1-x)^{n-r}dx$ you've shown $I_{n,\,r+1}=\frac{r+1}{n-r}I_{n,\,r}$. Using $I_{n,\,0}=\int_0^1(1-x)^ndx=\frac{1}{n+1}$, you should be able to induct on $r$ to prove $I_{n,\,r}=\frac{r!(n-r)!}{(n+1)!}$ for $r\le n$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "calculus, integration"
} |
Error in Sqlite : sqlite3_prepare_v2 failure: near \\\"UNION\\\" : syntax error\},\"code : 5} in IONIC 2
I am using sqlite in IONIC 2 to fetch data from chat table but it keeps giving me error at UNION. Here is my query:
SELECT a.id, a.timeDate, a.message, fromUser, toUser FROM ((SELECT id, message, fromUser, toUser, toUser AS uid, timeDate FROM chat WHERE fromUser = ?) UNION (SELECT id, message, fromUser, toUser, fromUser AS uid, timeDate FROM chat WHERE toUser = ? )) AS a GROUP BY a.uid ORDER BY a.id DESC , a.uid DESC
I tried with brackets before UNION and without bracket like (query1) UNION (query2) and (query1 UNION query2) but still that’ not working.
This query is working fine in mysql with same structured table.
How to solve this problem? | Subqueries use parentheses, but a compound query is not made up from subqueries, so it _must not_ use parentheses.
In your query, only the subquery in the FROM clause uses parentheses:
SELECT ... FROM (SELECT ... UNION SELECT ...) AS a GROUP BY ... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "mysql, sqlite, ionic framework, ionic2"
} |
Rails: rake db:structure:load times out on CircleCI 2.0
Currently, `rake db:schema:load` is run to setup the database on CircleCI. In migrating from using `schema.rb` to `structure.sql`, the command has been updated to: `rake db:structure:load`.
Unfortunately, it appears to hang and does not return:
$ bin/rake db:structure:load --trace
** Invoke db:structure:load (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:structure:load
WARNING: terminal is not fully functional
set_config
------------
(1 row)
(END)rake aborted!
Interrupt:
<STACK TRACE>
bin/rake:9:in `<main>'
Tasks: TOP => db:structure:load
Too long with no output (exceeded 10m0s)
Found someone else with the same issue on CircleCI, no answers though. | This seems to have something to do with the `psql` client's output to the terminal expecting user input:
set_config
------------
(1 row)
(END) <--- like from a terminal pager
Not exactly a proper solution, but a workaround in `.circleci/config.yml`:
jobs:
build:
docker:
- image: MY_APP_IMAGE
environment:
PAGER: cat # prevent psql commands using less | stackexchange-stackoverflow | {
"answer_score": 26,
"question_score": 18,
"tags": "ruby on rails, database, postgresql, circleci, circleci 2.0"
} |
Algolia Remove _highlightResult from search results
In the response from a `search` call, I get back a `hits` array and each item in the array includes a `_highlightResult` property. Is there any way to prevent that property from being returned in the search results? | There's an option `attributesToHighlight`.
You can use it as an index setting or specify it per search request in the params. By default, all searchable attributes will be highlighted, but if you explicitly set it to an empty array `attributesToHighlight: []`, none will be highlighted.
Please see < | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 5,
"tags": "node.js, search, algolia"
} |
Is MySQL Query framed properly?
I'm attempting to run the following Query on an AWS ec2 xlarge instance:
mysql> CREATE TABLE 3 SELECT * FROM TABLE 2 WHERE ID IN (SELECT ID FROM TABLE1);
I attempted using ec2 as I thought perhaps it was my laptop making the query taking long as Table1 has 14000 rows and 6 columns and table 2 has around 1 million rows and 11 columns. However I get:
Write failed: Broken pipe
When using the aws instance, and DBMS timeout on my laptop.
Should the Query be taking > than these timeout triggers? Anyway to word the query better? | MySQL is very poor at executing `WHERE table1.id IN (SELECT table2.id ...)`. It's better to use a `JOIN`.
CREATE TABLE Table3
SELECT t2.*
FROM Table2 AS t2
JOIN Table1 AS t1 ON t1.id = t2.id | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "mysql, ubuntu, amazon ec2"
} |
Where are my custom Photoshop CS4 actions on Snow Leopard?
I upgraded my HDD and I'm trying to import from the old one my custom user-generated actions (and some imported) which I had in Photoshop CS4. Which I can't find.
I have looked in
/Applications/Adobe Photoshop CS4/Presets/Actions
/Library/Application Support/Adobe/Adobe Photoshop CS4
~/Library/Application Support/Adobe/Adobe Photoshop CS4/Presets/Actions
And there's no `~/Library/Preferences/` | User generated actions don't get saved anywhere where you can physically grab a file and import into photoshop. It's an embedded setting. Although, you can export your actions from the actions palette and save it to a file which you can then import into the new hard drive. (Same with custom made shapes) | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "macos, osx snow leopard, adobe photoshop, photoshop cs4"
} |
Mapping Wikidata QID to Wikipedia CurID
Two questions:
1. How can I map `QID` from Wikidata to English Wikipedia `CurID` using dumps?
2. Which dump to use?
I am not looking for an API based solution, as I want to generate this mapping for all wikipedia entities. | Probably the easiest way is to fetch the page_props table from the database dumps and look for the `wikibase_item` property. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "wikipedia, wikidata, linked data"
} |
Looping over items from a list Emacs
Let's say we have a list like the following:
`("These" "Are "Some" "Words")`, let us call it `listy`
How to call a function on each of those items of the list?
Perhaps call a function like:
(defun messager (somelist)
(interactive)
(message somelist)
)
Running the function:
`(messager listy)`
I would expect in the buffer to see seperate lines for each item of the list.
The part that is not working though, is to loop or something over the items from the list. | Use
(mapc 'messager listy)
or
(dolist (item listy)
(messager item)) | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "list, function, emacs"
} |
iOS dismiss all keyboard and modal controls
I am making a network based application and I've stumbled across a little dilema. My app connects to the server and the application uses the keyboard and displays a modal view when certain buttons are pressed. This is all fine and working as I want it to. My issue is when the server loses connection whether for maintenance or we lose connection the app goes back to the login screen, but the keyboard or modal views don't get dismissed. Do I have to keep track of these to dismiss them or is there some global command that I could send to dismiss everything.
Thanks in advance for the help | There are at least a couple of different ways to dismiss the keyboard: One of these should work:
[myEditField resignFirstResponder];
[myEditField endEditing];
[parentView endEditing];
There is no "global" way to dismiss all open modal views. You will need to specifically dismiss any modal views you've opened using:
[self dismissModalViewControllerAnimated:YES];
// This can be called either from within the modal view or its parent: | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "ios, modalviewcontroller, uikeyboard"
} |
Error "emails":"Please enter an array" when making a request to MailChimp API V2.0
I have been trying to make a request to the V2 MailChimp API.
When I uses the following method :
def get_subscriber_info(self, list_id, email):
url = "
headers = {'content-type': 'application/json; charset=UTF-8'}
payload = {"apikey": "XXXXXXXXXXXXX9999XXX98X886544",
"id": "4hstitfbaa",
"emails":[{'email':"[email protected]"}]
}
r = requests.get(url, params=payload,
, headers=headers)
return r.json()
I get this error: "emails":"Please enter an array"
However if I change the emails key to "emails[]" I get this error: "email" should be a struct.
I have read the documentation and am pretty sure I am formatting the params payload as it should be formatted. What am I doing wrong? | I would use `POST` request and send `payload` in JSON format:
r = requests.post(url, data=json.dumps(payload), headers=headers) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, mailchimp, mandrill"
} |
How to cut out a polygon shaped part of an image?
I have a polygon with the following vertices...
20,20
20,30
40,30
and an image. I want to cut the polygon shaped part out of the image to form a new one. Is there any algorithm to do so? I am using Processing if that's anything helpful.
Thanks in advance. | You could create a new image and paint the old one on with the clip set.
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.getGraphics();
Path2D path = new Path2D.Double();
path.moveTo(20, 20);
path.lineTo(20, 30);
path.lineTo(40, 30);
path.closePath();
g.setClip(path);
g.drawImage(YourOrigioanlImage, 0, 0, null);
It looks like in "Processing" you can create a `PImage` from an `java.awt.Image` so you can get your `PImage` by using the code sample above then doing this:
PImage pImage = new PImage(image);
You can also get a `BufferedImage` object from a `PImage` by casting the `getNative()` method from `PImage` | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 4,
"tags": "java, image, processing"
} |
Hook DirectX to make objects in scene transpanent
I am good at C# programming and I want to know if is possible to make objects from **another** DirectX program about fifty persents tranpanent, so I can see behind them? I will be happy if you provide some working example or link to some tutorial to take me to the right direction.
 or EndScene (dx9). IT depends on how the objects are drawn in each application. You can also check Direct3DHook on GitHub: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "c#, directx, hook"
} |
Stretch side of half cylinder
I am trying to pull the curved side of a half cylinder, so instead of doing this,  | 1 - You can choose 3D cursor as pivot point and select everything and do s+z to scale on Z axis.
 _та всегда знает, что делать._
Какой знак уместнее поставить? | При **именительном темы** , тесно связанном с основным предложением, в котором имеется личное или указательное местоимение в качестве слова-отсылки, ставится тире:
> Тягач – он как танк, только без башни (газ.); Марченко – тот был человек, золотой человек (Каз.); Дорога в дождь – она не сладость, дорога в дождь – она беда (Евт.).
_**Маша — та всегда знает, что делать.**_
> Примечание. _Допустимо используемое в практике печати и написание с запятой: Врач, он ведь тоже не Бог (Бык.); Судьбы человеческие, они – каждая сама по себе, хотя мы вроде бы сообща и всё у нас должно быть общим (Аст.); Наташа, та знала, что за человек ее тетя (Бит.)._ | stackexchange-rus | {
"answer_score": 3,
"question_score": 1,
"tags": "пунктуация, запятые, тире"
} |
Where to specify version number in ASP.NET Web Site
So I have an ASP.NET 'Web Site' (as opposed to a Web Application) which has no AssemblyInfo.cs file or Bin folder or anything like that.
I want to have a way to specify an Assembly version number (e.g. 7.0.2.0). In a Web Application you would do this in an AssemblyInfo.cs file.
I've tried adding a Properties folder with an AssemblyInfo.cs file but I don't think its being picked up - because when I call Assembly.GetExecutingAssembly().GetName().Version.ToString() I get 0.0.0.0
So: What do I have to do to get AssemblyInfo.cs working OR how can I specify a version number? | K Scott Allen has a post here, but personally i'd recommend you move to a Web Application Project. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 6,
"tags": "asp.net, version, assemblyinfo"
} |
Link error on compiling ghc 7.10.3 on SLES11
I want to compile ghc 7.10.3 on a SLES11 instance since the downloaded binary doesn't work. Now I am getting link errors in the end:
/home/oswald/build/ghc-7.10.3/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.4.0.0-8TmvWUcS1U1IKHT0levwg3-ghc7.10.3.so: undefined reference to `__sync_val_compare_and_swap_2'
/home/oswald/build/ghc-7.10.3/libraries/ghc-prim/dist-install/build/libHSghc-prim-0.4.0.0-8TmvWUcS1U1IKHT0levwg3-ghc7.10.3.so: undefined reference to `__sync_fetch_and_nand_2'
with a lot lines more. These seem to be GCC primitives. The installed gcc version on this machine is 4.3.4, which has primitives, but I did not find the _2 and _1 endings in the documentation (it uses variable arguments list as I understand it).
Any idea on how to solve this? | Ok, so I did install a newer gcc (4.9.3) locally and then the compilation of ghc was successful. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "haskell, gcc, linker, ghc"
} |
change column value based on multiple conditions
I've seen a lot of posts similar but none seem to answer this question:
I have a data frame with multiple columns. Lets say A, B and C
I want to change column A's value based on conditions on A, B and C
I've got this so far but not working.
df=df.loc[(df['A']=='Harry')
& (df['B']=='George')
& (df['C']>'2019'),'A']=='Matt'
So if A is equal to Harry, and B is equal to George and C is greater than 2019, then change A to Matt
Anyone see what I've done wrong? | You are really close, assign value `Matt` to filtered `A` by boolean masks:
df.loc[(df['A']=='Harry') & (df['B']=='George') & (df['C']>'2019'),'A'] = 'Matt' | stackexchange-stackoverflow | {
"answer_score": 14,
"question_score": 9,
"tags": "pandas"
} |
Scan a matrix and find the maximum value in Matlab between 2 ranges
I have a matrix in the form of a text file, I was hoping to scan it using MATLAB, and scan for the maximum value in between 2 points (1.5 and 2) and use that as a threshold.
I wrote a code but it rerturned an error.
[filename, pathname] = uigetfile('*txt', 'Pick text file');
data = dlmread(fullfile(pathname, filename));
t=data(:,1);
N = size(t,1);
m= max(data(1.5,2));
figure;
threshold = m;
Error in file (line 214) m= max(data(1.5,2)); | `data(1.5,2)` does not ask for elements of `data` with values between `1.5` and `2`; it asks for the element of `data` on the "1.5th" row and 2nd column, which is clearly undefined. Indices have to be integers.
The elements of `data` with values between `1.5` and `2` can be obtained with
data(data > 1.5 & data < 2)
so you can get the largest of these using
m = max(data(data > 1.5 & data < 2)); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "matlab, matrix, range, minimum, threshold"
} |
Vala - Print generic value
I am trying to create a generic class that is able to print out it's values.
class Point<T>
{
public T x {get; set; default = 0;}
public T y {get; set; default = 0;}
public void print()
{
stdout.puts(@"x: $x, y: $y\n");
}
}
int main(string[] args)
{
var point = new Point<int>();
point.x = 12;
point.y = 33;
point.print();
return 0;
}
The compiler gives me these errors:
main.vala:8.21-8.22: error: The name `to_string' does not exist in the context of `T'
stdout.puts(@"x: $x, y: $y\n");
^^
main.vala:8.28-8.29: error: The name `to_string' does not exist in the context of `T'
stdout.puts(@"x: $x, y: $y\n");
^^
Is there a way to work this out? | Not directly. You'll need to pass in a delegate to print your item:
delegate string Stringify<T>(T item);
class Point<T>
{
public T x {get; set; default = 0;}
public T y {get; set; default = 0;}
public void print(Stringify<T> stringifier)
{
stdout.puts(@"x: $(stringifier(x)), y: $(stringifier(y))\n");
}
}
int main(string[] args)
{
var point = new Point<int>();
point.x = 12;
point.y = 33;
point.print(int.to_string);
return 0;
}
Alternatively, you can build a set of special cases as Gee does: < | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 3,
"tags": "generics, vala"
} |
How do I set Cheetah 'useAutocalling' off?
I have tryed multiple ways to try and turn this off including
#compiler-settings
useAutocalling=False
#end compiler-settings
#compiler-settings
useAutocalling=0
#end compiler-settings
but I cannot get cheetah to turn it off. The reason I need to turn it off is because of a bug where google app engine's db.model has 'has_key' and it pisses off cheetah. I found the part in the documents about turning it off but no documentation on how to actually do it. | #compiler-settings
useAutocalling=False
useNameMapper=False
#end compiler-settings
thought to look though the source and find what it wanted and turns out i needed useNameMapper also turned off. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "google app engine, cheetah"
} |
Measure Volatility or Stability Of Lists of Floating Point Numbers
Wonder if anyone can help.
I have a set of lists of numbers, around 300 lists in the set, each list of around 200 numbers. What I wish to calculate is the "relative stability" of each list.
For example:
List A: 100,101,103,99,98 - the range is v small - so stable.
List B: 0.3, 0.1, -0.2, 0.1 - again, v small range, so stable.
List C: 0.00003, 0.00002, 0.00007, 0.00008 - stable.
Now, I could use standard deviation - but the values returned by the standard deviation will be relative to the values within each list. So std for list C would be tiny in comparison to std for list A - and therefore numerically not give me a comparable measure of stability/volatility enabling me to meaningfully ask: if list A more or less stable than list C?
So, I wondered if anyone had any suggestions for a measure that will be comparable across such lists?
Many thanks for any help. R | You could use the standard deviation of the list divided by the mean of the list.
Those measures have the same units so their quotient will be a pure number, without a unit. This scales the variability (standard deviation) to the size of the numbers (mean).
The main difficulty with this is for lists that have both positive and negative numbers, like your List B. The mean could end up being an order of magnitude less that the numbers, exaggerating the stability measure. Worse, the mean could end up being zero, making the measure undefined. I cannot think of any correction that would work well in all cases. The "stability" of a list with both positive and negative numbers is very doubtful and would depend on the context, so I doubt that any general stability measure would work well in all such cases. You would need a variety for different situations. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python, math, statistics, volatility"
} |
How can I return an array from view asp.net-mvc-3
I have view model:
Customer
{
public string Name { get; set; }
...
public IEnumerable<string> Emails { get; set; }
}
I've post it in the view:
...
@foreach (var Emails in Model.Emails)
{
@Html.EditorFor(modelItem => Emails)
}
...
How can I return to controller an array of this Emails?
When I return data from form to controller in this moment, property "Customer.Emails" equals null, but it should contain an array of e-mails. | The `EditorFor()` call is incorrect.
You should remove the `foreach` and do
...
@Html.EditorFor(modelItem => modelItem.Emails)
... | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "c#, asp.net mvc 3"
} |
Slow query for MySQL using "IN"
For a large table (1 million records) I have an update query like this:
update direct_words set weight = (weight / 4) where knowledge_id = :a
and phrase_id in (select phrase_id from phrases where knowledge_id =:b
and phrase_class <> 6);
I have several indexes, but one is for the fields:
knowledge_id;phrase_id
This runs very fast under SQLite (2 seconds or less), but for MySQL the same query takes about 37 seconds. What am I doing wrong? | try execututing it using `JOIN`
update direct_words a
INNER JOIN phrases b
ON a.phrase_id = b.phrase_id
set a.weight = (a.weight / 4)
where a.knowledge_id = :a AND
b.knowledge_id = :b AND
b.phrase_class <> 6 | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 1,
"tags": "mysql, sql, database, join"
} |
How can I craft the Golden Wrench?
Soon Valve is announcing the **Engineer Update**. There is a lot of hype about **"The Golden Wrench"** , an item that can be crafted and used by the engineer class.
What I did not understand is which item should I craft in order to have the possibility to find it. Could be any item? Or only melee items? Or only token class? | You can no longer craft the Golden Wrench (or rather, receive while crafting other things), and the 100 people that won it and another who bid on it are the only ones who ever will as it is not tradable.
From the original 100 & 1, at least 19 have been destroyed, 14 of which net $31,000 for Child's Play, another raised $530 for the same charity, and one more provided 10,200 TWD (~$344) for a 2011 Sendai earthquake & tsunami charity. Why people donated so much money to have someone destroy a virtual item is beyond me, but I'm not going to argue with results. | stackexchange-gaming | {
"answer_score": 17,
"question_score": 10,
"tags": "team fortress 2, tf2 engineer"
} |
Finite projective planes
How big a set of points in **general position** (i.e., no three collinear) can be found in a finite projective plane of order $n$?
I hope the answers won't be too technical, as I know almost nothing about projective planes besides the definition.
**Motivation:** I want to use this for an example in graph theory.
**My work:** If $S$ is a set of points in general position, then $|S|\le n+2$, since $S$ has at most a point $p$ and another point on each of the $n+1$ lines through $p$. So $n+2$ is an upper bound. For a lower bound, let $S$ be any **maximal** set of points in general position and note that $\binom{|S|-1}2\ge n$, whence $|S|\ge\frac{3+\sqrt{1+8n}}2$. | An _arc_ is a set of points, no three collinear. An arc is _complete_ if it is maximal with respect to set inclusion. So you are asking for the maximum size of a complete arc.
According to this paper, this appears to be a hard problem in general, although if $n$ is even, then your upper bound is attained, and if $n$ is odd, then it can be improved to $n+1$.
I was hoping to track down a proof for the $n$ even case (due to Segre) but it appears to be a bit too obscure. Hopefully you have better luck. Actually it's not clear to me if he "only" proved it for $n=2^k$. | stackexchange-math | {
"answer_score": 1,
"question_score": 3,
"tags": "combinatorics, combinatorial geometry, finite geometry"
} |
What does the "-s" in a Perl if block do?
I have a block of code as such:
if ( ! -s $fh ) {
...more code
}
I just need to know what the "-s" means! | `-s $fh` checks file size of `$fh`, so `! -s $fh` tests if file size has length zero (or there is no such file).
`$fh` can be file name, or file handle (check perldoc -f -X).
Note that this is not the same as `-z $fh`, as it won't return true for non existing files. | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 3,
"tags": "perl"
} |
Allure report collapses tests with null and JSONObject.NULL parameters
If two set of parameters in @DataProvider differs only with null & JSONObject.NULL param - allure report will collapse 2 tests in 1. Can it be handled by settings somehow? | The problem is that your parameters have the same `toString()` value. As workaround you can create a parameter wrapper, that will name your params differently. Or you can use separate parameter for that. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "allure"
} |
Inherit build plugin/extension/... in Maven
Say a Maven project has a cool build plugin configured:
<project>
...
<build>
... extensions etc.
</build>
...
</project>
I want this configuration to be reusable, so that I can run the goals provided by the plugins/extensions in any new project. The above project might exist just so that other projects can reuse the config.
What is the best way to achieve this? | Use a `parent.pom`. Deploy this `pom` to your local repository. Of course you could configure `parent.pom`s for each type of project that you regularly develop in your organisation. Probably a `master.pom` with general values (location of servers, organisation name, general code style...) is a good idea. The project specific `pom`s would use this as parent. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "maven, build tools, maven extension"
} |
MarkLogic Journal Size Parameter
I have a question about "Journal Size" parameter in MarkLogic. The default setting is 2GB, is this means Journal directory inside Forests directory will never exceed 2GB? (I could not find max journal size or number or journals parameters) | It is the max size of a single journal file inside the `Journals` directory. Each in-memory stand comes with its own journal file to replay what was written to the in-memory stand in case of mishap. It therefor limits how much you can update in a single transaction. If you run out of journal space (e.g. exceed the max size for the active journal file), the transaction will fail.
Journal files should be cleaned up once in-memory stands are written to disk successfully. Normally, there is only one in-memory stand within each forest.
HTH! | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "marklogic"
} |
Definition of TextAppearance.MaterialComponents.Body2?
I am currently digging through the code of the Google IO 2019 android app. In the styles.xml line 77 it says:
<style name="TextAppearance.IOSched.Body2" parent="TextAppearance.MaterialComponents.Body2" />
But where can I find the definition of the parent `TextAppearance.MaterialComponents.Body2`? I already have the IO project locally in my Android Studio, in case that helps to resolve what is behind that definition.
Thanks! | It is defined in the Material Components library.
Currently it is:
<style name="TextAppearance.MaterialComponents.Body2" parent="TextAppearance.AppCompat.Body1">
<item name="fontFamily">sans-serif</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
<item name="android:textSize">14sp</item>
<item name="android:letterSpacing">0.0178571429</item>
</style>
You can find here the latest implementation. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "android, material design, android appcompat, material components android, material components"
} |
How to place a menu link in views footer?
I have created a page that displays the latest news. On the right side of the page using context module i have placed a "Recent news" block (Created using views). The recent news block shows 4 recently created news. I have added a "link" field in each item to show "Read more" on the block.
I have created another page using views which displays the complete news created so far. I call this as news archive. My problem is i have to create a "To news archive" menu in the "Recent block" last line.
!enter image description here | You have created a view for recent news. Just add a footer to the view and then implement php **l()** function for your menu in the global text area of the footer. | stackexchange-drupal | {
"answer_score": 2,
"question_score": 1,
"tags": "views, 7"
} |
Integrating Legendre polynomials
I need to solve following integral: $I_{n}=\int_{-1}^{1}\frac{1}{x}P_{n}(x)P_{n-1}(x)dx$. I have hint that following equation needs to be used: $(n+1)I_{n+1}+nI_{n}=2$. Does anyone have idea how to proceed? | First of all, it is easy to see that $I_1 = 2$. Then, after proving the given recurrence relation, you can see that: $I_2 =0$, $I_3=\frac{2}{3}$, $I_4=0$, $I_5=\frac{2}{5}$, ... It is clear that you have ($n \geq 1$): $$I_{2n} =0$$ and $$I_{2n-1} = \frac{2}{2n-1}$$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "legendre polynomials"
} |
How do I make Android consider my WiFi Access Point as valid (blue?)
We have a very large wifi network at Stack Exchange, and the primary guest network is tightly locked down. Our firewall rules permit essentially just http/https and vpn connections. When our Android phones connect to the wifi, they show good coverage but the WiFi icon never turns from grey to blue.
What is the Android phone checking to make the grey/blue wifi icon decision in JB 4.2.2? | After probing the firewall logs, it appears that the grey/blue icon is triggered depending on whether or not your device has access to Google Play. In our case, I had to open tcp-udp port 5228 (as per and after turning wifi off and back on again, the icon became blue.
I can't confirm whether http/https is also part of the equation; we already had that open so it's possible if one is running into this issue even after opening tcp-udp 5228, that http/https may also be required. | stackexchange-android | {
"answer_score": 11,
"question_score": 10,
"tags": "wi fi, 4.2 jelly bean, troubleshooting"
} |
Laravel5 でviewにデータを受け渡す時にエラーが出る
`Property [id] does not exist on this collection instance.`
view
@section('content')
@foreach($data as $row)
<tr>
<td>{{ $row->id }}</td>
<td>{{ $row->title }}</td>
</tr>
@endforeach
@endsection
controller
public function index()
{
$data['posts']=DB::table('posts')->get();
var_dump($data);
return View('post/index',['data' => $data]);
} | $data['posts']
foreach$data$data['posts']
$row=$data['posts']Collection)id
$data=DB::table('posts')->get();
@foreach($data['posts'] as $row) | stackexchange-ja_stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "laravel"
} |
independent chi squares mean independent non central chi square?
Let $Y$ be a multivariate normal random vector with covariance $\Sigma$. Let $A_0,A_1$ be matrices such that $$A_0\Sigma A_1=0.$$ It is known that in this case $Y'A_0Y$ and $Y'A_1Y$ are independent quadratic forms. For a real vector $C$, is it true that the quadratic forms $$(Y+c)'A_0 (Y+c) \quad \text{and}\quad Y'A_1Y$$ are independent?
I have tried to work with the characteristic functions of these quadratic forms but cannot go further than the statement "product of the char. functions is the char. function of the product".
**Edit** : **If we view the first two quadratic forms as independent variables $f(Y),g(Y)$ where $f,g:\mathbb{R}^d \rightarrow \mathbb{R}$ are functions. Then the question becomes: does it follow that $f(Y+c)$ and $g(Y)$ are independent where $c \in \mathbb{R}^d$ ?** | Proof: Let $B$, $C$ be matrices such that $B'B=A_0$ and $C'C=A_1$, $BB'=I_{rank(A_0)}$ and $CC'=I_{rank(A_1)}$ (it is called Takagi factorization).Then it suffices to show that $BY$ and $CY$ are independent random vectors. They are MVN, hence $Cov(BY,CY)=0$ would mean they are independent. Well $$Cov(BY,CY)=B\Sigma C'.$$ We also have $B'B\Sigma C'C=0 \Rightarrow B\Sigma C'=0$ by multiplying left with $B$ and right with $C'$, which means that $Cov(BY,CY)=0.$ | stackexchange-math | {
"answer_score": 0,
"question_score": 1,
"tags": "integration, probability distributions, quadratic forms"
} |
Proof that $CE=2AD$
I already have a proof, but if you can please give another:
> Let $ABC$ be an isosceles triangle with $AB=AC$ and point $D$ be on segment $AB$. The line perpendicular to $AB$ which passes $D$ intersects $BC$ (extended) and $AC$ at $E$ and $F$ respectively. $C$ is on segment $BE$, between $B$ and $E$. If the area of $CEF$ is twice that of $ADF$, prove that $CE=2AD$.
My proof involves the Pythagorean theorem and the similar triangles property.![image]( | $\dfrac{CF}{FA}\cdot\dfrac{EF}{FD} = 2$ and $\dfrac{DF}{FE}\cdot \dfrac{EC}{CB}\cdot \dfrac{BA}{AD} = 1.$ This implies that $\dfrac{CE}{AD} = 2\dfrac{BC}{BA}\cdot\dfrac{AF}{FC}$. But $\dfrac{AF}{FC} = \dfrac{AD}{DB}\cdot \dfrac{BE}{CE} = \dfrac{BE}{BD}\cdot\dfrac{AD}{CE} = \dfrac{2AB}{BC}\cdot \dfrac{AD}{CE}$. Multiply these two to get $\dfrac{CE}{AD} = 2\cdot 2\dfrac{AD}{CE}$ or $\dfrac{CE}{AD} = 2.$
Here, the only tricky part was $\dfrac{BE}{BD} = 2\dfrac{AB}{BC}$, which follows from the fact that $\angle BAC = 2\angle BED.$ | stackexchange-math | {
"answer_score": 2,
"question_score": 2,
"tags": "geometry, alternative proof"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.