Unnamed: 0 int64 65 6.03M | Id int64 66 6.03M | Title stringlengths 10 191 | input stringlengths 23 4.18k | output stringclasses 10 values | Tag_Number stringclasses 10 values |
|---|---|---|---|---|---|
1,720,875 | 1,720,876 | how to zip a text file | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/1666824/net-zip-up-files">.Net Zip Up files</a> </p>
</blockquote>
<p>Hi,</p>
<p>I am having a problem in creating a text file to zip file ,</p>
<p>I am creating a project which reads data file and convert it into a text file .</p>
<p>My code creates a text file .I want to zip the text file which is created , </p>
<p>Here Is My Code,</p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
string path = DayFuturesDestination + "\\" + txtSelectedDate.Text + ".txt";
StreamWriter Strwriter = new StreamWriter(path);
}
</code></pre>
<p>Can Anyone Pls Say me how to create the zip file after creating it into a text file.</p>
<p>Thanks In Advance.</p>
| c# | [0] |
4,766,228 | 4,766,229 | Getting specific value from an array with PHP | <p>If I have an array in the following format: </p>
<pre><code>Array ( [0] => stdClass Object ( [id] => 1 [c] => 1 [q] => value 1. ) [1] => stdClass Object ( [id] => 2 [c] => 1 [q] => value 2...
</code></pre>
<p>and I need to get </p>
<blockquote>
<p>value 1</p>
</blockquote>
<p>Shouldn't I be able to get it by doing something like? </p>
<pre><code>$myArray[0]['q']
</code></pre>
<p>FOr some reason I'm not getting anything...</p>
| php | [2] |
3,912,615 | 3,912,616 | c# Display the data in the List view | <pre><code>private void displayResultsButton_Click(object sender, EventArgs e)
{
gameResultsListView.Items.Clear();
//foreach (Game game in footballLeagueDatabase.games)
//{
ListViewItem row = new ListViewItem();
row.SubItems.Add(game.HomeTeam.ToString());
row.SubItems.Add(game.HomeScore.ToString());
row.SubItems.Add(game.AwayTeam.ToString());
row.SubItems.Add(game.AwayScore.ToString());
gameResultsListView.Items.Add(row);
// }
//footballLeagueDatabase.games.Sort();
}
}
}
</code></pre>
<p>This is the display button and the following code describes the add button.</p>
<pre><code>private void addGameButton_Click(object sender, EventArgs e)
{
if ((homeTeamTxt.Text.Length) == 0)
MessageBox.Show("You must enter a Home Team");
else if (homeScoreUpDown.Maximum <= 9 && homeScoreUpDown.Minimum >= 0)
MessageBox.Show("You must enter one digit between 0 and 9");
else if ((awayTeamTxt.Text.Length) == 0)
MessageBox.Show("You must enter a Away Team");
else if (awayScoreUpDown.Maximum <= 9 && awayScoreUpDown.Minimum >= 0)
MessageBox.Show("You must enter one digit between 0 to 9");
else
{
//checkGameInputFields();
game = new Game(homeTeamTxt.Text, int.Parse(homeScoreUpDown.Value.ToString()), awayTeamTxt.Text, int.Parse(awayScoreUpDown.Value.ToString()));
MessageBox.Show("Home Team" + 't' + homeTeamTxt.Text + "Away Team" + awayTeamTxt.Text + "created");
footballLeagueDatabase.AddGame(game);
//clearCreateStudentInputFields();
}
}
</code></pre>
<p>I need to insert data into the above text field and Numeric up down control and display them in the list view.
But I dont know How to do it, because when I press the button "Display Results" it displays the error message.</p>
<p>If you know how can I display the data in the list view, please let me know.This is the first time I am using List view.</p>
| c# | [0] |
1,075,491 | 1,075,492 | All my code is being overwritten by the last section | <p>We have a map which uses polygons to create overlays on top of countries. When a user hovers over a country the polygons change color.</p>
<p>When the mouse leave the country it changes back (or at least we want it to)</p>
<p>Us the code below what happens is that that both countries access the settings for JUST the last section of code. It seems all other code is overwritten.</p>
<p>I don't know which variable to make unique.</p>
<pre><code>for(var i = 0; i < germany.length; i++){
addListener( germany[ i ], germany );
}
function addListener( germany_item, tweened )
{
google.maps.event.addListener(germany_item, "mouseover",function() {
for( var i in tweened )
tweened[ i ].setOptions({ fillColor: "#DD732B", strokeColor: "#DD732B" });
});
google.maps.event.addListener(germany_item, "mouseout",function() {
for( var i in tweened )
tweened[ i ].setOptions({ fillColor: "#5EA9BD", strokeColor: "#5EA9BD" });
});
}//
for(var i = 0; i < france.length; i++){
addListener( france[ i ], france );
}
function addListener( france_item, tweened )
{
google.maps.event.addListener(france_item, "mouseover",function() {
for( var i in tweened )
tweened[ i ].setOptions({ fillColor: "#DD732B", strokeColor: "#DD732B" });
});
google.maps.event.addListener(france_item, "mouseout",function() {
for( var i in tweened )
tweened[ i ].setOptions({ fillColor: "#006886", strokeColor: "#006886" });
});
</code></pre>
| javascript | [3] |
2,308,268 | 2,308,269 | trying to create a jquery plugin for a custom check-box | <p>I am trying to create my own styled checkbox jQuery plugin. What I want to do is hide the check-box which is working and append a span after the check-box but the span is not adding after the check-box. Why is this?</p>
<h2>SETUP</h2>
<pre><code>var checkBox1 = $("<input type='checkbox'/>");
$(checkBox1).genCheckBox();
$(divBGContainer).append(checkBox1);
</code></pre>
<h2>PLUGIN</h2>
<pre><code>(function($) {
$.fn.genCheckBox = function(settings) {
var def = {
height: 15,
width: 15
};
$(this).css("display", "none");
var span = $("<span/>");
$(span).insertAfter(this);
}
})(jQuery);
</code></pre>
| jquery | [5] |
5,070,542 | 5,070,543 | javascript function - return value chain | <p>I need to access local variable returned by function inside a chained function</p>
<p>ex.</p>
<pre><code>$("#history_table").bind("sortStart", function() {
var a=30;
return a;
}).bind("sortEnd", function() {
alert(a);
});
</code></pre>
<p>here in this example I need to access variable a returned by the first function, sortStart and aortEnd events will trigger the two functions asynchronously... </p>
| javascript | [3] |
5,516,659 | 5,516,660 | How to encrypt and decrypt folder in android sdcard | <p>is it possible to encrypt the sd card folder r not please help me</p>
<p>if it possible , what is the processor of encryption and decryption</p>
<p>not possible , let me know what can i do for folder security in android sdcard </p>
<p>My file is here :/mnt/sdcard/image1.jpeg.</p>
<p>So How to encrypt this file in android please help me
and Android encryption support MBs r not</p>
| android | [4] |
4,338,150 | 4,338,151 | does nulling a System.Threading.Timer stop it? | <p>If I have an active <a href="http://msdn.microsoft.com/en-us/library/system.threading.timer%28VS.90%29.aspx" rel="nofollow">System.Threading.Timer</a> and I set it to null, is it stopped?</p>
<p>I realize that it is more proper to call <code>.Dispose()</code> but I would like an answer to the question as written.</p>
<pre><code>public class Foo
{
private System.Threading.Timer _timer;
public Foo()
{
// initialize timer
}
public void KillTimer()
{
_timer=null;
}
}
</code></pre>
<hr>
<h3>Update:</h3>
<p>After much back and forth about whether setting a single reference to a System.Threading.Timer to null will indeed result stopping it have shown that</p>
<ol>
<li>there are no lingering references, e.g. events list, as a threading timer takes a sinlge callback and does not expose events.</li>
<li>that <strong><em>if</em></strong> GC collects, the finalizer will indeed dispose the TimerBase and stop the timer.</li>
</ol>
<p>spike</p>
<pre><code>using System;
using System.Threading;
namespace SO_3597276
{
class Program
{
private static System.Threading.Timer _timer;
static void Main(string[] args)
{
_timer = new Timer((s) => Console.WriteLine("fired"), null, 1000, Timeout.Infinite);
_timer = null;
GC.Collect();
Console.ReadKey();
}
}
}
</code></pre>
<p>The timer callback is not called. Remove <code>GC.Collect()</code> and the callback is called.</p>
<p>Thanks all.</p>
| c# | [0] |
1,367,121 | 1,367,122 | isNaN not firing until 2 characters are typed in | <p>My HTML code is:</p>
<pre><code><input onKeyPress="validateA(this.value)" type="text" id="AAA" name="AAA" size="10" placeholder="A">
<span id="aspan" class="validate"> </span>
</code></pre>
<p>and my Javascript is:</p>
<pre><code>function validateA(valueOfAAA) {
if (isNaN(valueOfAAA)) {
document.getElementById('aspan').innerHTML="Please enter a numerical value.";
}
else {
document.getElementById('aspan').innerHTML="";
}
}
</code></pre>
<p>To clarify, my question is:</p>
<p>Why is the <code>innerHTML="Please enter a numerical value."</code> not firing until two letters OR numbers are typed into my input box?</p>
| javascript | [3] |
1,776,958 | 1,776,959 | Error: NetBeans 7.0 Android SDK 14 | <p>I am getting the following error on NetBeans 7.0 trying to run a HelloAndroid application. The Android SDK as well as an Android device have already been detected by NetBeans, and I followed all the instructions given.</p>
<blockquote>
<p>C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:421: Android Target is not set.</p>
</blockquote>
| android | [4] |
24,345 | 24,346 | jquery gt() get current index | <p>I'm using <code>gt()</code> to add columns to a table.</p>
<p>I need to use the row number and the column number to build the cell id.</p>
<p>Getting the column number is straightforward:</p>
<pre><code>var c = $("#gridLayout tr:first td").length;
</code></pre>
<p>but how can I get the current index from gt() for the row number?</p>
<pre><code>$("#gridLayout tr:gt(0)").append('<td>.......</td>');
</code></pre>
| jquery | [5] |
2,588,849 | 2,588,850 | Not seeing Nexus7 in Eclipse's Android Devices | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8801829/adb-dosnt-recognize-my-galaxy-nexus-win7">ADB dosn't recognize my Galaxy Nexus - Win7</a> </p>
</blockquote>
<p>I'm not seeing my Nexus7 listed in Eclipse's DDMS Devices.</p>
<p>DDMS and "adb devices" from the console show my G1 android phone, but not the Nexus7.</p>
<p>Usb Debugging is enabled on both phones, Eclipse is up to date as far as I can tell, Android SDK's Google-USB-rev6</p>
<p>When I plugged in the N7 USB, I did see the Windows7 driver installed, and can browse files on it from file manager.</p>
<p>MTP/PTP made no difference (MTP drivers from Microsoft Update, none for PTP)</p>
<p>"Select debug app" in Developer Options shows nothing.</p>
<p>"Unknown sources" is checked.</p>
<p>Tried different Usb port, toggled Usb Debugging. </p>
| android | [4] |
5,876,133 | 5,876,134 | Why is my script only running every few page loads? | <p>I find that my script can sometimes run only after 2 or 3 page loads, sometimes it runs without issue, but after 2 or 3 successful loads it will go back to only running the script sometimes.</p>
<p>For compression, here's my script on pastebin: <a href="http://pastebin.com/hyQ1uN9Y" rel="nofollow">http://pastebin.com/hyQ1uN9Y</a></p>
<p>My script live, so that you might be able to see this in action: <a href="http://bit.ly/qaDZLX" rel="nofollow">http://bit.ly/qaDZLX</a></p>
<p>Any idea why this could be? It's meant to redirect after page load by means of a meta-refresh, yet sometimes the page just loads blank. I know the script isn't being run in the background just leaving out the redirect, as no data in the table is updated.</p>
<p>Any help/thoughts would be very appreciated ;).</p>
<p><strong>EDIT:</strong> Won't work properly (for live viewing) on chrome. Personally, I'm your cross-browser kind of guy, especially if it's a big browser like chrome, but the client was insistent that he didn't care (he needs a meta-refresh for this to work properly).</p>
| php | [2] |
4,000,262 | 4,000,263 | Why doesn't ScheduledExecutorService spawn threads as needed? | <p>In my application I use ScheduledExecutorService, but only one thread is spawned to handle the scheduled tasks. Is this because ScheduledExecutorService does not spawn threads to handle the pending tasks?</p>
<p>Here is a code snippet that will output only "run() 1" instead of the expected "run() 1" followed by "run() 2" ... "run() 10."</p>
<pre><code>public class App {
public static void main(String[] args) {
int N = 10;
Runnable runner = new Runnable() {
public void run() {
foo();
}
};
for (int i = 0; i < N; i++) {
executor.schedule(runner, i, TimeUnit.MILLISECONDS);
}
}
private static void foo() {
System.out.println("run() " + (++n));
synchronized (executor) {
try {
executor.wait();
} catch (InterruptedException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
}
}
System.out.println("finished()");
}
private static Logger logger = Logger.getLogger(App.class.getName());
private static int n = 0;
private static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
}
</code></pre>
| java | [1] |
975,742 | 975,743 | What question should be asked to test the interview candidate's knowledge of references in C++? | <p>If a candidate says that his knowledge in C++ is 7/10 and you want to test his knowledge of references in C++, what question will you ask?</p>
<p>I thought of the following:</p>
<ol>
<li>Write a function declaration that takes a pointer as reference with default values and ask him to figure out a mistake and explain it.</li>
<li>Pass a literal as argument to a function that takes that parameter as reference.</li>
</ol>
<p>Any other question that is better at testing candidates overall knowledge of references in C++?</p>
<p>Thanks,</p>
| c++ | [6] |
4,328,726 | 4,328,727 | how to get enter row values value from JSGrid in a row when ever user updates the exsisting column values | <p>can any one suggest how to get enter row values value from JSGrid in a row when ever user updates the exsisting column values.</p>
<hr>
| javascript | [3] |
562,508 | 562,509 | CGContext - PDF margin | <p>I am showing PDF content on a view using this code using Quartz Sample:</p>
<pre><code> // PDF page drawing expects a Lower-Left coordinate system, so we flip the coordinate system
// before we start drawing.
CGContextTranslateCTM(context, 0.0, self.bounds.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
// Grab the first PDF page
CGPDFPageRef page = CGPDFDocumentGetPage(pdf, pageNo);
// We're about to modify the context CTM to draw the PDF page where we want it, so save the graphics state in case we want to do more drawing
CGContextSaveGState(context);
// CGPDFPageGetDrawingTransform provides an easy way to get the transform for a PDF page. It will scale down to fit, including any
// base rotations necessary to display the PDF page correctly.
CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, self.bounds, 0, true);
// And apply the transform.
CGContextConcatCTM(context, pdfTransform);
// Finally, we draw the page and restore the graphics state for further manipulations!
CGContextDrawPDFPage(context, page);
CGContextRestoreGState(context);
</code></pre>
<p>Using this all works fine. I want to set the margin for the PDF context, by default it showing 50 px margin in every side. I have tried CGContext methods but not got the appropriate one. Can anybody help me with this?</p>
| iphone | [8] |
2,891,115 | 2,891,116 | How to clear Activity Stack on Button Click in Android | <p>I have a question that I have a logout button in my App on which we have called an App login Screen but at this point when user press the Back Button of Android Phone, he entered in the App again without Authentication, which is not desirable. I want when we click on Logout button All previous Activity Stack being cleared or we can say that All previous onPause Activities have to be cleared.</p>
<p>Please Suggest me the right solution for this problem.</p>
<p>Thanks in advance.</p>
| android | [4] |
5,283,526 | 5,283,527 | using broad cast receiver along with activity | <p>i am working on a project with many activities but when trying to code a broad cast receiver within a class the broadcast receiver is not working though i have given permission to manifest file. with reciver.</p>
<pre><code><receiver android:name=".IncomingCallReciever" android:exported="true" android:enabled="true">
<intent-filter android:priority="1">actionandroid:name="android.intent.action.NEW_OUTGOING_CALL" />
<action android:name="android.intent.action.PHONE_STATE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
</code></pre>
| android | [4] |
3,254,052 | 3,254,053 | How can i get Client Webpage cookie information through javascript | <p>I want to get the browser cookies information like email or name. </p>
<p>pls help me</p>
| javascript | [3] |
4,778,169 | 4,778,170 | Cannot declare ViewHolder as static inner class | <p>In my application, I am using a listview and have customized the associated array adapter by extending the standard the array adapter.However,inside the extended adapter, I am unable to declare the viewholder as a static inner class. Eclipse keeps giving the error that "static types can only be declared in static or top level types". Here is the code:</p>
<pre><code>public class IconicAdapter extends ArrayAdapter<String>
{
public static class ViewHolder
{
public TextView text;
public ImageView image;
}
public IconicAdapter() {
super(MainActivity.this,R.layout.row,values);
// TODO Auto-generated constructor stub
}
public View getView(int position,View convertView, ViewGroup parent)
{
View row = convertView;
if(row == null)
{
LayoutInflater inflater = getLayoutInflater();
row = inflater.inflate(R.layout.row, parent,false);
}
TextView label =(TextView)row.findViewById(R.id.label);
label.setText(values[position]);
ImageView icon = (ImageView)row.findViewById(R.id.icon);
icon.setImageResource(R.drawable.ok);
return (row);
}
}
</code></pre>
<p>Any suggestion?</p>
| android | [4] |
4,267,248 | 4,267,249 | how to read a textbox value excluding commas using jquery | <p>My requirement is to read a textbox value with a currency formatted number.
eg: 3,500</p>
<p>How to read the textbox value excluding comma in the number? Can anyone please help me in doing this using jquery?</p>
| jquery | [5] |
4,213,362 | 4,213,363 | How to access a static member through a Class object | <p>I'd like to access a static HashMap object on one of my classes. This psuedocode illustrates how I'm attempting to go about it.</p>
<pre><code>public Class A
{
public static HashMap<String,String> myMap;
static
{
myMap.put("my key", "my value");
}
}
...
public void myfunction(Class clazz)
{
HashMap<String,String> myMap = clazz.getThatStaticMap();
}
...
myFunction(A.getClass());
</code></pre>
<p>The call to <code>getThatStaticMap()</code> is the part I don't know how to do.</p>
<p>In my actual code, I'm calling <code>myfunction</code> with a class as a parameter and returning an <code>ArrayList</code> of objects created using the class's newInstance() method but I want access to that static data belonging to the class to configure each instance.</p>
| java | [1] |
826,602 | 826,603 | How can i use Table Cell as UIImageView not using Custum Cell? | <p>In My Application I have to show Image after every 3 Rows.My Image is static and it should come after every 3 rows.I don't want to take UIImageView and add it to cell but if there any way to show my image using directly Cell's property.My Image size is 320X87 pixels. </p>
| iphone | [8] |
1,867,258 | 1,867,259 | Activate the event handler of an HTML element created with MooTool's extended element | <p>In browsing a JavaScript file, I see the following line:</p>
<pre><code>this.close = new Element('a', {id:'close-btn', href: 'javascript:void(0);', 'class': this.typeprefix + '-deletebutton', events: {click: this.remove.bind(this)}}).inject(this.bit);
</code></pre>
<p>I'm guessing that new Element() is a MooTools extended element. I can't seem to programmatically fire the MooTool's click event.</p>
<p>I tried</p>
<pre><code>document.getElementById('close-btn').onclick.apply(document.getElementById('close-btn'));
</code></pre>
<p>but nothing happened. Each of the following lines below gave me an undefined:</p>
<pre><code>alert(document.getElementById('close-btn').click);
alert(document.getElementById('close-btn').onclick);
alert(document.getElementById('close-btn').events);
alert(document.getElementById('close-btn').['events']);
</code></pre>
<p>Anyone have any ideas on how to programmatically fire the anchor's click event?</p>
| javascript | [3] |
5,288,328 | 5,288,329 | Detecting key presses in console | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/8898182/how-to-handle-key-press-event-in-console-application">how to handle key press event in console application</a> </p>
</blockquote>
<p>a simple question.</p>
<p>I am writing a simple text based adventure game for fun and I am stuck on the first part already! How can I make my console check for key presses I.E: press enter to continue!</p>
| c# | [0] |
2,530,926 | 2,530,927 | Android: UI design for calendar | <p>I am planning to develop a calendar UI with time displayed horizontally and date vertically. Please refer the image below:</p>
<p><a href="http://i54.tinypic.com/a2uiw8.png" rel="nofollow">http://i54.tinypic.com/a2uiw8.png</a></p>
<p>The following is my design requirement for the above attached UI design:</p>
<ol>
<li><p>This UI should be allowed to scroll horizontally and vertically</p></li>
<li><p>While scrolling horizontally, first column with date to be static and not moved horizontally. Only Meeting schedule and time in the top should scroll</p></li>
<li><p>When scrolling vertically, top most rows with time and "my calendar" text shouldn't move and it should be static. Only Date column and meeting columns should scroll</p></li>
</ol>
<p>My questions:</p>
<ol>
<li><p>What is the best layout for this ?
I guess tablelayout is the good one to use</p></li>
<li><p>How to implement the design requirements mentioned in 2 and 3 using table layout or any other layout?</p></li>
</ol>
<p>I am trying to find a solution for this. But couldn't find a better one. Please help me on this.</p>
<p>Thanks..</p>
| android | [4] |
4,395,334 | 4,395,335 | How to check if a word exists in a text file using Python 3.3 | <p>The program is used to find anagrams for a inputted string. The possible anagrams come from a text file 'dict.txt'. However, I am trying to check if the inputted string is not in the dictionary. If the inputted string is not the dictionary, the program should not look for anagrams, and just print a message saying that the inputted string is not in the dictionary. Currently the code is saying that all of my inputted strings are not in the dictionary, which is incorrect. </p>
<pre><code>def anagram(word,checkword):
for letter in word:
if letter in checkword:
checkword = checkword.replace(letter, '')
else:
return False
return True
def print_anagram_list():
if len(word_list) == 2:
print ('The anagrams for', inputted_word, 'are', (' and '.join(word_list)))
elif len(word_list) > 2:
print ('The anagrams for', inputted_word, 'are', (', '.join(word_list[:-1]))+ ' and ' +(word_list[-1]))
elif len(word_list) == 0:
print ('There are no anagrams for', inputted_word)
elif len(word_list) == 1:
print ('The only anagram for', inputted_word, 'is', (''.join(word_list)))
def anagram_finder():
for line in f:
word = line.strip()
if len(word)==len(inputted_word):
if word == inputted_word:
continue
elif anagram(word, inputted_word):
word_list.append(word)
print_anagram_list()
def check(wordcheck):
if wordcheck not in f:
print('The word', wordcheck, 'is not in the dictionary')
while True:
try:
f = open('dict.txt', 'r')
word_list=[]
inputted_word = input('Your word? ').lower()
check(inputted_word)
anagram_finder()
except EOFError:
break
except KeyboardInterrupt:
break
f.close()
</code></pre>
| python | [7] |
1,768,781 | 1,768,782 | Understanding prototype method calls | <p>In trying to call a method on the <a href="http://marijn.haverbeke.nl/codemirror/manual.html" rel="nofollow">CodeMirror</a> javascript code editor. I'm new to javascript and trying to understand how object oriented stuff works. I'm having problems calling what I believe are methods. For instance,</p>
<pre><code>var editor = CodeMirror.fromTextArea('code', options);
editor.grabKeys(function(e) { alert("Key event");});
</code></pre>
<p>This gives the <code>Uncaught TypeError: Cannot call method 'grabKeys' of undefined</code>. Looking at the <code>editor</code> object reveals that grabKeys seems to be located at <code>editor.__proto__.grabKeys</code>.</p>
<p>How should I be thinking about this?</p>
| javascript | [3] |
2,903,641 | 2,903,642 | Name 'variable_name' used both as a parameter and as a global. How to fix? | <p>The code I am working with is</p>
<pre><code>build_data = {}
# Code that adds data to build_data
build_data_filtered = {}
if flag:
# Code that adds subset of build_data to build_data_filtered
global build_data
build_data = build_data_filtered
</code></pre>
<p>The line "global build_data" shows a code hint in pycharm</p>
<pre><code>Name 'build_data' used both as a parameter and as a global
</code></pre>
<p>What can I do to remove this hint or is there a better approach to this?</p>
| python | [7] |
1,866,573 | 1,866,574 | What does it mean "weakly-referenced object no longer exists"? | <p>I am running a Python code and I get the following error message:</p>
<pre><code>Exception exceptions.ReferenceError: 'weakly-referenced object no longer exists' in <bound method crawler.__del__ of <searchengine.crawler instance at 0x2b8c1f99ef80>> ignored
</code></pre>
<p>Does anybody know what can it means?</p>
<p>P.S.
This is the code which produce the error:</p>
<pre><code>import sqlite
class crawler:
def __init__(self,dbname):
tmp = sqlite.connect(dbname)
self.con = tmp.cursor()
def __del__(self):
self.con.close()
crawler = crawler('searchindex.db')
</code></pre>
| python | [7] |
5,821,179 | 5,821,180 | create object from Form without Ref | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/78536/cloning-objects-in-c-sharp">Cloning objects in C#</a> </p>
</blockquote>
<p>My code :</p>
<pre><code>private void button1_Click(object sender, EventArgs e)
{
CopyForm(new Form1());
}
public void CopyForm(Form form)
{
Form frm = form;
frm.Text = "1";
form.Text = "2";
string c = frm.Text;// out 2
string c2 = form.Text;// out 2
}
</code></pre>
<p>How to create object from Form <code>without Ref</code> ?</p>
<p>Please show me the best way.</p>
<p>Edit :</p>
<p>please sample.</p>
| c# | [0] |
5,510,364 | 5,510,365 | How to round to nearest Thousand? | <p>How Do I round a number to its nearest thousand?<br>
<br>
function round($var){<br>
// Round it <br>
}</p>
| php | [2] |
54,580 | 54,581 | finding the request on a port | <p>how i can write a java program to find the total number of requests which can be found on a particular port with complete specification (request at present,request running & request pending?</p>
| java | [1] |
1,698,433 | 1,698,434 | adding a uiTableView in landscape mode as a modalView | <p>I am having a UITabBarController set up with many views, In one of the views , i have a UIbUTTON. On clicking this button or on a rotate , I wanted a landscape modal view controller having a tableViewController to popup. </p>
<p>Inside the modalviewController , on rotating to portait mode , it shud return back to the original orientation of the tabBarController.</p>
<p>I was UIDevice setOrientation for this, now this is being rejected by apple. Any pointers on how to do this?</p>
| iphone | [8] |
1,773,461 | 1,773,462 | Send mail From Localhost using PHP | <p>how to send Mail from localhost using PHP?</p>
<p>sending mail from localhost to remote server</p>
<p>i am using wamp server,OS windows Xp.</p>
<p>can anyone tell me about this issue</p>
<p>thank u in advance</p>
| php | [2] |
2,643,891 | 2,643,892 | Animation breaking on rapid button click | <p>So i have a slider (which is very buggy a WIP) but if i was to hammer (a british term for spam) one of the two navigational buttons the slider seems to breaks.</p>
<p>I think the example should speak for itself.</p>
<p><a href="http://jsfiddle.net/xavi3r/aZkPZ/" rel="nofollow">http://jsfiddle.net/xavi3r/aZkPZ/</a></p>
| jquery | [5] |
310,405 | 310,406 | Closest to “Mathematica Graphics[]" drawing environment for Python | <p>Being only familiar with Mathematica and its Graphics, I have now to learn to draw Graphics using Python for a server.</p>
<p>Mostly conditional combination of simple shape.</p>
<p><strong>What would be a package for Python that make drawing Graphics as close as possible as the Mathematica Graphics environment ?</strong></p>
<p>For Example, I would need to do such thing as in :</p>
<p><a href="http://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution-of-squares-coordinates#comment2475_1010">http://mathematica.stackexchange.com/questions/1010/2d-gaussian-distribution-of-squares-coordinates#comment2475_1010</a></p>
| python | [7] |
3,921,345 | 3,921,346 | in java how to avoid multiple if else with map for isAssignableFrom | <p>I would like to avoid the if else, in java this:</p>
<pre><code> for (Class clazz : method.getParameterTypes()) {
if (SomeClass.class.isAssignableFrom(clazz)) {
arguments[i] = onearg;
} else if (SomeOtherClass.class.isAssignableFrom(clazz)) {
arguments[i] = someotherarg;
}
}
</code></pre>
<p>can anyone suggest how to do this? thanks</p>
| java | [1] |
2,821,341 | 2,821,342 | trimming the string | <p>I have java String of say length 10 .Now i want to reduce it to lenthg of 5 .Is there something i can do like we do in C as shown below</p>
<pre><code> str[6] = '\0' ; //insert null at 6th place so remaining string is ignored.
</code></pre>
<p>I dont want to use inbuilt API of java to do this.The main problem that i wanted to solve is i wanted to remove duplicate characters in string .Now after removing duplicate characters string size is reduced so i want to remove remaining 5 characters.</p>
| java | [1] |
3,893,457 | 3,893,458 | Binding more click events on body will affect application the performance? | <p>My web app has many jquery custom components, in which most of them needs outside(body click) click to hide them. So the body have many click events with different namespace. Today my superior told me that application becomes slow (I have recently added some body click events) </p>
<p>Binding many click events will affect the applications overall performance. If it does, how shall i increase the performance without affecting the existing functionalities.</p>
<p>Thanks.</p>
| jquery | [5] |
3,709,859 | 3,709,860 | Replace strings possible with output of PHP file_get_contents? | <p>I'm using PHP to get content from an external website.</p>
<p>I want to know if it's possible to find and replace strings from the output so I can make all links absolute.</p>
<p>I need to convert "/ and '/ to "$url/</p>
<p>If it's possible to do that, I can figure out how to do the rest. I don't know if it's possible though.</p>
<p>Thanks</p>
| php | [2] |
642,608 | 642,609 | Checkable ImageView | <p>Does anybody know if it possible to make ImageView checkable. I try to use State-list drawable resource in my project where I define pictures for my ImageView check states, but there is no property to make ImageView checkable, only clickable.</p>
<p>Maybe anybody knows a way to solve this problem? </p>
| android | [4] |
2,355,023 | 2,355,024 | Broken ... System Image for Android in SDK Manager | <p>I notice the following in my Android SDK Manager:</p>
<pre><code>Broken Intel x86 Atom System Image, API 16
Broken Mips System Image, API 16
Broken ARM EABI v7a System Image, API 16
</code></pre>
<p>Where should I store my System Image for the above in which folder inside android-sdk to get rid of the "Broken" error message?</p>
| android | [4] |
5,531,083 | 5,531,084 | Android Gesture Prediction Score Range | <p>I'm working on a game for Android that uses gestures as input. I've got a working demo, but the gesture recognition seems a bit too liberal (e.g. there are many false positives), and as I'm considering a gesture library of 30 or so, this will be more of a problem as I add in new gestures.</p>
<p>The official documentation is here:</p>
<p><a href="http://developer.android.com/resources/articles/gestures.html">http://developer.android.com/resources/articles/gestures.html</a></p>
<p>It says:</p>
<blockquote>
<p>In this example, the first prediction is taken into account only if
it's score is greater than 1.0. The threshold you use is entirely up
to you but know that scores lower than 1.0 are typically poor matches.</p>
</blockquote>
<p>Okay, that's great, but what is the range of values for prediction.score? Neither this page nor the javadocs appears to provide a range of values. Does anyone here know? I will have to tweak the values anyway, but it would be nice to have some baseline for my guesses, and this seems like a weird oversight of the documentation.</p>
| android | [4] |
923,098 | 923,099 | How to handle listView item changes in managed option menu dialogs? | <p>I create a dialog in my activities <code>onCreateDialog</code> method like this</p>
<pre><code>ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.select_dialog_item, android.R.id.text1, items);
dialog = new AlertDialog.Builder(this).setTitle(R.string.dialogTitle).setAdapter(adapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
// do something
}
}).create();
</code></pre>
<p>The items I want to show in the dialog are in a simple ArrayList</p>
<pre><code>private List<String> items = new ArrayList<String>();
</code></pre>
<p>The dialog is now managed (saved and restored) by my activity - as I understand. Thus it is not recreated every time the user presses the menu button to open the dialog.</p>
<p>According to some user selection on the activity - the item list of the dialog needs to be changed. I thought this would be no great problem but after changing the content of the list I run into the following exception:</p>
<pre><code>06-03 10:55:29.263: ERROR/AndroidRuntime(276): java.lang.IllegalStateException:
The content of the adapter has changed but ListView did not receive a notification.
Make sure the content of your adapter is not modified from a background thread,
but only from the UI thread. [in ListView(16908785, class com.android.internal.app.AlertController$RecycleListView) with Adapter(class android.widget.ArrayAdapter)]
</code></pre>
<p>I debugged the <code>Thread.currentThread().getId()</code> and found it always to be "1" (creation of the dialog and also changing the items list).</p>
<p>How can I handle the item list changes to be noticed by my dialog? Or should I avoid using a "managed" dialog and create it from scratch every time the user opens it?</p>
<p>How can/should I make things work?</p>
<p>Thanks for any suggestions!</p>
| android | [4] |
4,795,845 | 4,795,846 | When I try calling the bubbleSort method within the class I get "itemsPriority can not be resolved to a type." | <p>As a part II to an assignment I must implement a sort method (I've chosen a bubbleSort) to sort an array of priorities from user input. In my previous part I program I accomplished this without a sort, by keeping track of what index the priority was assigned to. </p>
<p>I've been trying to implement a bubblesort in my ShoppingList class with plans to call the sort from my GoShopping (main) class. However this does not seem to be working, most likely because I am very new to Java.</p>
<p>When I try calling the bubbleSort method within the class I get itemsPriority can not be resolved to a type. I'm greatful for any advice.</p>
<pre><code>public class ShoppingList
public ShoppingList ()
{
super();
}
private int[] itemsPriority = new int[7];
public void pry(int itemsPry, int index)
{
itemsPriority[index] = itemsPry;
}
//run through the 2 arrays 7 times to give user their item and price
public int getPriorityItem(int i) //getItemAtPriority
{
for(int j = 0; j< 7;j++){
if(i == itemsPriority[j]){
return j;
}
}
return -1;
}
public String getItemNameAtPriority(int i) {
for(int j = 0; j< 7;j++){
if(i == itemsPriority[j]){
return itemNames[j];
}
}
return null;
}
//set itemPriority to use for shopping
public void setPriorityItem(int i, int PriorityItem) {
this.itemsPriority[i] = PriorityItem;
public int getitemsPriority(int i){
return itemsPriority[i];
}
public void bubbleSort(int[]itemsPriority) {
boolean swapped = true;
int temp;
while (swapped)
{
swapped = false;
for (int i = 0; i < itemsPriority.length - 1; i++)
{
if (itemsPriority[i] > itemsPriority[i + 1])
{
temp = itemsPriority[i];
itemsPriority[i] = itemsPriority[i + 1];
itemsPriority[i + 1] = temp;
swapped = true;
</code></pre>
| java | [1] |
5,757,992 | 5,757,993 | When does a class unload from heap memory | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="http://stackoverflow.com/questions/148681/unloading-classes-in-java">Unloading classes in java?</a> </p>
</blockquote>
<p>When does a class unload from memory?</p>
<p>For loading a class we can call <code>Class.forName("NameOfClass");</code> or when we create an object of a class, then the class loaded into memory.</p>
| java | [1] |
904,674 | 904,675 | python if file does not exist fails | <p>so I have a loop that checks folder if it contains *.zip file</p>
<pre><code>for file in glob.glob( os.path.join(rootdir, '*.zip')):
print "zip", file
#Check if file does not exist
if not os.path.exists(file):
print "No files"
#return
else:
some code
</code></pre>
<p>Now if file exist else works, but if there is no zip file print does not happen</p>
<p>Any suggestions??
Thank you</p>
| python | [7] |
4,278,900 | 4,278,901 | jQuery: How to get only direct text without tags (in HTML) | <p>I've got an HTML:</p>
<pre><code><strong>1)</strong>TEXT THAT I ONLY NEED<p>some par</p><ul>..</ul>
</code></pre>
<p>I need only <strong>"TEXT THAT I ONLY NEED"</strong> that is not withing any tags in his HTML, how can I get it with jQuery?</p>
<p>Thanks.</p>
| jquery | [5] |
45,568 | 45,569 | Gallery image display | <p>I am very new to android platform. I am calling this method <code>ga.setSelection(1);</code> in my <code>onCreate()</code> method. After running my application first image is focused but I want focused image and also display the same time. Can anybody please tell me how to display the image in gallery view?</p>
<p>Thanks
Raj</p>
| android | [4] |
5,091,595 | 5,091,596 | How to select all form elements? | <p>I usually just do this:</p>
<pre><code> $("#formid input, #formid select, #formid textarea")
</code></pre>
<p>But is there any shorthand for this, like..</p>
<pre><code> $("#formid All-Form-Elements")
</code></pre>
<p>?</p>
| jquery | [5] |
5,695,970 | 5,695,971 | How can I use the camera in Droid X by Android application | <p>In my two to three application I have to used camera activity from application. User taken the picture using camera and set that image on image View.</p>
<p>It works for all devices excepting Droid X. When the user takes the picture from Droid X mobile, application is forced close.</p>
<p>Here is my code for start camera activity:</p>
<pre><code>public void startCameraActivity()
{
_path = Environment.getExternalStorageDirectory() + "/default.jpg";
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST) {
_taken = true;
bita = BitmapFactory.decodeFile( _path);
imv.setImageBitmap(bita);
}
}
</code></pre>
<p>So what should I do to run camera activity successfully in Droid X? I wasn't able to find what the problem is.</p>
| android | [4] |
203,146 | 203,147 | In app billing - handling IN_APP_NOTIFY | <p>I'm implementing in-app billing for android and I had a question about handling the IN_APP_NOTIFY intent. Is there a way to determine what original request triggered this intent? As an example, if I send multiple requests to the Market service, how would my BroadcastReceiver know which request triggered the intent? </p>
<p>Thanks</p>
<p>Shravan</p>
| android | [4] |
1,298,628 | 1,298,629 | Receiving Memory Warning Level =1, Level =2 And Then Crashes | <p>I am Trying To Develop An TilesGame And I Am At The Last Stage. But My Project Begin to Show Unexpected Behaviors. At Random Times It Shows Memory Warning Level =1, Level = 2 and Then,
Program received signal: “0”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
kill
quit<br>
I don't know where I am Doing Wrong. I have a Huge number of ImageViews, but they are allocated and released properly.</p>
<p>Is There anything about IBOutlets? I released them in My viewController's Dealloc Method.</p>
<p>In ViewController.h</p>
<pre><code> @property (nonatomic, retain) MyCustomButton *paveButton;
@property (nonatomic, retain) MyCustomButton *slackenButton;
@property (nonatomic, retain) MyCustomButton *tkeeperButton;
@property (nonatomic, retain) MyCustomButton *spontButton;
@property (nonatomic, retain) UIImageView *paveHammer;
@property (nonatomic, retain) UIImageView *slackenHammer;
@property (nonatomic, retain) UIImageView *tkeeperHammer;
@property (nonatomic, retain) UIImageView *spontHammer;
@property (nonatomic, retain) UIImageView *paveKnob;
</code></pre>
<p>And In ViewController.m -</p>
<pre><code> @synthesize paveButton;
@synthesize slackenButton;
@synthesize tkeeperButton;
@synthesize spontButton;
@synthesize paveHammer;
@synthesize slackenHammer;
@synthesize tkeeperHammer;
@synthesize spontHammer;
@synthesize paveKnob;
- (void)dealloc {
[super dealloc];
[paveButton release];
[slackenButton release];
[tkeeperButton release];
[spontButton release];
[paveHammer release];
[slackenHammer release];
[tkeeperHammer release];
[spontHammer release];
[paveKnob release];
}
</code></pre>
<p>Where am I Doing Wrong? Any Help?<br>
Thanks In Advance.</p>
| iphone | [8] |
2,550,557 | 2,550,558 | Set all properties of same name recursively | <p>I have an <code>IsDirty</code> property of type <code>bool</code> on most of my objects.</p>
<p>My base object is called <code>Client</code>, but contains several inner collections e.g.: <code>Client.Portfolios.Policies.Covers.CoverOptions</code>, each object type has an <code>IsDirty</code> property:</p>
<ul>
<li><code>Client.IsDirty</code></li>
<li><code>Client.Portfolios.IsDirty</code></li>
<li><code>Client.Portfolios.Policies.IsDirty</code></li>
<li>etc...</li>
</ul>
<p>How do I recursively set all <code>IsDirty</code> properties?</p>
| c# | [0] |
1,438,764 | 1,438,765 | Parsing pakage error in android when install 2.3.4 android device | <p>When i install the apk in android 2.3.4 device it shows "Error on package parsing"application developed on android 2.2 version.How can i install this app into 2.3.4 device?</p>
| android | [4] |
3,663,983 | 3,663,984 | Detect that an option (any) has been selected | <p>I'm wondering how to throw an alert when i select an option of a select. <a href="http://jsfiddle.net/v4ep2/" rel="nofollow">This</a> is my try:</p>
<p><strong>HTML</strong></p>
<pre><code><select id="provinces">
<option>aaa</option>
<option>bbb</option>
<option>ccc</option>
</select>
</code></pre>
<p><strong>JS</strong></p>
<pre><code>$('#provinces').click(function(){
alert("test");
});
</code></pre>
<p>Any idea?</p>
| jquery | [5] |
5,942,070 | 5,942,071 | how to lauch an 3rd application automatically when the android phone is switched on | <p><br>
can any one tell me "how to lauch an 3rd application automatically when the android phone is switched on?". As I want to launch an application which is written by me when the device is turned on.<br>
I will be waiting for any valuable reply .
<p>Thanks in Advance,</p>
| android | [4] |
2,107,096 | 2,107,097 | Why extend Exception class? | <p>I've encountered a class which extends Exception : </p>
<pre><code>public class MyException extends Exception
{
public MyException()
{
super();
}
public MyException(final String argMessage, final Throwable argCause)
{
super(argMessage, argCause);
}
public MyException(final String argMessage)
{
super(argMessage);
}
public MyException(final Throwable argCause)
{
super(argCause);
}
}
</code></pre>
<p>Is it not pointless extening exception this way since all of the overriding constructors are just calling the super class Exception ?</p>
| java | [1] |
3,142,971 | 3,142,972 | Apply class to TD if it has a rowSpan attribute | <p>Looking for a really simple way in jQuery to add a class to a TD when it has the rowspan attribute.</p>
<p>Any ideas?</p>
| jquery | [5] |
3,757,845 | 3,757,846 | Random crash on access to my std::list<string> object | <p>I have been getting random crashes when trying to access my <code>std::list<code><string></code></code> object and can't figure out why it happens.</p>
<p>I started out with an extern <code>vector<code><string></code></code> object but I've created a class for accessing it now, use a list instead (not that it matters but probably more appropriate for what I need it for) and make use of critical section just to be sure, however it didn't help any.</p>
<p>When I was using a vector I had crashes when calling size().
Using critical section or not has the same effect.
I am hoping someone can point me in the right direction.</p>
<p>Thank you!
The code:
<pre><code>
class CWordHandler
{
public:
void AddWord(string text);
void DeleteWord(unsigned index);
string ReadWord(unsigned index);
void ClearWords();
unsigned GetSize();</p>
<p>private:
list<code><string></code> WordContainer;
};
extern CWordHandler WordHandler;
// ----------------------------------
string CWordHandler::ReadWord(unsigned index)
{
list<code><string></code>::iterator it = WordContainer.begin(); // crash
advance(it, index);
return index >= 0 && index <= WordContainer.size() ? *it : 0;
}</pre></code></p>
| c++ | [6] |
4,399,176 | 4,399,177 | Can I un-singleton a singleton | <p>I want to use a library that makes heavy use of singletons, but I actually need some of the manager classes to have multiple instances. The code is open source, but changing the code myself would make updating the lib to a newer version hard.</p>
<p>What tricks are there, if any, to force creation of a new instance of a singleton or even the whole library?</p>
| c++ | [6] |
1,771,928 | 1,771,929 | exe creator software for php | <blockquote>
<p>I want to know exe creator software for php. which software is useful for creatibg exe file.
my requirement is :</p>
</blockquote>
<p>1.it create php setup,<br>
2.create shortcut,<br>
3.install apache and mysql and start mysql and apache server,</p>
<p>Thanks in advance.</p>
| php | [2] |
3,494,832 | 3,494,833 | Problem with my method in C++ | <p>I have a class like so:</p>
<pre><code>class Qtree
{
public:
Qtree();
Qtree(BMP img, int d);
private:
class QtreeNode
{
public:
QtreeNode* nwChild; // pointer to northwest child
QtreeNode* neChild; // pointer to northeast child
QtreeNode* swChild; // pointer to southwest child
QtreeNode* seChild; // pointer to southeast child
RGBApixel element; // the pixel stored as this node's "data"
QtreeNode();
QuadtreeNode copy(QuadtreeNode & n);
};
</code></pre>
<p>And so the question is on the copy method. It makes a copy of a given node and returns it. </p>
<pre><code>QtreeNode Qtree::QtreeNode::copy(QtreeNode & n) {
QtreeNode *newNode;
//....
return newNode;
}
</code></pre>
<p>And then I call copy from my Qtree copy constructor:</p>
<pre><code>root=QtreeNode::copy(*tree.root); //each tree has a root pointer
//have also tried many different things here, but dont really know what to put
</code></pre>
<p>I get the following errors:</p>
<pre><code>error: cannot call member function ‘Qtree::QtreeNode* Qtree::QtreeNode::copy(Qtree::QtreeNode&)’ without object
and
error: no matching function for call to ‘copy(Qtree::QtreeNode&)’
</code></pre>
| c++ | [6] |
5,415,674 | 5,415,675 | Swap two elements of map | <p>I have a <code>map<int, Button*></code> wherein the button class has several attributes, in particular a integer variable named position. </p>
<p>If I want to swap two positions in Button class, I have to change the key, to be always key = Button-> position and it has to be a map.</p>
<p>I thought of deleting the two positions of the map (using the erase) and reinsert (indicating the index):</p>
<p>Example (indexFirst and indexSecond are known):</p>
<pre><code>map<int, Button*> buttons;
int posOfFirst = buttons.find(indexFirst)->second->getPos();
int posOfSecond = buttons.find(indexSecond)->second->getPos();
Button* button1 = buttons.find(indexFirst)->second;
Button* button2 = buttons.find(indexSecond)->second;
buttons.erase(indexFirst);
buttons.erase(indexFirst);
buttons[posOfSecond] = button2;
buttons[posOfFirst] = button1;
</code></pre>
<p>But appears not to change the object. Why?</p>
| c++ | [6] |
3,088,262 | 3,088,263 | PHP fails silently when function not defined? | <p>I am migrating from PHP4 to PHP5</p>
<p>I have this in my .htaccess:</p>
<pre><code>php_flag display_errors on
php_value error_reporting 2039
</code></pre>
<p>Which used to show all errors.</p>
<p>I am still getting some errors but I used to get an error when I called a function that was not defined, but now it stops where it is at and send the client everything up to the error and nothing after. With no error message.</p>
<p>Here is what phpinfo is telling me:</p>
<pre><code>Directive Local Value Master Value
display_errors On Off
error_reporting 2039 6143
</code></pre>
<p>I would like to be able to see my error messages for trouble shooting purposes.</p>
<p>Can someone tell me what I need to do? Thanks!!</p>
| php | [2] |
5,117,386 | 5,117,387 | C++ lvalue required as unary '&' operand | <p>I'm working on a game engine and working on implementing a state design. I have an Engine class which takes care of all the initialization of everything and contains the game loop which calls update, render and handle input functions of the active state.</p>
<p>All my different states inherit from State which requires a reference to the Engine class in its constructor, in order to initialize the protected reference of the engine for future use. Here's the relevant code:</p>
<pre><code>// file: state.h
class Engine;
class State {
public:
State(Engine &engine) : mEngine(engine) { }
protected:
Engine &mEngine;
};
// file: gamestate.h
class GameState : public State {
public:
GameState(Engine &engine) : State(engine) {}
};
</code></pre>
<p>and finally in engine.cpp in the initializer I create a new GameState object, which is where the error is reported.</p>
<pre><code>GameState *state = new GameState(&this);
</code></pre>
<p>I'm coding it in C++ using Qt Creator on Linux at the minute, don't have access to a windows machine right now to see if it's a problem with the gcc or not.</p>
| c++ | [6] |
3,464,233 | 3,464,234 | Iterative in order over Counter object | <p>I have a Counter object that looks like this:</p>
<pre><code>counts = Counter({'foo': 10, 'baz': 5, 'biff': 3, 'bonk': 1})
for k, v in counts.items():
print k, v
bonk 1
foo 10
baz 5
biff 3
</code></pre>
<p>What is the best way to iterative over the Counter object by descending frequency of the values? Speed is important. There is an OrderCounter class in the docs, but I was looking for something simpler.</p>
| python | [7] |
5,313,466 | 5,313,467 | Is there a way i can assign the value shown by the date picker widget to a variable of type "Date"? | <p>I'm creating an app for the android OS that allows the user to pick a Date. I want to be able to store the date the User picks in a mm/dd/yy form . I know there is a variable type called date. How do i assign the value shown by the picker to the date variable ?</p>
| android | [4] |
824,191 | 824,192 | javascript creating multi-dimensional array syntax | <p>Today I've heard that it's possible to create a multi - dimensional array in js using this syntax:</p>
<pre><code>var a = new Array(3,3);
a[2][2] = 2;
alert(a[2][2])
</code></pre>
<p>However this doesn't work in opera. Am I wrong somewhere?</p>
| javascript | [3] |
1,011,035 | 1,011,036 | How to unit test an helper function that use HTTPConnection | <p>I have written a <strong>helper function</strong> that can retrieve content from a url. This function can also parse a <code>Map</code> of parameters and feed a url or a body on request depending on <code>GET</code> or <code>POST</code> method. Let's say this function also do other things (change headers, cookies etc...). How can I test this function against an http(s) server ? How to simulate a fake servlet that will answer to the request made by this function ?
I've seen that we can use mock object, or other library that are specialized in servlet unit testing. But it doesn't seem to fit my needs as I trully need to test the request and its answer without changing the function content.</p>
| java | [1] |
3,869,552 | 3,869,553 | Check the dates in JavaScript | <p>I want to check two dates in java script. date format is YYYY-MM-dd.</p>
<pre><code>var date1 = 2011-9-2;
var date1 = 2011-17-06;
</code></pre>
<p>Can anybody say how can I write condition?</p>
| javascript | [3] |
2,652,245 | 2,652,246 | looping through php array | <p>Can someone explain the logic behind this for loop... I just don't get it on how it goes into the next element, that <code>$from[$i]</code>, what is it doing? </p>
<pre><code>$start = 2;
$path = array();
for (; $i != $start; $i = $from[$i])
$path[] = $i;
</code></pre>
| php | [2] |
1,039,338 | 1,039,339 | how can I read the document using php and store database in mysql with linux? | <p>How can I read a Word document using PHP and store it in a MySQL database on Linux?</p>
<p>I'm using Ubuntu and PHP5.</p>
| php | [2] |
3,799,491 | 3,799,492 | Using the HTTP Accept Header from JavaScript | <ul>
<li>I have a web service that performs a database search. It accepts both GET and POST requests, and can return data in either JSON, CSV, or HTML format based on the HTTP <code>Accept</code> header.</li>
<li>I have a web page that makes an Ajax request to this web service, and displays the search results.</li>
<li>I have been asked to add a button to this page that will allow the user to save the data in CSV format.</li>
</ul>
<p>Earlier this year, someone was <a href="http://stackoverflow.com/questions/2515162/need-to-save-html-table-to-csv-using-javascript">in the same boat</a>, and got the response</p>
<blockquote>
<p>You cannot do it using javascript
capabilities, since javascript has no
permission to write on client machine,
instead you can send request to server
to create csv file and send it back to
client.</p>
</blockquote>
<p>So I added a button that does</p>
<p><code>window.open("MyWebService.cgi?" + theSameQueryStringIPassedInTheAjaxCall)</code>,</p>
<p>which opens the HTML version in a new browser tab. I want the CSV version. Is there a way I could pass an <code>Accept: text/csv</code> HTTP header? (I know how to do it with XMLHttpRequest and setRequestHeader, but that doesn't help me.)</p>
| javascript | [3] |
1,104,955 | 1,104,956 | How really 'import' works in Python? | <p>I can't wrap my head around how 'import' statement works in Python. </p>
<p>It is said to search for the packages in directories returned by <code>sys.path()</code>. However, even if <code>sys</code> module is <em>available</em> automatically in every Python program it's not <em>imported</em> automatically. So does <code>import</code> statement import <code>sys</code> module under the hood?</p>
| python | [7] |
5,606,779 | 5,606,780 | Webservice error 401 returned from webservice called from javascript | <p>I am having a wsdl file in my application server along with swf and javascript.
We call a javascript method and from Javascript we call webservice using soap. The http request has been sent with credentials. It works fine and we get data for a while and after sometimes it returns 401 error. When we use different valid credentials. it works fine. Any one help me what went wrong</p>
| javascript | [3] |
4,101,264 | 4,101,265 | Implementation of PUSH Technology in IPhone OS | <p>I had to make use of PUSH TEchnology in my IPhone app. I am very new to this. Can any one suggest me how to start up the things. I would be very thankful if i can get some sample codes for reference. Thanks in advance... </p>
| iphone | [8] |
3,391,141 | 3,391,142 | Is this an ok use of the comma operator | <p>I've seen other posts in stackoverflow that highly discourage overloading of the comma operator. I was sent a github pull request with comma operator overload, that looked something like the following</p>
<pre><code>class Mylogger {
public:
template <typename T>
Mylogger & operator,(const T & val) {
std::cout << val;
return * this;
}
};
#define Log(level,args...) \
do { Mylogger logv; logv,level, ":", ##args; } while (0)
</code></pre>
<p>then you can use it as follows:</p>
<pre><code> Log(2, "INFO: setting variable \", 1, "\"\n");
</code></pre>
<p>Can someone explain why this is a good or bad usage case? </p>
| c++ | [6] |
4,671,058 | 4,671,059 | android edittext | <p>I have one edittext
EditText et1=(EditText)findViewById(R.id.EditText01);</p>
<p>when i want to clear edittext i use et1.setText("");
but if i have to clear edittext one by one character from the last
for this i have no solution can u pls give me solution</p>
| android | [4] |
3,397,113 | 3,397,114 | How to avoid "ls: write error: Broken pipe" with php exec | <p>I'm having an error that causes me a very big waste of time. This is the line:</p>
<pre><code> exec ("ls -U ".$folder." |head -1000", $ls_u);
</code></pre>
<p>This command runned on my shell needs less than a second, launched by php (direct from console, not throw apache) needs more than 15 seconds and I get this error:</p>
<p>ls: write error: Broken pipe</p>
<p>In the directory where is performing this action has more than 4.5M files, for this reason I use ls -U | head -1000 of course if the | fails it needs to list 4.5M files, besides than do just 1K.</p>
<p>Where is the error? Or using pipes in php exec is not a good idea?!</p>
<p>Thanks</p>
| php | [2] |
830,764 | 830,765 | AspxGridView visiblerowcount | <p>I have one nested aspxgridview in aspxpagecontrol. When I click on some button I want to get number of rows in grid. That's ok. But When I use filter and get no rows in grid, click on some button, I'm still getting 1000 rows, but no row is visible.</p>
<p>I don't know, where is the problem :/</p>
<p>Thanks.</p>
| asp.net | [9] |
3,439,822 | 3,439,823 | get the value undefine on onkeyup when used setTimeout function | <p>i have call function on onkeyup event of textbox which pass the data using ajax.below is sample code of my function which in .js file.</p>
<pre><code>var timeout;
function testfont(id,image)
{
alert('image');//when alert here it shows value
clearTimeout(timeout);
timeout = setTimeout( function()
{
if(image.match(/_small/g))
{
var image = image.replace('_small','');
} else {
var image = image;
}
alert('image'); //when alert here it show undefined
}, 500);
}
</code></pre>
<p>But the problem is that i get the image value undefined inside setTimeout function.it works perfectly without use of setTimeout but i need setTimeout function for event fire after some time.</p>
<p>how can i resolve this?</p>
| javascript | [3] |
3,734,224 | 3,734,225 | Error in Thread Resuming after it is put to sleep | <p>Hello i am having a problem with resuming a thread my code is </p>
<pre><code> public boolean Wait(String Reply){
if (Reply.equalsIgnoreCase("Y")){
try {
t.resume();
}
catch (Exception e){
System.out.println("\n" + "The exception in resume thread method:::: " + e);
}
System.out.println("\n" + "In the Wait Function of Sender");
return true;
}
JOptionPane.showMessageDialog(j ,
"Please Wait While The User Accpets the Trasmission ",
"",
JOptionPane.INFORMATION_MESSAGE);
try{
t = new Thread(this);
t.sleep(100000);
}
catch (InterruptedException ie){
System.out.println(ie.getMessage());
}
return false;
}
</code></pre>
<p>I might explain you how it works as it will help u determine the problem.
First the thread is put to sleep......Then i call this <code>public boolean Wait()</code> function from another function named <code>ReplyYes</code> which passes the value "Y" and i then try to resume the thread but the <code>t.resume()</code> function call, instead of resuming the thread gives me a <code>Java.Lang.Null.PointerException</code> and the thread isn't resumed resulting in returning a FALSE value. Plus because of this thread i can't even Stop my Service i have to wait for the thread to timeOut.</p>
<p>Can anyone explain how to make it work correctly!!
Thank you</p>
| java | [1] |
343,504 | 343,505 | How to get the name of calling activity? | <p>I want to retrive the name of the calling activity for checking some conditions.. What will be the solution?</p>
| android | [4] |
5,818,903 | 5,818,904 | Getting position number from an array | <p>If I have the following array in session, can I get a item position number in each [cat]:</p>
<pre><code>Array
(
[0] => stdClass Object
(
[id] => 1
[cat] => 1
[que] => Description here.
)
[1] => stdClass Object
(
[id] => 2
[cat] => 1
[que] => Description here.
)
[2] => stdClass Object
(
[id] => 3
[cat] => 1
[que] => Description here.
)
)
</code></pre>
<p>For example the following will give me the second description, but how do I get that it has position #2 (out of 3) in [cat] == 1:</p>
<pre><code>$item = $_SESSION['questions'][2]->que;
</code></pre>
<p>The actual array is much larger and has more than 1 [cat]. The count I am trying to get is withing each such group.</p>
| php | [2] |
4,812,537 | 4,812,538 | Error: "missing } in XML expression" | <p>my date time picker JavaScript giving the following error ...please resolve my problem
following is my code</p>
<p>// JavaScript File</p>
<pre><code>function SetDate(dateValue) {
// retrieve from the querystring the value of the Ctl param,
// that is the name of the input control on the parent form
// that the user want to set with the clicked date
ctl = window.location.search.substr(1).substring(4);
// set the value of that control with the passed date
thisForm = window.opener.document.forms[0].elements[ctl].value = dateValue;
// close this popup
self.close();
}
</code></pre>
<p>In Mozilla error console it gives the following error please have a glance on it.</p>
<blockquote>
<p>Error: missing } in XML expression<br>
Source File: <a href="http://localhost:1046/PlacementManager/Scripts/DatePicker.js" rel="nofollow">http://localhost:1046/PlacementManager/Scripts/DatePicker.js</a>
Line: 8, Column: 57<br>
Source Code:
ctl = window.location.search.substr(1).substring(4); </p>
</blockquote>
| javascript | [3] |
3,167,764 | 3,167,765 | Basic auth (like apache's .htaccess) using php, how? | <p>How can I implement basic auth using php? Is it possible?</p>
<p>Thank you</p>
| php | [2] |
2,015,515 | 2,015,516 | Does List and dictionary in python have a limited capacity ? if yes,how much is it? | <p>Does List and dictionary in python have a limited capacity ? if yes,how much is it ?</p>
| python | [7] |
4,573,582 | 4,573,583 | How can I create a notification which pops up on home screen at a regular time? | <p>I want to create a notification system which popsup on home screen and a text is shown. If we click on the notification the app is shown on the foreground. This notification must be poped at a given time period.Is this possible help plz?</p>
| android | [4] |
3,331,801 | 3,331,802 | How well is insertAdjacentHTML supported? | <p>I recently discovered the <code>insertAdjacentHTML</code> method and it's a god-send. Being such I wanted to know how well this method is supported. Does IE have it? What about Chrome?</p>
| javascript | [3] |
2,642,869 | 2,642,870 | How to strip this part of my string? | <pre><code> $string = "Hot_Chicks_call_me_at_123456789";
</code></pre>
<p>How can I strip away so that I only have the numberst after the last letter in the string above?</p>
<p>Example, I need a way to check a string and remove everything in front of (the last UNDERSCORE FOLLOWED by the NUMBERS)</p>
<p>Any smart solutions for this?</p>
<p>Thanks</p>
<p>BTW, it's PHP!</p>
| php | [2] |
4,886,051 | 4,886,052 | How to insert page loading code on my aspx page? | <p>I prepared a ASP.NET web site. But it contains lots of flash controls. When you enter the page, some flash controls can't load but page is opening.So flash parts are shown not well.</p>
<p>To solve this problem, I want to add a page loading code on the aspx page.An image or a gift is illustreted until the page fully loaded.</p>
<p>Please, give me a code but I can't know how I add the code to aspx page, so I need some instructions as well.</p>
| asp.net | [9] |
919,221 | 919,222 | How to remove black border from AlertDialog builder | <p>Actually i have created an custom dialog using AlertDialog.builder.In this dialog i am not displaying the titile.All works fine but there is an black border appear in the dialog.so can anyone tell me how can i remove this black boder.The code and screenshot are below.</p>
<p><strong>code in java:</strong></p>
<pre><code> AlertDialog.Builder start_dialog = new AlertDialog.Builder(this);
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog2,
(ViewGroup) findViewById(R.id.layout_root));
layout.setBackgroundResource(R.drawable.img_layover_welcome_bg);
Button btnPositiveError = (Button)layout.findViewById(R.id.btn_error_positive);
btnPositiveError.setTypeface(m_facedesc);
start_dialog.setView(layout);
final AlertDialog alert = start_dialog.create();
alert.show();
btnPositiveError.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
alert.dismiss();
}
});
</code></pre>
<p><strong>ScrrenShot</strong></p>
<p><img src="http://i.stack.imgur.com/ZxPWr.png" alt="enter image description here"></p>
| android | [4] |
1,231,458 | 1,231,459 | scandir outside web tree using PHP5 | <p>I'm looking for a way to get directory listing for files that are outside the webserver's tree, for example i want to list all files and folders under '/home' directory and put them in an array (just as scandir does).</p>
<p>I can 'sudo su' to a user that has rights to check the directory content but i don't know how to convert a directory listing that i could get from a </p>
<pre><code>exec ('ls -la /home');
</code></pre>
<p>Or maybe with a bash script ?</p>
| php | [2] |
6,033,416 | 6,033,417 | using only one button to play and pause a Mediaplayer in Android | <p>I am new to Android, my requirement is to use only one button for playing and pause using media player class?</p>
| android | [4] |
2,085,819 | 2,085,820 | looping through fusiontable results | <p>I would like to read some data from a GoogleFusion table and then use the results, being new to javascript, I would like to understand how to expose the results so that I can use it globally, here is what I have so far:</p>
<pre><code><!DOCTYPE html>
<meta charset="utf-8">
<head>
<script src="http://ft2json.appspot.com/api/ft2json.js" type="text/javascript"></script>
<script type="text/javascript">
var results = ft2json.query(
'SELECT * FROM 1j1kKW9s9CrtZ6_o6MdC-xb0YNWb73rQQYENmzQ', /* Fusion Tables query. */
function(result) {
/* Callback function. */
console.log(result);
},
{
/* Optional parameters. */
start : 25,
limit : 50
}
);
console.log('data', results);
</script>
</head>
<body>
</body>
</html>
</code></pre>
<p>The first <code>console.log</code> returns the Object, but the second <code>console.log('data', results);</code> returns <code>Undefined</code>.</p>
<p>In the Chrome console the <code>console.log('data', results);</code> is read first, which I don't understand why?</p>
| javascript | [3] |
679,274 | 679,275 | jquery display floating div | <p>When the user hovers over a specific element, I wish to display a div (up and to the right) that they can click to popup a dialog. The div would appear almost like a tooltip. The div would disappear when they hover away.</p>
| jquery | [5] |
1,555,820 | 1,555,821 | get height of a div and set the height of another div using it | <p>I have two divs, neither have a height set in css, as I want to take whatever height they end up as and set the other div to be that height.</p>
<p>The javascript I have is this</p>
<pre><code>function fixHeight() {
var divh = document.getElementById('prCol1').height;
document.getElementById('prCol1').innerHTML = '<ul><li>' + divh + '</li></ul>';
document.getElementById('prCol2').style.height = divh + 'px';
}
</code></pre>
<p>I have the following line of code just to see if I am getting some kind of actual response.</p>
<pre><code>document.getElementById('prCol1').innerHTML = '<ul><li>' + divh + '</li></ul>';
</code></pre>
<p>I have a onload set to run the function</p>
<p>my two divs look like this</p>
<pre><code><div id="prCol1">
..content..
</div>
<div id="prCol2" class="slideshow">
..content..
</div>
</code></pre>
| javascript | [3] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.