INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
Server.MapPath does not exist in the Current Context
I have a C# Model Class where I am trying to access a `.cshtml` page which is supposed to be an email format template. I'm using the following code:
string body = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailConfTemplate.cshtml")))
{
body = reader.ReadToEnd();
}
But i am getting the following error message:
> The name Server does not exist in the current context
Is there any error in the code or the `Server` class can't be accessed in POCO class. Please help.
|
To execute it inside a .Net pipeline, you can find it as an instance present in `HttpContext`
System.Web.HttpContext.Current.Server.MapPath()
|
stackexchange-stackoverflow
|
{
"answer_score": 20,
"question_score": 7,
"tags": "c#, .net"
}
|
dcolumn with alignment to comma
this is supposed to be an easy question, but I didn't find a clear answer anywhere.
I want to use `dcolumn` with comma as a separator. However, I found different solutions and the manual is unclear to me. It says in `D{>sep.tex<}{>sep.dvi<}{>decimal places<}`, I have to choose ',' instead of '.' to achieve alignment to the comma. However I dont understand the difference between `{>sep.tex<}` and `{>sep.dvi<}`.
Also I found a solution where someone only used `{>sep.dvi<}` as a comma, whereas the manual suggests to use comma in both, `{>sep.tex<}` and `{>sep.dvi<}`.
Can someone explain the difference and tell me how to specify it correctly?
MWE simple as that: `\newcolumntype{G}{D..{2.1}}` \- where `G` currently aligns to the decimal point, not the comma, in case of 2 decimal places before the separator and 1 after.
Thanks.
|
# Remarks
Let's look at the definition `\newcolumntype{>name<}{D{>sep.tex<}{>sep.dvi<}{>decimal places<}}`:
1. `>name<` is the name for your new column, limited to one character.
2. `>sep.tex<` is the character, which is used for alignment in the TeX code.
3. `>sep.dvi<` is the character, which will substitute the `>sep.tex<`-character in the output (in most cases identical to `>sep.tex<`, because we only use alignment).
4. `>decimal places<` is either `-1` for auto detect or `pre comma places.post comma places`.
# Example
\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{tikzsymbols}% for \Smiley
\usepackage{dcolumn}
\newcolumntype{G}{D{,}{\Smiley}{2.1}}
\begin{document}
\begin{tabular}{|G|G|}
10,2 & 5,3 \\
8,1 & 10,2 \\
4,4 & 8,1 \\
8.1 & 10.22 \\ % <-- broken by purpose
3,4 & 8,5 \\
\end{tabular}
\end{document}
# Output
> !enter image description here
|
stackexchange-tex
|
{
"answer_score": 7,
"question_score": 3,
"tags": "dcolumn"
}
|
How to post Image to facebook using koala gem
I am using this code to post images to facebook
def post_to_facebook(facebook_auth)
graph = Koala::Facebook::GraphAPI.new(facebook_auth.token)
graph.put_wall_post(self.message, {
"picture" => self.avatar.url(:thumb),
"description" => self.message
})
end
but I am not able to open local images
No such file or directory @ rb_sysopen - index5.jpeg
if any one knows solution please let me know
|
def post_to_facebook(facebook_auth,image,content)
begin
graph = Koala::Facebook::GraphAPI.new(facebook_auth.token)
graph.put_picture(image,content,{:message => self.message})
rescue Faraday::Error::ConnectionFailed => e
end
end
|
stackexchange-stackoverflow
|
{
"answer_score": -1,
"question_score": -1,
"tags": "facebook, ruby on rails 3, web services, koala"
}
|
PHP Multiple Files Upload print blank Array
This is my form:
<form action="?upload=1" method="post" enctype="multipart/form-data">
<input name="file[]" type="file" multiple />
<input type="submit" value="Upload"/>
</form>
This is my php:
function make_upload() {
print_r($_FILES);
}
if (isset($_GET["upload"]) && $_GET["upload"] == "1") {
make_upload();
}
If I try to select only one file then it shows the array with the file in. It's OK.
If I try to select multiple files then it shows `Array ( )`. Why?
|
Your code is good. No errors founds in it.
Your problem is 100% caused by `post_max_size`.
You need to increase it from your `php.ini` configuration file.
You could increase `upload_max_filesize` too.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "php, file upload, upload, image upload"
}
|
Is it possible to backup os while other apps are open
Is it possible on the free edition of macrium reflect?
|
It's physically possible, but can have undesirable side-effects.
In effect, Macrium Reflect (or any other backup product) will copy the disk in sequential order, hopefully locking each file whose sectors it's copying at the moment.
However, if the application you're using is dependent for its correct functioning on an ensemble of files which it modifies, it's possible (although low-probability) that Macrium Reflect will copy some of these files before they were updated, and copy the rest of the files after the update.
The result will be an incoherent group of files, which might cause this application to malfunction if you ever restore that disk-image. Which is why it's advisable not to use the computer while Macrium Reflect is imaging the disk.
Some applications, like the browser, will automatically recover an incoherent disk cache, and so are safe to use. Others may be more touchy.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 0,
"tags": "backup, macrium"
}
|
Programmatically add a file to jquery fileupload
I'm using blueimp/jQuery-File-Upload to allow users to upload attachments when creating a inquiry on my site.
I need to extend the current functionality to add a auto generated image to the queue. The image I need to add is an exported canvas, thus a base64 encoded string, i.e something like
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNby // blAAAADElEQVQImWNgoBMAAABpAAFEI8ARAAAAAElFTkSuQmCC
How can I add such a file to the upload queue? I am stuck and don't know where to start. Any pointers to the right direction is much appreciated.
|
It is not possible to programmatically add a `File` object to `FileList` object at `<input type="file">` element. You can create a file as `data URI`; `Blob` or `File`; or `FormData` object, use `POST` to send file object to server.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "javascript, jquery, file upload, blueimp"
}
|
Ports are used by programm execution
How can I found out which ports a program is using on his execution?
I am using a Ubuntu 14.04 Server and the program "SMcli". But the program shows on every execution "Network errors were detected while connecting to storage system". But before we changed the location everything was working fine.
Now I need to know which ports this program is using. Then I can look which ports the target is listening.
|
Try to use `netstat -tunap` or `netstat -tunlp` before the program starts and after the program starts.
|
stackexchange-askubuntu
|
{
"answer_score": 2,
"question_score": 1,
"tags": "viewports"
}
|
A question on complex valued function.
Let $f$ be a function which has power series representation around open nhd of $z_0$. If $f^{(n)}(z_0) \rightarrow 0$, what can we say about the function. Only polynomials will satisfy the condition? What if we assume extra such that $\sum f^{(n)}(z_0)$ converges. I could not find any explcit function other than polynomials. Any help please.
|
Consider $f(z) = \exp(\tfrac{1}{2} z)$. Then $f^{(n)}(z) = \left(\tfrac{1}{2}\right)^n \exp(\tfrac{1}{2} z)$, hence $f^{(n)}(0) = \left(\tfrac{1}{2}\right)^n$, which is summable.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "complex analysis, power series"
}
|
python print isn't work during the for loop
I want to check a some value in the python 2.7 during the for loop. And I want to print a current time. The problem is print isn't operate during the for loop. When the for loop finished, the print is operated. My Source code is below.
[ Code ]
import time
def display():
print "Something..."
while(1):
time.sleep(1)
display()
Who know the reason? or solution?
|
import time
def display(something):
print something
index = 1
while(1):
time.sleep(1)
display(index)
index += 1
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "python, time, while loop"
}
|
How to construct a 45 degree angle given its opposite segment and a line through its altitude?
I need to do this construction for perspective geometry and art. So I'm only using a straight edge and compass.
I can solve the problem if the angle needs to be 90 degrees. I just draw a semicircle with the segment as diameter. Then, where the semicircle intersects the perpendicular, I draw a triangle between this new vertex and the segment. This gives the required triangle.
The analogous construction for a 45 degree angle seems harder. Is there a better way?
Edit:
I think I didn't explain well.
I want to take this data . Find the point $D$ on the perpendicular bisector so that $m\angle ADB = 90^{\circ}$. Now $AD=DB$ as $D$ is on the perpendicular bisector of $\overline {AB}$ so $A$ and $B$ are points of a circle with radius $AD=DB$ with center $D$.
Find the point $C$ on the altitude so that $DC = AD=AB$. (There will be two such points, probably, but one will be below $\overline {AB}$ and the other above-- choose the one that is above.)
Then $A,C,B$ are three points on the circle so $m\angle ACB =\frac 12 m\angle ADB = 45^{\circ}$.
;
int i;
for( i = 0; i <= 25; i++ )
{
cipher[i] = name[i];
if( name[i] = 'g' ) {
cipher[i] = 'a';
};
cout << cipher[i];
};
`cipher[i] = name[i];` is there to copy one array to another, so then only one array gets changed. It works. And rest of the program, in my understanding, works like this: if there is a letter `g` in `name[0]`, make it a letter `a` in `cipher[0]` and if there isn't, just skip, repeat 25 times. But the results are so random to me i don't understand what's going on at all...
!img
|
In your if statement, you're doing an assignment rather than comparison:
`if( name[i] = 'g' )` should have `==` like so: `if( name[i] == 'g' )`
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "c++"
}
|
Execute code at timed view flip Android
I am writing an app that is similar to a slide show and uses a viewflipper that flips at an interval of 5 seconds. I am new to android, and was wondering, is there any way I can execute code at every view flip? This code would update a layout object such as text in a text box.
Here is some sample code:
vf=(ViewFlipper)findViewById(R.id.ViewFlipper01);
vf.setFlipInterval(5000);
vf.startFlipping();`
Thank you for your help.
|
There is no way built in to ViewFlipper that allows you to do that easily. It is still possible to do it a few ways though.
One option you have is to use a runnable to "run along side" of your ViewFlipper, since your interval is known you can set up a recursive runnable that will also use a 5000ms interval to make things happen at the same time as the view is changing.
vf=(ViewFlipper)findViewById(R.id.ViewFlipper01);
vf.setFlipInterval(5000);
Runnable r = new Runnable() {
@Override
public void run(){
//Do something here
vf.postDelayed(r,5000);
}
}
vf.postDelayed(r, 5000);
vf.startFlipping();
Another way to do it would be forego the automatic flipping via startFlipping(), and instead use a runnable like this with `vf.showNext()` inside of it. That way each iteration of the runnable will flip views for you, and you can do whatever else you want along with it.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 1,
"tags": "android, view, timer"
}
|
Исключить узел с определенным тегом
jQuery(element).contents().each(function() {...});
Можно как-нибудь исключить здесь узел с определенным тегом? Обрабатываю таким образом текст на странице, и нужно обработать все кроме тега `pre`.
|
Кроме селектора `:not`, есть еще метод `.not`.
//все содержимое .content исключая <pre> отмечаем красным
$('.content').contents().not('pre').each(function(){
$(this).addClass('red')
});
jsfiddle
|
stackexchange-ru_stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "javascript, jquery"
}
|
Vue.js VeeValidate how to prevent validation until user finished the input
I'm using VeeValidate to validate user's inputs in my vue component. The problem is it is validate the fields immediately when user start to input the data in to field.
 findet dieser Kurs in Berlin statt.
Das **Komma kann, muss aber nicht** gesetzt werden. Begründung: Der erste Teil ist ein formelhafter Nebensatz. Normalerweise grenzt man Nebensätze gemäß § 74 des amtl. Regelwerks mit Komma ab, doch für die formelhaften gilt § 76, wonach das Komma weggelassen werden kann (aber nicht muss).
### Zu Fall 2
> Wir freuen uns drauf, Sie bald in Berlin begrüßen zu dürfen!
Das **Komma muss** gesetzt werden. Begründung: Der zweite Teil ist eine vom Verweiswort _drauf_ abhängige Infinitivgruppe, und gemäß § 75 (3) des amtl. Regelwerks grenzt man Infinitivgruppen, die von einem Verweiswort abhängig sind, mit Komma ab. Zu prüfen ist noch, ob eines der Zusätze E1 oder E2 von § 75 die Bedingung (3) wieder auflöst. Dies ist hier nicht der Fall, denn E1 betrifft nur bloße Infinitive (wenn also _zu dürfen_ allein stünde), und E2 betrifft nur Infinitivgruppen, die nicht bereits durch § 75 (1)–(3) geregelt sind.
|
stackexchange-german
|
{
"answer_score": 4,
"question_score": 0,
"tags": "subordinate clause, comma, punctuation, adverbial"
}
|
Is there a way to find out what user owns a process from the process's task_struct?
I have a `task_struct *` that I got by calling `find_task_by_vpid(get_pid())`. I'd like to figure out what user owns that process so that I can do some permission checking in the system call I'm writing, but looking through the `task_struct` source code hasn't helped much. The only thing that looked helpful is the `loginuid`, but for some reason the kernel won't compile if I try to access it like this: `my_task_struct->loginuid`. Is there another way to get the user who called the process from the `task_struct`?
|
Unfortunately, the user/group ids are no longer stored in the task struct, but instead in a separate privilege structure that's dynamically allocated and shared between all tasks that have the same ids. This in turn creates a situation where `setuid` can fail due to resource exhaustion, and failure of `setuid` to prop privileges is an infamous source of vulnerabilities...
Anyway, it's in these members of the `task_struct`:
const struct cred __rcu *real_cred; /* objective and real subjective task
* credentials (COW) */
const struct cred __rcu *cred; /* effective (overridable) subjective task
* credentials (COW) */
|
stackexchange-stackoverflow
|
{
"answer_score": 7,
"question_score": 7,
"tags": "multithreading, process, permissions, linux kernel, pid"
}
|
How to list network shares and users in Windows?
With "net share" I can get a list of shares I'm connected to but how can I get a listing that shows the user info used to connect to a share, if the user is not the same as the logged in user in Windows?
|
Does going to computermanagement > System Tools > Shared Folders give you what you want?
|
stackexchange-superuser
|
{
"answer_score": 11,
"question_score": 11,
"tags": "windows"
}
|
is it possible to study MBA after B.tech and phd on electronics after MBA
Hi every one I'm full confused about my future please give a good suggestions, Currently I am working on Ebedded systems(yocto and embedded linux) I have completed my batchulor of technology in electronics and communications(4 years) in 2015. so now I want to study MBA after this can I do P.hd in electronics side. is am i thinking wrong?
|
If all you want is a PhD, you don't need to do an MBA.
If you want to get a PhD in the United States, then either:
1. You first earn an MS, MSc, MA, or MEng, then apply to a PhD program.
2. You apply directly to a PhD program without any graduate degree, then the graduate program basically has you earn a Master's degree before you start the typical PhD work.
MBA's are Master's degrees, but they're more focused on _Business Management_. You might choose to earn an MBA before, during, or after your PhD, but it's not necessary. MBA's and PhD's aren't very much related.
|
stackexchange-academia
|
{
"answer_score": 1,
"question_score": -4,
"tags": "education"
}
|
Sort TableView with Entity
This works but it's getting sorted randomly every time.
In points there is point.pointOrder which is a NSNumber. I would like to sort them after point.pointOrder. Can anyone point ;) me in the right direction please?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
OIOISingleTourTableViewCell *cell = (OIOISingleTourTableViewCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
point = [[self.tour.tour_infopoint allObjects] objectAtIndex:indexPath.row];
cell.lblInfoPointName.text = point.pointName;
return cell;
}
|
In viewDidLoad i did this:
pointArray = [self.tour.tour_infopoint allObjects];
NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey:@"pointOrder" ascending:YES];
sortedPointArray = [[NSMutableArray alloc] initWithArray:[pointArray copy]];
[sortedPointArray sort UsingDescriptors:[NSArray arrayWithObject:desc]];
and then in cellForRowAtIndexPath
point = [sortedPointArray objectAtIndex:indexPath.row];
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "ios, uitableview, core data, xcode5"
}
|
Android apache client logging in
I am developing an app. On the first screen user have to log in (POST call) and then on other screens it can perform actions (GET calls).
I am doing it in asynctask, but the problem is, I have to log in in background on every screen, becasue async task (and therefore the client instance) is destroyed after performing a call. Is it possible to send instance of HttpCLient between activities?
The second approach, I have tried was IntentService, but after I make a GET call, intentservise sent me response and close itself. And after recalling I need to log in again.
And I was wondering.
Is it possible to log in once in some backgroud thread, that is alive until the app is alive and then just sending GET calls from UI thread and receiving responses?
Or is it better to log in in every activity, but don't bother device with background thread?
|
Once you login then store the session value in `sharedPreference` until user log out. Its better approach rather sending the request to web server for authenticate again again.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "android, rest, apache httpclient 4.x"
}
|
The strange exchange
You have two people in the center of an endless plane.
Each one is holding some item that can fit in their palm, like a tennis ball. Both persons are identical in physical ability and brainpower.
However, each one is just as clever as sly as the other one, and both are very clever and sly in their own right. They will immediately do what is best for them, and will always do what is best for them, unless there is an incentive.
**Q** : What foolproof way is there for these two to exchange their items?
Examples of inappropriate ways:
Throw it over each other: One might not throw it and chase the others item
Each hold the others item at the same time: One might let go first and the other won't let go, taking both items
|
Both people set their items down a ways apart, then simultaneous walk toward each other's item.
Neither person can benefit from being sneaky by returning to pick up her own item, as the other person would then do the same. There is no way either person can end up with both items.
|
stackexchange-puzzling
|
{
"answer_score": 5,
"question_score": 5,
"tags": "logical deduction"
}
|
Is the following map a continuous map between two Lie groups?
Consider $GL_n(\mathbb{C})$ as a real Lie group, and $U_n(\mathbb{c})$ a real Lie subgroup of $GL_n(\mathbb{C})$. Consider map $\varphi$: $$ \varphi : GL_n(\mathbb{C}) \longrightarrow GL_n(\mathbb{C}) $$ $$ X \longrightarrow XX^* $$ Map which sends $X \rightarrow X^*$ is continuous, and real differentiable, but it's not complex differentiable, so $\varphi$ is continuous. Is it correct? If it's correct, then $U_n(\mathbb{C})$ is kernel of $\varphi$, then it's closed subgroup of real Lie group $GL_n(\mathbb{C})$, so it's real Lie subgroup of $GL_n(\mathbb{C})$?
|
Yes, it is correct. But there is no need to mention differentiability here. Just say that $\varphi$ is the product of the continuous maps $X\mapsto X$ and $X\mapsto X^*$.
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "lie groups, smooth manifolds"
}
|
Playing with Assembly without OS details
I sometimes like to play with inline assembly in C(++) to learn more about it and easily interact with it. I looked into tutorials for assemblers like NASM, but it seems you have to pay attention to a lot of OS specific details to do just about anything.
Is there a way to play with assembly where I can just write simple functions and call them from C or something like that? Perhaps an assembler with object files as output?
Basically I'm interested in learning how to turn problems into low level instructions, I don't want to deal with the boilerplate code to print messages to the screen and all that.
Note that I'm not intending to write actual programs in assembly language. I know compilers do a much better job at it than I ever will. I'm just doing it for fun, essentially solving puzzles.
|
You may be interested in following Paul Carter's PC Assembly Tutorial. It's for NASM and pretty much any C compiler (gcc, Open Watcom, Borland's, Microsoft's).
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "assembly, x86"
}
|
Regularity method: size of $\epsilon$-regular graph parts
I am applying the Regularity method, as described for example here.
I do not understand why the size $l$ of the $k$ resulting sets $V_i$, ie:
$l = |V_1| = |V_2| = ... = |V_k|$
has the following size, after the sets has been made super-regular:
$$\frac{n(1 - \epsilon)}{M(\epsilon)} \le l$$
With $M(\epsilon)$ being the upper bound on $k$.
I understand the $n/M(\epsilon)$ part: each set can have at most $n$ elements divided by the $M(\epsilon)$, the maximum number of parts. But where is the $(1 - \epsilon)$ term coming from?
|
The $1−ϵ$ term is coming from the $V_0$ part of size at most $ϵn$, thanks Erick!
|
stackexchange-math
|
{
"answer_score": 0,
"question_score": 1,
"tags": "graph theory, regularization"
}
|
merge sort recursion tree height
I am learning about recursion tree's and trying to figure out how the height of the tree is log b of n where n = 2 and one has 10 elements as input size. I am working with Merge sort.
The number of times the split is done is the height of the tree as far as I understood, and the number of levels in the tree is height + 1.
But if you take (for merge sort) log2 of 10 you get 1, where if you draw the tree you get at least 2 times that the recursion occurs.
Where have I gone wrong? (I hope I am making sense here)
NOTE: I am doing a self study, this is not homework!
|
log2(10) = 3.321928094887362...
In any case, the recursive call depth is O(log(n)), which basically means "on the order of log(n)". The actual call depth for an O(log(n)) algorithm might be `k*log(n)+c`, or even `k*log(n)+α(n)/log(log(n))+c`.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "recursion, computer science, tree"
}
|
Security/Security.h file not found [Lexical or Preposessor issue]
!Screenshot of my iPhone app
Screenshot of my iPhone app where I get this error when I am trying to create an archive file, can anyone help me to solve this issue. My Xcode version is 4.6.2
|
You may need to add Security.Framework in the "Link Binary With Libraries" section in "Project Build Phases" !enter image description here
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "iphone, xcode"
}
|
$\lim x_0^2 + x_1^2+...+x_n^2$ where $x_n=x_{n-1}-x_{n-1}^2$
So, we are given a sequence $x(n)$ for which $x_{n+1}= x_n-x_n^2$ , $x_0=a$, $0 \le a \le 1$
I was first requested to show that it converges and to find $\lim_{n \to \infty} x_n$. I will post my answer here for you to check if it is right :S
so, $x_n-x_{n+1} = x_n-x_n+x_n^2>0$ , thus the sequence is decreasing and since every term is positive its also bounded, therefore it converges to its infimum=A
so $A=\lim x_n= \lim x_{n+1}= \lim (x_n-x_n^2) = A-A^2 => A^2=0 => A=0$
And then it asks for me to find $\lim_{n \to \infty} x_0^2+x_1^2+...+x_n^2$ . I tried to do the same by defining a different sequence but it didn't work.
I know it converges but I can't find the limit. Can you give me any help? If it is possible, don't post any answer that involves series because I haven't studied them yet.
|
Notice that by rearranging the recursive formula, we obtain $x_n^2=x_n-x_{n+1}$. Plugging this in yields:
$$x_0^2+x_1^2+\ldots+x_n^2=(x_0-x_1)+(x_1-x_2)+\ldots+(x_n-x_{n+1})=x_0-x_{n+1}$$
Now taking the limit gives $x_0=a$ because $x_{n+1}$ vanishes as $n$ goes to infinity.
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 2,
"tags": "analysis"
}
|
XCode 4 only displaying cout statements with endl
I have a really weird issue with my cout statements. I've only tried this out with XCode 4. For instance, if I write,
cout << "this works" << endl;
cout << "this doesnt";
cout << memorySizeLimit << " blocks of memory available." << endl;
I see all three output statements in my debugger console. However, if I change the order to,
cout << memorySizeLimit << " blocks of memory available." << endl;
cout << "this works" << endl;
cout << "this doesn't";
I only see the first two couts. Even stranger, if I change the code to,
cout << memorySizeLimit << " blocks of memory available." << endl;
cout << "this works" << endl;
cout << "this doesn't" << endl;
I see all three statements.
Why would I not see that "this doesn't" cout statement when I change its position?
|
`std::cout` is an stream and normally it is buffered for performance. If you print `endl` the stream gets flushed (`cout << endl` is the same as `cout << "\n" << flush`.
You may flush the stream manually by `cout << flush` (or `cout.flush()`).
So that should print:
cout << "this doesn't" << flush;
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 1,
"tags": "c++, xcode4, cout, endl"
}
|
Passing parameters to jquery .load callback function in a loop
I am trying to load an set of images and apply different styles to each one as the load in. When I run my code I only get the last set of styles passed in to be applied to all images.
For a group of images ids $foo load that image into its own box and then apply a height.
for ( var i = 0; i < $foo.length; i = i + 1 ) {
$bar = i;
$('.box'+[i]).load('/getimage/'+$foo[i]', function(){style($(this), $bar);}
}
function style(img, $bar){
img.css('height', $bar);
}
Each image I format with the style function only gets set to height of last value of $bar.
I want to set the height to whatever the value of $bar is at the time that image is loaded.
|
You could use a closure to get the correct value on each iteration
for ( var i = 0; i < $foo.length; i = i + 1 ) {
$bar = i;
// closure to get correct value for i
(function(index) {
$('.box'+[index]).load('/getimage/'+$foo[index], function() {
style($(this), index);
});
})(i);
}
function style(img, $bar){
img.css('height', $bar);
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 1,
"tags": "javascript, jquery, html, ajax"
}
|
What is the best way to return big chunks of binary data from a webservice?
I am implementing a webservice that returns the content of binary files. The files are about 100MB big. The webservice and the client are build upon Axis2.
What is the best joice for the return type of the method that returns the data?
I tried byte[], but I always get OutOfMemoryErrors on the server side. Plus I am not very happy to have the whole file content in memory. Is there something stream-alike that I can use instead?
|
The article "Downloading a Binary File from a Web Service using Axis2 and SOAP with Attachments" describes exactly the solution I was looking for. Big chunks of data are added as attachment to the SOAP response of the webservice using "SOAP with Attachments" (SwA).
I can use a javax.activation.DataSource which provides an InputStream and I do not have to hold the whole file in memory.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 7,
"tags": "java, web services, axis2"
}
|
Outlook item to webDAV location
I have a web application which has a calendar, and I want to allow that calendar to be sync'd with an Exchange server.
I've written code to create appointments on an Exchange server directly in a user's calendar using webDAV. I save the appointment locations (URLs) so I can update the appointments in outlook if something changes in my application.
I'm trying to write an add-in for Outlook that lets a user send their appointment to my web application. In order to save it though (and allow updates in my application to propagate back to Exchange) I need to figure out what the appointment location (URL) is in WebDAV.
Is there any way to get the WebDAV URL of the appointment from within Outlook? I'm using VSTO for my outlook add-in.
|
Thanks for the help guys!
This question helped considerably: How to use WebDav to match dav:href to Outolook Interop href value
And this website was interesting too: <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "exchange server, webdav, outlook addin"
}
|
How to Connect Virtual Machines in a Cloud Service using REST
I'm working with Virtual Machines on Windows Azure and according to the following link: < it is possible to link various Virtual Machines to the same cloud service. The provided link clearly explains how to do it by means of the Windows Azure Management Portal. Nevertheless, in my case, I want to do the same using the REST API. Anyone knows how can it be done?
Thank you so much in advance, Abel.
|
I believe you need to "add role" to add a new VM to an existing IaaS Cloud service: <
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "rest, azure, hyperlink, virtual machine, iaas"
}
|
how to use android delay not extending or implementing Thread or Runnable
i am new here and i want to know how to use delay in android without using Threading . I am using Handler
Handler handler=new Handler();
Thread r=new Thread () {
public void run() {
// Your next task
}
};
handler.postDelayed(r, 30000);
|
Replace `Thread r = new Thread with Runnable`
Handler handler=new Handler();
Runnable r=new Runnable() {
public void run() {
// Your next task
}
};
handler.postDelayed(r, 30000);
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "android, timer, delay"
}
|
Using javascript map with a function that has two arguments
I know that I can use `map` with a function of one variable in the following manner:
var squarefunc = function(x) {
return x*x;
};
values = [1,2,3,4]
values.map(squarefunc) // returns [1,4,9,16]
How do I use `map` with the following function:
var squarefuncwithadjustment = function(x, adjustment) {
return (x*x + adjustment);
}
where, I want to input value for argument `adjustment` manually when I call map, say `adjustment=2`, and have the value of `x` taken from the array `values`.
|
Use an anonymous function:
values.map(
function(x) { return squarefuncwithadjustment(x, 2); }
);
|
stackexchange-stackoverflow
|
{
"answer_score": 113,
"question_score": 76,
"tags": "javascript"
}
|
Changing properties of the control that calls a Context Menu
I have 10 PictureBox on a windows form (created in Design View) and a context menu strip is attached to each of them. I am trying to set the property of the PictureBox using the context menu.
For eg If the user selects Red from the context menu a Red picture shows up
I can get the the name of the control that popped the Context Menu strip by
cmStrp1.SourceControl.Name
Is there any way I can use the cmStrp1.SourceControl.Name to get the object/control and set its properties
|
Just use `cmStrp1.SourceControl` instead of `cmStrp1.SourceControl.Name`. You need to cast the control to a `PictureBox` before using it.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "vb.net, contextmenu"
}
|
Subprocess file output needs to close before reading
I'm trying to use a subprocess to write the output to a data file, and then parse through it in order to check for some data in it. However, when I need to do the reading through the file's lines, I always get a blank file unless I close the file and then reopen it. While it works, I just don't like having to do this and I want to know why it happens. Is it an issue with subprocess, or another intricacy of the file mode?
dumpFile=open(filename,"w+")
dump = subprocess.Popen(dumpPars,stdout=dumpFile)
dump.wait()
At this point, if I try to read the file, I get nothing. However, it works fine by doing these commands after:
dumpFile.close()
dumpFile=open(filename,"r")
|
You probably need to `seek` back to the beginning of the file, otherwise the file pointer will be at the end of the file when you try to read it:
dumpFile.seek(0)
However, if you don't need to actually store `dumpFile`, it's probably better to do something like:
dump = = subprocess.Popen(dumpPars,stdout=subprocess.PIPE)
stdoutdata,_ = dump.communicate() #now parse stdoutdata
unless your command produces large volumes of data.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, file, subprocess"
}
|
Does mastering a DLC song count towards the "The Complete Package" achievement on Dance Central Spotlight?
Dance Central Spotlight's achievement "The Complete Package" is unlocked after the player **Collect[s] every move in every routine in the game**.
The game comes with 10 songs initially, but more may be purchased as DLC. I've been able to use DLC songs to unlock achievements like "Total Pro", which requires the player to **Unlock all 10 Pro routines**. However, I'm uncertain whether or not the same applies for "The Complete Package". Does collecting every move in every routine in a DLC song count towards unlocking "The Complete Package"?
|
The DLC songs do not count for the "The Complete Package" achievement.
Reading this discussion, the user confirms that only the 10 original songs can be used to get the achievement:
> *NOTE: Some people have asked if DLC helps towards this achievement, IT DOES NOT. I have confirmed this myself. The achievement will only unlock after you have gold boomboxes for all 10 original songs in the game. Getting a gold boombox (collecting all moves for an entire song) on DLC will not work toward this achievement.
It is also confirmed by some other user:
> I can also confirm that the TA description is the Unlocked description. DLC does not count, nor will it interfere, towards this achievement, even if you've played some DLC songs.
|
stackexchange-gaming
|
{
"answer_score": 1,
"question_score": 1,
"tags": "achievements, dance central spotlight"
}
|
what is the meaning of percent symbol(%) and sharp symbol(#) in c++ template
here is the code from MS VC stl:
template<typename _Fun_t,
typename _Arg_t> inline
binder1st<_Fun_t> bind1st(_Fun_t% _Func, _Arg_t _Left)
{ // return a binder1st functor adapter
typename _Fun_t::first_argument_type _Val = _Left;
return (binder1st<_Fun_t>(_Func, _Val));
}
and QT:
#define Q_ARG(type, data) QArgument<type >(#type, data)
|
Neither of these is specific to templates.
The '%' is a Microsoft extension to C++, part of C++/CLI. It defines a tracking reference. A normal lvalue reference variable of type `T&` is a reference to another variable; so is `T%` except it refers to a managed object which might be moved by the garbage collector; the GC knows that when it moves objects it has to patch up all the tracking references to that object.
'#' is the stringify operator of the C preprocessor. It means the value of the following macro argument, surrounded by double quote marks. So this:
Q_ARG(MyType, 12345)
will expand to this:
QArgument<MyType >("MyType", 12345);
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 0,
"tags": "c++, templates"
}
|
SCSS is "&" necessary for targeting nested children?
I'm trying to get a handle on what the & sign does when using it BEFORE a nested element. I using it after targets the parent, but before it seems unnecessary.
This...
ul {
list - style: none;
text - align: left;
& li {
margin - bottom: 17 px;
}
}
Seems to compile to the same as this...
ul {
list - style: none;
text - align: left;
li {
margin - bottom: 17 px;
}
}
|
No, you don't have to always. It depends on the context. The `&` symbol refers to the current element scope, and is generally used for adding pseudo selectors like `:hover`, `focus` etc:
a {
text-decoration: none;
&:hover {
font-weight: bold;
}
}
Compiles to:
a {
text-decoration: none;
}
a:hover {
font-weight: bold;
}
Whereas omitting the `&` before the `:` will result in a wrong selector:
a {
text-decoration: none;
:hover {
font-weight: bold;
}
}
Compiles down to:
a {
text-decoration: none;
}
a :hover {
font-weight: bold;
}
Which doesn't work as intended. You can try out different variations at < without any setup.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "sass"
}
|
Drools rule flow design
I have recently started working on drools. I was just designing a simple application to understand it better.
I have a `.drl` file having a couple of rules in the "when", "then" format. I have designed a flow diagram in a `.bpmn` file(both for the same project). I don't want to set constraints explicitly in my flow diagram.
Is it possible for me to set constraints for my flow diagram in the `.drl` file? So that when I run all processes and rules together, my `.drl` file should set constraints for my `.bpmn`. I tried doing this by using some global variables. I am not happy with the working though. It would be great if anyone can help me out.
Also, is it possible to design my own blocks for rule flow having properties which I am interested in? This is just out of curiosity.
Thank you
|
If you want to evaluate a set of rules in a .drl file in your process, you should use a rule task, where the ruleflow-group attribute of the rule task matches the ruleflow-group rule header attribute (so those rules will activated if the process reaches the rule task node.
If you want to pass in parameters from the process, you should probably use an on-entry script on the rule task to insert the relevant data inside the working memory right before executing the rule. If you want to get results from the rule evaluation, you might want to insert some object (which is a variable in your process) in the on-entry script, in the rule make sure you set the result on that object and then in the on-exit script retrieve that value so you can use if (for example store it in a variable).
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "drools, jbpm"
}
|
Insert line break after each "!" character
Is it possible using CSS3 to insert a line break after a specific character in the HTML? In this case, we need to insert a line break after the exclamation mark `!`. This talks about the `:before` pseudo-element and `content`. Is this possible for putting a newline after an exclamation mark?
|
With pure CSS, it isn't possible to just find all of the exclamation marks on the page. However, if you happen to have everything that ends with an exclamation mark in its own element, you can add a class to it that has some `:after` pseudo-content.
.new-line:after {
content: "";
display: block;
}
Making the `:after` content `display: block` allows the content to take up the whole space of the line, forcing the elements coming after it to the next line. <
However, wrapping everything in a `<span>` isn't the most elegant solution. Not sure what you're working with, but assuming that the exclamation points are at the ends of chunks of text, you could simply just give those chunks a container with `display: block`.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "html, css"
}
|
What is maximum purchaseToken length provided by google after in app purchases in android?
Can anyone tell me the exact length of purchaseToken provided by google after successfull in app purchase in andorid.
|
This token is an opaque character sequence that may be up to **1,000** characters long.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "android, in app billing, android billing"
}
|
One-third neutral and full neutral
This is my first question here; if its not good enough, please let me know. Thanks
For underground cables, we can choose "concentric neutral cable" or "tape shielded cable".
For the first one, it contains 1/3rd sized neutral or full size neutral.
According to the following website:
<
1. 1/3rd sized neutral is used for three phase supply.
2. full sized neutral is used for single phase supply.
What is the difference of the structure between them?
. However, this must be done with care, because if the system becomes unbalanced or the harmonics get out of hand, you will quickly exceed the rating of the neutral conductor.
The "difference in structure" is merely a difference in the size (area) of the neutral conductor.
|
stackexchange-electronics
|
{
"answer_score": 5,
"question_score": 1,
"tags": "power engineering"
}
|
Android Calendar "Grid of Dates"
I am looking for an Android open source Calendar control which displays the full month in a grid, much like a real printed-on-paper calendar. It's for an app to show special days.
Like this from my iPhone version we are porting:
!alt text
|
< that is an open source android calendar very very nice
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 4,
"tags": "android, controls, calendar"
}
|
Matplotlib plot to QtGraphicsView
Having trouble finding a way to embed my matplotlib plot to a QGraphicsView object in this GUI that I'm designing. Should I try converting the plot to a PIL image or is there a way to directly embed a matplotlib plot?
|
I don't really understand your question, if you are trying to display an image on qt graphics, try saving it with the below function first.
plt.savefig('image1.png', transparent = True, bbox_inches = 'tight', pad_inches = 0)
then you can just use pixmap and set scene to display on the graphics view.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, matplotlib, python imaging library, qt designer"
}
|
Why is the inflection point of cubic functions on x=0 when the quadratic term is removed from the equation?
How is this possible and what's its relationship with the second derivative of a cubic equation because the second derivative of a cubic equation, which is $-\frac{a}{3}$ for $x^3+ax^2+bx+c=0$, gives the inflection point on the graph and used as a substitute to solve cubic equations by removing the quadratic term.
Thanks in advance.
|
For the root of any polynomial to be at zero, it must have no constant term. The quadratic term in a cubic provides the constant term to the second derivative.
* * *
The inflection point is the point at which the second derivative is zero. The second derivative of your cubic function is a line: $$f’’(x) = 6x + 2a$$
The root of this line is $-a/3$. To put the inflection point on zero you can do a horizontal shift of the whole function. As suggested by Mohammed, the substitution happens to cancel the quadratic term. This makes sense, as the root of the second derivative of a cubic equation with no quadratic term is a line passing through zero:
$$g(x) = x^3 + \beta x + \gamma$$ $$ g’’(x) = 6x $$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 0,
"tags": "derivatives, quadratics, quadratic forms, cubics"
}
|
How can I find and delete all files in subfolders by matching part of the file name
Windows 10. Photos stored by month like this:
Photos > Year > Month
For example, the photos for December 2011:
Photos > 2011 > 12
There are duplicate files of nearly every photo like this:
IMG_3257.JPG
IMG_3257 (1).JPG
How can I search the entire Photos directory and remove the duplicates containing ' (1)' in the file name? Like this one:
Photos > 2011 > 12 > IMG_3257 (1).JPG
|
Welcome aboard, Jay :-)
If you want a GUI based solution, then:
* download the excellent (and free) Double Commander
* install (or use the portable version) and run it
* navigate to the top directory, beneath which you have your pictures
* press Alt+F7 (or use menu item Commands/Search)
* enter `(1)` as the file name (or `*(1).jpg`, or even `*(*).jpg`)
* when shown the results, click on the button "feed to listbox"
* press Ctrl+A to select all
* press F8 to delete them
If that sounds like a lot of work, it's because I detailed it step by step. In practise, a few seconds will see it done, and you will find Double Commander to be much more useful than the built in Windows Explorer :-)
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 2,
"tags": "windows"
}
|
Is Turing Reduction always in context to decidable languages?
According to Wikipedia's article on Turing Reduction
> It can be understood as an algorithm that could be used to solve A if it had available to it a subroutine for solving B.
Does solving mean always halting (accept/reject)? Should B assumed to be decidable language for the sake of proofs ?
|
Absolutely not. In fact, these are most useful when $B$ is undecidable.
Diagonalization was used to show the Halting problem undecidable, but most other problems were shown to be undecidable through a reduction:
1. Suppose we have a subroutine solving $B$
2. Show that we can use that subroutine to solve $A$.
3. If $A$ is undecidable, then we have a contradiction, so we know $B$ must also be undecidable.
That said, the a proper Turing reduction should always halt. It's cheating if you say "I can use $B$ to make a program that either solves $A$ or runs forever". That's not useful in general.
(Although if you used $B$ to find a recognizer for $A$ where $A$ is not recursively-enumerable, you could show that $B$ is not decidable/recursively-enumerable, depending on your initial assumption about $B$.)
If $B$ is decidable, and you reduce $A$ to $B$, all you've done is create an algorithm deciding $A$. Which is useful, but you don't need a formal notion of reduction to do that.
|
stackexchange-cs
|
{
"answer_score": 3,
"question_score": 0,
"tags": "computability, reductions"
}
|
SRFI reference implementations in Scheme?
I'm interested in broadening my understanding of Scheme and I came accross SRFI 1. I saw mention of a reference implementation, but I can't find it anywhere.
Is there such an implementation, written in some variant of Scheme?
|
SRFI 1's reference implementation is linked to in the "References & Links" section of the document: <
Each SRFI will have its own reference implementation, usually written by the author of the SRFI. Some will work across many Scheme implementations, but there are occasionally reference implementations that only work for one or two Scheme implementations, that you may have to port.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "scheme"
}
|
How do write a rewrite rule in IIS that allows HTML anchors?
Currently I have a rule that doesn't seem to work and I am wondering if I can use html anchors `#` to redirect users
<match url="^article\/article\.aspx$" />
<action type="Redirect" url=" />
<conditions>
<add input="{QUERY_STRING}" pattern="#24" />
</conditions>
|
Hash Tags in the URL serve a special purpose to the client browser, not to the server. That means that a browser will NOT actually send anything after a '#' character to the server. So: if you request ` the server only sees `
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "iis, url rewriting"
}
|
how to get eager loading in a many to many relationships?
I have a database with four tables. TableA and TableB are the main tables and the TableC is the table of the many to many relationships.
* TableA(IDTableA, Name...)
* TableB(IDTableB, Name...)
* TableC(IDTableA, IDTableB)
This create three entities, The EntityA has an ICollection of Entity C and Entity C has a Collection of EntitiesB, so when I try to get the related entities I do this:
myContext.EntityA.Include(a=>a.EntityB.Select(b=>b.EntityC));
But this throw and exception that says that the collection is null.
So I would like to know if it is possible to do an eager loading when there are a table for the many to many relationship.
Thanks.
|
With many to many association in Entity Framework you can choose between two implementations:
* The junction table (C) is part of the conceptual model (class model) and the associations are `A—C—B` (1—n—1). _A can't have a collection of Bs._
* The junction table is not part of the conceptual model, but Entity Framework uses it transparently to sustain the association `A—B` (n—m). A has a collection of Bs and B has a collection of As. This is only possible when table C only contains the two FK columns to A and B.
So you can't have both.
You (apparently) chose the first option, so you will always have to query the other entites through `C`, like
from a in context.As
select new { a, Bs = a.Cs.Select(c => c.B) }
or
from a in As.Include(a1 => a1.Cs.Select(c => c.B))
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "c# 4.0, entity framework 5, eager loading"
}
|
Coredata, cascade delete not working
I have a Coredata app with two entities with a to-many relation from A to B (Basic Teacher/Student, Author/Books, Department/Employee layout). I have set the deletion rules in the model relationship to cascade but it's not working. I can delete an item from A, but the related items from B still remain - thoughts? Per the Apple documentation, everything should work the way I have it setup.
Any thought/pointers would be appreciated.
Thank You.
|
This is one of those "duh" moments...
I was actually dealing with a group of 4 entities that were linked. I discovered in my add method, I forgot to add the relationship item in one of them - so two of the entities were not linked. Added the one line of code and all is good.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "cocoa, core data"
}
|
Understanding Transactions
I am trying to understand all the properties of the transaction object. On the developers site (< they provide the below transaction object:
`{ "expiration": "2018-04-01T15:20:44", "region": 0, "ref_block_num": 42580, "ref_block_prefix": 3987474256, "net_usage_words": 21, "kcpu_usage": 1000, "delay_sec": 0, "context_free_actions": [], "actions": [{ "account": "eosio.token", "name": "issue", "authorization": [{ "actor": "eosio", "permission": "active" } ], "data": "00000000007015d640420f000000000004454f5300000000046d656d6f" } ], "signatures": [ "" ], "context_free_data": [] } `
My **questions** are 1) what context_free_actions is? 2)where are the scope and recipients fields that dan pointed out in this < article? Scope was used so as a block can produced parallel? 3)How this achieved without the scope property?
|
1. Context free actions don't depend on (can't read or modify) the state of the blockchain and can therefore be executed in parallel.
2. Receivers are notified and can "discard" a transaction if they deploy a custom dispatcher (see eosio::on_notify())
3. Scope is already implemented in the state, each table has a scope - but it's not used for multi-threading yet.
|
stackexchange-eosio
|
{
"answer_score": 0,
"question_score": 1,
"tags": "transactions"
}
|
How can I burn an ISO using C#
I have no experience in burning cd/dvd through code. could someone point me out where to start or give an example?
|
Burning and Erasing CD/DVD/Blu-ray Media with C# in this article and forums thread
you can search in google and you can find more.
I hope these links will helps you and how to install IMAP and how to use it
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": -3,
"tags": "c#, image, iso, dvd burning"
}
|
Which open-source C++ projects have good (inspiring) tests?
What are inspiring examples of open-source software written in C++ with great tests?
I would like to read, study and follow.
|
I like mysql's exhaustive test suite, where they add a test for almost every bug they fix to prevent regressions.
|
stackexchange-stackoverflow
|
{
"answer_score": 6,
"question_score": 4,
"tags": "c++, unit testing, testing, open source, tdd"
}
|
Sefer Torah Lishma **not** from the Ben Ish Hai?
Yabia Omer vol. 9 Orah Haim sim. 96:
> גם ראיתי בקובץ "משנת חכמים", (תשרי תש"ס), במאמר מאת הרה"ג עזריאל מנצור (עמוד לה) שכתב, ששאל על זה מאת הרה"ג יעקב מוצפי זצ"ל, ואמר לו, שספר "תורה לשמה" אינו לרבי יוסף חיים.
HaRav Yaakov Muztafi זצ"ל was quoted saying that Sefer "Torah Lishma" is not from the Ben Ish Hai! I am misunderstanding this? Can someone please explain what exactly is going on? This book is _known_ to be from the BI"H.
|
There is a Mahloket between Hacham Ovadia Yosef Shelita (Yabia 9:OH:96) and HaRav Yaakov Moshe Hilel Shelita (one of his biographies of Ben Ish Hai - in the Inyan about "Torah Lishma): Hacham Ovadia (obviously) holds it was not written by Rabenu Yosef Haim. However, Hacham Yaakov Hilel holds it was written by him, and he even adds "ודלא כאלה שפקפו בזה".
|
stackexchange-judaism
|
{
"answer_score": 4,
"question_score": 7,
"tags": "jewish books, rabbis, authorship, hacham ovadia yosef"
}
|
CSS Align logo same height as text
How can I align the logo and the text link next to it on the same height? Is this something done with `display: inline-block;` ?
a {
text-decoration: none;
color: blue;
}
<nav>
<a href="google.be"><img alt="logo" src=" wikipedia</a>
</nav>
|
You can use flexbox, as noted in another answer. You can also use the `vertical-align` property
a {
text-decoration: none;
color: blue;
}
img {
vertical-align: middle;
}
<nav>
<a href="google.be"><img alt="logo" src=" wikipedia</a>
</nav>
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 0,
"tags": "html, css, hyperlink, css position, text align"
}
|
Remove multiple values of data in filter using macro
Suppose I have a set of data and i want to filter the column date. I have another macro that can generate the values of date (value to be filtered). the value is multiple values of date and can be different value every time (but in same format). the expected result will be the the filtered source table.
so I want to apply those value in my date column using macro. is there an efficient way to do?
source data and expected result as below !source data and expected result
|
The most efficient way is **filter**. But the format of your `value to be filtered` have to be changed.
I use `AdvancedFilter` method.
Sub test()
Range("A1:C8").AdvancedFilter _
Action:=xlFilterCopy, _
CriteriaRange:=Range("F1:G2"), _
CopyToRange:=Range("I1:K1"), Unique:=False
End Sub
then

alert("Condition met!")
else
alert("Condition not met!")
However it is highly recommended that you always use braces because if you (or someone else) ever expands the statement it will be required.
This same practice follows in all C syntax style languages with bracing. C, C++, Java, even PHP all support one line statement without braces. You have to realize that you are only saving **two characters** and with some people's bracing styles you aren't even saving a line. I prefer a full brace style (like follows) so it tends to be a bit longer. The tradeoff is met very well with the fact you have extremely clear code readability.
if (cond)
{
alert("Condition met!")
}
else
{
alert("Condition not met!")
}
|
stackexchange-stackoverflow
|
{
"answer_score": 254,
"question_score": 216,
"tags": "javascript"
}
|
prove that $\forall N \in \mathbb{N}$, there is a $n\in N$ such that the prime gap $g_n = p_{n+1} - p_n$ > N.
prove that $\forall N \in \mathbb{N}$, there is a $n\in N$ such that the prime gap $g_n = p_{n+1} - p_n$ > N.
I tried using induction but i can't seem to get it right. Are there any other tricks to try solving this problem rather than proof with induction?
for $N = 1$ we can obviously take $n = 2$, for we get $p_3 - p_2 = 5-3 = 2 > 1$
suppose it's true for m numbers, is it than true for m+1? I don't seem to understand how to go further here....
Kees
|
Look at the sequence
$$\\{N!+2,N!+3,\cdots,N!+N-1,N!+N\\}$$
We have for $k\in\\{2,\cdots,N\\},\,k|N!+k$, so all the numbers in the above set are composite number so if $p_n$ is the largest prime $\lt N!+2$ and $p_{n+1}$ the next prime $p_{n+1}\gt N!+N$ and so $p_{n+1}-p_n\geq N$
|
stackexchange-math
|
{
"answer_score": 2,
"question_score": 1,
"tags": "number theory"
}
|
Redrawing GradientButton (Subclassed from UIButtons)
I am using the GradientButton class in my application. When I change the frame of a button the CAGradientLayer doesn't change for the new frame. The CAGradientLayer is the size of the old frame dimensions which makes the button look really poor. The added width or height then is just a solid color and doesn't have the Gradient. One solution would be to delete the button and re-add it, however this is not the path I want to take. Is there a method that I can call to redraw the GradientButton so that the gradient layer encompasses the new button dimensions?
Update: `removeFromSuperview` and `addSubview` doesn't fix issue.
|
Created this method to solve problem:
- (void)setFrame:(CGRect)frame {
[super setFrame:frame];
shineLayer.frame = self.layer.bounds;
highlightLayer.frame = self.layer.bounds;
}
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "uibutton"
}
|
Convert points to lines in fsharp
I have several points that I want to convert to lines. for example `[{x=0; y=0}; {x=1; y=1}; {x=2; y=2}; {x=3; y3}]` should be converted to `[({x=0; y=0}, {x=1; y=1}); ({x=1; y=1}, {x=2; y=2}); ({x=2; y=2}, {x=3; y=3})]`.
my current approach is like this:
type Point = { x: int; y: int }
type Line = Point * Point
let rec pointsToLines lines points =
if (List.length points) < 2 then
lines
else
let line = points.[1], points.[0]
let lines = line :: lines
pointsToLines lines (List.tail points)
So my question would be, is there one-liner or an idiomatic way to achieve the same thing?
|
You could write it like this for more idiomatic F#:
let rec pointsToLines points =
let rec loop lines points =
match points with
| x::y::rest -> loop ((x,y)::lines) rest
| _ -> lines
loop [] points
However, this already one of the built in functions as you suspected:
List.pairwise
Both will give you the same results.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 1,
"tags": "f#"
}
|
How to prevent automatic insertion of a blank line at the beginning of a `justify` environment of `ragged2e` package?
Blank line is always generated at the beginning for some reason. I need to get rid of it.
 inside the node text. But then you have to use a `\par` at the end of the text.
