INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Error bar in python:ErrorbarContainer object of 3 artists
I am trying to make an error plot but I get the error:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3])
y = np.array([17706973.57161736, 4605821.60887734, 2179197.59021156])
nor = np.array([1.21377113, 0.31571817, 0.14937884])
plt.errorbar(x, y, yerr = nor)
ErrorbarContainer object of 3 artists and the plot does not contain error bars. Any idea? | What are you getting is not an error, it is the output of `plt.errorbar`. The reason you do not see the bars is because the scale of the error is way smaller than the scale of the data you are plotting. In fact, if you make the errors larger you will see them:
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3])
y = np.array([17706973.57161736, 4605821.60887734, 2179197.59021156])
# Larger error.
nor = np.array([1.21377113 * 5000000, 0.31571817 * 5000000, 0.14937884 * 5000000])
plt.errorbar(x, y, yerr = nor)
 bearing?
I wonder if there exist a formal guideline to help engineers choosing the right type of bearing.
Except in some few cases, this is not very evident to me. As far as i know, the plain bearing systems are really simple, so why bothering to design the rolling element bearings? I guess there is a reason, but i don't see it.
I've done some research on the web, besides the economic factors and some other vague statements i couldn't find anything useful. | rolling element bearings produce less friction, last longer, can position a rotating shaft with greater accuracy, and do not require pressurized lubrication in order to carry large loads.
sliding contact bearings are cheap, easy to install, and are adequate for light loads without pressure lubrication, and are fine for cost-sensitive applications. | stackexchange-engineering | {
"answer_score": 4,
"question_score": 2,
"tags": "mechanical engineering, bearings"
} |
How can I eliminate nested require when combining two js files
I`m trying to combine javascript files, I tried uglifyjs and it works but I want to eliminate duplicate require for the same npm library. Use case: I have file1.js and file2.js. Both files are using for example request npm module, and when I combine these two files into one, it duplicates the require('request'). Is there an option or something I can eliminate this issue?
Thanks. | One way to do that is to pass the module as parameter to another file. For example:
file1.js
var request = require('request');
var file2 = require('./file2')(request);
module.exports = {...};
file2.js
module.exports = function(request) {
// use "request" parameter, instead of requiring.
return {...};
};
Update:
import * as file2 from './file2';
const file2Module = file2(request); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, node.js, gulp, uglifyjs"
} |
What's the difference between lock_time and unlock_time in pam_tally2?
I realize that pam_tally2 is deprecated in favor of pam_faillock, but I have to use it anyway. What I don't get is the difference between these two options. They sound identical to me:
lock_time=n
Always deny for n seconds after failed attempt.
unlock_time=n
Allow access after n seconds after failed attempt. If
this option is used the user will be locked out for the
specified amount of time after he exceeded his maximum
allowed attempts. Otherwise the account is locked until
the lock is removed by a manual intervention of the
system administrator. | It would be clearer it `lock_time`'s description said "after _each_ failed attempt." `lock_time` blocks further login attempts for _n_ seconds once you fail a login attempt. `unlock_time` blocks login attempts for _n_ seconds after the maximum allowed failed login attempts (specified using `deny=n`).
You can check the source code to see that `unlock_time` is only used in the block for checking `deny`, and `lock_time` is used for each tally check. | stackexchange-unix | {
"answer_score": 0,
"question_score": 0,
"tags": "linux, pam"
} |
Which is correct — "avoid fight" or "avoid fighting"?
> * To avoid **fighting** among children, we should give them equal number of chocolates.
> * To avoid **fight** among children, we should give them equal number of chocolates.
>
Which one of the above statements is grammatical, and why? | The non-count-noun categorial polyseme ('incarnation' / usage) of **fight** does exist:
> fight [6] [UNCOUNTABLE] energy and determination to continue trying to achieve something:
>
> After her husband died there was very little fight left in her. [Macmillan]
and arguably in the fixed expression:
> the fight-or-flight response
but the gerund is the only choice that almost all native speakers would make in
'To avoid **fighting** among the children, we should give them an equal number of chocolates'. | stackexchange-ell | {
"answer_score": 1,
"question_score": 1,
"tags": "grammaticality, nouns, gerunds"
} |
What's the best "insert all images" plugin?
I've tried several plugins that supposedly allow you to "insert all images" after using the flash based uploader to upload multiple images.
However, I still haven't found one that ties in well with the latest version of wordpress in a non-hacky way. Which plugins the most for inserting multiple images?
image | < | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 2,
"tags": "images, media, uploads, customization"
} |
Extract Erlang tuples in list
I got the tuples in the list:
Contents = [{john, [jill,joe,bob]},
{jill, [bob,joe,bob]},
{sue, [jill,jill,jill,bob,jill]},
{bob, [john]},
{joe, [sue]}],
The print I want to get is:
john: [jill,joe,bob]
jill: [bob,joe,bob]
sue: [jill,jill,jill,bob,jill]
bob: [john]
joe: [sue] | You can try use `lists:foreach/2` or can try implement your own function for iteration and print out lists items:
1> Contents = [{john, [jill,joe,bob]},
{jill, [bob,joe,bob]},
{sue, [jill,jill,jill,bob,jill]},
{bob, [john]},
{joe, [sue]}].
2> lists:foreach(fun({K, V}) ->
io:format("~p : ~p~n", [K, V])
end, Contents).
Custom function:
% call: print_content(Contents).
print_content([]) ->
ok;
print_content([{K, V}|T]) ->
io:format("~p : ~p~n", [K, V]),
print_content(T).
Lists generators:
1> [io:format("~p : ~p~n", [K, V]) || {K, V} <- Contents]. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "list, erlang, tuples"
} |
Where is the welcome page set in a Maven webapp archetype project
I created a Maven project with webapp archetype. There is just an index.jsp file in /src/main/webapp folder. The web.xml file doesn't mention any welcome file. No other mention or any setting elsewhere. On running the application, the index.jsp page is shown. Where is this page being set as welcome page? | Quoted from <
By default server looks for the welcome file in following order:
1) welcome-file-list in web.xml
2) index.html
3) index.htm
4) index.jsp
If none of these files are found, server renders 404 error. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 0,
"tags": "java, maven, jsp, web.xml, maven archetype"
} |
How to generate form back from JSON Schema in form builder
I am using Form.io's Formbuilder, I have built a form using the Formbuilder's drag and drop functionality and I have saved the generated JSON Schema into my database. How can I reconstruct the form builder again with the same controls from JSON Schema?
I want to do this so that the user can make any modifications to the created form.
I am looking for how to reinitialize the form builder back from JSON.
JSON was generated from the form builder's `builder.instance.schema`. | I was able to to load the form back by passing the json schema to Formio.builder. I was using vanilla javascript. All credits to @randallknutson's Github reply.
//JSON Schema loaded from database
const createdForm = {
display: 'form',
components: [],
...
}
Formio.FormBuilder(document.getElementById('builder'), createdForm, options); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "formio"
} |
Как организовать правку модели с возможностью применить/отменить изменения
Приветствую!
Имеем примерно следующее:
Модель, скажем, товаров:
this.trade_model = [
{
name: 'name1',
title: 'title_one',
cost: 1000,
...
},
...
];
Полей типа `name`, `title`, `etc..` может быть множество.
По клику показываем `<input ng-model="needed_object.name">`, который правит `name` объекта нашей модели.
Как дать ввести человеку новое значение, затем после нажатия кнопки "ОК" применить значение к полю модели или же после нажатия кнопки "ОТМЕНА" сбросить введённые значения.
Прошу прощения если не понятно объяснил :) | Сделать редактирование копии нужного элемента, а не непосредственно элемента массива.
this.trade_model = [
{
name: 'name1',
title: 'title_one',
cost: 1000,
...
},
...
];
this.editIs = false;
this.editIndex = -1;
this.editObject = null;
this.edit = function (index) {
if (!this.trade_model[index]) {
return;
}
this.editIs = true;
this.editIndex = index;
this.editObject = angular.copy(this.trade_model[index]);
};
this.editCancel = function () {
this.editIs = false;
this.editIndex = -1;
this.editObject = null;
};
this.editDone = function () {
this.trade_model[this.editIndex] = angular.copy(this.editObject);
this.editCancel();
};
Либо же наоборот, сохранять оригинал, чтобы если нужно, откатить до него и редактировать напрямую в массиве. | stackexchange-ru_stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "angularjs"
} |
What is (void*) casting used for?
I did try searching for this on Stack Overflow, but I think due to the syntax and not knowing exactly what to search I became a little unstuck.
I have seen `(void*)` being used to cast, usually to function calls. What is this used for? | `void*`, usually referred to as a **void pointer** , is a generic pointer type that can point to an object of any type. Pointers to different types of objects are pretty much the same in memory and so you can use void pointers to avoid type checking, which would be useful when writing functions that handle multiple data types.
Void pointers are more useful with C than C++. You should normally avoid using void pointers and use function overloading or templates instead. Type checking is a good thing! | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 8,
"tags": "c++, casting, void pointers"
} |
Can I draw State-Transition diagrams in JSF2 Web App?
I'm looking for a way to draw state-transition diagrams in my JSF2 project. I would like to be able to load state and transition data and transform them in a graph that can be displayed on my web page.
I haven't found a way to do that yet. Charts available with Primefaces or MyFaces projects (I'm using the 1st one) are dedicated to statistics. In addition, it's probably possible to do that in javascript but I didn't found any example of that in the Google's API's for example.
Any suggestion or help would be appreciated. Thanks a lot.
Clément | I doubt there are components that display graphs using plain html, but you might look for a library that generates an image which you can display in your page. That library wouldn't necessarily be JSF specific though.
Edit: maybe JUNG might be of interest for you. In addition PrimeFaces' dynaImage might help you with displaying the generated graph image. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, graph, jsf 2, state, diagram"
} |
C'est-y pas vrai ?
Dans la lecture du _Voyage au bout de la nuit_ , je suis tombé sur cette phrase orale :
> « C'est-y pas vrai ? »
De nos jours, j’emploierais, pour ma part, « C'est pas vrai ? » à la place.
Était-ce à l’époque correct et qu'en est-il aujourd'hui ? | D'après le wiktionnaire, il s’agit plutôt d’une forme familière qu’argotique de « _Cela n’est-il pas vrai ?_ ». | stackexchange-french | {
"answer_score": 4,
"question_score": 8,
"tags": "grammaire, pronoms, histoire, oral"
} |
Position absolute top property based on the parent width
Having the following HTML
<div class="child-of-body">
This is a text
</div>
and the following CSS
.child-of-body {
position: absolute;
top: 10%;
}
I can set the `top` value of the selected elements. I see that `10%` is computed based on the parent height.
How can I set the `top` property in percent values based on the parent width?
I know that is possible via JavaScript, but would it be possible with CSS only?
**JSFIDDLE** | I think you're looking for `margin-top` property.
A percentage value on top/bottom `padding` or `margins` is relative to the `width` of the containing block.
.child-of-body {
position: absolute;
margin-top: 10%;
}
**JSFiddle Demo**.
Also, it's worth to take a look at **Louis Lazaris' _Vertical Percentages in CSS_** article. | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 3,
"tags": "javascript, html, css"
} |
Threaded Java server with inner class and final variable
I've written the following code to implement a Threaded Server:
ServerSocket passiveSocket = new ServerSocket(port, maxConnections);
while(true){
final Socket socket = passiveSocket.accept();
new Thread(new Runnable() {
public void run() {
//access socket as needed to communicate. E.g.:
PrintWriter writer = new PrintWriter(socket.getOutputStream());
//Finally close socket.
socket.close();
}
}).start();
}
Now this seems to work, but in reflection I do not really understand what's going on with the final socket variable _socket_ when the next connection arrives. How is each thread associated with the socket instance which was current when starting the thread? - is the _final_ keyword responsible for that? | Think of it this way: `socket` is secretly passed as an argument to the `new Runnable` constructor, and it's kept as a variable in the anonymous `Runnable` class. (That's actually how it works, at the bytecode level.)
The created `Runnable` object contains a reference to the one specific `Socket` value at its creation time, so it can close that specific socket when it's done. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "java, sockets, final, anonymous inner class"
} |
The value of $w$ also has a max error of $p\%$
Suppose $\frac{1}{w}=\frac{1}{x}+\frac{1}{y}+\frac{1}{z}$ where each variable $x,y,z$ can be measured with a max error of $p\%$
Prove that the calculated value of $w$ also has a max error of $p\%$
* * *
I guess I need to take its derivative i.e $-\frac{1}{w^2}dw=-\frac{1}{x^2}dx-\frac{1}{y^2}dy-\frac{1}{z^2}dz$
After there, what do I need to do?
I know this question maybe seem nonsense. But please help me to solve. Thanks!:) | From this line
$$-\frac{1}{w^2}dw=-\frac{1}{x^2}dx-\frac{1}{y^2}dy-\frac{1}{z^2}dz$$
The percentage error of $w$ is
$$p_w=100\frac{dw}{w}\%$$
and likewise for the other variables, therefore
$$\frac{1}{w}p_w=\frac{1}{x}p_x+\frac{1}{y}p_y+\frac{1}{z}p_z$$
So assuming a maximum error of $p\%$ on the independent variables we have that
$$\frac{1}{w}p_w\leq\frac{1}{x}p+\frac{1}{y}p+\frac{1}{z}p=\left(\frac{1}{x}+\frac{1}{y}+\frac{1}{z}\right)p=\frac{1}{w}p$$ | stackexchange-math | {
"answer_score": 2,
"question_score": 1,
"tags": "calculus, real analysis, derivatives, approximation"
} |
Unpacking a list / tuple of pairs into two lists / tuples
I have a list that looks like this:
my_list = [('1','a'),('2','b'),('3','c'),('4','d')]
I want to separate the list in 2 lists.
list1 = ['1','2','3','4']
list2 = ['a','b','c','d']
I can do it for example with:
list1 = []
list2 = []
for i in list:
list1.append(i[0])
list2.append(i[1])
But I want to know if there is a more elegant solution. | >>> source_list = [('1','a'),('2','b'),('3','c'),('4','d')]
>>> list1, list2 = zip(*source_list)
>>> list1
('1', '2', '3', '4')
>>> list2
('a', 'b', 'c', 'd')
**Edit:** Note that `zip(*iterable)` is its own inverse:
>>> list(source_list) == zip(*zip(*source_list))
True
When unpacking into two lists, this becomes:
>>> list1, list2 = zip(*source_list)
>>> list(source_list) == zip(list1, list2)
True
Addition suggested by rocksportrocker. | stackexchange-stackoverflow | {
"answer_score": 493,
"question_score": 256,
"tags": "python, list, split, tuples"
} |
How to add files from different input controls into gridview
Below is my requirement. I will have two browse buttons on the page , and two upload buttons on the page.
My requirement is to have both the attachments uploaded by the user to be displayed in a gridview in one row.
Upload1 and Upload2 are the two attachments uploaded by the user and i need to get them as below in the gridview.
Attachment 1 Attachment 2 Delete
Upload1 Upload2 Delete
Can you please help me with an easy way to achieve this? | If I understand you correctly you should be able to do this by using a TemplateField when you define your columns:
<Columns>
<asp:TemplateField HeaderText="FirstColumn">
<ItemTemplate>
<asp:FileUpload ID="fu_FirstFile" runat="server" /><br/>
<asp:Button ID="btn_UPloadFirst" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SecondCOlumn">
<ItemTemplate>
<asp:FileUpload ID="fu_SecondFile" runat="server" /><br/>
<asp:Button ID="btn_UPloadSecond" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "asp.net"
} |
Simple C code not working
I have written a simple code to check whether a given character is present in the string entered by the user but it doesn't seem to work.
#include<stdio.h>
#include<string.h>
int main()
{
char a[20],b;
int i,p=0,n;
printf("Enter the string-");
scanf("%s",a);
printf("\nEnter the character-");
scanf("%c",&b);
n=strlen(a);
for(i=0;i<n;i++)
{
if(a[i]==b)
{
printf("\ncharacter is present in string\n");
p=1;
break;
}
}
if(p==0)
printf("\nchracter is not present in string\n");
return 0;
}
The output I get is this: <
I do not see what is wrong with the code. If I replace "scanf("%s",a);" with "gets(a);" it works fine. Why?
Help is appreciated. Thanks! | Add a space character in:
scanf(" %c",&b);
^
To consume the trailing `\n` character that is left in stdin after the first `scanf`.
So a `\n` is left in the standard input from which `scanf` is reading. So when a new `scanf` is met it scans the old `\n` character.
To neutralize that effect I put a space character in `scanf` i.e. I am telling it to expect to read a `\n` or space or `\t` and then to read a `%c`. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "c, arrays, string"
} |
How to add entity to the databse without adding related entitiy in DB as well?
I have a problem adding one entity using JPA save without error :
`JdbcSQLIntegrityConstraintViolationException: NULL not allowed for column`
because i add empty entity to the object i want to save. how can i save one entity and tell it's related one to ignore this transaction?
For example i have student and i have student_info OneToOne Relationship. I want to save student and not assign information to him yet, but my student_info tells me : hey student_info column 1 can not be null. | You can't!
If there is a constraint on the database like Not Null, primary or foreign key then you can only save the data to this table when the constraints are fulfilled. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, sql, spring, jpa"
} |
Matching the same name in cells
I'm trying to write a macro so when there is the same value from the combobox value selected by the user, then it should output "Checked" in the cell below. Here the code that works fine:
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("A3:G11")
For Each cel In SrchRng
If InStr(1, cel.Value, m1_day1.Value) > 0 Then
cel.Offset(1, 0).Value = "Checked"
End If
Next cel
The problem is that when `m1_day1.Value` is '2', then the program will output "Checked" in the cell below under all the numbers that contain '2': 12, 20, 22 24 etc. | to show it properly: (without replace)
If InStr(1, ","&cel.Value&",", ","&m1_day1.Value&",") > 0 Then
lets asume the cell has `"3,6,14,26"` it will be changed to `",3,6,14,26,"` and looking for `",6,"` => 26 wont count | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "vba, excel"
} |
why is the compiler treating character as an integer?
I have a small snippet of code. When I run this on my DevC++ gnu compiler it shows the following output:
main ()
{ char b = 'a';
printf ("%d,", sizeof ('a'));
printf ("%d", sizeof (b));
getch ();
}
> OUTPUT: 4,1
Why is `'a'` treated as an integer, whereas as `b` is treated as only a character constant? | Because character literals are of type `int` and not `char` in C.
So `sizeof 'a' == sizeof (int)`.
Note that in C++, a character literal is of type `char` and so `sizeof 'a' == sizeof (char)`. | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 4,
"tags": "c, integer"
} |
Separator below actionBar
I noticed that most of android applications have a separator under the action bar. The image below shows the separator:
!enter image description here
How can I use that separator? I thought that this is a default behaviour but in my apps I don't have it.
Thanks a lot! | in themes.xml,
<item name="android:windowContentOverlay">@drawable/ab_solid_shadow</item>
define the windowContentOverlay attribute. the image is the shadow. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "android, android actionbar"
} |
Are there differences in nuance and usage of [内]{ない}[緒]{しょ}, [秘]{ひ}[密]{みつ}, [隠]{かく}し[事]{ごと} and [秘]{ひ}め[事]{ごと}?
They all carry the meaning of "secret" in English, but are there differences in nuance and usage of each of them:
> []{}[]{}
> []{}[]{}
> []{}[]{}
> []{}[]{}
Incidentally, why is it that there is []{}[]{}[]{} but you have to add into []{}[]{}[]{}? | I think that has two usages, one of which is interchangeable with and the other is interchangeable with or . and are synonyms although sounds more poetic to me.
**Cases where and are correct but and are incorrect** :
* That is secret. []
* Let’s keep this between us. []
* secretly , or
In this usage, I feel that is more formal than .
**Cases where , and are correct but is incorrect** :
“Something which is kept secret” is , or , but not . For example,
* “He has secret” is [, ]
As for why is much more common than , ~~it’s secret~~ I do not know. It seems to me like one of the many cases where one phrase is used more often than another for no particular reason. By the way, I would not say is incorrect. If someone uses the word , I will understand its meaning naturally and it will not strike me as incorrect. | stackexchange-japanese | {
"answer_score": 7,
"question_score": 13,
"tags": "word choice, words, nuances"
} |
cassandra udt: when adding a new field into udt type, columns only shows old udt type data
I have created a udt type in cassandra. \--> member(name text).
Then I create a table "users" and one of columns "members" is list>.
I add an another field age into type user So now is member(name text, age int).
I insert data [{name: 'james', age: 1}] into table "users". But it only shows [{name:'james'}] when I do a query. I have run DESC KEYSPACE, and the type is exactly as member(name text, age int). Any suggestions?
PS: my cassandra version is 2.1.3 | This is a known bug (CASSANDRA-9188). You need to restart your cqlsh session to make it use the latest type definition. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "cassandra"
} |
$|\{ |f| > t \}| \leq Ct^{-2} \implies \int_{E}|f| \leq D\sqrt{|E|}$
Let $f \colon \mathbb{R}^{n} \to \mathbb{R}$ be a measurable function such that there is a constant $C > 0$ such
$$ |\\{|f| > t \\}| \leq Ct^{-2} ~~ \text{for all } t>0$$
Show that there exists a constant $D > 0$ such that for every measurable set of finite measure $E$:
$$ \int_{E} f(x) dx \leq D\sqrt{|E|}$$ | This is related to the "duality characterization" of weak $L^2$\- space. For a given $\lambda>0$ (which will be chosen later), let $\displaystyle E = \left(E\cap \\{|f|>\lambda\\}\right) \cup \left( E\cap \\{|f| \le \lambda\\}\right) = E' \cup E'' $. Then we have \begin{align*} \left|\int_E f\right| \le& \int_{E'} |f| + \int_{E''}|f| \\\ \le& \int_\lambda^\infty \left|\\{ |f|>t\\}\right| dt + \int_{E}\lambda \\\ \le& \frac{C}{\lambda} + |E|\lambda \end{align*} from the fact that $\displaystyle \int \varphi =\int_0^\infty \left|\\{\varphi > t\\}\right|dt$ for all non-negative measurable $\varphi$. Now we choose $\lambda = \left(\frac C {|E|}\right)^{\frac 1 2}$ to have that $$ \left|\int_E f\right| \le 2 C^{\frac 1 2} |E|^{\frac 1 2 }. $$ | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "real analysis, lebesgue integral, lebesgue measure, measurable functions"
} |
Virtual PC: Why do I have to re-logon on every window resize?
I am running a Windows XP virtual machine in Microsoft Virtual PC on Windows 7. I have the integration features installed on the guest machine.
Every time I resize the virtual machine's Window, I get the Windows XP logon screen (the one that appears when you leave your computer for a defined amount of time, and need to enter your password to get back to windows).
How do I turn that off? | Unfortunately, Virtual PC now works with remote desktop as protocol of choice. If you change resolution, it breaks of connection and reestablishes new one. During that reestablishing you get password prompt.
Only choice I see is telling it to remember password. Downside is that it will never ask for password again so it is not a solution when you need some basic security. | stackexchange-superuser | {
"answer_score": 5,
"question_score": 1,
"tags": "windows 7, microsoft virtual pc"
} |
Python :: How to open a page in the Non Default browser
I was trying to create a simple script to open a locally hosted web site for testing the css in 2 or more browsers. The default browser is IE7 and it opens the page fine but when I try to open a non default browser such as Firefox or Arora it just fails.
I am using the webbrowser module and have tried this several way as detailed in various sites across the web.
Is it possible and if so how? | Matt's right and it's a pretty useful module to know...
18.1. subprocess
IDLE 2.6.2
>>> import subprocess
>>> chrome = 'C:\Users\Ted\AppData\Local\Google\Chrome\Application\chrome.exe'
>>> chrome_args = 'www.rit.edu'
>>> spChrome = subprocess.Popen(chrome+' '+chrome_args)
>>> print spChrome.pid
2124 | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 5,
"tags": "python, browser"
} |
communication between static method and instance field in java
"Static methods may not communicate with instance fields, only static fields". I got to read this quoted lines. When I studied other threads in this forum, I found that we can use instance fields in static methods and vice versa. So, what does this quote means?? Is it true? | You can't use non-static (instance) fields in static method. That's because a static method is not associated with an instance.
A `static` method is one-per-class, while a class may have many instances. So if you have 2 instances, the fields of which one will the static methods see?
Let's imagine that this is valid:
class Foo {
private int bar;
public static int getBar() {
return bar; // does not compile;
}
}
And then:
Foo foo1 = new Foo();
foo1.bar = 1;
Foo foo2 = new Foo();
foo2.bar = 2;
Foo.getBar(); // what would this return. 1 or 2? | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": 1,
"tags": "java, oop, static"
} |
What tool can I use to to rip DVD movies?
What tool can I use to to rip DVD movies? I have used "Dr. DivX" long back. Is there any better tool to rip DVDs? | **Handbrake**
> HandBrake is an open-source, GPL-licensed, multiplatform, multithreaded video transcoder, available for MacOS X, Linux and Windows.
**Input:**
* Any DVD-like source: VIDEO_TS folder, DVD image or real DVD (unencrypted--protection methods including CSS are not supported internally and must be handled externally with third-party software and libraries), and some .VOB and .TS files
* Most any multimedia file it can get libavformat to read and libavcodec to decode.
**Output:**
* File format: MP4, MKV, ~~\--AVI--~~ or OGM
* Video: MPEG-4, H.264, or Theora (1 or 2 passes or constant quantizer/rate encoding)
* Audio: AAC, MP3, Vorbis or AC-3 pass-through (supports encoding of several audio tracks)
Screenshot:
!alt text
Here are some good tutorials:
* Tutorial on YouTube
* Rip DVD's for Your iPod, Apple TV or iPhone
* How to Rip DVDs with Handbrake | stackexchange-superuser | {
"answer_score": 24,
"question_score": 18,
"tags": "dvd, video conversion, ripping, video encoding"
} |
Uncaught SyntaxError: missing ) after argument list....but it's not missing
Here is the code I'm having a problem with:
<script>
$( "li#1" ).hover(
function() {
$( this ).append( $( "<span>Answer 1</span>" ) );
} function() {
$( this ).find( "span:last" ).remove();
}
);
$( "li#2" ).hover(
function() {
$( this ).append( $( "<span>Answer 2</span>" ) );
} function() {
$( this ).find( "span:last" ).remove();
}
);
</script>
There is no problem with li#2, even though li#1 has identical syntax but is getting "Uncaught SyntaxError: missing ) after argument list" in li#1. Where am I missing the parenthesis? NetBeans debugger tells me it's in the line } function() { which is identical for both. | You are missing commas to separate the multiple functions in each of your `.hover()`'s
<script>
$( "li#1" ).hover(
function() {
$( this ).append( $( "<span>Answer 1</span>" ) );
}, // <-- comma added here
function() {
$( this ).find( "span:last" ).remove();
}
);
$( "li#2" ).hover(
function() {
$( this ).append( $( "<span>Answer 2</span>" ) );
}, // <-- comma added here
function() {
$( this ).find( "span:last" ).remove();
}
);
</script> | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, jquery"
} |
Uninstall "3rd party software"
So I recently reinstalled Ubuntu on my computer and during the installation process, I checked the "Install 3rd party software" box. I was wondering if there was a way to revert it and uninstall all of the packages that came with checking that. From looking online, I realize you can uninstall a package at a time but I am wondering if there is a way to uninstall all of those at once or if I want this effect should I re-install Ubuntu again? | That checkbox installs the metapackage `ubuntu-restricted-extras` which also includes the metapackage `ubuntu-restricted-addons`. To see the full list of what this installs see the following pages:
* <
* <
Each of these can be uninstalled independently.
There is no sure-fire way to remove them all at once, if they were added at install time. You _could_ remove the multiverse and restricted repositories, and then remove all newly-obsolete packages - if you are sure you don't need anything else in those repositories. | stackexchange-askubuntu | {
"answer_score": 0,
"question_score": 2,
"tags": "16.04, package management, uninstall"
} |
"Name" of the route in Symfony2 relevance
I am wondering, what is the use of the "name" of the route in Symfony2 routes.yml file
_welcome:
pattern: /
defaults: { _controller: AcmeDemoBundle:Welcome:index }
For example here, `pattern` and `defaults` are obviously keywords, however, what the `_welcome` stands for? Is it arbitrary or a is it kind of predefined keyword for every bundle? Thank you in advance. | In this case `_welcome` is an arbitrary, unique id for each route you have in your project. You need it if you want to generate a url out of a template or if you want to overwrite a vendor-route... | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, symfony, yaml"
} |
Developing Windows apps with JavaScript
I'm currently in the need of developing a Windows application. I want to keep things simple (in the spirit of uTorrent) and I would like the result program to be a single .exe file containing all that it needs.
The program is simple. It just needs some UI. It needs to run for a long period of time (lay there as a tray icon). It needs to do some routine tasks like simple I/O. It also needs to access the internet, specifically some web server.
Apart from these small requirements I would like to write all of it in JavaScript, as I feel more comfortable with it than any other language.
I know there's things like Windows Script Host that let you run JavaScript programs and interact with some Win32 API, but will I be able to do everything I need with Windows Script Host? Can I pack all of the Windows Script Host in a single .exe?
If not, what alternatives do I have for JavaScript? | I found that there's actually a JavaScript compiler that comes with the .NET framework called `jsc.exe`.
For more information:
<
<
I guess it's not really JavaScript since it introduces extra things like `import` and even some `class` syntax which is weird for me. But this works perfectly for me as I will just doing things as I am used to on the web. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 13,
"tags": "javascript, windows"
} |
Sample space of possible outcomes for a knockout tournament
I would like to confirm if my answer is correct for the following question:
> A conventional knock-out tournament begins with $2^n$ competitors and has $n$ rounds. There are no play-offs for the positions $2,3,..,2^{n-1}$, and the initial table of draws is specified. Give a concise description of the sample space of all possible outcomes.
My answer is: $$\sum_{i=1}^{n} 2^{2^{i}/2}.$$
My reasoning is as follows: For each round, the number of players is $2^n$. The number of matches for each round is $2^n / 2$. Since there can be only a win or loss, the total number of combinations per round is $2^{2^{n}/2}$. Therefore the total number of combinations of outcomes (the total sample space), is the sum of combinations in each round from $1 \ldots n$. | You don't need to sum any complicated series here. Simply observe that each match eliminates one competitor, therefore there are $2^n-1$ matches, each of which has two possible outcomes. | stackexchange-math | {
"answer_score": 3,
"question_score": 2,
"tags": "combinatorics, discrete mathematics"
} |
Split a Python string (sentence) with appended white spaces
Might it be possible to split a Python string (sentence) so it retains the whitespaces between words in the output, but within a split substring by appending it after each word?
For example:
given_string = 'This is my string!'
output = ['This ', 'is ', 'my ', 'string!'] | I avoid regexes most of the time, but here it makes it really simple:
import re
given_string = 'This is my string!'
res = re.findall(r'\w+\W?', given_string)
# res ['This ', 'is ', 'my ', 'string!'] | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 1,
"tags": "python, string, split, whitespace"
} |
Conditional splitting
I am writing a .cpp parser in C#. I need to split the file by some operators. However, I have two delimiters, `-` and `->`.
I want to split the file by `>` when it doesn't have a `-` preceding, otherwise `>` delimiter would also split the `->`.
Should I use regex, or any different solutions? | In C# `String.Split` is enough:
String source = "1->2>3->4->5>6";
// "1", "2", "3", "4", "5", "6"
var items = source.Split(new String[] { "->", ">" }, StringSplitOptions.None); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "c#, c++, regex, parsing"
} |
Angular Could not install ESLint, it does not contain a package.json file
I really like lint. I love that the CLI has built-in lint, but it is being deprecated. I use Windows 10 Pro. Per the Quick Start, I tried the first step and it failed as follows:
> npm i -g @angular-devkit/{core,schematics} @angular-eslint/schematics
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@angular-devkit\{core,schematics}" as it does not contain a package.json file.
Quick Start: <
How can I install ESLint globally or locally? | The full first step of installing **eslint** (per the URL in the question) is as follows:
npm i -g @angular/cli @angular-devkit/{core,schematics} @angular-eslint/schematics
I am not familiar with _{core,schematics}_ but that seems to cause a problem (as per the error message). When I executed the **NPM** installs separately as follows:
> npm i -g @angular-devkit/core
> npm i -g @angular-eslint/schematics
It didn't cause an error. I hope this helps somebody. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "angular cli, eslint, lint"
} |
Blockchain.info not actual?
I'm really new to Bitcoining. I've made my own wallet at blockchain.info, and then I decided to get some "free" bitcoins by watchings ads or something. This worked. At leas when i login at Microwallet.org with the Adress I have from Blockchain. On Microwallet there's displayed my account balance of xxx Bitcoin. But on Blockchain.info (logged in with the same address, of course), my Account balance is 0.
Why? | Lorenz,
Blockchain.info is one of the, if not the most "actual" bitcoin wallets you can get. It's streaming and constantly revised data plotting is also the industry standard, although it is incomplete.
Most of the spoofy little faucets you find Will in fact earn you some mbtc, or micro bitcoin, however, just because they have deposited into a wallet of their own creation and their own design, this does not obligate them in any way to connect with the blockchain.info main chain.
This is because mostly you get what you pay for, and you work for what you're paid. So, watching videos and doing this or that is all well and stupid, and it also has nothing to do with earning money. . 00000001 is called a satoshi, after bitcoins pseudonymous creator. You will be lucky to have as many as just a handful of these doing what you're describing and also successfully redeeming them by TRANSFERING THEM to legitimate wallet service like a blockchain.info. | stackexchange-bitcoin | {
"answer_score": -1,
"question_score": 1,
"tags": "blockchain.info"
} |
Let $a = \frac{9+\sqrt{45}}{2}$. Find $\frac{1}{a}$
I've been wrapping my head around this question lately:
Let
$$a = \frac{9+\sqrt{45}}{2}$$
Find the value of
$$\frac{1}{a}$$
I've done it like this:
$$\frac{1}{a}=\frac{2}{9+\sqrt{45}}$$
I rationalize the denominator like this:
$$\frac{1}{a}=\frac{2}{9+\sqrt{45}} \times (\frac{9-\sqrt{45}}{9-\sqrt{45}})$$
This is what I should get:
$$\frac{1}{a} = \frac{2(9-\sqrt{45})}{81-45} \rightarrow \frac{1}{a}=\frac{18-2\sqrt{45}}{36})$$
Which I can simplify to:
$$\frac{1}{a}=\frac{2(9-\sqrt{45})}{36}\rightarrow\frac{1}{a}=\frac{9-\sqrt{45}}{18}$$
However, this answer can't be found in my multiple choice question here:
 }{ 18 } =\frac { 3-\sqrt { 5 } }{ 6 } $$ | stackexchange-math | {
"answer_score": 4,
"question_score": 2,
"tags": "fractions"
} |
How do you handle (critical) glitches if both parties have one?
The rules state that the character suffers from his mistake and may even injure himself in the case of a critical glitch.
But the rules doesn't cover the case if both involved parties of an opposed test suffer from a glitch.
I guess that this is probably a question of choice and depends on the situation but I may have overlooked something. | Granted, I have no experience with SR4, but in other games with fumble/glitch/oops mechanics (such as older versions of SR and oWOD) my group has handled in one of two ways:
* **Double oops** : If the DM was feeling particularly vindictive (or the character tried something stupid and glitched) both parties take the glitch effect. Usually falling flat, losing the grip on their weapon, and they sacrifice an action to get back up, pick up their weapon, and get ready for the next round
* **Simple miss** : The other option is that you did something that opened a huge window of opportunity for the other guy, but the other guy didn't sense the opportunity. As a result, both folks just take the "miss" effect instead of the "oops" effect. | stackexchange-rpg | {
"answer_score": 7,
"question_score": 7,
"tags": "shadowrun sr4"
} |
What does "immediately" mean in the following phrase?
A website where it is possible to send messages to users uses the following message as confirmation that the message has been correctly sent:
> The user will see the message immediately.
* The message is shown in a list of messages visible in a specific page
* Users are not alerted of messages sent them
* The message is always the same, whenever the users getting the message are using the website, or not
I would understand _immediately_ as _without delay_ , but in this case it is not necessarily true as:
* If the users are not using the website, they cannot immediately see the message
* If the users are using the website, they could not be watching the right page, and read the new messages
What does _immediately_ mean, in this case?
What is the difference between the used message, and "the message has been sent"? | _"Immediately"_ , in this case, appears to mean _"immediately available"_ , rather than _"it will happen now"_. Clearly, as you say, the recipient may not be in a situation to see the message. However, as soon as the sender sends the message, the recipient WILL have the message to view.
As for _"the message has been sent"_ versus _"the user will see the message immediately"_ , consider the case of a letter sent through the postal service. You have posted the letter, but it is not immediately available to the recipient. Obviously the transit time is much lower for electronic communication, but it's fairly certain that most readers here have experienced e-mail delays. The "immediately" appears to say that these sorts of delays won't happen.
(And User3169 is correct that _". . .the user will see. . ."_ is bad phrasing. I would put it as _"the message will be immediately available to the recipient."_ ) | stackexchange-ell | {
"answer_score": 2,
"question_score": 2,
"tags": "difference, meaning in context"
} |
Webstorm can't find '@angular/core';
TS2307: Cannot find module '@angular/core'.
TS2307: Cannot find module '@angular/router'.
or any other module in @angular folder.
Those folders **does exsist** but for some reason - webstorm or typescript or something else doesnt find it.
im working with angular 2 cli
node v = 6.2.2
npm v =3.9.5
....
"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/forms": "0.2.0",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/router": "3.0.0-alpha.8",
"es6-shim": "0.35.1",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "0.19.26",
"zone.js": "0.6.12"
},
.... | In webstorm : File->settings->Languages & Frameworks -> TypeScript ->enable typescript compiler & Use tsconfig.json
Enjoy :) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "angular, npm"
} |
Can I force Ubuntu One to sync a file?
I set up the `Documents` folder to sync in Ubuntu One a few months ago. Last week I made some modifications to a file in that folder.
According to this question `Will Ubuntu one sync if I update files in my local directory?`, I understand that Ubuntu One is supposed to sync my modifications.
But now, I've set up Ubuntu One on another system in order to sync the folder. But I've found out that my modification weren't uploaded to Ubuntu One, as I received the older, unmodified version of my file.
So my question, since that file wasn't updated, is there a way to find out if there were any other files that also weren't updated and can I force them to be synced and updated? | 1.Disconnect from Ubuntu One.(Device tab in Ubuntu One)
2.Connect to Ubuntu One.
When You reconnect all files will synchronize.
< | stackexchange-askubuntu | {
"answer_score": 1,
"question_score": 1,
"tags": "ubuntu one, sync"
} |
Show that $W$ is a subspace and find its dimension.
Let $x\in R^n$ be any nonzero vector. Let $W\subset R^{n\times n}$ consist of all matrices A such that $Ax=0$. Show that $W$ is a subspace and find its dimension.
It is trivial to verify that $W$ is a subspace. Since $A_1x=0$ and $A_2x=0$ implies that $(A_1+A_2)x=0$ and $kAx=0$ with $k\in R$.
I know that the dimension of vector space $F^{m\times n}$ of $m\times n$ matrices is $mn$. That is $E_{ij}$ which have a $1$ in the $i$-th row and $j$-th column and a zero everywhere else. When I tried to find the dimension of $W$ defined above, I cannot relate it with the rank of $A$.
This is my first blood on Math stack. Guys please conquer. | For proving $W$ is a subspace, you should also see that $0 \in W$ but it is trivial.
For calculating the dimension, let $T: \mathbb{R}^{n \times n} \to \mathbb{R}^n$ be defined by
$$ TA = Ax \qquad \text{ for } A \in \mathbb{R}^{n \times n} $$
Then by the dimension theorem,
$$ \dim(\mathbb{R}^{n \times n}) = \text{nullity}(T) + \text{rank}(T) $$
Note that $x \neq 0$. WLOG assume $x_1 \neq 0$. Then for any fix $k = 1, 2, \ldots, n$, we let $$A_{k,1} = 1 \text{ and }A_{i,j} = 0 \text{ otherwise}$$
that is, \begin{equation*} A = \begin{bmatrix} 0 & 0 & \ldots & 0 \\\ \vdots & \vdots & \ddots & \vdots \\\ 1 & 0 & 0 & 0 \\\ \vdots & \vdots & \ddots & \vdots \\\ 0 & 0 & \ldots & 0 \end{bmatrix} \end{equation*}
Then we have $$Ax = (0, 0, \ldots, x_1, \ldots, 0)^T = x_1 e_k \neq 0$$
Note that $n$ different such matrices $A$'s are defined. Therefore we have $n$ independent vectors in $R(T)$ and $$ \text{rank}(T) = n $$
Therefore,
$$ n^2 = \dim(W) + n $$ $$\dim(W) = n(n-1) $$ | stackexchange-math | {
"answer_score": 0,
"question_score": 3,
"tags": "linear algebra"
} |
If $A$ is artinian and commutative, is $A[x]$ artinian?
If $A$ is a commutative, artinian ring, is $A[x]$ artinian? | Polynomial rings are not Artinian, since $$(x)\supset(x^2)\supset(x^3)\supset\ldots$$ | stackexchange-math | {
"answer_score": 2,
"question_score": -1,
"tags": "abstract algebra, ring theory"
} |
From number to formatted datetime in R
I have a field into a dataframe of class numeric. I want to convert that into a date time format.
value: 1353959527000000 expected: 2012-11-26 11:52:07.000-08:00
**How do I do that in R?**
I tried: Using lubridate or default Posix conversion and nothing produced the date above. Read a bunch of posts and still not figuring out what I am doing wrong.
dn <- 1353959527000000
as.POSIXct(as.numeric(as.character(dn)),origin="1970-01-01 00:00:00")
output was something super off the expected date with some gibberish. Same output trying this
as_datetime(1353959527000000, origin = "1970-01-01 00:00:00") | It's FAQ and a repeat question, but as @r2evans told you, the right _scale_ helps. As does eg `anytime::anytime` as it frees you from using the origin etc pp:
R> dn <- 1353959527000000
R> anytime::anytime(dn/1e6) # local time
[1] "2012-11-26 13:52:07 CST"
R> anytime::utctime(dn/1e6) # utctime
[1] "2012-11-26 19:52:07 UTC"
R> | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "r"
} |
XPath select node before current
<table>
<tr>...</tr>
....
<tr>NodeToSelect</tr>
<tr>..</tr>
<tr class="SomeClass">CurrentNode</tr>
...
</table>
I have an HtmlNode object which indicates `-tr class="SomeClass"CurrentNode-` in some function:
string Proccess(HtmlNode node)
{
//need select
}
How can i get node -NodeToSelect- from this function by Xpath? | preceding-sibling::tr[text()="NodeToSelect"]
preceding-sibling::tr[2] | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c#, xpath"
} |
Ruby on rails Twitter gem, paging results
I stumbled over this one: When you get a home_timeline, twitter API normally returns the first 20 tweets. I wanted to get the first 200 which is allowed by the API, but couldn't find how to do it. In Java it works like this:
Paging paging = new Paging(1);// always get first page of tweets
paging.setCount(200);// set count of tweets to get from timeline
List<Status> statuses = null;
// get newsfeed from twitter
statuses = twitter.getHomeTimeline(paging); | Here's the answer:
@tweetCollection = TwitterClient.home_timeline(:page => 1, :count => 200) | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "ruby on rails, api, twitter, pagination, paging"
} |
There are similar tools like FindBugs?
I'm searching for similar tools like FindBugs to analyze my code. I only saw that in the links page of the FindBugs site.
I can search in webfor the tools, but I don't know what is the category of this type of program.
I don't searching for the best, but all that can help me to test my code. | See _A Comparison of Bug Finding Tools for Java_, which is referenced from the FindBugs site. | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 4,
"tags": "java, findbugs"
} |
how to reload/refresh/reinit DynaTree?
When I do the following
$('#tree').dynatree("option","initAjax",{url:"
I want dynatree to forget about current tree data and reload with new data from the specified url instead. But I find it does not do that by default.
Thanks. | look at the `tree.reload()` method, it should do what you are after.
see the docs here: <
as in the docs, the tree is the internal drawing of the tree, and you get it by calling the getTree command: `$("#node").dynatree("getTree")` | stackexchange-stackoverflow | {
"answer_score": 16,
"question_score": 15,
"tags": "javascript, jquery, treeview, dynatree, jquery dynatree"
} |
Python clustering from .csv file as input
I'm trying to find a similar way to perform clustering using Python as I would do using Weka.
I tried scipy, however it gets as input an array.
What I have is a .csv file consisting of
objectId, attribute1, attribute2, .., attributeN
e.g. '1234', 0, 1, 0,1,1,1, ..., 0
Attribute1,2,..,N get values 0 and 1.
Is there a way to load the aforementioned .csv file and perform clustering using a python library and get the cluster each objectId falls into?
My .csv file consists of 300.000 ojectId records.
I have transformed my .csv file into .arff form for weka, but it takes up to 6 hours to perform clustering, so I'm looking for a faster way to do it and was hoping that python library would be faster.
Thanks in advance. | I don't know if is this is what you want but:
To read the .csv:
f = open('yourcsv.csv', mode='r')
content = f.readlines()
Now you can create a list to add all the info
cluster = []
for line in content:
list = line.decode('utf-8').strip().split(',')
cluster[list[0]] = list[1 : len(list) - 1]
// Now you can acces to all the info like this
objectId = 'someIdentifier'
info = cluster[objectId] | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -1,
"tags": "python, csv, cluster analysis, weka"
} |
GeoTIFF Conversion
I've seen several requests like this but I still have one pressing question...
GDAL is often suggested as the easiest way to convert GeoTIFF files into a different format. I downloaded several GeoTIFF files from the FAA website. The downloaded raster maps are compressed zip files which, when extracted, contain 3 files: a .TIF, a geospatial .tfw and .htm metadata file.
The GDAL command to convert the input.tif to a NetCDF output.nc is: `gdal_translate -of NetCDF <input filename> <output filename>`
How does GDAL create a georeferenced NetCDF file from the .tif input file only when the geospatial data is in a different .tfw file? | > If no georeferencing information is available in the TIFF file itself, GDAL will also check for, and use an ESRI world file with the extension .tfw, .tifw/.tiffw or .wld, as well as a MapInfo .tab file.
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "gdal, netcdf, geotiff"
} |
What is the shortcut for moving outside the scope one level when the cursor is on a brace?
exampleObject = new Panel{
if (this.exampleField ===1) {
}
}
Cursor is on one of the inner braces. What is a shortcut for going to one of the outside braces?
I only posted the simple example for clarity of the question. My code is much more messy with dozens of blocks within a big block. A simple search will not suffice. | I don't know a single key combo, but
`<shift>-<right>, <ctrl-F>, <enter>`
will take you to the end of the outer block if you are on the trailing brace, and
`<shift>-<right>, <ctrl-F>, <shift>-F3`
will take you to the beginning if you are on the leading one. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "visual studio, visual studio 2010"
} |
Does $\frac{n^a}{a^n}$ converge or diverge? $a$ is Natural Number
I Applied the Ratio test and it all cancelled apart from $\frac{1}{a}$ so this would suggest the series converges, however wolfram alpha says it diverges. Whats going on?
Sorry this has been editied a thousand times. This is what i want to know. | For the ratio test, we consider $$\lim_{n\to\infty} \left\vert \frac{b_{n+1}}{b_n} \right\vert = \lim_{n\to\infty} \frac{(n+1)^a/a^{n+1}}{n^a/a^n} = \lim_{n\to\infty} \left(1+\frac{1}{n}\right)^a \frac{1}{a} = \frac{1}{a}$$ which is the answer you found.
We know that the series converges if and only if $$\left\vert \frac{1}{a} \right\vert < 1 \iff \left\vert \,a\, \right\vert > 1$$ So your logic is almost correct: just be careful with the ratio test, as it doesn’t tell us anything about what happens when the ratio is equal to one.
Here, we have equality if $a = 1$, and then the general term reduces to $n$. Clearly this doesn't converge.
So the series does not converge for _all_ natural numbers, but it does converge for all natural numbers _greater than one_.
As for the discrepancy between Wolfram Alpha and your logic, I suspect that arises because WA probably doesn't know that $a$ is a natural number. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "analysis"
} |
Free running /side scrolling type game in cocos2d
I want to make free running/side scrolling type game in cocos2d.i try it in tile maps but i am
stucked due to an issue.Issue is i want to jump and after jump the player sprite detects the
lower floor boundary and get the position at floor boundary whenever don't get boundary it
dies.can anyone suggest me what i do or any tutorial etc?Or help me by code example ?
Thanks | I created a basic platformer for the Global Game Jam, using Box2D and adding a couple of classes similar to the Flash engine called "Citrus Engine". You may use this as you like and take it as an example.
< | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "iphone, objective c, ios, cocos2d iphone"
} |
WCF design - One Request and Response object or multiple?
Should you make one request/response object for each method or should you have one per service?
My service request object would only have 5 different things in it if I used it across all methods as I use the same inputs for almost all methods.
The response object would only have a dictionary, a bool, an int that represents an ID, and a string value for the name. I'm not sure I see the point in creating a bunch of separate objects that all have the same things inside of them instead of just using one object.
What is considered the best practice? | I would advise one for each method containing only the request and response information that that method provides and returns. The reason being that it will be clearer to calling clients what the expectations of that method are when they generate their proxy code from the wsdl. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 3,
"tags": "wcf, architecture, request, response"
} |
Recursion - Declaring variable in the body or use it as a parameter?
What is the difference between this recursive function:
int foo (int n,int sum)
{
if (n==0)
return sum;
int temp;
cin>>temp;
return foo(n-1,sum+temp);
}
int main()
{
...
...
foo(n,0);
...
...
}
and this one:
int foo (int n,int sum, int temp)
{
if (n==0)
return sum;
cin>>temp;
return foo(n-1,sum+temp,temp);
}
int main()
{
...
int temp;
foo(n,0,temp);
...
...
}
which one is more efficient in the manner of space complexity? does they have any difference at all? can we say as the recursive calls makes a copy of the parameters, declaring a variable in the function is the same as using it as a parameter? | From the memory consumption point of view a function parameter is identical to a local vartiable. I.e. there's no difference between the two variants form the point of view of memory consumption, aside from the fact that you introduced a completely unnecessary local variable in `main`.
However, the second variant might be less efficeint in therms of time, since at each level of recursion you pass the current value of `temp` down to the next level of recursion. That value is not used at all (the one received from `main` is not even initialized), meaning that any CPU efforts spent on passing it there are completely wasted. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 3,
"tags": "c++, recursion"
} |
Smooth floor function
I want a monotonic function on the positive real numbers that behaves like floor but in smooth way, like smoothstep but for all integers. It should follow this simple rule.
> slope is zero at integers and slope is maximum at median of two adjacent integers or in other words: slope is at $0$ when fract$(x) = 0$ and slope is at maximum when fract$(x)=0.5$
So far i was able to approximate this function my self with help of trigonometric functions. $$ f(x) = \lfloor x \rfloor + \max\left(\frac{(-1)^{\lfloor x\rfloor}}{2}(1-\cos(\pi x)), \frac{(-1)^{\lfloor x+1\rfloor}}{2}(1-\cos(\pi x + \pi))\right) $$ can this be achieved in a simpler/shorter way? | What do yo think of : $$y(x)=x-\frac{\sin(2\pi x)}{2\pi}$$
 and Latin America. Feel free to give me continental links or even country links to the best vector digital GIS coastlines. High-detail and high-resolution matters (1:50,000 or better).
Countries required are:
* Brazil
* Ecuador
* Mexico
* India
* Bangladesh
* China
* Thailand
* Malaysia
* Vietnam
* Philippines
* Indonesia
* Myanmar
Thanks. | The coastline in the referenced resource ("A New Map of Standardized Terrestrial Ecosystems of Africa") was created from an analysis of 30m Landsat imagery, subsequently generalized to 90m (see page 6).
I am not aware of a global database of coastlines derived from Landsat, but check out GSHHG. Their shoreline data comes from the World Vector Shoreline database, originally produced at 1:250,000.
GSHHG A Global Self-consistent, Hierarchical, High-resolution Geography Database < | stackexchange-gis | {
"answer_score": 4,
"question_score": 4,
"tags": "data, vector"
} |
How can I fill these gap of the verticals?
I don't want to fill it with F. I want to select the edge and snap it to the other edge adjacent to it.
. | stackexchange-blender | {
"answer_score": 3,
"question_score": -4,
"tags": "mesh"
} |
How can I query for all values of a custom taxonomies?
Suppose I have a Custom Taxonomy "Fruits". I want to query for all the values available eg. Oranges, Apples, Mangos etc. How can I do that? | Use `get_terms($taxonomy, $args)`
$terms = get_terms('Fruits');
Codex page | stackexchange-wordpress | {
"answer_score": 0,
"question_score": 0,
"tags": "custom taxonomy, query"
} |
Is Adding runat="server" to HTML tags to get relative path in ASP.net an elegant solution?
I've got a couple of ASP.Net Usercontrols that I am using in different locations of my new website. These usercontrols had links like this :
<a href="daily/panchang/"></a>
If the usercontrol is used in pages in various subdirectories the relative path just doesn't work, and I don't want to provide my full website name in the path. So I did this
<a href="~/daily/panchang/" runat="server">
and now the ASP.Net '~' marker works correctly to resolve the root path.
Is it okay to mark all my HTML tags where I have the need to resolve the root path with runat="server" or do you know of a better, HTML way?
Thanks | I won't say whether it's an elegant solution, I'll just point out an alterantive within System.Web:
<a href="<%= VirtualPathUtility.ToAbsolute("~/daily/panchang/") %>"> | stackexchange-stackoverflow | {
"answer_score": 7,
"question_score": 6,
"tags": "asp.net, html"
} |
Blog post contains a link to a deleted user
This blog post contains a broken link:
> .ToString("yyyy-MM-dd")) Then
End If
but if the date in the database is 0000-00-00 its returning an error:
Unable to convert MySQL date/time value to System.DateTime
i have also tried remove the `ToString`
If Not IsDate(reader3.GetDateTime(0)) Then
End If
but i still get the same error | A way is to use IF into your MySql Select:
IF(YourDateField='0000-00-00' OR YourDateField IS NULL,'',YourDateField) AS YourDateField
So, when the field is null or equal to '0000-00-00', the output from DB will be an empty string and you'll avoid vb.net errors. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "mysql, vb.net"
} |
Using Stream to map Collection result
I'm trying to think of a way to do this without invoking `stream()` twice but to no avail:
List<Song> songs = service.getSongs();
List<ArtistWithSongs> artistWithSongsList = songs.stream()
.collect(Collectors
.groupingBy(s -> s.getArtist(), Collectors.toList()))
.entrySet()
.stream()
.map(as -> new ArtistWithSongs(as.getKey(), as.getValue()))
.collect(Collectors.toList());
As requested:
class ArtistWithSongs {
private Artist artist;
private List<Song> songs;
ArtistWithSongs(Artist artist, List<Song> songs) {
this.artist = artist;
this.songs = songs;
}
}
Is there a more optimal way of doing this? | I think you can use FlatMap:
List<Song> songs = service.getSongs();
List<ArtistWithSongs> artistWithSongsList = songs.stream()
.collect(Collectors
.groupingBy(s -> s.getArtist(), Collectors.toList()))
.entrySet()
.flatMap(as -> new ArtistWithSongs(as.getKey(), as.getValue()))
.collect(Collectors.toList());
Edit:
Sorry we cannot use flatMap after collect() because it doesnot return stream. Other solution is:
List<ArtistWithSongs> artistWithSongsList = new ArrayList<>();
songs.stream()
.collect(Collectors.groupingBy(Song::getArtist))
.forEach((artist, songs) -> artistWithSongsList.add(new ArtistWithSongs(artist, songs));); | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 4,
"tags": "java, java stream"
} |
Syntax for passing tables to call read() JavaScript functions
What's the syntax for passing a table like as a parameter to an external JavaScript function with the return value stored in a variable?
* table user
| UserId | UserType | UserRoles |
| 123 | 'Regional' | { Role : Ninja } |
I'm thinking `* def uid = call read('base64-encoder.js') { user }` where the function is defined as
function(uid) {
var Base64 = Java.type('java.util.Base64');
var encoded = Base64.getEncoder().encodeToString(uid.bytes);
}
But this gives a:
> ParserException: Unexpected End of File position 7: null | The syntax for passing the karate table to an external JavaScript function would in this case be
* def uid = call read('base64-encoder.js') user
just adding a space for the function parameter.
JavaScript just doesn't know how to handle the list item it gets. So for this function not to fail on type checks, the table row first has to be cast to a string like this:
* string me = user[0]
* def uid = call read('base64-encoder.js') me
This way the java won't choke on the table and you'll get well-formed JSON strings out of the encoded string:
function(uid) {
var Base64 = Java.type('java.util.Base64');
var encoded = Base64.getEncoder().encodeToString(uid.bytes);
return encoded;
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "javascript, karate"
} |
how to add active profile to spring in conjuction with spring's spring.profiles.active
We do have some spring profiles enables via web.xml spring.profiles.active and I want to leave it that way as this is the way for our deployment team to activate profiles. in addition I want to activate some more profiles based on the presence of properties files. so I added an ApplicationContextInitializer
public class WecaApplicationContextInitializer implements
ApplicationContextInitializer<ConfigurableApplicationContext>{
@Override
public void initialize(ConfigurableApplicationContext applicationContext)
{
applicationContext.getEnvironment().addActiveProfile("someprofile");
}
but then spring ignores the spring.profiles.active context param and does not load my main profiles.
anyone has an idea how to do it?
I think I can add a ServletContextListener and add a profile to spring.profiles.active param but I think this is kind of ugly. | Can you use:
profiles = ac.getEnvironment().getActiveProfiles()
To get active profiles, then add to these and pass into:
ac.getEnvironment().setActiveProfiles(profiles, "profileName") | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "spring, web, servletcontextlistener, spring profiles"
} |
Laravel query to output json data as select list. How to amend existing code to concatenate two values
I've got a pre-existing function in my controller that will run a simple query and return the model_name and id then return the result as json.
public function getModel($id)
{
$models = DB::table('model')->where('man_id',$id)->pluck('model_name','id');
return json_encode($models);
}
New requirement is that I include an additional column named model_num with the query. Plan is to concatenate the model_name and model_num columns.
Tried the following, but it doesn't return any values and I get a 404 response for the json:
public function getModel($id)
{
$models = DB::table("model")->select("id","CONCAT(model_name, '-', model_num) as model")->where("man_id",$id)->pluck('model','id');
return json_encode($models);
}
Am I missing something obvious? | You are using SQL functions within a `select` these will probably not work. You can use `selectRaw` instead:
public function getModel($id)
{
$models = DB::table("model")
->selectRaw("id, CONCAT(model_name, '-', model_num) as model")
->where("man_id",$id)
->pluck('model','id');
return response()->json($models); // response()->json() is preferable
}
alternatively you can do the concatenating in the PHP side:
public function getModel($id)
{
$models = DB::table("model")
->select("id", "model_name" "model_num")
->where("man_id",$id)
->get()
->mapWithKeys(function ($model) {
return [ $model->id => $model->model_name.'-'.$model->model_num ];
})
return response()->json($models);
} | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "laravel"
} |
Extract plist from Simulator directory to use with my project during loads/saves
I'm using a plist to store bookmarks as a simple array of strings.
I can load a plist from my project directory with no problem, but when I make changes to the plist it doesn't show up on the file in my project directory. Instead, the changes to the plist are being saved in a temporary directory used by the simulator.
Is there anyway to tell xcode to use the plist that's in the project directory?
When I run the app again my saved changes to this plist file are not seen since it loads the data from the project directory, then saves it again to the temp simulator folder. | From what I understand the app should **change** the contents of the plist. If that's the case, you should not load the file from the projects-directory. Those files are not to be changed once the app is shipped.
Instead, you should load and save the plist file in the Documents/ directory of your app bundle. That way, it will also be synced with iCloud if you want it to.
So, do something like ... if there's no file in the Documents/ directory, copy it to Documents/ from the bundle (assuming there are some default values in it). If there is a file, load it from Documents/ and work with it. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "ios, xcode, plist"
} |
Img onkeydown don't work
Why this code don't work properly?
<img src="picture.jpg" id="picture"/>
<script>
document.getElementById('picture').onkeydown = function() {alert('tekst');}
</script> | Your image doesn't have focus so it won't listen to the 'onkeydown' event. I'm not sure if it is possible to give an image focus in order for your onkeydown event to work.
Instead you could place your image within an a-tag which can have focus and therefore can listen to the onkeydown event.
Something like this:
<a id="picture" href="#">
<img src="picture.jpg" />
</a>
<script>
// The a tag
var picture = document.getElementById('picture');
// You have to put focus on the atag (or any element that you want to have for you onkeydown event.
picture.focus();
// Now your event will work
picture.onkeydown = function() {
alert('tekst');
}
</script> | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "image, function, onkeydown"
} |
Is there a recommended number of lines of code per file?
I have a class file that contains all the classes that are needed for a certain web application. Currently I'm at line 7269 and it contains numerous classes. I'm not particularly worried but I've started to notice that when working on this file Visual Studio responds slower. I'm thinking that this may be caused by the size of the file and Visual Studio's re-compile after every enter key press.
Has anyone got any recommendations for limits to lines per file of classes per file or perhaps guidelines as to how/why I should move classes into separate files?
I found this regarding Java but I'm specifically concerned with VB and Visual Studio 2005
Maximum lines of code permitted in a Java class?
Thanks
EDIT There are about 50+ classes in the file, some tiny, some large! | Egad.
It's highly recommended by just about everyone that classes are contained in a file per class.
Lines isn't very relevant directly, but it can be a symptom that you're creating an overly complex god class and need to break the logic up. Unit test driven development forces this when done correctly.
**edit (noticed the "why?"):**
from the fact you're asking it should be obvious :)
A few (of many reasons):
* it's very hard to visualise the actual code layout in large files
* most IDEs are default set-up to show multiple files at a time, but not multiple views of the same file
* source control over a single file can be a problem: "can you please check in {godfile} so I can work on the project?"
* fragmenting code into namespaces/packages/branches is a problem | stackexchange-stackoverflow | {
"answer_score": 18,
"question_score": 8,
"tags": "vb.net, visual studio"
} |
DataTable.DefaultView.Sort doesn't seem to be working
I populate a DataTable, then sort the DefaultView of that DataTable. When I set the DataTable as the source for my report, the sort doesn't work. In case it helps, here is the code (GetData returns a valid DataTable):
Dim dt As DataTable = a.GetData(Parm1, Parm2, Parm3)
If rbtSortByField1.Checked Then
dt.DefaultView.Sort = "Field1 ASC"
ElseIf rbtSortByField2.Checked Then
dt.DefaultView.Sort = "Field2 ASC"
ElseIf rbtSortByField3.Checked Then
dt.DefaultView.Sort = "Field3 ASC"
End If
rpt.SetDataSource(dt.DefaultView.Table)
'This also doesn't work
'rpt.SetDataSource(dt) | ASSUMING this is a Crystal Report...
See this article. You can't sort on the datasource, you need to have the report do the sorting.
<
Also covered here:
< | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 2,
"tags": "asp.net, datatable, sorting, dataview"
} |
SQL Server 2008 Login Problem
I'm trying to install yet another forum on my local machine, and while I'm configuring the database connection I got this message
> Failed to connect:
>
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
I have served Google and I found that I have to add network service Login to my SQL server and then add this user to my database
I don't know if this is true or false but anyway I don't know hot to add the network service to my SQL server
please help as soon as you can
Thanks in Advance | This is the Identity of the Appplication Pool in IIS
Local database, same box as IIS:
CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS;
Local or remote database in Active Directory domain
CREATE LOGIN [myDomain\ServerName$] FROM WINDOWS; | stackexchange-serverfault | {
"answer_score": 4,
"question_score": 0,
"tags": "asp.net, sql, sql server 2008"
} |
The button clicked by code jquery
Is there any function of `Javascript` or `Jquery` to make a button clicked by code?
I already search on the internet but didn't see the answer for this.
Thanks so much! | Yes, `.click`
$("#yourButtonElement").click();
### fiddle
Note this is also possible in native JavaScript without jQuery
### Native JS fiddle | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": 2,
"tags": "javascript, jquery, button, click"
} |
How to get full points in a SuperTuxKart Challenge(Story Mode)
When I complete a challenge in SuperTuxKart Story Mode, I always win 6/8 points. The game says:
> You completed the easy challenge! Points earned on this level: 6/8
I am wondering why I only get 6 points out of 8? I am winning each race an average of 30 seconds ahead of all the AI karts, and skidding like a pro! Is it because I sometimes go off the track, or because I should stay closer to the other karts? Or it is because I am in Novice mode and will get more points if I do the challenge in Intermediate or Expert? | You will get more points for completing the challenges in higher-level modes, such as Intermediate or Expert. If you win the race in Intermediate mode, you will get 7/8 points, and if you win in Expert mode you will get 8/8 points. | stackexchange-gaming | {
"answer_score": 0,
"question_score": 1,
"tags": "supertuxkart"
} |
Powershell WMI-Object Select-Object makes 2 blank lines, is there a way to remove the blank lines?
I'm making a list of infomation that i what to display. But anytime i run the line that is needed to show the info, it's gonna place 2 blank lines over the output.
Code looks like this
$Pro = Get-WmiObject -Class win32_processor
$pro | select-Object Name,NumberofCores,NumberOfLogicalProcessors | format-list
Is there something else i can do to make it remove the 2 lines from the output? (Can't show the blank lines because they don't show)
Name : Intel(R)
NumberOfCores : x
NumberOfLogicalProcessors : x | The Answer from @leeharvey1 is what was needed.
$pro | Select-Object Name | Format-list| Out-string | ForEach-Object { $_.Trim() | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "string, windows, list, powershell"
} |
MonthCalendar control displaying non ISO-8601 compliant week numbers
I am encountering an issue with the MonthCalendar Windows Form UI Control. With the ShowWeekNumbers property enabled, it shows week 1 of 2016 to be the week containing January 1st, which is on a Friday. This is not compliant with ISO-8601, which states that the first week of the year is the week that contains the year's first Thursday (first 4-day week).
The MonthCalendar control (SysMonthCal32) is part of the Common Control Library (comctl32.dll). It uses the MCS_WEEKNUMBERS style when displaying week numbers. On the Month Calendar Control Styles page of the MSDN site, it provides the following statement in the description of MSC_WEEKNUMBERS: "Week 1 is defined as the first week that contains at least four days." Unfortunately, that is contrary to what I'm experiencing with the control.
Here's a photo of the MonthCalendar control, showing the issue described above. | The calculation for week numbering is determined by the operating system's user locale settings. It can not be influence by modifying the CurrentCulture and CurrentUICulture properties of the main execution thread. As stated by this Microsoft Support article:
> This behavior occurs because the DateTimePicker control and the MonthCalendar control are Microsoft Windows common controls. Therefore, the operating system's user locale determines the user interface of these controls.
Unfortunately, the operating system's user locale settings can not be set during application runtime. To achieve ISO-8601 compliance, a custom control will be necessary. These culture-aware MonthCalendar and DateTimePicker controls on CodeProject should do nicely. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": ".net, visual studio, iso, week number, monthcalendar"
} |
jquery div id is not taking on dynamic div id creation
I am creating a set of dynamic divs
Let div id is div1 div2 div3 etc
in my function for getting div id am concatinating
var divid= 'div'+1
var divid= 'div'+2
etc.
if i call jquery slide down
$('#div1').slideDown('slow');
Its working ,but if i use
$('#divid').slideDown('slow');
Its not working . Why? divid is having same value.. What i am missing?? | Change
$('#divid').slideDown('slow');
to
$('#'+divid).slideDown('slow');
String literal v.s variable issue | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "jquery"
} |
Renaming column names in Pandas
I want to change the column labels of a Pandas DataFrame from
['$a', '$b', '$c', '$d', '$e']
to
['a', 'b', 'c', 'd', 'e'] | Just assign it to the `.columns` attribute:
>>> df = pd.DataFrame({'$a':[1,2], '$b': [10,20]})
>>> df
$a $b
0 1 10
1 2 20
>>> df.columns = ['a', 'b']
>>> df
a b
0 1 10
1 2 20 | stackexchange-stackoverflow | {
"answer_score": 2494,
"question_score": 2791,
"tags": "python, pandas, replace, dataframe, rename"
} |
Create folder hierarchy in zip - with gradle
I'm trying to create a dist zip with gradle. I want to locate my jar at the root dir of the zip. and locating all my dependencies at lib folder . I didn't succeed to do so.
No matter what i tried only one folder is being created(I tried do create some folders). And my artifact jar is included in this folder.
I will appreciate any help.
This is my task defintion :
task zip(type: Zip, overwrite:true) {
from jar.outputs.files
from configurations.runtime.collect{it}
into ('lib')
} | I believe you need to do:
task zip( type: Zip, overwrite:true ) {
from jar.outputs.files
into( 'libs' ) {
from configurations.runtime
}
}
As it shows in the documentation | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 3,
"tags": "groovy, zip, gradle"
} |
If $1 \leq q < p$ whats a sequence in $\ell^{p}$ but not in $\ell^{q}$?
> If $1 \leq q < p$ whats a sequence in $\ell^{p}$ but not in $\ell^{q}$?
Having trouble understanding this, just looking for an example. Thank you. | The sequence $x_n=n^{-\frac{1}{q}}$ will do. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "functional analysis"
} |
Can you add a loading (not a menu background) image or video to grub?
When you boot out of the box ubuntu, there is a post grub menu "animation" of orange circles loading. I want to know if I can instruct grub to display my own custom image during the post menu bootloading. I have tried looking this up,m but I only get how to change the background.
My main OS is arch linux btw. | The package that handles the boot screen is called plymouth. Grub’s job ends as soon as an operating system is selected (either by user input or timeout).
This answer gives some details on how to change the Plymouth theme. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "linux, grub, bootloader"
} |
How to call a function using the package and function name in a string with ::
How can I call a function in a package using the fully qualified name ("package::function")?
This does not work:
> eval(call("utils::sessionInfo"))
Error in `utils::sessionInfo`() :
could not find function "utils::sessionInfo"
This works:
eval(call("sessionInfo"))
It must be possible to parse and execute a code snippet without internal knowledge, but how? | Replace `call` with `parse`:
eval(parse(text = 'utils::sessionInfo()'))
For example:
eval(parse(text = 'dplyr::count(iris, Species)'))
# A tibble: 3 x 2
Species n
<fctr> <int>
1 setosa 50
2 versicolor 50
3 virginica 50 | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "r"
} |
converting hex string in ipv6 format in postgresql
I have a hex string like `\xfc80000000000000ea508bfff217b628` in bytea format and I want to convert it into `fc80:0000:0000:0000:ea50:8bff:f217:b628` in select query, I tried:
select '0:0:0:0:0:0:0:0'::inet + encode(ip::bytea,'hex') from a;
but following error is coming
ERROR: operator does not exist: inet + text
LINE 1: select '0:0:0:0:0:0:0:0'::inet + encode(stationipv6::bytea,'...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. | `substring()` works with `bytea` values and you can use that to extract the individual parts of the bytes to convert it to an `inet`:
select concat_ws(':',
encode(substring(stationipv6, 1, 2), 'hex'),
encode(substring(stationipv6, 3, 2), 'hex'),
encode(substring(stationipv6, 5, 2), 'hex'),
encode(substring(stationipv6, 7, 2), 'hex'),
encode(substring(stationipv6, 9, 2), 'hex'),
encode(substring(stationipv6, 11, 2), 'hex'),
encode(substring(stationipv6, 13, 2), 'hex'),
encode(substring(stationipv6, 15, 2), 'hex')
)::inet
from your_table
works on `bytea` columns | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "postgresql, ipv6"
} |
Adding decimals from a list of interfaces
Hello friends,
public decimal Balance
{
get
{
_test = 0m;
foreach (ITransaction t in _Transactions)
{
_test += t.Value;
}
return _OpeningBalance + _test;
}
}
The Value variable of ITransaction and the _OpeningBalance instance variable are both decimals. Is there a shorter way to return the sum of the ITransaction values and the _OpeningBalance without using a 'temporary variable'? This is for a university assignment and I want the code to be as neat as possible. Thanks in advance :) | Try LINQ `Sum()`
return _OpeningBalance + _Transactions.Sum(t => t.Value);
You can find an example along with documentation on MSDN. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "c#, interface, foreach, return"
} |
exponential difference inequality
Im asked to prove the inequality when $0\leq a<b$ and $x>0$:
$$ a^x(b-a)<{b^{x+1}-a^{x+1}\over{x+1}}<b^x(b-a) $$
So far I have seen that obviously: $$a^x(b-a)<b^x(b-a)$$ and that $$b^{x+1}-a^{x+1} = (b-a)(b^x+b^{x-1}a+...+ba^{x-1}+a^x) > a^x(b-a)$$ This has done no good for me yet but it seems related to it. $$$$ I was thinking it may have to do with $a<{a+b\over{2}}<b$ but I cant see how. If you think a hint may help me out I would prefer that over a straight solution. But any help is appreciated thank you. | also use your idea: $$b^x+b^{x-1}a+\cdots+ba^{x-1}+a^x>a^x+a^x+\cdots+a^x=(x+1)a^x$$ and $$b^x+b^{x-1}a+\cdots+ba^{x-1}+a^x<b^x+b^x+\cdots+b^x=(x+1)b^x$$ | stackexchange-math | {
"answer_score": 1,
"question_score": 3,
"tags": "real analysis, inequality"
} |
Scala Map[String, MutableList]()
I want to create mutable Map which contains string as key and MutableList as value.
val myMap = scala.collection.mutable.Map[String, MutableList]()
like this:
mymap = Map("a" -> MutableList(1, 2, 3), "b" -> MutableList(5, 6, 7))
but whne i try to create it raises error:
scala> var myval = scala.collection.mutable.Map[String, scala.collection.mutable.MutableList]()
<console>:10: error: class MutableList takes type parameters
var myval = scala.collection.mutable.Map[String, scala.collection.mutable.MutableList]() | `MutableList[A]` expects a type paremeter. You should use a `var` for mutable state and not `val` as well:
import scala.collection.mutable.{Map => MutableMap, MutableList}
var myMap = MutableMap[String, MutableList[Int]]()
myMap = MutableMap("a" -> MutableList(1, 2, 3), "b" -> MutableList(5, 6, 7)) | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 2,
"tags": "list, scala, dictionary"
} |
Best way to use Rspec Expect instead of should
I have noticed that I am getting depreciation warnings using should instead of expect with rspec. I cant find the best way to implement expect for the following test
it "is invalid without a goal" do
FactoryGirl.build(:project, goal: nil).should_not be_valid
end
If any help me out or put me in the right direction it would be much appreciated. | According the documentation you could use `expect.to` something as follows:
it "is invalid without a goal" do
expect( FactoryGirl.build(:project, goal: nil) ).to_not be_valid
end | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "ruby on rails, rspec"
} |
Why is PMD give different results for Eclipse and Gradle?
I am using the eclipse-pmd plugin, and I am also using PMD via the following Gradle configuration:
plugins {
id 'pmd'
}
pmd {
consoleOutput = true
ruleSets = []
ruleSetFiles = files("pmd-ruleset.xml")
toolVersion = "6.41.0"
}
Both methods are configured to use the same ruleset, and my `PATH` variable points to PMD 6.41.0 (which I _think_ is what the Eclipse plugin uses), and yet both give different results.
For example, running `./gradlew pmdMain` complains about the rule `AvoidUncheckedExceptionsInSignatures`, but eclipse-pmd does not flag this up at all.
Why might this be? | It turns out that the **eclipse-pmd** plugin (which I found in `C:\Users\{username}\.p2\pool\plugins`) comes packaged with its own version of PMD, which in this case is 6.28.0.
This doesn't fully explain the discrepency, since the `AvoidUncheckedExceptionsInSignatures` rule has been around since PMD 6.13.0, but I'm happy enough to blame the difference in versions for the difference in output. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "java, eclipse, pmd"
} |
How to add conditional classes in rails?
I am new here :/ ,, trying to create a dynamic blog and the problem is I am trying to change div ID according to words count inside it .. sometimes I get "cannot compare fixnum with string" error and sometime syntax error ..
<style>
#smalldiv {
width: 100px;
background-color: red;
height: 150px;
}
#largediv {
width:300px;
background-color: green;
height: 150px;
}
</style>
Posts controller
class PostsController < ApplicationController
def index
@posts = Post.all
end
end
Posts_view
<% @posts.each do |x| %>
<div id = '<%= 'smalldiv' if x.description.size < '50' + 'largediv' if x.description.size > '50' %>' >
<p> <% x.description %> </p>
</div>
<% end %> | Try `<div id="<%= x.description.size < 50 ? 'smalldiv' : 'largediv' %>" >`
You had ... quotes around 50, too many `if` statements in a row, a missing `=` in your `<%`, and a gap if `.size` equals exactly 50. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ruby on rails"
} |
What difference with Android when iOS is not open?
My question may seem silly, but, I've read in many Android books that the better part of Android is Android is open, and iOS is closed.
But, from a programmer viewpoint, who cares about this point? Programmers just care about the platform: is it easy to program in, easy to have help in the network, etc. They don't care about whether the platform is open or closed.
One book had additional information, but I don't understand it much. Since iOS is not open, I’d be able to share my work with others only if Apple allowed it.
So, if you write an app, and need to share, you must have Apple's permission, but not Android's?
Please help me understand this point. I'm preparing for a presentation on Android. And I don't know if I should put this point into my presentation. | If Google doesn't accept your app for the play store, or you don't like their conditions, you could still offer it through alternative means, e.g. Amazon Market, AndroidPIT etc. or just sell it on your own website (*). Additionally, since Apple has strict requirements regarding content etc., and enforces them, your app is more likely to be rejected by Apple than by Google.
Android in general allows your app to dig deeper into the system. On iOS, your app simply cannot get the permission e.g. to kill other apps.
(*) Gameloft offered their Android games only through their website for a long time, so it's not a purely hypothetical option. | stackexchange-softwareengineering | {
"answer_score": 8,
"question_score": 2,
"tags": "android, ios"
} |
Partition of set into subsets of size at most k
I have a set of $N$ elements, and I want to generate all partitions of the set into subsets of cardinality at most $k$. For example, if $N = 4$ and $k=3$, for the set $S = \\{a, b, c, d\\}$ we have the partitions $(a)(b)(c)(d)$, $(a b)(c)(d)$, $(a c)(b)(d)$, $(a d)(b)(c)$, $(b c)(a)(d)$, $(b d)(a)(c)$, $(c d)(a)(b)$, $(a b)(c d)$, $(a c)(b d)$, $(a d)(b d)$. How many partitions are there for general $N$, $k$? | Let $E_k(x)=\sum_{i=0}^k \frac{x^i}{i!}$ be the partial exponential series. Then the answer is $$ N![x^N]\exp(E_k(x)-1) $$ where $[x^N]f(x)$ is the coefficient of $x^N$ in the power series $f(x)$. This is the simplest expression I can think of for the solution.
For example, when $N=4$ and $k=2$, note $$ \exp(x+\tfrac{x^2}2)=1+(x+\tfrac{x^2}2)+\tfrac12(x+\tfrac{x^2}2)^2+\tfrac16(x+\tfrac{x^2}2)^3+\tfrac1{24}(x+\tfrac{x^2}2)^4+\dots $$ Extracting the coefficient of $x^4$, we get...
* a contribution of $\frac18$ from the $\tfrac12(x+\tfrac{x^2}2)^2$ term,
* a contribution of $\frac14$ from the $\tfrac16(x+\tfrac{x^2}2)^3$ term, and
* a contribution of $\frac1{24}$ from the $\tfrac1{24}(x+\tfrac{x^2}2)^4$ term.
There are no contributions from anything else. Adding these up and multiplying by $N!=24$, we get $3+6+1=10$. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "combinatorics"
} |
Mysql sorting issue
I have a table like following
ID Position
1 A1
2 A2
3 A3
4 A4
5 A5
6 A6
7 A7
8 A8
9 A9
10 A10
11 A11
12 A12
13 B1
.
.
22 B10
.
. H12
Note that the ID is not unique but positions are unique
when I do
Select * from <tablename>
I get
> A1, B1, C1, D1, E1... H1...H12
as output and when I do
Select * from <tablename> order by Position
I get
> A1, A10, A11, A12, A2, A3 .....
as output
I wanna sort it such that my output is A1,A2,A3,A4,A5,A6,A6,A8,A9,A10,A11,A12,B1,B2... H12..
What should be the query? | try this:
SELECT * FROM <tablename> ORDER BY SUBSTR(position FROM 1 FOR 1), CAST(SUBSTR(position FROM 2) AS UNSIGNED) | stackexchange-stackoverflow | {
"answer_score": 4,
"question_score": -1,
"tags": "mysql"
} |
IE8 cannot view sites that share certificate on one IP from IIS 7.5
I have multiple sites with different root domains that use use the same IP/port and certificate on IIS 7.5.
With firefox, chrome, and IE9 it works fine. But IE8 users experience the error:--
`**Internet Explorer cannot display the webpage.**`
`HTTP` works fine but not `SSL`.
Is there a way to get this work without having users upgrade to IE9 or use another browser? | Using the same IP address for multiple secure web sites requires Server Name Indication, a TLS extension. Its primary drawback, however, is that no version of Internet Explorer on Windows XP supports it. If you intend to support such clients, you will need unique IP addresses for each host. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 1,
"tags": "windows server 2008, ssl, iis 7.5, internet explorer 8, internet explorer 9"
} |
Badge indicator is too large relative to other text on Android App
_Not to be confused withModerator diamond is too large relative to other text on Android_.
Well, I just updated my Nexus 4 to Android 5.0 Lollipop. Nothing is wrong, all work well, no problem with app compatibility, and it's a good time to browse Stack Exchange... uh, were those badge indicators _that_ large?
> !those are laaaarge!
* Stack Exchange: 1.0.51
* Android model: Nexus 4
* Android version: 5.0
For comparison, this is from SE 1.0.51 on Galaxy S3, Android 4.0.4 taken from this question
> !normal!
And this is from SE 1.0.48 on Nexus 4, Android 4.4.4 taken from my previous bug report
> !normal too! | This seems to be an issue specific to Android 5.x Lollipop, and possibly related to Android system font.
On Android 6.0 Marshmallow, the badge size is back to normal (but then there's another "problem"...)
) $ . Find smallest k for which $a_k= 0 $
$ a_1 = 10 $ and $ a_2 =20$. Given that, $ a_{n+1} = a_{n-1} - (4/(a_n)) $ . Find smallest k for which $a_k= 0 $
A. Does not exist. B. is 200 C. is 50. D. is 52. | $$ a_{n+1} = a_{n-1} - \frac{4}{a_n}$$ $$\implies \large 4=a_{n-1}a_n - a_na_{n+1} $$ So we can write by a telescoping series; $$\begin{align} & 4=a_{n-1}a_n - a_na_{n+1} \\\ & 4=a_{n-2}a_{n-1} - a_{n-1}a_{n} \\\ &4=a_{n-3}a_{n-2} - a_{n-2}a_{n-1} \\\ & \ldots \\\ & 4=a_1a_2 - a_2a_3 \end{align}$$
By adding the $(n-1)$ sums, we get by cancelling, $$4(n-1)=a_1a_2-a_na_{n+1}$$ $$\implies \large a_na_{n+1} = -4n+204 \tag1$$
Now, observe that the product $a_na_{n+1}$ first becomes zero for $n=51$. But for $n=50$ using $(1)$, $a_{50}a_{51}=4\not=0$. And since such a product can only be $0$ if either of the terms is $0$, so $a_{51} \not=0$; rather $a_{52}=0$.
But then using $(1)$, $a_{52}a_{53}=-4\not=0 \Rightarrow a_{52}\not=0$ , neither of them, that is.
So this is a contradiction.
Hence the smallest $k$ for which $a_k=0$ does not exist i.e no such $k$ exists for $k \in \mathbb{I^+}$. | stackexchange-math | {
"answer_score": 6,
"question_score": -2,
"tags": "real analysis, sequences and series, recurrence relations"
} |
How to create irrational endpoints of open sets in $\mathbb{R}$ from countable basis
I read that $\mathbb{R}$ has a countable basis (i.e. it's second countable). The countable basis consists of open intervals with rational endpoints. Now, from this countable basis, how do you construct open sets (intervals) with irrational endpoints? | Let $(u_n)$ be a descending sequence of rationals converging to $a$.
Let $(v_n)$ be an ascending sequence of rationals converging to $b$.
$$(a,b) = \bigcup_n (u_n, v_n)\text{.}$$ | stackexchange-math | {
"answer_score": 4,
"question_score": 0,
"tags": "general topology"
} |
What is this notation mean in this code? []()
From the docs for ESP8266WebServer here < its shows server.on syntax like this
server.on("/", handlerFunction);
I don't understand what this line is doing.
server.on ( "/admin.html", []() { Serial.println("admin.html"); server.send ( 200, "text/html", PAGE_AdminMainPage ); } );
I specifically do not understand what the `[]()` is. The rest of it I get. | This is what's known as a "lambda expression". It's something that C++ and many other languages support (C does not).
Lambda expressions are used to allow languages to manipulate functions. In this case, the lambda expression lets you use an "anonymous function" so that you can pass a handler to `server.on()` without having to declare it as a function with a name ahead of time.
The `[]` part lets you specify "captures" - variables which will be available to the lambda function. The `()` part is the normal list of function parameters that you'd have when you declared a function. And the `{}` part is of course the function's code.
In this case, no captures, no parameters, so `[]() { code... }`.
You can read more about C++ lambda expressions at < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "c++, arduino, esp8266, arduino esp8266"
} |
How to implement smooth scrolling on a webpage?
I want to implement smooth scrolling on my web page. I'm not sure how to do it, either by overriding normal mouse scrolling or maybe there's another way. What I want to achieve is shown e.g. here. Try to scroll through the page. | The site you mention is using this plugin for smooth scrolling: <
If you want the same scrolling results, I recommend using the same plugin instead of building your own version. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -2,
"tags": "php, jquery, css, smooth scrolling"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.