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,973,864
1,973,865
How to check for key in a Map irrespective of the case?
<p>I want to know whether a particular key is present in a HashMap, so i am using containsKey(key) method. But it is case sensitive ie it does not returns true if there is a key with Name and i am searching for name. So is there any way i can know without bothering the case of the key?</p> <p>thanks</p>
java
[1]
1,284,761
1,284,762
A static variable trying to access another static variable
<p>I was wondering, whether the following code are safe.</p> <pre><code>public class GUIBundle { // The technique known as the initialization on demand holder idiom, // is as lazy as possible. // http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom //private static class BundleHolder { // private static final ResourceBundle bundle = ResourceBundle.getBundle("org.yccheok.jstock.data.gui"); //} private static final ResourceBundle bundle = ResourceBundle.getBundle("org.yccheok.jstock.data.gui"); private GUIBundle() { } public static String getString(String key) { // return BundleHolder.bundle.getString(key); return bundle.getString(key); } } </code></pre> <hr> <pre><code>public class SellPortfolioChartJDialog extends javax.swing.JDialog { private static final String[] cNames = new String[] { GUIBundle.getString("BuyPortfolioTreeTableModel_NetGainValue") }; } </code></pre> <hr> <p>Since cNames is within static scope, is it safe for it to access static bundle? Does it make any different whether I am using lazy initialization technique?</p> <p>I remember I came across an article (I lost the article anyway) talking about nondeterministic of initialization order of static variables. I am not sure whether the nondeterministic of initialization order of static variables, applied to the above case?</p>
java
[1]
1,439,349
1,439,350
Android - Installing apk from SD cord
<p>I'm distributing my android application (apk) along with some encrypted audio files in SD card. After installing the apk on the android phone, i want the apk to be deleted automatically. Actually I dont want the apk to be copied by others. Is there any solution such that apk cant be installed or copied by others?</p>
android
[4]
1,367,266
1,367,267
Name isn't found in my Python application
<pre><code>keepProgramRunning = True while keepProgramRunning: print "Welcome to the Calculator!" print "Please choose what you'd like to do:" print "0: Addition" print "1: Subtraction" print "2: Multiplication" print "3: Division" #Capture the menu choice. choice = raw_input() #Capture the numbers you want to work with. numberA = raw_input("Enter your first number: ") numberB = raw_input("Enter your second number: ") if choice == "0": print "Your result is:" print Addition(numberA, numberB) elif choice == "1": print "Your result is:" print Subtraction(numberA, numberB) elif choice == "2": print "Your result is:" print Multiplication(numberA, numberB) elif choice == "3": print "Your result is:" print Division(numberA, numberB) else: print "Please choose a valid option." def Addition(a, b): return a + b def Subtraction(a, b): return a - b def Multiplication(a, b): return a * b def Division(a, b): return a / b </code></pre> <p>Here's the error:</p> <pre><code>Traceback (most recent call last): File "C:\Users\Sergio.Tapia\Documents\NetBeansProjects\Tutorials\src\tutorials.py", line 23, in &lt;module&gt; print Addition(numberA, numberB) NameError: name 'Addition' is not defined </code></pre> <p>Thanks for the help!</p> <p>Ps. I realize the loop will never end, I haven't added the menu option yet. :P</p>
python
[7]
5,792,954
5,792,955
Remove/Toggle Divs
<p>How do remove a div by clicking on it, but hide or display any of the divs with name or age in the ID.</p> <p>One checkbox should toggle any divs with "name" at the beginning of the ID, and another checkbox should toggle any divs with "age"at the beginning of the ID</p> <pre><code>&lt;div id="container"&gt; &lt;div id="name-254"&gt;&lt;/div&gt; &lt;div id="age-645"&gt;&lt;/div&gt; &lt;div id="name-142"&gt;&lt;/div&gt; &lt;div id="name-341"&gt;&lt;/div&gt; &lt;div id="age-341"&gt;&lt;/div&gt; &lt;div id="name-341"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
jquery
[5]
1,076,633
1,076,634
Upload data when Wi-Fi is connected?
<p>I'm making an app that is essentially a web form. I fill it out and send it to a website to be processed. But I only want it to send the data when connected to wifi.</p> <p>I was thinking of putting the data into a tinyDB then running a check for wifi immediately. If connected it would submit the form and delete the db entry. I'd probably also run a check when the app is loaded and closed. It's important that I don't lose the data.</p> <p>Is there a better way to do this?</p>
android
[4]
3,767,661
3,767,662
Android SDK Align two elements in center
<p>Im trying to align two elements in my xml file. I want to display a TextView called "Description" and a TextView called "Value" on the same line. The Description should right aligned to the center, the Value should be left aligned the center. But the following gravity doesnt seem to affect them.<br/><br/> I assume I should avoid using AbsoluteLayout because of different screen sizes.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="wrap_content" &gt; &lt;TextView android:id="@+id/TextViewDescription" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:text="@+id/TextView01" &gt; &lt;/TextView&gt; &lt;TextView android:id="@+id/TextViewValue" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="left" android:text="@+id/TextView02" &gt; &lt;/TextView&gt; &lt;/LinearLayout&gt; </code></pre> <p>I also looked at TableLayout but struggled with that too.</p> <p>What is the correct way to create a set of description/values down the screen that are center aligned so they appear fine on both portrait and landscape view?</p>
android
[4]
114,519
114,520
Async task thread source
<p>I'm wondering about the relation between async task and threads? Each one create a new one, Is it cached, pooled.</p>
android
[4]
892,856
892,857
How to condense this function?
<pre><code>def average(tup): """ ugiufh """ total = ((int(tup[0]) + int(tup[1]) + int(tup[2]))/3, (int(tup[0]) + int(tup[1]) + int(tup[2]))/3, (int(tup[0]) + int(tup[1]) + int(tup[2]))/3) return total </code></pre> <p>I am writing a function to average out three element in a tuple which means if the original tuple = (1, 2, 3) which give me tuple = (2, 2, 2)</p> <p>My question is there any way to condense what wrote to give me the same answer? If yes, how to condense it?</p> <p>Thanks</p>
python
[7]
4,112,488
4,112,489
Can anyone explain this snippet of Javascript?
<p>Can anyone explain the following code? Forget the sine and cosine parts. Is it trying to build a space for the object?</p> <pre><code>objectsInScene = new Array(); for (var i=space; i&lt;180; i+=space) { for (var angle=0; angle&lt;360; angle+=space) { var object = {}; var x = Math.sin(radian*i)*radius; object.x = Math.cos(angle*radian)*x; object.y = Math.cos(radian*i)*radius; object.z = Math.sin(angle*radian)*x; objectsInScene.push(object); } } </code></pre>
javascript
[3]
5,793,845
5,793,846
sort array list from second item android
<p>i have a array list for using it in spinner ,i have first value i spinner as title and i want to sort array list from second item in the spinner but i dont know how to do this i am using below trick but it sort whole array list including first item which is title so how to statr sorting from second item... my code is below...</p> <pre><code> // this is my title ie. "provincia" String select2= "Provincia"; if(!estado1.contains(select2)){ estado1.add(select2); } for (int i = 0; i &lt; sitesList1.getEstado().size(); i++) { if(!estado1.contains(sitesList1.getEstado().get(i))) { estado1.add(sitesList1.getEstado().get(i)); Collections.sort(estado1); } </code></pre> <p>use below code for show it in spinner...</p> <pre><code> final ArrayList&lt;String&gt; estado1 = MainMenu.barrio1; final Spinner estado11 = (Spinner) findViewById(R.id.Spinner04); ArrayAdapter&lt;String&gt; adapterbarrio = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_item, estado1) estado11.setAdapter(adapterbarrio); </code></pre>
android
[4]
5,060,485
5,060,486
Accessing App.config in a location different from the binary
<p>In a .NET Win console application, I would like to access an App.config file in a location different from the console application binary. For example, how can C:\bin\Text.exe get its settings from C:\Test.exe.config?</p>
c#
[0]
5,585,376
5,585,377
How can I get information from JVM about what classes are loaded along with the specs of all the loaded class?
<p>I want to get the information of all the classes loaded, <strong>as well as specs of the classes</strong>, such as what methods and their signature, what kind of exceptions can a method throw. etc. I know there are previous posts saying how to get all the classes loaded, but not other detailed information, so is there any available thing already to get what I want?</p>
java
[1]
3,376,069
3,376,070
How to check if a file exists with stat in visual studio c++ 2010?
<p>This is the code I have for checking if a file exists in my visual studio 2010 c++ project:</p> <pre><code>bool GLSLProgram::fileExists( const string &amp; fileName ) { struct stat info; int ret = -1; ret = stat(fileName.c_str(), &amp;info); return 0 == ret; } </code></pre> <p>I am not sure why it returns false for "shaders/color.vert" when that file really exists, and shaders is a folder in my project main folder.</p> <p>Can you see something wrong?</p> <p>THanks</p>
c++
[6]
2,570,372
2,570,373
How to change custom component height programatically
<p>I've prepared custom component based on LinearLayout. Whole component is defined in XML. Currently to use it you have to write: </p> <pre><code>&lt;com.xxx.android.components.TopMenu android:layout_width="fill_parent" android:layout_height="44dp" /&gt; </code></pre> <p>Is it possible to set width and height in the java constructor? So it would be possible to write just: </p> <pre><code>&lt;com.xxx.android.components.TopMenu /&gt; </code></pre> <p>I've tried to modify and set LayoutParams, but it didn't work for me.</p>
android
[4]
4,402,302
4,402,303
Need to ping remote server programmatically and store output of telnet
<p>Guys I am supposed to ping remote server Programmatically. Also I have to store output of telnet .I have recieved a mail where I am supposed to Share the following things but I dont know how to do these things.I have to share output of following activities of server where my site is hosted and from this server I have to ping another server i.e.203.189.91.127</p> <ol> <li><p>Ping to 203.189.91.127</p></li> <li><p>Output of telnet 203.189.91.127 9090</p></li> <li><p>Screen shot of <a href="http://www.whatismyip.com" rel="nofollow">http://www.whatismyip.com</a></p></li> </ol> <p>Guys I dont know how to do this help would be strongly appreciated</p>
c#
[0]
327,945
327,946
Application hangs when contact display
<p>I want to fetch my phone contact name,number and email in single query. Is that possible to fetch all in 1 Query?</p> <p>I have almost 1000 contacts in my phone and its get hanged when I tried following line of code to display my contact:</p> <pre><code> Cursor cursor = this.getContentResolver().query(intent.getData(), null, null, null,null); while (cursor.moveToNext()) { String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID)); hasPhone = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); if ( hasPhone.equalsIgnoreCase("1")) hasPhone = "true"; else hasPhone = "false" ; if (Boolean.parseBoolean(hasPhone)) { Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = "+ contactId,null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE NOCASE"); while (phones.moveToNext()) { String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); String name = phones.getString(phones.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); } phones.close(); } // Find Email Addresses Cursor emails = getContentResolver().query(ContactsContract.CommonDataKinds.Email.CONTENT_URI,null, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = " + contactId,null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE NOCASE");// contactId+ " DESC"); while (emails.moveToNext()) { String emailAddress = emails.getString(emails.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA)); String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME)); } emails.close(); } //while (cursor.moveToNext()) </code></pre>
android
[4]
4,702,690
4,702,691
How to composite argb image data on top of xrgb image data
<p>I have a pointer to an 32bit argb image's pixel data and a 32bit xrgb image's pixel data. How can I composite the argb on top of xrgb image while making use of the alpha component?</p> <p>Visual Studio 2008 C++</p> <p>Edit:</p> <p>Is there a quicker (faster processing) way to do the compositing than this:</p> <pre><code> float alpha = (float)Overlay[3] / 255; float oneLessAlpha = 1 - alpha; Destination[2] = (Overlay[2] * alpha + Background[2] * oneLessAlpha); Destination[1] = (Overlay[1] * alpha + Background[1] * oneLessAlpha); Destination[0] = (Overlay[0] * alpha + Background[0] * oneLessAlpha); </code></pre>
c++
[6]
2,224,254
2,224,255
How do I select an html-select jquery
<p>My html is such:</p> <pre><code>&lt;select id="slctDiv2" class="slct"&gt;&lt;option value="0"&gt;Any&lt;/option&gt; &lt;option value="1"&gt;Administration&lt;/option&gt;&lt;option value="2"&gt;Collections&lt;/option&gt; &lt;option value="3"&gt;Distribution&lt;/option&gt;&lt;option value="4"&gt;Engineering&lt;/option&gt; &lt;option value="5"&gt;Treatment&lt;/option&gt;&lt;/select&gt; </code></pre> <p>How do I get the ID of the select item (in this case "slctDiv2") if I found the selected option via jquery.</p> <pre><code>$('#slctDiv1,#slctDiv2').change(function(){ if($(this).parent().attr('id')=='slctDiv2'){ //do this }else{ //do that } }); </code></pre> <p>Using the parent function doesn't work.</p>
jquery
[5]
446,058
446,059
for loop in Python
<p>I am new to Python </p> <p>In C/C++, I can have the following loop <code>for(int k = 1; k &lt;= c ; k +=2)</code></p> <p>How do do the same thing in Python ?</p> <p>I can do this <code>for k in range(1,c):</code> in Python, which would be identical to <code>for(int k = 1; k &lt;= c ; k++)</code> in C/C++</p> <p>Thanks !</p>
python
[7]
4,445,098
4,445,099
How best to store game config variables in java
<p>I'm writing a small java game and am storing global game settings in a class structure like the one below:</p> <pre><code>public class Globals { public static int tileSize = 16; public static String screenshotDir = "..\\somepath\\.."; public static String screenshotNameFormat = "gameNamexxx.png"; public static int maxParticles = 300; public static float gravity = 980f; // etc } </code></pre> <p>While this is very convenient to work with I'd like to know if this is the accepted pattern.</p>
java
[1]
4,497,646
4,497,647
in Android, when a service and activity use the same static class, is the class 'created' twice?
<p>this is just a general knowledge question - out of curiosity...</p> <p>In Android, when an activity and a service use the same static class (i.e. singleton) does the service end up getting its own 'version' of the class ?</p> <p>For example, I put all of my global constants into a static class. Are these memory locations created once for activities and again for separate processes such as a service ?</p>
android
[4]
2,856,961
2,856,962
java webservice using soap
<p>I am developing Soap based web services using Java. Can anyone please let me know how to use the server side webservice for user login and authenticate the client who is consuming the web services?</p>
android
[4]
5,961,607
5,961,608
Conditional application launch view
<p>My app is driven by a UITabBarController embedded with a UINavigationController for each individual view within each active tab.</p> <p>When the app is launched the first time, I'd like to present a separate settings view without a visible TabBar. After the user has completed the setup, they'd be taken to the main view with the TabBar. Also, once configured, the initial configuration view won't be accessible again from within the app although there will be a separate settings section that the user can modify their preferences.</p> <p>What's a good pattern for doing this? </p>
iphone
[8]
5,103,639
5,103,640
please explain the apply and call methods in javascript
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/1986896/what-is-the-difference-between-call-and-apply">What is the difference between call and apply?</a> </p> </blockquote> <p>What is the main difference between apply and call methods... I go through the web but unable to find the best solution.. Please help me friends...</p>
javascript
[3]
2,091,946
2,091,947
Python Convert ordered list of relative changes to absolute changes
<p>Let's assume I have a set of objects containing: (relative change, time of change):</p> <pre><code>(+1,0) (-1, 1) (+1,3) (+1, 3) (-1, 5) (+1, 9) </code></pre> <p>Now I want to replace the relative changes by their absolute value, starting at 0:</p> <pre><code>(1,0) (0, 1) (1,3) (2, 3) (1, 5) (2, 9) 0+1 0+1-1 0+1-1+1 ... </code></pre> <p>What is the best way to do this? Is there a Python function that allows me to</p> <ul> <li>Iterate over a (ordered) list of objects</li> <li>Internally store an absolute value</li> <li>read the change from each object, update the internal absolute value</li> <li>replace the relative change with the absolute value</li> </ul>
python
[7]
774,636
774,637
What is the simplest way to convert a const char[] to a string in c++
<p>Is there a simple way of creating a std::string out of an const char[] ?</p> <p>I mean something simpler then:</p> <pre><code>std::stringstream stream; stream &lt;&lt; const_char; std::string string = stream.str(); </code></pre>
c++
[6]
681,048
681,049
PHP Commenting, Which way is correct?
<p>I have</p> <pre><code>/** * This happens when the user is logged in. */ </code></pre> <p>but is it meant to be like that? Like is the spacing correct? Because I've seen</p> <pre><code>/** * This happens when the user is logged in. */ </code></pre> <p>and others.</p> <p>Which is classed as correct?</p>
php
[2]
3,197,799
3,197,800
sort hashtable by values
<p>If I have a Hashtable and I want to sort it by the value, i.e: integer in a descending order. How can I do this and be able to print through all of the key - value pair?</p>
java
[1]
5,207,815
5,207,816
Android: What should be the phone number format while sending an SMS?
<p>My app sends an SMS and I need to know about the <code>sendTextMessage</code> method in the <code>SmsManager</code> class : </p> <p>A. what happens if I give a String that is not a phone number ?</p> <p>B. what should be the formatting of the number ?</p> <p>(for example : 052-2222222, 0522-222-222, +97252222222 etc' , will the <code>SmsManager</code> accept all of them ?)</p>
android
[4]
3,065,961
3,065,962
java creating object suggestion
<p>I have some doubts/questions regarding the object creation. I have heard that objects should not be created in the loop. Whats wrong with the creation of objects inside the loop? Whats the difference between creating outside the loop and creating inside the loop?</p> <p>Please consider the following example.</p> <pre><code>public java.util.List&lt;Object&gt; objectCreationTest(){ java.util.List&lt;Object&gt; objectList =new java.util. ArrayList&lt;Object&gt;(); Object obj = null; for(int i = 0 ; i &lt;1000;i++){ Object e = new Object(); //1 --&gt; Is this object creation wrong? obj = new Object(); //2 --&gt; Is this right way to create? objectList.add(e ); } return objectList ; } </code></pre> <p>Please suggest me which way I have to follow? </p>
java
[1]
4,817,005
4,817,006
Calculating Internet Speed in android
<p>I am working with an App which contains web service things.</p> <p>In that I need to know the status when the Internet speed is low. How to find the internet speed level in Android?</p> <p>For example, Consider if I am using 2Mbps connection in my cell phone and when it slows to 50Kbps I need to notice that situation by making a Toast or Alert.</p> <p>Thanks.</p>
android
[4]
3,921,481
3,921,482
Is it possible to have a variable accessible and modified by different functions of the same class in PHP?
<p>I declare a variable as private in the body of the class and set it to null. After that, I access the variable by a function in the class and initialize it. When I try to read the value of this variable from another function, it's always null! Did I miss something?</p>
php
[2]
4,961,949
4,961,950
How to access to given element in Json
<p>I am new to Json. please tell me how to access following element. this is my Json </p> <pre><code>var data = {"student":[{"fname":"mad", "sname":"cha"}, {"fname":"sun", "sname":"ban"}, {"fname":"sha", "sname":"kiri"}]}; </code></pre> <p>so how I access to the <code>"mad"</code>value.</p> <p>actually this is what I trying to do</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;script&gt; function click_me(){ var data = {"student":[{"fname":"mad", "sname":"cha"}, {"fname":"sun", "sname":"ban"}, {"fname":"sha", "sname":"kiri"}]}; localStorage.setItem('my_name',data); alert('OK'); } function show_me(){ var x = localStorage.getItem('my_name'); x = x.student[0].fname; alert(x); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="button" name="btn" value="Click" onclick="click_me()"&gt; &lt;input type="button" name="btn" value="show_me" onclick="show_me()"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
javascript
[3]
5,684,790
5,684,791
Modify code for javascript from php
<p>I am using a series of check boxes all are with different name that is checkbox1....checkbox40. I am generating a series of sting with '1' and '0' that is if check box is checked than sting will be concatenated with '1' else it will be concatenated with '0'. I have successfully implemented idea for PHP but as now I am using Ajax I want to develop same code for java script. My PHP code for that is</p> <pre><code>if (isset($_POST[submit])) { for ($i=1; $i&lt;41; $i++) { $walue = "restriction".$i; if(isset($_POST[$walue])) {$val .="1";} else {$val .="0";} } } echo "Equivalent String: ".$val."&lt;p&gt;"; </code></pre> <p>for implementing it using Javascript I have called a function on submit event of form. </p> <p>My form id is <code>theForm</code> and my checkboxes name is <code>restriction1....restriction40</code>. Please give me hint to implement the idea.</p>
javascript
[3]
1,787,749
1,787,750
Multiple page technique
<p>Six years ago I wrote an large web application. It was my very first php program, and it grew, and grew. I used a lot of forms, and some very (atrocious) techniques to give an AJAX "look" to the site, and to handle multiple users with various permissions.</p> <p>I am looking to expand this, and sell it to other companies in the field, but I need to seriously modernize it. </p> <p>Currently, it loads index.php where you log in. The user can then select from various "students" or "participants" (We work with people with disabilities). From there, you can select different lesson plans or life skills that are being worked on. There are many other branches as well.</p> <p>At each stage, a different page is served: Sel_Paricipant.php, Sel_Program.php, etc.</p> <p>Are there any fundamental problems with doing it this way? If so, what are some good techniques for eliminating this, so that people only see the TLD in their address bar?</p> <p>Thanks in advance. --Dave</p>
php
[2]
5,066,588
5,066,589
iPhone: NSTimer doesn't repeat during server request happening
<p>I am having the below timer code for showing progress increment in the real time. But, during this progress view, i'm downloading some huge data from server. So, the progress bar starts little bit percentage, and then stops forever, even though i gave repeats=yes, doesn't fully viewing the progress bar increment. Could someone please advise what i am doing wrong? I tried putting my timer code in separate thread and then in mainthread, but both are not resolving my issue.</p> <pre><code>-(void)downloadProgresss { progressView.progress=0.1; progressTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(progressTimerTick:) userInfo:nil repeats:YES]; } - (void)progressTimerTick:(NSTimer*)timer { NSLog(@"progressTimerTick called...."); progressValue=progressValue+0.3; progressView.progress=progressValue; } </code></pre> <p>Thank you!</p>
iphone
[8]
3,351,418
3,351,419
Write text or HTML to file on disk
<p>I want my PHP script to write a file to my directory. What this would do is write a file called <code>hello.php</code>, <code>hello.txt</code>, or <code>hello.html</code> and put it in a specific directory.</p> <p>The reason is so that when a user fills out their name and age on a form, it would generate a <code>.html</code> file that would be a basic outline, including theirname and age from the form data.</p>
php
[2]
3,622,812
3,622,813
Using .wrap() around several elements
<p>I need to add another <strong>div</strong> around items with class <strong>.item</strong></p> <pre><code>&lt;div id="container"&gt; &lt;div class="item"&gt;Item 1&lt;/div&gt; &lt;div class="item"&gt;Item 2&lt;/div&gt; &lt;div class="item"&gt;Item 3&lt;/div&gt; &lt;/div&gt; &lt;div id="container"&gt; &lt;div id="wrapper"&gt; &lt;div class="item"&gt;Item 1&lt;/div&gt; &lt;div class="item"&gt;Item 2&lt;/div&gt; &lt;div class="item"&gt;Item 3&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I came across .wrap() but it wraps each .item in that div. How do I add just one for the group?</p>
jquery
[5]
3,729,553
3,729,554
PackageInstallationReceiver can't remove temporary apk file
<p>A friend got an error on his HTC Desire trying to install an app. He uses eclipse for installing.</p> <p>The error from LogCat:</p> <pre><code>E/PackageInstallationReceiver( 244): Remove /data/local/tmp/my.package.apk Fail! W/System.err( 244): java.io.IOException: Error running exec(). </code></pre> <p>I used adb shell to see whats inside this tmp folder. And there was no such apk. So I renamed another, but the error stays which means, that he never really tries to delete this apk, right?</p> <p>The same code runs fine on the emulator and my Nexus One. Some suggestions?</p>
android
[4]
3,808,425
3,808,426
What is the best way to store a non serializable object instance in android?
<p>i have a class that inherits from BroadcastReceiver and is bound to listen for PHONE_STATE events. inside of the onReceive method, i need an object instance that has to be always the exact same (at least between the state ringing and the next occurrence of ide / offhook). that means i need to store the object somewhere. it can not be serialized nor anyhow be stored in a database or in the SharedPreferences.</p> <p>i thought about 2 different approaches:</p> <ol> <li>using a static variable. downside: no one knows at which point android is going to delete it.</li> <li>using a service. downside: the service needs to be started at the first call and then bound. this is an async call and i might have to wait for an uncertain time. also it seems kinda wrong to use a service just to store one single object.</li> </ol> <p>any other, better ideas?</p>
android
[4]
3,093,677
3,093,678
Sets module deprecated warning
<p>When I run my python script I get the following warning</p> <pre><code>DeprecationWarning: the sets module is deprecated </code></pre> <p>How do I fix this?</p>
python
[7]
4,022,721
4,022,722
How do I load a page in javascript from its source string?
<p>if I have a javascript variable:</p> <pre><code>var page = "&lt;!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"&gt;&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Example&lt;/body&gt;&lt;/html&gt;" </code></pre> <p>and I want to load that page, what do I do?</p>
javascript
[3]
109,151
109,152
go to external site if it's an hyperlink
<p>I have a "view" link to an aspx page in a gridview for each row. </p> <p>Depending on the type of resource 1)File or 2)Hyperlink , it should either download the file or go to the hyperlink mentioned.</p> <pre><code>&lt;asp:TemplateField HeaderText="View"&gt; &lt;ItemTemplate&gt; &lt;a id="View" href="../resources/ResourceFile.aspx?Id=&lt;%# Eval("Id")%&gt;" target="_blank"&gt;View&lt;/a&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; </code></pre> <p>I got it working for the file type but how do I redirect to an external link like "www.yahoo.com" if it's an hyperlink.</p> <p>In the code behind </p> <pre><code>if(resource.ResourceType.ToLower().Equals("hyperlink")){ // what should i do here? // the link is stored in resource.value } </code></pre> <p>EDIT : Figured that the link should have an http:// prefix to work. Feeling stupid now :)</p>
asp.net
[9]
5,631,883
5,631,884
How to install mobile app on iPhone emulator
<p>I want to install iphone application on iphone emulator. Can anybody tell me , how to install it? I am a penetration tester and looking for some sample application which i can install on iPhone emulator.</p>
iphone
[8]
2,460,955
2,460,956
on click of id=checkMain i want “child”(checkboxes) to get enabled and “child1”(radio buttons) to be disabled
<p>HTML:</p> <pre><code>&lt;input type="radio" id="chkMain" name="chkMain"/&gt; &lt;input type="radio" id="chkMain1" name="chkMain" /&gt; &lt;input type="radio" id="chkMain2" name="chkMain" /&gt; &lt;input class="child" type="checkbox" id="chk1" disabled="true" /&gt; &lt;input class="child" type="checkbox" id="chk2" disabled="true" /&gt; &lt;input class="child" type="checkbox" id="chk3" disabled="true" /&gt; &lt;input class="child" type="checkbox" id="chk4" disabled="true" /&gt; &lt;input class="child" type="checkbox" id="chk5" disabled="true" /&gt; &lt;input class="child" type="checkbox" id="chk6" disabled="true" /&gt; &lt;input class="child" type="checkbox" id="chk7" disabled="true" /&gt; &lt;input class="child1" type="radio" id="tone1" disabled="true"/&gt; &lt;input class="child1" type="radio" id="tone2" disabled="true"/&gt; &lt;input class="child1" type="radio" id="tone3" disabled="true"/&gt; </code></pre> <p>Javascript:</p> <pre><code>$(function(){ $("input:radio[id=checkMain]").click(function(){ if (this.checked) { $("input:checkbox.child").removeAttr("disabled"); } else { $("input:checkbox.child, input:radio.child1").attr("disabled", "enabled"); } }); }); </code></pre> <p>when i 1st click on id=checkMain then later click on id=checkMain1 it works perfectly.but when i 1st click on id=checkMain1 then on id=checkMain i want the child1 to get disabled </p>
jquery
[5]
5,406,872
5,406,873
Change document.getElementById in Javascript
<p>Does anyone know how to change document.getElementById to something else, like $? </p> <p>It would work like this:</p> <pre><code>$("theid") </code></pre> <p>instead of this:</p> <pre><code>document.getElementById("theid") </code></pre>
javascript
[3]
4,741,032
4,741,033
instanceof with generic collection
<p>Why would the following snippet not compile ?</p> <pre><code>if (mangoList instanceof List&lt;Mango&gt;) { System.out.println("true"); } </code></pre> <ul> <li>You don't know that mangoList is a List type. </li> <li>The instanceof keyword only works on primitive types. </li> <li>You can only check the type of collections using reflection. </li> <li>Generic types are erased before runtime.(ans) </li> <li>The statement could cause mangoList to be set to an instance of a List.</li> </ul> <p>Which do you think is the correct answer ?</p>
java
[1]
2,137,487
2,137,488
how to attach a database with an assets folder?
<p>I have created one databse using query i have stored my databse in it. now when i install .apk file of that applican it shows me error so how to attach that databse in an assets folder so that my app run on actual device ?</p> <p>Tahnk you</p>
android
[4]
4,178,702
4,178,703
Attributes do not set up
<p>Why does this not work? (<em>http://jsfiddle.net/J8n2g/</em>): </p> <pre><code>$('body') .append($('&lt;img&gt;') .attr({ 'src': 'http://www.google.com/intl/en_ALL/images/logo.gif', 'width': '100%', 'height': '100%' }) .hide() .load(function() { $(this).show(); }));` </code></pre> <p>While this works well (<em>http://jsfiddle.net/J8n2g/1/</em>): </p> <pre><code>$('body') .append($('&lt;img width="100%" height="100%"&gt;') .attr({ 'src': 'http://www.google.com/intl/en_ALL/images/logo.gif' }) .hide() .load(function() { $(this).show(); })); </code></pre>
jquery
[5]
2,761,516
2,761,517
Find string of method in a file
<p>Right now I have this to find a method</p> <pre><code>def getMethod(text, a, filetype): start = a fin = a if filetype == "cs": for x in range(a, 0, -1): if text[x] == "{": start = x break for x in range(a, len(text)): if text[x] == "}": fin = x break return text[start:fin + 1] </code></pre> <p>How can I get the method the index <code>a</code> is in?</p> <p>I can't just find <code>{</code> and <code>}</code> because you can have things like <code>new { }</code> which won't work</p> <p>if I had a file with a few methods and I wanted to find what method the index of x is in then I want the body of that method for example if I had the file</p> <pre><code>private string x(){ return "x"; } private string b(){ return "b"; } private string z(){ return "z"; } private string a(){ var n = new {l = "l"}; return "a"; } </code></pre> <p>And I got the index of "a" which lets say is 100</p> <p>then I want to find the body of that method. So everything within <code>{</code> and <code>}</code></p> <p>So this...</p> <pre><code>{ var n = new {l = "l"}; return "a"; } </code></pre> <p>But using what I have now it would return:</p> <pre><code> {l = "l"}; return "a"; } </code></pre>
python
[7]
4,721,223
4,721,224
Should I always test JS in browser?
<p>I'm a JS beginner. My question is do we always need to use a browser to test JS code? Is there a command prompt compiler/interpreter avilable ?</p>
javascript
[3]
2,832,485
2,832,486
Override back button in navigation stack
<p>HI, </p> <p>How do I override the back button for just one view (not for all the back buttons present in different views) such that on click of the back button, root view controller is shown. </p>
iphone
[8]
67,880
67,881
fetching and updating data from web service
<p>Data can be fetched into an application through web service can it be possible to update data in web service from our application ..</p>
asp.net
[9]
4,088,818
4,088,819
C++ File Operations
<p>As part of an assignment, I need to read data from a binary file which consists of <code>int</code>, <code>char</code> datatypes of data. This binary file is divided into records 96 bytes each. I am trying to reading these 96 bytes into a <code>char</code> buffer and then trying to split them according to info I have. But I am getting nothing when trying to get <code>int</code> values from the buffer. Can you help me in this?</p> <pre><code>#include&lt;iostream&gt; #include&lt;fstream&gt; #include&lt;cstdio&gt; using namespace std; int main() { char buffer[100]; char *p; char temp[10]; int val; fstream ifs,ofs; ifs.open("write.bin",ios::binary); if(ifs.read(buffer,96)) { cout &lt;&lt; "READ" &lt;&lt; endl; } p = buffer; memcpy(temp,buffer,4); cout &lt;&lt; temp &lt;&lt; endl; val = atoi(temp); cout &lt;&lt; val &lt;&lt; endl; } </code></pre> <p>I used <code>strncpy</code> also in place of <code>memcpy</code>. The output is 0 for <code>val</code> and blank for <code>temp</code>.</p>
c++
[6]
1,618,100
1,618,101
Get query string only if integer
<p>Trying to get a query string into a variable but only if it's an integer.</p> <p>Code is probably a bit more complicated than it should be but this is where I'm up to-</p> <pre><code> //get page number. default is 1. check is not empty and is a number if (empty($_GET['pag'])) {$page = 1;} else if (is_int($_GET['pag'])){$page = $_GET['pag'];} else {$page = 1;} </code></pre> <p>Where am I going wrong?</p>
php
[2]
3,062,112
3,062,113
Some confusions about Command Line Compiler and MSBuild
<p>C# CSC.exe: <a href="http://msdn.microsoft.com/en-us/library/78f4aasd.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/78f4aasd.aspx</a></p> <p>If we give it a C# file, a .CS , is it able to compile it and say for example a ";" is missing at line 12 of your code? In a form that later in my program - which is Java RCP app, I can show those compile errors in a Spreadsheet </p> <p>How about MSBuild? Is that able to show compile errors same as my previous example?</p>
c#
[0]
3,451,623
3,451,624
Dataset hold only one table
<p>I fill the data set twice, </p> <p>the table name never set correctly. I see only one table in the DataSet</p> <p>What is chances?</p> <pre><code>public static DataSet GetSchoolTree() { BLLBase.CreateConnection(); BLLBase.Connection.Open(); DataSet dataSet = new DataSet("SS"); Stages.GetStages(ref dataSet); Schools.GetSchools(ref dataSet); BLLBase.Connection.Close(); dataSet.Relations.Add(dataSet.Tables["Schools"].Columns["ID"], dataSet.Tables["dbo.Stages"].Columns["School_ID"]); return dataSet; } internal static void GetSchools(ref DataSet dataSet) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.TableMappings.Add("dbo.Schools", "Schools"); SqlCommand command = new SqlCommand(); command.CommandText = "[dbo].[SR_School_ALL]"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Connection = BLLBase.Connection; adapter.SelectCommand = command; adapter.Fill(dataSet); } internal static void GetStages(ref DataSet dataSet) { SqlDataAdapter adapter = new SqlDataAdapter(); adapter.TableMappings.Add("dbo.Stages", "Stages"); SqlCommand command = new SqlCommand(); command.CommandText = "[dbo].[Stp_Stages_All]"; command.CommandType = System.Data.CommandType.StoredProcedure; command.Connection = BLLBase.Connection; adapter.SelectCommand = command; adapter.Fill(dataSet); } </code></pre> <p>thanks</p>
asp.net
[9]
1,300,441
1,300,442
Use of .on() without direct parent
<p>How would I use <code>.on()</code> in jQuery for an element that isn't a direct parent?</p> <p><code>.live()</code> would look like this</p> <pre><code>$('.home_collapsibles').find('.ui-collapsible-heading').live('tap', function (event) {}); </code></pre> <p>With elements of</p> <pre><code>&lt;div data-role="collapsible-set" class="home_collapsibles ui-collapsible-set" data-theme="c" data-inset="false"&gt; &lt;div data-role="collapsible" data-collapsed="true" data-collapsed-icon="arrow-r" data-expanded-icon="arrow-d" data-iconpos="right" class="ui-collapsible ui-collapsible-collapsed"&gt; &lt;h3 class="ui-collapsible-heading ui-collapsible-heading-collapsed"&gt;&lt;a href="#" class="ui-collapsible-heading-toggle ui-btn ui-btn-icon-right ui-btn-up-c" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="arrow-r" data-iconpos="right" data-theme="c"&gt; </code></pre> <p>Here is my JS Fiddle <a href="http://jsfiddle.net/jostster/WD6DD/" rel="nofollow">http://jsfiddle.net/jostster/WD6DD/</a></p> <p><strong>EDIT:</strong> This seems to work <a href="http://jsfiddle.net/jostster/fNNnJ/" rel="nofollow">http://jsfiddle.net/jostster/fNNnJ/</a>, However I want to limit the listener to only in the <code>.home_collapsibles</code></p>
jquery
[5]
530,464
530,465
what is wrong with this java thread program
<p>I am trying to figure out what is wrong with this thread program in java. Can anyone shed some light? Here is the code:</p> <pre><code>public class Z { private Account account = new Account(); private Thread[] thread = new Thread[100]; public static void main(String[] args) { Z test = new Z(); System.out.println("What is balance ? " + test.account.getBalance()); } public Z() { ThreadGroup g = new ThreadGroup("group"); boolean done = false; // Create and launch 100 threads for (int i = 0; i &lt; 100; i++) { thread[i] = new Thread(g, new AddAPennyThread(), "t" + i); thread[i].start(); System.out.println("depositor: " + thread[i].getName()); } // Check if all the threads are finished while (!done) if (g.activeCount() == 0) done = true; } // A thread for adding a penny to the account class AddAPennyThread extends Thread { public void run() { account.deposit(1); } } // An inner class for account class Account { private int balance = 0; public int getBalance() { return balance; } public void deposit(int amount) { int newBalance = balance + amount; balance = newBalance; } } } </code></pre> <p>It compiles and runs fine. It was a test question I missed and wnated to know what is actually wrong with it. Thanks!</p>
java
[1]
3,396,334
3,396,335
Async task - not clear re called methods
<p>I have a a service class which includes an Async task. In the doInBackground and onPostExecute I call some methods which are in the service class but outside the Async task. When these methods get called will they still be in the thread created by the Async task and therefore not interfering with the main UI.</p> <p>To illustrate my lack of understanding a bit more should I try to get almost everything that the service class does into the Async task. For example the service starts up as the result of an alarm and in the onStartCommand sets a repeating alarm (this is as Reto Meire's Earthquake example)and creates a database. Would it make sense to move the code for these two operations into the onPreExecute part of the Async task?</p>
android
[4]
687,871
687,872
FTPClient in C#
<p>I have created one FTPClient in C#.</p> <p>I have written one sendcommand method to send the command now i want customize it like if i pass any command it should send it like for example :</p> <pre><code>ftpcommand.sendCommand("PASV"); // for creating new data socket connection ftpcommand.sendCommand("NLST *"); //for returning list of files from server </code></pre> <p>where FTPcommand is my class name.</p> <p>MY send method is :</p> <pre><code>public void sendCommand(String command) { Byte[] cmdBytes = Encoding.ASCII.GetBytes((command + "\r\n").ToCharArray()); clientSocket.Send(cmdBytes, cmdBytes.Length, 0); readResponse(); } public void readResponse() { this.message = ""; this.result = readLine(); if (this.result.Length &gt; 3) this.resultCode = int.Parse(this.result.Substring(0, 3)); else this.result = null; } public string readLine() { while (true) { this.bytes = clientSocket.Receive(this.buffer, this.buffer.Length, 0); this.message += ASCII.GetString(this.buffer, 0, this.bytes); if (this.bytes &lt; this.buffer.Length) { break; } } string[] msg = this.message.Split('\n'); if (this.message.Length &gt; 2) this.message = msg[msg.Length - 2]; else this.message = msg[0]; if (this.message.Length &gt; 4 &amp;&amp; !this.message.Substring(3, 1).Equals(" ")) return this.readLine(); return message; } </code></pre>
c#
[0]
2,880,423
2,880,424
A application with password
<p>How can Write and Create Safer Windows Applications with lock key in C#?</p>
c#
[0]
1,472,160
1,472,161
What does the C# compiler mean when it prints "an explicit conversion exists"?
<p>If I make an empty test class:</p> <pre><code>public class Foo { } </code></pre> <p>And I try to compile code with this statement:</p> <pre><code>Foo foo = "test"; </code></pre> <p>Then I get this error as expected:</p> <blockquote> <p>Cannot implicitly convert type 'string' to 'ConsoleApplication1.Foo'</p> </blockquote> <p>However, if I change the declaration of <code>Foo</code> from class to interface, the error changes to this (emphasis mine):</p> <blockquote> <p>Cannot implicitly convert type 'string' to 'ConsoleApplication1.Foo'. <strong>An explicit conversion exists</strong> (are you missing a cast?)</p> </blockquote> <p>What is this "explicit conversion" which is supposed to exist?</p> <p><strong>update</strong>: the issue is a bit more subtle than I initially thought. To reproduce it, put this code in a new console application in Visual Studio 2008:</p> <pre><code>namespace ConsoleApplication1 { class Foo { } interface IFoo { } class Program { static void Main(string[] args) { Foo b = "hello"; } } } </code></pre> <p>Visual studio will automatically show the correct error at this point (before you build the code). Now insert the "I" to turn "Foo" into "IFoo" and <strong>wait a few seconds without building</strong>. The "explicit conversion exists" version of the error will now appear automatically in the error output window and in the tool tip for the assignment error.</p> <p>The erroneous error then <strong>disappears again when you explicitly hit F6 to build</strong>.</p>
c#
[0]
3,173,142
3,173,143
iPhone: Date conversion issues
<p>I need to check an event date, which should be between Current date and 60 days from now. The below code is used, but it is NOT working correctly. Please note, i'm getting event string like this - "2012-04-14T16:50:02Z" from my server.</p> <pre><code>// current date double currDateInMilliSecs = [NSDate timeIntervalSinceReferenceDate] * 1000; NSLog(@"currDateInMilliSecs: %f", currDateInMilliSecs); // sixty days double sixtydaysvalue = 60.0 * 24.0 * 3600.0 * 1000.0; NSLog(@"sixtydaysvalue: %f", sixtydaysvalue); // add current date + sixt days double sixtyDaysMilliSecsFromCurrDate = currDateInMilliSecs + sixtydaysvalue; NSLog(@"sixtyDaysMilliSecsFromCurrDate: %f", sixtyDaysMilliSecsFromCurrDate); // check does the event date between current date + 60 days NSDateFormatter *df = [[NSDateFormatter alloc] init]; //[df setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"]; //[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; // [eventDict objectForKey:@"begin_at"] gives date string like this "2012-04-14T16:50:02Z" for ex. NSDate *eventdate = [df dateFromString:[eventDict objectForKey:@"begin_at"]]; NSTimeInterval nowSinceEventDate = [eventdate timeIntervalSince1970]; NSLog(@"nowSinceEventDate: %f", nowSinceEventDate); double eventDateInMilliSecs = nowSinceEventDate * 1000; NSLog(@"eventDateInMilliSecs: %f", eventDateInMilliSecs); // this is not working as expected if ( eventDateInMilliSecs&lt;sixtyDaysMilliSecsFromCurrDate &amp;&amp; eventDateInMilliSecs&gt;currDateInMilliSecs ) { } else { } </code></pre> <p>Any help please?</p>
iphone
[8]
4,370,307
4,370,308
Get attribute of newly created element
<p>I'm trying to get the <code>src</code> attribute of an image that has been added to the page after it has loaded, but the result keeps coming back <code>undefined</code>.</p> <pre><code>$('#qtr').change(function() { data = { 'img': $('#edit_image').attr('src'), 'degrees': '90' }; $.post('/ajax/ajax_images/rotate', data, function(response) { if (response.error != 0) { alert('Unable to rotate image'); } else { $('#edit_image').attr('src', response.html); new_image = response.html; var start = new_image.lastIndexOf('/') + 1; new_image = new_image.substr(start); } }, 'json'); });​ </code></pre> <p><code>$('#edit_image')</code> is the newly created image. Where am I going wrong?</p>
jquery
[5]
2,431,210
2,431,211
Android Development: Webview progress Bar
<p>Take a look at: <a href="http://groups.google.com/group/android-beginners/msg/61802d28a8335809" rel="nofollow">http://groups.google.com/group/android-beginners/msg/61802d28a8335809</a></p> <p>ive done that a got it to work but the progress does not change when clicking on a link in the webbrowser.</p> <p>So the progressbar is showed when the app starts and load the home URL but when i click a link or search in google the bar is not showed. why?</p> <p>Thank-you!</p>
android
[4]
2,551,482
2,551,483
Cmparing string elements stored in ArrayList
<p>I have a string arraylist ArrayList data = new ArrayList();</p> <p>and I have stored string values inside. Now i want to do something like</p> <p>data.get(0) == "a" (need to compare)</p> <p>How can I do? please help out.</p>
java
[1]
4,227,664
4,227,665
I developed a website. I want to know where to give the start up page URL
<p>I have one doubt. I developed a website using entity framework.</p> <p>I want to know where to give the <code>URL</code> for <code>login page</code>?? My start up page is my <strong>login page</strong> </p> <p>I want to know how to give the default page URL.</p> <p>Thanks in advance</p>
asp.net
[9]
1,350,460
1,350,461
Java compare two map
<p>In java, I want to compare two maps, like below, do we have existing API to do this ?</p> <p>Thanks</p> <pre><code>Map&lt;String, String&gt; beforeMap ; beforeMap.put("a", "1"); beforeMap.put("b", "2"); beforeMap.put("c", "3"); Map&lt;String, String&gt; afterMap ; afterMap.put("a", "1"); afterMap.put("c", "333"); //--- it should give me: b is missing, c value changed from '3' to '333' </code></pre>
java
[1]
281,826
281,827
write a file in php
<p>This function fetches the records from the db. Now I want it to write them to a file. Please help me. </p> <pre><code>function selectcsv($classname) { echo $sql = "SELECT * FROM tblstuden WHERE classname = $classname;"; $obj_db = new DB(); $obj_db-&gt;query($sql); while($row = $obj_db-&gt;rsset()){ $this-&gt;_id($row[id]); $this-&gt;_studentname($row[studentname]); $this-&gt;_rollnumber($row[rollnumber]); $this-&gt;_classname($row[classname]); $out = $out . $row[studentname] . " , ". $row[rollnumber] . "\n"; } $obj_db-&gt;db_close(); </code></pre> <p>The above portion is running</p> <pre><code>$myFile = "write.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = "write::"; fwrite($fh, $stringData); $stringData = $_POST[read]; fwrite($fh, $stringData); fclose($fh); </code></pre>
php
[2]
4,249,461
4,249,462
How to generate avi video from images?
<p>I need to create a video from text input. I have successfully generated image from text input.</p> <p>Now i need to generate a video of avi format from the above created image.</p> <p>How can i do this?</p>
java
[1]
4,544,624
4,544,625
jQuery search val() in multiple textboxes
<p>What's the most efficient way to loop though all textboxes for searching for a specific value and not using <code>each()</code>?</p>
jquery
[5]
1,787,416
1,787,417
What is the correct syntax for the code
<pre><code>&lt;input type="radio" name="rdbtnques1"&gt; &lt;input type="radio" name="rdbtnques2"&gt; </code></pre> <p>//php code</p> <pre><code>for($i=0;$i&lt;count($_POST['txt']);$i++) { echo $chk = $_POST['rdbtnques.$i']; } </code></pre> <p>I want to know the correct syntax for the above code</p>
php
[2]
5,269,434
5,269,435
How can i read md5 from this file
<p>Ok so first, i have it writing to the file..</p> <pre><code>string line1, line2, line3, line4, line5, line6, line7, line8, line9, line10; // step 1, calculate MD5 hash from input MD5 md5 = System.Security.Cryptography.MD5.Create(); byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(Password); byte[] hash = md5.ComputeHash(inputBytes); // step 2, convert byte array to hex string StringBuilder sb = new StringBuilder(); for (int i = 0; i &lt; hash.Length; i++) { sb.Append(hash[i].ToString("X2")); } using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(Username); sw.WriteLine(sb.ToString()); } </code></pre> <p>Then. how can i make it so it can be read from the file? As normal text. Not the encrypted form</p>
c#
[0]
5,532,772
5,532,773
killBackgroundProcesses does not work on SETTINGS?
<p>I want to kill the background process of SETTINGS by using killBackgroundProcesses. But it does not work without any errors? I use API(8) level 2.2 and having KILL_BACKGROUND_PROCESSES permission in manifest.</p> <pre><code> ActivityManager activityManager = (ActivityManager)getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE); activityManager.killBackgroundProcesses("com.android.settings"); </code></pre> <p>"com.android.settings" is checked by getPackageName of getRunningTasks in ActivityManager.</p>
android
[4]
9,343
9,344
PHP echo code not returning '0' if no results
<p>Here is the query:</p> <pre><code>$query = "SELECT name,deleted,COUNT(message) as message FROM guestbook_message WHERE name='".$name."' AND deleted=1 GROUP BY name"; $result = mysql_query($query) or die(mysql_error()); $deletedtotal_row = mysql_fetch_array($result); </code></pre> <p>Here when I use it:</p> <pre><code>echo "You have had ".($deletedtotal_row['deleted']) ? $deletedtotal_row['deleted'] : '0'." messages deleted"; </code></pre> <p>This errors, doesn't show an syntax error, but doesn't display any results.</p> <p>But when I use:</p> <pre><code>echo ".$totaldeleted_row['deleted']."; </code></pre> <p>It works fine. But if there is no messages deleted for that user, it returns nothing, but I want it to display '0'.</p> <p>Any ideas where I'm going wrong?</p>
php
[2]
3,182,291
3,182,292
Chrome extension to find links on a page: Passing values between two js files
<p>I am making a chrome extension to catch links from a page and display in the popup of the extension. I use two javascript files, popup.js, toInject.js. The code of the two files:-</p> <p>popup.js:</p> <pre><code> chrome.tabs.executeScript(null,{file:"toInject.js"}); </code></pre> <p>toInject.js:</p> <pre><code>var linkTarget; findLinks() { var links=document.getElementByTagName('a'); for(var i=0;i&lt;links.length;i++) { linkTarget=links[i].getAttribute('links'); } } findLinks; </code></pre> <p>Now what i am trying is to get the links from toInject.js to popup.js ... How can i pass the values between these two js files? </p>
javascript
[3]
3,810,855
3,810,856
Canvas keep ignoring Paint in drawBitmap method
<p>I would like to draw bitmap(with specified color) on canvas.</p> <pre><code> Paint paint = new Paint(); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.RED); // create bitmap canvas.drawBitmap(bitmap, 0, 0, paint); </code></pre> <p>Well, the bitmap is visible on the canvas, but color of drawable didn't change. Where is the problem?</p>
android
[4]
4,575,678
4,575,679
invoke javascript
<p>I need to retrieve a value from the javascript below in my html code and inject this value into a webbrowser. how can I format and invoke this script ?</p> <pre><code>$(function() { jQuery.liveviewWithTable( { enableCountsTable:false, enableCountTable:true, countTableElement:$("#count"), directionIn:$.getParam("Counter.DirectionIn"), liveSumUrl:"/local/people-counter/.api?live-sum.json", loadingAnimationUrl:"/people-counter/images/ajax-loader.gif", dataTypes:["in","out"] }) }); </code></pre> <p>Thanks alot</p>
javascript
[3]
5,946,215
5,946,216
Android dynamic icon in listview
<p>I have a ListActivity in my application. The list is populated from a parsed http response in the form of an ArrayList of hashmaps.</p> <pre>final ArrayList&lt;HashMap&lt;String,String>> LIST = new ArrayList&lt;HashMap&lt;String,String>>(); ... SimpleAdapter adapter = new SimpleAdapter(this, LIST, R.layout.item_row, new String[]{"author","title"}, new int[]{R.id.text1,R.id.text2}); setListAdapter(adapter); ... for(Element src : lists){ String title = src.select(); String author = src.select(); HashMap&lt;String,String> temp = new HashMap&lt;String,String>(); temp.put("author", author); temp.put("title", title); LIST.add(temp); } </pre> <p>Where author and title are correctly derived from the parsed http.</p> <p>In the R.layout.item_row XML file I have defined a drawable for text2:</p> <pre>android:drawableLeft="@drawable/default_icon"</pre> <p>And i would like to be able to change that icon to "new_icon" on a given row if the hashmap contains a certain string.</p> <p>For instance, within the for loop above, I would add something like:</p> <pre> String status = src.select(); String icon = "default"; if(status.contains("test")){ icon = "should_change"; } temp.put("icon", icon); ...etc </pre> <p>I'm leaving out the specific logic for brevity, but I am able to correctly pass whether the icon should change or not as a string value back to the adapter, however, I am not sure how to then actually change the icon.</p> <p>I am not experienced with either Java or Android so I am quite likely approaching this backwards.</p> <p>Any help would be great.</p>
android
[4]
2,268,626
2,268,627
Creating protruding button from tab bar on iOS
<p>I've seen a couple of apps that have 1 button in what looks like a UITabBar protruding outside the frame.</p> <p>How does one go about doing something like this? Code samples/tutorial suggestions to read would be much appreciated.</p> <p>Here's a photo from one the apps I've seen this in.</p> <p><img src="http://i.stack.imgur.com/Q6Hyu.png" alt="enter image description here"></p>
iphone
[8]
5,039,403
5,039,404
use jquery to get index of element in parsed html result set
<p>it appears that</p> <pre><code>$(html).find('*').index('#theID'); </code></pre> <p>yields -1 whereas</p> <pre><code>$(html).find('*').each(function(ind){if(this.id=='theID') alert('found! @'+ind) } ); </code></pre> <p>does work (alerting 229)</p> <p>I am using <strong>Windows 7</strong> with <strong>IE 8</strong> and <strong>jquery 1.6.1</strong></p> <p>My question is, why doesn't the first one work? Thanks.</p>
jquery
[5]
170,494
170,495
How to set a font for the Options menu?
<p>When I create an Options Menu the items seem to default to the native "sans" font. When I look at commercial apps they mostly seem to do the same thing. Is it possible to set the font size, color weight or typeface for Option Menu items?</p> <p>Thanks in advance.</p>
android
[4]
4,542,787
4,542,788
How to append to a text file in android?
<pre><code>FileWriter f; try { f = new FileWriter(Environment.getExternalStorageDirectory()+ "/Text/o1"+".txt"); f.write("Hello World"); f.flush(); f.close(); } </code></pre> <p>I can create a file and write to it using the above code. How do i append to the text file without over writing it? thanks</p>
android
[4]
4,806,460
4,806,461
PHP: Split header into spans
<p>I have a simple content rotator that displays text like so:</p> <pre><code>&lt;h4&gt;&lt;span&gt;Featured Article&lt;/span&gt;&lt;/h4&gt; &lt;h2&gt;&lt;span&gt;Lorem ipsum dolor sit amet,&lt;/span&gt; &lt;span&gt;consectetur adipisicing elit&lt;/span&gt;&lt;/h2&gt; &lt;span class="author"&gt;by Cameron Drysdale&lt;/span&gt; </code></pre> <p>As you can see the h2 has it's text split up into <code>&lt;span&gt;</code> tags. This is so I can achieve the following effect as seen here on the pink box: <a href="http://www.paperviewmagazine.com/" rel="nofollow">http://www.paperviewmagazine.com/</a></p> <p>The problem is how to do this automatically as the header will be generated from a database and will not have the span tags by default. Any ideas on how I could use PHP to add in some tags to wrap certain parts of a title?</p> <p><strong>EDIT: I'm using WordPress and so the title would be shown like <code>&lt;?php the_title(); ?&gt;</code> and I'd probably want to split the text after x number of characters</strong></p> <p><strong>EDIT2: I should note that the idea is to split the content using span tags so this could also be a possibility: <code>&lt;span&gt;this is&lt;/span&gt; &lt;span&gt;some text&lt;/span&gt; &lt;span&gt;I'm sharing&lt;/span&gt;</code></strong></p>
php
[2]
5,467,735
5,467,736
Instead of error, why don't both operands get promoted to float or double?
<p>1) If one operand is of type <code>ulong</code>, while the other operand is of type <code>sbyte/short/int/long</code>, then compile-time error occurs. I fail to see the logic in this. Thus, why would it be bad idea for both operands to instead be promoted to type <code>double</code> or <code>float</code>?</p> <pre><code> long L = 100; ulong UL = 1000; double d = L + UL; // error saying + operator can't be applied to operands of type ulong and long </code></pre> <p>b) Compiler implicitly converts <code>int</code> literal into <code>byte</code> type and assigns resulting value to <code>b</code>:</p> <pre><code>byte b = 1; </code></pre> <p>But if we try to assign a literal of type <code>ulong</code> to type <code>long</code>(or to types <code>int</code>, <code>byte</code> etc), then compiler reports an error:</p> <pre><code>long L = 1000UL; </code></pre> <p>I would think compiler would be able to figure out whether result of constant expression could fit into variable of type <code>long</code>?! </p> <p>thank you</p>
c#
[0]
801,586
801,587
Making shapes from user input
<p>The program should get two numbers from the user. The first number is the amount of triangles. The second number is the amount of rows per triangle. </p> <p>It's based off a square problem we just did which is</p> <pre><code>numRows = input('Please enter the number of rows: ') numRows = eval(numRows) numAst = 1 for i in range(numRows): print(numAst*'*') numAst += 1 </code></pre> <p>I can not for the life of me figure out how to get it to make triangles though. I know I need some sort of outside loop to restart the inner loop, but I'm not sure how to go about that?</p>
python
[7]
4,280,402
4,280,403
How to remove return url in asp.net membership
<p>I am using asp.net membership and I got some code from code plex on loin page that is common to all role members I am doing following code:</p> <pre><code>protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { //some code missing below is to identify role and then redirecting to appropriate default page else { // Next, determine if the user's username/password are valid if (Membership.ValidateUser(loginUsername, loginPassword)) { e.Authenticated = true; string[] userRoles = Roles.GetRolesForUser(loginUsername); switch (userRoles[0]) { case "Administrator": Login1.DestinationPageUrl = "~/Admin/Default.aspx"; break; case "Member": Login1.DestinationPageUrl = "~/Members/Default.aspx"; break; } } } </code></pre> <p>But when I log out, it logs out properly, redirecting me to the log out page but attached a return url:</p> <pre><code>http://localhost:52045/NexLev/login.aspx?ReturnUrl=%2fNexLev%2fMembers%2fDefault.aspx </code></pre> <p>So if first time a member log ins then it takes to correct page then if it log out then the above url apear on log out page, but next time if an admin logs in then it take to the LoginView logged in template kept on the same log in page instead of taking it to the default page of admin.</p> <p>Could some body suggest how to overcome with this problem? Or should I apply a different approach to redirect according to user roles.</p>
asp.net
[9]
3,455,020
3,455,021
Benefits of using "const" with scalar type? (e.g. "const double" or "const int")
<pre><code>/////////////////////////////////////// class A { ... const double funA(void) {...} }; A a; double x = a.funA(); // although the intention is to // enforce the return value to be const and cannot be // modified, it has little effect in the real world. class A2 { ... double funB(void) {...} }; /////////////////////////////////////// class A { void setA(const double d) { // now you cannot change the value of d, so what? // From my point of view, it is NOT a good practice to change the pass-in parameter // in this case, unless you want the caller to receive that change // instead, you can do // const double dPassIn = d; / /then use dPassIn instead. ... } }; class A2 { void setB(double d) {...} }; ////////////////////////////////////// </code></pre> <p>From my understanding, we should prefer to using <code>A2::funB</code> and <code>A2::setB</code> because the <strong>const</strong> used in both <code>A::funA</code> and <code>A::setA</code> has little meaning.</p> <p>// Update //</p> <pre><code> FMOD_RESULT F_API EventSystem::getReverbPresetByIndex(const int index, FMOD_REVERB_PROPERTIES *props, char **name = 0); </code></pre> <p>I consider FMOD is a well-designed package and it does use <code>const int</code> inside function parameter list. Now, I agree that the <code>A::setA(const double d)</code> has its edge.</p>
c++
[6]
2,700,143
2,700,144
Is there a std::bitset equivalent (or similar) in Java?
<p>I am looking for a c++ std::bitset equivalent or a similar functionality implementation in Java (1.6 specifically). I tried java.util.BitSet but I am finding that it is not quite similar.</p> <p>The operations I need are the usual bitwise operations such as AND, OR, etc. If possible, I'd like to be able to set the length of the bitset dynamically (which is unsupported in std::bitset). Can anyone provide a recommendation? Thanks.</p>
java
[1]
3,841,271
3,841,272
Using php how to send push notification such as an alert to an ios device
<p>I have an app which is capable of chatting and sending friend requests. I want to send an alert or push message to the device registered in my user table, when ever a new message is sent to friend a push must be sent to the user...same way if a friend request is sent a push alert must be sent. I am storing the device token in my users table for every user.. --apns-push.pem file is ready actually i would like to give a json web service Please help, Thanks in advance.... </p>
php
[2]
4,431,155
4,431,156
Debugging ASP.NET without code-behind file
<p>I was wondering how does any interface with database been done without using code behind e.g. C# or VB in ASP.NET?</p> <p>Actually I am trying to debug an application which require further update / enhancement, but it seems that the aspx page does not have and .cs or .vb file. In the header, only mention Inherits some kind of function like "user_changepass", but when I using search function in VS (for whole solution), I could not find particular function, to edit/understand better.</p> <p>In the folder also only contains JS script, CSS files, images, config file etc. Nothing about the query script etc.</p> <p>Hoping for some ideas to shed the light on. Thanks!</p>
asp.net
[9]
3,175,031
3,175,032
Android: Can background Activities execute code?
<p>Are Activities in the background considered "running" (and can execute code) or are they in a suspended state?</p>
android
[4]
2,367,134
2,367,135
Basic question about objects and instances
<p>I have a Class named Group, it is described as follow:</p> <pre><code>public class Group{ public int identifier; public int[] members; public String name; } </code></pre> <p>Now, I would like to create many different objects for this class, I mean for example 1000 groups each one has different number of members,</p> <p>How can make it? I mean I would not make 1000 instructions like: </p> <pre><code>Group g1= new Group(....); </code></pre> <p>Thanks and best regards.</p>
java
[1]
293,018
293,019
function.prototype.bind not working in FF on Windows only
<p>I can't find this question being asked anywhere, so I figured I'd ask here. I have the following code, which as far as I know, is totally valid JavaScript. It works just fine in FF on Linux, but FF on Windows says that function.prototype.bind is not a function.</p> <p>doesn't work</p> <pre><code> this.form .submit(function(e) {function(e) { e.preventDefault(); this._videoForm_onSubmit(e); }.bind(this)); </code></pre> <p>does work</p> <pre><code> var _onFormSubmit = function(e) { e.preventDefault(); this._videoForm_onSubmit(e); }; this.form .submit(function(e) { _onFormSubmit.call(this, e); }); </code></pre> <p>What gives?</p> <p>** Edit/Answer **</p> <p>So, I've probably just been doing too much server-side JS, since Function.prototype.bind appears to have been introduced in 1.8.5 [1]</p> <p>Instead of the code that I was using before, I just sent the current context object as an argument to a self-executing anonymous function, as shown below.</p> <pre><code> (function(myObject) { myObject.form .submit(function(e) { e.preventDefault(); myObject._videoForm_onSubmit(e); }); })(this); </code></pre> <p>[1] <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind" rel="nofollow">https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind</a></p>
javascript
[3]
1,639,009
1,639,010
Find song files on the device?
<p>Is there a way to discover all song files on the device? I basically want to make a list of them to show to the user (don't need to play them or anything).</p> <p>I'm searching for "android sdk + song file discovery" and the like but not seeing anything related to programatically finding song files on the device.</p> <p>Thanks </p>
android
[4]
3,300,324
3,300,325
Dismiss some views
<p>First, sorry about my English, I know it's bad, but I'm trying to make it better... Here is the issue: I'm making an app, with a view controller, with a lot of views... I want to make a button to go back to the main one. I think I have to dismiss the views I pushed. I dont know if that is necessary or if I can push it again directly. If it is, how can I do that? I've tried to put a dismiss method after the presentModalViewController one, but it didn't work. Any help? Thank you so much for your help ;)</p>
iphone
[8]
1,963,790
1,963,791
How to reset the value of the dropdownlist after choosing a value for filtering the GridView?
<p>I used this <a href="http://csharpdotnetfreak.blogspot.com/2011/04/gridview-filterexpression-dropdownlist.html" rel="nofollow">example</a> to create a GridView with DropDownList for filtering the content of the GridView. </p> <p>Everything works well but when I refresh the page the dropdownlist keeps the same value that I chose before refreshing the page. I don't know why. Could anyone help me and tell me why this is happened?</p>
asp.net
[9]
4,339,774
4,339,775
Switch button - disable swipe function
<p>I have a <code>switch</code> button (actually is a custom one) and I want to disable the swipe functionality for some reason; I want the user to be able to click it only. Is there a way to achieve this? Thanks.</p>
android
[4]