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 |
|---|---|---|---|---|---|
5,688,648 | 5,688,649 | Why doesn't this cause an array out of bounds error in Python? | <p>I do not know much about python, but I am surprised the following code works:</p>
<pre><code>import sys
prev = [sys.maxint]*(5)
j = 0
print prev[j]
print prev[j-1]
</code></pre>
<p>In general I thought second <code>print</code> statement should give me an error. Why does this work?</p>
<p>I need to convert some <code>python</code> code into <code>C++</code>, and in <code>C++</code> this will not work.</p>
| python | [7] |
1,431,271 | 1,431,272 | Getting error while retrieveing value from name | <p>I am beginner with jquery, I am getting error while getting input from name in jquery..
My code is...
HTML</p>
<pre><code><input type="text" name="pcpfname" id="pcpfname" class="text" />
<input type="submit" name="pcpsubmit" id="pcpsubmit" value="Submit" />
</code></pre>
<p>Jquery</p>
<pre><code>$('#pcpsubmit').click(function(){
var pcpfname = $('input[name=pcpfname]');
alert (pcpfname);
});
</code></pre>
<p>My alert message is</p>
<pre><code>[object Object]
</code></pre>
| jquery | [5] |
3,356,451 | 3,356,452 | Avoid form Re-Submit | <p>I'm developing ASP.NET applications and stuck with a "problem" relating to resubmit behaviour.
I'm controling the re-submit using a counter in form submit event which disables the submit if it's already been posted.
My application is a 3 step workflow and when the 3rd step is shown the transaction was submited from step2 to step 3.
What's my problem? Well... i want to avoid the user to resubmit the data by pressing the F5 or all other possibility. I don't want to disable the key because may be workarounds.
I'm wondering if i can remove the post data in a HTTP module that runs after the render was completed and right before the response is sent to the user.</p>
| asp.net | [9] |
3,759,863 | 3,759,864 | Shape at "Actual Size" | <p>What's the easy way to render a shape in Java to its "actual size". For example, I have a tube with a diameter of 1" and I want to depict it on screen as the outline of a 1" circle. The Graphics2D method drawOval(int x, int y, int width, int height) takes a height and width in pixels. What are the steps to translate a pixel size into the size rendered on screen?</p>
<p>Thanks in advance.</p>
| java | [1] |
2,659,281 | 2,659,282 | how do you pass a parameter to a function when it is called by reference? | <p>I've created a global variable to pass informatin to a method that is called via a method reference</p>
<pre><code>d_g.onerror=i_bm_err_fix;
</code></pre>
<p>I tried passing it the variable like this(below) but it did not work.</p>
<pre><code>d_g.onerror=i_bm_err_fix(d_g);
</code></pre>
<p>All I'm trying to do is have a generic image load if the site favicon does not.</p>
<pre><code>function i_bm_err_fix(d_g)
{
d_g.src='http://www.archemarks.com/favicon1.ico';
}
</code></pre>
<p>Currently I'm using a global variable to pass this info. but this does not seem like good practice.</p>
| javascript | [3] |
740,568 | 740,569 | set textview color programaically for the item under section header Listview | <p>I have implemented a Section header Listview where i inflate a layout which have three textviews in it as item.i have referred this example <a href="http://jsharkey.org/blog/2008/08/18/separating-lists-with-headers-in-android-09/" rel="nofollow">here</a> to achieve it.</p>
<p>My code is </p>
<pre><code>adapter.addSection(monthitems2[l], new SimpleAdapter(this, security, R.layout.phone_row,
new String[] {"Title", "Caption","val1" }, new int[] { R.id.tvContact, R.id.tvMobile,R.id.tvMail }));
</code></pre>
<p>I have a condition where i need to change text color of ID "R.id.tvContact".I havent defined the textview anywhere in thelayout.i have just referred it as simpleadapter parameter.How to change the textview color the default is white.Any suggestions answers are highly appreciated.</p>
| android | [4] |
529,892 | 529,893 | Wordpress redirect to landing page if not logged in | <p>I'm using the following code in my functions.php file to redirect users who are not logged in to a particular landing page</p>
<pre><code> <?php
if(!is_user_logged_in()) {
wp_redirect( 'http://www.mysite.com/landingpage', 301 ); exit;
}
</code></pre>
<p>The problem is I cannot access my wp-login or wp-admin anymore. Every url redirects to landingpage. Is there a way I can exclude certain urls from redirecting?</p>
| php | [2] |
1,160,002 | 1,160,003 | Is it possible to make a DataTable as a AutoCompleteSource in a TextBox? (C#) | <p>Is it possible to make a DataTable as a AutoCompleteSource in a TextBox? (C#)</p>
| c# | [0] |
528,363 | 528,364 | How to Draw an arc between two cordinate | <p><strong>i want to Draw an arc between two cordinate</strong></p>
| java | [1] |
3,283,501 | 3,283,502 | need to store a bunch of constant integer values, class with just const or something better? | <p>I am making a class with a bunch of constant integer fields.</p>
<p>Any better ideas to doing it this way? maybe a struct would be better? if so, why?</p>
<p>This won't ever change, and will need to be referenced in the web application throughout.</p>
| c# | [0] |
710,342 | 710,343 | C# throwing dice method | <p>I need two methods. The first method throws four dice and returns the dice sum. The second method estimates the sum and print "excellent" if the sum is greater than 20, "good" if the sum is greater 12 or sum is less than or equal to 20 and "poor" if the sum is less than or equal to 12.</p>
<p>The dice are thrown by writing the rows</p>
<pre><code>Random ran = new Random ();
int throwingdice = ran.nextInt(1,7);
</code></pre>
<p>i tried many times but it wont work, any ideas?
Thank you in advance.</p>
| c# | [0] |
5,695,060 | 5,695,061 | Using jQuery i want to show li five at a time when i click the show button | <p>Using jQuery, I want to show li five at a time when I click the show button.</p>
<p>here is my code:</p>
<pre><code><button class="show">show</button>
<ul>
<li id="Li0">0</li>
<li id="Li1">1</li>
<li id="Li2">2</li>
<li id="Li3">3</li>
<li id="Li4">4</li>
<li id="Li5">5</li>
<li id="Li6">6</li>
<li id="Li7">7</li>
<li id="Li8">8</li>
<li id="Li9">9</li>
<li id="Li10">10</li>
<li id="Li11">11</li>
<li id="Li12">12</li>
<li id="Li13">13</li>
<li id="Li14">14</li>
<li id="Li15">15</li>
</ul>
</code></pre>
<p>The script is:</p>
<pre><code>$(".show").click(function(){
$("ul > li:lt(' + (index - 5) + ')+ ").addClass('active');
});
</code></pre>
<p>The css is:</p>
<pre><code>ul li{
display:none;
}
.active{
display:inline;
}
</code></pre>
| jquery | [5] |
5,510,949 | 5,510,950 | In Eclipse, how can I access a resource in another project? | <p>I have two projects in Eclipse and one has the class which has the 'main' function.
Let's call this project as 'A'.
And in this 'main' function, it instantiate a class in another project. Let's call this project and and the class, 'B' and 'C' respectively. In class 'C', it tries to load a RESOURCEFILE from the project 'B' by using 'System.property("user.dir")".</p>
<p>When I try to run this application from the project 'A', it can't get the RESOURCEFILE opened which is in project B because the working directory is in project 'A'. But I need to put the file in project 'B'.</p>
<p>I don't what is the best way to get this problem solved. Do I need to pass the information of the project B when I am running this application? I am totally lost..</p>
<p>I will wait for someone's help!</p>
<p>gim</p>
| java | [1] |
5,555,396 | 5,555,397 | Searching string while looping through $_SESSION variables | <p>Is there a better way to search through $_SESSION variables (or any array) for a particular string than:</p>
<pre><code>foreach($_SESSION as $k => $v){
if(strstr($k, 'p_')){
</code></pre>
<p>Thanks.</p>
<p>edit: My keys will look similar to:</p>
<p>p_123
p_456
i_123
...</p>
| php | [2] |
981,579 | 981,580 | sorting a list of strings according to an array of integers | <p>I have an array list <code>[Mod8, Mod5, Mod9, Mod10]</code> and an integer array <code>[1, 0, 2, 3]</code>. I need an output list <code>[Mod5, Mod8, Mod9, Mod10]</code> according to the numbers in the integer array. Any ideas of how to do this? </p>
| java | [1] |
3,549,722 | 3,549,723 | Argument question javascript | <p>One more question regarding arguments in javascript. I was reading a tutorial about the javascript framework Prototype and came over the following text, I will quote below:</p>
<p>"If you have some DOM methods of your own that you'd like to add to those of Prototype, no problem! Prototype provides a mechanism for this, too. Suppose you have a bunch of functions encapsulated in an object, just pass the object over to Element.addMethods():</p>
<pre><code>var MyUtils = {
truncate: function(element, length){
element = $(element);
return element.update(element.innerHTML.truncate(length));
},
updateAndMark: function(element, html){
return $(element).update(html).addClassName('updated');
}
}
Element.addMethods(MyUtils);
// now you can:
$('explanation').truncate(100);
</code></pre>
<p>The only thing to watch out here is to make sure the first argument of these methods is the element itself. In your methods, you can also return the element in the end to allow for chainability (or, as practiced in the example, any method which itself returns the element)."</p>
<p>Everything seems pretty straightforward except one thing that I seem to have problem understanding. It says that you need to make sure the first argument of these methods is the element itself. And that is the case in the functions but when you call the function you only provide 1 argument? So for example:</p>
<pre><code>$('explanation').truncate(100);
</code></pre>
<p>There is only 1 argument here that is sent to the function namely 100, but the function signature looks like this:</p>
<pre><code>truncate: function(element, length){
</code></pre>
<p>So element comes from where? And is it logic that you must make sure that the first argument is the element itself but you do not provide it when you call the function?</p>
| javascript | [3] |
5,511,917 | 5,511,918 | Android fullscreen image | <p>I'm quite experienced Android developer but I have very easy problem.
How to properly make a fullscreen image in Android?
Currently I'm using one better quality image and use it on all devices. This works quite ok but downscalling on very small devices looks bad and it can cause an OOM Error.</p>
<p>There were few threads about it, for example:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/8160515/fullscreen-images-and-android-resolutions">fullscreen images and android resolutions</a></li>
<li><a href="http://stackoverflow.com/questions/16135984/full-screen-background-image-in-an-activity">Full screen background image in an activity</a></li>
</ul>
<p>But in my opinion answers are not right.
Everybody says that I should use ldpi, mdpi, hdpi, xhdpi folders and I agree this works for small images (buttons, switches), nine patches, things that you want to have the same physical size on every screen.
When it comes to fullscreen this is wrong. My HTC Desire (480x800) is hdpi and my Samsung Galaxy Tab 2 (800x1280) is mdpi. Using above advices would result in Galaxy Tab 2 using smaller images than HTC Desire which is very wrong. </p>
<p>Is there any easy way to solve this fullscreen image problem?</p>
<p>Thanks in advance</p>
| android | [4] |
3,993,679 | 3,993,680 | automatically pick random select choices in web form | <p>I have a page with a bunch of radio fields. How can I create a script that will loop through each select group and pick a random choice from each.</p>
<p>I already have sections of the site implemented with scriptaculous, which has known jquery compatibility issues.</p>
| javascript | [3] |
5,683,350 | 5,683,351 | what is the meanning of " += ( s, e )" in the code? | <p>i can't find anywhere what is exactly the <code>+= ( s, e )</code> in the code. </p>
<p>example: </p>
<p><code>this.currentOperation.Completed += ( s, e ) => this.CurrentOperationChanged();</code></p>
<p>someone can explain ? </p>
<p>Thanks. </p>
| c# | [0] |
4,187,484 | 4,187,485 | Wrong event getting called, while adding item into listbox through textbox | <p><img src="http://i.stack.imgur.com/gv59f.png" alt="enter image description here"></p>
<p>I have <code>2 textboxes</code> and <code>2 listbox</code>, with respective add buttons of those.</p>
<p>When I just enter some text in textbox1 and press the enter it gets added into listbox1, as expected from event Add1.</p>
<p>Problem:</p>
<blockquote>
<p>When I just enter some text in textbox2 and press the enter it gets
added into listbox1, from event Add1. But it should get added in
listbox2 from event Add2.</p>
</blockquote>
<p>I checked the tab index after entering text in textbox 2 for both buttons Add1 and Add2 its "Zero".</p>
<p>What can be done? if I have enter text into textbox2, after hiting enter should call Add2 rather than Add1.
<strong>Update:</strong></p>
<pre><code> $('#textbox1').keypress(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
alert('You pressed a "enter" key in textbox1');
__doPostBack('<%=btnAdd1.UniqueID %>', '');
}
});
$('#textbox2').keypress(function(event){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
alert('You pressed a "enter" key in textbox2');
__doPostBack('<%=btnAdd2.UniqueID %>', '');
}
});
</code></pre>
<p>This is also not helping, when I add 1st item using Add2 and then tries to add using Add1.</p>
<p>Can anyone correct me what am I missing?</p>
| asp.net | [9] |
1,687,459 | 1,687,460 | memory management on back | <p>I am new to iPhone development.
I have an application with custom tab bar.
I am calling Back Button Method on my back button.
Here it is :</p>
<pre><code>-(void)backBtnPessed
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"GeneralViewController" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SchoolViewController" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"WorkViewController" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"FavoriteViewController" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ContactViewController" object:nil];
[self.navigationController popViewControllerAnimated:YES];
}
</code></pre>
<p>On every NSNotificationCenter, I am deallocation all objects of that file.
My Question is when I am checking in instrument , that objects are not deallocating.
So what should i do now?
Please help me. Thanking you...</p>
| iphone | [8] |
1,364,540 | 1,364,541 | JavaScript optimization with nested loops | <p>I have a huge array of points to draw on a canvas. Right now i am drawing every point by running a nested loop for x and y on the array of the data. This seems to be causing firefox to show a script has hanged notice.</p>
<p>What would be the best way to avoid that?</p>
<p>IMO some kind of parallel looping solution would be great, but the problem is i am not aware of any such method.</p>
| javascript | [3] |
3,880,093 | 3,880,094 | Cannot Run HelloWorld C++ App on Eclipse, Mac OS X? No RunAs Option; GCC Not Installed Despite XCode Installed | <p>I've spent hours this evening trying to get the hello world C++ App to run and no luck.</p>
<p>What I've Done:
1. Installed XCode and C++ for Eclipse as per <a href="http://www.banym.de/mac/install-eclipse-cc-juno-on-mac-os-x" rel="nofollow">http://www.banym.de/mac/install-eclipse-cc-juno-on-mac-os-x</a>
2. Tested that XCode works and can open it</p>
<p>What Happens:
1. When I create a new C++ Hello World project in Eclipse, I have no Run As options. Run As simply does not appear.</p>
<p><img src="http://i.stack.imgur.com/FV37A.png" alt="enter image description here"></p>
<p>Other Observations:
1. I am not convinced that GCC is really installed on my Mac because when I run "gcc -v" from a terminal I get "-bash: gcc: command not found"
2. When I attempt to go to "/bin/usr/gcc/" there is nothing (which <a href="http://www.tech-recipes.com/rx/726/mac-os-x-install-gcc-compiler/" rel="nofollow">http://www.tech-recipes.com/rx/726/mac-os-x-install-gcc-compiler/</a> implies that GCC is not installed but I know I have XCode installed).</p>
| c++ | [6] |
4,335,160 | 4,335,161 | How to handle Done button click event for Samsung Galaxy Ace [Solved] | <p>I have created EditText attached <code>setOnKeyListener</code> and <code>addTextChangedListener</code> Using both of these I can get the text entered by the user using softkey. But If user press Done button of that soft key then I want to perform some action. I tried to handle with <code>KeyEvent.KEYCODE_ENTER</code>. But the keycode is not same. How to Handle Done button click event for Samsung Galaxy Ace. </p>
| android | [4] |
1,231,043 | 1,231,044 | $_SERVER['HTTP_REFERER'] not working with Header | <p>I have a site that allows public access to some pages, but requires a login for others. I have a link to the login from all pages, and what I'd like to do after a successful login is send the user back to the page they were on when they clicked the login link. I know the HTTP_REFERER can be spoofed, and sometimes stripped out by certain hosts and proxies, but since it's strictly within my own site, and only a convenience for users, I'm not too worried about it. </p>
<p>I am curious about why it isn't working in conjunction with a redirect, though. I've set a visible field to contain the value of the http referer, and it displays correctly. So the page is getting the value of the referrer variable. But when I try this:</p>
<pre><code>$home_url = $_SERVER['HTTP_REFERER'];
header('Location: ' . $home_url);
</code></pre>
<p>it doesn't work. This, on the other hand, does:</p>
<pre><code>$home_url = 'http://' . $_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/discussions.php';
header('Location: ' . $home_url);
</code></pre>
<p>So I know the header location part works. Any idea why it doesn't want to work in conjunction with the http_referer variable? </p>
<p>(Also, does it drive anyone else nuts that referer is spelled incorrectly? I keep mistyping it using the OED spelling, silly me...)</p>
| php | [2] |
2,093,073 | 2,093,074 | How to keep only the last duplicate when iterating through rows | <p>Following code iterates through many data-rows, calcs some score per row and then sorts the rows according to that score:</p>
<pre><code>unsigned count = 0;
score_pair* scores = new score_pair[num_rows];
while ((row = data.next_row())) {
float score = calc_score(data.next_feature())
scores[count].score = score;
scores[count].doc_id = row->docid;
count++;
}
assert(count <= num_rows);
qsort(scores, count, sizeof(score_pair), score_cmp);
</code></pre>
<p>Unfortunately, there are many duplicate rows with the same docid but different score. Now i like to keep the last score for any docid only. The docids are unsigned int, but usually big (=> no lookup-array) - using a HashMap to lookup the last count for a docid would probably be too slow (many millions of rows, should only take seconds not minutes...).</p>
<p>Ok, i modified my code to use a std:map:</p>
<pre><code>map<int, int> docid_lookup;
unsigned count = 0;
score_pair* scores = new score_pair[num_rows];
while ((row = data.next_row())) {
float score = calc_score(data.next_feature())
map<int, int>::iterator iter;
iter = docid_lookup.find(row->docid);
if (iter != docid_lookup.end()) {
scores[iter->second].score = score;
scores[iter->second].doc_id = row->docid;
} else {
scores[count].score = score;
scores[count].doc_id = row->docid;
docid_lookup[row->docid] = count;
count++;
}
}
</code></pre>
<p>It works and the performance hit is not as bad as i expected - now it runs a minute instead of 16 seconds, so it's about a factor of 3. Memory usage has also gone up from about 1Gb to 4Gb.</p>
| c++ | [6] |
704,574 | 704,575 | Get a ZIP and extract contents OR file_get_contents individual files and then file_put_contents into folder | <p>I'm writing a script that will grab several files and then copy them into a new directory. I've come up with two methods of doing this but want to know which is better.</p>
<p><strong>1)</strong></p>
<ul>
<li>store several file names in an array and use file_get_contents in a loop to get those files.</li>
<li>same again, but using file_put_contents to copy these files to a new directory.</li>
</ul>
<p><strong>2)</strong></p>
<ul>
<li>Store these files needed in a .ZIP file by default</li>
<li>Use PHP to open this zip and extract the contents to the new folder.</li>
</ul>
<p>I'm guessing that the ZIP method is better to use but I have no evidence to back that up. Can anyone advise me on what's best?</p>
| php | [2] |
5,478,327 | 5,478,328 | Task Parallel library vs Native Thread Synchronization | <p>This quetion may be subjective but i just want to know when to use TPL and when to use native thread based synchronization (evnts , wait handles)</p>
<p>is the native thread synchronization techniques will be obsolete going forward?</p>
<p>Thanks</p>
| c# | [0] |
2,811,548 | 2,811,549 | good examples of model-view-controller | <p>I'm new to Objective-C and the iPhone and thought I was getting the hang of it until, after many play apps, I ran into a really basic problem around MVCs, NIBs and IB. Are there any really clear explained examples of how to follow this framework that I could go back to?</p>
<pre><code>@interface test1ViewController : UIViewController {
IBOutlet myView *myview;
IBOutlet myModel *mymodel;
}
</code></pre>
<p>Both the views and models are linked in by IBOutlets but instantiating the model object either kills the application or produces an object which does not respond to any messages. </p>
<p>I am also unclear as to where to carry best out initialisations. I currently do this over viewDidLoad in the view controller. Is there a standard way to do this and does the simulator actually always start up in the same way? Should one use awakeFromNib? Does it make any difference if I use plain code or the IB? And if I have use the IB, should it include a model object?</p>
<p>The MVC idea would make good sense for me here because I have potentially several views and view controllers all feeding back into - and sharing - one common central data model. Any references or advance on this newbie problem would be more than welcome!</p>
| iphone | [8] |
1,103,754 | 1,103,755 | Java update on windows xp problem | <p>I have JBOSS IDE 1.5(eclipse 3.x) on my windows xp computer and it works fine for years.
Today when I tried to open JBOSS IDE 1.5, it give me following error when startup:
JVM terminated. Exit code=2</p>
<pre><code>C:\WINDOWS\system32\javaw.exe
-Xmx512m
-jar C:\eclipse\startup.jar
-os win32
-ws win32
-arch x86
-launcher C:\eclipse\eclipse.exe
-name Eclipse
-showsplash 600
-exitdata 1128_70
-vm C:\WINDOWS\system32\javaw.exe
-vmargs
-Xmx512m
-jar C:\eclipse\startup.jar
</code></pre>
<p>But I did not change anything for last time good working.
So I check javaw.exe on windows/system32 and found it's updated at 2009-07-30.</p>
<p>Really frustrated. How to resolve this problem?</p>
| java | [1] |
859,790 | 859,791 | Progress Dialog dont move | <p>Hi I try show progress dialog when mymethod is running with code that below. When thread starts the progress dialog stop I dismiss it at the end of the method that called in thread. How can I solve this?</p>
<pre><code>>mDialog = new ProgressDialog(DealActivity.this);
mDialog.setMessage("Loading...");
mDialog.setCancelable(false);
mDialog.show();
mDialog.setProgress(0);
new Thread() {
public void run() {
mymethod();
}
}.start();
</code></pre>
| android | [4] |
5,582,426 | 5,582,427 | list images in a directory with php and add a specific class | <p>How can i list images in a folder...(which could be any number) and echo them in a list making the sure the first li has a class of "first" and the the last list item has a class of "last" like so...</p>
<pre><code><li class="first"><img src="flowing-rock.jpg" /></li>
<li><img src="stones.jpg" alt="Stones" /></li>
<li><img src="grass-blades.jpg" /></li>
<li><img src="ladybug.jpg" alt="Ladybug" /></li>
<li class="last"><img src="pier.jpg" alt="Pier" /></li>
</code></pre>
<p>Any help would be appreciated...</p>
| php | [2] |
4,218,783 | 4,218,784 | sorting columns using particular words in c# | <p>i have a table with a column named size which will have values big,medium and small. wat i want is i want to sort this column in such a way that all rows with size big should come first, then rows with size medium and finally rows with size small.
is there a way by which i can achieve this?</p>
<p>edit: it is a data table which i add to a dataset.</p>
<p>edit: wat if the initials of the words, in this case b,m and s, are not in alphabetical order. in that wat am i supposed to do coz i have another application as well where i'll be required to sort a column having value High, normal and low. </p>
| c# | [0] |
5,307,703 | 5,307,704 | iphone app release mode issue | <p>i am about to launch app in app store,
i am trying to run code in release mode , i downloaded the <strong>release mode profile</strong>
but when i compile code from iphone they say</p>
<p><strong>"A valid provisioning profile for this executable was not found."</strong></p>
<p>how to solve this pls help</p>
############## EDIT
<p>now i can run release mode on my iphone but i got this msg
<strong>The program being debugged is not being run.</strong></p>
<p><strong>so now can i upload this release file to appstore???</strong>
my setting</p>
<pre><code>Code Sign Entitlements:Entitlements.plist
Code Sign Identity: my iphone dist release profile
any iphone dev: my iphone dist release profile
</code></pre>
<p>are these parameters sufficient to lauch app??</p>
| iphone | [8] |
2,095,901 | 2,095,902 | how to split string according to character length | <p>I have a string which has say 3000 characters, now I want to split the same into array, where each index holding not more than 500 characters, I am not getting the logic for the same. I tried the below one but its not working..</p>
<p>say string arr holding 3000 characters... </p>
<p>I am using a loop to get the characters length of 500</p>
<p>here i am storing the value returned by the loop in an array...</p>
<p>say </p>
<pre><code>ArrayList ar = new ArrayList();
for(int i=0; i < arr.Length; i+=500)
{
ar.Add(arr.Substring(i,500));
}
Response.Write(ar[0].ToString());
</code></pre>
<p>but this throws an error message saying </p>
<blockquote>
<p>Index and length must refer to a location within the string.</p>
</blockquote>
<p>Please reply with the appropriate code for the same, any reply would be greatly appreciated.</p>
| c# | [0] |
2,803,579 | 2,803,580 | calendar control: MS Ajax vs. jQuery | <p>I need to put a calendar control on an aspx page. I can choose among the multiple jQuery plug-ins or use the calendar control that comes with the Ajax Control Toolkit.</p>
<p>What's going to be easier/faster/better?</p>
<p>Thanks.</p>
| asp.net | [9] |
1,944,811 | 1,944,812 | Android Span or Non-Breaking Space Causing line break and text duplication (4.0 ICS) | <p>I'm using several text views with heavy use of spans.</p>
<p><strong>The Problem:</strong> Sometimes in my app (specifically on Ice Cream Sandwich) I will see a line break that isn't in the text string, along with text duplication. See the image below for an example. Notice how the third sentence begins, then there is a line break, then the text is duplicated and the sentence finishes.</p>
<p><img src="http://i.stack.imgur.com/UcHoS.png" alt="enter image description here"></p>
<p><strong>Code:</strong></p>
<pre><code>tv = (TextView) inflater.inflate(R.layout.fragment_reader_list_item, parent, false);
SpannableStringBuilder ssb = ssbList.get(position);
tv.setText(ssb, BufferType.SPANNABLE);
</code></pre>
<p>When I debug into the code, the variable 'ssb' properly only contains the text ..."3 not domineering over those in your charge, but being examples to the flock. 4 And when the chief"...</p>
<p><strong>Some specifics I've noticed from playing around with it for a few hours:</strong>
The conditions that cause the bug seem to have something to with with the overall width of the rendered text. For instance, with the text pictured above, if I turn off bold span on the numbers, the pictured text will show properly, however if I leave the bold span, andturn off the color change span on the number (which doesn't change the width at all), the issue persists.</p>
<p>It's also worth noting that after each number I'm using a non-breaking space. If I swap the non-breaking space with a breaking space, I don't see the issue anymore, but that's more or less probably because the rendered string changes. This issue may not have anything to do with spans, but it seems like too big of a bug to pass with just any old text.</p>
<p>Any help is greatly appreciated!</p>
<p><strong>EDIT:</strong>
This bug seems strongly linked to the use of the Bold span. Taking it off of the numbers fixes the problem. That's what I've currently resorted to as a work-around. It'd be nice if there was a better option.</p>
| android | [4] |
3,289,236 | 3,289,237 | how can I launch an activity directly from my activity | <p>In my android project, I have 2 Activities. How can I launch an Activity from an Activity.
I know I can do 'startActivity', but my activity has NOT registered for any Intent, is there anyway I can still launch it from my activity?</p>
<p>Thank you.</p>
| android | [4] |
1,052,359 | 1,052,360 | Is there a way to search and retrieve the first image from a site using php? | <p>Is there a way to search for an image and retrieve the url for it using php for another site, sort of like using get_meta_tags, or for example something like the facebook micropublisher, when you paste a url inside, it grabs an image associated with the site, is there a way to do this? any help would be greatly appreciated.</p>
| php | [2] |
4,992,659 | 4,992,660 | variable 'fstream grabpass' has initializer but incomplete type | <p>I'm getting an error reading from a file using fstream, on line 37 (fstream grabpass("passwords.txt");) but doesn't seem like I'm doing anything wrong.</p>
<pre><code>#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int i,passcount,asterisks;
char replace, value, newchar;
string username,password,storedUsername,storedPassword;
int login(string username, string password)
{
if (username=="test"/*storedUsername*/)
{
if (password==storedPassword)
cout<<"Win!";
else
cout<<"Username correct, password incorrect.";
}
else cout<<"Lose. Wrong username and password.";
}
int main()
{
cout<<"Username: ";
cin>>username;
cout<<"Password: ";
do
{
newchar = getch();
if (newchar==13)break;
for (passcount>0;asterisks==passcount;asterisks++)cout<<"*";
password = password + newchar;
passcount++;
} while (passcount!=10);
fstream grabpass("passwords.txt");
getline(grabpass,storedPassword);
grabpass.close();
login(username,password);
return 0;
}
</code></pre>
| c++ | [6] |
4,609,131 | 4,609,132 | get Special Character | <p>I would like to intercept the arrow keys on the java command line to move a character inside the shell!</p>
| java | [1] |
2,328,651 | 2,328,652 | Extending a class with a variable? | <p>This works and is tested.
PHP Code:</p>
<pre><code>$data_stats = json_decode($ret);
$projected_points = $data_stats->body->player_stats->42550689->FPTS
</code></pre>
<p>I just need to know how to do it using a variable. Something like this:
PHP Code:</p>
<pre><code>$data_stats = json_decode($ret);
$projected_points = $data_stats->body->player_stats->$id->FPTS
</code></pre>
<p>How can I make $id work here?</p>
<p>Also is this called extending a class? I don't even know the correct terminology to describe my question.</p>
| php | [2] |
5,798,082 | 5,798,083 | Add a class to first li if last li contains class | <p>There is a class that is being added to the li on hover <a href="http://jsfiddle.net/6PfKb/9/" rel="nofollow">in this fiddle</a>.</p>
<p>I want to be able to add a class to the first li if the last li has the .on class applied to it. I have tried something like this but it doesn't seem to work?</p>
<pre><code>if ($("li.top-level:last").contains(document.on))
{
$('li.top-level:first').addClass('first');
}
</code></pre>
<p><a href="http://jsfiddle.net/aaronk85/6PfKb/21/" rel="nofollow">Updated fiddle</a> with suggested answer.</p>
| jquery | [5] |
3,504,334 | 3,504,335 | GetWebResponse very slow on windows7 | <p>I have tried all the settings, i found on internet to make the C# webclient fast on a Windows7 machine
to no avail. The same exe on Windows XP machine responds in less 100ms for every request.</p>
<p>I have overridden the GetWebRequest function in the derived class of
<strong>System.Web.Services.Protocols.SoapHttpClientProtocol</strong></p>
<pre><code> protected override WebRequest GetWebRequest(Uri address)
{
//ServicePointManager.UseNagleAlgorithm = false;
HttpWebRequest.DefaultWebProxy = null;
ServicePointManager.DefaultConnectionLimit = 4096;
ServicePointManager.Expect100Continue = false;
System.Net.ServicePointManager.CheckCertificateRevocationList = false;
HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
request.Proxy = HttpWebRequest.DefaultWebProxy;
return (WebRequest)request;
}
</code></pre>
<p>protected override WebResponse GetWebResponse(WebRequest request)
{</p>
<pre><code> HttpWebResponse response = null;
//HttpWebRequest.DefaultWebProxy = null;
//ServicePointManager.Expect100Continue = false;
response = (HttpWebResponse)base.GetWebResponse(request);
return response;
}
</code></pre>
<p>I have also added the socket trace settings in the machine.config .Net4.0 folder
and it always waits on the below statement for 7-15 seconds in the output window</p>
<p><strong>System.Net.Sockets Verbose: 0 : [6088] Socket#54042743::Receive()</strong></p>
<p>Hope some champion has resolved this</p>
| c# | [0] |
6,013,673 | 6,013,674 | javascript: What's the difference between functionName() and functionName? | <p>I've noticed that you can reference a function with or without the parentheses. Why?, what's the difference?</p>
<p>As a slight aside, I've noticed this works:
<code>window.onload = functionName;</code></p>
<p>Whereas this doesn't:
<code>window.onload = functionName();</code></p>
<p>Could anyone explain why the top line of code works and the bottom doesn't?</p>
| javascript | [3] |
4,582,456 | 4,582,457 | Auto refreshing with Javascript? | <p>Sorry if this is a simple question (or answered before), but could anyone tell me how to download a page with JScript? I want to use Javascript to download the page "example.php" on my server every five seconds and compare it with what it was before. If the page changes, I would like the Javascript code to refresh the page hosting the Javascript. Does that make sense ? Somethingl ike:</p>
<p><code>string downloaded = DownloadPage("example.php");</code></p>
<p><code>timer x = new timer(5);</code></p>
<p>when the timer goes off:</p>
<p><code>if(DownloadPage("example.php") == downloaded){</code></p>
<p><code>RefreshPage();</code></p>
<p><code>}</code></p>
<p>Thanks, and sorry this was probably such an easy question :)</p>
| javascript | [3] |
2,659,173 | 2,659,174 | Unbind keypress handler for specific combination only | <p>I have 2 keydown handlers:</p>
<pre><code>$(document).bind('keydown', function(e) {
if (e.keyCode == 75) {
// handler1 strategy
} else if (e.keyCode == 78) {
// handler2 strategy
}
});
</code></pre>
<p>How can I unbind one handler without affecting all the other keydown handlers?</p>
<p>updated.</p>
| jquery | [5] |
2,126,516 | 2,126,517 | Auto create directories after uploading with PHP | <p>I'm creating a php site where a company will upload a lot of images. I'd like one folder to contain upto 500-1000 files and PHP automatically creates a new one if previous contains more that 1000 files.</p>
<p>For example, <code>px300</code> has folder <code>dir1</code> which stores 500 files, then a new one <code>dir2</code> will be created.</p>
<p>Are there any existed a solutions?</p>
| php | [2] |
4,155,457 | 4,155,458 | About using Microsoft Chart Controls for Microsoft .NET Framework 3.5 | <p>I download the Microsoft Chart Controls Add-on for Microsoft Visual Studio 2008
and Microsoft Chart Controls for Microsoft .NET Framework 3.5.</p>
<p>But can not able to see the control in toolbox of visual studio 2008.</p>
<p>Regards
Hrishi</p>
| asp.net | [9] |
1,224,093 | 1,224,094 | Bitmap ListAdapter from assets | <p>I am trying to create ListAdapter for bitmaps stored in <code>assets/</code>(size of each is about 300k).</p>
<p>I have 1 activity contains GridView, and 2nd is just ImageView.</p>
<p>When I'm picking one of images from 1st activity to show in second Activity and then try to save on filesystem it often throws me OOM(OutOfMemory) or Bitmap exceeds VM budget.</p>
<p>My request is next:
What kind of solution you can suggest to organize Bimaps from <code>assets/</code> for using via ListAdapter? </p>
| android | [4] |
3,801,424 | 3,801,425 | Error : Retrieving the COM class factory for component with CLSID {xxxx} failed due to the following error: 80080005 | <p>I am using My Company's Outlook account to send mails, but i got this error : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.</p>
<p>The Sendmail method is given below:</p>
<pre><code> public static void SendEmail(string _ToEmail, string _Subject, string _EmailBody)
{
oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)(oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem));
email.Recipients.Add(_ToEmail);
email.Subject = _Subject;
email.Body = _EmailBody;
((Microsoft.Office.Interop.Outlook.MailItem)email).Send();
}
</code></pre>
<p>and also I added both Microsoft.Office.Interop.Outlook.dll and office.dll to my solution.</p>
<p>any suggestion?</p>
| asp.net | [9] |
3,580,439 | 3,580,440 | JTabbedPane on mac os | <p>one of the Java application developed working properly on the microsoft windows xp,vista,2007 and on linux but on mac os when we clicked on tab its stop working not getting what happens any one having idea what may be the issue.</p>
| java | [1] |
3,164,308 | 3,164,309 | How to implement refinement in JavaScript | <p>I am trying to implement (so-to-say) a refinement in JavaScript. Kindly look at the following example:</p>
<pre><code><html>
<head>
<title>Function Override (Refinement) example</title>
<script type="text/javascript">
// original function
function oneFunc() {
document.writeln("<p> In original oneFunc() </p>");
}
var prevOneFunc = null;
if (oneFunc) {
prevOneFunc = oneFunc;
}
// redeclared function (should refine/complement the original one)
function oneFunc() {
if (prevOneFunc) {
prevOneFunc(); // should call original oneFunc(), BUT IT ISN'T
}
document.writeln("<p> In refined oneFunc() </p>");
}
oneFunc();
</script>
</head>
<body>
</body>
</html>
</code></pre>
<p>My intention was to have two printouts:</p>
<blockquote>
<pre><code>In original oneFunc()
In refined oneFunc()
</code></pre>
</blockquote>
<p>However, it seems that since at the <em>moment of execution</em> <code>oneFunc</code> refers to the new/refined function, hence the output is different than expected. In the debugger checked that I am entering into the infinite recursion :) (yes, understood why exactly).</p>
<p>Please explain which information I am missing to implement it properly. </p>
<p><strong>Update:</strong> A few limitations: I think (not sure) that I can't modify the original <code>oneFunc</code> declaration and it is declared just like described above. I shouldn't modify the declaration of the refined <code>oneFunc</code> either.</p>
| javascript | [3] |
3,776,924 | 3,776,925 | how to remove phone from contact | <p>I want to remove the phone tab from android contacts application. How can i do this? </p>
<p>Also how can i rotate the focus on contacts different tabs means when focus reaches on the last last tab of contact when pressing keyboard it should focus on first tab.</p>
| android | [4] |
1,921,137 | 1,921,138 | User complaining of Android app 'disappearing' following an update | <p>A user of one of my Android apps has reported that his version 'disappeared' following an update. None of the other (thousands of) users have reported issues.</p>
<pre><code>This morning I tried to open up the app but could not get anything.
I tried and tried and then physically turned my phone off and back on.
Now the icon has disappeared.
</code></pre>
<p>He has a lot of data stored in the app, so removing and re-installing isn't an option.</p>
<pre><code>I think the problem has been caused by another apps update which happened yesterday.
I can see your icon in my apps list but it is the only one that is black and white, all the rest are in colour.
When I view the properties of your app it says:
Storage 20.00KB
Application 0.00KB
Data 20.00KB
It gives an option to clear data or uninstall.
My memory card, which I haven't removed, says I have 55mb of data left.
</code></pre>
<p>What could have caused this, is there anything I can do to avoid this happening to users in the future and is there anything I can suggest to remedy his problem?</p>
| android | [4] |
5,418,033 | 5,418,034 | download file from database through browser in java desktop (non web) | <p>is it possible to download file from database through browser (ex: mozilla,chrome) in java desktop application (non web app) ? can you explain me with an example code ?<br>
thanks in advance,</p>
| java | [1] |
5,080,831 | 5,080,832 | populating database from csv file using php | <p>How would I go about populating a database from info in a csv file using PHP code? I need to practice using php to make database calls but at the moment, all I have access to is this csv file...</p>
| php | [2] |
3,029,515 | 3,029,516 | bind method of javascript | <p>what is the use of bind() in javascript??</p>
| javascript | [3] |
2,424,789 | 2,424,790 | UITableViewCell Resign FirstResponder | <hr>
<p>Hi,</p>
<p>I have a UIViewController class that contains a UITableViewCell subclass.</p>
<p>Within the tableViewCell I have a UITextView that calls the numberPad which I have ammended to contain the missing DONE button.</p>
<p>THe DONE button, when pressed calls a method named backgroundPressed. This method is called from the root UIViewController class.</p>
<pre><code>-(IBAction)backgroundPressed:(id)sender{
[textField2 resignFirstResponder];
</code></pre>
<p>The problem I have is that calling this method does not dismiss the numberPad. This is probably because the method is called from the UIViewContoller class. How do I access
the UITableViewCell to resign the first responder when the for the UITextView?</p>
<p>Many Thanks</p>
| iphone | [8] |
901,475 | 901,476 | C++ What's wrong with my array/loop? | <p>I've just started learning C++ so I'm fairly sure the answer may be a simple one. As a test I'm just setting up an array and then wanting to print out the array by looping through it.</p>
<p>My code is below. It prints out my array as expected but then prints out a load of other numbers below it. What are these numbers and where are they coming from? I suspect that 'sizeof' isn't the best to use. All of the examples i've found are alot more complicated than I need. In any case I am interested to understand the extra numbers. Any insight available?</p>
<pre><code>int age[4];
age[0]=23;
age[1]=34;
age[2]=65;
age[3]=74;
for (int i = 0; i <= sizeof(age); i++)
cout << age[i] << endl;
return 0;
</code></pre>
<p>...output:</p>
<pre><code>23
34
65
74
4
2147307520
0
2293608
4198582
1
3084992
3085608
-1
2293592
1980179637
-725187705
-2
</code></pre>
| c++ | [6] |
1,835,036 | 1,835,037 | Speed and style of Math.max vs ternary operator in JavaScript | <p>In JavaScript, is it better to do this:</p>
<pre><code>var h = th > ch ? th : ch;
</code></pre>
<p>or </p>
<pre><code>var h = Math.max(th, ch);
</code></pre>
<p>?</p>
| javascript | [3] |
2,787,316 | 2,787,317 | Android in-app billing cancel payment, application not active | <p>I'm having trouble figuring out how the in-app billing process is supposed to work for broadcast events when the application isn't running. I have a managed product setup and as far as I can see, is working well. With a test account I'm able to purchase my published component and my test application handles it, retaining its state. I then cancel this order via my merchant account and the application again receives the event and removes the item.</p>
<p>The problem occurs when instead of cancelling the order while the application is active. I exit out of it (not with home, with multiple back buttons). If I cancel the item now, my '<em>device</em>' gets a notification 'purchase failed', but when I start my application nothing seems to happen and thus the state of the item is still purchased.</p>
<p>I'm not sure if billing service is still running or not. Given the <a href="http://developer.android.com/guide/google/play/billing/billing_overview.html#billing-action-notify" rel="nofollow">documentation</a> says my application must send back a CONFIRM_NOTIFICATIONS or it keeps sending it I can only assume it is. However why is it unable to interact with my database and remove the item like it does correctly if the application is active?</p>
<p>I hope tihs is clear, and I apologize if it has been discussed before, I couldn't find anything in my searches.</p>
| android | [4] |
5,722,652 | 5,722,653 | Team programming | <p>We are a little group of developers who are going to develop apps for android. We are using Eclipse for that. We need an application to mantain project synchronization between different computers. Is there any application for that? I mean that we create a project or a workspace in eclipse and all the files are synchronized with other computers.</p>
| android | [4] |
2,999,197 | 2,999,198 | Java Game Programming with JFrames | <p>Hello everyone I am interested in Java game programming, but I want to do it with JFrames not applets. I was wondering if there were any tutorial websites that would show me how, because all of the ones I found were about applets. Any help would be appreciated.</p>
<p>Thank you for reading this message.</p>
| java | [1] |
5,017,112 | 5,017,113 | Cannot connect zte android device | <p>I have ZTE Cool android phone, which I want to use it for android development. I could not see the device from Eclipse. I could not install the some drivers for Windows 7. </p>
<p>When I the connect phone to a PC, Windows says that the driver installation is being done, but it does not finish successfully. It says <em>"ZTE HSUSB device did not install successfully"</em>. When I try to download and install the driver manually, it says the driver is up to date. So I could not connect to device from Eclipse.</p>
<p>Can anyone help solve this issue?</p>
| android | [4] |
4,901,376 | 4,901,377 | Two Gridview inside Panel - Not Properly Binded | <p>I am working in C#.Net. I am having a gridview. In that there is a EDIT button. If i click the EDIT button, i am opening a Model PopUp extender Panel. In that i am binding two gridviews. </p>
<p>My problem is, The first gridview inside panel is binding properly, but the second gridview is not binding. Even though the dataset is having the values, the EMPTYDATA TEXT = "No Records Found" is displayed.</p>
<p>I am binding these two gridviews in Row Command event of Main Gridview.</p>
<p>This is the code for Second gridview binding.</p>
<pre><code>DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("StatusUpdateID"));
dt.Columns.Add(new DataColumn("StatusUpdate"));
dt.Columns.Add(new DataColumn("CreatedBy"));
dt.Columns.Add(new DataColumn("CreatedDateTime"));
DataRow r = dt.NewRow();
r["StatusUpdateID"] = "1";
r["StatusUpdate"] = "2";
r["CreatedBy"] = "3";
r["CreatedDateTime"] = "4";
gvStatus.DataSource = dt;
gvStatus.DataBind();
</code></pre>
| c# | [0] |
100,152 | 100,153 | c# protected key word related problem | <p>I have a product.aspx class</p>
<pre><code>public partial class _Products : Product
{
protected void Page_Load(object sender, EventArgs e)
{
Product p1 = new Product();
p1.m1(); ///here I am facing problem y intelligence system not allowing me access the product class method m1();
}
new virtual int m1()
{
return 10;
}
}
</code></pre>
<p>and in my AppCode I have a class product.cs</p>
<pre><code>public class Product
{
public Product()
{
//
// TODO: Add constructor logic here
//
}
protected void m1()
{
}
public void m2()
{
}
</code></pre>
<p>Tthe problem is, p1.m1(); here I am facing problem my intelligence system not allowing me access the product class method m1(); </p>
| c# | [0] |
5,572,844 | 5,572,845 | how is the decision taken at run time whether to call derived class function or base class function? | <p>How is the decision taken internally (during runtime) as to which function to call, either the base class or derived class function. In the below sample code how is decision taken to call <strong>fn()</strong> of <strong>B</strong> and <strong>fn2()</strong> of <strong>A</strong>.</p>
<pre><code>Class A {
virtual void fn() { std::cout << "A" < <std::endl; }
virtual void fn2() { std::cout << "A-fn2" < <std::endl; }
};
Class B : A
{
void fn() { std::cout << "B" < <std::endl; }
}
int main() {
B b = new B;
A *a = &b;
a->fn();
a->fn2();
}
</code></pre>
<p>The output would be <strong>B</strong> and <strong>A-fn2()</strong></p>
<p>Basically how is the decision taken at run time whether to call derived class function or base class function?</p>
| c++ | [6] |
4,889,065 | 4,889,066 | "misplaced construct(s)" in Java code near a catch | <p>I could not compile the following code in Java, error is: misplaced construct(s). What's wrong?</p>
<pre><code>public class ExceptionsTutorial {
public static void main(String[] argv) throws Exception{
try{
System.out.println("A");
try{
System.out.println("B");
throw new Exception("1");
}
catch{
System.out.println("C");
throw new Exception("2");
}
finally{
System.out.println("D");
throw new Exception("3");
}
}
finally{
System.out.println("F");
}
}
}
</code></pre>
| java | [1] |
4,034,317 | 4,034,318 | distutils create a .egg-info directory | <p>For some reason, using</p>
<pre><code>python setup.py sdist
</code></pre>
<p>started creating a folder called .egg-info
whenever I run it.</p>
<p>This did not happen before. What is this file? How can I disable it?</p>
| python | [7] |
2,837,759 | 2,837,760 | implementing publish subscribe scenario using distributed programming native C++ | <p>i want to implement publish subscribe scenario using a client on one machine and a server found on separate machine , clients to subscribe for specific event on server and server to notify the clients at time event occurs. consider native c++ , client and server run on separate machines.
even a sample code snippet , link ...
thank you </p>
| c++ | [6] |
2,738,401 | 2,738,402 | Does jquery validation Plugin validate alphabets/characters | <p>Is there a way to validate characters via jquery validaton plugin?</p>
| jquery | [5] |
2,064,511 | 2,064,512 | Pythonic way to make sure list exists at dict key before appending | <p>I'm asking this from the perspective that my impression is that it's more Pythonic to ask forgiveness than permission.</p>
<p>So, I've got some code that's like:</p>
<pre><code>d = dict()
try:
d[est['state']].append(est)
except Exception:
d[est['state']] = []
d[est['state']].append(est)
</code></pre>
<p>In the above code I ask forgiveness rather than permission at the expense of repeating myself, which is pretty lame! So, knowing no alternative, I would rather:</p>
<pre><code>d = dict()
if est['state'] in d:
d[est['state']].append(est)
else:
d[est['state']] = [est]
</code></pre>
<p>Both of these approach are sort of gnarly. What's a better way to do this? Best I've found so far is:</p>
<pre><code>from collections import defaultdict
d = defaultdict(list)
d[est['state']].append(est)
</code></pre>
| python | [7] |
1,407,962 | 1,407,963 | how to write integer number in particular no of bytes in python ( file writing) | <p>assume i have to store few integer numbers like 1024 or 512 or 10240 or 900000 in a file, but the condition is that i can consume only 4 bytes (not less nor max).but while writing a python file using write method it stored as "1024" or "512" or "10240" ie they written as ascii value but i want to store directly their binary value.</p>
<p>Any help will really appreciable. </p>
| python | [7] |
3,231,452 | 3,231,453 | Breaking upgrades in Android | <p>It will save a lot of coding if I am able to make a breaking change to my Android application. Instead, they will have to download a clean install and visit a URL to reinitialise the application data.</p>
<p>According to the <a href="http://developer.android.com/guide/publishing/publishing.html#marketupgrade" rel="nofollow">documentation</a>, "if the package name and signing certificate do not match those of the existing version, Market will consider it a new application and will not offer it to users as an update." This would allow me to publish a new version of the application without the user being able to accidentally upgrade and break the application. </p>
<p>If I do upload a new version of my application with a different signing certificate, will the application appear in the application store twice? If so, is there any way to prevent users from downloading the old application?</p>
| android | [4] |
2,335,619 | 2,335,620 | maintaining view state in asp.net | <p>I am creating fileupload control at run time. When I click a link button a new fileupload control is generated.</p>
<p>Now suppose I have selected a file from a upload control and now I click the linkbutton...</p>
<p>The previous fileupload control loses it's path...however I'm maintaining the viewstate of each control that I create at runtime by usng this line:</p>
<pre><code>f1.enableviewstate=true;
</code></pre>
<p>How do I maintain the data of fileupload control?</p>
| asp.net | [9] |
4,301,383 | 4,301,384 | jQuery: Click an element and add a class to a div, click away and it removes class | <p>I've researching this problem and I can find a solution for adding/removing a class to the div i'm clicking, but not a separate div altogether e.g.</p>
<p>Click the input with the class .search-bar.... and it adds a class to a div called .search-wrap... click anywhere else on page/off element it removes the class added to .search-wrap.</p>
<p>I've tried this:</p>
<pre><code>$("div.search-bar").click(function(){
$("div.search-wrap").addClass("white");
});
</code></pre>
<p>Any ideas please?</p>
| jquery | [5] |
4,347,254 | 4,347,255 | Difficulty in maintaining the previous state of progress bar when activity is resumed | <p>I am trying to download an mp3 file. For this i have created an activity like this:</p>
<pre><code>public class audiostream extends Activity{
private Button streamButton;
private ImageButton playButton;
private TextView textStreamed;
private boolean isPlaying;
private StreamingMediaPlayer audioStreamer; //This is the object of supporting class
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//other activities }
</code></pre>
<p>now on the button click event i am calling this function:</p>
<pre><code>private void startStreamingAudio() {
try {
final ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
if ( audioStreamer != null) {
audioStreamer.interrupt();
}
audioStreamer = new StreamingMediaPlayer(this,textStreamed, playButton, streamButton,progressBar);
audioStreamer.startStreaming("file path",file_size,duration);
streamButton.setEnabled(false);
} catch (IOException e) {
}
}
</code></pre>
<p>Give below is the StreamingMediaPlayer class:</p>
<pre><code>public class StreamingMediaPlayer {
private TextView textStreamed;
private ImageButton playButton;
private ProgressBar progressBar;
public StreamingMediaPlayer(Context context,TextView textStreamed, ImageButton playButton, Button streamButton,ProgressBar progressBar)
{
this.context = context;
this.textStreamed = textStreamed;
this.playButton = playButton;
this.progressBar = progressBar;
}
}
</code></pre>
<p>Rest of the works are done by the remaining class such as incrementing the progress bar, playing the audio etc.</p>
<p>Progress bar increments as audio progresses. The issue that i am facing is that, while playing the audio, if i am pressing back button and opening previous activity the audio plays (this is what i want), but when i come back to the activity with the help of intent, everything appears in a way that activity is just created. The progress bar which was previously progressing now looks when i first opened this activity. In simple sentence the problem is that, the activity which is playing the audio file is not resuming the previous state. Kindly help me.</p>
| android | [4] |
4,581,808 | 4,581,809 | Working of pre-fix increment in Java | <p>What is the control flow of post-increment operator?</p>
<pre><code>public class PostIncrement
{
public static void main(String[] args)
{
int a = 0;
for(int i=0;i< 2 ;i++)
{
a =a++;
}
for(int i=0 ;i< 1;i++)
{
a++;
}
System.out.println("Result2 :"+" "+a);
}
}
</code></pre>
<p>The results are like 0 and 1</p>
<p>Why is it so?</p>
| java | [1] |
4,953,778 | 4,953,779 | loading image is taking too much time | <p>now Im doing an android application . In my app I have to swipe and show different pages.Each page is having some images.To make the sense of moving image [eg: smiling apple] I am using the logic of showing one image and hide that image and show second image in the same position and third so on.But this process is taking too much time to load image. </p>
| android | [4] |
4,504,035 | 4,504,036 | Jquery button click to select check box | <p>I have grid with user data with first column having check box.. I have a button at the top of the grid..If I click button I need to select top 5 users from the list.
Can anybody tell me how to do this using jquery?</p>
<p>Thanks.</p>
| jquery | [5] |
5,275,026 | 5,275,027 | URL mapping in the webconfig query | <pre><code><urlMappings enabled="true">
<add url="~/Name.aspx"
mappedUrl="~/ActualName.aspx"/>
</urlMappings>
</code></pre>
<p>Any idea why this is not working for me?</p>
| asp.net | [9] |
5,850,421 | 5,850,422 | Java Problem/Program | <p>Given a string of characters as input, without using regular expression or pattern matching, how to get the output, if the characters matches aaa should output 1 and if the characters matches aBa should output 2. (Note: Should not re-process characters so as to output both “1” and “2” when processing the same input)</p>
<p>So for example:</p>
<p>given 'aaBaBaaaBaaa' it should output 211</p>
<p>given 'aaaBaBaaaaBBaBaBa' it should output 1212</p>
<p>Thanks in advance.</p>
<p>PS: I have posted the same problem for a solution in Ruby at <a href="http://stackoverflow.com/questions/2022436/ruby-program-problem">http://stackoverflow.com/questions/2022436/ruby-program-problem</a>
which might give some insight about the implementation.</p>
| java | [1] |
6,000,299 | 6,000,300 | Help with OnTouch | <p>I am trying to create a few circles when the user touches, and if they touch again depending where they touch another one would show... but when I use the ontouch event.. it crashes... I am new by the way, how can I fix it?</p>
<pre><code>public class GameView extends View{
private final float x;
private final float y;
private final int r;
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
public GameView(Context context, float x, float y, int r) {
super(context);
mPaint.setColor(0xFFFF0000);
this.x = x;
this.y = y;
this.r = r;
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(x, y, r, mPaint);
}
</code></pre>
<p>}</p>
<pre><code>public class GameActivity extends Activity {
/** Called when the activity is first created. */
GameView gm;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
FrameLayout main = (FrameLayout) findViewById(R.id.my_view);
main.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(final View v, MotionEvent e) {
final float x = e.getX();
final float y = e.getY();
final Handler handler = new Handler()
{
public void handleMessage(Message msg) {
gm.postInvalidate();
}
};
Thread graphicThread = new Thread()
{
public void run() {
try {
//Do the drop
FrameLayout flView = (FrameLayout) v;
flView.addView(new GameView(getParent(), x,y,25));
Thread.sleep(1000);
handler.sendMessage(handler.obtainMessage());
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
boolean isRunning=true;
graphicThread.start();
return true;
}
});
}
}
</code></pre>
| android | [4] |
1,797,491 | 1,797,492 | updating with a menu in a form | <p>How do i retrieve information from a database and display certain information as the first option in a menu among other options. I want to edit information in a database using the menu like:</p>
<pre><code> <select name="items" id="items" >
<?php
while($product_rows=mysql_fetch_assoc($productSQL)){ ?>
<option value="<?php echo $ord_rows['pid'];?>">
<?php echo $ord_rows['name'];?>
</option>
<?php } ?>
</select>
</code></pre>
<p>but this jst gets all the options from the db. I want the option am editing to appear as the first one and the rest follow, Any help, hope the question is clear.</p>
| php | [2] |
1,735,477 | 1,735,478 | pre-defined parameters | <p>I want to be able to do this in JavaScript:</p>
<pre><code>function myFunction(one, two = 1) {
// code
}
myFunction("foo", "2");
myFunction("bar");
</code></pre>
<p>I tried this and it doesn't work. I don't know how to call this type of parameters, could somebody point me in the right direction? </p>
<p>Thanks.</p>
| javascript | [3] |
5,656,521 | 5,656,522 | Free *regular* application on iPhone - how to display ads? | <p>What ad networks are available to iPhone developers who want to distribute free regular apps (not web applets) that are ad supported?</p>
<p><a href="http://www.appleinsider.com/articles/09/01/22/iphone_developer_app_store_rewards_crap_apps.html" rel="nofollow">Prompted by this story on crappy app making $200/hr.</a></p>
| iphone | [8] |
3,392,477 | 3,392,478 | Uploading Sqlite database to a remote server | <p>I am collecting data using my device then save it in a local sqlite database. I am now attempting to upload this database to a remote server by the click of a button.
I have been able to upload the whole database, but the catch is that am not able to view the contents as they are encrypted using UTF-8 (if am not wrong). When i open the uploaded file the encrypted text starts with SQLite format 3 but then the other entered data is encrypted.</p>
<p>Here is a sample of my code that implements the upload, How can i get this file decrypted back to normal text/characters?</p>
<pre><code> public void doUpload(String filepath, String filename) {
HttpClient httpClient = new DefaultHttpClient();
try {
httpClient.getParams().setParameter("http.socket.timeout",new Integer(90000));
post = new HttpPost(new URI("http://10.0.2.2:8080/Force/sync"));
File file = new File(filepath);
FileEntity entity;
if (filepath.substring(filepath.length() - 2, filepath.length()).equalsIgnoreCase("db" || filepath.substring(filepath.length() - 3, filepath.length()).equalsIgnoreCase("log")) {
entity = new FileEntity(file, "text/plain; charset=\"SQLite format 3\"");
entity.setChunked(true);
} else {
entity = new FileEntity(file, "binary/octet-stream");
entity.setChunked(true);
}
post.setEntity(entity);
post.addHeader(filepath, filename);
HttpResponse response = httpClient.execute(post);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
} else {
// Here every thing is fine.
}
HttpEntity resEntity = response.getEntity();
if (resEntity == null) {
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
httpClient.getConnectionManager().shutdown();
}
}
</code></pre>
<p>This code is invoked at the click of the upload button, and the url invokes a servlet (sync) that handles the uploaded file.</p>
<p>I will appreciate any asist.
Regards.</p>
| android | [4] |
4,461,798 | 4,461,799 | Allow my app to be chosen when a URL the intent.view intent is passed? | <p>I am wanting to do a similar thing to the Google+ app, as when you click a Google+ link in, say, and e-mail app it prompts you to choose either the browser or the Google+ app.</p>
<p>How can I implement a function like this into my app? I have tried searching, but struggled as I don't think I was using the correct keywords :/</p>
| android | [4] |
4,132,952 | 4,132,953 | How do I add a random number to a Stored variable at the results as a number, not 2 strings added together? | <p>So here is a dorky experiment I put together basically trying to generate a D&D style attack roll with a modifier. I want to add the numbers, but javascript keeps adding the numbers as strings. I'm not sure how to get the basic math done..... Here is my code-</p>
<pre><code> function battle()
{
var CS = document.battleForm.playerCS.value;
var D20 = Math.ceil(Math.round(Math.random() * 20))
var attackRoll = CS + D20
if (isNaN(CS))
{
alert ("please provide your Combat Score!")
return
}
if (CS != '')
{
document.battleForm.enemyCS.value = attackRoll
}
}
</code></pre>
| javascript | [3] |
4,830,612 | 4,830,613 | can't store cookie with jquery | <p>I have a check-box list where users can check only two options. The two options selected are stored in an array $values[]. Then, I remove any non-numeric characters from the string value. Now I want to store the number values as cookies to copare them later:</p>
<pre><code>// store value 1
str1 = values[0];
number1 = str1.replace(/\D/g,"");
$.cookie('value1', number1, {expires: 7});
// store value 2
str2 = values[1];
number2 = str2.replace(/\D/g,"");
$.cookie('value2', number2, {expires: 7});
//get both values and compare them
result = $.cookie('value1') - $.cookie('value2');
</code></pre>
<p>this doesn't seem to work.. any help?</p>
<p>n.b. I'm using a plugin (jquery-cookie) for this. </p>
| jquery | [5] |
2,450,441 | 2,450,442 | Wanted: JRibbon tutorials | <p>Is there anywhere I can find a tutorial on how to use the JRibbon of the <a href="https://flamingo.dev.java.net/" rel="nofollow">Flamingo</a> project?</p>
<p>I downloaded and tried reading the test source files, but there is no explanation what so ever on how to use the various classes.</p>
| java | [1] |
2,855,099 | 2,855,100 | which stl container I should choose If I need to random get an item from the container | <p>Just As title . As least I know array might not be one I want . cus I need to generate a random index before I want to randomly pick up one item from the array . For your opinion.</p>
<p>I've change the title of my question to "which stl container I should choose If I need to random get an item from the container" . what I really find is a cotain , let's say
C , and this Contain should have method , let's say, get_ramdom_member(), which will help me get an item randomly from the Container C without providing any key .</p>
<p>@binary:
what I store in the container is actually socket fd . the other side of the socket is an "erlang node" . several erlang node togerther serves as a cluster . So I store all the socket
fds towards that cluster into one container . Every time I need to talk to the cluster , I need choose one fd . For the purpose of load sharing, I need to randomly get one . I can't tell you guys exactly number of fd the Container need to maintain , but currently it is less than 10 at the moment. but who knows whether the number will be 1000 some day later on . </p>
| c++ | [6] |
5,876,362 | 5,876,363 | what is the best method for passing information from a child to a parent object in c# | <p>I have a object that dynamically creates a number of child objects. These child objects are derived from UserControl. What is the best method to pass information to pass information back to the parent? In the past I have used the delegate event but recently I have been just using a reference to the parent in the constructer of the child objects.</p>
<p>I do have reservations to tight coupling as I am concerned that the child object may be tied up if the parent fails to execute the referenced method in a timely fashion.</p>
<p>I didn't want to start a new question so I'll ask here.</p>
<p>If I have events wired for the dynamically created objects and the object is disposed of at a later time, should I be unwiring the event prior to disposing of the event.</p>
<p>and ... if I am keeping my dynamically created objects in an array or hashtable would simply removing that list item dispose of the item from memory.</p>
| c# | [0] |
4,489,486 | 4,489,487 | Can you use android intents to listen for a hyperlink click? | <p>I run a website similar to rotten-tomatoes that allows users to add their reviews for movies. I am currently developing an app for android that allows users to post their reviews directly from their phone and providing a wiki or imdb link for the title is a very important part of the process.</p>
<p>Is there a way (I'm assuming with intents) to either monitor the android's clipboard or listen for a link press and only subscribe my application to run for imdb.com links? (Obviously this will be a optional preference in the app.) And what would be the best way to approach this without wasting battery life?</p>
<p>Or is there another approach to achieve this?</p>
| android | [4] |
4,679,568 | 4,679,569 | Singleton over collections of objects in Java and garbage collector | <p>I'm using a singleton for granting a unique copy of each object in runtime:</p>
<pre><code>Car object1= CarFactory.createCar(id);
</code></pre>
<p>where the createCar method is:</p>
<pre><code>private static ArrayList<Car> cars= new ArrayList<Car>();
public static synchronized Car createCar(int id){
Car result= new Car(id);
int index= cars.indexOf(result);
if (index==-1){
cars.add(result);
return result;
} else {
return cars.get(index);
}
}
</code></pre>
<p>The problem is that with this method each Car have always an reference due to the "cars" collection and the object's memory is never released. How can I improve it?</p>
| java | [1] |
5,523,544 | 5,523,545 | collect text file information using c# | <p>Dear all,<br>
I have a text file named <code>abc.txt</code>. The file have info like this </p>
<pre><code>jani
stay in USA
karim
stay in France
fara
stay in UK
</code></pre>
<p>The code needs to read the file from beginning and read the first line and put it to in a string let <code>nameString</code>. Then it read the second line and put the info to a another string let name <code>addressString</code>. Then it read the third line and put the info into <code>nameString</code> and then forth line and put the info as <code>addressString</code>. Like this way it will continue up to the end of file. I have to put those information on anywhere else. So, I need all the name and address in a for loop.</p>
<p>Can anybody pls help me to collect this info.</p>
<p>Thanks in advance<br>
Riad</p>
| c# | [0] |
466,834 | 466,835 | Getting JS Error (for - event.srcElement.id) in WebForm | <p>I am building a dynamic user control (ascx) which contains a placeholder. Inside the placeholder, there will be n tables. Inside each table, in one of the cells i have the link button as below.</p>
<p>HyperLink lnkButton = new HyperLink();
lnkButton.ID = "lnkButton_" + ID.ToString();
lnkButton.Text = tstText;
lnkButton.NavigateUrl = "javascript:JS_Click();"; </p>
<p>I have to call a JS function on the link button click (no postback). </p>
<p>In the JS function, i have to get the id of the control that invoked that JS function. In this case, it will be link button. I am writing the below code in the JS Function:</p>
<p>var ctrl = event.srcElement.id;</p>
<p>but i am getting 'Object Required' error in javaScript. </p>
<p>Few other things: This user control will be loaded in default.aspx page and the JS Function i am writing in default.aspx.</p>
<p>I am not sure why this is not working. I am using IE6/7, VS 2005. Is there any other function or way available to get the srcElement.id. Please help.</p>
| asp.net | [9] |
5,830,445 | 5,830,446 | Replacing <br> tag in asp multiline textbox | <p>I'm working with textbox in a datagrid. Before saving the data into the database, I replace the newline with <code><br></code> by using following script :</p>
<pre><code>description.Replace(Environment.NewLine, "<br>")
</code></pre>
<p>Working fine, it's replacing the newline with <code><br></code>. Then I need to fetch the data into the textbox again for editing. I've tried to replace the <code><br></code> with newline by using following script :</p>
<pre><code>data.description = ((TextBox)dgrid.Items[i].FindControl("description")).Text;
data.description = data.description.Replace("<br>", "\r\n");
</code></pre>
<p>But it's not working, do you guys have any solutions for this ?</p>
| asp.net | [9] |
3,800,705 | 3,800,706 | JQuery scrollbar plugin for double arrow | <p>I'm looking for a plugin where it can support custom vertical and
horizontal scrolling based on image here -
<a href="http://img845.imageshack.us/img845/9704/arrowsd.jpg" rel="nofollow">http://img845.imageshack.us/img845/9704/arrowsd.jpg</a> .</p>
<p>I couldn't find any so any help on this will be greatful..</p>
| jquery | [5] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.