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,127,233
1,127,234
Module pattern | Private access to passed in reference
<p>Suppose I have someFunction() that has a public prototype function giveMeAccess() available to the user. </p> <p>Now suppose I want this prototype method to have access to Private variables inside the function that returned it..</p> <p>Is there any way to do this?</p> <p>Yes this has an application as strange as it might seem. I need this info. to model a class hierarchy.</p> <pre><code>var privateMaker = function ( give_me_access ) { var Private = {}, someFunction = function(){}; someFunction.prototype = { public_access: give_me_access }; return someFunction; } </code></pre> <p><strong>Use</strong></p> <pre><code>var Func1 = new privateMaker(); var private_loot = Func1.public_access(); </code></pre> <p><strong>Question</strong></p> <p>How do I give giveMeAccess() access to Private inside of privateMaker()? </p> <p>Note the prototype function is passed in to the outer function instead of defined in the function as usual. This is the weird caveat.</p> <p>If this is impossible with this model...then state that as an answer.</p>
javascript
[3]
5,301,142
5,301,143
Javascript to image cycle
<p>Simple request, but I don't know how to do it. I've got a series of 10 images (image0.gif, image1.gif image2.gif etc...) that need to change to the next image in the sequence (cycling around after 9) when another image is pressed. This is what I have so far...</p> <pre><code> &lt;html&gt; &lt;head&gt;&lt;/head&gt; &lt;body bgcolor="#808080"&gt; &lt;script type="text/javascript"&gt; var c = 0; function preload(img) { var a = new Image(); a.src = img; return a; } if (needed) { time0 = preload("image0.gif"); time1 = preload("image1.gif"); time2 = preload("image2.gif"); time3 = preload("image3.gif"); time4 = preload("image4.gif"); time5 = preload("image5.gif"); time6 = preload("image6.gif"); time7 = preload("image7.gif"); time8 = preload("image8.gif"); time9 = preload("image9.gif"); } function clickme() { // update image c += 1; // alert(c) } &lt;/script&gt; &lt;div align="center"&gt; &lt;center&gt; &lt;img src="images/image0.gif" width="20" height="55" name="time0"&gt; &lt;a href="#" onMouseDown="return clickme()"&gt; &lt;img src="images/button.gif" border="0" width="96" height="55"&gt; &lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/center&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
2,836,827
2,836,828
Create waveform of audio file in android
<p>I want to create the wave forms of audio file in android. Can anyone provide me an example source code?</p>
android
[4]
5,862,065
5,862,066
Input (Scanner) variable in while loop
<p>Im trying to make the program to ask for a percentage (grade) but I want it to ask again after the user has made the first input and has seen the output. I'm having trouble with the loop because the variable myMark is no assigned. </p> <pre><code>import java.util.Scanner; public class passFail{ public static void main(String[] args){ Scanner result = new Scanner(System.in); int myMark = 0; while(myMark &gt;=0 &amp;&amp; myMark &lt;=100){ System.out.println("Please enter the percentage you have received:"); myMark = result.nextInt(); if(myMark &lt;=49 &amp;&amp; myMark &gt;=0){ System.out.println("You have failed!"); } else if(myMark &lt;=59 &amp;&amp; myMark &gt;=50){ System.out.println("You have passed!"); } else if(myMark &lt;=69 &amp;&amp; myMark &gt;=60){ System.out.println("You have received a Credit"); } else if(myMark &lt;=79 &amp;&amp; myMark &gt;=70){ System.out.println("You have received a Distinction!"); } else if(myMark &lt;=100 &amp;&amp; myMark &gt;=80){ System.out.println("You have received a High Distinction"); } else{ System.out.println("Please enter a whole number"); } } } } </code></pre>
java
[1]
4,740,500
4,740,501
Is it possible to populate an ICredentials object with the current user context?
<p>I need to call a webdav function, and this requires credentials. The user that the rest of the c# code runs under has access to this external website where the webdav function executes. </p> <p>How can I pass the executing users credentials through to the webdav function without manually specifying the username + password. </p> <p>My code looks something like this:</p> <pre><code>var request = (HttpWebRequest)WebRequest.Create(folderAddress); request.Credentials = credentials;// here I need the transform; request.Method = "MKCOL"; response = (HttpWebResponse)request.GetResponse(); response.Close(); </code></pre> <p>Thanks in advance</p> <p>EDIT: from my understanding System.Net.CredentialCache.DefaultCredentials gets the currently logged on user (correct me if I'm wrong), but the currently logged on user isn't the same as the user account that runs this service. </p>
c#
[0]
2,190,360
2,190,361
Empty "using" statement in Dispose
<p>Recently I've seen some code written as follows:</p> <pre><code>public void Dipose() { using(_myDisposableField) { } } </code></pre> <p>This seems pretty strange to me, I'd prefer to see <code>myDisposableField.Dispose();</code></p> <p>What reasons are there for using "using" to dispose your objects over explicitly making the call?</p>
c#
[0]
3,067,475
3,067,476
Multiple setTimeout functions but that goes off with different times
<pre><code>switch (e.keyCode) { case 32: $("#Main").prepend('&lt;div class="Bomb" style="absolute; top:' + position.top + 'px; left: '+ position.left +'px;"&gt;&lt;/div&gt;'); setTimeout( function(){ var BombPos = $('.Bomb').position(); var BombPosTopb = BombPos.top; var BombPosLeftb = BombPos.left; var BombPosTopt = BombPos.top; var BombPosLeftt = BombPos.left; var BombPosTopl = BombPos.top; var BombPosLeftl = BombPos.left; var BombPosTopr = BombPos.top; var BombPosLeftr = BombPos.left; $(this).remove(); .... More stuff if (CheckRight == false){ $("#Main").prepend('&lt;div class="Effect" style="absolute; top:' + BombPosTopr + 'px; left: '+ BombPosLeftr +'px;"&gt;&lt;/div&gt;'); BombPosLeftr += 30; } }; setTimeout( function(){ $('.Effect').remove(); } , 1000 ); } , 1500 ); </code></pre> <p>My project is called Bomberman and I am trying to spawn multiple Bombs. The problem with this code: I spawn the object, it works &amp; it goes awey without any problem.</p> <p>But when I click multiple times my spacebar and put more than 1 bomb they all disappear <strong>at the same time</strong>.</p> <p>I just want them to have a 'seperate timer' on each of my litle bombs so they go awey after 1-2 seconds when I click on the spacebar and not all at once.</p>
jquery
[5]
3,412,583
3,412,584
Where would I get Microsoft Chart Control sample codes?
<p>Can anyone please tell me where would I get Microsoft Chart Control sample codes ? Link will be sufficient.</p>
asp.net
[9]
4,575,120
4,575,121
jquery got error event change on select element
<p>I got error </p> <blockquote> <p>"Use of attributes' specified attribute is deprecated. It always returns true. return !val || val.specified ? elem.value : elem.text;"</p> </blockquote> <pre><code> $(document).ready(function(){ $("#o_productCategory").change(function(e){ $.getJSON("URI", ({"parent" : $("#o_productCategory").val()}),function(result) { //code here }); }); }); </code></pre>
jquery
[5]
1,424,294
1,424,295
How to start another program without having to wait on it in C++?
<p>How can I make a C++ program start another program/process (C++ specifically) and not wait for it to end? (so <code>system()</code> won't work here because it starts the other program/process as child, right?)</p> <p>I was thinking about starting the second program/process on another thread or something but I'm not sure if that would work.</p> <p>Thanks for the help.</p> <p>Edit: Running linux, sorry for missin that precision... (ubuntu 11.10 to be precise)</p>
c++
[6]
5,533,431
5,533,432
How java import works
<p>I would like to know how the <code>import</code> works. </p> <p>I'm asking this, because I have the following <code>imports</code> in my project</p> <pre><code>import static com.googlecode.javacv.jna.highgui.cvCreateCameraCapture; import static com.googlecode.javacv.jna.highgui.cvGrabFrame; import static com.googlecode.javacv.jna.highgui.cvReleaseCapture; import com.googlecode.javacv.CanvasFrame; import com.googlecode.javacv.FrameGrabber; import com.colorfulwolf.webcamapplet.gui.ImagePanel; import com.googlecode.javacv.OpenCVFrameGrabber; import com.googlecode.javacv.jna.cxcore.IplImage; </code></pre> <p>I don't have in my project these <code>package</code> so, how this will be imported ?</p> <p>If I create a <code>jar</code> file with all my classes, my server where will host this <code>jar</code> file, has to be free internet access to get these <code>package</code> ?</p> <p>I got some problem in my <code>Applet</code> that has these <code>import</code> and I'm asking this question, to understand if can be a internet rule.</p> <p><strong>UPDATE</strong></p> <pre><code>&lt;applet code="com.colorfulwolf.webcamapplet.WebcamApplet" archive="http://san.redenetimoveis.com/teste.jar, http://san.redenetimoveis.com/core.jar, http://san.redenetimoveis.com/javacv.jar, http://san.redenetimoveis.com/javase.jar, http://san.redenetimoveis.com/jna.jar, http://san.redenetimoveis.com/customizer.jar, http://san.redenetimoveis.com/jmf.jar, http://san.redenetimoveis.com/mediaplayer.jar, http://san.redenetimoveis.com/multiplayer.jar, http://san.redenetimoveis.com/sound.jar" height="550" width="550"&gt; &lt;/applet&gt; </code></pre>
java
[1]
3,321,321
3,321,322
AVD Manager - No system image installed for this target
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/13488419/unable-to-create-android-virtual-device">Unable to create Android Virtual Device</a> </p> </blockquote> <p>The CPU/ABI field in Android New AVD popup window shows "No system image installed for this target".</p> <p>How do I fix this?</p>
android
[4]
4,049,294
4,049,295
get mouse coordinates relative to a div position doesn't work in firefox
<p>Why doesn't the example code below work in my browser, firefox v. 19.0.2?</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; #example { position: absolute; top: 20px; left: 50px; width: 300px; height: 300px; background-color: #C00; } &lt;/style&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;script&gt; $("#example").mousemove(function(e) { var xPos = e.pageX - $(this).position().left; var yPos = e.pageY - $(this).position().top; $("#pos").text("x: " + xPos + " / y: " + yPos); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="example"&gt;&lt;/div&gt; &lt;div id="pos"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>I can't see the coordinates that are supposed to be in the <code>&lt;div&gt;</code> tag with ID pos. ThanX in advance for your help.</p>
jquery
[5]
2,083,215
2,083,216
select data from row error
<p>I have some code which selects data from a row. It is working and prints the result correctly, but I have an error I can not figure out.</p> <pre><code>$rs=array(); $select=array ("system_name", "location", "alarmtype", "severity", "start_time", "end_time", "duration", "reason","shift_oparation", "system_oparation"); for ($i=0;$i&lt;=9;$i++){ $SQL = "SELECT (".$select[$i].") FROM (".$is.") WHERE duration=('".$ic."') AND location=('".$id."')"; $result = mysql_query($SQL); $db_field = mysql_fetch_array($result); $rs[$i]=$db_field[$select[$i]]; echo $rs[$i]; } </code></pre> <p>Echo prints correctly, but there is an error:</p> <p><code>Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given.</code></p>
php
[2]
1,783,409
1,783,410
display date in dd.mm.yyyy format in javascript
<p>I have a date like <code>var string = 2013-02-22</code>. I want to convert it into <code>22.02.2013</code>. How can I do it in JavaScript?</p>
javascript
[3]
1,605,624
1,605,625
How to prevent my app from running in the background on the iPhone
<p>Is there any way to cause an app to quit instead of going to background when the home button is pressed? For security reasons, it would be better if the app did not run in background but actually closed when home is pushed. This is <em>not</em> for users' security, but rather for company data on the app, so it is not a user's choice. I could not find any way to quit other than forcing an exit, which Apple discourages.</p>
iphone
[8]
3,568,357
3,568,358
A list of string replacements in Python
<p>Is there a far shorter way to write the following code?</p> <pre><code>my_string = my_string.replace('A', '1') my_string = my_string.replace('B', '2') my_string = my_string.replace('C', '3') my_string = my_string.replace('D', '4') my_string = my_string.replace('E', '5') </code></pre> <p>Note that I don't need those exact values replaced, I'm simply looking for a way to turn 5+ lines into fewer than 5</p>
python
[7]
3,526,784
3,526,785
Asp.net bind datatable to gridview
<p>I know how to bind a simple datatable to a gridview, but this is a different scenario (I think). I am calling a class library dll which returns a class. I can say its kind of list.</p> <p>I will call it like,</p> <pre><code>Dim demo = New ABCDataTable() demo = demo.GetTheDataTable(MyConnectionString) GridView1.DataSource = demo GridView1.DataBind() </code></pre> <p>Question: How do I bind this to gridview in a markup file? Which datasource control I have to use?</p> <p>Update: </p> <p>I used ObjectDataSource and assigned SelectMethod="GetTheDataTable" and used selectparameter to pass connection string. </p> <p>I am assigning connection string in the code behind ObjectDataSource1.SelectParameters["connectionString"].DefaultValue = MyConnectionString;</p> <p>but I am getting an error.</p>
asp.net
[9]
3,869,203
3,869,204
in spinner items display the list array to replace drawable images how can implemented
<p>hi i am using spinner in some application in spinner item list array this text replaced in drawable images how can its implemented</p> <p>p</p> <pre><code>ersonalinformation = (Spinner) findViewById(R.id.SpinnerCategory); ArrayAdapter&lt;?&gt; adapterDefaultpersonal = ArrayAdapter.createFromResource(Animals.this,R.array.Animalinformation, android.R.layout.simple_spinner_item); adapterDefaultpersonal.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); personalinformation.setAdapter(adapterDefaultpersonal); </code></pre> <p>this R.array.Animalinformation array list items replaced in drawable images hopw can implemented please forward some solution i am new in android<br> please forward some suggestion its urgent </p>
android
[4]
4,074,504
4,074,505
Advice on writing to a log file with python
<p>I have some code that will need to write about 20 bytes of data every 10 seconds. I'm on Windows 7 using python 2.7</p> <p>You guys recommend any 'least strain to the os/hard drive' way to do this?</p> <p>I was thinking about opening and closing the same file very 10 seconds:</p> <pre><code>f = open('log_file.txt', 'w') f.write(information) f.close() </code></pre> <p>Or should I keep it open and just <code>flush()</code> the data and not close it as often?</p> <p>What about <code>sqllite</code>? Will it improve performance and be less intensive than the open and close file operations? (Isn't it just a flat file database so == to text file anyways...?)</p> <p>What about <code>mysql</code> (this uses a local server/process.. not sure the specifics on when/how it saves data to hdd) ?</p> <p>I'm just worried about not frying my hard drive and improving the performance on this logging procedure. I will be receiving new log information about every 10 seconds, and this will be going on 24/7 24 hours a day. Your advice?</p> <p>ie: Think about programs like utorrent that require saving large amounts of data on a constant basis for long periods of time, (my log file is significantly less data that those being written in such "downloader type programs" like utorrent)</p> <pre><code>import random import time def get_data(): letters = 'isn\'t the code obvious' data = '' for i in xrange(20): data += random.choice(letters) return data while True: f = open('log_file.txt', 'w') f.write(get_data()) f.close() time.sleep(10) </code></pre> <p>My CPU starts whining after about 15 seconds... (or is that my hdd? )</p>
python
[7]
731,489
731,490
How to make use of i++ operator in a set statement in c#
<p>Is there a special method that you can add if you get an i++ type of operation on a property?</p> <p>Here is an example of what I'm trying to do. I know this don't work, but this gives you an idea of what I'm talking about. Actually, I'm working with two internals and I want to increase one on + and the other on -.</p> <pre><code>int mynum; int yournum { get{ return mynum; } set{ mynum = value; } set++{ mynum = mynum + 5; return mynum; } //this is what I want to do } // elsewhere in the program yournum++; //increases by 5 </code></pre>
c#
[0]
2,992,658
2,992,659
why is there different id syntax in the Android docs?
<p><a href="http://developer.android.com/guide/topics/ui/layout-objects.html" rel="nofollow">This page</a> in the Android documentation defines an element id as follows:</p> <pre><code>&lt;TextView android:id="@+id/label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Type here:" /&gt; </code></pre> <p>However <a href="http://developer.android.com/guide/topics/resources/resources-i18n.html" rel="nofollow">this page</a> defines it as:</p> <pre><code>&lt;EditText id="text" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textColor="@color/opaque_red" android:text="Hello, World!" /&gt; </code></pre> <p>I thought I had a decent understanding of what was going on until I saw this second example. In the first case, you need the + character so that id 'label' is added to the R file, correct? In the second case, would the EditText's id not be added to the R file because it does not contain the + character?</p> <p>Also, the second example does not include the android namespace on the id. Does having or not having the Android namespace affect whether that id will be added to the R file?</p> <p>Thanks for any clarification. </p>
android
[4]
3,392,713
3,392,714
how can I save images to iphone directory and retrieve it?
<p>I want to save image in iphone album and retrieve them on particular index, how can I?</p> <p>I have to save profile of many people, along with their images, so how can I access such concept?</p>
iphone
[8]
3,908,121
3,908,122
How to delete all files but leave directory structure intact?
<p>I want to delete all the files in a folder, and delete all the files in all its sub folders, and sub sub folders, etc, BUT I do not want to delete the folders themselves.</p> <p>What would be the simplest way to do this?</p>
c#
[0]
3,520,636
3,520,637
What is the script in javascript equals to $_SERVER['REQUEST_URI'] in php?
<p>I want to pass a URL to another domain through javascript appending iframe, when exit the iframe, the other domain can return the user to previous page on my site. If use php to submit the exit_url, it is </p> <pre><code>$exit_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "&amp;request=example""; </code></pre> <p>I would like to learn how to convert this string to use in javascript. Thanks!</p>
javascript
[3]
4,414,939
4,414,940
event Action<> vs event EventHandler<>
<p>Is there any different between declaring <code>event Action&lt;&gt;</code> and <code>event EventHandler&lt;&gt;</code>.</p> <p>Assuming it doesn't matter what object actually raised an event.</p> <p>for example:</p> <pre><code>public event Action&lt;bool, int, Blah&gt; DiagnosticsEvent; </code></pre> <p>vs</p> <pre><code>public event EventHandler&lt;DiagnosticsArgs&gt; DiagnosticsEvent; class DiagnosticsArgs : EventArgs { public DiagnosticsArgs(bool b, int i, Blah bl) {...} ... } </code></pre> <p>usage would be almost the same in both cases:</p> <pre><code>obj.DiagnosticsEvent += HandleDiagnosticsEvent; </code></pre> <p>There are several things that I don’t like about <code>event EventHandler&lt;&gt;</code> pattern:</p> <ul> <li>Extra type declaration derived from EventArgs</li> <li>Compulsory passing of object source – often no one cares</li> </ul> <p>More code means more code to maintain without any clear advantage.</p> <p>As a result, I prefer <code>event Action&lt;&gt;</code></p> <p>However, only if there are too many type arguments in Action&lt;>, then an extra class would be required.</p>
c#
[0]
172,241
172,242
java quick application
<p>I want to create a database application using Java, currently I am using Netbeans and I am building everything from scratch, so I am reinventing the wheel.<br> Is there is any tools to use that help me to create a quick forms similar to Oracle forms?<br> I think Oracle ADF may be helpful but many articles and friends advised me to avoid using Jdeveloper. Does anyone have any idea what I should do to create Forms for users to input and query data for Desktop applications or Web applications quickly ?</p>
java
[1]
1,450,449
1,450,450
Hiding shopping cart when hovering away from both cart and the tab that opened it
<p>I implemented a shopping cart using two divs. A 'cart' div that contains the cart image and 'cart_items' div containing cart items. I can make cart_items slideDown when clicking on the cart image. I can hide cart_items when hovering it then leaving it, the problems I have are:</p> <ol> <li>I can not hide cart_items when clicking the cart then mouseleaving it without entering cart_items.</li> <li>I can not hover over both, cart and cart_items without preventing cart_items from hiding.</li> </ol> <p>cart and cart_items are in two adjacent divs.</p> <p>HTML</p> <pre><code>&lt;div id='header'&gt; &lt;div id='cart'&gt;&lt;img src='cart.png'&gt;&lt;/div&gt; &lt;/div&gt; &lt;div id='container'&gt; &lt;div id='cart_items'&gt; contain items that will be pulled from database &lt;/div&gt; &lt;/div&gt; </code></pre> <p>jQuery</p> <pre><code> $('#cart').click(function(){ $('#cart_items').slideDown("300"); }); $('#cart_items').mouseleave(function(){ $('#cart_items').hide(); }); </code></pre> <p>I did lots of online search and I added many jQuery mouseenter and mouseleave to both divs but somehow the events were cancelling each other.</p>
jquery
[5]
5,210,881
5,210,882
forse close when click button for open google map
<p>in my app when i click the button it opens a Google map it is running well when i open it in android emulator and when i install this application on my device after making .apk folder it install successful and also other functions are going well but when i click button of open Google map it force close.. <strong>is api key should be registered for using in mobile???</strong></p> <p>my manifest file are given beow</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.androidpeople.tab" android:versionCode="1" android:versionName="1.0"&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable= "true"&gt; &lt;uses-library android:name="com.google.android.maps" /&gt; &lt;activity android:name=".SplashScreen" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; </code></pre> <p> </p>
android
[4]
5,301,146
5,301,147
HTML not showing up on browser
<p>I am writing a code in which the user is asked for username and password. If the details provided match the details in the database, then he is displayed the data, else he is prompted with a message that the information provided is not valid. Here is the part of the code that says information is not valid,</p> <pre><code>&lt;?php if($user!=$username &amp;&amp; $pass!=$password) { ?&gt; &lt;p id="intro"&gt;Invalid Information&lt;/p&gt; &lt;?php } ?&gt; </code></pre> <p>But the problem I am facing is that even if the username and password does not match, the message Invalid Information is not displayed. Please help out. Thanks</p>
php
[2]
495,211
495,212
still didnt get @android:id/list vs @+id/listView1
<p>when extending listactivity it is must to have a @android:id/list</p> <p>question 1> what if i want to implement 2 listviews then ids will be same @android:id/list.</p> <p>question 2> in what scenario i should use @+id/listView1. </p> <p>Thanks in advance. </p>
android
[4]
4,879,717
4,879,718
Formatting Output to Currency
<p>I need to format Gtotals output to currency how can I accomplish this. I just grabbed a quick snippet from my code it is not in order.</p> <pre><code> string Lname, Fname, Depart, Stat, Sex, Salary, cDept, cStat, cSex; double Gtotal; fields = recordIn.Split(DELIM); Lname = fields[0]; Fname = fields[1]; Depart = fields[2]; Stat = fields[3]; Sex = fields[4]; Salary = fields[5]; Fname = fields[1].TrimStart(null); Depart = fields[2].TrimStart(null); Stat = fields[3].TrimStart(null); Sex = fields[4].TrimStart(null); Salary = fields[5].TrimStart(null); Gtotal = double.Parse(Salary); //convert this to currency? ie. $56,000 </code></pre>
c#
[0]
2,658,014
2,658,015
Secure static html files using IIS7 in integrated mode and using custom httphandler
<p>My asp.net application is not using formsauthentication. Instead we make a call to database, check username//password and save the value in session if user is logged in.</p> <p>Now i need to secure my html files. I put IIS7 in integrated mode and added a handler mapping to a statichtmlhandler that i wrote that basically checks that if the request url contains .html and session("userloggedin") is not null then do nothing else redirect to login page.</p> <p>This works fine. Only problem is my html files show up as blank. How to fix it?</p>
asp.net
[9]
2,383,939
2,383,940
Dynamically create controls in thread in WPF
<p>In my WPF form i have button Control when i click that button Dynamically tabcontroll is added in the form inside that tab control one page is there. On that page many data are there .so the tabcontrol take time to load in the form.</p> <p>I want to show the tab control first then i want to add the page in the tab. Is it Possible with the help of background worker or any other thread.</p>
c#
[0]
1,018,819
1,018,820
How to add another page ID in a PHP function - newbie asking?
<p>I need some help to see where I am going wrong. </p> <p>I am trying to add a page ID to this original function:</p> <pre><code>&lt;?php if( $post-&gt;ID != '91' ) { get_sidebar(); } ?&gt; &gt; </code></pre> <p>to also exclude the ID 1267. I am trying this, with no success. </p> <pre><code>&lt;?php $pageIDs_to_exclude=array("91","1267"); if( $post-&gt;ID != $pageIDs_to_exclude ) { get_sidebar(); } ?&gt; </code></pre> <p>Surely there must be a better way of doing this? Or what am I missing? Thnaks for any help /Anders</p>
php
[2]
3,037,907
3,037,908
How I can monitor all Internet requests?
<p>Is there any way to monitor all requested URLs using the .NET framework classes?</p>
c#
[0]
2,519,192
2,519,193
How to count online users on a website
<blockquote> <p><strong>Possible Duplicates:</strong><br> <a href="http://stackoverflow.com/questions/568835/script-to-tell-me-who-and-how-many-users-are-online">script to tell me who, and how many users, are online</a><br> <a href="http://stackoverflow.com/questions/1822921/best-way-to-keep-track-of-current-online-users">Best way to keep track of current online users</a> </p> </blockquote> <p>How should I count the people online on a PHP website at a given time, if they don't have to be logged-in?</p>
php
[2]
4,073,637
4,073,638
Where'd padding go, when setting background Drawable?
<p>I have this issue on my <code>EditText</code> and <code>Button</code> views, where I have a nice padding for them to space away from the text, but when I change the background with <code>setBackgroundDrawable</code> or <code>setBackgroundResource</code> that padding is lost forever.</p>
android
[4]
1,906,035
1,906,036
Converting Microsoft Office documents and PDF documents to image file with Java
<p>In my current project, I need to convert Microsoft Office documents and PDF documents to image file with Java. Is there any open source Java library for that. And if so, which is the most reliable? </p>
java
[1]
4,243,064
4,243,065
ObjectStore in C#
<p>Is there an ObjectStore implmentation for csharp that allows be to generate string handles for my own objects, lookup these objects later on on from the string handle. I can see there are implementations for C++, but in dotnet we have a garbage collector! Lars</p>
c#
[0]
1,496,074
1,496,075
Java BufferedImage increase width
<p>I have managed to load in an image using:</p> <pre><code>BufferedImage image = ImageIO.read(out); </code></pre> <p>and place text over it however, I want the text to appear next to the image. How can I increase the image width on the right to allow for space for the text to be drawn on. Or do I have to create a new empty image and insert the existing one?</p> <p>Thanks</p>
java
[1]
5,394,135
5,394,136
WebView also Gone when Sreen Time-Out
<p>I would like to find a solution to allow my WebView still alive when screen time-out.</p> <p>I am program to play music using WebView, it's working very properly if the screen alive but when the screen time-out my music in WebView also GONE.</p> <h1>Here is my code:</h1> <pre><code>public class WebViewActivity extends Activity { WebView mWebView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.playlist); mWebView = (WebView) findViewById(R.id.webView1); mWebView.setWebViewClient(new HelloWebViewClient()); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setPluginsEnabled(true); mWebView.getSettings().setAllowFileAccess(true); mWebView.loadUrl("http://mp3skull.com/usher.html"); } private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) &amp;&amp; mWebView.canGoBack()) { mWebView.goBack(); return true; } return super.onKeyDown(keyCode, event); } @Override public void onPause() { mWebView.setVisibility(View.GONE); mWebView.destroy(); super.onPause(); } } </code></pre> <p>I am very shy to tell you that i tried to find this solution over a week but still can't done :(.</p> <p>Hope you give me solution on this matter.</p> <p>Thanks you.</p>
android
[4]
3,686,042
3,686,043
iPhone nslog "EXC_BAD_ACCESS"
<p>Im trying to use the NSLog, to print console messages. The problem is sometimes i receive a "EXC_BAD_ACCESS" error when calling it</p> <pre><code>-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { NSLog(@"Working test %d", toInterfaceOrientation); NSLog(@"EXC_BAD_ACCESS %@", toInterfaceOrientation); } </code></pre> <p>Here i simply want to see what the arguments passed into the function contain. The first NSLog works fine. The second causes an "EXC_BAD_ACCESS" and i dont understand why?.</p>
iphone
[8]
5,868,163
5,868,164
jquery callback not working
<p>Can anyone tell me what I'm doing wrong in this jquery script? </p> <pre><code>$(document).ready(function() { $("a.book").click(function() { $(this).parent().next('div').slideToggle('slow', function(){ $(this).toggleClass('bookopen'); }); }); }); </code></pre> <p>I want the div to toggle, and then afterwards I want the element <code>$a.book</code> to change to <code>$a.bookopen</code>. But when I write the code above the toggle doesn't work. If I remove the callback function <code>toggleClass</code> the the <code>slideToggle</code> works just fine. </p> <p>Any ideas? I appreciate your help.</p>
jquery
[5]
4,624,899
4,624,900
Getting a value from a list
<p>I have a list like that:</p> <pre><code>&lt;select size="1"&gt; &lt;option value="1"&gt;Option 1&lt;/option&gt; &lt;option value="2"&gt;Option 2&lt;/option&gt; &lt;option value="3"&gt;Option 3&lt;/option&gt; &lt;option value="4"&gt;Option 4&lt;/option&gt; &lt;option value="5"&gt;Option 5&lt;/option&gt; &lt;/select&gt; </code></pre> <p>How can I get the value of this options with JavaScript (Getting the "1", "2", "3" and so on...).</p>
javascript
[3]
3,916,608
3,916,609
Displaying image from server in android
<p>I want to display an image from server. Actaully I need to display a paragraph and along with that an image. I have chosen a list view for this. At present I am displaying the paragraph but when I am trying to display the image it is not working. Help me regarding this...</p> <p>My Code:</p> <pre><code>private class ListAdapter extends ArrayAdapter&lt;UserBO&gt; { -- -- -- -- public View getView(int position, View convertView, ViewGroup parent) { View view = convertView; try { if (view == null) { LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = vi.inflate(R.layout.list_item, null); // --CloneChangeRequired(list_item) } final UserBO listItem = mList.get(position); // --CloneChangeRequired if (listItem != null) { -- -- -- -- imageUrl = "http://server.com//folder/"+ array.get(0); ((TextView) view.findViewById(R.id.description)) .setText(listItem.getdesc())); downloadFile(imageUrl); ---- -- } } } } void downloadFile(String fileUrl) { URL myFileUrl = null; try { myFileUrl = new URL(fileUrl); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { HttpURLConnection conn = (HttpURLConnection) myFileUrl .openConnection(); conn.setDoInput(true); conn.connect(); int length = conn.getContentLength(); InputStream is = conn.getInputStream(); bmImg = BitmapFactory.decodeStream(is); imView.setImageBitmap(bmImg); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre>
android
[4]
1,204,962
1,204,963
I need role base website security with php
<p>I created one please delete this question;</p>
php
[2]
1,118,432
1,118,433
How can a code in a library project call code in the application project?
<p>In an effort to reduce duplication, I have my app's workspace split into 3 projects:</p> <ul> <li>Main (A library project, where all of the common code lives)</li> <li>Free (To make the free version)</li> <li>Paid (To make the paid version)</li> </ul> <p>Behavior in the free version and the paid version must differ sometimes. How can I "call into" the final projects from the library project?</p> <p>Here is some sample psuedo-code to illustrate my question:</p> <h2>In the Main project:</h2> <pre><code>private void makeADecision() { if (AppCode.isPaid()) { // do one thing } else { // do something else } } </code></pre> <h2>In the Free project:</h2> <pre><code>public class AppCode { public static bool isPaid() { return false; } } </code></pre> <h2>In the Paid project:</h2> <pre><code>public class AppCode { public static bool isPaid() { return true; } } </code></pre> <p>That is basically what I have tried, but it won't compile because the Main project doesn't know about the AppCode class.</p> <p>Bear in mind that this is only an example, so try not to focus on how an app can tell if it is the paid version or not. :) So far the best solution I have found is to put a string in the resources of all three projects and then make a decision based on its value but I don't like that method. Besides being ugly, I would prefer to keep functionality where it belongs. That way I can prevent "paid-only" functionality from being compiled into the free version at all and I can avoid having to include any "free-only" code in the paid version.</p>
android
[4]
5,421,800
5,421,801
how to use Obtion menu in two class
<p>Hi i have Use Menu in 2 class this is my Menu code:</p> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:id="@+id/setting" android:icon="@drawable/ic_seting" android:title="Setting"&gt; &lt;/item&gt; &lt;/menu&gt; </code></pre> <p>in class A i have use this </p> <pre><code>@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.options, menu); return true; } public boolean onCreateOptionsMenu(MenuItem item) { // TODO Auto-generated method stub switch (item.getItemId()) { case R.id.SavedList: Intent intent = new Intent( A.this, SetPreference.class); startActivity(intent); return true; } return true; } </code></pre> <p>and in class b i have use </p> <pre><code>@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater menuInflater = getMenuInflater(); menuInflater.inflate(R.menu.options, menu); return true; } public boolean onCreateOptionsMenu(MenuItem item) { // TODO Auto-generated method stub switch (item.getItemId()) { case R.id.SavedList: Intent intent = new Intent( b.this, SetPreference.class); startActivity(intent); return true; } return true; } </code></pre> <p>in one class b its working fine but in class its not working please tell me where i m doing wrong please help me i am new n android </p>
android
[4]
3,226,080
3,226,081
Why does negating a static member variable produce a linker error?
<p>Please consider the following mini example</p> <pre><code>// CFoo.hpp class CFoo{ private: static const double VPI = 0.5; public: double getVpi(); }; // CFoo.cpp #include "CFoo.hpp" double CFoo::getVpi(){ double x = -VPI; return x; } // main.cpp #include "CFoo.hpp" int main(){ CFoo aFoo(); return 0; } </code></pre> <p>Lining the program with gcc version 4.5.1 produces the error <code>CFoo.cpp: undefined reference to CFoo::VPI</code>. The error dose <strong>not</strong> occur if</p> <ul> <li>VPI is not negated</li> <li>the negation is written as <code>double x = -1 * VPI;</code></li> <li>Declaration and definition of class CFoo happen in the same file</li> </ul> <p>Do you know the reason for this error?</p>
c++
[6]
1,007,546
1,007,547
Start an Activity via Email?
<p>I want in my application the client to send an email which contains coordinates and other information and when the email is received by someone starts an activity in his device which will use this coordinates.Is this possible or I have to use something else?Thanks in Advance!</p>
android
[4]
5,296,420
5,296,421
How to make a power method without for loops or recursion?
<p>I'm thinking of a method that calculates the power (base 10 only) of an integer which will be passed as an argument but without using for loops or recursion:</p> <p>here's the method in it's simplest form using forr loop:</p> <pre><code> static long power(int val) { long y = 10l; if (val == 1) { return y; } else { for (int x = 0; x &lt; val - 1; x++) { y *= 10; } return y; } } </code></pre>
java
[1]
4,465,559
4,465,560
Problems title-casing a string in Python
<p>I have a name as a string, in this example "markus johansson".</p> <p>I'm trying to code a program that makes 'm' and 'j' uppercase:</p> <pre><code>name = "markus johansson" for i in range(1, len(name)): if name[0] == 'm': name[0] = "M" if name[i] == " ": count = name[i] + 1 if count == 'j': name[count] = 'J' </code></pre> <p>I'm pretty sure this should work, but it gives me this error:</p> <pre><code>File "main.py", line 5 in &lt;module&gt; name[0] = "M" TypeError: 'str' object does support item assignment </code></pre> <p>I know there is a library function called .title(), but I want to do "real programming".</p> <p>How do I fix this?</p>
python
[7]
2,242,175
2,242,176
How to set color mTitles Array in that API demo?
<p><a href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List6.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List6.html</a></p> <p>In the above link , how toset color to mTitles string.</p>
android
[4]
3,984,445
3,984,446
JAVA : regarding System.out
<p>JAVA : is there a difference between the two references "p" &amp;&amp; "pp"?</p> <pre><code> PrintStream p = new PrintStream(System.out); p.println("lol"); PrintStream pp = System.out; pp.println("lol"); </code></pre> <p>I would just like to shorten the System.out.println(); statement for some prototyping. cheers! matt </p>
java
[1]
65,587
65,588
jQuery: jScrollHorizontalPane - Adding content dynamically
<p>I have a set of images in a jScrollHorizontalPane and I want to be able to change the content of the pane per project. </p> <p>Currently this is what I have loading every time a project is selected:</p> <pre><code> $.each(project.images || [], function() { if(this == "") return; imgCont.append('&lt;div class="image-item"&gt;&lt;img height="225" src="' + this + '" /&gt;&lt;/div&gt;'); }); var width = 0; imgCont.find('img').each(function() { width += $(this).width(); }); imgCont.width(width); $('#project-images-scroll').jScrollHorizontalPane ( { scrollbarHeight:10, scrollbarMargin:0, reset:true, animateTo:false, animateInterval:25, animateStep:5 } ); </code></pre> <p>But what ends up happening is the scroll bar is reset but not working when clicked.</p> <p>Any help on this would be greatly appreciated.</p>
jquery
[5]
5,745,557
5,745,558
document.body is null or not an object
<p>I am getting Java script error while loading page: document.body is null or not an object. URL: <a href="https://admit-uat.belgacom.be/WCE/ESW/selectBundle/productId/bun_nettv_go" rel="nofollow">https://admit-uat.belgacom.be/WCE/ESW/selectBundle/productId/bun_nettv_go</a></p> <p>Can you please let me know what is the issue.</p>
javascript
[3]
2,717,860
2,717,861
Add a custom event handler to an AppWidget component
<p>Is there any way to add a custom event handler to an AppWidget component, i.e an event handler that's not related to an Intent? I just want a listener function, like components in standard activities have. Thanks.</p>
android
[4]
4,578,439
4,578,440
Activating MyFiles app for a URI result
<p>there must be a way to do that, as in the clock alarm app that is built in android, when you press on the change alert button, it opens 2 possibilities, one uses RingtoneManager, and on the other you can choose to find a ringtone using My Files to get an alert ringtone, I want to do the same in my app... how is it done?</p>
android
[4]
2,119,465
2,119,466
Clearing a list using a for loop
<p>I'm making a Black Jack game, and at the start of every new round I need to clear the list of cards that represents the Player's and the Dealer's hands. I used this to do so:</p> <pre><code>public void ClearPlayerHand() { for (int i = 0; i &lt; PlayerHand.Count; ++i) { PlayerHand.Remove(PlayerHand[i]); } } </code></pre> <p>Problem is I always seem to be left with one card left in the list, or I receive an out of bounds error, no matter how I change the value of i, what is the best method of removing all the elements from the PlayerHand?</p>
c#
[0]
5,492,102
5,492,103
How to get the last value in a list/string using Python
<p>I am a beginner in writing Python scripts and I need help on the following:</p> <p><code>Threads::num,47141,47146,47151,47156,47161,47166,47171,47176</code></p> <p>How can I get and display the last value '47176'</p> <p>The following is the part of the code I have written:</p> <pre><code>elif sys.argv[1] == "-c": b = sys.argv[2] with open(b) as f: for line in f: if 'Threads::num' in line: print line.strip(',').split(',')[-1] print line </code></pre> <p>The output of this code is that it displays all the values as follows <code>Threads::num,47141,47146,47151,47156,47161,47166,47171,47176</code></p>
python
[7]
351,291
351,292
Populating data on gridview
<p>In my android app, i have a particular scenario, for one of the screens.</p> <p>I require 2 button,one on each side of the corner(left and right). Below this i want to populate data in a control.</p> <p>If left button is clicked, the control should be a gridview. If right button is clicked , the control should be a listview.</p> <p>And accordingly the data should be populated.</p> <p>How should i approach this scenario. Should i create controls dynamically, or use xml instead</p> <p>Rgds</p>
android
[4]
1,427,608
1,427,609
Is it allowed to assign to a dereferenced this (*this)?
<p>I'm currently refreshing my C++ skills and was wondering if it is possible to assign something to <code>*this</code>. I know assigning to <code>this</code> is forbidden, but can't find the same information for my case.</p> <p>An example:</p> <pre><code>class Foo { int x; public: Foo(int x) : x(x) {} Foo incr() { return Foo(x+1); } void incr_() { (*this) = incr(); } }; </code></pre> <p>Edit: corrected <code>incr()</code>'s return type from <code>void</code> to <code>Foo</code>.</p>
c++
[6]
1,344,173
1,344,174
Java: thread safe class instances
<p>I have the following two classes:</p> <pre><code>public class MyClass { public static void faceTheWorld(String Input){ SafeClass sC = new SafeClass(); sC.workWithInput(Input); } } public class SafeClass { public void workWithInput{String allInp) work with allInp... } </code></pre> <p>My question is. If I call MyClass.FaceTheWorld() several times at the very same time, will it always create a new class instance of SafeClass or will it try to create the same instance called 'sC' all the time?</p> <p>Would I need to create an array of instances instead to make avoid creating the same instance at the same time? How would this look in Java?</p> <p>Ultimately what I'm trying to achieve is that when I call FaceTheWorld with the 'Input' it would always make sure that 'Input' is thread safe e.g. no other instances can modify/access it.</p> <p>I make SafeClass synchronized, would that solve the problem?</p> <p>Many thanks</p>
java
[1]
1,853,680
1,853,681
Javascript not working in FF or IE
<p>I have some javascript code that gets the id of the element selected by the user, it works absolutely fine with Chrome, Safari, Opera but when it comes to Firefox and IE it doesn't seem to work at all.</p> <p>It is located within a closure function and I have done some tests and found that it is this exact line that is breaking the code. </p> <p>my function...</p> <pre><code>var myfunction = (function(){ var testId; var item1; var item2; return{ animate: function(){ testId = window.event.target.id; item1 = $('#heading' + testId); item2 = $('#subheading' + testId); //jquery operating on item1 and item2 goes here } }; }()); </code></pre> <p>line that doesn't seem to be working...</p> <pre><code>testId = window.event.target.id; </code></pre> <p>Any help with this problem would be much appreciated.</p>
javascript
[3]
5,575,975
5,575,976
I want buttons that flow with my Div and be displayed next to it
<p>I am writing a javaScript program that has N number of Div's and when ever mouse hovers over a particular div on the left of it there should be displayed a UP and DOWN button. </p> <p>I tried taking two DIV's. even when the mouseOver's the second div the buttons are visible only on the left side of the First Div.</p> <p>I want it left of the First DIV when mouse overs the First Div and left of the Second Div when the mouseOver's the second Div...</p> <p>Here is an example in jsfiddle:</p> <blockquote> <p><a href="http://jsfiddle.net/trendyteja/FtwTa/" rel="nofollow">http://jsfiddle.net/trendyteja/FtwTa/</a></p> </blockquote> <p>How to fix this?</p>
javascript
[3]
4,433,448
4,433,449
read text from html body
<p>In my android application i'm signing up a user with username and password, if done correctly it returns value "1" if not then "0" by calling a URL with a username and password as parameters and the result 0 or 1 shows in html body. </p> <p>my signup is doing perfectly but the html result 0 or 1 is not showing, instead of showing </p> <pre><code> java.io.BufferedInputStream@23888f88 </code></pre> <p>I've written a code to read the html data</p> <pre><code>public String getDataFromURL(String urlString) throws Exception { String response=""; URL url = new URL(urlString); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); try { InputStream in = new BufferedInputStream(urlConnection.getInputStream()); //readStream(in); response = in.toString(); } finally { urlConnection.disconnect(); } return response; } </code></pre> <p>Now what should i do to get the html body text ?</p> <p>Thanks</p>
android
[4]
1,533,557
1,533,558
How do I prevent the slow script warning and force the browser to continue running script until it's finished?
<p>Rather than get overly specific to my problem, I'll keep this generic so other people who stumble upon this can find it useful. </p> <p>I have a function that accepts one parameter, a string. If the string is short the function runs fine and completes in a timely fashion. If, however, the string that's passed in is too long the script runs for a bit, then eventually times out and returns the browser's slow script dialog that allows the user to kill the script. </p> <p>I would like to disable that from happening so the script can continue to its terminus.</p> <p>How can this be done? </p> <p>A side note: If I can get this working, I would also like to make a status bar, similar to the one you see when loading gmail, appear so the user knows things are happening. </p> <p>Thanks!</p>
javascript
[3]
2,918,417
2,918,418
Android - Strange crash reports when sending the user to android play for the app
<p>I have a button that the user can click which sends them to the app page in the Google Play store. This is the code I use for the button:</p> <pre><code> Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.problemio")); startActivity(intent); </code></pre> <p>and the package is here: <a href="https://play.google.com/store/apps/details?id=com.problemio" rel="nofollow">https://play.google.com/store/apps/details?id=com.problemio</a></p> <p>and sometimes it works fine, but sometimes I get a crash report like this:</p> <pre><code>android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.problemio } at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) at android.app.Activity.startActivityForResult(Activity.java:2833) at android.app.Activity.startActivity(Activity.java:2959) at com.problemio.content.BusinessIdeasActivity$5.onClick(BusinessIdeasActivity.java:107) at android.view.View.performClick(View.java:2538) at android.view.View$PerformClick.run(View.java:9152) at android.os.Handler.handleCallback(Handler.java:587) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3691) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Any idea why it only sometimes works?</p> <p>Thanks!</p>
android
[4]
1,842,273
1,842,274
C++ Add this pointer to a container by calling it in base class constructor
<pre><code>class Base { public: Base (int a, int b); private: int a,b; }; class Derived1 { public: Derived1():base(1,2){} }; </code></pre> <p>similarly Derived2, Derived 3 which doesnt contain any data members on its own</p> <p>Now i need to contain these derived objects in a singleton, so i was thinking to call this in base constructor like</p> <pre><code>Base::Base(int a, int b) { CBaseMgr::GetInstance()-&gt;AddtoVector(this); } </code></pre> <p>so now if i construct </p> <p>Derived d1, d2, d3 etc. will the Singleton's container contain all derived objects?</p> <p>My doubt is can i do this adding of objects to container in base ctor or should i do in derived ctor.?</p>
c++
[6]
5,365,438
5,365,439
Static Blocks - when are they executed
<p>I'm totally new to Java and I'm wondering why my static block is not executing.</p> <pre><code>public class Main { public static void main(String[] args) { Account firstAccount = new Account(); firstAccount.balance = 100; Account.global = 200; System.out.println("My Balance is : " + firstAccount.balance); System.out.println("Global data : " + Account.global); System.out.println("*******************"); Account secondAccount = new Account(); System.out.println("Second account balance :" + secondAccount.balance); System.out.println("Second account global :" + Account.global); Account.global=300; System.out.println("Second account global :" + Account.global); Account.add(); } } public class Account { int balance; static int global; void display() { System.out.println("Balance : " + balance); System.out.println("Global data : " + global); } static // static block { System.out.println("Good Morning Michelle"); } static void add() { System.out.println("Result of 2 + 3 " + (2+3)); System.out.println("Result of 2+3/4 " + (2+3/4)); } public Account() { super(); System.out.println("Constructor"); } } </code></pre> <p>My output is:</p> <pre><code>Good Morning Michelle Constructor My Balance is : 100 Global data : 200 ******************* Constructor Second account balance :0 Second account global :200 Second account global :300 Result of 2 + 3 5 Result of 2+3/4 2 </code></pre> <p>I want to know why "Good Morning Michelle" was not displayed when I went in with the second account.</p> <p>From the research I have done, this static block should execute each time the class is called (new Account).</p> <p>Sorry for the real beginner question. Michelle</p>
java
[1]
138,278
138,279
asp.net sessions issue
<p>I have a problem of the session not expiring. Here is my case</p> <p>I have a application in asp.net1.1. i am able to handle session when user click logout button. Session is active for 35 minutes. the application is also check if same user is trying to login using multiple machine and blocks it. </p> <p>Now this application is deployed in city where there is power outage. When user is loggd in and light goes off, the session remain open. Due to this, the user is not able to log in again for next 35 minutes from alternate machine.</p> <p>Can you tell solution of how to handle issue of session remained open the right way?</p>
asp.net
[9]
3,820,271
3,820,272
jquery ajax error when nothing wrong with http request
<p>I am using jquery to do ajax calls:</p> <pre><code> // omitting the code for the options properties var options = { type: Type, url: Url, data: '{aString:"abc"}', contentType: ContentType, dataType: dataType, //processdata: ProcessData, success: function (msg) { ServiceSucceeded(msg); }, error: ServiceFailed }; function ServiceFailed(result) { alert('Service call failed: ' + result.status + '' + result.statusText); } $.ajax(options).done(function () { alert("success: " + msg); }); </code></pre> <p>This call works in that the url defined in options is called. The endpoint is a wcf service which I host so I have verified it's called as expected.</p> <p>I monitor the call with fiddler, and I see nothing wrong with the request or the response. The http response code is 200 OK.</p> <p>But the function in done is not called. Instead ServiceFailed is run. Why is this? Why is done() not called, and why does jquery consi</p>
jquery
[5]
1,871,068
1,871,069
Why or why not should I use 'UL' to specify unsigned long?
<pre><code>ulong foo = 0; ulong bar = 0UL;//this seems redundant and unnecessary. but I see it a lot. </code></pre> <p>I also see this in referencing the first element of arrays a good amount</p> <pre><code>blah = arr[0UL];//this seems silly since I don't expect the compiler to magically //turn '0' into a signed value </code></pre> <p>Can someone provide some insight to why I need 'UL' throughout to specify specifically that this is an unsigned long?</p>
c++
[6]
843,346
843,347
How to get the last modified files in PHP?
<p>I want to create a list the names of the files which have been last modified at </p> <pre><code> http://www.searchr.us/web-search/ </code></pre> <p>I want to show these file names on my Homepage and they should change according to the last modified files !!</p>
php
[2]
2,967,362
2,967,363
Set a default value to jquery variable
<p>I want to set a default value to a variable.</p> <p>When the body loads it runs a function which needs the variable to get the data.<br>The form will do the same onchange but the form elements will be hidden and added only if the user wants to see the filter options</p> <p>My current code is</p> <pre><code>var grade = document.getElementById('grade').value; </code></pre> <p>If the id grade isnt available on the first load of the i want the grade to default to 0</p>
jquery
[5]
4,828,902
4,828,903
How to create new MIME type in Android DownloadProvider?
<p>I want to download a .JSON file from the tomcat server via Android DownloadManager. Is it possible to include the new MIME type like "application/json" in the android downloadprovider?..</p> <p>Thanks in advance, Bala</p>
android
[4]
5,988,961
5,988,962
redirect to a page if response.redirect fails
<p>I have a response.redirect(url), it goes to another site. In the event this fails, how would I redirect again to a 'redirect fail' page? the request is bieng sent from the code behind an aspx page. I have an httpmodule in place already if that could be used? Thanks in advance.</p>
c#
[0]
5,703,770
5,703,771
How do you make an android layout hold widgets programmatically?
<p>I'm trying to make a custom home screen application and can't seem to find an article or a book that explains how to add widgets to a layer programmatically. Anyone know of any good tutorials or a book where I can find this information as a Google search only returned me articles on how to make a widget. Maybe I'm asking the wrong question in Google or something. Anyway, thank you!</p> <p>EDIT: Since I don't have 100 reputation yet I can't answer my own question... which is... ah nvm... </p> <p>This is the answer... the only one I could find: <a href="http://www.anddev.org/advanced-tutorials-f21/appwidgethost-tutorial-t10329.html" rel="nofollow">http://www.anddev.org/advanced-tutorials-f21/appwidgethost-tutorial-t10329.html</a></p> <p>It works but you have to really take the time to understand it. Anyway it's the only real... example I could find I guess.</p>
android
[4]
3,110,476
3,110,477
Stop animating a jpg
<p>I have a url which produces a animated jpg. It has a js file attached which uses the property of top and left. Random values are assigned to the top and left. The entire script is pure javascript.[No <code>jQuery</code> is used or <code>jQuery animate</code>]</p> <h2>What I want is</h2> <p>To stop the animation until I do a mouseover.</p> <h2>My Code</h2> <pre><code>$('#s0').live('mouseover',function(){ var top = $(this).css("top"); var left = $(this).css("left"); $(this).css({top:top, left:left}).animate({top:top, left:left}); console.log(top); console.log(left); }) </code></pre> <p>This only stop for about a second, since <code>animate</code> needs an argument to show the time in <code>ms</code> to keep alive the animation. </p> <p>I tried add <code>setinterval</code> and <code>hover</code>.</p> <h2>Constrains</h2> <p>I cant do any changes in the main js file. I have a write additional code to make this work.[Its a screwed up system, and I have to follow the rule.</p>
jquery
[5]
5,199,291
5,199,292
problem building matrix through use of a loop
<p>This is my code:</p> <pre><code>var shuffle = function() { var set = []; var waiter = []; var suitset = ["Hearts","Clubs","Diamonds","Spades"]; for (var r = 1;r &lt;= 13;r++) { for (var s = 0;s &lt; suitset.length;s++) { card = []; var cardeval = evalcard(r); //This is an input from another function card.push(cardeval[0]); card.push(suitset[s]); card.push(cardeval[1]); waiter.push(card); } } while (waiter.length) { //This is what randomizes the deck aka shuffles set.push(waiter.splice(Math.random() * waiter.length,1)); } return set; }; </code></pre> <p>I'm trying to build a matrix of cards (I'm using matrix here as an array of arrays). There will be 52 arrays of card arrays, each of which holds a card number, suit, and value. But after I call the function, <code>card</code> returns as a string and not an array, even though it is defined with array brackers <code>[]</code>. Can anyone see what I'm doing wrong here?</p>
javascript
[3]
1,084,318
1,084,319
Working with images (playing cards)
<p>What is the best way of working with images, for a playing cards game in my case? Defining a resource for each image I have seems a little overkill. </p>
android
[4]
2,990,632
2,990,633
Query regarding CheckBox in C#
<p>I have list of checkbox with header text, if i check any checkbox then header should be check by default and if i uncheck any then header should be uncheck.</p>
c#
[0]
1,408,234
1,408,235
download file exception handling
<p>In my application I download several critical files from a server, and I want to write some code that handles the case where the a file download didn't complete for a reason or other ,to retry downloading it at next startup. The function that downloads a file at a time however throws only MalformedURLException and IOException , but if these exceptions are thrown that means that the download didn't even begin. How should I arrange things so I can treat the case where a download failed , even if it began ? </p> <pre><code>void download(String file) throws MalformedURLException ,IOException { BufferedInputStream getit = new BufferedInputStream(new URL(file).openStream()); FileOutputStream saveit = new FileOutputStream(DOWNLOAD_PATH+fileName+"."+ZIP_EXTENSION); BufferedOutputStream bout = new BufferedOutputStream(saveit,1024); byte data[] = new byte[1024]; int readed = getit.read(data,0,1024); while(readed != -1) { bout.write(data,0,readed); readed = getit.read(data,0,1024); } bout.close(); getit.close(); saveit.close(); } </code></pre>
java
[1]
1,894,359
1,894,360
forward declaration with vector of class type - pointer to incomplete class type not allowed
<p>I have two classes, foo and bar. foo includes bar and contains a std::vector of pointers to bar objects. at some point during runtime, bar has to access this vector of pointers to other bar objects. Therefor, foo contains a method named getBarObjects() that returns the array of pointers.</p> <p>Therefor, I forward declarate foo in bar. I obvioulsy also have to forward declarate the method I'm using - foo::getBarObjects(). As this returns the array of pointers to bar, I get into a vicious cycle.</p> <p>I cannot forward include Bar and then simply forward include getBarObjects(), as this results in "incomplete type name is not allowed".</p> <p>foo.h:</p> <pre><code>#include "bar.h" #include &lt;vector&gt; class foo { public: foo(); ~foo(); std::vector&lt;bar*&gt; getBarObjects(); private: std::vector&lt;bar*&gt; barObjects; } </code></pre> <p>bar.h:</p> <pre><code>class foo; std::vector&lt;bar*&gt; foo::getBarObjects(); // error, doesn't know bar at this point class bar { public: bar(foo *currentFoo); ~bar(); bool dosth(); private: foo *thisFoo; } </code></pre> <p>bar.cpp:</p> <pre><code>#include "bar.h" bool bar(foo *currentFoo) { thisFoo = currentFoo; } bool bar::dosth() { thisFoo-&gt;getBarObjects(); // error, pointer to inomplete class type is not allowed } </code></pre> <p>If I simply include the other way around, I'll have just the same problem in foo lateron. Any suggestions?</p>
c++
[6]
509,497
509,498
Understanding converView in BaseAdapter
<p>I have the following getView in the BaseAdapter.</p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout itemLo; if (convertView != null) { itemLo = (LinearLayout) convertView; } else { itemLo = (LinearLayout) LayoutInflater.from(mContext.getApplicationContext()). inflate(R.layout.item, parent, false); } View v1 = itemLo.findViewById(R.id.view1); View v2 = itemLo.findViewById(R.id.view2); if (position == 0) { v1.setVisibility(View.GONE); v2.setText("Start"); } else { v1.setText("" + position); v2.setText("" + position); } return convertView; } </code></pre> <p>When it is the first row (row 0), I hide v1 in row 0. My worry is that, after row 0 is scrolled out of the window, the converView for row 0 will be reused by other rows. The issue is that, v1 in row 0 has been set to View.GONE in row 0. If other rows reuse the converView for row 0, do I have to set View.Visible to v1? My test shows that I don't have to reset visibility for v1 in the convertView. So I am confused. Doesn't converView conserves the visibility property for each view in it, when the convertView is reused?</p> <p>Thanks.</p>
android
[4]
5,830,873
5,830,874
What is a good PHP script I can use as a poll?
<p>What is a good free PHP script to use as a poll for a website? I'd need a simple script to show on the web page with the standard multiple option vote + bar chart graph. Also an admin interface with add / edit / delete poll would be required.</p>
php
[2]
2,137,529
2,137,530
Persist javascript variables across pages?
<p>Hi Is there a way we can persist javascript variables across various pages? Suppose in Page A I am setting window.someVar = 5. Then I move to Page B, via clicking a hyperlink in A, and do something like alert(window.someVar) -- I should get a message box displaying 5. Is there a technique to persist someVar as such...?</p>
javascript
[3]
1,690,084
1,690,085
Change image src based on style width + height
<p>I have an asp.net mvc project, and a function that streams out an image based on url parameters. like: /Image/40/100/50 streams out image with ImageID 40, 100px wide and 50px high.</p> <p>So is there a way to change:</p> <pre><code>&lt;img class="image" src="/Content/View?fileID=31" style="width: 500px; height: 100px; " /&gt; </code></pre> <p>To:</p> <pre><code>&lt;img class="image" src="/Image/31/500/100" style="width: 500px; height: 100px; " /&gt; </code></pre> <p>In some fancy way? /Lasse</p>
jquery
[5]
319,967
319,968
IME keyboard does not show when OnClickListener set for EditText?
<p>I'm not sure if this is a bug or not with Android OS 1.5, but when I set an OnClickListener for an EditText, then try clicking it (using trackball), the IME keyboard no longer displays itself. With a click listener set, it displays when clicked.</p> <p>Is there another way I can request the IME keyboard to come up in the click handler? Either that, or I can add an OnTouchListener (which works correctly with IME keypad + touch) and just do something like performMotionEvent() from the click listener to simulate a real touch?</p> <p>Thanks</p>
android
[4]
1,492,235
1,492,236
why two keywords in c#: String and string
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/215255/string-vs-string-in-c">String vs string in C#</a> </p> </blockquote> <p>I see there are 2 different keywords (classes ?) one which starts with capital S and other with small in c#.</p> <p>String and string</p> <p>What is the reason ? is one not sufficient ?</p>
c#
[0]
1,066,263
1,066,264
RegisterStartupScript and multiple controls
<p>I have a parentUserControl that loads a childUserControl. Multiple instances (say 3) of parentUserControl is added to the host page.</p> <p>On PageLoad of the parentUserControl, I register JS:</p> <pre><code>ScriptManager.RegisterStartupScript(this, typeof(Page), keyJSLoadBegin, "OnParentLoad();", true); </code></pre> <p>On PageLoad of hte childUserControl, I register JS:</p> <pre><code>ScriptManager.RegisterStartupScript(this, typeof(Page), keyJSLoadBegin, "OnChildLoad();", true); </code></pre> <p>I get a JS error when I navigate to the page. The line that causes this error is (in View Source):</p> <pre><code>`OnParentLoad('parentA');OnChildLoad('childA');OnParentLoad('parentB'); OnParentLoad('parentC')`;OnChildLoad('childC');OnChildLoad('childB') </code></pre> <p>Clearly, the calls are out of order. </p> <p>Anyone knows why?</p> <p><strong>EDIT:</strong></p> <p>The problem seems to be related to the bug here: <a href="http://support.microsoft.com/kb/817032" rel="nofollow">http://support.microsoft.com/kb/817032</a></p> <p>The suggestion is to register all related scripts at once. This is impossible in my situation as the scripts are in different user controls.</p> <p>Has anyone come across a solution to this issue?</p>
asp.net
[9]
2,088,983
2,088,984
How to check for NULL in c++?
<p>Let say for example, I have a struct, and an array of the struct. What I want to do is to iterate through the array and check if any of the item is a null. I tried checking the item against NULL and (struct *) 0, that don't seem to work. Is there any reliable way to check for null value?</p> <p>UPDATE Sample Code</p> <pre><code>struct Test{ int a; }; Test testArray[size]; for (int i = 0; i &lt; testCount; i++) { if (testArray[i] == NULL) //this doesnt work { } } </code></pre> <p>Thanks,</p> <p>RWendi</p>
c++
[6]
913,400
913,401
Programming keybinds in C++
<p>I am actually not sure what I am looking for, I can not supply allot of information because of that, but what I am trying to do is program key binds, were when you click a certain key a certain sound will play, could someone please supply links as to were I could go to learn this?</p>
c++
[6]
5,091,812
5,091,813
how to pause the UI thread in javascript
<p>I'm wondering what a clean way is to pause the UI thread in javascript? Just for a couple seconds, I have a really good reason to.</p>
javascript
[3]
890,365
890,366
Change an element when an event occurs
<p>I want to change the element an event is attached to. In the below example I try to increase the border from 2px to 10 px without success.</p> <p>Complete minimal example (look for the FAILS row):</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;Example&lt;/title&gt; &lt;style&gt;P { margin-bottom: 40%; }&lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Paragraph 1&lt;/p&gt; &lt;p&gt;Paragraph 2&lt;/p&gt; &lt;p&gt;Paragraph 3&lt;/p&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $('p').each(function (i) { $(this).css('border', '2px solid'); $(window).scroll(function (event) { console.log('scroll triggered, but nothing happens!'); event.target.css('border', '10px solid'); // FAILS with TypeError: event.target.css is not a function }); }) &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
jquery
[5]
4,742,236
4,742,237
App doesn't run. Getting error window
<p>I have a problem with this code. This is a tutorial code that show how to get and show data from mysql DB. But when I try to run it I am getting a problem window that application has stopped unexpectedly. Any ideas how to fix it?</p> <pre><code>public class FoodActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String result = null; InputStream input = null; StringBuilder sbuilder = null; ArrayList &lt;NameValuePair&gt; nameValuePairs = new ArrayList &lt;NameValuePair&gt;(); nameValuePairs.add(new BasicNameValuePair("1","Avinas")); try{ HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://ik.su.lt/~jbarzelis/Bandymas/index.php"); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); HttpEntity entity = response.getEntity(); input = entity.getContent(); } catch(Exception e){ Log.e("log_tag","Error in internet connection"+e.toString()); } try{ BufferedReader reader = new BufferedReader(new InputStreamReader(input,"iso-8859-1"),8); sbuilder = new StringBuilder(); String line = null; while((line = reader.readLine()) != null){ sbuilder.append(line + "\n"); } input.close(); result = sbuilder.toString(); } catch(Exception e){ Log.e("log_tag", "Error converting result "+e.toString()); } int fd_id; String fd_name; try{ JSONArray jArray = new JSONArray(result); JSONObject json_data = null; for(int i=0;i&lt;jArray.length();i++){ json_data = jArray.getJSONObject(i); fd_id = json_data.getInt("FOOD_ID"); fd_name = json_data.getString("FOOD_NAME"); } } catch(JSONException e1){ Toast.makeText(getBaseContext(), "No food found", Toast.LENGTH_LONG).show(); } catch(ParseException e1){ e1.printStackTrace(); } } </code></pre> <p>}</p>
android
[4]
4,673,975
4,673,976
problem with integers
<p>can anybody look at this code and tell me why the exception happens? </p> <pre><code>public static void main(String[] args) { int total =100; int discount_Ammount = 20 ; int newAccount=Integer.parseInt( String.valueOf(Math.floor(total - discount_Ammount)).trim()); } </code></pre> <p>Method floor returns double value , then I make casting to integer, so I cast it to string then to integer... please, can anybody help?</p>
java
[1]
4,218,716
4,218,717
Whats the difference between these two lines in PHP....Are they both variables?
<p>There's:</p> <pre><code>$myvar="somthing"; </code></pre> <p>and:</p> <pre><code>define('myvar', 'something'); </code></pre> <p>I know the first one is defining a variable and I thought the second one was too, until someone told me its not...</p> <p>Whats the difference between the two? They both do the same things right?</p>
php
[2]
3,409,433
3,409,434
how to check if allow_url_fopen is enabled or not
<p>I'm using the following code</p> <pre><code>echo 'file_get_contents : ', ini_get('allow_url_fopen') ? 'Enabled' : 'Disabled'; </code></pre> <p>this can get it enabled or disabled</p> <p>but i would like to make as function say function name is <code>_isgetcontents</code></p> <p>then i can call it as following any where in my website code</p> <pre><code>if (_isgetcontents()){ echo "this is enabled"; // will do an action }else{ echo "this is disabled"; // will do another action } </code></pre> <p>~ thanks</p>
php
[2]