\documentclass[border=0.5mm]{standalone}
\usepackage{ragged2e}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path node[draw,text width=3cm,align=justify]
{\justifying this is just some text this is just some text this is just some text\par};
\end{tikzpicture}
\end{document}
|
stackexchange-tex
|
{
"answer_score": 3,
"question_score": 2,
"tags": "ragged2e"
}
|
Importance of Critical region and Monitors as Synchronization mechanism
I read in many text books that critical region and monitors are high-level language mechanisms to provide synchronization mechanism.
I couldn't find a simpler explanation about these in any text. I have some doubts on these.
How compiler actually implements these?
Whether these things are available in C, Java, Python . . ?
What is the importance of conditional constructs in monitors and critical region (conditional critical region)
|
In java, monitors are a built-in element of the language. They are accessed by the `synchronized` keyword, and have several functions related to them (such as `wait()`). You can google it to find out more about it.
Regarding how it is implemented, There are several algorithms that implement monitors, with different pros and cons. If you are interested in this, allow me to recommend Herlihy and Shavit's book - the art of multiprocessor programming.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "synchronization, operating system, theory, critical section"
}
|
Q: tableView created by storyboard running appears space form the top to the first cell
Create the `tableView` in the `storyboard`, and set the constraints to arrive the all around. But when running on simulator, there appear some space form the top to the first cell.
The issue on simulator:
 {
if (e.Row.RowType == DataControlRowType.DataRow) {
HtmlGenericControl div = (HtmlGenericControl)e.Row.FindControl("yourDiv");
div.Attributes.Add("class", "ClassYouWantToAdd");
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -2,
"tags": "c#, html, asp.net, gridview, itemtemplate"
}
|
Encapsulate intersect type into interface
I see myself writing the following everywhere:
product: Product & { id: string; };
How do I write an interface, so that instead I can write
product: WithId<Product>;
I tried something like this, but the compiler doesn't like extending from generics:
export interface WithId<T> extends T {
id: string;
}
|
You can use a type intersection
export type WithId<T> = { [K in keyof T]: T[keyof T] } & { id: string }
interface product { myNew: string }
let et: WithId<product> = { myNew: "s", id: "s" } // ok
let et: WithId<product> = { test: "s", id: "s" } // error
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 2,
"tags": "typescript"
}
|
Why does bigger text push content to the left down?
So I made four simple divs and I will be changing the property of the header div.
**The HTML:**
<div class="third">
Lorem Ipsum
</div>
<div class="third">
Lorem Ipsum
</div>
<div class="third">
<div class="header">Lorem Ipsum</div>
</div>
**The CSS:**
.third {
width:500px;
display:inline-block;
border-right:1px solid black;
height:400px;
}
.header {
margin-left:16%;
font-family:Arial;
font-size:200%;
}
The third div works great but the first two divs are pushed down because of the bigger text. What can I do to prevent this issue?
|
Adding `vertical-align: top` will fix your problem.
Fiddle: <
If you're curious why this works, andyb does a great job explaining why here: Why does this inline-block element have content that is not vertically aligned
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "html, css"
}
|
What is the most efficient way to create a pixelated game with Kivy?
This is a simple example of how I draw a pixelated image in my game:
SCALE = 6
class MyApp(App):
def build(self):
parent = Widget()
texture = self.load_some_texture()
texture.min_filter = 'nearest'
texture.mag_filter = 'nearest'
with self.canvas:
PushMatrix()
Scale(SCALE)
self.pixelart = Rectangle(texture=texture, pos=(0, 0), size=(64, 64))
PopMatrix()
return parent
**Is this the best and most efficient way to make a pixelated game in Kivy? If not, what is?**
|
with self.canvas:
Scale(6)
self.pixelart = Rectangle(texture=texture, pos=(0, 0), size=(64, 64))
I think you're fighting the widget system a bit - instead of doing this, why not leave out the scale, set the Rectangle pos/size to the widget pos/size (and make a binding so that it follows the widget pos/size when they change), and then set the widget pos and size to change everything at once. This way the widget will work as expected, as everything tracks it. Or if you want the button to be a widget that behaves normally, you could put your pixel drawings in a different Widget that doesn't have any normal behaviour of its own.
For resetting scale (and other matrix instructions), you can put your scale changes between `PushMatrix` and `PopMatrix` canvas instructions.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python 3.x, kivy, pixel"
}
|
C# namespaces in web.config
Coming from a VB background and being forced to learn C# I have hit the first hurdle.
In VB i could put all the namespaces I wanted available across the entire app in the web.config file and it would be available in each code behind file without me having to add import statements.
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Generic"/>
It seems Visual Studio can't do this with C# and I have to add using statements all over the place.
Please tell me I'm missing something obvious and there is a way to get this done.
|
For C#, the namespaces entered in the web.config will be recognized in .aspx files, but not codebehind. I don't think it will take you long to adjust (Ctrl-. will let you quickly add a namespace when you type a class name that doesn't have the namespace referenced).
|
stackexchange-stackoverflow
|
{
"answer_score": 8,
"question_score": 5,
"tags": "c#, web config"
}
|
Exchange 2019 Has begun to behave strangely - Socket errors in Receive logs
I have a Exchange 2019 server that has been running perfectly for a good long time. For the last couple of days it has randomly started not receiving email, although you can still send and all the clients on both POP3 and IMAP can still connect.
In the receive logs the following error occurs for each email :-
Message or connection acked with status Retry and response 451 4.4.397 Error communicating with target host. -> 421 4.2.1 Unable to connect -> SocketConnectionRefused: Socket error code 10061.
Then all of a sudden after a random time it starts receiving again all by itself.
Now from my point of view I have changed nothing in the configuration, and have been unable to get to the bottom of the cause.
Any help gratefully appreciated.
|
Ok so I flattened the whole thing and started again - that seems to have fixed it!
|
stackexchange-serverfault
|
{
"answer_score": 0,
"question_score": 0,
"tags": "exchange 2019"
}
|
Little puzzle about intersections of Schubert cells.
I was reading chapter 6 in the book of Harris on Algebraic geometry and came to the following puzzle.
It seems to me that every Schubert cell in a Grassmanian is obtaining by cutting the Grassmanian by a certain plane in its Plucker embedding (hope this is correct, I got this idea from Harris' book)
Now, I was thinking always, that there is a whole theory of Littlwood Richardson coefficients that explains the intersection theory of Grassmanian and in particular explains what are intersection numbers of various cells.
**My question is as follows.** Why do we have this complicated theory of Littlwood Richardson coefficients? (is this because Schubert cells don't always have expected dimension ?) Naively, if all Schubert cells were obtained by intersecting Grassmanian transversally by some planes the only number that would pop up would be the degree of Grassmanian in its Plucker embedding.
|
Precisely as you say, the intersection is almost always not transverse.
For example, think about $G(2,4)$. It is the quadric $p_{12} p_{34} - p_{13} p_{24} + p_{14} p_{23} =0$ in $\mathbb{P}^{\binom{4}{2}-1}$. There are two codimension $2$ Schubert cells: One of them is given by $p_{12}=p_{13} = p_{23}=0$ and the other is given by $p_{12}=p_{13}=p_{14}=0$. In each case, we are using $3$ linear equations to cut out something which is codimension $2$. If we just interesect $G(2,4)$ transversely with a codimension $2$-plane, we get something whose cohomology class is the sum of these two classes; if we intersect $G(2,4)$ with $p_{12}=p_{13}=0$ then we literally get the union of these two cycles.
|
stackexchange-mathoverflow_net_7z
|
{
"answer_score": 10,
"question_score": 6,
"tags": "ag.algebraic geometry, grassmannians"
}
|
Grunt dynamic mapping configuration to output one file
Is it possible using the dynamic mapping configuration to output one minimized file instead of one per src file?
cssmin: {
target: {
files: [{
expand: true,
cwd: 'release/css',
src: ['*.css', '!*.min.css'],
dest: 'css/finalfile.css',
ext: '.min.css'
}]
}
}
This configuration creates folder named css/finalfile.css and generates one output file per one src file.
Any help appreciated.
|
You can use standard file config to do that.
cssmin: {
target: {
files: {
'output.css': ['app/**/*.css']
}
}
}
Above will minify and concatenate all the CSS files from app directory into output.css
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "gruntjs"
}
|
neo4j number accuracy
i am currently using neo4j-community(2.2.2) and found that this cypher query does not work as one expect:
CREATE (n:Node {some_attribute:602867661010247681}) RETURN n
and at the end you found that on the node that was just created, that property has the value _'602867661010247700'_. I dig about this issue, but did not found any documentation or feasible solution to this, anyone knows if is something that has not been properly configured on my neo4j default installation?
Thanks in advance.
|
The problem is the Neo4j Browser messing up the value when displaying it.
If you check the node created via the Neo4j shell, you'll find that it has been saved with the correct value.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "neo4j"
}
|
call python module functions from command line
I would like to know if there is a way to call module functions from the command line. My problem is that I have a file package called find_mutations. This requires that the input files are sorted in a specific way, so i made a function to do so. I would like the user to be able to have the option to run the code normally:
$ python -m find_mutations -h
or run the specific sort_files function:
$ python -m find_mutations.sort_files -h
Is something like this possible? If so, does the sort_files function need to be in its own strip? Do I need to add something to my `__init__.py` script? The package install properly and runs fine, I would just like to add this.
|
You could add flags to run the function. The following example is not a good way to work with command arguments, but demonstrates the idea.
import sys
if __name__ == "__main__":
if '-s' in sys.argv:
sort_files()
Add a flag to run the specific function, in this case `-s` to sort the files.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "python, function, module, distutils, setup.py"
}
|
How do I stop a daemon when the user logs out?
I wrote a daemon in C++ which is automatically started on login using a bash script placed in `/etc/profile.d/` while running the `install` section of my makefile. The problem is that when I log out and log back in, there are now two instances of the daemon running.
What I would have liked is for the first one to stop when I logged out, not keep going. It's only meant to run while somebody is logged in, anyhow. How do I make sure my daemon is not still running after I logout?
|
If you're using D-Bus in your application, you could listen for the SessionOver signal on the org.gnome.SessionManager interface. With C++ Qt5, your code would look something like this:
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.connect("org.gnome.SessionManager", "",
"org.gnome.SessionManager", "SessionOver",
this, SLOT(handle_sessionOver());
References:
* GNOME session manager documentation
* QDBusConnection class (don't forget to add "QT += dbus" to your qmake)
|
stackexchange-askubuntu
|
{
"answer_score": 2,
"question_score": 1,
"tags": "programming, services, logout"
}
|
C++ STL for_each should take pointer to member function taking one argument
I have to pass the address of a member fn taking one argument to the std::for_each. how do i do this?
class A{
void load()
{
vector<int> vt(10,20);
std::for_each(vt.begin(), vt.end(), &A::print);
//It didnt work when i tried mem_fun1(&A::print)
}
void print(int a)
{
cout<<a;
}
};
Thanks
|
When using std::mem_fun, you have to pass pointer to class as first argument. You can bind it in this case with std::bind1st.
class A
{
public:
void print(int v) {std::cout << v;}
void load()
{
std::vector<int> vt(10, 20);
std::for_each(vt.begin(), vt.end(), std::bind1st(std::mem_fun(&A::print), this));
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 4,
"question_score": 2,
"tags": "c++, stl"
}
|
create mysql query from a colum in a second table
I have a piece of code that should get the names of food items that are not ingredients from one table and then generate a query to create another table with columns matching the names of those items this is not generating a table:
function create_table(){
$query = "SELECT * FROM food";
$tablequery = "CREATE TABLE (id int(6) NOT NULL auto_increment,";
if($result=mysql_query($query)){
while($row = mysql_fetch_array($result)){
if($result['ingredient'] != 1){
$tablequery = $tablequery.$result['name']."varchar(30) NOT NULL,";
}
}
$tablequery = $tablequery."PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
}
mysql_query($tablequery);
}
I did call the function so that is not the problem and somehow it worked once but with just the id.
|
Try this:
while($row = mysql_fetch_assoc($result)){
if($row['ingredient'] != 1){
$tablequery = $tablequery.$row['name']."varchar(30) NOT NULL,";
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, mysql"
}
|
to show a dialog: what is the difference of use messageBox and create a view and a view model in MVVM pattern?
I have always read that is not a good solution to use in the view model the messageBox to show a dialog when it is used the MVVM pattern.
Show I think that the other solution is create a view and a view model that is create in my main view model and related the view and the view model of the dialog. Additionally, I need to create a class that is passed from the main view model to the dialog view model that is returned as result of the dialog.
But really the second way is better? what is it the difference? because in both cases I need to wait until the result of the dialog.
Or both of t he solutions are a bad option?
Thanks.
|
In my opinion, creating a ViewModel for a MessageBox is overkill. I'd create an interface for ViewModels with a ShowMessage event, and an attached behavior with an attached property that can bind to the ViewModel, register a listener for the ShowMessage event, and opens a MessageBox when the event is raised. The result of the message box could be passed through the EventArgs.
The difference here would be that you can encapsulate the interface and the attached behaviour in a reusable component, and that you need minimal code in the ViewModel to use it.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "wpf, mvvm, dialog"
}
|
Gephi: increase maximal zoom
I want to use gephi to plot a huge network with ~5.500 notes. I would like to see more of the network structure, thus I use Force Atlas with a large _Repulsion Strength_. Unfortunatly, at some point when I zoom out, a mystical square appears which seem to be the limit size of gephis network-window: .click(function() {
$("#status").html("<p>Please Wait! TESTING</p>");
$.ajax({
url: 'go.php?ab=1',
success: function(data, textStatus, xhr) {
alert (data);
}
});
});
How can I adapt this so if I have 4 more buttons each button uses the function, calls the same page but uses unique values ?
EG :
<input type="button" id="update" value="update" /> Calls go.php?up=1
<input type="button" id="new" value="new" /> Calls go.php?new=1
etc...
Thanks
|
Give your buttons the same class and call the code using the class name, and add a data attribute to each button to retrieve the seperate values.
Give this a try:
<input type="button" class="clickButton" data-value="go.php?up=1" value="Update" />
<input type="button" class="clickButton" data-value="go.php?new=1" value="New" />
$(".clickButton").click(function() {
$("#status").html("<p>Please Wait! TESTING</p>");
$.ajax({
url: $(this).attr("data-value"),
success: function(data, textStatus, xhr) {
alert (data);
$(this).prop('value', 'New Text');
}
});
});
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "php, jquery, ajax, button, load"
}
|
How to copy a file from a local machine to a linux server using bash
I have a file on my local machine and want to copy it to the Linux server. I know I can do this online(through mail or dropbox for example), but think that there must be easier ways to do so. Is there a Bash command to do this right from the linux server?
|
`scp` (secure copy; part of ssh) is what is commonly used for this.
scp myfile.txt [email protected]:/path/on/server/
Note that like most Unix commands, `scp` is a general Unix command, not specifically a `bash` built-in command. It can be invoked from any shell, not just `bash`.
|
stackexchange-superuser
|
{
"answer_score": 2,
"question_score": 1,
"tags": "linux, bash, virtual machine"
}
|
Converting a Pandas dataframe to dictionary
I have a Pandas Dateframe:
+-----------+-------+---------+
| kpi_name | coeff | measure |
+-----------+-------+---------+
| messi | 2 | DoD |
| ronaldo | 1.5 | MTD |
| del_piero | 2 | MTD |
+-----------+-------+---------+
I need to convert this to a dictionary like :
{'MTD':[{'KPI':'ronaldo', 'measure':'1.5'}, {'KPI:':'messi', 'measure':'2'],
'DoD':['KPI':'messi', 'measure':'1.4']}
I am trying:
a = df.groupby('measure').apply(lambda x: x.to_dict('list')).to_dict()
My output:
{'MTD': {'kpi_name': ['ronaldo', 'del_piero'], 'coeff': [1.5, 2.0], 'measure': ['MTD', 'MTD']}, 'DoD': {'kpi_name': ['messi'], 'coeff': [2.0], 'measure': ['DoD']}}
Thx a lot of help!
|
Please look into slicing dataframes and transpose `T` for future reference.
Given a dataframe
df = pd.DataFrame({'KPI':['messi', 'ronaldo', 'del_piero'],\
'coeff':[2, 1.5, 2], \
'measure':['DoD', 'MTD', 'MTD']})
You can use the following lambda function
df.groupby('measure').apply(lambda x: list(x[['KPI','coeff']].T.to_dict().values())).to_dict()
To achieve your expected output
{'DoD': [{'KPI': 'messi', 'coeff': 2.0}],
'MTD': [{'KPI': 'ronaldo', 'coeff': 1.5}, {'KPI': 'del_piero', 'coeff': 2.0}]}
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 1,
"tags": "python, pandas, dictionary, dataframe"
}
|
HTTPDebuggerPro doesn't save response contents
I'm using HTTPDebuggerPro on Win 7 x64 and the problem is, it doesn't save response contents for some of the response bodies. Is there a way to fix it?
I've tried Charles... it's so lame, you need to configure an app to use it's localhost proxy and it can't preview received html, so no this app isn't worth using imho. By the way maybe one can recommend me another http monitor having html preview tool and working correctly under this OS?
|
Fiddler (www.fiddler2.com) is free, and can fully save any HTTP/HTTPS traffic.
If you want to preview the rendered HTML, use the "WebView" addon.
|
stackexchange-superuser
|
{
"answer_score": 0,
"question_score": 0,
"tags": "windows 7, sniffing"
}
|
Cumulative cost upstream a raster stream network with GRASS
I have a river network in raster and locations of many dams on the river.
 and then use that map the following
r.watershed elevation=dem flow=dam_raster_map accumulation=cumulative_dams
This approach accumulates all the dams in downstream direction (along the flow path). Assuming all your points of interest (blue points) are on the stream raster (i.e. same caveat as in Micha's approach: the target "random cell" must lie exactly on the stream network) then you could just use an `r.mapcalc` approach to only get the info from your new cumulative_dams map at your blue points or you could use `r.to.vect` to sample the raster at specific vector points.
|
stackexchange-gis
|
{
"answer_score": 1,
"question_score": 0,
"tags": "raster, grass gis, upstream"
}
|
Netbeans Profiler: Connecting to the target vm forever
I am trying to attach the Netbeans profiler to my Java project but it get stucked with `Connecting to the target vm`.
I found this old bug report but that is already fixed. My version is 7.1.2 with Java 1.7.0_04 on windows 7.
I tried to disable the firewall and start Netbeans as administrator but still i got the same problem.
A bit strange is that calibration works fine.
I have the feeling it's a problem with Java 7. Because if I have look into `profiler\lib\deployed` there is no jdk17 folder. Only jdk16 and jdk15.
Any thoughts?
|
I found out the profiler works if I attach it dynamically. Therefor you have to start the application first (with a break point). Then you click Profile > Attach Profiler... In the top select your project and attach a local dynamical profiler. If you already created the wrong one you can change it at the bottom of the Attach Profiler dialog. Now select the running process and that's it.
|
stackexchange-stackoverflow
|
{
"answer_score": 14,
"question_score": 17,
"tags": "java, netbeans, profiler, java 7"
}
|
how do I convert text to integer in Java
I am trying to figure out how to convert text from text fields into intergers in Eclipse. here is what I have so far, and it's been a few days since I have worked on this program and I am also new to java coding. If I have the code I need in here already, I apologize in advance for asking this question.
protected void do_enterButton_actionPerformed(ActionEvent arg0) {
int scr1, scr2, scr3 = -1;
TestScores score = (TestScores)studentList.getSelectedValue();
int score1 = Integer.parseInt(score1TextField.getText());
score.setScore1(score1);
int score2 = Integer.parseInt(score2TextField.getText());
score.setScore2(score2);
int score3 = Integer.parseInt(score3TextField.getText());
score.setScore3(score3);
if (score1TextField != null) {
// this is where I need to convert to text to integer
}
|
`score1` is where you already did the conversion. `Integer.parseInt(score1TextField.getText());` was correct.
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": -3,
"tags": "java"
}
|
Finding location of mongo source on Alpine linux
I'm in an Alpine container and wish to find the location where `apk add mongodb` installed the mongo source code.
I tried installing some packages for locating files (`whatis`, `whereis`, `locate`...) but none came down with a simple `apk add $PACKAGE` so I'm not sure how best to search around.
Does anyone know how I can quickly find the path to the Mongo source in Alpine linux?
|
As far as I know, `apk` packages don't generally contain source code, but rather pre-compiled binaries. The contents of the `mongodb` package can be found here.
The log file associated with the latest build of the package indicates that the source was pulled down from < by the build machine, but I wouldn't expect those contents to be present on a machine that just `apk add`s the `mongodb` package.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "linux, docker, alpine linux, locate"
}
|
Phase velocity greater then the speed of light?
It is my understanding the the phase velocity of a wave can be greater then the speed of light. So imagine we had a wave packet consisting of a single sinusoidal wave; $$y=\sin(\omega t-kx)$$ Then from the definition of phase velocity, this wave will (if I am not mistaken) travel with the phase velocity, which as stated above can be greater then $c$. But in this case information is been passed greater then the speed of light, is it not? If we start the wave packet of at a point $A$ say and let it propagate to another point $B$ it will travel to $B$ faster than the speed of light and pass of the **information** of its frequency and wavelength. Why is this not breaking special relativity?
|
The simple answer is that the wave packet travels at the group velocity not the phase velocity, and the group velocity is always less than or equal to $c$.
You might argue that you aren't using a wave packet. For example you might argue that you are just turning the light on and waiting for it to get to the point $B$. However any modulation of the wave intensity, including turning it on and off, will propagate at the group velocity.
|
stackexchange-physics
|
{
"answer_score": 6,
"question_score": 5,
"tags": "special relativity, waves, faster than light, phase velocity"
}
|
Filling a PictureBox of Type Rectangle, C++ WINAPI
I'm recreating an application that mimics the Windows Color Editing Dialog (ie from Paint), for study purposes.
<
I created an identical looking Dialog, using PictureBox(es) as the "color containers". I set the PictureBox type to "Rectangle", I figured it would be easier to use a LOGBRUSH to fill a Rectangle Object; instead of setting the PictureBox to type "Bitmap" and setting every pixel of the bitmap to the necessary color.
The issue I am having is... I don't know how to use the HWND of the PictureBox Control with the LOGBRUSH, to fill it.
I was having trouble finding the PictureBox Notifications and Messages to communicate with the Control.
Can anyone give me some insight in how to communicate correctly with the PictureBox Control?
|
Use a static control with SS_SIMPLE style and no text. Then handle WM_CTLCOLORSTATIC message in the parent window. The parent window can then return the brush which the system uses to paint the background. Remember that its your responsibility to free the brush unless its a system brush. i.e if you have created the brush using CreateSolidBrush or similar functions, then you need to free the brush once it is no longer used, otherwise it will lead to GDI objects to leak. For the implementation you are proposing, you can have an array of brush handles created while initializing the dialog and supply appropriate brush for a particular box in response to WM_CTLCOLORSTATIC. And when the dialog box is about to destroy, you can free the brush handles.
Another way to implement is to create a custom control which only saves the colors for various boxes in an array in the window's private data, and draw them manually in response to WM_PAINT.
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "c++, winapi, picturebox"
}
|
Case with Select and Null Check
select a.AgentId,
case(select acs.IsConnected
from rmm.tblAgentConnectionStatus acs
where acs.AgentName = a.AgentName)
when 1 then 'True'
when 0 then 'False'
when null then 'False'
end as ConnectionStatus
from Sentilan2.rmm.tblAgent a
order by AgentName asc
I have the above, but it results in ConnectionStatus being null when their is no corresponding row in `tblAgent`.
Is it possible for the result to be `False` when the column is null.
Current output
AgentId ConnectionStatus
010D0206-5D8C-4AB1-90B6-7BD0C2773E22 True
CA4C48DD-3D2E-4948-9F93-254CDF081658 True
1DB90EE5-D96A-4071-8F51-26B3130EC6D4 NULL
ACA694D0-0C1D-45BA-80DD-273F41BD70B1 NULL
941B539B-7CA0-4472-ABCD-2777AE8B2E5D NULL
1E7DDA4D-C119-4E47-8478-277952024FD1 NULL
I'd like those nulls to be false.
|
You could use `coalesce()` or `isnull()` to substitute a value for `null`:
select a.AgentId,
case coalesce((select acs.IsConnected
from rmm.tblAgentConnectionStatus acs
where acs.AgentName = a.AgentName),0)
when 1 then 'True'
when 0 then 'False'
end as ConnectionStatus
from Sentilan2.rmm.tblAgent a
order by AgentName asc
Or just `else 'False'`:
select a.AgentId,
case (select acs.IsConnected
from rmm.tblAgentConnectionStatus acs
where acs.AgentName = a.AgentName)
when 1 then 'True'
else 'False'
end as ConnectionStatus
from Sentilan2.rmm.tblAgent a
order by AgentName asc
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "sql server, tsql, sql server 2012"
}
|
Real time Search /count occurence in VBA?
I was wondering, is there a way to create a real time search and count method in vba? (like webbrowser ctrl f) I add a textbox on my worksheet and add this code to realise a search :
ActiveWindow.ScrollRow = Cells.Find(TextBox1.Value, searchorder:=xlByRows, searchdirection:=xlNext).Row
That allow me to go to the first occurence on my document. What i want is counting the remaining occurence and navigate through using button. So i add a count code :
count = 0
With ThisWorkbook.Worksheets(1).UsedRange
Set Loc = .Cells.Find(TextBox1.Value)
Do Until Loc Is Nothing
Set Loc = .FindNext(Loc)
count = count + 1
Loop
End With
The problem i have is, it's slow and make my excel freeze if too much occurences are found (i work on a large file). Is There a better way to realise this kind of stuff?
Thanks!
|
`WorksheetFunction.CountIf` is much faster.
## Exact Match
WorksheetFunction.CountIf(ThisWorkbook.Worksheets(1).UsedRange, TextBox1.Value)
## Count cells containing string value
WorksheetFunction.CountIf(ThisWorkbook.Worksheets(1).UsedRange, "*" & TextBox1.Value & "*")
Reference: MSDN - WorksheetFunction.CountIf Method (Excel)
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 2,
"tags": "vba, excel"
}
|
Filtering on multiple values from a single field - Django
myprefs = aboutme.mypreferences_set.all()[0]
mygpref = myprefs.MyGPref.all()
mygpref has a range of values and I'd like to return a QuerySet based on on these filters. I don't know how many values there may be in mygprefs. Might be one or two. How should I build a filter the pythonic way without lots of if and thens - I tried the below but this does not work for multiple values exist in mygpref.
mylist = AboutMe.objects.all().filter(MyG=mygpref)
How to do this elegantly?
|
I think I had forgotten about this:
mylist = AboutMe.objects.all().filter(MyG__in=mygpref)
This seems to work..
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "python, django"
}
|
Easiest way to play video?
EDIT: If your havng my problem, please watch this: <
I have a `JFrame` setup for my game, I'd like to play a quick video before my game loads. How would I go about playing the video the easiest way?
The video should not include controls etc, just the video so my whole frame should be the video!
I've read other topics on this and they dont seem to help... at all D:
I'm not the best Java programmer so don't expect me to know every API and how to use them.
|
You can use VLCJ to play video, and you can use this link to add the video to jpanel which you can show on startup : <
|
stackexchange-stackoverflow
|
{
"answer_score": 0,
"question_score": 0,
"tags": "java, swing, video, jframe, codec"
}
|
trigger event in angular using command?: (event?: any) => void;
I am new to angular and using primeNg MenuItem which has the following property
command?: (event?: any) => void;
I want that once the relevant item is clicked an activity will be created (even just set a flag to true ) this looks simple but I couldn't find information or an example.. thank you
|
`(event?: any) => void` simply means that it's a function that takes an optional parameter `event` (which is of type `any`) and doesn't return anything (it's `void`).
Here's how you define it:
this.items = [
// ... other items ... //
label: 'Create activity',
icon: 'fa fa-plus',
command: (event) => {
// Create activity and set flag to true here
}
// ... other items ... //
]
Here's the documentation for it: <
Not sure what you wanted help with, but I hope this helps.
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": -1,
"tags": "angular"
}
|
CSS selector help for below structure
I have to find the anchor "a" nested under table with class as `table.ic-table-creditReportProduct table tr`. I tried but doesn't seem to work. Any ideas where the problem might be or another way to reference it.
**NOTE** : I can't use the id's that have **j_idt** in them as they are auto generated.
!enter image description here
|
table.ic-table-creditReportProduct table tr a
should work.
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 0,
"tags": "css, selenium, css selectors, spock, geb"
}
|
How to implement a function that will take a list of strings and parse them into a list of tuples
I'm trying to create a new function that runs a list of string measurements through a parsing function `parse_measurement` and returns a list of tuple values. For example if I enter `parse_measurement(["1 ft", "8 ft", "3.3 meters"])` I would want to return `[(1, 'ft'), (8, 'ft'), (3.3, 'meters')]`.
This is my parse_measurement function. It will parse a single string into a tuple. i.e. `"3 ft"` outputs to `('3', 'ft')`.
def parse_measurement(measure_value: str):
tuple_value = tuple(measure_value.split(' '))
return tuple_value
Goal Output: `[(1, 'ft'), (8, 'ft'), (3.3, 'meters')]`
|
Your question is unclear on what you really want, so I'm assuming this is the actual problem. Starting from the statement in which you said that you needed something that looks like this : `parse_measurement(["1 ft", "8 ft", "3.3 meters"])`, and following up on it :
In the following code :
* I take the list of strings
* loop over each str measurment
* Separate and _parse_ the values as needed
* Append the results as a tuple into the final list.
* And finally return the final_list
def parse_measurement(measure_values: list):
final_list = []
for m_value in measure_values:
measure, unit = m_value.split()
measure = float(measure)
final_list.append((measure, unit))
return final_list
print( parse_measurement(["1 ft", "8 ft", "3.3 meters"]) )
# [(1.0, 'ft'), (8.0, 'ft'), (3.3, 'meters')]
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": -1,
"tags": "python"
}
|
Conda fails to build on Julia 1.0
Trying to add and build Conda results in the following error:
 pkg> add Conda#master
