Unnamed: 0
int64 65
6.03M
| Id
int64 66
6.03M
| Title
stringlengths 10
191
| input
stringlengths 23
4.18k
| output
stringclasses 10
values | Tag_Number
stringclasses 10
values |
---|---|---|---|---|---|
1,423,434 | 1,423,435 |
Java output from process buider overwritten when using BufferedReader
|
<p>I'm trying to run an external program in Java and to read the output. The program is a Linux application in C++ that runs a data mining algorithm and prints the patterns found on standard output. I want to be able to read that output from my Java app and to show the patterns using a table. The problem is that the size of the output is quite big (as a test it produces 6.5MB in about 30 seconds). I'm using ProcessBuilder and reading the output using an InputStreamReader buffered using a BufferedReader as you can see in the following code:</p>
<pre><code> String[] cmd = {"./clogen_periodic", selected, support, "-t 4"};
Process p = new ProcessBuilder(cmd).start();
input = new BufferedReader (new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
...
process line;
...
}
</code></pre>
<p>The problem is that the output gets corrupted. When I execute the same program on a console the output is correct but when I use the Java app some lines are merged. More precisely output should be like this</p>
<pre><code> TMEmulation log_pseduo_allocation (34985) (2 45 76 89 90)
__divw clock timer (8273) (4 6 67 4 2)
</code></pre>
<p>but it is like this </p>
<pre><code> TMEmulation log_pseduo_allocation (34985) (2__divw 45clock 76timer (89 8273) 904) (6 67 4 2)
</code></pre>
<p>Any idea about the possible problem?</p>
<p>Thanks a lot in advance,
Patricia</p>
|
java
|
[1]
|
2,668,809 | 2,668,810 |
i want to display this listview on scrolling
|
<p>I'm completely stumped on this one. I have three different lists that need to be displayed on the screen.
I've tried using a ScrollView with a LinearLayout child, and putting my ListViews in the LinearView, but all of the ListViews lock to a fixed height with scroll bars. Using other kinds of Layouts means no scrolling.</p>
|
android
|
[4]
|
119,451 | 119,452 |
display image in servlet
|
<p>I am having the following requirement.
When the user cliock the buton the image should be displayed.The following code that i have tried gives me error</p>
<pre><code> Toolkit tk = Toolkit.getDefaultToolkit();
Image ima = Toolkit.getImage("C:\\DB.jpg");
MediaTracker mt = new MediaTracker(new Canvas());
mt.addImage(ima, 0);
try
{
mt.waitForAll();
}
catch(Exception x) {}
OutputStream os = res.getOutputStream();
// Now create a writable image,
BufferedImage bi = new BufferedImage(ima.getWidth(null), ima.getHeight(null), BufferedImage.TYPE_INT_RGB);
bi.drawImage(ima, 0, 0, null); // Draw the loaded image onto a writable thing
JPEGImageEncoder je = JPEGCodec.createJPEGEncoder(os);
je.encode(ima);
os.close();
}
</code></pre>
|
java
|
[1]
|
1,148,126 | 1,148,127 |
Strat new Activity some time Creare error as 272097-byte external allocation too large for this process
|
<p>I have Tab Based Application and in between application i change tab some time error will generate as "272097-byte external allocation too large for this process." and Application will Crash.. so how can handle this error and Continue my application without crash? is there any method?</p>
|
android
|
[4]
|
305,426 | 305,427 |
parsing xml for iphone
|
<p>can i parse my XML in this method</p>
<blockquote>
<p>Blockquote</p>
</blockquote>
<pre><code>- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
</code></pre>
<p>// here some instance of XMLparser ??
}</p>
<blockquote>
<p>Blockquote</p>
</blockquote>
<p>like whenevrr uer press table cell then for detail view i want to pull data at that time only and for that specfic only as i have 8k data so i dont want to parse other data</p>
|
iphone
|
[8]
|
6,018,338 | 6,018,339 |
shortcut to existentially define variable in javascript
|
<p>To avoid clobbering existing variables, I have code like this</p>
<pre><code>window.x = typeof x != "undefined" ? x : {}
</code></pre>
<p>Which seems like a very long winded way to define something, but necessary to avoid console errors.</p>
<p>I tried this out instead, and it seems to work ok. Is it ok to define a variable like this?</p>
<pre><code>window.x=window.x||{}
</code></pre>
<p>Or even in the global scope...</p>
<pre><code>x=this.x||{}
</code></pre>
|
javascript
|
[3]
|
3,617,325 | 3,617,326 |
jQuery.proxy() usage
|
<p>I was reading the api about <a href="http://api.jquery.com/jQuery.proxy/" rel="nofollow"><code>jQuery.proxy()</code></a>. It looks promising but I was wondering in what situation is this best use. Can anyone enlighten me? Thanks.</p>
|
jquery
|
[5]
|
3,803,295 | 3,803,296 |
Creating images with nice tables
|
<p>I have some data that I would like to represent as a table. Is there a python library that will allow easy generation of an image with a nice looking table in it?
I know that matplotlib does not have this feature, but maybe some other library has...</p>
|
python
|
[7]
|
2,438,004 | 2,438,005 |
Error while loading a file in Python-Set Up path Problem
|
<pre>
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-20294.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python2.6/dist-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
http://peak.telecommunity.com/EasyInstall.html
Please make the appropriate changes for your system and try again.
</pre>
<p>How do I change the directory? Or how would I make it change so that it accepts changes in the root directory?</p>
|
python
|
[7]
|
503,793 | 503,794 |
Get count of inner objects
|
<p>How would you get the count of the objects inside of this object. We only want to count the two inner objects <code>Count This</code> <code>And This</code>. So our answer will be two.</p>
<p>Here is the object</p>
<blockquote>
<p>stdClass Object (</p>
<pre><code>[Count This] => stdClass Object
(
[arr] => Array
(
[0] => data
[1] => some data
)
)
[And This] => stdClass Object
(
[anotherArr] => Array
(
[0] => more data
)
)
</code></pre>
<p>)</p>
</blockquote>
|
php
|
[2]
|
4,868,358 | 4,868,359 |
Can (x==0) be more efficient than (0==x)?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/4624536/which-one-will-execute-faster-ifflag-0-or-if0-flag">Which one will execute faster, if(flag==0) or if(0==flag)?</a> </p>
</blockquote>
<p>I usually write my equality conditions as:</p>
<pre><code>if(0==x)
</code></pre>
<p>as many people do, instead of</p>
<pre><code>if(x==0)
</code></pre>
<p>so that the compiler will tell me when I accidentally type = instead of ==.</p>
<p>Someone told me that some compilers implement this as two register loads, instead of one using a not-equal-zero operation, and so it is less efficient. </p>
<p>Anyone know if this is a reasonable comment?</p>
|
c++
|
[6]
|
989,574 | 989,575 |
jQuery wait for event to complete
|
<p>How can I realize that when I have a function</p>
<pre><code>$('.anyclass').slideToggle(1000);
</code></pre>
<p>that the program exetutes the function test() after the slideToggle completed?</p>
<p>If I write like this:</p>
<pre><code>$('.anyclass').slideToggle(1000);
test();
</code></pre>
<p>...test() gets executed before slideToggle completed.</p>
<p>How can I realize? I don't know jQuery very well ...</p>
<p>Thank you for your help! Regards, Florian</p>
<p>EDIT: Results u can see here: <a href="http://virtual-swiss-hornets.ch" rel="nofollow">www.virtual-swiss-hornets.ch</a></p>
|
jquery
|
[5]
|
1,488,811 | 1,488,812 |
CSimpleIniA - method of wrapper class doesn't read config file value
|
<p>I wrapped <a href="http://code.jellycan.com/simpleini/" rel="nofollow">CSimpleIniA</a> in a Config class to manage configuration options in a 'config.ini' file.</p>
<p>In the example I provide, <code>sample_size</code> is read in the <code>Config</code> constructor.
When <code>readSampleSize()</code> is called, the value of the configuration file is returned.</p>
<p>By contrast, <code>readInitialPos()</code> should (what I expected) be able to read the <code>config.ini</code> and return the value of <code>inital_pos</code>. Instead, it returns the default value, the third argument <code>70000</code>.</p>
<p>I don't understand why this second method is not working. </p>
<p>config.hpp</p>
<pre><code>class Config {
private:
unsigned long int sample_size;
public:
unsigned long int readInitialPos ();
unsigned long int readSampleSize ();
CSimpleIniA ini;
Config ();
};
</code></pre>
<p>config.cpp </p>
<pre><code>#include "../include/config.hpp"
Config::Config ()
{
CSimpleIniA ini;
int error_nr = ini.LoadFile("config/config.ini");
if ( error_nr ) {
cout << "Error " << error_nr << " opening config.ini file." << endl;
exit(3);
}
sample_size = ini.GetLongValue("Rock", "sample_size", 50);
}
unsigned long int Config::readInitialPos ()
{
return ini.GetLongValue("Rock", "initial_pos", 70000);
}
unsigned long int Config::readSampleSize ()
{
return sample_size;
}
</code></pre>
<p>caller, rock.cpp</p>
<pre><code>void Rock::readConfig ()
{
Config config;
initial_pos = config.readInitialPos ();
sample_size = config.readSampleSize ();
}
</code></pre>
|
c++
|
[6]
|
1,968,520 | 1,968,521 |
Android list item focus lost on long click
|
<p>I have serious problem with listview item. My requirement is when I am long clicking on list item or dragging on list item the focus should stay. Currently I am using the following selector for list item. But it is not giving me the expected result and the focus is getting lost:</p>
<pre><code><item android:state_pressed="true"
android:drawable="@drawable/detail_btn_frame_select" />
<item android:state_selected="true"
android:drawable="@drawable/detail_btn_frame_select" />
<item android:state_focused="true"
android:drawable="@drawable/detail_btn_frame_select" />
//Default
<item
android:drawable="@drawable/detail_btn_frame_norm" />
</code></pre>
<p>Please do help in this</p>
|
android
|
[4]
|
4,759,989 | 4,759,990 |
Turn first character of str capitalized but ignore one or two letter words
|
<p>I am a newbie and this is a tough one for me.</p>
<p>I have a text inside a variable:</p>
<pre><code>$bio = 'text, text, tex ...';
</code></pre>
<p>I can use the <strong>ucfirst</strong> php function to make word in the text start with an uppercase letter.</p>
<p><strong>The problem is I don't want the words with one, two or three letters be capitalized</strong> becouse it would look unprofessional.</p>
<p><strong>IMPORTANT:</strong> But I want also to keep the <strong>letter "I"</strong> capitalized since it's proper english grammar.</p>
<p><strong>So a text like:</strong>
this is a text without ucfirst function and i think it needs some capitalizing</p>
<p><strong>Would look like:</strong>
This is a Text Without Ucfirst Function and <strong>I</strong> Think it Needs Some Capitalizing</p>
<p>Any ideas?</p>
|
php
|
[2]
|
3,618,177 | 3,618,178 |
How to format a date in java?
|
<p>How can change this date format "2011-09-07T00:00:00+02:00" into the "dd.MM." i.e "07.09."</p>
<p>Thanks in advance!</p>
|
java
|
[1]
|
1,442,169 | 1,442,170 |
How to create custum volume meter
|
<p>Volume meter,when use drag his fingure up than row images light up accordingly an drag down than row images dim down accordingly....and volume increase and decrease acordingly to the UI.</p>
<p>Thanks</p>
|
android
|
[4]
|
4,424,365 | 4,424,366 |
How to move a dynamically created button?
|
<p>I have a Button1 and a textbox. When i put a value in textbox and click this button then a new button is created with the value filled in textbox but i want that when again i click Button1 and there should be one more button or we can say how to move previous button's position? </p>
<p>This is code for Button1 in .aspx.cs</p>
<p>protected void Button1_Click(object sender, EventArgs e)
{</p>
<pre><code> Button btnNew = new Button();
btnNew.ID = "btnNew";
btnNew.Text = textBox1.Text;
form1.Controls.Add(btnNew);
}
</code></pre>
<p>Please help me to solve this.
Thanks in advance.</p>
|
asp.net
|
[9]
|
2,427,362 | 2,427,363 |
How can I 'blink' the whole surface view
|
<p>In my android application, I have a SurfaceView to show Camera Preview.
I got that to work.</p>
<p>But my question is how can I do a 'blink' effect on this SurfaceView, I would like to give user a visual aid when a photo is taken.</p>
<p>Thank you.</p>
|
android
|
[4]
|
4,875,286 | 4,875,287 |
Permutation of sequence?
|
<p>I have a specific amount of numbers. Now I want to somehow display all possible permutations of this sequence.</p>
<p>For example if the amount of numbers is 3, I want to display:</p>
<pre><code>0 0 0
0 0 1
0 0 2
0 1 0
0 1 1
0 1 2
0 2 0
0 2 1
0 2 2
1 0 0
1 0 1
1 0 2
1 1 0
1 1 1
1 1 2
1 2 0
1 2 1
1 2 2
2 0 0
2 0 1
2 0 2
2 1 0
2 1 1
2 2 0
2 2 1
2 2 2
</code></pre>
<p>I have this code to do that where depth is the amount of numbers. Obviously this code isn't working correct. Any hints how to improve?:</p>
<pre><code> for (int i = 0; i < (depth * depth); i++) {
path = setPath(depth, path, i);
print(path);
}
private static int[] setPath(int depth, int[] path, int i) {
for (int j = 1; j <= depth; j++) {
if (j == 1) {
path[depth-1] = i%depth;
} else {
path[depth-j] = i / ((j-1)*depth);
}
}
return path;
}
</code></pre>
|
java
|
[1]
|
1,544,374 | 1,544,375 |
Java - add a node to the end of a list?
|
<p>Here's what I have:</p>
<pre><code>public class Node{
Object data;
Node next;
Node(Object data, Node next){
this.data = data;
this.next = next;
}
public Object getData(){
return data;
}
public void setData (Object data){
this.data = data;
}
public Node getNext(){
return next;
}
public void setNext(Node next){
this.next = next;
}
}
</code></pre>
<p>How do I write the code to add a Node at the end of a list?</p>
<p>So if I had</p>
<pre><code>head -> [1] -> [2] -> null
</code></pre>
<p>How do I get to</p>
<pre><code>head -> [1] -> [2] -> [3] -> null
</code></pre>
<p>Actually...I'm not even sure if I have to add to the end. I think it's valid to add and then sort? Not sure.</p>
<p>Thanks!</p>
|
java
|
[1]
|
4,915,881 | 4,915,882 |
creating html table based on an algorithm suggestion
|
<p>I'm trying to create an algorithm and want to get your suggestions about that.</p>
<p>There are 4 numbers from 1 to 4 (The sum of this number can vary e.q: 10 or 20).
According to the above total number a html table will occur automatically as below.</p>
<p><img src="http://i.stack.imgur.com/pyiNr.jpg" alt="enter image description here"></p>
<p>After the formation of the table; </p>
<ol>
<li>Every number will put into the table randomly from <strong>R1</strong> to <strong>R3</strong> just once. </li>
<li>Every number necessarily must be in every rows.</li>
<li>If current number was in B side (of colums), next time (i mean, in next row) must be in A side or just the opposite. </li>
<li>Every numbers necessarily must match just once in whole table.</li>
</ol>
<p>Thank you very much for your advice, help and suggust already now.</p>
|
php
|
[2]
|
1,709,132 | 1,709,133 |
Do nothing if RSS feed hasn't changed
|
<p>I want to run a Python script every so many minutes. The script starts by fetching the newest article from a rss-feed (using feedparser). What I want, is when the newest article is the same as the last time it ran, the script just ends. How do I accomplish this?</p>
|
python
|
[7]
|
1,346,265 | 1,346,266 |
Neat way of doing stuff with a List (and such) in Java
|
<p>In C# you can do some operations on a list, like this:</p>
<pre><code>return myList.Average(p => p.getValue());
</code></pre>
<p>This returns the average of all values. Is there something similar in Java? (That would save me the calculation of a sum and then division by the number of elements?)</p>
<p>Thanks!</p>
|
java
|
[1]
|
5,705,513 | 5,705,514 |
How to reload table view with new data
|
<p>I am calling other view controller name "cityState" on button click which has table in it.
code for calling that view on button click(which has table): </p>
<pre><code>[self presentModalViewController:cityState animated:YES];
</code></pre>
<p>now in this view controller I am loading my table with data, its working fine for first time.<br>
For example numberofRowsInSection is like: </p>
<pre><code>-(NSInteger) tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
SingleTon *s = [SingleTon sharedInstance1];
NSMutableArray *x;
rn =[s getRName:x];
NSLog(@"rname : %@",rn);
return [rn count];
[s release];
[ss release];
[x release];
}
</code></pre>
<p>I have a button on this view, and on button press I am going back to the view from which I called this cityStae view </p>
<pre><code>//code for button click
[self dismissModalViewControllerAnimated:YES];
</code></pre>
<p>Now I when I am back on the first view, here I am changing the value of rn (as rn I am using in table view) and calling the table view again with same button click as I did first time, view is called and it is showing with old value of rn and I can see at this time of call NSLog in my numberofRowsInSection is not reached. So the old table with old data is displayed.<br>
My question is <strong>how to show table with new data.</strong>? </p>
|
iphone
|
[8]
|
8,884 | 8,885 |
I need an object to do anything
|
<p>Or at least, to pretend to do anything.</p>
<pre><code>>>> three = Three()
>>> three.value()
3
>>> three.sqrt()
3
>>> three.close()
3
>>> three.someRandomFunctionWithMadeUpParameters("hello, world", math.PI, True)
3
>>> three.stopSayingThreeDamnIt()
3
</code></pre>
<p>Is it possible to implement class <code>Three</code> in Python 2.6 ?</p>
|
python
|
[7]
|
90,052 | 90,053 |
prototype confusion
|
<p><img src="http://i.stack.imgur.com/zGn7u.png" alt="alt text"></p>
<p>This is the representation of prototype chain when I created two instances of Book constructor. The screen-shot is taken from "High Performance Javascript - N.C.Jakas".
My confusion is about the Book constructor given in the middle (the yellow box with the heading "Book"). As every function in javascript is an instance of Function prototype, shouldn't this box (Book) has a <strong>proto</strong> property linking it to prototype of <strong>Function</strong>.? </p>
|
javascript
|
[3]
|
4,304,675 | 4,304,676 |
Call method will null this object
|
<p>I can call a method like this </p>
<pre><code>Func.apply(null,[123]);
</code></pre>
<p>If the function relies on the <code>this</code> pointer, will it throw an exception?</p>
|
javascript
|
[3]
|
3,844,683 | 3,844,684 |
A problem on using x==Y or (x-y)==0 to control the if condition
|
<p>My program includes the following code segment, which do sth based on whether two variables, temp.get(j1) and temp(j2) are equivalent or not.</p>
<pre><code> for (int j1 =0; j1<2;j1++)
{
for (int j2 =0; j2<2;j2++)
{
System.out.println("j1="+j1+"j2="+j2+" "+temp1.get(j1)+"----"+temp2.get(j2));
int xyz = temp1.get(j1)-temp2.get(j2);
System.out.println("the difference is "+ xyz);
if (temp1.get(j1)==temp2.get(j2))
{
System.out.println("find match");
}
}
}
</code></pre>
<p>The program prints out sth like</p>
<p>j1=0j2=0 7698380----7698380</p>
<p>the difference is 0</p>
<p>Even the two values, temp1.get(j1) and temp2.get(j2) do overlap, the "if" part just did not go through. If I change the <code>if (temp1.get(j1)==temp2.get(j2)) to
if (xyz == 0)</code></p>
<p>Then the result will look like</p>
<p>j1=0j2=0 7698380----7698380</p>
<p>the difference is 0</p>
<p>find match
`</p>
<p>I think the two conditions for controlling the if loop should be the same, why the result if so different? Thanks a lot for the answer.</p>
|
java
|
[1]
|
5,589,525 | 5,589,526 |
Relative path to config file in PHP project
|
<p>I'm new to PHP. I'm developing a new PHP website. My website folder structure is as below, </p>
<pre><code>-SystemRoot
+Code
+Data_Access
-Public_HTML
+css
+js
+Templates
-resources
config.php
</code></pre>
<p>There I have a config file in resources directory, I need to include <code>config.php</code> in most of other php pages in various directories. So I have to specify the path to config file differently in different pages like,</p>
<pre><code>include_once '../resources/config.php';
include_once '../../resources/config.php';
</code></pre>
<p>Is there a way to overcome this & use a common (relative) path to <code>config.php</code> that can be used in eny folder path within the project? </p>
<p>What is the common/best practice to include classes in php projects?</p>
|
php
|
[2]
|
2,141,586 | 2,141,587 |
Changed const variable to static variables
|
<p>I adh some constants in my project.</p>
<pre><code>private const int refercePosition = 0.3;
</code></pre>
<p>I shifted the constants to the Settings file of my project (i.e into App.config) and using now in my project as.</p>
<pre><code>private static int refPos = Properties.Settings.Default.referencePosition;
</code></pre>
<p>Is this a good practice to decalre the variable as static instead of constant?<br/>
There are approximately 10 other constants in my project which which I did the same.</p>
<p>BTW, since App.config variables are runtime configurable but does declaring a variable as static defeat that purpose?</p>
|
c#
|
[0]
|
5,897,392 | 5,897,393 |
Calculation Question
|
<p>We have the following code </p>
<pre><code><?php
$num1 = $_POST['num1'];
$sum= $num1 * 1.59;
echo "The final price is ". $sum;
?>
</code></pre>
<p>and we would like it to show the final price is £9.99 for example , but wherever we try to add the £ into the sum it just seems to throw out errors usually either PHP Parse error: syntax error T_variable or T_string ive tried £ . $sum; - . £$sum; but nothing seems to work </p>
<p>Appreciate any help</p>
<p>Dan</p>
|
php
|
[2]
|
539,973 | 539,974 |
Sending out notification email to user on user-defined date in php
|
<p>I am making a feature on my website that allows the user to enter a task they need to finish by a certain date. The website will then notify them by email when it gets near the date, defined by the user (1 day before due date, 2 hours before due date and so on..) I am totally new to notifications and am unsure how to ask this question but here it is in an example of what I want done... </p>
<p><strong>In an example:</strong></p>
<ol>
<li>The user types in "Need to call boss." </li>
<li>The user enters in the date selector, May 31st at 11:00 AM. </li>
<li>And then clicks the "Notify me 1 day before"</li>
<li>They enter their email and click submit. </li>
</ol>
<p>My website will then notify them by email on May 30th at 11:00 AM reminding them to call their boss... </p>
<p>I have looked around and have noticed somethings pointing to CRON jobs.. I looked at that and am unsure if that is the way to go... </p>
<p>Thanks for the time!</p>
|
php
|
[2]
|
3,121,612 | 3,121,613 |
iphone app new update popup
|
<p>I've seen apps the shows a dialog box when a new version of the app is available.</p>
<p>How does it do that?</p>
|
iphone
|
[8]
|
2,043,977 | 2,043,978 |
google.ads.AdView not take the full width of screen in samsung galaxy notes
|
<p>Actually i am displaying an google.ads.AdView in my app at the bottom of the screen..All works fine. But the only problem is that it doesn't take the full width of the screen while showing in samsung galaxy notes, however while displaying in nexus s it take the full width of the screen.</p>
<p>Why this happen, is there is a way to solve this issue.</p>
<p><strong>My xml Layout where i put my google.ads.AdView is</strong></p>
<pre><code><LinearLayout
android:id="@+id/bottom_control_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="a14e5222d46c63d"
ads:loadAdOnCreate="true" >
</com.google.ads.AdView>
</LinearLayout>
</code></pre>
|
android
|
[4]
|
4,735,109 | 4,735,110 |
how to cancel shutdown or restart of windows and make it entering something looks like windows updating more?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/2720125/how-cancel-shutdown-from-a-windows-service-c-sharp">How cancel shutdown from a windows service C#</a> </p>
</blockquote>
<p>I have windows service that should transfer file to nas storage, now the problem is that these files are very important and must not be interupted by windows shutdown or restart,</p>
<p>I want to do something looks like windows updating, when a user hit shut down while the service transfering files in queue, windows should wait until all files are transfered then performing shutdown or restart.</p>
<p>like in this image:
<a href="http://www.7tutorials.com/files/img/ie9_uninstall/unie93.png" rel="nofollow">http://www.7tutorials.com/files/img/ie9_uninstall/unie93.png</a></p>
<p>how to do this in c#.net?</p>
|
c#
|
[0]
|
813,433 | 813,434 |
Shared Preferences
|
<p>I want to show an edit box in shared preferences which should be read only for user but i should be able to change it at through code. how to achieve this? </p>
|
android
|
[4]
|
1,905,875 | 1,905,876 |
Any good way to position UITableViewCellEditingStyleDelete icon within a grouped tableview?
|
<p>as title, can i position the UITableViewCellEditingStyleDelete button/icon to be within the tableviewcell of a grouped tableview rather than outside of it?</p>
|
iphone
|
[8]
|
2,390,045 | 2,390,046 |
Draw on an image
|
<p>Here is my problem. I am currently working on an android application that is handling images. When the application first starts, I have a list of categories (Food, Transport, Emergency ...). So I click on a category for example Food. I find myself in the second activity where I have subcategories (Fruit, Meat, Fish ...). So let's say I click on Fruit. I end up in the third activity which displays images (like in a gridview) of different fruits. I can either click on a fruit to zoom it or I can drag & drop it to the bottom of the activity where I have 3 dropzone that are here for me to create a sequence of images and save it.</p>
<p>So back to my problem, when I zoom on an image I want to be able to add a drawing feature. I want to be able to draw on the image when I click on the menu button of the phone and when I select "Draw". I tried to draw on an image but the drawing lines are always going underneath the pictures so I can't see them. Besides, I want to be able to save the image afterwards and I can't seem to find a way to my problem.</p>
<p>Could someone help me please?</p>
<p>I tried using BitmapFactory but it got me nowhere...</p>
<p>Thank you</p>
|
android
|
[4]
|
3,351,098 | 3,351,099 |
Dialog didn't show
|
<p>I am trying to pop up a dialog when the user overwrite on a backup database so I wrote this code but it didn't work:</p>
<pre><code>$if(backupDB.exists()){
AlertDialog.Builder builder = new AlertDialog.Builder(getBaseContext());
builder.setTitle("Backup database...");
builder.setMessage("You have already backup the database, do you want to overwrite?");
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Intent i=new Intent(getBaseContext(),FinancialSecretary.class);
finish();
startActivity(i);
}
});
AlertDialog dialog = builder.create();
}
</code></pre>
<p>what is wronge?</p>
|
android
|
[4]
|
5,701,502 | 5,701,503 |
Samsung galaxy note not taking xml file from layout-large after updating to android 4
|
<p>In my app i have small, normal and large layout. Initially when i buy Samsung galaxy note, it comes with android 2.3.3, I tested my app in Samsung galaxy note, at that time it takes layout form layout-large and all works fine.</p>
<p>But once i updated my device to android 4. It started taking layout form layout-normal, and as a result of this some of my page alignment changes. So i want to know why this happen, is there any way to fix this out.</p>
|
android
|
[4]
|
5,483,049 | 5,483,050 |
How to check whether "File open..." window is open with javascript?
|
<p>I have an keyup handler. I want something to happen every time I press ESC <em>except</em> when I'm inside a "Choose File..." window.</p>
<p>Here is a jQuery sample code of what I need:</p>
<pre><code>$(document).bind('keyup', function(e) {
if (e.keyCode == 27) {
if (!IsChooseFileDialogBoxOpen())
doSomething();
}
});
</code></pre>
<p>How can I do that?</p>
<p>Thanks</p>
|
javascript
|
[3]
|
5,160,963 | 5,160,964 |
Sort a list by multiple attributes?
|
<p>I have a list of lists (which could have been tuples, but I digress) in a format such as:</p>
<pre><code>[12, 'tall', 'blue', 1]
[15, 'tall', 'black', 3]
[13, 'tall', 'blue', 8]
[9, 'short', 'blue', 3]
[1, 'short', 'black', 2]
[2, 'short', 'red', 9]
[4, 'tall', 'blue', 13]
</code></pre>
<p>If I wanted to sort by one element, say the tall/short element, I could do it via <code>s = sorted(s, key = itemgetter(1))</code></p>
<p>If I wanted to sort by BOTH tall/short and colour, I could do the sort twice. Once for each element. However, this is computationally ridiculous. Is there a quicker way?</p>
|
python
|
[7]
|
1,331,387 | 1,331,388 |
Android View Visibility GONE
|
<p>If i set a views visibility which as been inflated, to gone, will it Speed up my UI?</p>
|
android
|
[4]
|
4,340,980 | 4,340,981 |
getElementById id does not exist
|
<p>I have run into a problem with getElementById again.. I never quite understood the behaviour of this method, as simple as it should be, it often doesn't work for me.</p>
<p>What I have now is a HTML page that contains:</p>
<pre><code><div id="vraag">
ha
</div>
<div id="antwoorden">
</div>
<div id="controls">
<form name="controlform">
<input type="button" name="back" disabled value="<" onClick="goBack();" />
<input type="button" name="forth" value=">" onClick="goForth();" />
</form>
</div>
</code></pre>
<p>I have attached a javascript file that does several (working) things, among which is this:</p>
<pre><code>document.getElementById['vraag'].innerHTML = 'ho';
</code></pre>
<p>However, when I click the button that calls this, the firefox error console says:
<code>Error: document.getElementById.vraag is undefined</code></p>
<p>Sadly, the only think I can think of is.. It simply is! I have used this method in very similar environments and that still works, so I can't for the life of me figure out why this doesn't work..</p>
|
javascript
|
[3]
|
3,587,018 | 3,587,019 |
Device RADIO firmware version number in android 1.6
|
<p>how can i get radio firmware version number in API level 4.</p>
|
android
|
[4]
|
4,990,786 | 4,990,787 |
Java Duplicates in Arraylist
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/562894/java-detect-duplicates-in-arraylist">Java: Detect duplicates in ArrayList?</a> </p>
</blockquote>
<p>I have a strange issue. Im sending out email alerts when remarks get added to a form. Basically each remarks has its own individual id, but multiple remarks can attached to certain form.</p>
<p>In this scenario I have 3 remarks that I added. Two were added to 1 form and the last to a different form. So I would like it just to send 2 forms. The email is sending out 3 forms. I understand that 3 beans will get populated, but 2 will have the same data because 2 remarks belong to the same form. I tried some algorithms I seen posted on here for dups in and what not, but I guess the code is not recognizing duplicate elements because the remarks each have their own id??</p>
<p>For iteration purposes the JSP requires I throw the list of <code>hotParts</code> into an additional <code>ArrayList</code></p>
<p>This is the code..there is more to it, but this is the part that matters</p>
<p>Thanks</p>
<pre><code> try
{
List<Object> dataList = new ArrayList<Object>();
Set<Long> ids = new HashSet<Long>();
for (HotPartsRemarkBean remark : latestHotPartRemarks)
{
ids.add(remark.getHpId());
}
for ( Long id : ids)
{
hotPart = hotPartsDAO.getHotPartById(id);
dataList.add( hotPart ); //List Of Hot Parts Beans
}
THIS WORKS!!!!!!! :)
</code></pre>
|
java
|
[1]
|
4,368,803 | 4,368,804 |
JavaScript array in SharePoint different in length from html?
|
<p>Apologies for deliberately cross-posting, but I have an issue where a JavaScript array in SharePoint is showing a different length from HTML (and an incorrect one!)</p>
<p><a href="http://stackoverflow.com/questions/13373688/javascript-array-giving-different-length-inside-sharepoint-compared-to-html-ind">SO Question</a></p>
<hr>
<p>Updated original to add test javascript</p>
|
javascript
|
[3]
|
2,857,328 | 2,857,329 |
if condition on array
|
<p>if i have </p>
<pre><code>int win[][] ={{1,2,3},{4,5,6},{7,8,9},{1,4,7},{2,5,8},{3,6,9},{1,5,9},{3,5,7}};
</code></pre>
<p>Can I put condition in this way? </p>
<pre><code>if(((win[0][0]) && (win[0][1]) && (win[0][2]))||
((win[1][0]) && (win[1][1]) && (win[1][2]))||
((win[2][0]) && (win[2][1]) && (win[2][2]))||
((win[3][0]) && (win[3][1]) && (win[3][2]))||
((win[4][0]) && (win[4][1]) && (win[4][2]))||
((win[5][0]) && (win[5][1]) && (win[5][2]))||
((win[6][0]) && (win[6][1]) && (win[6][2]))||
((win[7][0]) && (win[7][1]) && (win[7][2]))||
((win[8][0]) && (win[8][1]) && win[8][2])))
</code></pre>
|
android
|
[4]
|
5,540,211 | 5,540,212 |
What methods and properties are available in Java array like String[] strs?
|
<p>I could not locate the package in which Java defines raw arrays like String[] strs
( not ArrayList). </p>
<p>What methods and properties are defined in such Java array and how do I return an iterator for such array supposed I am asked to return an iterator for two integers begin and end?</p>
|
java
|
[1]
|
214,225 | 214,226 |
System.in.read() does not block to read more input characters?
|
<p><br />
Can anyone please explain why the following code behaving strangely: </p>
<pre><code>public class UserInputTest {
public static void main(String[] args) throws IOException {
int n=3;
char[] arr = new char[n];
for (int i=0; i<n; i++) {
System.out.println(i+1 + " character :");
arr[i] = ((char)System.in.read());
}
System.out.println("You Entered : ");
for (int i=0; i<n; i++) {
System.out.println(arr[i]);
}
}
}
</code></pre>
<p><strong>OUTPUT:</strong>
<br/>
1 character :<br/>
u<br/>
2 character :<br/>
3 character :<br/>
You Entered : <br/>
u<br/></p>
<p>I was expecting it to block three times for a user to input values.
Any comments ?</p>
<p><br/><br/>
Thanks,<br/>
Mohit</p>
|
java
|
[1]
|
4,158,999 | 4,159,000 |
Access Contents In An Iframe jquery
|
<p>I have a textarea in an iframe. When I try to do any type of jquery manipulation in the textarea it will not respond. </p>
<p>The text area initially loads data in the iframe fine with this simple code..</p>
<pre><code>//txtHozSliderEmail is the textarea in the iframe
$('#txtHozSliderEmail').val(notificationTemplate.Body)
</code></pre>
<p>but when I change the value of notificationTemplate.Body on subsequent calls, the data from the first call displays. The textarea wont update. I verified that notificationTemplate.Body has different data in it on every call so its not that. </p>
<p>The iframe is nested inside the main page.</p>
<p>When I check the "frames" collection I can see it has 2 frames how can I see the names of them? It seems the iframe has no id when I look at it in the html. Do I have to give it an "id" to access it or some other attribute?</p>
<p>The iframe is on the same domain/server I am not accessing an outside domain. The iframe is being used in the jHtmlArea.js library</p>
<p>Here the code in the library that is creating the iframe:</p>
<pre><code> var iframe = this.iframe = $("<iframe/>").height(textarea.height());
iframe.width('580px');
iframe.height('180px');
//iframe.width(textarea.width() - ($.browser.msie ? 0 : 4));
var htmlarea = this.htmlarea = $("<div/>").append(iframe);
</code></pre>
|
jquery
|
[5]
|
2,701,267 | 2,701,268 |
How to retrieve values from arrays and check if they match
|
<p>I am learning to program in php and I have a little problem.
I have two arrays:<br>
Array A:</p>
<pre><code>array(10){
[0]: string(10) "2012-08-01"
[1]: int 1
[2]: string(10) "2012-08-03"
[3]: int 1
[4]: string(10) "2012-08-07"
[5]: int 2
[6]: string(10) "2012-08-09"
[7]: int 2
[8]: string(10) "2012-08-27"
[9]: int 1
}
</code></pre>
<p>Array B:</p>
<pre><code>array(4){
[0]: string(10) "2012-09-04"
[1]: string(10) "2012-09-06"
[2]: string(10) "2012-09-08"
[3]: string(10) "2012-09-10"
}
</code></pre>
<p>I want to check if the first element from Array A equals the first element from Array B, if it does then write second element (in this case <code>1</code>) from array A to an new Array C (one dimensional) else don't write anything in an array C and next check if element with index 2 from an array A equals second element <code>[1]: string(10) "2012-09-06"</code> from an array B if so the write fourth element (<code>[3]: int 1</code>) from an array A to an array C etc. so an array C would have int elements only.
If someone could help me out how to sort this out please I would be very happy </p>
|
php
|
[2]
|
3,642,596 | 3,642,597 |
How can I manage the location of my application icon in android
|
<p>After installing my application, I want to locate the application icon into my folder, not directly appear at the main menu .
How can i write to change it after app installed .</p>
|
android
|
[4]
|
886,627 | 886,628 |
Calling non static method with "::"
|
<p>why can i use a method non-static with the sintaxe of the methods static(class::method) ? Is it a some kind of configuration?</p>
<pre><code>class Teste {
public function fun1() {
echo 'fun1';
}
public static function fun2() {
echo "static fun2" ;
}
}
Teste::fun1(); // why?
Teste::fun2(); //ok - is a static method
</code></pre>
<p>Thanks</p>
|
php
|
[2]
|
3,668,440 | 3,668,441 |
Generate values for str.format style template strings from formatted output
|
<p>This might seem like a wierd requirement, but I am looking for a good implementation to do this.</p>
<p>I have a dict like</p>
<pre><code>vals = dict(red='#F00', green='#0F0', blue='#00F')
</code></pre>
<p>and a string like</p>
<pre><code>tpl = '{red}:{green}:{blue}'
</code></pre>
<p>and the <code>str.format</code>ted output</p>
<pre><code>output = tpl.format(**vals)
</code></pre>
<p>All is well till here. However, I now need to do the reverse of this. I have to turn a string like <code>'#F00:#0F0:#00F'</code> into a dict of the values that we previously started with. Of course, I could just <code>split</code> and <code>strip</code> the string and take the values I need, but it will fail in the event the <code>tpl</code> string should change.</p>
<p>Any good ideas on how I can do this (If it can even be done, that is)?</p>
|
python
|
[7]
|
807,246 | 807,247 |
Open a resource file with StreamReader?
|
<p>This doesnt work:</p>
<pre><code>string fileContent = Resource.text;
StreamReader read = File.OpenText(fileContent);
string line;
char[] splitChar = "|".ToCharArray();
while ((line = read.ReadLine()) != null)
{
string[] split = line.Split(splitChar);
string name = split[0];
string lastname = split[1];
}
read.Dispose();
</code></pre>
<p>How do you open a resource file to get its contents?</p>
|
c#
|
[0]
|
2,617,112 | 2,617,113 |
Dynamically Specify the First Activity
|
<p>The main activity is specified in AndroidManifest.xml with:</p>
<pre><code> <intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</code></pre>
<p>But I don't know how to dynamically specify the first activity according code logic.</p>
|
android
|
[4]
|
3,259,229 | 3,259,230 |
How to check if background data is enabled on the android?
|
<p>I want to check if the user enabled background data on his/her device and display a message if it is disabled.</p>
<p>How can I check if it has been enabled?
I tried </p>
<pre><code>import android.provider.Settings;
//...
Settings.System.getString(getContentResolver(), Settings.Secure.BACKGROUND_DATA);
//and
Settings.Secure.getString(getContentResolver(), Settings.Secure.BACKGROUND_DATA);
</code></pre>
<p>But they are returning null.</p>
<p>Thank you,
Achie.</p>
|
android
|
[4]
|
4,901,483 | 4,901,484 |
What does & in C++ function arguments list mean?
|
<blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/57483/what-are-the-differences-between-pointer-variable-and-reference-variable-in-c">What are the differences between pointer variable and reference variable in C++?</a><br>
<a href="http://stackoverflow.com/questions/9488894/what-does-a-function-prototype-mean-with-an-ampersand-in-it">What does a function prototype mean with an ampersand in it?</a> </p>
</blockquote>
<p>In my understanding, </p>
<pre><code>void bar(int &x) { ... }
</code></pre>
<p>Seem to mean pass <code>x</code> by reference. But in C++, there are pointers etc already. So what difference is there to </p>
<pre><code>void bar(int *x) { ... }
// then call by
bar(&x);
</code></pre>
<p>Apart from the fact that it's longer... I also noticed if I use the 2nd method, I need to use <code>-></code> as opposed to <code>.</code> if I pass in a <code>struct</code>... why? </p>
|
c++
|
[6]
|
5,461,184 | 5,461,185 |
Java Simple Date format Conversion
|
<p>If <code>2011-11-26T03:53:00.001-0800</code> is <code>yyyy-MM-dd'T'HH:mm:ss.SSSZ</code></p>
<p>Then what is <code>2011-11-26T03:53:00.001-08:00</code></p>
<p>Hope it explains everything what i need...</p>
|
java
|
[1]
|
2,518,643 | 2,518,644 |
why use "%.24s\r\n" instead of "%24s\r\n" in the calling of function snprintf
|
<pre><code>char buff[MAXLINE];
time_t ticks;
ticks = time(NULL);
snprintf(buff, sizeof(buff), "%.24s\r\n", ctime(&ticks)); // with .
</code></pre>
<p>I have tried the following line and don't see any difference:</p>
<pre><code>snprintf(buff, sizeof(buff), "%24s\r\n", ctime(&ticks)); // without .
</code></pre>
<p>Do I miss some key point here?</p>
<p>Thank you</p>
|
c++
|
[6]
|
17,427 | 17,428 |
Python network/socket programming, simple game
|
<p>Im trying to make a simple game but cant understand how to make it work and send more then one thing over the network. It works the first time but it supposed to go 10 times. It only sends 1 random number now but i want it to send one new when the game goes again and want a new number.</p>
<p>Server </p>
<pre><code>import socket, random
sock = socket.socket()
host = socket.gethostname()
port = 12345
sock.bind((host, port))
sock.listen(5)
c, addr = sock.accept()
cpu = random.choice(range(0, 3))
c.send(cpu)
gameon = c.recv(int(1024))
</code></pre>
<p>Client</p>
<pre><code>import socket, random
sock = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
port = 12345 # Reserve a port for your service.
sock.connect((host, port))
GAMEON = 'Rock', 'Paper', 'Scissors'
game = 0
iwin = 0
ilose = 0
tie = 0
while game < 10:
for i in range(0, 3):
print "%d %s" % (i + 1, GAMEON[i])
player = int(input ("Choose from 1-3: ")) - 1
cpu = int(sock.recv(1024))
print cpu
print""
print "%s vs %s" % (GAMEON[player], GAMEON[cpu])
print ""
if cpu != player:
if (player - cpu) % 3 < (cpu - player) % 3:
print "Player wins\n"
iwin += 1
else:
print "CPU wins\n"
ilose += 1
else:
print "TIE!\n"
tie += 1
game += 1
sock.send(str(game))
print"Game is done"
print"you win: ", (iwin), "Times"
print"computer wins: ", (ilose), "Times"
print"tie: ", (tie), "Times"
</code></pre>
|
python
|
[7]
|
3,555,928 | 3,555,929 |
changing the Request.QueryString value
|
<p>how can i modified the querystring?</p>
<p>I have capture the query string like this</p>
<pre><code>qs = Request.QueryString["flag"].ToString();
</code></pre>
<p>and then rebuilt the query string with modified values
and response.redirect(url & qs) to it</p>
|
asp.net
|
[9]
|
395,651 | 395,652 |
How to solve foreclose problem in start up my application?
|
<p>I am developing an android application,I want to my application automatically invoked,when I switch on my device.so i used this permission <code><uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /></code> in my application's manifest.xml file and i used service , activity and register Broadcast receiver in manifest.xml file.but I got foreclose error appear in when will i start up my device.How solve this proplem.
My Receiver code given bellow
context.startActivity(new Intent(context,ServicesDemo.class));<br>
//In my mainfest.xml for myReceiver</p>
<pre><code><receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter> </receiver>
</code></pre>
<p>I got this exception <code>java.lang.RuntimeException: Unable to start receiver com.servicedemo.MyReceiver: android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?</code></p>
|
android
|
[4]
|
2,752,191 | 2,752,192 |
Javascript Inheritance and this
|
<p>Lets say I have a namespace called ns and ns has to functions on it:</p>
<pre><code>ns = {};
ns.Foo = function(message, fn){
this.message = message;
fn.call(this);
};
ns.bar = function() {
alert('Hello, world!');
};
</code></pre>
<p>And I call it like this:</p>
<pre><code>var foo = new Foo('My Message', function() {
bar();
});
</code></pre>
<p>I get an error saying bar() is undefined. But if I call it this way:</p>
<pre><code>var foo = new Foo('My Message', function() {
this.bar();
});
</code></pre>
<p>It works. Is there a way to structure my JavaScript so I can just call bar() without the this?</p>
<p>Thanks!</p>
|
javascript
|
[3]
|
2,552,901 | 2,552,902 |
High precision calculations with mutable class in Java
|
<p>I'm designing a tool using Java 6, that will read data from Medical Devices. </p>
<p>Each Medical Device manufacturer implements its own Firmware/Protocol. Vendors (like me) write their own interface that
uses the manufacturer's firmware commands to acquire data from the Medical Device. Most firmwares will output data in a cryptic fashion, so the vendor receiving it, is supposed to scale it by doing some calculations on it, in order to figureout the true value. </p>
<p>Its safe to assume that medical data precision is as important as financial data precision etc. </p>
<p>I've come to the conclusion of using BigDecimal to do all numerical calculations and store the final value. I'll be receiving a new set of data almost every second, which means, I'll be doing calculations and updating the same set of values every second. Example:Data coming across from a ventilator for each breath.</p>
<p>Since BigDecimal is immutable, I'm worried about the number of objects generated in the heap every second. Especially since the tool will have to scale up to read data from lets say 50 devices at the same time.</p>
<p>I can increase the heap size and all that, but still here's my questions....</p>
<p>Questions</p>
<ol>
<li><p>Is there any mutable cousin of BigDecimal I could use?</p></li>
<li><p>Is there any existing opensource framework to do something like this?</p></li>
<li><p>Is Java the right language for this kind of functionality?</p></li>
<li><p>Should I look into Apfloat? But Apfloat is immutable too. How about JScience?</p></li>
<li><p>Any Math library for Java I can use for high precision </p></li>
<li><p>I'm aiming for a precision of upto 10 digits only. Dont need more than that. So whats the best library or course of action for this type of precision?</p></li>
</ol>
<p>Thanks
Amit</p>
|
java
|
[1]
|
5,008,227 | 5,008,228 |
Seeing the actual error behind ‘An unexpected error has occurred’ in Sharepoint 2010
|
<p>In MOSS 2007, we could update the tag's callstack attribute to true and then customerrors mode to "Off" to see the actual error behind the 'An unexpected error has occurred' message. Does it apply on SharePoint 2010 as well ? I tried it but I get the following error:<BR><BR></p>
<p>Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.</p>
<p>Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root direc...</p>
|
asp.net
|
[9]
|
3,697,026 | 3,697,027 |
change <option> stylebackground
|
<p>Why would this not work. This is referring to the option tag in a select tag.
If I remove the mouseOut style the mousOver works.</p>
<pre><code>//inside a loop
option[b].onmouseover = Custom.mouseOver;
option[b].onmouseout = Custom.mouseOut;
mouseOver: function() {
this.style.backgroundColor = "#999999";
}
mouseOut: function() {
this.style.backgroundColor = "#e8eff4";
}
</code></pre>
|
javascript
|
[3]
|
4,069,581 | 4,069,582 |
Escaping characters in jQuery
|
<p>I've googled and I've checked stackoverflow for an answer, but yet I haven't found a proper one. My input regularly contains <code>&</code> (ampersand) and <code>@</code> so I would need to escape that variable CN99, how can i do this with jquery?</p>
<pre><code>$("#CompanyNameFilter").focus(function() {
var CN99 = $("#CompanyNameFilter").val();
$.ajax({
url: "clients.php?companyname=" + CN99,
dataType: "html",
success: function(html) {
var div = $("#companyList", $(html)).addClass("done");
$("#companyList").html(div);
}
});
});
</code></pre>
|
jquery
|
[5]
|
1,889,356 | 1,889,357 |
Strange php problem
|
<p>The following code:</p>
<pre><code>print_r($_GET);
echo '<br />';
echo isset($_GET['logout'])?'yes':'no';
</code></pre>
<p>prints:</p>
<pre><code>Array ( [logoout] => )
no
</code></pre>
<p>Why is it printing "no" instend of "yes"?</p>
|
php
|
[2]
|
2,243,652 | 2,243,653 |
How to get data From Status bar and disable it?
|
<p>I am creating a custom lock screen so that in my activity the Status
bar won't be there.</p>
<p>At the mean time i want to get the the status bar notifications such
as missed calls, new chat messages, new emails, new voice-mail, etc...</p>
<p>How to implement this?
please give me a hint </p>
|
android
|
[4]
|
3,958,185 | 3,958,186 |
C# importing Excel
|
<p>This code is throwing an exception, I know its due to the INTO clause can someone please point out my mistake I cannot seem to find it.</p>
<pre><code> "SELECT Brand,`Manufacturer Code`,Description,`Dove Code`,Price,`Stock Level` "
+ "INTO " + pBrand + "," + pManufacturer + "," + pDescription + "," + pDoveCode + "," + pPrice + "," + pStock
+ " FROM [Stock$]", newConnection
</code></pre>
<p>Thank you!
P.S. I know the other two lines of code above and below the INTO clause are working.</p>
|
c#
|
[0]
|
6,026,409 | 6,026,410 |
Array of the 3 largest numbers
|
<p>I was working on a method trying to create a array that will contain the 3 largest numbers. But there is an error in my code and I couldn't understand what I did wrong. Thanks!</p>
<p>public class Method3 {</p>
<pre><code>public static void main(String[] args) {
int[] a={2,5,6,7,9,1,2,3,5,9,7};
System.out.print(largestSum(a));
}
public static int[] largestSum(int[] a){
int temp, first, second, third;
first=second=third=a[0];
for(int element: a){
if(first < element)
{
temp=first;
first=element;
second=temp;
}
if(second<element && first> element)
{
temp=element;
second=element;
third=temp;
}
if(third< element && second> element)
{
temp=element;
third=element;
}
}
int [] array=new int[3];
array[0]=first;
array[1]=second;
array[3]=third;
return array;
}
</code></pre>
<p>}</p>
|
java
|
[1]
|
882,627 | 882,628 |
zlib module missing - python 2.4.3
|
<p>I am trying to get simplejson installed on this python 2.4.3 - <strong>I cannot upgrade, I know it is old, there is nothing I can do about it, it is not my fault, please help.</strong> however when i do the ..\python.exe .\setup.py install i get: </p>
<pre><code>File "C:\Program Files (x86)\WorldViz\Vizard30\bin\lib\zipfile.py", line 188, in __init__ raise RuntimeError,\
RuntimeError: Compression requires the (missing) zlib module
</code></pre>
<p>Does anyone know how can I get zlib installed on this windows 64 machine? or where I can get a compiled version of simplejson or where can I find a compatible alternative for it.</p>
<p>Again, I can't do anything about it being python 2.4.3 - it is a proprietary modified version of python that I cannot do a thing about.</p>
|
python
|
[7]
|
4,825,211 | 4,825,212 |
Load resource from anywhere in classpath
|
<p>I have a simple java application that loads a properties file from the current package.</p>
<pre><code>this.getClass().getResourceAsStream("props.properties");
</code></pre>
<p>This works fine when the property file I want is in the current package. However, I want to package this application as a JAR and define and override with a new properties file where I use it. Is there a way to load the first resource named "props.properties" that is on the classpath?</p>
<p>I want it to be as easy to override the properties file via command line:</p>
<pre><code>java.exe -classpath props.properties;myJar.jar com.test.MyApp
</code></pre>
<p>I don't want to have to unpack the JAR and modify the properties file to change something. I feel like I'm missing something obvious...</p>
|
java
|
[1]
|
1,397,900 | 1,397,901 |
What is this in javascript: "var var1 = var1 || []"
|
<p>I just want to increase my core javascript knowledge.</p>
<p>Sometimes I see this statement but I don't know what it does:</p>
<pre><code>var var1 = var1 || [];
</code></pre>
<p>What does it means and/or what's it for, and how do you use it?</p>
<p>Thank you.</p>
|
javascript
|
[3]
|
4,362,521 | 4,362,522 |
Better to change protected to public? or create another method that calls the superclass
|
<p>I'm trying to create a game using the best practices to my knowledge.
I have:</p>
<ul>
<li>a <code>VisibleObject</code> with a <code>protected void draw(Canvas c)</code> function</li>
<li>a <code>MapTile</code> that <code>extends VisibleObject</code> to draw itself.</li>
<li>a <code>Map</code> class that contains a LinkedList of MapTiles, <code>tiles</code>.</li>
</ul>
<p>In the <code>Map</code> class i wanted a loop like this:</p>
<pre><code>public void draw(Canvas c){
for(MapTile tile : tiles){
tile.draw(c);
}
}
</code></pre>
<p>But i realised i could not call draw upon each tile because it's a protected method in <code>VisibleObject</code>.
I can think of 3 possible solutions:</p>
<ol>
<li>Just change <code>protected</code> to <code>public</code> in <code>VisibleObject</code>.</li>
<li>Create a public method of MapTile that just calls <code>super.draw(c)</code> (I think that's valid syntax?)</li>
<li>change the for loop in Map to something like this, which i believe would make it valid. </li>
</ol>
<p>New Loop: </p>
<pre><code>MapTile current;
for(MapTile tile : tiles){
current = tile;
current.draw(c);
}
</code></pre>
<p>Which solution would be better programming practice?</p>
|
java
|
[1]
|
2,583,248 | 2,583,249 |
Is it OK to program a method body inside of an event?
|
<p>I recently saw some code from a college teacher where he had something like this:</p>
<pre><code>public void Button1_Click(blabla)
{
//His code was here.
}
</code></pre>
<p>Isn't it considered better programming practice to call a method to do the dirty work, that way if the method changes you only have to change the method itself and not the event? (Less chance of breaking something)</p>
<pre><code>public void Button1_Click(blabla)
{
DoSomething();
}
public void DoSomething()
{
//The actual code here.
}
</code></pre>
|
c#
|
[0]
|
3,752,243 | 3,752,244 |
Converting string to digits in Python
|
<p>I have a string:</p>
<pre><code>x = "12.000"
</code></pre>
<p>And I want it to convert it to digits. However, I have used int, float, and others but I only get <code>12.0</code> and i want to keep all the zeroes. Please help!</p>
<p>I want <code>x = 12.000</code> as a result.</p>
|
python
|
[7]
|
4,529,053 | 4,529,054 |
python: select a sublist with a list length limit
|
<blockquote>
<p>players = [ a long list of (id, float) tuples with each id unique,
order by highest float]</p>
<p>on_teams = [ a list of unique ids, every on_teams id is also in the
players list]</p>
</blockquote>
<pre><code>picked = set(on_teams)
best_remaining = []
for best_player in players:
if best_player[0] not in picked:
best_remaining.append(best_player)
if len(best_remaining) == 5: break
</code></pre>
<p>When I use six lines of code to do a simple thing, such as "get the five best remaining players", I wonder if there isn't a more elegant, pythonic solution. It's a simple problem, no doubt, but is there a better way to code it?</p>
<p>UPDATE:
My code run 100,000 times, runs in 0.24 secs. When I run:</p>
<pre><code>best_remaining = [(id, float) for id, float in players if id not in picked][:5]
</code></pre>
<p>The code runs in 4.61 secs (100,000x). So the code looks and scans nicer, but it create the whole list then slices it. So now my question is a little different. With speed as a constraint, is there a better way to code up the search for the '5 best remaining players`?</p>
<p>UPDATE:</p>
<pre><code>best_remaining = list(islice((p for p in players if p[0] not in picked), 5))
</code></pre>
<p>This code runs trivially longer than my code. To me at least, it has the value of a list comprehension. And best of all, it shows me a good place to work on my code habits. Thanks</p>
|
python
|
[7]
|
50,184 | 50,185 |
How to put password permission to folder in android Application, that folder contain sub folder. code example pls
|
<p>How to put password to the folder in android,is there any permission,
just i want to set password to the folder,folder contain sub folder,pls any body?</p>
|
android
|
[4]
|
2,679,221 | 2,679,222 |
Weird onclick behavior of images on home screen widget
|
<p>I wrote a home screen widget with one image on it. When the image is clicked, browser will be opened for a url link.
Generally, it is working. But a weird thing is that, when I click background, then click the picture, the browser will not be open. Until I click the second time on the picture, the browser opens. The steps to reproduce is below:</p>
<ol>
<li>Click on the home screen widget background.</li>
<li>Click on the image on the home screen. The browser is not opened.</li>
<li>Click on the image again. The browser is opened.</li>
</ol>
<p>If I didn't click on the background, the image will react to click very well, i.e. browser will be open when the image is clicked the first time.</p>
<p>The widget XML file is as below:</p>
<pre><code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget"
android:layout_width="320dip" android:layout_height="200dip"
android:background="@drawable/prt_base"
>
<ImageView android:id="@+id/picture1"
android:layout_width="134dip"
android:layout_height="102dip"
android:layout_marginLeft="62dip"
android:layout_marginTop="6dip"
android:scaleType="center"
android:src="@drawable/picture1"
/>
</RelativeLayout>
</code></pre>
<p>The code to set OnClick on the picture1 ImageView is as below:</p>
<pre><code> defineIntent = new Intent(Intent.ACTION_VIEW, Uri
.parse("http://www.google.com"));
pendingIntent = PendingIntent
.getActivity(context,
0 /* no requestCode */,
defineIntent, 0 /* no flags */);
updateViews.setOnClickPendingIntent(
picId, pendingIntent);
</code></pre>
<p>Anyone knows what's wrong?</p>
<p>Thanks.</p>
|
android
|
[4]
|
3,664,838 | 3,664,839 |
Determine whether a KeyEvent is belongs to KEY_PRESSED type
|
<p>I am getting an instance of <code>KeyEvent</code> from a 3rd party libraries.</p>
<p>How can I know whether the event is a <code>KeyEvent.KEY_PRESSED</code> type? Which method from <code>KeyEvent</code> I should call?</p>
|
java
|
[1]
|
3,805,198 | 3,805,199 |
How to calculate the point(x2,y2) with the point (x1,y1) and the angle
|
<p>Again i came back with a question.</p>
<p>1.I have a line drawing from a point (x2,y2) for which i do no the end point(Say point unknown as in the fig),but i knew the line length and the angle from the vector (x2,y2). Can any one help me how to calculate the unknown points.</p>
<p><img src="http://i.stack.imgur.com/s3slO.png" alt="alt text"></p>
<p>Thanks,
Lokesh.</p>
|
c#
|
[0]
|
6,003,238 | 6,003,239 |
Omniture tracking in iphone
|
<p>Wannted to implement omniture tracking in iPhone application, I just have basic clue on omniature that it is a third party software that helps you to track keyword search by your user in your application, also help to present similar searches to user, and helps reporting, plz correct me if I am wrong as I still digging information on it.</p>
<p>I wanted to implement the same in iphone form my application.</p>
<p>I have goggled by the information about omniture tracking is scare and there is no help to as to how to implement in iPhone</p>
<p>Can any one guide me how it is done and how to do it iphone.</p>
|
iphone
|
[8]
|
2,822,809 | 2,822,810 |
which function is there in android for the following java function--statement = database.createStatement(sqlStatement);?
|
<pre><code>public void execute(String sqlStatement) throws DBException {
Statement statement;
try {
statement = database.createStatement(sqlStatement);
statement.prepare();
statement.execute();
statement.close();
} catch (DatabaseException databaseException) {
throw new DBException(Class.class.getName(), "execute", databaseException.getMessage());
}
}
</code></pre>
<p>This is the function in java that i have to implement in android. In android how can i use the createstatement(), statement.prepare() and statement.execute() functions?</p>
|
android
|
[4]
|
539,874 | 539,875 |
How do I convert a 12-bit integer to a hexadecimal string in C#?
|
<p>I want to convert a number between 0 and 4096 ( 12-bits ) to its 3 character hexadecimal string representation in C#. </p>
<p>Example:</p>
<pre>
2748 to "ABC"
</pre>
|
c#
|
[0]
|
5,209,341 | 5,209,342 |
ASP.net Calendar Control conditional
|
<p>I want to have a calendar control to only allow users to select dates which are weekdays (Mon-Fri) in the future and if it's after eg. 9.00 am of the current day then this date will also not be available, this to be then returned into a text box.</p>
<p>How can a do this easily. I'm still very new to ASP.net.</p>
<p>Thank you,</p>
|
asp.net
|
[9]
|
3,871,239 | 3,871,240 |
Android Webview - setting proxy
|
<p>I have a weather icon. On click on that I am launching a webview(www.weather.com). User is allowed to go anywhere in weather.com If he leaves wesite and tried to open other website do not allow and no pop ups. Can I do it ? How ?</p>
|
android
|
[4]
|
1,197,989 | 1,197,990 |
.aspx vs .cs class
|
<p>what is the difference between the .aspx class and the .cs class of appcode?</p>
<p>when i write some aspx class it's aspx.cs by default inherit the System.Web.UI.Page and it's
aspx paeg in page directive mention the tag inherit="page_name_what we saved with", cant we make it inherit something else like .cs class of appcode, all this confuse me please elaborate me on this.</p>
|
asp.net
|
[9]
|
6,013,834 | 6,013,835 |
How to retrieve CSS style object by CSS class name?
|
<p>Is it possible to get all properties of a css class associated with an element?<br>
e.g. </p>
<pre><code>.hightligh {
font-weight: bold;
border: 1px solid red;
padding-top:10px;
}
</code></pre>
<p>Lets say the css class "hightlight" is assigned to div element</p>
<pre><code><div class='highlight'></div>
</code></pre>
<p>Now using JavaScript, I need to iterate through all style properties of css class "highlight" associated with the div element.
Basically, I want to treat it as a JavaScript object whose properties can be accessed using iterator or for loop.</p>
<p>Thanks in advance</p>
|
javascript
|
[3]
|
2,255,591 | 2,255,592 |
c# help with interview questions
|
<p>i am trying to analyze some interview test questions i an not sure if i answered correctly. I have a hard time looking for the correct answers for these.</p>
<p>i wonder if anyone could help me with these question, or point me to the right direction.</p>
<p>Many thanks
(i have a star for the answer i gave)</p>
<ol>
<li><p>A feature of static classes is they may: <br></p>
<p>a. have sealed or abstract modifiers. <br>
b. have members with protected accessibility. <br>
c. be marked as partial.*<br>
e. inherit from anotherclass or be inherited. <br>
d. contain instance members.<br></p></li>
<li><p>What class modifier do you use to specify a class you can only use WITHOUT instantiation? <br></p>
<p>a. abstract <br>
b. partial <br>
c. sealed <br>
d. static * <br>
e. abstract static <br></p></li>
<li><p>What must you implement to fully implement an interface? <br></p>
<p>a Only methods and properties marked abstract <br>
b. All defined methods, properties, events, and indexers <br>
c. All defined methods only <br>
d. Zero or more defined methods <br>
e. All defined methods and properties only *<br></p></li>
<li><p>What statement do you use to instantiate a generic collection of integers using only System.Collections.Generic? <br></p>
<p>a. <code>ICollection<int></code> codes = new <code>List<int>( );</code> <br>
b. <code>CollectionBase<int></code> codes = new <code>CollectionBase<int>( );</code> <br>
c. <code>Collection<int></code> codes = new <code>List<int>( );</code> <br>
d. IntegerCollection codes = new <code>IntegerCollection( );</code> <br>
e. List codes = new <code>List<int>( );</code> *<br></p></li>
</ol>
|
c#
|
[0]
|
4,505,028 | 4,505,029 |
Using ItemType for strongly typed repeater control?
|
<p>Okay, so I looked up some cool stuff about strongly typed repeater controls... the only issue is that it won't work. I have a <code>List<Entry></code> that I've bound my repeater to. I just want to display the data. Normally I use <code>((Entry)(Container.DataItem))</code>, but from what I've read I can just declare the type in the ItemType. </p>
<p>Well... that's what I tried to do, but I get nothing. What am I messing up here?</p>
<pre><code><asp:Repeater ID="UserRptr" ItemType="HROpenEnrollment.Classes.Entry" runat="server">
<ItemTemplate>
<ul class="UserList">
<li class="CompoundField">
<%# ???? I can't use Item here. %>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
</code></pre>
<p>I would guess that it's not finding my entry class... how do I get that in there? It's in the same namespace, in a separate folder.</p>
|
asp.net
|
[9]
|
5,197,367 | 5,197,368 |
jquery using load function - how to retrieve dynamic values?
|
<p>Is it possible? - this is my try, i have a bunch of thumbs on a page, while the user click on the thumb, i suppose to open a new page, and i should load the slide image, based on thumb, what the user clicked.</p>
<p>what i tried is, when a user click on thumb, i store the data as text in the some hidden element ( replacing text), and with the new page opens, i am loading the element to retrieve the data, what i was assigned. but the dynamic content is event updated, i am only getting the static data, what the element has... is it not possible to get the dynamic data? - as a sample example :</p>
<p>thumb page js :</p>
<pre><code>var i=0;
$('a').click( function (e) {
e.preventDefault();
i++;
$('strong').text(i);
})
</code></pre>
<p>i am updating the strong's value each time on click..
the new page loading the prev, pages strong element.</p>
<pre><code> $(document).ready(function(){
$('body').load('index.html strong', function (data) {
console.log('loaded');
})
})
</code></pre>
<p>but i see, only the static data. not dynamic data i assigned. any clue to fix this? or any other way to pass data, apart from get and post method?</p>
|
jquery
|
[5]
|
1,342,382 | 1,342,383 |
Get image out, one by one, from a "images" directoy, using - PHP
|
<p>OK I have a folder with ALL website images (news category ones, only, of course) at only one location called "images/pictures". That folder is PHP controlled. After submitting news to my website, GD (after resizing and stuff) stores images to that location. That works perfect. Even thus, after PHP controlled removal of news from CP, PHP automatically deletes those unnecessary files, images, given from MySql entries. That works perfect.</p>
<p>But, as time goes on.. lots of images left in folder due to sloppy DB/foder backups, changes or some experiments. Even more, recently I had a mess with that folder, so now I have lots of (unnecessary) images in that folder ready to be deleted.</p>
<p>Anyway, I have an idea how to do that.</p>
<ol>
<li><p>PHP to read all images from that directory at first,</p></li>
<li><p>And get every file out, one by one, as a string for while loop (ready to be controlled by MySql for deleting or not).</p></li>
</ol>
<p>Any advice how to achieve that by using PHP? </p>
|
php
|
[2]
|
1,212,901 | 1,212,902 |
what is the best iframe modal box
|
<p>i want a internal popup or nice modal box which contains an iframe ( i should able to set the width and height ) and which is easy to install , and has no too much files.</p>
<p>i don't prefer lightbox currently.</p>
<p>Thanks</p>
|
jquery
|
[5]
|
5,106,814 | 5,106,815 |
browsers user agent list
|
<p>I'm using function to detect my website visitors browser type but later i found there many visits comes with undetectable browsers so i might needs to do some update to my browsers user agent list. </p>
<p>this is my list of browsers with browser name as array key and user agent as value. </p>
<pre><code>$browsers = array(
'Opera' => 'Opera',
'Mozilla Firefox'=> '(Firebird)|(Firefox)',
'Galeon' => 'Galeon',
'Mozilla'=>'Gecko',
'MyIE'=>'MyIE',
'Lynx' => 'Lynx',
'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
'Konqueror'=>'Konqueror',
'SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
'Internet Explorer 8' => '(MSIE 8\.[0-9]+)',
'Internet Explorer 7' => '(MSIE 7\.[0-9]+)',
'Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
'Internet Explorer 5' => '(MSIE 5\.[0-9]+)',
'Internet Explorer 4' => '(MSIE 4\.[0-9]+)',
);
</code></pre>
<p>my question is where to get more browsers name / user agent !
for example for safari,navigator,mosaic,lynx,amaya,omniweb,avant,camino ..etc.</p>
|
php
|
[2]
|
689,785 | 689,786 |
Replace New with other solution?
|
<p>This code has lot of trouble for my AIR 2.0 Native process which I tried to launch Java from AIR application, then the Java.exe terminate itself in the Windows Task manager, I found that <code>new MidiTest()</code> was the caused. Is there a better solution for new instance?</p>
<pre><code> public static void main(String[] arg) {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while (!(speed.equals(speed_stop))) {
try {
speed = in.readLine();
if(!(Global.newPlayer.equals("1"))){new MidiTest();}
} catch (IOException e) {
System.err.println("Exception while reading the input. " + e);
}
}
}
private MidiPlayer player;
public MidiTest() {
System.out.println("Start player");
// /*
}
</code></pre>
|
java
|
[1]
|
1,098,990 | 1,098,991 |
Character encoding when passing value to PHP in GET URL parameter
|
<p>I have the following HTTP GET parameter in my URL what I'm trying to return in a query:</p>
<pre><code>Tablets & Phones
</code></pre>
<p>When I do <code>var_dump($_GET['my_get_param'])</code>, the string is not full, instead I'm getting <code>"Tablets "</code> (note the space afterwards.) How can I encode the string to get the desired value? I have been trying urlencode and html_specialchars, but without any result.</p>
<p><code>var_dump(urlencode($_GET["my_get_param"))</code> is returning <code>"Tablets+"</code>.</p>
|
php
|
[2]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.