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
4,207,102
4,207,103
Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError on object initialization
<p>I have an instance variable, like so:</p> <pre><code>PathFinder finder; </code></pre> <p>(this is using Kevin Glass' A* tutorial, so the PathFinder class is in the same file, link here: <a href="http://cokeandcode.com/index.html?page=tutorials/tilemap2" rel="nofollow">http://cokeandcode.com/index.html?page=tutorials/tilemap2</a>)</p> <p>Anyways, when I do</p> <pre><code>finder = new AStarPathFinder(currentMap, 1000, true); </code></pre> <p>I get a Exception in thread ""AWT-EventQueue-0" java.lang.ExceptionInInitializerError".</p> <p>currentMap is an instance of my Map class, and yes it is initialized. 1000 represents the maximum tile distance that will be searched, and the boolean represents diagonal movement true/false. Oh well I'll just throw the constructor at you:</p> <pre><code>public AStarPathFinder(TileBasedMap map, int maxSearchDistance, boolean allowDiagMovement) { this(map, maxSearchDistance, allowDiagMovement, new ClosestHeuristic()); } </code></pre> <p>I know it has something to do with static initializers, but I'm not too sure what else. Oh, and I tried to initialize an instance of the same AStarPathFinder class in another class, and I got the same result.</p>
java
[1]
2,830,027
2,830,028
Is it valid, to use std::string to hold binary data, to avoid manual dynamic memory management
<p>Pay attention to <code>base64_decode</code> in <a href="http://www.adp-gmbh.ch/cpp/common/base64.html" rel="nofollow">http://www.adp-gmbh.ch/cpp/common/base64.html</a></p> <pre><code>std::string base64_decode(std::string const&amp; encoded_string) </code></pre> <p>The function is suppose to return <code>byte array</code> to indicate binary data. However, the function is returning <code>std::string</code>. My guess is that, the author is trying to avoid from perform explicit dynamic memory allocation.</p> <p>I try to verify the output is correct.</p> <pre><code>int main() { unsigned char data[3]; data[0] = 0; data[1] = 1; data[2] = 2; std::string encoded_string = base64_encode(data, 3); // AAEC std::cout &lt;&lt; encoded_string &lt;&lt; std::endl; std::string decoded_string = base64_decode(encoded_string); for (int i = 0; i &lt; decoded_string.length(); i++) { // 0, 1, 2 std::cout &lt;&lt; (int)decoded_string.data()[i] &lt;&lt; ", "; } std::cout &lt;&lt; std::endl; getchar(); } </code></pre> <p><strong>The decoded output is correct. Just want to confirm, is it valid to <code>std::string</code> to hold binary data, to avoid manual dynamic memory management.</strong></p> <pre><code>std::string s; s += (char)0; // s.length() will return 1. </code></pre>
c++
[6]
5,305,432
5,305,433
UpdatePanel is not known elements.This can occur if compilation error in website
<p>I have created one master page and one content page.Added scripManager in master page(contentplaceholder) and update panel in content page.But I am getting an error <code>"UpdatePanel is not known elements"</code>.I am using vs 2005.In my machine there is vs2005,vs2008,vs2010.When I am opening vs 2005,I can see Ajax Extention in toolbar(There is only basic 5 control like timer,updatepannel,progress),when I am trying drag a update pannel from toolbox,code for assembly comes that <code>system.web.Extention</code> version 1.0 and same is in web config.Then where is a mistake.</p>
asp.net
[9]
5,996,181
5,996,182
Most efficient way to store a 40 cards deck
<p>I'm building a simulator for a 40 card's deck game. The deck is divided into 4 seeds, each one with 10 cards. Since there's only 1 seed that's different from the others ( let's say, hearts ) , I've thinked of a quite convinient way to store a set of 4 cards with the same value in 3 bits: the first two indicate how many cards of a given value are left, and the last one is a marker that tells if the heart card of that value is still in the deck. So,</p> <p><strong>{7h 7c 7s} = 101</strong></p> <p>That allows me to store the whole deck on 30 bits of memory instead of 40. Now, when i was programming in C, I'd have allocated 4 chars ( 1 byte each = 32 bits), and played with the values with bit operations. In C# I can't do that, since chars are 2 bytes each and playing with bits is much more of a pain, so, the question is : what's the smallest amount of memory I'll have to use to store the data required?</p> <p>PS: Keep in mind that i may have to allocate 100k+ of those decks in system's memory, so saving 10 bits is quite a lot</p>
c#
[0]
3,689,509
3,689,510
how to read SMS inbox programatically in iphone?
<p>how to read SMS inbox programatically in iphone?</p>
iphone
[8]
3,774,549
3,774,550
Android: The AlertDialog is invisible when the Activity back to foreground
<p>This question is related to <a href="http://stackoverflow.com/q/6303713/602011">The AlertDialog is invisible when the Activity back to foreground</a> post.</p> <p>I have the same problem. The previous post is old, and have no answer. Any suggestions how to solve that problem ? Thanks...</p>
android
[4]
5,594,320
5,594,321
checkbox in listview in android
<p>In my code the assigned value comes through the server when assigned value is 1. The <code>checkbox</code> value in <code>listview</code> should be <code>checked</code> while <code>unchecked</code> ... and after load of listview if I try to check on already checked or change that state it shows an alert box </p> <p>When I check rest of <code>checkbox</code> while scrolling its automatically unchecked..</p> <pre><code>boolean checked[]; ArrayList&lt;HashMap&lt;String, Object&gt;&gt; Arraymanagemember = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;(); ListView managelist = (ListView) findViewById(R.id.managememberlist); final CheckBox cbox = (CheckBox) managelist.findViewById(R.id.usercheck); for (int i = 0; i &lt; array.length(); i++) { HashMap&lt;String, Object&gt; membermap = new HashMap&lt;String, Object&gt;(); memberinfo[i] = array.getJSONObject(i).getString("username").toString(); assingedinf[i] = array.getJSONObject(i).getString("assigned").toString(); if (assingedinf[i].equals("1")) { membermap.put("assign", true); } else { membermap.put("assign", isTaskRoot()); } membermap.put("member", memberinfo[i]); Arraymanagemember.add(i, membermap); } SimpleAdapter memberadp = new SimpleAdapter( getApplicationContext(), Arraymanagemember, R.layout.managememberrow, new String[]{"member", "assign"}, new int[]{R.id.manageuserinfo, R.id.usercheck} ); managelist.setAdapter(memberadp); managelist.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick( AdapterView&lt;?&gt; parent, View arg1, int postion, long arg3) { if (assingedinf[postion].equals("1")) { Toast.makeText(getApplicationContext(), "not run", Toast.LENGTH_SHORT).show(); } } } }); </code></pre>
android
[4]
2,928,398
2,928,399
android text view give runtime error in eclipse
<p>In the code below I get runtime error in eclipse. Why this error is not displayed at compile time?</p> <pre><code>public class AndroidUIActivity extends Activity implements OnClickListener { private static final int PROGRESS = 0x1; private ProgressBar mProgress; private int mProgressStatus = 0; private int maxtime=0; private Handler mHandler = new Handler(); int fileSize=0; private MediaPlayer mp3player; private TextView txt_Currenttime; protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); txt_Currenttime.setText(12); /* line with error */ } } </code></pre>
android
[4]
2,704,694
2,704,695
regarding implementation of camera in android
<p>I am developing an application of android which involves saving image of camera on click of click button.Can anyone give me a guidance of how to implement camera in android??</p>
android
[4]
4,410
4,411
Business logic of the CheckBox listener inside a ListView
<p>I have implemented a custom adapter for my ListView, that includes a CheckBox in each row.</p> <p>As I have my click listener in my custom adapter, I'm forced to implement there my business logic (that is, what happens when a CheckBox is clicked... access the database, etc).</p> <p>Is that correct? Wouldn't be a better practice to implement that business logic outside the custom adapter? (I think the adapter should only care about visualization).</p>
android
[4]
2,463,694
2,463,695
Correct quotes in query
<p>I've tried a lot of combinations to quote the OR-part, but nothing worked so far.</p> <p>I would be very happy if someone could tell me the right syntax for this. </p> <p><code></p> <pre><code>mCursor = mDb.query(true, SQLITE_TABLE, new String[] {KEY_ROWID, KEY_NAME, KEY_PLACE, KEY_INFO}, KEY_INFO + " like '%" + inputText + "%'" + OR KEY_PLACE + " like '%" + inputText + "%'", null, null, null, null, null); </code></pre> <p></code></p>
android
[4]
2,774,894
2,774,895
jQuery prevAll for seperate elements
<p>How can I get the previous input value in the fiddle below. I get undefined unless they are in the same span.</p> <pre><code>&lt;span&gt; &lt;input type="text" value="48.00" &gt; &lt;/span&gt; &lt;span&gt; &lt;input type="text" value="44.00" &gt; &lt;/span&gt; $('input[type=text]').click(function () { alert($(this).prevAll("input[type=text]").val()); }); </code></pre>
jquery
[5]
1,220,800
1,220,801
why sql delete query is not working
<p>I have a table <code>table1</code> with fields <code>id(int)</code>, <code>name(nchar)</code>, <code>grade(real)</code>. The following code isn't working. There are no errors or warnings. The code executes well but the number of affected rows = 0.</p> <p>MsSql Server</p> <pre><code>sqlConnection1.Open(); SqlCommand cmd = new SqlCommand("Delete from [table1] where [id] = 1", sqlConnection1); int c = cmd.ExecuteNonQuery(); sqlConnection1.Close(); </code></pre> <p>All other queries are working well.</p>
c#
[0]
3,574,653
3,574,654
php version difference
<p>Any difference between php 5.3.0 and 5.2.15?</p> <p>I am using 5.3.0 on my localhost and 5.2.15 on the remote server</p> <p>My apps work well on the localhost and breaks on the remote server.</p> <p>One particular error is "Only variable should be passed by reference"</p>
php
[2]
4,020,337
4,020,338
Passing Integer by reference with threads
<p>I have a class with a global variable, Integer clock, initialized to 0. It passes 'clock' to a few thread constructors, starting the threads also. It seems increments to 'clock' can be seen within the thread, but in their calling process, 'clock' is always 0. Because Integer is an object and objects are passed by reference, I would expect changes to 'clock' to be seen everywhere. Is this not the case?</p>
java
[1]
1,336,305
1,336,306
create custom score
<p>I want to make a tennis score app but i don't know how to create a custom score (0, 15, 30, 40, advantage)?</p> <p>Here is the code I've used with an other "counter" app:</p> <pre><code>public class counter extends Activity { // Private member field to keep track of the count private int Count = 0; /* Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final TextView countTextView = (TextView) findViewById(R.id.TextViewCount); final Button countButton = (Button) findViewById(R.id.ButtonCount); countButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Count++; countTextView.setText("" + Count); } }); } } </code></pre>
android
[4]
4,727,253
4,727,254
I created a resource but files inside it are shown as not existing
<p>I embedded my files as resource in my C# program. Now i am trying to see that files exist or not through </p> <pre><code> if(File.Exists(path)) </code></pre> <p>but it is not going inside the if block when even the path is the valid path to the files inside the resources. The files are the DTDs, which would be embedded as resources inside the assembly at compile time, and resolved as resources at runtime. Please help. what could possibly the reason? and what am i missing?</p>
c#
[0]
5,063,881
5,063,882
animating a div based on its existing position
<p>I am trying to animate a div -1500px every time my .btn-arrow button is clicked by grabbing the current position of #content</p> <pre><code> var $offset = $('#content').offset.left()-1500; $('.btn-arrow').click( function(){ $('#content').animate({marginLeft:$offset}); return false; }); &lt;div style="margin-left: 0px; width: 99999px;" id="content"&gt;content &lt;/div&gt; </code></pre> <p>Its not working though currently, any ideas anyone? </p>
jquery
[5]
3,744,863
3,744,864
python how to overcome global interpretor lock
<p>I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading. To do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest session opened correctly.</p> <p>I did bit of research on internet and found that it's because of Global Interpretor Lock in python. I would like to know how to overcome this GIL...Any idea would be much appreciated</p>
python
[7]
190,415
190,416
note pad/ leave comment widget
<p>I am looking for a widget that I can use. What am after is when a user hits my tab button a activity start and this activity is for users to leave a comment or tip for what there looking for. I want the users to have something like 100 word limit. Is there anything that I can use to do this.</p>
android
[4]
5,076,739
5,076,740
Is there a way to rename the android program shortcut on desktop?
<p>In some modified version(for example, CM7), you can long press the shortcut to rename it. But CM7 have some bugs now.</p> <p>I would like to know is there a way I can do that? modify the database, change the programs code or resources is OK. Thanks. </p>
android
[4]
4,283,591
4,283,592
how to parse the response in JSON file from SOAP request in android application
<p>hi guys my soap request and soap response is as follows</p> <p>Test To test the operation using the HTTP POST protocol, click the 'Invoke' button. Parameter Value accessCode: xxxxxx Invoke </p> <p>SOAP 1.1</p> <p>The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.</p> <p>POST /UI/WebServices/CalManager.asmx HTTP/1.1 Host: login.nediso.com Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://nediso.com/add/login"</p> <p> string </p> <p>HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: length</p> <p> string </p> <p>Here iam sending the SOAP request as specified in the above SOAP request format with accesscode,let it be "xxxxx"(for example).In the below iam getting the Response as string. whenever iam entering the access code and click on the Invoke button just above the SOAP request iam getting .Json file as response .Here the issue is whether iam getting String as a response or .Json file as response.If it is .Json file how to handle and parse it.please post the code for this immediate response is needed. </p>
android
[4]
242,847
242,848
HttpServletRequest cannot be resolved can you help?
<p>Hi all I have imported the following import javax.servlet.http.*;</p> <p>I want to get the preferred language Browser</p> <pre><code>HttpServletRequest request = ServletActionContext.getRequest(); Locale userPreferredLocale = request.getLocale(); </code></pre> <p>I get an error HttpServletRequest cannot be resolved.</p> <p>Can somebody help me and give me a step by step instruction if possible. I am not a java developer but a .net one and just fixing a bug.</p> <p>thanks a lot</p>
java
[1]
2,234,677
2,234,678
Image processing in iOS to get an object status
<p>I am new to iOS projects. In my current project, I have to process an image which contains LED object. I want to extract the LED object status (on/off) from that image in iOS. Is there any open source library to process the image for my scenario. Please help me.</p> <p>Thanks in advance.</p>
iphone
[8]
3,555,488
3,555,489
How does the JavaScript instanceOf method execute in this statement?
<pre><code>var a = "words"; a instanceOf String; #=&gt; false </code></pre> <p>I can't understand how this code snippet works.</p> <ul> <li>Is <code>instanceof</code> a method of <code>a</code>, or of <code>this</code> which locates it in the default scope?</li> <li>If <code>String</code> here is a parameter passed to <code>instanceof</code>, how come it doesn't have parentheses?</li> </ul>
javascript
[3]
3,422,060
3,422,061
Is there a Python idiom for the last n elements of a sequence?
<p>e.g., for a sequence of unknown length, what is the most "Pythonic" way of getting the last n elements?</p> <p>Obviously I could calculate the starting and ending indices. Is there anything slicker?</p>
python
[7]
1,735,870
1,735,871
NULL pointer conversion
<blockquote> <p>C++03 $4.10- "The conversion of a null pointer constant to a pointer to cv-qualified type is a single conversion, and not the sequence of a pointer conversion followed by a qualification conversion (4.4)."</p> </blockquote> <p>Here is my understanding</p> <pre><code>int main(){ char buf[] = "Hello"; char const *p1 = buf; // 2 step conversion process // C1: char [6] to char * // C2: char * to char const * (qualification conversion) char const *p2 = 0; // $4.10 applies here } </code></pre> <p>Is my understanding (as in the code comments) correct?</p> <p>My question is </p> <ol> <li><p>What is so significant about the quoted portion of $4.10 that it deserves a mention? Not that it hurts to be there, but then I don't understand it I think.</p></li> <li><p>What is the impliciation of this quote (overload resolution?)? Any examples?</p></li> </ol>
c++
[6]
2,858,198
2,858,199
What i am missing/ is wrong in this jquery code
<pre><code>$(document).ready(function(){ $("#cross").livequery("click", function(e){ e.preventDefault(); $.post("getNewFollowing.pl, function(data){ $('#follow_name1').text(data.userName); $('#follow_email1').text(data.userEmail); }); }); }); </code></pre> <p>On clicking ID="cross", it should call a perl file wich returns userName and userEmail.<br> This code is not doing anything. Can someone please help me, what i am missing in this? Thanks, Sapna</p>
jquery
[5]
1,339,902
1,339,903
C# error handling (NaN)
<p>I have written simple math function plotter in C# using Patrick Lundin´s Math free parser.</p> <p>Now, my code snippet is this: </p> <pre><code>for (float value = -xaxis; value &lt; xaxis; value += konst) { hash.Add("x", value.ToString()); double result = 0; result = parser.Parse(func, hash);... </code></pre> <p>This works perfectly for functions defined on real numbers. But, when I want want to parse functions defined only on R+ for example, ln(x), naturally parser gives NaN into result.</p> <p>Now, I tried to handle it thru exception handling, like so:</p> <pre><code>for (float value = -xaxis; value &lt; xaxis; value += konst) { hash.Add("x", value.ToString()); double result = 0; try{ result = parser.Parse(func, hash); } catch { count = false; //just a variable I am using to draw lines continue; // I hoped to skip the "wrong" number parsed until I came to R+ numbers }... </code></pre> <p>But this doesen´t work, while debugging, catch is not executed at all.</p> <p>Please, what am I doing wrong? Thanks.</p>
c#
[0]
2,350,148
2,350,149
Create dynamic button with dynamic text
<p>I have a project where I need to create menu buttons from a list in SQL Server. The problem I am having is that I need to add code to the text of those buttons. So there would be a birthday button and it should display the number of birthdays within the next two weeks or a button with the number of upcoming events. Any thoughts on how best to do this? Thanks.</p> <p>Wade</p> <p>Clarification:</p> <p>There is no code yet, just some requirements. What I am doing is querying a table to get the list of buttons to display. Now each of these buttons may have dynamic text, for things like count of birthdays, events,etc... I am trying to see what the best way would be to handle this. Should I embed a snippet of code to go along with the menu item to execute when I iterate over the menu items? Maybe I should build a javascript file to go along with the code, which I add code to query a service for certain menu items? Thanks for any help.</p>
asp.net
[9]
225,912
225,913
is it possible in android to programatically call a person and then let him/her hear a pre-recorded voice/audio?
<p>I want to know if it is possible using public android API's to call a person programatically and then as soon as she picks up the phone, let her hear a pre-recorded voice message/audio?</p> <p>Before I get comments like why I want to do that, or its a bad user experience, I just want to clarify that the question is more on the technical front than implementation so please do let me know if you have any pointers.</p> <p>Thnx for your time!</p>
android
[4]
5,119,708
5,119,709
get heading name as url using jquery
<pre><code>&lt;div class="myclass selected"&gt; &lt;h2 class = "title"&gt;#Content 1&lt;/h2&gt; &lt;/div&gt; &lt;div class="myclass"&gt; &lt;h2 class = "title"&gt;#Content 2&lt;/h2&gt; &lt;/div&gt; &lt;div class="myclass"&gt; &lt;h2 class = "title"&gt;#Content 3&lt;/h2&gt; &lt;/div&gt; &lt;div class="myclass"&gt; &lt;h2 class = "title"&gt;#Content 4&lt;/h2&gt; &lt;/div&gt; </code></pre> <p>I want to show as "http://example.com/#content-1" in url and want to update for each selection. Is this possible to do that using jquery ?</p>
jquery
[5]
5,367,648
5,367,649
Add samsung android device to eclipse
<p>HI Thanks in advance Please let me know that how to connect samsung android device to eclipse for debugging. I have downloads google usb driver in my sdk..</p> <p>Thanks in advance.</p>
android
[4]
4,689,647
4,689,648
Making a table row animate upward movement in sortable UI
<p>I'm using Sortable jQuery UI to allow users to drag and drop table rows. This allows users to rank items in a table based on their preference. Once a user has finished ordering his list, they press a save button which executes an Ajax call. The new rank is saved into the database and the table highlights briefly.</p> <p>I have now added an additional button that will send an item straight to the top of the list. It's also ajax. It works very well except that I would like to add a transition effect where by the <code>&lt;tr&gt;</code> will break away and drag itself to the top of the table, and push the following rows down. Is this possible? Here is the code I'm using:</p> <p>This code handles the call to save changes to the database from the "drag-and-drop" feature:</p> <pre><code>&lt;input type="button" value="Save Queue" id="saveButton" class="list-button"&gt; $(document).ready(function(){ $("#sortable").sortable(); $("#saveButton").click(persist); }); // Persist function (save order) function persist() { var data = $("#sortable").sortable('toArray'); $.ajax({ traditional: true, url: "/gz/index.cfm/membros/rankListByAjax?order="+data, type: "POST", success: function(msg){ $("#sortable tr").effect("highlight", {}, 1000); } }); } </code></pre> <p>The following code is the new "send-item-to-top" button I added. This is when I would like the transition to happen:</p> <pre><code>&lt;form ...onsubmit=" $.ajax({ dataType: 'script', type: 'post', url: '/gz/index.cfm?controller=membros&amp;amp;action=send-item-to-top&amp;amp;key=1082&amp;amp;format=js&amp;amp;modType=replace', data: $(this).serialize(), success: function(data, textStatus){$(this).attr('disabled','false');}, beforeSend: function(XMLHttpRequest){$(this).attr('disabled','true');}}); return false;" text="&amp;uarr;"&gt; </code></pre>
jquery
[5]
818,696
818,697
Sorting and reinserting elements removes bound functions
<p>I need to sort some rows after they've been inserted. What I'm doing now is:</p> <pre><code>var $r = $tbody.find('tr').sort(function(a,b) { return compare(taxstatusOf(a), taxstatusOf(b)); }); $tbody.empty().append($r); </code></pre> <p>This works, <em>except</em> that functions that were bound to elements contained in the rows are no longer bound (or no longer fire, which amounts to the same thing).</p> <p>So, is there a right way to sort rows that doing fail like this? Do I have to re-bind?</p>
jquery
[5]
4,084,472
4,084,473
Stream reference error
<p>Compiler Error Message: 'Stream' is an ambiguous reference between 'System.IO.Stream' and 'WebReference.Stream'</p> <p>Any thoughts?</p> <p>I have web method accepting <code>System.IO.Stream</code> stream as an input parameter &amp; internally i assing <code>stream=new MemoryStream(bytes[]);</code></p>
c#
[0]
838,915
838,916
Best language tooling
<p>I was listening to a podcast recently (may have been SO - can't remember) when the interviewee said that one of the reasons Java was so successful and popular was the tooling.</p> <p>Having use of great FOSS editors such as Eclipse, NetBeans. Metrics tools such as Cobertura, Find Bugs, Build tools such as Maven and ANT.. I'd have to agree</p> <p>I've done a fair bit of .NET and the tools are OKish. The problem seems to be that there isn't the depth in tooling that there is in Java. The FOSS stuff seems pretty limited. </p> <p>My question: Are there any modern languages with a better community and tooling for getting the job done? </p>
java
[1]
2,448,096
2,448,097
I have a project in Java I am running that uses an external JAR file
<p>I have a project in Java I am running that uses an external JAR file.</p> <p>In Eclipse I added the JAR file to the class build path and everything working fine.</p> <p>But my question is: how can I add it to my project after I created the executable JAR (myPtog.jar) and I am running "ant" in cmd but the external jar file is not found?</p> <p>This is my build.xml:</p> <pre><code>&lt;project name="" default="dist" basedir="."&gt; &lt;description&gt; Ant &lt;/description&gt; &lt;!-- Set global properties for this build. --&gt; &lt;property name="src" location="src"/&gt; &lt;property name="build" location="target"/&gt; &lt;target name="init"&gt; &lt;tstamp/&gt; &lt;mkdir dir="${build}"/&gt; &lt;/target&gt; &lt;target name="compile" depends="init" description="compile the source "&gt; &lt;javac srcdir="${src}" destdir="${build}"/&gt; &lt;/target&gt; &lt;target name="dist" depends="compile" description="generate the distribution"&gt; &lt;jar jarfile="TPCServer.jar" basedir="${build}"&gt; &lt;manifest&gt; &lt;attribute name="Main-Class" value="Main1"/&gt; &lt;/manifest&gt; &lt;/jar&gt; &lt;/target&gt; &lt;target name="clean" description="clean up"&gt; &lt;delete dir="${build}"/&gt; &lt;delete dir="${dist}"/&gt; &lt;/target&gt; &lt;/project&gt; </code></pre>
java
[1]
4,593,713
4,593,714
how to create dynamic array in c#
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5307642/how-to-create-dynamic-array-in-c">how to create dynamic array in c#</a> </p> </blockquote> <p>This is my code. I explecitely specify the server names. but i want to specify implicitely server names. Hence create dynamic array.that take server names implicitely.&amp; remove <code>\\</code> &amp; <code>\n</code> in the server names. hence how to create dynamic array with changes of code. please give me solution for this question with changes of code. Thank you.</p> <pre><code> System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName = "cmd "; p.StartInfo.UseShellExecute = false; p.StartInfo.Arguments = "/C net view"; char[] delimiterChars = { '\\' }; string input = "\\st1\n,\\st10\n,\\st4\n,\\st5"; List&lt;string&gt; serverNames = input.Split(',').ToList(); Console.WriteLine(input); Console.ReadLine(); </code></pre>
c#
[0]
2,307,487
2,307,488
Minify everything into one file or use CDN
<p>For things like jQuery etc, isit better to leave it to use CDN or minify it into 1 file together with other JS</p>
javascript
[3]
1,918,307
1,918,308
borrowing costructors and prototype chain
<p>in many books and online tutorial there are examples on passing data to a super-class constructor via a borrowing method pattern:</p> <pre><code>var Parent = function(name) { this.name = name; this.my_parent = "parent_property"; this.go = function() { alert("GO") } } var Child = function(name) { this.name = name; this.my_child = "child_property"; Parent.call(this); alert(this.hasOwnProperty("go")) // HERE TRUE!!! } var ChildChild = function(name) { this.name = name; this.su = function(){} } // PSEUDO CLASSICAL ECMA STANDARD Child.prototype = new Parent("PARENT"); ChildChild.prototype = new Child("CHILD"); var c = new ChildChild("CHILDCHILD"); </code></pre> <p>now my question is: is this correct? in that pattern the properties of the super-class are copied into THIS but in a OOP system I think that those properties must be in its super-class. Now BORROWING constructor is only another pattern to make a sort of inheritance so I could not use prototype and so all the chain superclass properties are into the last child class...but I don't think it's efficient.</p> <p>So, at end, how can I pass data to a super-class without that pattern?</p> <p>Thanks</p>
javascript
[3]
2,657,525
2,657,526
Changing the map from SateliteView to TrafficView or viceversa using dialog
<p>I want to change the map from sateliteView to TrafficView by selecting the dialog as mentioned in image</p>
android
[4]
658,093
658,094
regarding a code of creating a file object
<p>I once saw the following code for creating a file object</p> <pre><code>File trainingFile = new File(new File(dataDir,category),category+".txt"); </code></pre> <p>looks to me that there exists a recursive call of <code>new File</code> in the outside <code>new File</code>, what does this code exactly to do?</p>
java
[1]
4,378,774
4,378,775
C# How to spoof IP address for WebRequest
<p>I have asp.net website hosted and I am making WebRequest to post data and get response. The website is having IP filtering. I want to spoof sender IP address for testing purpose. Is it possible to do it programmatically or I have to use any tool.</p> <pre><code>public string GetResponse(string request) { lock (Obj) { request = request + _dataControlInfo.SendEndingWith; Logger.Info(request); var req = (HttpWebRequest)WebRequest.Create(_serviceUrl); req.Headers.Add("SOAPAction", "\"\""); req.ContentType = "text/xml;charset=\"utf-8\""; req.Accept = "text/xml"; req.Method = "POST"; var stm = req.GetRequestStream(); var bytes = UtfEncoding.StringToUtf8ByteArray(request); stm.Write(bytes, 0, bytes.Length); stm.Close(); var resp = req.GetResponse(); var stmr = new StreamReader(resp.GetResponseStream()); var strResponseXml = stmr.ReadToEnd(); Logger.Info(strResponseXml); return strResponseXml; } } </code></pre> <p>Please specify any possibilities.</p>
c#
[0]
1,482,017
1,482,018
How to test Text Field Validate a comma exists in a field
<p>How to test input Field Validate a comma exists in a input field ?</p>
javascript
[3]
3,184,447
3,184,448
Comparing the HKEY_USER and HKEY_CURRENT_USER
<p>Is any easy method to compare two registry keys ?</p> <p>I want to compare user and current user keys in Windows Registry.</p> <p>If the values changed, I want to pick out and correct with default value in HKEY_USER.Default.</p> <p>Please Guide me..</p> <p>Thank You.</p>
c#
[0]
5,493,303
5,493,304
Save Checkboxes state in ListView and Retrieve it back when come back to class using Shared preferences
<p>I Got stucked in saving the Checkboxes state and getting back in listview, i want to save what all the items were checked and save it and get it back when the Activity is called again... Pls help me in this with sample code... any help will be very usefull for me. </p>
android
[4]
1,114,770
1,114,771
Javascript disappearing in sharepoint 2007 when using rich text editor
<p>This may be an easy one.</p> <p>When I add javascript code and HTML to a Sharepoint 2007 content webpart, if I then go in and edit the page using the rich text editor and save, the javascript disappears.</p> <p>Is their a wrapper or something similar I can use to retain the javascript after a user has used the rich text editor.</p> <p>Appreciate any help.</p> <p>MitchK</p>
javascript
[3]
4,280,810
4,280,811
php real_escape_string
<p>I post the data of dynamically generated textbox in PHP. When I post the data using <code>real_escape_string()</code>, i.e:</p> <pre><code>$ingredient = mysql_real_escape_string($_POST['ingredient']); </code></pre> <p>...it doesn't post data from textbox and I use simple <code>$_POST[''];</code> method i.e:</p> <pre><code>$ingredient = $_POST['ingredient']; </code></pre> <p>...it gives me error when I use a single quote (<code>'</code>) in my text.</p> <blockquote> <p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's', 'fgad', '55')' at line 2</p> </blockquote> <p>this was my old post <br/> i solved the problem locally by enabling <code>magic_quotes_gpc = On</code> but when upload this on my server it does't work again so how can i turn on magic quotes on server.</p>
php
[2]
4,811,088
4,811,089
php calling html
<p>can you please let me know what I am missing:</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;title&gt;page&lt;/title&gt;&lt;/head&gt; &lt;body&gt; &lt;h2&gt;&lt;center&gt;Welcome to the mainpage&lt;/center&gt;&lt;/h2&gt;&lt;br /&gt; &lt;a href="sample4.php?currpage=2"&gt;Home page&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>php code is :</p> <pre><code>&lt;?PHP $currpage=$_GET['currpage']; echo "Hello world $currpage"; ?&gt; </code></pre> <p>when I click the homepage I want the sample4.php script to be executed and that output which is a html page to be displayed. But when I click the homage page : I get a file window download.</p> <p>I have the php script in the same location I have the html?</p>
php
[2]
4,628,635
4,628,636
How turning off animation of system operation android programmatically
<p>To save energy of my mobile device my app should turn off animation of system operation android. How can I turn off animation of system operation android programmatically? Does there exist some broadcast receiver for listen this action?</p> <p>I mean that if you want more performance in your android you can go settings ("Menu-Settings-Display-Animation-NO ANIMATIONS")... I want know how do this programmatically...</p>
android
[4]
4,947,367
4,947,368
what does the er here stands for?
<pre><code>try: os.execvp('sqlite3', args) except OSError, er: if er.errno == 2: #file not found raise OSError, _("sqlite3 executable not found. Is it installed?") else: raise except: raise </code></pre> <p>In the above code, the <code>except</code> statement catches the <code>OSError</code> but what does the <code>er</code> variable stand for? </p> <p>EDIT: this one only excepts <code>OSError</code>; is there a way to except any error and get the exception object for it? </p>
python
[7]
4,880,759
4,880,760
How to setup Math program
<p>I'm needing to write a program (C#) that will allow the user to create generic formulas with variables and numbers. For example:</p> <pre><code>D = A + (A - C / X)(7.8 - 6.6) F = E + (E - C / X)(7.8 - 6.6) FinalResult = (A + D)(0.9) + (E + F)(0.32) + B(0.1) + .023 </code></pre> <p>where all variables would mean for me to go to a database and look something up based on values and return a number in its place. So A would be 2.12 for example (and the same for C and E)</p> <p>Whats the best way to structure this program? How would I make my program read these formulas?</p> <p>I've seen a little bit of the MathML but not sure how to get that started (or an example of it)</p> <p>--Update--</p> <p>I mentioned MathML just seeing some other questions involving it on SO. Y'all are correct, I'm not needing to display it, I'm just needing to identify what someone wants and use that to calculate something.</p> <p>My variables will map to something in a database. For example, A would tell me to use the following:</p> <pre><code>Vend_Key = 3 Trmnl_Key = 5 Prod_Key = 7 </code></pre> <p>which would then be used to return a number from a database.</p> <p>I'm going to need a database to save the formula's that people create. I'll have to have a scheduled task that can run and execute these functions and save the information somewhere else.</p>
c#
[0]
3,118,891
3,118,892
Changing Base Path In PHP
<p>I need to change the folder that "relative include paths" are based on.</p> <p>I might currently be "in" this folder: C:\ABC\XYZ\123\ZZZ</p> <p>And in this case, the path "../../Source/SomeCode.php" would actually be in this folder: C:\ABC\XYZ\Source</p> <p>And realpath('.') would = 'C:\ABC\XYZ\123\ZZZ';</p> <p>If however, realpath('.') were "C:\Some\Other\Folder"</p> <p>Then in this case, the path "../../Source/SomeCode.php" would actually be in this folder: C:\Some\Source</p> <p>How do I change what folder is represented by '.' in realpath()?</p> <p>Like this:</p> <pre><code>echo ('BEFORE = '.realpath('.')); // BEFORE = C:\ABC\XYZ\123\ZZZ // Some PHP code here... echo ('AFTER = '.realpath('.')); // AFTER = C:\Some\Other\Folder </code></pre> <p>How can I change the folder represented by '.', as seen by realpath()?</p>
php
[2]
1,867,101
1,867,102
whats wrong with this code in php
<p>I'm getting this message when I try to run a php script</p> <blockquote> <p>Warning: preg_replace() [function.preg-replace]: Unknown modifier '.'</p> </blockquote> <p>This is the code:</p> <pre><code>$ext = preg_replace("^.+\\.([^.]+)$", "\\1", $file); </code></pre>
php
[2]
735,624
735,625
c# console application to repeat keyboard presses?
<p>I am trying to make a simple macro program to repeat keyboard key presses and I am having trouble finding out how to fire a keyboard event, anyone have any hints?</p>
c#
[0]
2,502,823
2,502,824
How can I create a create a java regular expression for a comma separator list
<p>How can I create a java regular expression for a comma separator list</p> <p>(3) (3,6) (3 , 6 )</p> <p>I tried, but it does not match anything:</p> <pre><code>Pattern.compile("\\(\\S[,]+\\)") </code></pre> <p>and how can I get the value "3" or "3"and "6" in my code from the Matcher class?</p>
java
[1]
4,184,843
4,184,844
PhP best practices & real world examples for further learning
<p>I learned php from various video tutorials (lynda, phpacadmey) and my php programming is good to go. But now i want to learn more. Various books seems boring ...as mainly these books a are for beginners I want to learn from various examples and real world stuff not from basics Pls suugest me any nice source</p>
php
[2]
1,467,524
1,467,525
Does having more methods in a class mean that object uses more memory at runtime
<p>Say I have one class <code>ClassBig</code> with 100 methods inside, and a second with only 10 methods <code>ClassSmall</code></p> <p>When I have objects at runtime</p> <p><pre><code> ClassBig big = new ClassBig(); ClassSmall small = new ClassSmall(); </pre></code></p> <p>Does the larger class take up more memory space?</p> <p>If both classes contained an identical method, does the larger class take longer to execute it?</p>
java
[1]
4,001,208
4,001,209
Hidden Field being set with data from another website
<p>I have a very interesting situation and I'm just looking for ideas at the moment. I have a webpage for insurance agents that the agent will login and then enter some insured information. </p> <p>There is a field named "agentnumber" that is on the form, but is hidden by a display:none. The field is set from the username of the person who logs in whenever the form loads the first time. The form will save automatically when the user leaves the page. </p> <p>I am experiencing a weird issue that every now and then, the agentnumber field is getting saved with incorrect data. After discussing it with the agent, it is being saved with the agentnumber of the agent from other companies, not from the my website. Just looking for any ideas on what may be happening as I thought browser security would prevent cross site javascript. The users are using IE 7 &amp; IE 8. Any help would be appreciated as I'm not even sure what to look for.</p>
javascript
[3]
3,353,843
3,353,844
How to set an image as wallpaper?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5153003/code-to-set-image-as-wallpaper-in-iphone">code to set image as wallpaper in iphone</a> </p> </blockquote> <p>I am creating an app in which i am having wallpaper sections. After the wallpapers displayed in full screen size there is button set as wallpaper when clicking on that button particular image should be set as iphone wallpaper.</p> <p>Can anyone help me with this???</p>
iphone
[8]
1,243,256
1,243,257
Web access authentication in C++?
<p>I'm trying to write a simple GUI application using Qt framework.</p> <p>The purpose of this app is to retrieve data from my isp and parse them for presentation.</p> <p>How do i authenticate my user/password with the webserver and retrieve the html page in question?</p> <p>Are there any utility libs that make this task trivial? </p> <p>I figure i need to interact with the server php script and simulate a form input somehow.</p> <p>Am i on the right track? </p>
c++
[6]
5,620,434
5,620,435
textarea hide submit button until clicked?
<p>I have a small textarea with <code>ID='texta'</code> and this has a submit button as part of the form. </p> <p>How can I hide the submit button until the user clicks inside the textarea using javascript or jquery?</p>
jquery
[5]
1,504,512
1,504,513
How to compare an array variable and Normal variable using if condition in PHP
<p>I want to compare an array variable and Normal variable using if condition in PHP.. I have an Array VAriable as .$AllowedEnquiryType[$i] and a variabe as $TIntType how to check these to are equal.</p> <p>My coding is</p> <pre><code>for($i=1;$i&lt;=$length;$i++) { if($AllowedEnquiryType[$i]==$TIntType) { return true; } else { return false; } } </code></pre>
php
[2]
1,404,536
1,404,537
How to remove warnings java
<p>I found this and it seems to be working, I'm trying to iterate trough HashMap :</p> <p><a href="http://stackoverflow.com/questions/1066589/java-iterate-through-hashmap">Java: iterate through HashMap</a></p> <p>But this portion of code shows warnings and I don't have a clue how to make it not show them :</p> <pre><code>Iterator it = map.entrySet().iterator(); Map.Entry pairs = (Map.Entry) it.next(); </code></pre> <p>Is there a way to "fix" this without using suppressWarnings annotation ?</p>
java
[1]
5,926,811
5,926,812
Website is freezing and cant login to cpanel
<p>I am new to php web dev and I have been working on a website recently... It was working great on my local server but when I put it up on an actual server it started running really slow until it finally gave up and now I can't even access the website.. or cpanel... I have been doing a little research thinking maybe it had to do with and overload of sql queries but I can't seem to find any... </p> <p>My site contains a lot of javascript and ajax calls to php scripts which fetch data from the database... (new notifications, messages) and I have stuff like:</p> <pre><code>//QUESTION RETRIEVAL FOR HOME FEED $(function(){ $r = setTimeout(alive_retrieval,100); }); function alive_retrieval(){ $.ajax({ type:"GET", url:"php/alive_questions.php", success:function(data){ $("#alive_question.content").html(data); } }); $r = setTimeout(alive_retrieval,100); } $(function(){ $t = setTimeout(question_retrieval,100); }); </code></pre> <p>This just keeps calling the alive_retrieval function over and over, which I am guessing could cause my site to be slow...</p> <p>I don't kno what to post in order to help (code, the link to my website.. or w/e) Please tell me what I should give you guys so you might be able to see what is happening...</p> <p>When I go to my site address this error pops up from my hosting provider:</p> <pre><code>Website you were trying to visit was disabled for 5 minutes, because it received over 20% of total server requests. It means that this website was using over 20% of processor resources, which is above allowed limit. Website was temporary disabled to protect server from overloading and other websites on server. </code></pre>
php
[2]
5,321,269
5,321,270
How to convert DateTime object to dd/mm/yyyy in C#?
<blockquote> <p><strong>Possible Duplicates:</strong><br /> <a href="http://stackoverflow.com/questions/123263/convert-a-string-to-a-date-in-net">Convert a string to a date in .net</a><br /> <a href="http://stackoverflow.com/questions/501460/format-date-in-c">format date in c#</a><br /> <a href="http://stackoverflow.com/questions/808057/what-markup-is-used-to-format-stackoverflow-questions">What markup is used to format StackOverflow questions?</a> </p> </blockquote> <p>How to convert DateTime object to dd/mm/yyyy in C#?</p>
c#
[0]
4,074,253
4,074,254
Supporting multiple screen sizes with Android using ImageButtons
<p>I've read the Android documentation: <a href="http://developer.android.com/guide/practices/screens_support.html" rel="nofollow">http://developer.android.com/guide/practices/screens_support.html</a> but still have some questions.</p> <p>I'm trying to design a music application which basically has images of the instrument (ImageButton) that play a sound when clicked. However, I'm confused about how to have the ImageButtons scale to fit all the different screen sizes and how to position them.</p> <ol> <li><p>Which layout is best used for needing to position ImageButtons in specific locations on the screen? (i.e. cymbals on a drum set) FrameLayout, RelativeLayout?</p></li> <li><p>If I only really care about medium and large screens, do I need to create different resources (images) for both as well as a different XML layout to position them?</p></li> </ol> <p>I'm trying to find the simplest way to do this without having to create a separate layout XML file for positioning/size and separate image resources for each screen.</p> <p>Any guidance is greatly appreciated. Thanks!</p>
android
[4]
912,688
912,689
Reasons for C++ Prototyping
<p>I'm a beginning programmer, trying to get a grasp on everything, so pardon the probably mundane theoretical question:</p> <p>I see in a C++ tutorial that prototyping is needed to let the compiler know that a function(?) is coming up and not to throw up any errors. Why does it not search throughout a document to find the function it's looking for?</p> <p>Maybe the question I'm asking is; what is the purpose for prototyping? And can it be used in other languages?</p>
c++
[6]
5,952,489
5,952,490
Java conditional statement
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/767372/java-string-equals-versus">Java String.equals versus ==</a> </p> </blockquote> <p>I am using jcreator to practice java language. I came up with a conditional statement in which if the user input is = "test" it will print an "okay!" message. This is my code: </p> <pre><code>class conditional { public static void main (String[] args) { Scanner user_input = new Scanner(System.in); String username; System.out.print("username: "); username = user_input.next(); if (username == "test") { System.out.println("okay"); } else { System.out.println("not okay"); } } </code></pre> <p>The above code does not show any error, it does not display the "okay" &amp;&amp; "not okay" message either. I am not sure what's wrong with my logic.</p>
java
[1]
3,775,216
3,775,217
Accessing object's property inside generic method
<p>How can access the property of an object inside generic method?<br> I can't use <code>where T: A</code> because this method will receive different objects, but all objects have a common property to work on.<br> (I also can't make for them a common interface) </p> <pre><code>public class A { public int Number {get;set;} } List&lt;A&gt; listA = new List&lt;A&gt;{ new A {Number =4}, new A {Number =1}, new A {Number =5} }; Work&lt;A&gt;(listA); public static void Work&lt;T&gt;(List&lt;T&gt; list1) { foreach(T item in list1) { do something with item.Number; } } </code></pre> <p>An update: I need also to set the property</p>
c#
[0]
5,004,769
5,004,770
Play sound on page flip in Android
<p>I have an Aurdino Comic where there are so many Jpeg Images. I want to show this images with sound. Which means, when I flip the next page then a flipping sound will be played.</p> <p>Is this possible? I am new to android, please help me.</p> <p>Thank you in advance.</p>
android
[4]
919,480
919,481
calculating factorials in C#
<p>I am trying to write a program that will take the users input value and asks whether they want to calculate the value of the numbers 1 to n or the factorial of n! This is what I have so far</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Project_2_Part_B { class Program { static void Main(string[] args) { var Fkeylow = "f"; var FkeyCap = "F"; var Skeylow="s"; var SkeyCap="S"; int n = 0; long factorial = n; Console.WriteLine("Input a value n"); n = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Do you want to calculate factorial or sum"); Console.WriteLine("Enter F or S"); var A = Console.ReadLine(); if (A == Fkeylow) Console.WriteLine(); if (A == FkeyCap) Console.WriteLine(); var B=Console.ReadLine(); if (B == Skeylow) Console.WriteLine(); if (B == SkeyCap) Console.WriteLine(); Console.WriteLine("Press any key to close..."); Console.ReadLine(); } } } </code></pre> <p>My issue is with the syntax of the calculation to make the code execute the n*(n-1) while n>1 Any help would be greatly appreciated. Thank you in advanced!</p>
c#
[0]
997,371
997,372
Android Dev - R.layout.main , Variable 'R' cannot be resolved
<p>We are new to Android and we are trying to develop a new application. We installed all the basic setup of Android. We tried to run the Android Sample projects in Eclipse. But while to compile the following lines and a few other lines that uses the variable 'R' throws up an error. </p> <p>setContentView(R.layout.activity_main);</p> <p>'R cannot be resolved to a variable'. I do not understand what is causing the error. Anyone help me out in this issue.</p>
android
[4]
3,114,617
3,114,618
Getting specific table row based on id mysql DB
<p>I have a database where I view all the records, the last column is the table ID, I click it and I want to be able to edit that rows data only, here's what I got but it doesn't waork after updating phpmyadmin:::</p> <pre><code> &lt;?php include "db.inc.php"; $id=$_GET['id']; $order = "SELECT * FROM ircb where id='$id'"; $result = mysql_query($order); $row = mysql_fetch_array($result); ?&gt; &lt;form method="post" action="update.php"&gt; &lt;input type="hidden" name="id" value="&lt;? echo "$row[id]"?&gt;"&gt; &lt;tr&gt; &lt;td&gt;Date&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="cdate" value="&lt;? echo "$row[cdate]"?&gt;" size="30" style="color: black;background-color:#FFFF11"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Item&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="item" value="&lt;? echo "$row[item]"?&gt;" size="30" style="color: black;background-color:#FFFF11"&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>I end up getting no results returned, when I hover over the link it does display the correct table row id but when I click the link I get empty boxes containing some of the code like <code>&lt;? echo</code> in the fields..no true values though..and the page header after clicking the link does show ::: ...../edit_form.php?id=8 for row 8 so I assume something in my query is not quite right. thanks</p>
php
[2]
960,562
960,563
Sorting a dictionary by value then by key
<p>This seems like it has to be a dupe but my SO-searching-fu is poor today...</p> <p>Say I have a dictionary of integer key/values, how can I sort the dictionary by the values descending, then by the key descending (for common values).</p> <p>Input:</p> <pre><code>{12:2, 9:1, 14:2} {100:1, 90:4, 99:3, 92:1, 101:1} </code></pre> <p>Output:</p> <pre><code>[(14,2), (12,2), (9,1)] # output from print [(90,4), (99,3), (101,1), (100,1), (92,1)] </code></pre>
python
[7]
5,066,843
5,066,844
Python element-wise in-place addition
<p>Here is the scenario: given <em>n</em> lists (of identical length) of integers and an accumulator (of the same length, indeed), accumulate the element-wise sum, in-place. The in-place constraint is here because I accumulate values in a dict of lists (hum ... quite not clear, see the example below)</p> <p><strong>EDIT</strong>: I'm looking for a solution that does not involve numpy</p> <pre><code># My lists are long (they are actually pixels in 1000x1000 images) # but I keep l low for the sake of the example l = 5 # Values here are arbitrary and won't be repeated in the real word # e.g. list 1 might be [41,15,0,2,3], etc. lists = [ {'id': 1, 'values': [12]*l}, {'id': 2, 'values': [42]*l}, {'id': 2, 'values': [25]*l}, {'id': 1, 'values': [6]*l}, ] maps = { 1: [0]*l, 2: [0]*l } for item in lists: # Get the "target" for this list target = maps[item['id']] # Element-wise addition of item['values'] to target here! # This won't work target = map(lambda x,y:x+y, target, item['values']) # This neither target = [(x+y) for x,y in itertools.izip(target,item['values'])] # For either of the previous to work, I need to re-assign # the result to 'target', like so maps[item['id']] = target </code></pre> <p>While it works and I can professionally live with it, I personally can't.</p> <p>Can anyone make me sleep better tonight ?</p>
python
[7]
5,900,071
5,900,072
How are Messengers garbage collected?
<p>Consider this code:</p> <pre><code>Message message = Message.obtain(null, MSG_REQUEST_QUOTE, symbol); message.replyTo = new Messenger(new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case StockMessengerService.MSG_QUOTE_VALUE: callback.onQuote(symbol, msg.arg1); break; case StockMessengerService.MSG_QUOTE_FAILURE: callback.onFailure(symbol, msg.obj.toString()); break; default: super.handleMessage(msg); } } }); mService.send(message); </code></pre> <p>How is the JVM able to garbage collect the replyTo Messenger? In the Android javadocs, they only have a single Messenger, bound to the Activity. But this code works, but I'm quite curious how it is the JVM doesn't GC the Messenger before it gets its message, OR, whether this code is quite risky and will leak memory?</p> <p>Edit2: mService is like:</p> <pre><code>private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { mService = new Messenger(service); </code></pre> <p>This is based on the sample code in the Service javadoc at <a href="http://developer.android.com/reference/android/app/Service.html" rel="nofollow">http://developer.android.com/reference/android/app/Service.html</a></p> <p>Thanks, Eric</p>
android
[4]
5,584,087
5,584,088
question on the output of double value
<p>In the code, I have</p> <pre><code>int a = 62; int b = 132; double c; c = (double) a/b; System.out.println(c); </code></pre> <p>which prints out the value of c as 0.469696968793869<br> How can I just keep a short format for c, like 0.4697</p>
java
[1]
3,933,335
3,933,336
First android app. Should I use the 2.3.3 version of the honeycomb?
<p>So I`m about to write my first android app. I want it to be able to run on a handset but also on a tablet. </p> <p>My question is, when I create an Android in Eclipse, which SDK should I choose? My initial thought is to write with 2.3.3 SDK. I imagine I should be able to run it on honeycomb as well, or I will have to write the same app but using the 3.0 SDK?</p>
android
[4]
2,384,651
2,384,652
Error in PHP code
<p>The error: </p> <pre><code>Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in PSubscriptionFile.php on line 90; </code></pre> <p>I think that public static _fromJSON should be public </p> <pre><code>static function _fromJSON </code></pre> <p>but that give Fatal error: </p> <pre><code>Declaration of PSubscriptionFile::__construct() must be compatible with that of PuSHSubscriptionInterface::__construct() in PSubscriptionFile.php on line 9 </code></pre> <p>The files: <a href="http://github.com/bobdia/PuSHSubscriber" rel="nofollow">http://github.com/bobdia/PuSHSubscriber</a></p> <p>I don't understand how to fix the error.Thanks!</p>
php
[2]
1,985,440
1,985,441
ASP>NET Page performance issue
<p>I have an asp.net page which has 4 grid views connecting to mysql database for data population. The average response time for a round trip to the server is 20.55 seconds. That is way too much time. I have since applied the HTTP Compression GZip to improve the speed,I don't see any improvement in load time. Any suggestion, ideas will be greatly appreciated.</p> <p>Ive also used pagination, but no effect. </p>
asp.net
[9]
2,533,749
2,533,750
class extending GCanvas won't do as told by addComponentListener
<p>After importing java.awt.event.*, I've added a component listener to a class extending GCanvas with the following code:</p> <pre><code>public NameSurferGraph() { addComponentListener(this); nameList = new ArrayList&lt;NameSurferEntry&gt;(); } public void componentHidden(ComponentEvent e) { } public void componentMoved(ComponentEvent e) { } public void componentResized(ComponentEvent e) { update(); } public void componentShown(ComponentEvent e) { } public void update() { removeAll(); drawBackground(); if (nameList.size()&gt;0) { for (int i=0; i&lt;nameList.size(); i++) {; drawLineForOneName(i); } } } </code></pre> <p>But when I call a method on it from another class, nothing happens.</p> <pre><code>public NameSurferGraph graph = new NameSurferGraph(); public void graphName(String name) { entry = database.findEntry(name); graph.addEntry(entry); graph.update(); } </code></pre> <p>Any ideas about what I might be doing wrong?</p>
java
[1]
3,032,967
3,032,968
How to change file URI string
<p>How to change something <code>file:///system/media/lockscreen/lockscreen_001.jpg</code> to something like <code>/mnt/sdcard/myPicture.jpg</code><br> The reason why I want to change is that file:/// is wrong if I want to further process. It is hard to tell but if I get the <code>URI</code> from <code>Uri uri= data.getData();</code> is <code>file:///system/media/lockscreen/lockscreen_001.jpg</code>, how to handle because normally is start with <code>mnt</code></p>
android
[4]
3,122,036
3,122,037
Extracting substrings at specified positions
<p>How to extract substrings from a string at specified positions For e.g.: ‘ABCDEFGHIJKLM’. I have To extract the substring from 3 to 6 and 8 to 10.</p> <p>Required output: DEFG, IJK</p> <p>Thanks in advance.</p>
python
[7]
652,370
652,371
Is there a document way to create thumbnail from UIImage/UIImageView?
<p>I hope to create thumbnail from an UIImage/UIImageView. There are some undocument solution: <a href="http://ofcodeandmen.poltras.com/2008/10/30/undocumented-uiimage-resizing/" rel="nofollow">http://ofcodeandmen.poltras.com/2008/10/30/undocumented-uiimage-resizing/</a> ..</p> <p>I wonder if there is a documented way to create thumbnail from UIImage/UIImageView?</p> <p>Thanks</p> <p>interdev</p>
iphone
[8]
343,461
343,462
window.open open the page in a new tab instead of in popup window
<p>i'm trying to open popup window this this jscript: window.open(myUrl, ""); for some users the page appears in a new tab, but I want it in a popup window. maybe someone know any reason for it?</p>
javascript
[3]
547,447
547,448
A way to pass a variable into a nested function
<p>Is there a way i can pass information into a nested function ? The problem is i want to use jQuery to animate an object being removed and then after have it remove the object from the dom. But theres no way to pass information into the nested function. I first though the bellow would work but no luck,</p> <pre><code>tab = this.tab //this.tab is a dom element $(this.tab).effect('drop',null,null, function(tab) { $(tab).remove() }) </code></pre> <p>People have suggested that i store the element in a global put this function is part of a class and there can be many objects which may call this function at the same time.</p> <p>Thankyou!</p>
javascript
[3]
2,940,259
2,940,260
Force superscripts for operators in jqMath
<p>I am using jqMath to display chemistry formulas on a website. I need to be able to display charges as superscripts (i.e., positive + and negative charges -). It seems like jqMath (or maybe MathML) hardcodes all math operators to display as normal size. I've tested this with +, -, =, and % signs and none will display as superscripts (tested here: <a href="http://mathscribe.com/author/jqmath.html" rel="nofollow">http://mathscribe.com/author/jqmath.html</a>). Note that </p> <pre><code>&lt;sup&gt;&lt;/sup&gt; </code></pre> <p>is not valid markup when using jqMath; the ^ precedes any character to be superscripted. </p> <p>Has anyone found a way around this? </p>
javascript
[3]
4,720,320
4,720,321
C# background worker and timer loop
<p>This is my first attempt of a Timer, if someone could help me out where I am going wrong it would be awesome.</p> <p>I'm trying to use a while loop where if the timer hits 30 seconds try to loop it again. </p> <pre><code>private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { System.Windows.Forms.Timer my_timer = new System.Windows.Forms.Timer(); my_timer = null; //int restartticker = 30000; while (true) { my_timer.Start(); if (my_timer.Equals(30000)) { watcherprocess1(); } my_timer = null; } } </code></pre> <p>Object reference not set to an instance of an object. my_timer.Start();</p>
c#
[0]
4,647,120
4,647,121
jquery force http:// on value with no http://
<p>So I'm trying to force urls entered into the search box to have "http://" forced on to them because the url doesn't work without it.</p> <pre><code>var mySite = $('.search').val(); if (mySite -="http://"){ alert('http://').append(mySite); }; </code></pre> <p>Sorry if this code is horribly wrong I'm just trying to hash out the idea here.</p>
jquery
[5]
664,265
664,266
Detecting if a variable is global or not
<p>Is there a way to detect weither or not a variable is defined globally inside from inside a function scope?</p>
javascript
[3]
5,542,204
5,542,205
How do I return false if the typeof a function is equal to undefined?
<p>In JavaScript, is there a way to display a message or to return false if the type of an object or function is undefined? It seems as though if an object or function is not present, there's no way to display an error message on screen, but rather the error appears in the Web Console.</p>
javascript
[3]
4,648,629
4,648,630
Is using menuItem.getItemId() valid in finding which MenuItem is selected by user?
<p>I have menu in my App. I need to check for the which menu item been selected by the user and take appropriate action. I did this as,</p> <pre><code> @Override public boolean onOptionsItemSelected(MenuItem menuitem){ String title = menuitem.getTitle().toString(); int itemId = menuitem.getItemId(); switch(itemId){ case 2131296257: -----------------; break; case 2131296258: ------------------; break; } </code></pre> <p>But these MenuItem Id's are getting changed each time I run my App. Now I thought to compare the menuTitle with hard coded string values like ,</p> <pre><code> String title = menuitem.getTitle().toString(); if(title.equals("Settings..")){ ------------- ------------- ------------- } </code></pre> <p>But I don't think it's a good practice. But I guess I can do the same using the menu titles defined in strings.xml. But I am not sure how to use this.... (like R.string.....).</p> <p>Can someone suggest on this please.</p> <p>Thanks</p>
android
[4]
487,528
487,529
how to hide the qtip
<p>Hi i am using Qtip in my Project, i need a little bit help in it, i have placed a condition which the checkbox boolean is true, qtip is active, now what i want is this i want to hide the qtip when checkbox boolean is false, how i am able to do that, anyhelp will be awesome. Thnxs in advance!</p>
jquery
[5]
3,001,351
3,001,352
how to make the value of an array as the keys of the values of another array in PHP?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/5422955/merging-php-array-one-as-keys-the-other-as-values">Merging PHP array, one as Keys the other as Values?</a> </p> </blockquote> <p>i have an array of keys, and i have an array of values..how to make the values of arrray A, as the "keys" of the values of array B ?</p> <pre><code>array A [0] =&gt; 224 [1] =&gt; 77 [2] =&gt; 78 [3] =&gt; 79 [4] =&gt; 80 [5] =&gt; 81 [6] =&gt; 82 [7] =&gt; 76 ) 1 array B Array ( [0] =&gt; Men Shoes [1] =&gt; Fashion Accessories [2] =&gt; Men Apparels [3] =&gt; Shoes &amp; Belts [4] =&gt; Watches &amp; Clocks [5] =&gt; Women Apparels [6] =&gt; Others [7] =&gt; Bags </code></pre> <p>what i want to happen is make it like this</p> <pre><code>array( [224] =&gt; Men Shoes [77] =&gt; Fashion Accessories [78] =&gt; Men Apparells [79] =&gt; Shoes &amp; Belts [80] =&gt; Watches &amp; clocks [81] =&gt; Women Apparels [82] =&gt; Others [76] =&gt; Bags ) </code></pre>
php
[2]
4,264,084
4,264,085
can not redraw rect from callback
<p>I am new on iphone</p> <p>what I wanna do is to render image to iphone</p> <p>so I have one module to generate image data, after done invoke callback function to notify UIView, in UIView I have I have callback function to give the image to UIImage, and then I setNeedsDisplay and return.</p> <p>In my UIView class drawRect:(CGRect)rect I call drawImage, but it does not called, no refresh, also I got NSAutoreleaseNoPool UIImage autoreleased with no pool in place error.</p> <p>any helps?</p> <p>thanks</p>
iphone
[8]
5,716,316
5,716,317
Music doesnot stop after pressing backkey
<p>I have an activity A which invokes Activity B on Button Click,and a Button click on Activity B invokes Class C. When button is clicked in Activity B , B calls a static method in Class C which passes its reference as one of the argument to method in C and other argument is path to the sound file that needs to be played. Once control reaches class C , Audio is played. But when Backkey is pressed Audio doesnot stop it continuous to play. How can I make the Audio to stop when BackKey is pressed. More over when Backkey is pressed control is coming to Activity A instead of Activity B. Can any one help me in solving this issue?</p> <p>class activityA extends Activity <br> { startIntent(ActivityB) on ButtonPress <br> } <br></p> <p>class ActivityB extends Activity <br> { classc.playAudio(ActivityB.this,audiopath); <br> } <br></p> <p>class c <br> { playAudio(Activity a, audiopath) <br> { sound code to play audio is done here. <br> } <br> } <br></p>
android
[4]
5,762,662
5,762,663
drop down list had zero value
<p>I had ddl which in selected changed it execute some code but when i tried to do that it wasn't worked well WHEN i checked the reason i found that ddl in selected value =0 also i made all well and this is my code </p> <pre><code>protected void DDlProductFamily_SelectedIndexChanged(object sender, EventArgs e) { if (DDlProductFamily.DataValueField.Contains("ProductCategory_Id")) using (SqlConnection Con = Connection.GetConnection()) { SqlCommand Com = new SqlCommand("GetListViewByProductCategory", Con); Com.CommandType = CommandType.StoredProcedure; Com.Parameters.Add(Parameter.NewInt("@ProductCategory_Id", DDlProductFamily.SelectedValue.ToString())); SqlDataAdapter DA = new SqlDataAdapter(Com); DA.Fill(dt); DataList1.DataSource = dt; DataList1.DataBind(); } } </code></pre>
asp.net
[9]
4,851,831
4,851,832
How to Convert Android project into Google Api project
<p>i developed android application in normal android2.1, i want to use Google map in my application. can i convert my android2.1 application into Google API application. I add maps jar file in my normal android application. but its not working. It throws an error like "java.lang.NoClassDefFoundError:".</p> <p>Any one know how to solve this problem?</p>
android
[4]