(v1.0) pkg> build Conda
|
stackexchange-stackoverflow
|
{
"answer_score": 1,
"question_score": 0,
"tags": "build, julia, conda"
}
|
Spock: PollingConditions expect exception to eventually be thrown
I'm trying to use `PollingConditions` to expect that an exception will eventually be thrown.
then:
new PollingConditions(timeout: 3, initialDelay: 0.1, delay: 0.1).eventually {
sasClient.getSASToken(pod, targetServiceType)
thrown(NotFoundException)
}
but this causes Groovy to complain with: `Groovyc: Exception conditions are only allowed as top-level statements`
Is it possible to test that an exception will eventually be thrown?
|
Maybe GroovyAssert can help you, try this:
new PollingConditions(timeout: 3, initialDelay: 0.1, delay: 0.1).eventually {
GroovyAssert.shouldFail(NotFoundException) {
sasClient.getSASToken(pod, targetServiceType)
}
}
|
stackexchange-stackoverflow
|
{
"answer_score": 3,
"question_score": 3,
"tags": "groovy, spock"
}
|
Radio button trigger with Javascript
I have two radio buttons and I need first radio button to be check after window load with Javascript. By using its class automatically need to be triggered
|
Try the following way:
function manageRadioButton() {
var x = document.getElementsByClassName("radio");
x[0].checked = true;
}
<body onload="manageRadioButton()">
<input type="radio" class="radio" name="gender" value="male"> Male<br>
<input type="radio" class="radio" name="gender" value="female"> Female<br>
</body>
|
stackexchange-stackoverflow
|
{
"answer_score": 2,
"question_score": 0,
"tags": "javascript, radio button, dom events"
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.