Unnamed: 0
int64
65
6.03M
Id
int64
66
6.03M
Title
stringlengths
10
191
input
stringlengths
23
4.18k
output
stringclasses
10 values
Tag_Number
stringclasses
10 values
4,063,171
4,063,172
Catch exception throw from inside of the with statement
<pre><code>zip_file_name = "not_exist.py" try: with zipfile.ZipFile(zip_file_name) as f_handle: print("open it successfully") except (zipfile.BadZipfile, zipfile.LargeZipFile), e: print(e) </code></pre> <p>Is this the correct way to handle exception throw by a with statement?</p>
python
[7]
4,864,131
4,864,132
Event.type not working in Mozilla Firfox
<p>By referring this <a href="http://api.jquery.com/event.type/" rel="nofollow"><strong>link</strong></a>, I had adopted a property called <code>Event.Type</code> to my <code>script</code> for a particular need and it worked fine in <code>IE9</code>. After that while making <code>compatibility test</code>, i came to know that it is not working in <code>Mozilla FireFox</code>. Additionally it is working with out any problems in <code>Google Chrome</code> and <code>Safari</code>. </p> <h2><a href="http://jsfiddle.net/Kjk7a/" rel="nofollow"><em>DEMO</em></a></h2> <p>Any clues to solve this ? or Is there any alernate way available to substitute <code>Event.Type</code> in jquery.? </p>
jquery
[5]
5,320,448
5,320,449
How to load all Jars in the same path that as url shows into JVM after a certain URLClassLoader had been created?
<p>Oh, sorry for my poor presentation skill, I mean that now I have create an URLClassLoader A, and its URL[] is B, now I need to load and unload all the jars in B dynamically. But I don't know how to do it. </p>
java
[1]
1,828,941
1,828,942
How to make sure a static method/property runs before all other static properties in other classes
<p>I have some classes in my project with static properties. How could I make one static method that populates a container from which these static properties read data from. How could I make one static method run first before any other static method.How do you which classes static properties get loaded first</p>
c++
[6]
5,195,047
5,195,048
Passsing JSON in OnClick Events
<p>How can I embed the following parameter string in an onclick event without breaking the JS? Right now there is collision with double Quotes. the values in th onclick event are coming from a JS variable.</p> <p>Ex:</p> <pre><code>initializeMap('["2012-02-17 15:39:19.0,33.38727791932264,-86.74324840021933","2012-01-10 00:40:08.0,33.38708092092858,-86.74331461676397"]','%68%74%74%70%3a%2f%2f'); </code></pre> <p>In an Onclick Event:</p> <pre><code>&lt;a href="#-" onclick="JavaScript:initializeMap('["2012-02-17 15:39:19.0,33.38727791932264,-86.74324840021933","2012-01-10 00:40:08.0,33.38708092092858,-86.74331461676397"]','%68%74%74%70%3a%2f%2f');"&gt;Click Me&lt;/a&gt; </code></pre> <p>Thanks</p>
javascript
[3]
4,012,535
4,012,536
How come alert breaks javascript execution?
<p>how is that possible that call to the alert function changes behavior of a js script? Something like that:</p> <pre><code>function add_token (item) { var li_data = $.data(item.get(0), "tokeninput"); </code></pre> <p>works but this:</p> <pre><code>function add_token (item) { alert('a'); var li_data = $.data(item.get(0), "tokeninput"); </code></pre> <p>doesn't - I get following error in firebug: li_data is undefined jquery.tokeninput.js Line 336 (adding alert call is the only change)</p> <p>(as you can see I'm playing with Tokenizing Autocomplete jQuery plugin - <a href="http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/" rel="nofollow">http://loopj.com/2009/04/25/jquery-plugin-tokenizing-autocomplete-text-entry/</a> )</p> <p>Now that's something that bugs me. Can someone explain to me how is that even possible? </p> <p>UPDATE: I tried using Chrome instead of Firefox and this particular problem doesn't appear. So now what? It should be considered some kind of a bug in FF or is there something else about this that I'm not aware of?</p>
javascript
[3]
2,561,445
2,561,446
PHP unlink() breaks file_exists, header, and echo functions?
<p>I have the following code:</p> <pre><code>$tmpfile = $tempDirectory . $file ; if (file_exists($tmpfile)) { header('Location: &lt;some location&gt;'); } </code></pre> <p>It works flawlessly, the file exists, I get redirected to my new page.</p> <p>So, now I know that the file exists and works. So, I go into FTP, ensure the file is there.</p> <p>Then I run this code:</p> <pre><code>$tmpfile = $tempDirectory . $file ; if (file_exists($tmpfile)) { unlink($tmpfile); header('Location: &lt;some location&gt;'); } </code></pre> <p>Redirect stops working. PHP outputs nothing. The file gets deleted from the FTP directory. But the redirect completely fails.</p> <p>If I put an <code>echo</code> inside the if statement when there is an unlink present (before or after any other line of code in the if statement, it outputs nothing.</p> <p>There isn't an unlink error, and the file is clearly deleted when I check FTP, so what is going on here?</p> <p>It gets deleted when the code is run, so it's obviously not a permission issue. It wouldn't be able to delete the file if it didn't have permissions to do so.</p> <p>Any help is appreciated. Thanks!</p>
php
[2]
2,914,898
2,914,899
How to place aspx-files in seperate Web Application Projects in one solution?
<p>We have been building ASP.Net websites for many years. During this time we gathered a lot of knowledge of ASP.Net. We know what to use, a what not. One problem is still, persistently, bugging us. I hope to solve this for once and for all.</p> <p>We have a fairly large solution with lots of aspx-files. All aspx-files reside in one Web Application Project. This single big WAP needs to be split in multiple smaller projects. The exact reasoning is beside the point, please believe me ;-).</p> <p>There are a number of ways to accomplish this, but I am still unsure what the best way would be. We use ASP.Net 4.0 and Visual Studio 2010 Premium.</p> <p>Any advice is greatly appreciated.</p> <p><strong>This is our current work-around (which we do not like)</strong></p> <ol> <li>Create a WAP (Runner).</li> <li>Create a second WAP (ProjectA)</li> <li>Create a third WAP (ProjectB)</li> <li>Delete the web.config's in ProjectA and ProjectB</li> <li>Create a simple aspx-file in Runner, ProjectA and ProjectB with a hello world message</li> <li>Remove ProjectA and ProjectB</li> <li>Go to Windows Explorer</li> <li>Move the folders ProjectA and ProjectB inside the folder Runner</li> <li>Go back to Visual Studio</li> <li>Add Existing Project to solution (ProjectA and ProjectB)</li> <li>Hit F5</li> <li>Navigate to <a href="http://localhost:4867/WebForm1.aspx" rel="nofollow">http://localhost:4867/WebForm1.aspx</a></li> <li>Navigate to <a href="http://localhost:4867/ProjectA/WebForm1.aspx" rel="nofollow">http://localhost:4867/ProjectA/WebForm1.aspx</a></li> <li>Navigate to <a href="http://localhost:4867/ProjectB/WebForm1.aspx" rel="nofollow">http://localhost:4867/ProjectB/WebForm1.aspx</a></li> </ol> <p>Tada! The above works, but it feels like a hack and it smells awful. Is there a better way?</p>
asp.net
[9]
4,977,885
4,977,886
Bar code scanner in Android
<p>I want to Create an application which can read the Ba Codes. I want to do this through my on application not using third party applications like 'ZXing'. Please any coding help or tatorial...</p>
android
[4]
524,759
524,760
full screen in android at runtime (no notification/status bar and app title bar)?
<p>is following both lines are <br></p> <pre> getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); setTheme(android.R.style.Theme_NoTitleBar_Fullscreen); </pre> <p>considering I am writing this line in activity class </p> <p>Thanks in advance</p>
android
[4]
5,338,397
5,338,398
nextLine() Issues with java Scanner Class
<pre><code>import java.util.Scanner; public class b { public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); String[] lines = new String[5]; lines[0] = keyboard.nextLine(); lines[1] = keyboard.nextLine(); lines[2] = keyboard.nextLine(); lines[3] = keyboard.nextLine(); lines[4] = keyboard.nextLine(); for (int i = 0; i &lt; lines.length; i++) { System.out.println(lines[i]); } } } </code></pre> <p>Why does the above code not allow me to store the following:</p> <pre><code>Hello there How are you My name is Bill Gates What is yours? </code></pre> <p>The output I get is:</p> <pre><code>Hello there How are you My name is Process completed. </code></pre> <p>I know there are issues with primitives and nextInt() but I thought nextLine() was supposed to address this.</p>
java
[1]
4,244,150
4,244,151
glassfish server is not working
<p>i am working on netbeans versin 7 with glass fish server 3.1 in java but whenever i run a project ,it shows "glassfish server start failed"</p> <p>and a warining that i am pasting here is shown</p> <pre><code> SEVERE: not.found.in.original.location[Ljava.lang.Object;@1760a96 WARNING: DPL8027: Ignore WEB-INF/sun-web.xml in archive /C:/Users/user/Documents/NetBeansProjects/StrutsPro/build/web/, as GlassFish counterpart runtime xml WEB-INF/glassfish-web.xml is present in the same archive. </code></pre> <p>What to do?</p>
java
[1]
5,881,808
5,881,809
What is $$ in php?
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2715654/what-does-mean-in-php">What does $$ mean in PHP?</a><br> <a href="http://stackoverflow.com/questions/4179489/double-dollar-sign-php">Double dollar sign php</a> </p> </blockquote> <p>What is $$ in php. This question is asked in a recent interview for a web developer position. Thanks in advance!</p>
php
[2]
819,343
819,344
How to put a string variable inside a doublequote?
<p>So I would like to create a text(like a log file) from the database. Each text represent a user's record. Obviously each record has different name according to the database. And I am wondering how to put the string variable inside the doubleqoute when creating the text file.</p> <pre><code>public static void createLog() { MySqlConnection con = new MySqlConnection(); con.ConnectionString = "SERVER=localhost;DATABASE=s_project;UID=root;PASSWORD='';";SELECT con.Open(); MySqlCommand thiscommand = con.CreateCommand(); thiscommand.CommandText = "SELECT user_name FROM user_info"; MySqlDataReader read = thiscommand.ExecuteReader(); while (read.Read()) { string user_name; user_name = read.GetString("user_name"); StreamWriter SW; SW = File.CreateText("c:\\MyTextFile.txt"); //what should I put instead of MyTextFile if I would like it to be the variable user_name? } con.Close(); } </code></pre>
c#
[0]
4,586,981
4,586,982
java - How to handle array:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
<p>In my code i am comparing the 2 elements of an array. but i got the following exception.please can anybody help me</p> <blockquote> <p>array:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at Sarray.main(Sarray.java:64)</p> </blockquote> <p><br></p> <pre><code>public class Sarray { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print( "Enter sorted array length:" ); int length = scan.nextInt(); int[] a = new int[length]; System.out.println("Enter integer sorted array:"); for(int i = 0;i&lt;length;i++) { String token = scan.next(); a[i] = Integer.parseInt(token); } System.out.print("Unique array:"); int[] b=new int[length]; int k=0; for(int i=0;i&lt;length;i++) { //here i got Exception if(a[i] != a[i+1]) { b[k++]= a[i]; } } for(int i=0;i&lt;k;i++) { System.out.print(b[i]+" "); } } } </code></pre>
java
[1]
4,512,118
4,512,119
setting backgroung image to button tag in asp.net
<p>i tried to set image to the button tag in asp.net but it gave an error saying background-image cannot be applied to . Please help I wrote the following code</p> <pre><code>&lt;asp:Button ID="bsrc" runat="server" Style="left: 545px; position: absolute; top: 18px;font-family:Tahoma; font-size:small" Text="Search" Width="101px" /&gt; &lt;img src="search-icon.png" alt="" style="left: 649px; width: 29px; position: absolute; top: 17px; height: 26px" /&gt; </code></pre>
asp.net
[9]
3,978,695
3,978,696
importing in python and checking __name__
<p>I am importing a module (i am using its name as module only). Whenever i press </p> <pre><code>module.__name__ </code></pre> <p>it is showing some name Module.module</p> <p>when i did </p> <pre><code>print module </code></pre> <p>,i go to the path mentioned. I don't have the module, it has a pyd file. I am completely confused about python importing process,What exactly is <code>__name__</code>? How does change in <code>__name__</code> change the way we import, how does main change while importing</p>
python
[7]
1,559,235
1,559,236
How to kill an Android app and all running service/tasks from another service?
<p>I am writing an app that intercepts the launching of apps, killing them, then restarting them if certain permissions are met. I've managed to figure out the first part(launching of apps) by having a service that monitors the system log. I'm now working on killing the app that was just launched. I'm trying to use:</p> <pre><code>ActivityManager.killBackgroundProcesses(packageName); </code></pre> <p>but I'm not sure if this will kill the entire app, including all services/tasks that it starts. I've tried using killBackgroundProcesses() to indiscriminately kill all apps that are launching, but the app still seems to start.</p> <p>I've also tried android.os.Process.killProcess(pid), passing the other app's pid, however the app still seems to start as well.</p>
android
[4]
1,997,006
1,997,007
Android how to show .docx file in webview?
<p>In my app i have URL:: <a href="http://mymobilece.com/api/api_getexammaterials.php?id=27" rel="nofollow">http://mymobilece.com/api/api_getexammaterials.php?id=27</a> Its a file how to show in webview? but not with Google document viewer.</p>
android
[4]
2,121,919
2,121,920
Connect device for debugging with Android?
<p>I need to connect my device (Sony S) to eclipse for debugging. How can I do this?</p> <p>I've got it plugged in, and set up for development with debugging mode turned on.</p> <p>I have adb devices to see if its there and it isnt.</p> <p>I am on OSX 10.6</p>
android
[4]
1,917,604
1,917,605
Android Map programming
<p>Actually i am developing a Map browser app in Android. I have a .dat file contains map information with a File format like this,</p> <pre><code>struct point{ int x, int y; }; </code></pre> <p>How can i read this .dat file using this format and copy the values into x and y?</p>
android
[4]
3,397,817
3,397,818
Not able to retrieve key from App.Config
<p>In my WAP project I have a reference to another C# Project (non-web). In that C# project I have an app.config and I renamed it to [projectName].config</p> <p>I then tried to grab a key from my [project].config from some code within my C# Project and it can't find it:</p> <pre><code>return ConfigurationManager.AppSettings["somekey"] </code></pre> <p>So I am wondering why it can't read my app.config. I would think that ConfigurationManager would be able to read keys form the Web project's web.config AND my [projectName].config (app.config) file that is in my referenced project as well?</p>
asp.net
[9]
4,195,892
4,195,893
How can i force an user to select the file extension i want?
<p>How can I force the user to save the file as .java or whatever?</p> <p>Thank you!</p> <p>EDIT: </p> <p>I would like to use the JFileChooser option and throughout, force the user to select the file extension that I want. </p>
java
[1]
6,025,209
6,025,210
multiple form validation
<p>If all asp.net controls are required to be within a form in order to be generated, how does one go about using the jquery validation plugin with multiple forms on the same page?</p> <p>What I mean by that is, how can I have two forms both containing asp controls that can be validated independently with jquery validation?</p>
jquery
[5]
5,451,624
5,451,625
How can I "avoid" mousedown over some inside elements?
<p>My <a href="http://jsfiddle.net/GUPUG/4/" rel="nofollow">code</a> :</p> <h1>HTML</h1> <pre><code>&lt;div style="position:relative;"&gt; &lt;div class="boxImmagineResultNext"&gt;&lt;/div&gt; &lt;div class="boxImmagineResult"&gt; &lt;textarea cols="15" rows="5"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <h1>CSS</h1> <pre><code>.boxImmagineResultNext { height: 235px; position: relative; width: 200px; z-index: 1; display:none; } .boxImmagineResult { background-color: #595959; height: 255px; position: relative; width: 220px; z-index: 1; top:0; left:0; } ​ </code></pre> <h1>jQuery</h1> <pre><code>$('.boxImmagineResult').mousedown(function (e) { $(this).css({ 'position': 'absolute', 'z-index': '10' }); $('.boxImmagineResultNext').show(); }); $('.boxImmagineResult').mouseup(function (e) { $(this).css({ 'position': 'relative', 'z-index': '5' }); $('.boxImmagineResultNext').hide(); });​ </code></pre> <p>Due to this mechanism, I can't "write" on the textarea. This just on Firefox, for example, on chrome it works as well. It seems "readonly" but in fact it is not.</p> <p>How can I fix it? I should "avoid" mousedown when I click over the textarea...</p>
jquery
[5]
2,077,138
2,077,139
Displaying progress dialog before starting a new activity
<p>I have an activity 'Activity1' and also another activity named 'Activity2'. The 'Activity2' is loaded upon clicking a button in 'Activity1'. I wanted to display the progress dialog until the new activity is loaded . Can you please show me the code to do this </p>
android
[4]
664,410
664,411
elegant way to convert IP to octal
<p>I have been looking for an elegant way in php to convert an IP address into its octal representation without having to do each of the four digits separately. </p> <p>for example, the IP: 1.2.3.4 would be 0001.0002.0003.0004</p>
php
[2]
1,832,134
1,832,135
Data connection to Internet
<p>My app is making a connection, using the DefaultHttpClient and HttpPost, to the internet. I configured it to have Internet permission (manifest) and all is working well when my device is connected via WIFI. Switching off the WIFI and trying to use a data connection via the phone network seems to fail (there is not really a connection error, but it seems the data (from the server) is never arriving.</p> <p>Any suggestions to what causes this behaviour are welcome. Do I need to add more permissions ?</p> <p>Thanks,</p> <p>Vincent</p>
android
[4]
3,562,079
3,562,080
Process C#| How To Make A Process Into system tray
<p>So, I have a <code>Process</code> running in C#, and I want to make it a system tray. Is it possible?</p> <p>This is the code I am using:</p> <pre><code>Process proc = Process.Start("XXXX"); </code></pre>
c#
[0]
1,949,528
1,949,529
Is there an infinite loop in my code?
<p>My webpage crashes when I run this:</p> <pre><code>function replace() { var str = document.getElementById('feeds'); var cont = str.innerHTML; curstring = "twitter: "; while (cont.indexOf(curstring)) { replaced = cont.replace(curstring,"TWIMG "); str.innerHTML = replaced; } } </code></pre>
javascript
[3]
2,606,802
2,606,803
Problem with $_POST
<p>This wont work. All the fields are correct etc and I have a db connection.</p> <p>To the problem</p> <p>I use this script to insert a post into the db:</p> <pre><code>&lt;?php if (isset($_POST['msg'])) { $title = mysql_real_escape_string($_POST['title']); $msg = mysql_real_escape_string($_POST['msg']); // kolla efter tomma fält if (empty($title) || empty($msg)) { $reg_error[] = 1; } if (!isset($reg_error)) { mysql_query("INSERT INTO messages (title, message, date, user_id) VALUES('$title', '$msg', '".time()."', '2')"); header('location: /'); exit; } } ?&gt; </code></pre> <p><b>The Form:</b></p> <pre><code>&lt;form action="post_msg.php" method="post"&gt; &lt;b&gt;Title:&lt;/b&gt; &lt;input type="text" name="title" size="40" /&gt; &lt;b&gt;Message:&lt;/b&gt; &lt;textarea rows="15" cols="75" name="msg"&gt;&lt;/textarea&gt; &lt;input type="submit" value="Post Message" /&gt; &lt;/form&gt; </code></pre> <p></p> <p>Worked fine the other day. Not today. No errors. The "post stuff" shows up in the url. I thought it only did when using $_GET which i dont. <code>http://localhost/post_msg.php?title=fdsg&amp;msg=sdfg</code></p> <p>i dont get any errors the page just reloads</p> <p>messages db</p> <pre><code>CREATE TABLE IF NOT EXISTS `messages` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `title` varchar(140) COLLATE utf8_unicode_ci DEFAULT NULL, `message` text COLLATE utf8_unicode_ci `date` int(10) unsigned NOT NULL, `user_id` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), FULLTEXT KEY `title` (`title`,`message`) </code></pre>
php
[2]
5,012,958
5,012,959
Gather all Python modules used into one folder?
<blockquote> <p><strong>Possible Duplicate:</strong><br /> <a href="http://stackoverflow.com/questions/907660/gather-all-python-modules-used-into-one-folder">Gather all Python modules used into one folder?</a> </p> </blockquote> <p>I don't think this has been asked before-I have a folder that has lots of different .py files. The script I've made only uses some-but some call others &amp; I don't know all the ones being used. Is there a program that will get everything needed to make that script run into one folder?</p> <p>Cheers!</p>
python
[7]
5,543,205
5,543,206
PHP errors for (isset) variables and optimization
<p>My error logs get huge quick because I reference a ton of variables with may or may not exist. I have been going back through and starting to clean them up but wanted to see if there was a more effective (and cleaner) way of checking for php variables. </p> <p>Currently I use as the following:</p> <p>Example 1:</p> <pre><code>&lt;?php if (isset($_SESSION['checked']) &amp;&amp; $_SESSION['checked'] == "Y") { do something; } ?&gt; </code></pre> <p>Example 2: (within html form)</p> <pre><code>&lt;input type="text" name="sample_number" onKeyUp="this.value=this.value.replace(/[^0-9]/ig, '')" value="&lt;?php echo $fields['sample_number']; ?&gt;" /&gt; </code></pre> <p>where sample number is displayed if it is set.</p> <p>is there a better way to handle scenarios like these?</p>
php
[2]
2,004,578
2,004,579
What's the pythonic way of declaring variables?
<p>Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed. </p> <p>Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?</p> <p>How would you avoid such a situation? </p>
python
[7]
4,971,316
4,971,317
onCreate not getting called for first activity when calling startActivity consecutively for two different activities
<p>I have three activities <strong>A</strong>, <strong>B</strong>, and <strong>C</strong>.</p> <p>In <code>onCreate()</code> of A, I call <code>startActivity(...)</code> in two consecutive statements for launching B &amp; C. But android does not calls <code>onCreate()</code> on activity B instantly. Instead when I press back on C since it is on top of stack. it calls <code>onCreate()</code> on B and the other lifecycle methods then.</p> <p>Here is what my example code looks like.</p> <pre><code>public class A extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); startActivity(this, B.class); startActivity(this, C.class); } } </code></pre> <p>Any clues to why the call to onCreate of activity B is getting deferred ?</p>
android
[4]
2,781,479
2,781,480
HTML tags in string for TextView
<p>If I put simple HTML formatting tags, such as &lt;b&gt;...&lt;/b&gt; into a string resource and display the string in a TextView, the expected formatting is applied. But how can I do this if I build up my own String and display it? If I do something like String str = "This is &lt;b&gt;bold&lt;/b&gt;";, the actual tags get displayed -- not the expected bolding.</p> <p>Do I have to run the string through some other method to cause the tags to be recognized as tags?</p>
android
[4]
741,218
741,219
jquery test a condition vs entire collection without a loop
<p>Pretty simple to do with loop but I'm wondering if there's a way to see if every item in a collection matches a condition without a loop. For example:</p> <pre><code>if( $('.many-items-of-this-class').hasClass('some-other-class') ) { } </code></pre> <p>This returns true if any item in the collection returns true. Is there a way to do this sort of operation so it only returns true if all items are true?</p>
jquery
[5]
2,606,451
2,606,452
Detect end of running process without Admin rights
<p>I was wondering if it was possible to detect when a certain process gets killed or closed the normal way. With other words if the process is removed from the process list.</p> <p>I know it's possible by using WMI and the System.Management.ManagentEventWatcher, however this needs Administrator rights, I'd prefer if it's done without requiring those.</p> <p>Since at the moment I use Process.Start("ProgramX.exe"); I'd like to find out when that program is closed or terminated. So that I can act upon that.</p>
c#
[0]
567,423
567,424
Android SeparatedListAdapter - How to use custom object as List Item?
<p>I have a basic object called <code>Employee</code>. You can retrieve an Employee's name and id using <code>.getName()</code> and <code>.getId()</code>.</p> <p>I want to use Jeff Sharkey's SeparatedListAdapter to build a sectioned list. For the list items though, I need to use my custom Employee objects for the items instead of just lists of Strings.</p> <p>In the included examples for the SeparatedListAdapter, he uses an <code>ArrayAdapter&lt;String&gt;</code> and a <code>SimpleAdapter()</code> for populating the list.</p> <p>Is there any way to use a custom object/class, like my Employee class? The reason I'm needing to do this, is that when I click on an item in the list, I want to retrieve the actual Employee object that I used for that item and then retrieve the ID of the employee so I can display information pertaining to that Employee.</p> <p>I'm a little bit confused on how to use Adapters properly. Should I make my own adapter or something?</p>
android
[4]
2,386,065
2,386,066
Location of default image button in android?
<p>Does anyone know where I can find the default image used for button in android? It will be a nine-patch with the .9.png extensions. </p>
android
[4]
1,472,400
1,472,401
How to prevent Overloading?
<p>Is it possible to prevent overloading of user defined functions in C++? Suppose I have a function as:</p> <pre><code>void foo(int , int); </code></pre> <p>Can I prevent foo from being overloaded, and if so how? If I can, can this be extended to prevent overriding of the methods through inheritance?</p>
c++
[6]
2,003,446
2,003,447
strtotime / 86400 not returning even number of days
<p>I am having a strange result with PHP Version 5.3.1, can anyone explain the below result?</p> <pre><code>$secondsDiff = strtotime(date("2011-11-10")) - strtotime('2011-07-15'); return ($secondsDiff/86400); </code></pre> <p>it returns 117.958333333??</p> <p>When I use dates closer together it generally works.</p> <p>I had a look through the docs, but couldnt find any reference to this. Is this a known php bug that I just need to learn to live with or am I missing something very obvious?</p>
php
[2]
1,389,769
1,389,770
Java Subclasses last instance overwriting values
<p>I'm a web developer dabbling in Java (again) and I'm having trouble with something.</p> <p>Basically, I have a superclass Employee with two subclasses that extend it called Management and Programmer. The Employee class contains an array <code>employees</code> that is basically an array of Employee objects.</p> <p>Here's the important snippets of two of the classes (Employee and Management) and the final main method. I'll explain the output at the bottom.</p> <pre><code>public class **Employee** { private static String firstName; protected static int MAXEMPLOYEES = 5; protected Employee[] employees = new Employee[MAXEMPLOYEES]; protected int totEmployees = 0; public Employee(String first) { setFirstName(first); } public void setFirstName(String str){ firstName = str; } public String getFirstName(){ return firstName; } public boolean addEmployee(String fname) { boolean added = false; if (totEmployees &lt; MAXEMPLOYEES) { Employee empl = new Employee(fname); employees[totEmployees] = empl; added = true; totEmployees++; } return added; } } public class **Management** extends **Employee** { private String title = "Project Manager"; public Management(String fname, String t){ super(fname); title = t; } public boolean addManagement(String fname, String t){ boolean added = false; if (totEmployees &lt; MAXEMPLOYEES) { employees[totEmployees] = new Management(fname, t); added = true; totEmployees++; } return added; } } ------------------------------------- package employee; public class EmployeeApplication { public static void main(String[] args) { Employee[] empl = new Employee[3]; empl[0] = new Employee("Kyle"); empl[1] = new Management("Sheree", "Director"); System.out.println(empl[0].getFirstName()); } } </code></pre> <p>Now, I expect the system to print out "Kyle", but it prints out "Sheree". Any ideas???</p>
java
[1]
2,936,113
2,936,114
Need help understanding the + operator in Javascript
<p>Why is <code>1 + + + 1 = 2</code> in Javascript?</p> <p>What is this behavior called? Is it documented somewhere? </p> <p>Thanks.</p>
javascript
[3]
122,968
122,969
How to add share application button from activity to google+ and facebook?
<p>I am building android application now i already completed, but I want to add Share button in root activity that user can share my application(link to download from google market) to google+ , facebook, twitter and linkin.</p> <p>How can i do it?</p> <h1>my code:</h1> <pre><code>ImageButton sharingButton = (ImageButton) findViewById(R.id.share); sharingButton.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); sharingButton.setImageResource(R.drawable.ic_share); sharingButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { shareIt(); } }); private void shareIt() { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); String shareBody = "Here is the share content body"; sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(sharingIntent, "Share via")); } </code></pre> <p>I tried this but doesn't give me a result. Can you please help me?</p> <p>regards, </p>
android
[4]
5,565,029
5,565,030
ASP.NET What is this called using from keyword to loop through list
<p>Hey I just wanted to find out the working of the following script as I never seen "From" used like this before</p> <pre><code> var formattedList = from a in value select new { a.value, currencyId = a.currencyId == -1 ? "" : a.currencyId + "" }; </code></pre>
asp.net
[9]
2,636,873
2,636,874
jQuery problems with tinybox
<p>I'm using tinybox <a href="http://www.scriptiny.com/2011/03/javascript-modal-windows/" rel="nofollow">http://www.scriptiny.com/2011/03/javascript-modal-windows/</a> for a pop-up window. It looks like this: </p> <pre><code>TINY.box.show({ iframe: "someDocument.html", boxid: "frameless", width: 300, height: 200, fixed: false, maskid: "bluemask", maskopacity: 40, closejs: function () {}}); </code></pre> <p>I'm using this with jQuery and it works fine when I launch it. But the problem is that I can't change anything when it's open, I want to add an event. I'm using a iframe as shown. Any ideas?</p>
jquery
[5]
4,090,239
4,090,240
Is this a good bind method?
<pre><code>Function.prototype.bind = function() { var $this = arguments[0]; return this.apply($this, Array.prototype.slice.call(arguments, 1)); }; </code></pre> <p>Is it good enough to use in real-world application?</p>
javascript
[3]
5,198,506
5,198,507
PhotoSwipe JS gallery, remove specific event handler
<p>In <a href="https://github.com/codecomputerlove/PhotoSwipe/blob/master/src/photoswipe.class.js" rel="nofollow">PhotoSwipe</a> JavaScript image gallery is there any way to remove a specific event handler? I found you can remove ALL but I found no way to remove one by name.</p>
javascript
[3]
5,204,046
5,204,047
Reading standard output from process, always empty
<p>Running this code:</p> <pre><code>Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "tool.exe"; p.Start(); p.WaitForExit(); </code></pre> <p>Makes tool.exe run, and output some content on standard output. However, if I try to capture the content using:</p> <pre><code>Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName = "tool.exe"; p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); Console.WriteLine(output); Console.ReadLine(); </code></pre> <p>Then nothing gets outputted, i.e. my variable "output" is always empty.</p> <p>I've verified that tool.exe indeed outputs to standard output (and not standard error).</p> <p>Anyone have a clue of what's going on? Starting to feel stupid here, as it seems to be a real text book example...</p>
c#
[0]
3,214,925
3,214,926
What does this mean in my boss's python code?
<p>This is the code :</p> <pre><code>modulename, classname = settings.APP_USER_CLASS.rsplit('.',1 ) modulemeta = __import__(modulename, globals(), locals(), [classname]) </code></pre> <p>I don't understand this: <code>__import__(modulename, globals(), locals(), [classname])</code> mean ,</p> <p>so what is it ,</p> <p>thanks</p>
python
[7]
5,527,542
5,527,543
Strip All Urls From A Mixed String ( php )
<p>i reposted this question because i didn't find a good answer.</p> <p>i have a string which can contains text with urls.</p> <p>i want a function to strip all urls from this string and just let the text.</p> <p>by example the string can contains like this :</p> <p>1) hey take a look here : <a href="http://xxx.xxx/545df5" rel="nofollow">http://xxx.xxx/545df5</a> this is nice!</p> <p>2) hey take a look here : <a href="http://www.xxx.xxx/545df5" rel="nofollow">http://www.xxx.xxx/545df5</a> this is nice!</p> <p>3) hey take a look here : xxx.xxx/545df5 this is nice!</p> <p>4) hey take a look here : www.xxx.xxx/545df5 this is nice!</p> <p>Thanks</p>
php
[2]
4,536,931
4,536,932
How to sort an array starting with a specific position
<p>I have an array:</p> <pre><code>int[] array = {1,2,3,4,5,6,7,8,9,10}; </code></pre> <p>I want to pick a starting point for the sorting. If I choose <code>6</code> the output should be </p> <pre><code>(6,7,8,9,10,1,2,3,4,5) </code></pre>
java
[1]
85,267
85,268
Object definition SyntaxError
<p>Why does the second line of code produce an error but not the third?</p> <pre><code>{ foo: 'bar' } // =&gt; 'bar' { "foo": 'bar' } // =&gt; SyntaxError: Invalid label ({ "foo": 'bar' }) // =&gt; { foo: 'bar' }. </code></pre>
javascript
[3]
2,582,174
2,582,175
Why is my setImage line not working?
<p>I have written 1 code for</p> <pre><code>-(IBAction)action:(UIEvent *)id { [act setImage:[UIImage imageNamed:@"down.png"] forState:UIControlStateHighlighted]; } </code></pre> <p>It's working, but I have written 1 code for</p> <pre><code>-(IBAction)action:(UIEvent *)id { [act setImage:[UIImage imageNamed:@"down.png"] forState:UIControlStateHighlighted]; } </code></pre> <p>And after that I had written code for communication with server.</p> <p>Now the <code>setImage:</code> line is not working.</p> <p>What should I do?</p>
iphone
[8]
4,978,984
4,978,985
formatting float to two decimal format
<p>I'm trying to print out a float value in plain text with two decimal values (if possible). For example, if I had 229806210.039999 in the database, then I would like to print it out as 229806210.04, but for some reason it's printing out in scientific notation: 2.29806208E8, which is incorrect in that the last two digit is 08 instead of 10. I tried to convert the number to double and currency format before printing it out but the number is still off (last two digit as 08 instead of 10). Is there a way to address this issue? Here's what I have now:</p> <pre><code>float amount = 0; amount = something.getAmount() //this will run the query //to retrieve the amount stored in database (i.e. 229806210.039999) Stringbuilder buffer = new StringBuilder(); buffer.append ("the amount = " + amount) emailObject.setBody(buffer.toString()); emailService.sendEmail(emailObject); </code></pre>
java
[1]
3,845,502
3,845,503
what does "*" mean in Python?
<p>I came across with a line in python.</p> <pre><code> self.window.resize(*self.winsize) </code></pre> <p>What does the "*" mean in this line? I haven't seen this in any python tutorial.</p>
python
[7]
476,636
476,637
Is arr.length=0 better than arr=[] in javascript while reseting
<p>I'm improving the performance of a HTML5 Game,while I reset some arrays,in order to reduce the garbage collection,I tend to use array.length=0(Yet I'm not sure if it's working in real world)<br> I did some tests to find out the speed of these 2 types of reset array here<br> <a href="http://tinkerbin.com/hqQvp5fQ" rel="nofollow">http://tinkerbin.com/hqQvp5fQ</a> </p>
javascript
[3]
3,555,855
3,555,856
Relative Date from Unix Timestamp with PHP
<p>I've seen a few other people talking about relative dates, but I still haven't managed to get it working properly.</p> <p>My script pulls a unix timestamp from a MySQL database and I would like the it to display something like this:</p> <blockquote> <p>2 minutes ago<br> 16 hours ago<br> On Tuesday 10th November at 7pm</p> </blockquote> <p>Thanks to anyone who can help.</p>
php
[2]
3,322,320
3,322,321
Passing data to Datagrid textbox in another form
<p>I open a datagrid when I double-click the textbox in my form1. I need to give two clicks on a cell of datagrid in form2 and when I click it already bring value to the textbox in form1. I've tried many ways no longer works, which he already ran automatically adds the value in the textbox before I click the cell, can anyone help?</p> <p>I tried this:</p> <p>in form1</p> <pre><code> Ncm Ncm formNcm = new (); formNcm.Show (); ncmcb.Text formNcm.getNCM = (); ncmcb.Focus (); </code></pre> <p>the form2</p> <p>public string getNCM () { = dataGridView1.CurrentCell.Value.ToString value2 string (); return value2; } Only this way it selects already own the value of the datagrid and I can not change, if I change it does not take the value for the textbox in form1</p>
c#
[0]
6,021,001
6,021,002
Why does the void operator invoke GetValue(expr) when it always evaluates to undefined?
<p><a href="http://ecma262-5.com/ELS5_Section_11.htm#Section_11.4.2" rel="nofollow">The void operator in JavaScript</a> will call the internal <code>GetValue(expr)</code>, but always return <code>undefined</code>, regardless of what value or expressions are. </p> <p>The spec says:</p> <blockquote> <p><strong>11.4.2 The void Operator</strong></p> <p>The production <em>UnaryExpression : void UnaryExpression</em> is evaluated as follows:</p> <ol> <li>Let expr be the result of evaluating <em>UnaryExpression</em>.</li> <li>Call <code>GetValue(expr)</code>.</li> <li>Return undefined.</li> </ol> <p>GetValue must be called even though its value is not used because it may have observable side-effects.</p> </blockquote> <p>My question is, why? What sort of observable side-effects could happen? Can we demonstrate how void might alter program flow, and discuss what would happen if we didn't run <code>GetValue</code>?</p>
javascript
[3]
4,202,908
4,202,909
boost c++ library object serialization problem
<p>The error was:</p> <pre><code>terminate called after throwing an instance of 'boost::archive::archive_exception what(): input stream error Aborted </code></pre> <p>I have these code in my main.c</p> <pre><code>Object *obj = new Object(); { std::ifstream ifs("FILEX"); boost::archive::text_iarchive ia(ifs); ia &gt;&gt; *obj; } </code></pre> <p>"FILEX" may or may not exist before, is this the cause of the error? or it is because I implemented the serialize method of Object class in a wrong way?</p>
c++
[6]
1,946,960
1,946,961
Creating a maze type application
<p>How would I go about building maze type app for the iPhone, I can't find any tutorials ag all. </p>
iphone
[8]
1,823,054
1,823,055
Image Displays Incorrectly On All Versions Of Internet Explorer
<p>I have the following Javascript code that resizes images on a page:</p> <pre><code> var max_size = 498; $(".slideimage").each(function(i) { if ($(this).height() &gt; $(this).width()) { var h = max_size; var w = Math.ceil($(this).width() / $(this).height() * max_size); } else { var w = max_size; var h = Math.ceil($(this).height() / $(this).width() * max_size); } $(this).css({ height: h, width: w }); }); </code></pre> <p>This code is contained within a $(document).ready() function.</p> <p>The images display fine when viewed in Chrome, Firefox, Safari and Opera. However, when the same page is viewed in Internet Explorer 7, 8 and 9, sometimes (well, 50% of the time) when the page is first loaded the image appears at the correct width, but the height is really really small. I would guesstimate the height to be around 100px high. But when the page is reloaded, the same image will display perfectly.</p> <p>It's a strange issue, and only happens in IE. Do I need to add or remove anything in that code?</p> <p>Cheers</p>
javascript
[3]
1,373,184
1,373,185
PC ram size using python or windows command line
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/276052/how-to-get-current-cpu-and-ram-usage-in-python">How to get current CPU and RAM usage in Python?</a> </p> </blockquote> <p>How to read pc ram size using python or wmi generator/Windows command line </p>
python
[7]
5,871,687
5,871,688
android developer console exception report platform not mentioned?
<p>I am new to android development. Recently I published a free app. after 70 to 80 downloads I have received a stack trace for a null pointer exception, </p> <p>But the platform is not mentioned it only says 'Other'.</p> <p>I am unable to reproduce the issue at my end and the stack trace is giving me no clue I have mentioned it here <a href="http://stackoverflow.com/questions/9929696/android-texttospeech-app-null-pointer-exception">Android TextToSpeech app null pointer exception</a> . I would try to test it on the platform where the problem has occurred. </p> <p>Can you please tell me what can I do to get the platform information if I get such errors ??</p> <p>Like do I need to incorporate any code in the app for scenarios where app crashes do get more detailed information about the environement ??</p> <p>Thanks, </p>
android
[4]
4,709,119
4,709,120
jQuery scrollTop function
<p>I have one page where the next page is fired when the user reaches the bottom of the page:</p> <pre><code>$(window).scroll(function(){ if ($(window).scrollTop() == $(document).height() - $(window).height()){ next_funtion(); } }); </code></pre> <p>However, I want next page to be fired when the user reaches 50% of the page height <em>or</em> 200 px from the top.</p>
jquery
[5]
3,045,068
3,045,069
C++, how many years experience?
<p>As a little background, I've been programming for a long time now using various languages, systems, etc.</p> <p>I've come across the old problem of a recruiter wanting to know "how many years experience" I have of C++. I'm a little stumped as I've bounced around it many times over a number of years. I don't think I can just add up the months/years. I'd put myself somewhere around the 3 - 5 year mark. I know it's a bit of a wide range, but I'm not really sure, with newer standards and libraries, the older stuff probably becomes deprecated.</p> <p>So, I wanted to ask your opinion. What would you expect a C++ programmer with (i) 3 years, and (ii) 5 years experience (mainly on Unix/Linux systems) to be able to do? Perhaps, more importantly, what would be the difference you would expect to see between a programmer of 3 years compared to 5 years (and above)?</p> <p>I know this is all a bit vague and the correct answer is, "it depends". But if anyone has a good opinion, I'd love to know.</p>
c++
[6]
2,785,122
2,785,123
Anyone Know any Java Bookmarking Site
<p>Hi Anyone know good website for learning and updating for Java learning. Is something like dotnetkicks.com same in Java. </p> <p>Please let me know.?</p>
java
[1]
3,082,956
3,082,957
Windows 7 Compatibility Issue in .NET
<p>When we create a SetUp &amp; Deployment project for our application in .net, the default folder for our application to be installed is being set as <code>C:\Program Files.....</code> Our application will run perfectly if we are using a Windows XP machine. But if we are using a Windows Vista or Windows 7 machine, the application wont run perfectly, especially if we are performing any file operations in our application...</p> <p>Can anyone find a solution for this problem? Is there any means to penetrate this User Account Control and File Access Controls of Windows 7? or can any1 give a choice to change the default installation folder from <code>[ProgramFilesFolder]\[Manufacturer]\[ProductName]</code> to some other folder?</p>
c#
[0]
3,220,916
3,220,917
Best way to get lat and long from gps and sending to a server to get data back using expandable list view android
<p>what is the best way to design an expandable list view, the details for the list view will come from server after the device sends the latitude and longitude to the server. </p> <p>I am early learner on AsyncTask, as User Interface might freeze when getting lat,long and sending the same to the server and getting back branch details. Some example, pointers would be helpful. Looking forward to reply. thanks.</p>
android
[4]
5,300,221
5,300,222
How to get JSON from the Blogger API filtered by category
<p>I am trying to get list of recent posts from a blog filtered by category completely on the client-side using jQuery. I'm really close and there have been a lot of posts here at stackoverflow which have been immensely helpful. Here is what I have so far... </p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function () { BloggerImporter.getPosts(); }); var BloggerImporter = { getPosts: function () { var feedURL = "http://blog.mild.net/feeds/posts/default"; var paras = { alt: 'json-in-script' }; $.ajax({ url: feedURL, type: 'get', dataType: "jsonp", success: BloggerImporter.onGotPostData, data: paras }); }, onGotPostData: function (data) { var feed = data.feed; var entries = feed.entry || []; var filteredEntries = $.grep(entries, function (value) { return value.category == 'Mild.Net' }); $("#blogTemplate").tmpl(filteredEntries).appendTo("#posts"); } } &lt;/script&gt; </code></pre> <p>Now, the problem is that each entry can have more than one category. So, in that jQuery grep function above, "category" is an array of objects, where each object has a "term" property. I need to filter by that "term" property, returning all the entries where that term property equals "Mild.Net".</p> <p>How do I do that?</p>
jquery
[5]
348,641
348,642
C# STARTUPINFO Flags to show UI for a process started from a Service in XP
<p>I'm launching a process from a windows service in XP, I'm just launching the process not trying to interact with it. The process starts but the UI does not show. I believe I need to set some flags in STARTUPINFO to make process visible, and hoping someone could show how and what flags to set.</p> <pre><code> sPath = @"C:\Windows\notepad.exe"; string Message = string.Empty; // Variables PROCESS_INFORMATION processInfo = new PROCESS_INFORMATION(); STARTUPINFO startInfo = new STARTUPINFO(); Boolean bResult = false; IntPtr hToken = IntPtr.Zero; try { // Logon user bResult = LogonUser( "Test", "VirtualXP-23639", "test", LogonType.LOGON32_LOGON_INTERACTIVE, LogonProvider.LOGON32_PROVIDER_DEFAULT, out hToken ); if (!bResult) { throw new Exception("Logon error #" + Marshal.GetLastWin32Error()); } // Create process startInfo.cb = Marshal.SizeOf(startInfo); startInfo.lpDesktop = "winsta0\\default"; bResult = CreateProcessAsUser( hToken, null, sPath, IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref startInfo, out processInfo ); if (!bResult) { Message = "Failed to Create Process on Desktop/Console. Code=" + Marshal.GetLastWin32Error().ToString(); Logging.LogError(Ascension.CM.Common.Enums.ApplicationModuleEnums.Service, Message, "Ascension.CM.ServiceWorker.ProcessLauncher.XpLaunchDesktopProcess", null); } } finally { // Close all handles CloseHandle(hToken); CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hThread); } } </code></pre>
c#
[0]
294,785
294,786
Mysterious javascript behaviour: unequal equals
<p>I really don't know how is it possible, and I couldn't reproduce the error in a simplified environment, say JSFiddle. But here is how it looks in my application. </p> <p>I'm trying to convert value that can be 'True', 'False' or 'something else' string into boolean if it is either True or False. In most cases it works just fine (although they may be a slicker way of doing the conversion) as it is shown on the picture below</p> <p><img src="http://i.stack.imgur.com/8yVbg.png" alt="enter image description here"></p> <p>however on occasion it fails and the value of the watch shows as follow:</p> <p><img src="http://i.stack.imgur.com/DBgIZ.png" alt="enter image description here"></p> <p>So suddenly string variable with a value of "True" is not equal to a "True" string literal. I'm lost. How is it possible? What am I missing here? </p> <p>Thanks in advance</p>
javascript
[3]
5,336
5,337
java.lang.NullPointerException error when selecting list item
<p>I receive the null pointer error when i tried to connect an activity to an fragment class.. activity class is an listactivity and when clicking on particular list, fragment class should open..any body has sample code or solution can provide me..my fragment class name is Termfragment..</p> <p>i used this code in my listactivity class:</p> <pre><code> public class HelpActivity extends ListActivity { Context myContext=this; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); String[] helplist = getResources().getStringArray(R.array.helplist); this.setListAdapter(new ArrayAdapter&lt;String&gt;(this, R.layout.list_view, R.id.label, helplist)); ListView lv = getListView(); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { TermFragment mytermfragment = new TermFragment(myContext); getSupportFragmentManager().beginTransaction().add(R.id.mytermfragment_container, mytermfragment).commit(); mytermfragment.show(getSupportFragmentManager(),"mytermfragment"); } }); } } </code></pre> <p>TermFragment class:</p> <pre><code> public class TermFragment extends DialogFragment implements DialogInterface.OnClickListener { private Context termContext; private AlertDialogListener mListener; public TermFragment(Context context) { termContext=context; } public interface AlertDialogListener { public void onDialogPositiveClick(DialogFragment dialogFragment); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Log.i("help","onCreateDialog"); AlertDialog.Builder builder = new AlertDialog.Builder(termContext); LayoutInflater inflater = getActivity().getLayoutInflater(); builder.setTitle("Terms"); builder.setView(inflater.inflate(R.layout.terms_view, null)); builder.setPositiveButton("I AGREE", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { mListener.onDialogPositiveClick(TermFragment.this); } }); AlertDialog alertDialog = builder.create(); Log.i("alert","alertDialog Created"); return alertDialog; } @Override public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } </code></pre> <p>}</p>
android
[4]
4,197,735
4,197,736
How to get the current seconds in the current month?
<p>I am trying to calculate the current second in the current month, but I'm having trouble creating a simple function that does it.</p> <p>My best guess involves using getTime() - the current milliseconds since January 1 1970 - and then subtracting X, where X is the number of milliseconds up to the end of the previous month. </p> <p>Can you help me think of a better way to do this? </p> <p>Thank you very much for your help.</p> <p>Cheers,</p>
javascript
[3]
3,596,869
3,596,870
Two error messages (I changed to mysqli, and now get different error messages!)
<p>Help!<br> 1. here is the page: <a href="http://www.bpanzullo.com/ThornAJAX/Ajaxindex.html" rel="nofollow">http://www.bpanzullo.com/ThornAJAX/Ajaxindex.html</a> The only name in the database now is Paul I get 2 error messages when I type in Paul:</p> <pre><code>Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/ftpbpan/public_html/ThornAJAX/info.php on line 10 which is: $query = mysqli_query("select * from peopleTwo where name='$name' limit 1"); Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/ftpbpan/public_html/ThornAJAX/info.php on line 15 which is: $num_rows = mysqli_num_rows($query); </code></pre> <p>Here is the code: </p> <p>*<em>','</em>***');</p> <pre><code>mysqli_select_db($connect, 'people'); if(strlen($_GET['user']) &gt;0){ $name = $_GET['user']; $query = mysqli_query("select * from peopleTwo where name='$name' limit 1"); if (false === $query) { die(mysql_error()); } $num_rows = mysqli_num_rows($query); if($num_rows == 1) { $row = mysqli_fetch_assoc($query); </code></pre>
php
[2]
5,287,387
5,287,388
Android Licensing Check Code... need direction...?
<p>I have been searching all over the web, reading MANY articles trying to find a completed working example of Android Licensing Check for my app. I have already setup PROguard and was wanting to use the LVL even though I read it is easily bypassable.. DEXguard, which cost money, is suppose to be better...</p> <p>Any rate, I found articles here and other places that seem to use an depreciated method from the LVL jar. </p> <p>Has this LVL been updated recently because all tutorials do not work in this same fashion.</p> <p>Here is article here I found but does not work for me: <a href="http://stackoverflow.com/questions/7452332/how-to-license-my-android-application">How to license my Android application?</a></p> <p>Errors on these lines state 'import cannot be resolved'</p> <pre><code>import android.vending.licensing.AESObfuscator; import com.android.vending.licensing.LicenseChecker; import com.android.vending.licensing.LicenseCheckerCallback; import com.android.vending.licensing.ServerManagedPolicy; </code></pre> <p>Any valid example with detail for current LVL would be VERY appreciated! Thank you all in advance. =]</p>
android
[4]
2,041,226
2,041,227
Twitter+Oauth on iPhone: How do you logout?
<p>I'm using <a href="http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master" rel="nofollow">http://github.com/bengottlieb/Twitter-OAuth-iPhone/tree/master</a> for Twitter+Oauth in my iPhone app. I'm trying to create a facebook connect like feature where can log in and log out of twitter. This paticular Twitter+Oauth implementation doesn't use sessions, so I'm not sure how this works. </p> <p>Does anyone have experience with this and if so how would I go about logging out?</p>
iphone
[8]
3,093,649
3,093,650
jQuery hover opacity IE8
<p>This is for a thumbnail - a simple opacity set then hover function.</p> <p>What am I missing? This is working in most browsers (including IE7) but in IE8 I get nothing.</p> <pre><code>&lt;script type="text/javascript"&gt; $(function() { // set opacity on page load $(".image-thumb").css("opacity", "0.6"); // on mouse over $(".image-thumb").hover( function() { // animate opacity to full $(this).stop().animate({ opacity: 1 }, "slow"); }, // on mouse out function() { // animate opacity $(this).stop().animate({ opacity: 0.6 }, "slow"); } ); }) &lt;/script&gt; </code></pre>
jquery
[5]
5,159,118
5,159,119
How to run a method in a loop only once?
<p>I'm using a switch as a state manager for my XNA game. The switch is a part of main update method, so it's run every frame. Sometimes I need to set a timer value and it should only be set once per method call. There are multiple methods that set the timer per case, so it can't use the current and previous state numbers to check if it's ok to overwrite previous time.</p> <pre><code>case "state 34": { SetTime(theTime); // should run only once // other things if (TheTimeisRight(time)) // runs every call { SetTime(theTime); // should run only once if (TheTimeisRight(time)) { /* some methods */ } } break; } </code></pre> <p>How can I make this work, or is there a better way to do this without going outside the switch? (changing SetTime method is ok, but I wouldn't like to clutter up the switch with additional code)</p>
c#
[0]
5,083,619
5,083,620
How to unify redundant tuples of a dictionary?
<pre><code>t = ({'x':1}, {'x':1}, {'y':2}) </code></pre> <p>I am unifying it using:</p> <pre><code>l = [] for i in t: if i not in l: l.append(i) tuple(l) </code></pre> <p>gives the result <code>({'x': 1}, {'y': 2})</code></p> <p>Is there any better way for that?</p> <p>Another Sample Input = <code>({'x':1, 'y':1}, {'x':3}, {'x':1, 'y':2}, {'x':1, 'y':2})</code> Sample output: <code>({'x':1, 'y':1}, {'x':3}, {'x':1, 'y':2})</code></p>
python
[7]
5,565,834
5,565,835
C++ basic type wrappers
<p>I'd like to make some basic wrapper classes around simple types in C++. Since you can't just inherit from base types like you should be able to, I'm just using a wrapper class. The problem is, I want to be able to cast directly to that type, since that cast would be totally valid. The compiler just doesn't let you and I can't find a way to tell it that it's ok without running a cast method which kills performance. Is there any way to do this?</p> <p>Here's what I have for the conversion constructor:</p> <pre><code>class Integer32 { public: Integer32(int value) { this-&gt;Value = value; } int Value; }; </code></pre> <p>Does the compiler know to skip that and just assign it directly from an int? How do I test this to make sure since it's rather important...</p>
c++
[6]
3,680,033
3,680,034
ASP.NET Question: Request.Url.Host property
<p>Does this property return, e.g., www1.domain.com, www2.domain.com, etc.</p> <p>And if there is any exception?</p> <p>Thanks.</p>
asp.net
[9]
2,850,856
2,850,857
Can not insert css image into pseudo :before
<p>I am trying to insert a background image into a header:before element, but jquery fails.</p> <p><strong>HTML</strong> content </p> <pre><code> &lt;a href="image.jpg" class="image-source"&gt;Try insert image into .header:before&lt;/a&gt; </code></pre> <p><strong>JS</strong></p> <pre><code> $('.image-source').click(function() { var src = $(this).attr('href'); // slash is okay $('.header:before').css('backgroundImage', 'url(/' + src + ')'); return false; }); </code></pre> <p>CSS:</p> <pre><code>.header { position: relative; background: url(anotherimage.jpg) no-repeat; } .header:before { position:absolute; top:0; left:0; right:0; bottom:0; margin:auto; min-width:50%; min-height:50%; content: ""; } </code></pre> <p>Does anyone know if I am dealing with a bug here, or missed an obvious? Note, I can not use <code>.header</code> itself, because I am working with multiple background image, thats why I need <code>:before</code>.</p> <p><strong>UPDATE:</strong> Might be this:</p> <ul> <li><p><a href="http://www.w3.org/TR/2009/CR-CSS2-20090908/generate.html#x2" rel="nofollow">http://www.w3.org/TR/2009/CR-CSS2-20090908/generate.html#x2</a></p></li> <li><p><a href="http://stackoverflow.com/questions/5814810/target-before-and-after-pseudo-elements-with-jquery#comment6671974_5814824">Target :before and :after pseudo-elements with jQuery</a></p></li> </ul>
jquery
[5]
753,756
753,757
Return values from one script to another script
<p>I have the following script that will run each script (sequentially) in a directory:</p> <pre><code>import os directory = [] for dirpath, dirnames, filenames in os.walk("path\to\scripts"): for filename in [f for f in filenames if f.endswith(".py")]: directory.append(os.path.join(dirpath, filename)) for entry in directory: execfile(entry) print x </code></pre> <p>my scripts look like this:</p> <pre><code>def script1(): x = "script 1 ran" return x script1() </code></pre> <p>When <code>print x</code> is called, it says x is not defined. I'm just curious if there is a way to return values so that the parent script can access the data. </p>
python
[7]
711,138
711,139
Hide a character in text with jQuery?
<p>I want to change some text which says 'Name:' to 'Name'. In other words, I just want to hide the ':'.</p> <p>Can jQuery select a character or word within a div? If so it would be easy to hide the ':' character or if needs be replace the text to same word but without that character.</p> <p>Thanks </p>
jquery
[5]
4,461,163
4,461,164
how to customize subview that supports only landscape mode
<p>i have one view with 4 subviews.</p> <p>my application will supports both portrayed and landscape modes.</p> <p>Among the 4 subviews,one of the view is support only for portrayed.</p> <p>how can i done this.</p> <p>Thank u in advance. </p>
iphone
[8]
2,500,749
2,500,750
appending a string to another string
<p>I have 2 lists :</p> <p>list1 contains "T" "F" "T" "T"</p> <p>list2 contains "a" "b" "c" "d"</p> <p>I want to create a third list such that I append element1 in list1 to element1 in list2.</p> <p>So list3 would be the following: "Ta" "Fb" "Tc" "Td"</p> <p>How can i do that?</p>
python
[7]
6,025,802
6,025,803
jQuery version issue causes menu to stop working in IE 6
<p>I found a nice multi-level menu that I would like to use because it's cross-browser friendly AND it works in IE 6. However, it only works correctly in IE 6 with jQuery versions up to 1.3.2. Newer versions cause a problem that prevents the sub-sub-menu items to stop working. There must have been a change in jQuery 1.4 that caused this problem, but I haven't been able to find much information that addresses this issue. I'm hoping that someone that's been using jQuery since version 1.3 encountered a similar issue when 1.4 was released and might be able to clue me in. </p> <p>I posted an example including the code here: </p> <p><a href="http://nunyabiz.freeiz.com/jquery_slide_menu/menu.php" rel="nofollow">http://nunyabiz.freeiz.com/jquery_slide_menu/menu.php</a></p> <p>Let me know if I can provide any additional information that I forgot to include initially.</p> <p>Thanks in advance...</p> <p>Paul</p>
jquery
[5]
5,118,358
5,118,359
How to sort 3D array in c#, with each row is specific to one entry if 1D array?
<p>Please guide me as how to sort an array with taking into consideration that each row is specific to one specific column value. For example,</p> <p>1D array<br> 5<br> 3<br> 4 </p> <p>2D array<br> 1,2,3<br> 3,4,5<br> 6,7,8 </p> <p>In above example,let say, 5 (In 1Darray) is associated with the first row of 2d array (1,2,3). Similary, 3 in 1d array is associated with second row of 2d array(3,4,5).And similarly for the third entry of 4 (of 1d array). Now I want to sort the 1D array with taking into consideration that the associated rows with each 1D array element also change accordingly. I mean its kind of auto-arrangment of rows with change of column values. Please guide Regards Asad</p>
c#
[0]
1,175,238
1,175,239
User login before executing Java app
<p>I'm trying to create a login before users use my Java app and I'm stuck. I've made a file called login.php on my website (wordpress user database) but I'm confused as what to do on the Java end. Basically I want it to log in, and then check to see if they have permissions to use the specific app.</p> <p>The PHP is fine, just dont know what I'm doing on the Java side..</p>
java
[1]
1,251,671
1,251,672
Search box on top like browser
<p>How can I place the search box to stay on the top like in the default browser in android? I don't mean search widget, I mean a search dialog that are persistant on the top of the activity.</p>
android
[4]
324,152
324,153
Set selected radio from radio group with a value
<p>Why am I struggling with this?</p> <p>I have a value: 5</p> <p>How do I check the radio button of group "mygroup" with the value of 5?</p> <pre><code>$("input[name=mygroup]").val(5); // doesn't work? </code></pre>
jquery
[5]
5,814,105
5,814,106
dependency between singletons in different assemblies
<p>singleton B initializes singleton A. singleton A has no knowledge of B. How can we use A and be sure that B has done its initialization routine first? </p> <p>B and A are in different assemblies and are maintained by different teams.</p> <p>Trying to keep the implementations completely seperate.</p> <hr> <p>The best answer seems to be just don't. Here's what I'm thinking thought:</p> <p>kick off the initialisation via a registration class that implements a certain interface. If a DoSomething gets called, and T is in an assembly we haven't seen before, then we search for a class with the given IRegistration interface. </p> <p>So... that would get rid of the dependency. It'd use reflection. We'd have to look up the types assembly home each time a method got called, but not too high a price to pay perhaps</p>
c#
[0]
5,530,400
5,530,401
Unique number list
<p>I have an HTML form from which a user selects numbers using checkboxes. The numbers are put into an PHP array like this:</p> <pre><code>&lt;input type="checkbox" name="formnumber[]" value="1" /&gt; </code></pre> <p>There are 24 numbers to pick from 1 to 24. I want to output a list of 10 unique lines with 5 unique numbers per line using the numbers from the array.</p> <p>e.g.: I pick 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 from the form. The output would look like this:</p> <pre class="lang-none prettyprint-override"><code>2 16 4 1 15 10 13 2 4 5 12 1 3 16 11 etc etc (10 lines) </code></pre>
php
[2]
3,331,096
3,331,097
What are helper objects in java?
<p>Hi I come across few of the times called helper objects... can anybody elaborate what are those helper objects and why do we need them?</p>
java
[1]
3,482,396
3,482,397
www.domain.com not displaying website but www.domain.com/index.php displays it correctly
<p>I have a Php website and I recently renewed the domain and hosting. When I checked www.domain.com it it not displaying website but when I check for www.domain.com/index.php displays it correctly.. what shall I do to make this correct.</p>
php
[2]
4,242,787
4,242,788
Drag and drop/ dropping elements issue
<p>Hello i am developing a shopping cart and i would like to send values to each of my fields in the basket. I have the example here: <a href="http://jsfiddle.net/ckSPG/1/" rel="nofollow">http://jsfiddle.net/ckSPG/1/</a></p> <p>I would like the data to be organized:-? </p> <pre><code>$(function() { $(".draggable").draggable({ revert: true }); $("#droppable").droppable({ over: function() { $(this).css('backgroundColor', '#cedae3'); }, out: function() { $(this).css('backgroundColor', '#CDAF95'); }, drop: function(e, ui) { var p = $("#name").text();; var name = $(ui.draggable).text(); //var price = $(ui.draggable).text(); addlist(name); } }); }); function addlist(name) { $("#droppable").append(name); } </code></pre>
jquery
[5]
3,324,463
3,324,464
Python math output incorrect
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1787249/why-doesnt-this-division-work-in-python">Why doesn&#39;t this division work in python?</a> </p> </blockquote> <p>A simple problem I'm having (I Think) The following statement:</p> <pre><code> print (4950*8)/(((4950*8)/10000000*(1538/1460))+0.1/1000)/1000 </code></pre> <p>Gives me 396000.0.</p> <p>But on a Calculator I get 9270.614192621.</p> <p>If someone could point out what I'm doing wrong in the code that would be great.</p> <p>Thanks.</p>
python
[7]